incyclist-services 1.7.104 → 1.7.105
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/workouts/base/model/Workout.js +4 -0
- package/lib/cjs/workouts/base/parsers/incyclist/Json.js +1 -1
- package/lib/cjs/workouts/base/parsers/intervals/parser.js +1 -1
- package/lib/cjs/workouts/base/parsers/zwo/zwo.js +1 -1
- package/lib/cjs/workouts/list/cards/WorkoutCard.js +10 -1
- package/lib/cjs/workouts/list/service.js +4 -1
- package/lib/esm/workouts/base/model/Workout.js +4 -0
- package/lib/esm/workouts/base/parsers/incyclist/Json.js +1 -1
- package/lib/esm/workouts/base/parsers/intervals/parser.js +1 -1
- package/lib/esm/workouts/base/parsers/zwo/zwo.js +1 -1
- package/lib/esm/workouts/list/cards/WorkoutCard.js +10 -1
- package/lib/esm/workouts/list/service.js +4 -1
- package/lib/types/workouts/base/model/Workout.d.ts +2 -0
- package/lib/types/workouts/base/model/types.d.ts +2 -0
- package/lib/types/workouts/list/cards/WorkoutCard.d.ts +1 -0
- package/package.json +1 -1
|
@@ -11,6 +11,8 @@ class Workout extends Segment_1.Segment {
|
|
|
11
11
|
name;
|
|
12
12
|
description;
|
|
13
13
|
category;
|
|
14
|
+
isLocal;
|
|
15
|
+
isDeleted;
|
|
14
16
|
explicitId;
|
|
15
17
|
constructor(opts) {
|
|
16
18
|
super(opts, true);
|
|
@@ -21,6 +23,8 @@ class Workout extends Segment_1.Segment {
|
|
|
21
23
|
this.repeat = 1;
|
|
22
24
|
this.type = 'workout';
|
|
23
25
|
this.category = opts.category;
|
|
26
|
+
this.isLocal = opts.isLocal;
|
|
27
|
+
this.isDeleted = opts.isDeleted;
|
|
24
28
|
this.steps = [];
|
|
25
29
|
this.start = this.end = this.duration = 0;
|
|
26
30
|
opts.steps?.forEach(s => {
|
|
@@ -17,7 +17,7 @@ class JsonParser {
|
|
|
17
17
|
const str = await this.getData(file, data);
|
|
18
18
|
const parsedData = JSON.parse(str);
|
|
19
19
|
const { name, description, category, steps, type = 'workout' } = parsedData;
|
|
20
|
-
const workout = new Workout_1.Workout({ type, name, description, category });
|
|
20
|
+
const workout = new Workout_1.Workout({ type, name, description, category, isLocal: true });
|
|
21
21
|
steps.forEach(step => {
|
|
22
22
|
if (step.type === 'step') {
|
|
23
23
|
workout.addStep(step);
|
|
@@ -77,7 +77,7 @@ let IntervalsJsonParser = (() => {
|
|
|
77
77
|
}
|
|
78
78
|
fromJSON(data, fileName) {
|
|
79
79
|
const name = fileName?.replace(/\.json$/i, '');
|
|
80
|
-
const workout = new model_1.Workout({ type: 'workout', name, description: data.description });
|
|
80
|
+
const workout = new model_1.Workout({ type: 'workout', name, description: data.description, isLocal: true });
|
|
81
81
|
data.steps.forEach(s => {
|
|
82
82
|
if (s.reps !== undefined && s.reps !== null) {
|
|
83
83
|
const segment = this.convertSegment(s, data);
|
|
@@ -46,7 +46,7 @@ class ZwoParser {
|
|
|
46
46
|
xml.expectScheme('workout_file');
|
|
47
47
|
const name = (0, utils_1.ignoreEmpty)(xml.json['name']) ?? fileName;
|
|
48
48
|
const description = (0, utils_1.ignoreEmpty)(xml.json['description']);
|
|
49
|
-
const workout = new Workout_1.Workout({ type: 'workout', name, description });
|
|
49
|
+
const workout = new Workout_1.Workout({ type: 'workout', name, description, isLocal: true });
|
|
50
50
|
return this.parse(str, workout);
|
|
51
51
|
}
|
|
52
52
|
supportsExtension(extension) {
|
|
@@ -133,6 +133,10 @@ let WorkoutCard = (() => {
|
|
|
133
133
|
this.logError(err, 'save');
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
+
async markDeleted() {
|
|
137
|
+
this.workout.isDeleted = true;
|
|
138
|
+
await this.getRepo().save(this.workout, true);
|
|
139
|
+
}
|
|
136
140
|
delete() {
|
|
137
141
|
try {
|
|
138
142
|
const service = this.getWorkoutList();
|
|
@@ -206,7 +210,12 @@ let WorkoutCard = (() => {
|
|
|
206
210
|
let deleted;
|
|
207
211
|
try {
|
|
208
212
|
this.deleteObserver.emit('started');
|
|
209
|
-
|
|
213
|
+
if (this.workout.isLocal) {
|
|
214
|
+
await this.getRepo().delete(this.workout);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
await this.markDeleted();
|
|
218
|
+
}
|
|
210
219
|
this.deleteFromUIList();
|
|
211
220
|
this.getWorkoutList().emitLists('updated');
|
|
212
221
|
deleted = true;
|
|
@@ -539,6 +539,10 @@ let WorkoutListService = (() => {
|
|
|
539
539
|
});
|
|
540
540
|
}
|
|
541
541
|
addItem(item) {
|
|
542
|
+
this.items.push(item);
|
|
543
|
+
if (item.isDeleted) {
|
|
544
|
+
return undefined;
|
|
545
|
+
}
|
|
542
546
|
const list = this.selectList(item);
|
|
543
547
|
let card;
|
|
544
548
|
if (item.type === 'workout') {
|
|
@@ -548,7 +552,6 @@ let WorkoutListService = (() => {
|
|
|
548
552
|
}
|
|
549
553
|
list.add(card);
|
|
550
554
|
card.enableDelete(true);
|
|
551
|
-
this.items.push(item);
|
|
552
555
|
this.emitLists('updated');
|
|
553
556
|
return card;
|
|
554
557
|
}
|
|
@@ -8,6 +8,8 @@ export class Workout extends Segment {
|
|
|
8
8
|
name;
|
|
9
9
|
description;
|
|
10
10
|
category;
|
|
11
|
+
isLocal;
|
|
12
|
+
isDeleted;
|
|
11
13
|
explicitId;
|
|
12
14
|
constructor(opts) {
|
|
13
15
|
super(opts, true);
|
|
@@ -18,6 +20,8 @@ export class Workout extends Segment {
|
|
|
18
20
|
this.repeat = 1;
|
|
19
21
|
this.type = 'workout';
|
|
20
22
|
this.category = opts.category;
|
|
23
|
+
this.isLocal = opts.isLocal;
|
|
24
|
+
this.isDeleted = opts.isDeleted;
|
|
21
25
|
this.steps = [];
|
|
22
26
|
this.start = this.end = this.duration = 0;
|
|
23
27
|
opts.steps?.forEach(s => {
|
|
@@ -14,7 +14,7 @@ export class JsonParser {
|
|
|
14
14
|
const str = await this.getData(file, data);
|
|
15
15
|
const parsedData = JSON.parse(str);
|
|
16
16
|
const { name, description, category, steps, type = 'workout' } = parsedData;
|
|
17
|
-
const workout = new Workout({ type, name, description, category });
|
|
17
|
+
const workout = new Workout({ type, name, description, category, isLocal: true });
|
|
18
18
|
steps.forEach(step => {
|
|
19
19
|
if (step.type === 'step') {
|
|
20
20
|
workout.addStep(step);
|
|
@@ -74,7 +74,7 @@ let IntervalsJsonParser = (() => {
|
|
|
74
74
|
}
|
|
75
75
|
fromJSON(data, fileName) {
|
|
76
76
|
const name = fileName?.replace(/\.json$/i, '');
|
|
77
|
-
const workout = new Workout({ type: 'workout', name, description: data.description });
|
|
77
|
+
const workout = new Workout({ type: 'workout', name, description: data.description, isLocal: true });
|
|
78
78
|
data.steps.forEach(s => {
|
|
79
79
|
if (s.reps !== undefined && s.reps !== null) {
|
|
80
80
|
const segment = this.convertSegment(s, data);
|
|
@@ -40,7 +40,7 @@ export class ZwoParser {
|
|
|
40
40
|
xml.expectScheme('workout_file');
|
|
41
41
|
const name = ignoreEmpty(xml.json['name']) ?? fileName;
|
|
42
42
|
const description = ignoreEmpty(xml.json['description']);
|
|
43
|
-
const workout = new Workout({ type: 'workout', name, description });
|
|
43
|
+
const workout = new Workout({ type: 'workout', name, description, isLocal: true });
|
|
44
44
|
return this.parse(str, workout);
|
|
45
45
|
}
|
|
46
46
|
supportsExtension(extension) {
|
|
@@ -130,6 +130,10 @@ let WorkoutCard = (() => {
|
|
|
130
130
|
this.logError(err, 'save');
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
+
async markDeleted() {
|
|
134
|
+
this.workout.isDeleted = true;
|
|
135
|
+
await this.getRepo().save(this.workout, true);
|
|
136
|
+
}
|
|
133
137
|
delete() {
|
|
134
138
|
try {
|
|
135
139
|
const service = this.getWorkoutList();
|
|
@@ -203,7 +207,12 @@ let WorkoutCard = (() => {
|
|
|
203
207
|
let deleted;
|
|
204
208
|
try {
|
|
205
209
|
this.deleteObserver.emit('started');
|
|
206
|
-
|
|
210
|
+
if (this.workout.isLocal) {
|
|
211
|
+
await this.getRepo().delete(this.workout);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
await this.markDeleted();
|
|
215
|
+
}
|
|
207
216
|
this.deleteFromUIList();
|
|
208
217
|
this.getWorkoutList().emitLists('updated');
|
|
209
218
|
deleted = true;
|
|
@@ -536,6 +536,10 @@ let WorkoutListService = (() => {
|
|
|
536
536
|
});
|
|
537
537
|
}
|
|
538
538
|
addItem(item) {
|
|
539
|
+
this.items.push(item);
|
|
540
|
+
if (item.isDeleted) {
|
|
541
|
+
return undefined;
|
|
542
|
+
}
|
|
539
543
|
const list = this.selectList(item);
|
|
540
544
|
let card;
|
|
541
545
|
if (item.type === 'workout') {
|
|
@@ -545,7 +549,6 @@ let WorkoutListService = (() => {
|
|
|
545
549
|
}
|
|
546
550
|
list.add(card);
|
|
547
551
|
card.enableDelete(true);
|
|
548
|
-
this.items.push(item);
|
|
549
552
|
this.emitLists('updated');
|
|
550
553
|
return card;
|
|
551
554
|
}
|
|
@@ -6,6 +6,8 @@ export declare class Workout extends Segment implements WorkoutDefinition {
|
|
|
6
6
|
name: string;
|
|
7
7
|
description: string;
|
|
8
8
|
category?: Category;
|
|
9
|
+
isLocal?: boolean;
|
|
10
|
+
isDeleted?: boolean;
|
|
9
11
|
protected explicitId: boolean;
|
|
10
12
|
constructor(opts: WorkoutDefinition);
|
|
11
13
|
get hash(): string;
|
|
@@ -20,6 +20,7 @@ export declare class WorkoutCard extends BaseCard implements Card<Workout> {
|
|
|
20
20
|
unselect(): void;
|
|
21
21
|
move(targetListName: string): void;
|
|
22
22
|
save(enforce?: boolean): Promise<void>;
|
|
23
|
+
protected markDeleted(): Promise<void>;
|
|
23
24
|
delete(): PromiseObserver<boolean>;
|
|
24
25
|
getId(): string;
|
|
25
26
|
getTitle(): string;
|