available weight values are bound.

rest settings are not bound, although syntax looks ok so far
This commit is contained in:
Tommy Dorsey 2017-04-19 06:53:07 -04:00
Родитель bb85c85ba2
Коммит c770702202
3 изменённых файлов: 65 добавлений и 10 удалений

Просмотреть файл

@ -10,7 +10,7 @@ class WeightsCtrl {
weights: any[];
constructor(
public Weights: Services.IWeightsService
) {
) {
this.weights = Weights.all();
}
remove(weight) {
@ -28,17 +28,15 @@ class WeightDetailCtrl {
constructor(
public Weights: Services.IWeightsService,
public $stateParams: IStateParams
) {
) {
this.weight = Weights.get($stateParams.weightId);
}
}
class SettingsCtrl {
settings: Object;
constructor() {
this.settings = {
enableFriends: true
};
constructor(public Settings: Services.IUserSettings) {
this.settings = Settings;
}
}

Просмотреть файл

@ -13,6 +13,54 @@ module Services {
face: String;
}
export interface IExercise {
id: Number;
name: String;
workingWeight: Number;
warmupWeight: Number;
workingSets: Number;
warmupSets: Number;
maxWeight: Number;
reps: Number;
}
export interface ISession {
id: Number;
date: Date;
exercises: Array<IExercise>;
}
export interface IUserSettings {
restPerExercise: Number;
restPerSet: Number;
availableWeights: Array<WeightValue>;
}
export class WeightValue {
constructor(public weight: Number, public enabled: Boolean) {
this.weight = weight;
this.enabled = enabled;
}
}
export class UserSettings implements IUserSettings {
restPerExercise: 180;
restPerSet: 90;
availableWeights: Array<WeightValue>
constructor() {
this.availableWeights = [];
this.restPerExercise = 180;
this.restPerSet = 90;
let defaultWeightValues = [2.5, 5, 10, 15, 25, 35, 45];
for (let val in defaultWeightValues) {
this.availableWeights.push(new WeightValue(defaultWeightValues[val], true));
}
}
}
export class Weights implements IWeightsService {
weights: Array<IWeightUser>;
constructor() {
@ -62,5 +110,5 @@ module Services {
}
angular.module('starter.services', [])
.service('Settings', Services.UserSettings)
.service('Weights', Services.Weights);

Просмотреть файл

@ -1,9 +1,18 @@
<ion-view view-title="Settings">
<ion-content>
<ion-list>
<ion-toggle ng-model="Settings.settings.enableFriends">
Enable Friends
</ion-toggle>
<ion-label color="primary">Rest Time Per Exercise (s)</ion-label>
<ion-input type="text" ngModel="Settings.settings.restPerExercise" >
<ion-label color="primary">Rest Time Per Set (s)</ion-label>
<ion-input type="number" ng-model="Settings.settings.restPerSet">
<ion-list>
<ion-list-header>
Available Weights
</ion-list-header>
<ion-item ng-repeat="weight in Settings.settings.availableWeights">
<ion-label>{{weight.weight}}</ion-label>
<ion-checkbox ng-checked="{{weight.enabled}}"></ion-checkbox>
</ion-list>
</ion-list>
</ion-content>
</ion-view>