@myrmidon/cadmus-state 0.0.8 → 0.2.0
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/README.md +24 -24
- package/esm2020/lib/app.query.mjs +29 -0
- package/esm2020/lib/app.service.mjs +43 -0
- package/esm2020/lib/app.store.mjs +26 -0
- package/esm2020/lib/cadmus-state.module.mjs +34 -0
- package/esm2020/lib/edit-fragment-feature-base.mjs +115 -0
- package/esm2020/lib/edit-fragment-query-base.mjs +32 -0
- package/esm2020/lib/edit-fragment-service-base.mjs +137 -0
- package/esm2020/lib/edit-fragment.store.mjs +39 -0
- package/esm2020/lib/edit-item.query.mjs +52 -0
- package/esm2020/lib/edit-item.service.mjs +182 -0
- package/esm2020/lib/edit-item.store.mjs +47 -0
- package/esm2020/lib/edit-layer-part.query.mjs +35 -0
- package/esm2020/lib/edit-layer-part.service.mjs +230 -0
- package/esm2020/lib/edit-layer-part.store.mjs +53 -0
- package/esm2020/lib/edit-part-feature-base.mjs +116 -0
- package/esm2020/lib/edit-part-query-base.mjs +25 -0
- package/esm2020/lib/edit-part-service-base.mjs +120 -0
- package/esm2020/lib/edit-part.store.mjs +39 -0
- package/esm2020/lib/edit-thesaurus.query.mjs +26 -0
- package/esm2020/lib/edit-thesaurus.service.mjs +59 -0
- package/esm2020/lib/edit-thesaurus.store.mjs +37 -0
- package/{esm2015/myrmidon-cadmus-state.js → esm2020/myrmidon-cadmus-state.mjs} +1 -1
- package/{esm2015/public-api.js → esm2020/public-api.mjs} +1 -1
- package/fesm2015/{myrmidon-cadmus-state.js → myrmidon-cadmus-state.mjs} +316 -255
- package/fesm2015/myrmidon-cadmus-state.mjs.map +1 -0
- package/fesm2020/myrmidon-cadmus-state.mjs +1418 -0
- package/fesm2020/myrmidon-cadmus-state.mjs.map +1 -0
- package/lib/app.query.d.ts +3 -0
- package/lib/app.service.d.ts +3 -0
- package/lib/app.store.d.ts +3 -0
- package/lib/cadmus-state.module.d.ts +8 -0
- package/lib/edit-fragment-feature-base.d.ts +45 -3
- package/lib/edit-fragment-query-base.d.ts +2 -2
- package/lib/edit-fragment-service-base.d.ts +10 -7
- package/lib/edit-fragment.store.d.ts +3 -0
- package/lib/edit-item.query.d.ts +3 -0
- package/lib/edit-item.service.d.ts +4 -1
- package/lib/edit-item.store.d.ts +3 -0
- package/lib/edit-layer-part.query.d.ts +3 -0
- package/lib/edit-layer-part.service.d.ts +5 -3
- package/lib/edit-layer-part.store.d.ts +3 -0
- package/lib/edit-part-feature-base.d.ts +42 -17
- package/lib/edit-part-query-base.d.ts +3 -4
- package/lib/edit-part-service-base.d.ts +23 -6
- package/lib/edit-part.store.d.ts +3 -0
- package/lib/edit-thesaurus.query.d.ts +3 -0
- package/lib/edit-thesaurus.service.d.ts +4 -1
- package/lib/edit-thesaurus.store.d.ts +3 -0
- package/myrmidon-cadmus-state.d.ts +1 -0
- package/package.json +25 -13
- package/bundles/myrmidon-cadmus-state.umd.js +0 -1758
- package/bundles/myrmidon-cadmus-state.umd.js.map +0 -1
- package/bundles/myrmidon-cadmus-state.umd.min.js +0 -16
- package/bundles/myrmidon-cadmus-state.umd.min.js.map +0 -1
- package/esm2015/lib/app.query.js +0 -31
- package/esm2015/lib/app.service.js +0 -49
- package/esm2015/lib/app.store.js +0 -25
- package/esm2015/lib/cadmus-state.module.js +0 -19
- package/esm2015/lib/edit-fragment-feature-base.js +0 -106
- package/esm2015/lib/edit-fragment-query-base.js +0 -29
- package/esm2015/lib/edit-fragment-service-base.js +0 -126
- package/esm2015/lib/edit-fragment.store.js +0 -38
- package/esm2015/lib/edit-item.query.js +0 -56
- package/esm2015/lib/edit-item.service.js +0 -184
- package/esm2015/lib/edit-item.store.js +0 -46
- package/esm2015/lib/edit-layer-part.query.js +0 -37
- package/esm2015/lib/edit-layer-part.service.js +0 -238
- package/esm2015/lib/edit-layer-part.store.js +0 -52
- package/esm2015/lib/edit-part-feature-base.js +0 -107
- package/esm2015/lib/edit-part-query-base.js +0 -39
- package/esm2015/lib/edit-part-service-base.js +0 -88
- package/esm2015/lib/edit-part.store.js +0 -38
- package/esm2015/lib/edit-thesaurus.query.js +0 -28
- package/esm2015/lib/edit-thesaurus.service.js +0 -63
- package/esm2015/lib/edit-thesaurus.store.js +0 -36
- package/fesm2015/myrmidon-cadmus-state.js.map +0 -1
- package/myrmidon-cadmus-state.metadata.json +0 -1
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, NgModule } from '@angular/core';
|
|
2
3
|
import { Store, StoreConfig, Query } from '@datorama/akita';
|
|
3
4
|
import { __decorate } from 'tslib';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
5
|
+
import { forkJoin } from 'rxjs';
|
|
6
|
+
import * as i2 from '@myrmidon/cadmus-api';
|
|
7
|
+
import { CadmusApiModule } from '@myrmidon/cadmus-api';
|
|
8
|
+
import * as i2$1 from '@myrmidon/cadmus-core';
|
|
9
|
+
import { TokenLocation, CadmusCoreModule } from '@myrmidon/cadmus-core';
|
|
10
|
+
import { deepCopy } from '@myrmidon/ng-tools';
|
|
8
11
|
import { CommonModule } from '@angular/common';
|
|
9
12
|
import { CadmusMaterialModule } from '@myrmidon/cadmus-material';
|
|
10
13
|
|
|
11
|
-
const initialState = {
|
|
14
|
+
const initialState$3 = {
|
|
12
15
|
facets: [],
|
|
13
16
|
flags: [],
|
|
14
17
|
typeThesaurus: null,
|
|
@@ -16,17 +19,18 @@ const initialState = {
|
|
|
16
19
|
};
|
|
17
20
|
let AppStore = class AppStore extends Store {
|
|
18
21
|
constructor() {
|
|
19
|
-
super(initialState);
|
|
22
|
+
super(initialState$3);
|
|
20
23
|
}
|
|
21
24
|
};
|
|
22
|
-
AppStore.ɵ
|
|
23
|
-
AppStore
|
|
24
|
-
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
25
|
-
];
|
|
26
|
-
AppStore.ctorParameters = () => [];
|
|
25
|
+
AppStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AppStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
26
|
+
AppStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AppStore, providedIn: 'root' });
|
|
27
27
|
AppStore = __decorate([
|
|
28
28
|
StoreConfig({ name: 'app', resettable: false })
|
|
29
|
-
], AppStore);
|
|
29
|
+
], AppStore);
|
|
30
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AppStore, decorators: [{
|
|
31
|
+
type: Injectable,
|
|
32
|
+
args: [{ providedIn: 'root' }]
|
|
33
|
+
}], ctorParameters: function () { return []; } });
|
|
30
34
|
|
|
31
35
|
class AppQuery extends Query {
|
|
32
36
|
constructor(store) {
|
|
@@ -46,13 +50,12 @@ class AppQuery extends Query {
|
|
|
46
50
|
return this.select((state) => state.itemBrowserThesaurus);
|
|
47
51
|
}
|
|
48
52
|
}
|
|
49
|
-
AppQuery.ɵ
|
|
50
|
-
AppQuery
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
];
|
|
53
|
+
AppQuery.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AppQuery, deps: [{ token: AppStore }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
54
|
+
AppQuery.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AppQuery, providedIn: 'root' });
|
|
55
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AppQuery, decorators: [{
|
|
56
|
+
type: Injectable,
|
|
57
|
+
args: [{ providedIn: 'root' }]
|
|
58
|
+
}], ctorParameters: function () { return [{ type: AppStore }]; } });
|
|
56
59
|
|
|
57
60
|
class AppService {
|
|
58
61
|
constructor(_store, _facetService, _flagService, _thesaurusService) {
|
|
@@ -85,18 +88,14 @@ class AppService {
|
|
|
85
88
|
});
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
|
-
AppService.ɵ
|
|
89
|
-
AppService
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
{ type: FacetService },
|
|
95
|
-
{ type: FlagService },
|
|
96
|
-
{ type: ThesaurusService }
|
|
97
|
-
];
|
|
91
|
+
AppService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AppService, deps: [{ token: AppStore }, { token: i2.FacetService }, { token: i2.FlagService }, { token: i2.ThesaurusService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
92
|
+
AppService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AppService, providedIn: 'root' });
|
|
93
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AppService, decorators: [{
|
|
94
|
+
type: Injectable,
|
|
95
|
+
args: [{ providedIn: 'root' }]
|
|
96
|
+
}], ctorParameters: function () { return [{ type: AppStore }, { type: i2.FacetService }, { type: i2.FlagService }, { type: i2.ThesaurusService }]; } });
|
|
98
97
|
|
|
99
|
-
const initialState$
|
|
98
|
+
const initialState$2 = {
|
|
100
99
|
item: null,
|
|
101
100
|
parts: [],
|
|
102
101
|
partGroups: [],
|
|
@@ -110,7 +109,7 @@ const initialState$1 = {
|
|
|
110
109
|
};
|
|
111
110
|
let EditItemStore = class EditItemStore extends Store {
|
|
112
111
|
constructor() {
|
|
113
|
-
super(initialState$
|
|
112
|
+
super(initialState$2);
|
|
114
113
|
}
|
|
115
114
|
setDirty(value = true) {
|
|
116
115
|
this.update({
|
|
@@ -128,14 +127,15 @@ let EditItemStore = class EditItemStore extends Store {
|
|
|
128
127
|
});
|
|
129
128
|
}
|
|
130
129
|
};
|
|
131
|
-
EditItemStore.ɵ
|
|
132
|
-
EditItemStore
|
|
133
|
-
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
134
|
-
];
|
|
135
|
-
EditItemStore.ctorParameters = () => [];
|
|
130
|
+
EditItemStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditItemStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
131
|
+
EditItemStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditItemStore, providedIn: 'root' });
|
|
136
132
|
EditItemStore = __decorate([
|
|
137
133
|
StoreConfig({ name: 'edit-item', resettable: true })
|
|
138
|
-
], EditItemStore);
|
|
134
|
+
], EditItemStore);
|
|
135
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditItemStore, decorators: [{
|
|
136
|
+
type: Injectable,
|
|
137
|
+
args: [{ providedIn: 'root' }]
|
|
138
|
+
}], ctorParameters: function () { return []; } });
|
|
139
139
|
|
|
140
140
|
/**
|
|
141
141
|
* The query facade to the edit item store.
|
|
@@ -177,14 +177,12 @@ class EditItemQuery extends Query {
|
|
|
177
177
|
.partKey;
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
EditItemQuery.ɵ
|
|
181
|
-
EditItemQuery
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
{ type: LibraryRouteService }
|
|
187
|
-
];
|
|
180
|
+
EditItemQuery.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditItemQuery, deps: [{ token: EditItemStore }, { token: i2$1.LibraryRouteService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
181
|
+
EditItemQuery.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditItemQuery, providedIn: 'root' });
|
|
182
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditItemQuery, decorators: [{
|
|
183
|
+
type: Injectable,
|
|
184
|
+
args: [{ providedIn: 'root' }]
|
|
185
|
+
}], ctorParameters: function () { return [{ type: EditItemStore }, { type: i2$1.LibraryRouteService }]; } });
|
|
188
186
|
|
|
189
187
|
/**
|
|
190
188
|
* The service which handles the edit item store.
|
|
@@ -305,22 +303,26 @@ class EditItemService {
|
|
|
305
303
|
*/
|
|
306
304
|
deletePart(id) {
|
|
307
305
|
this._store.setDeletingPart();
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
this.
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
306
|
+
return new Promise((resolve, reject) => {
|
|
307
|
+
// delete from server
|
|
308
|
+
this._itemService.deletePart(id).subscribe((_) => {
|
|
309
|
+
this._store.setDeletingPart(false);
|
|
310
|
+
// reload the store
|
|
311
|
+
this.load(this._store.getValue().item.id);
|
|
312
|
+
resolve(id);
|
|
313
|
+
}, (error) => {
|
|
314
|
+
console.log(error);
|
|
315
|
+
this._store.setDeletingPart(false);
|
|
316
|
+
this._store.setError('Error deleting part ' + id);
|
|
317
|
+
reject(error);
|
|
318
|
+
});
|
|
317
319
|
});
|
|
318
320
|
}
|
|
319
321
|
addNewLayerPart(itemId, typeId, roleId) {
|
|
320
322
|
const part = {
|
|
321
|
-
itemId
|
|
322
|
-
typeId
|
|
323
|
-
roleId
|
|
323
|
+
itemId,
|
|
324
|
+
typeId,
|
|
325
|
+
roleId,
|
|
324
326
|
id: null,
|
|
325
327
|
creatorId: null,
|
|
326
328
|
userId: null,
|
|
@@ -351,16 +353,17 @@ class EditItemService {
|
|
|
351
353
|
});
|
|
352
354
|
}
|
|
353
355
|
}
|
|
354
|
-
EditItemService.ɵ
|
|
355
|
-
EditItemService
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
{ type: AppQuery },
|
|
361
|
-
{ type: ItemService }
|
|
362
|
-
];
|
|
356
|
+
EditItemService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditItemService, deps: [{ token: EditItemStore }, { token: AppQuery }, { token: i2.ItemService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
357
|
+
EditItemService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditItemService, providedIn: 'root' });
|
|
358
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditItemService, decorators: [{
|
|
359
|
+
type: Injectable,
|
|
360
|
+
args: [{ providedIn: 'root' }]
|
|
361
|
+
}], ctorParameters: function () { return [{ type: EditItemStore }, { type: AppQuery }, { type: i2.ItemService }]; } });
|
|
363
362
|
|
|
363
|
+
/**
|
|
364
|
+
* Base class for fragment feature editors.
|
|
365
|
+
* This is similar to the EditPartFeatureBase class.
|
|
366
|
+
*/
|
|
364
367
|
class EditFragmentFeatureBase {
|
|
365
368
|
constructor(_router, route, snackbar, _editFrQuery, _editFrService, _editItemQuery, _editItemService, _editLayersQuery, _editLayersService, _libraryRouteService) {
|
|
366
369
|
var _a;
|
|
@@ -380,7 +383,7 @@ class EditFragmentFeatureBase {
|
|
|
380
383
|
this.frRoleId = route.snapshot.queryParams.frrid;
|
|
381
384
|
// connect _stateDirty to the value of the edit state
|
|
382
385
|
this._editFrQuery.selectDirty().subscribe((d) => {
|
|
383
|
-
console.log('fr
|
|
386
|
+
console.log('fr dirty change (from state): ' + d);
|
|
384
387
|
this._stateDirty = d;
|
|
385
388
|
});
|
|
386
389
|
}
|
|
@@ -404,8 +407,14 @@ class EditFragmentFeatureBase {
|
|
|
404
407
|
this._editLayersService.load(this.itemId, this.partId, thesauriIds);
|
|
405
408
|
}
|
|
406
409
|
}
|
|
410
|
+
/**
|
|
411
|
+
* Initialize the editor. You MUST call this in your OnInit.
|
|
412
|
+
*
|
|
413
|
+
* @param thesauriIds The optional ID(s) of the thesauri sets you want
|
|
414
|
+
* to use in your editor.
|
|
415
|
+
*/
|
|
407
416
|
initEditor(thesauriIds) {
|
|
408
|
-
this.
|
|
417
|
+
this.fragment$ = this._editFrQuery.selectFragment();
|
|
409
418
|
this.thesauri$ = this._editFrQuery.selectThesauri();
|
|
410
419
|
this.baseText$ = this._editLayersQuery.select((state) => state.baseText);
|
|
411
420
|
this.frLoc = TokenLocation.parse(this.loc);
|
|
@@ -423,20 +432,27 @@ class EditFragmentFeatureBase {
|
|
|
423
432
|
* @param value The value of the dirty state.
|
|
424
433
|
*/
|
|
425
434
|
onDirtyChange(value) {
|
|
426
|
-
console.log('fr dirty change: ' + value);
|
|
435
|
+
console.log('fr dirty change (from editor): ' + value);
|
|
427
436
|
this._formDirty = value;
|
|
428
437
|
}
|
|
429
|
-
|
|
438
|
+
/**
|
|
439
|
+
* Save the fragment.
|
|
440
|
+
*
|
|
441
|
+
* @param fragment The fragment to be saved.
|
|
442
|
+
*/
|
|
443
|
+
save(fragment) {
|
|
444
|
+
// get a copy of the container part
|
|
430
445
|
const part = JSON.parse(JSON.stringify(this._editLayersQuery.getValue().part));
|
|
431
|
-
|
|
446
|
+
// replace the fragment edited in it
|
|
432
447
|
const frIndex = part.fragments.findIndex((f) => f.location === this.loc);
|
|
433
448
|
if (frIndex > -1) {
|
|
434
|
-
part.fragments.splice(frIndex, 1,
|
|
449
|
+
part.fragments.splice(frIndex, 1, fragment);
|
|
435
450
|
}
|
|
436
451
|
else {
|
|
437
|
-
part.fragments.push(
|
|
452
|
+
part.fragments.push(fragment);
|
|
438
453
|
}
|
|
439
|
-
|
|
454
|
+
// save the new layer part with the replaced fragment
|
|
455
|
+
this._editFrService.save(part).then((p) => {
|
|
440
456
|
console.log(p.id);
|
|
441
457
|
this.snackbar.open('Fragment saved', 'OK', {
|
|
442
458
|
duration: 3000,
|
|
@@ -449,13 +465,6 @@ class EditFragmentFeatureBase {
|
|
|
449
465
|
close() {
|
|
450
466
|
// /items/<id>/<part-group>/<part-typeid>/<part-id>?rid=<role-id>
|
|
451
467
|
const part = this._editLayersQuery.getValue().part;
|
|
452
|
-
// const item = this._editItemQuery.getValue().item;
|
|
453
|
-
// const facet: FacetDefinition = this._appQuery.getValue().facets.find(f => {
|
|
454
|
-
// return f.id === item.facetId;
|
|
455
|
-
// });
|
|
456
|
-
// const partDef = facet.partDefinitions.find(d => {
|
|
457
|
-
// return d.typeId === part.typeId && d.roleId === d.roleId;
|
|
458
|
-
// });
|
|
459
468
|
const editorKey = this._libraryRouteService.getEditorKeyFromPartType(part.typeId, part.roleId);
|
|
460
469
|
const url = `/items/${this.itemId}/${editorKey.partKey}/${part.typeId}/${this.partId}`;
|
|
461
470
|
this._router.navigate([url], {
|
|
@@ -477,17 +486,21 @@ class EditFragmentQueryBase extends Query {
|
|
|
477
486
|
selectSaving() {
|
|
478
487
|
return this.select((state) => state.saving);
|
|
479
488
|
}
|
|
480
|
-
|
|
481
|
-
return this.select((state) => state.fragment)
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
489
|
+
selectFragment() {
|
|
490
|
+
return this.select((state) => state.fragment);
|
|
491
|
+
}
|
|
492
|
+
// public selectJson(): Observable<string> {
|
|
493
|
+
// return this.select((state) => state.fragment).pipe(
|
|
494
|
+
// map((fr: Fragment) => {
|
|
495
|
+
// // supply IDs
|
|
496
|
+
// if (fr) {
|
|
497
|
+
// return JSON.stringify(fr);
|
|
498
|
+
// } else {
|
|
499
|
+
// return '{}';
|
|
500
|
+
// }
|
|
501
|
+
// })
|
|
502
|
+
// );
|
|
503
|
+
// }
|
|
491
504
|
selectThesauri() {
|
|
492
505
|
return this.select((state) => state.thesauri);
|
|
493
506
|
}
|
|
@@ -517,17 +530,18 @@ let EditFragmentStore = class EditFragmentStore extends Store {
|
|
|
517
530
|
this.update({ saving: value });
|
|
518
531
|
}
|
|
519
532
|
};
|
|
520
|
-
EditFragmentStore.ɵ
|
|
521
|
-
EditFragmentStore
|
|
522
|
-
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
523
|
-
];
|
|
524
|
-
EditFragmentStore.ctorParameters = () => [];
|
|
533
|
+
EditFragmentStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditFragmentStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
534
|
+
EditFragmentStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditFragmentStore, providedIn: 'root' });
|
|
525
535
|
EditFragmentStore = __decorate([
|
|
526
536
|
StoreConfig({ name: 'edit-fragment' })
|
|
527
|
-
], EditFragmentStore);
|
|
537
|
+
], EditFragmentStore);
|
|
538
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditFragmentStore, decorators: [{
|
|
539
|
+
type: Injectable,
|
|
540
|
+
args: [{ providedIn: 'root' }]
|
|
541
|
+
}], ctorParameters: function () { return []; } });
|
|
528
542
|
|
|
529
543
|
/**
|
|
530
|
-
* Base class for fragment
|
|
544
|
+
* Base class for fragment editor services.
|
|
531
545
|
*/
|
|
532
546
|
class EditFragmentServiceBase {
|
|
533
547
|
constructor(_itemService, _thesaurusService) {
|
|
@@ -535,24 +549,30 @@ class EditFragmentServiceBase {
|
|
|
535
549
|
this._thesaurusService = _thesaurusService;
|
|
536
550
|
}
|
|
537
551
|
/**
|
|
538
|
-
* Load the
|
|
552
|
+
* Load into the state the fragment with the specified ID
|
|
553
|
+
* and its thesauri.
|
|
539
554
|
*
|
|
540
555
|
* @param partId The ID of the part the fragment belongs to.
|
|
541
556
|
* @param loc The fragment's location.
|
|
542
|
-
* @param thesauriIds The
|
|
557
|
+
* @param thesauriIds The thesauri IDs array, or null.
|
|
543
558
|
*/
|
|
544
559
|
load(partId, loc, thesauriIds = null) {
|
|
560
|
+
// signal that we're loading
|
|
545
561
|
this.store.setLoading(true);
|
|
562
|
+
// if thesauri are required:
|
|
546
563
|
if (thesauriIds) {
|
|
547
564
|
// remove trailing ! from IDs if any
|
|
548
565
|
const unscopedIds = thesauriIds.map((id) => {
|
|
549
566
|
return this._thesaurusService.getScopedId(id, null);
|
|
550
567
|
});
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
this.
|
|
554
|
-
|
|
555
|
-
|
|
568
|
+
// fetch fragment and thesauri
|
|
569
|
+
forkJoin({
|
|
570
|
+
part: this._itemService.getPart(partId),
|
|
571
|
+
thesauri: this._thesaurusService.getThesauriSet(unscopedIds),
|
|
572
|
+
}).subscribe((result) => {
|
|
573
|
+
// loading has ended
|
|
574
|
+
this.store.setLoading(false);
|
|
575
|
+
const layerPart = result.part;
|
|
556
576
|
const fr = layerPart.fragments.find((f) => f.location === loc);
|
|
557
577
|
if (!fr) {
|
|
558
578
|
// not found: new fragment
|
|
@@ -560,7 +580,7 @@ class EditFragmentServiceBase {
|
|
|
560
580
|
fragment: {
|
|
561
581
|
location: loc,
|
|
562
582
|
},
|
|
563
|
-
thesauri,
|
|
583
|
+
thesauri: result.thesauri,
|
|
564
584
|
loading: false,
|
|
565
585
|
error: null,
|
|
566
586
|
});
|
|
@@ -569,20 +589,23 @@ class EditFragmentServiceBase {
|
|
|
569
589
|
// found: existing fragment
|
|
570
590
|
this.store.update({
|
|
571
591
|
fragment: fr,
|
|
572
|
-
thesauri,
|
|
592
|
+
thesauri: result.thesauri,
|
|
573
593
|
loading: false,
|
|
574
594
|
error: null,
|
|
575
595
|
});
|
|
576
596
|
}
|
|
577
597
|
// if the loaded layer part has a thesaurus scope, reload the thesauri
|
|
578
|
-
if (part.thesaurusScope) {
|
|
598
|
+
if (result.part.thesaurusScope) {
|
|
579
599
|
const scopedIds = thesauriIds.map((id) => {
|
|
580
|
-
return this._thesaurusService.getScopedId(id, part.thesaurusScope);
|
|
600
|
+
return this._thesaurusService.getScopedId(id, result.part.thesaurusScope);
|
|
581
601
|
});
|
|
602
|
+
// loading again
|
|
582
603
|
this.store.setLoading(true);
|
|
583
|
-
this._thesaurusService.getThesauriSet(scopedIds).subscribe((
|
|
604
|
+
this._thesaurusService.getThesauriSet(scopedIds).subscribe((thesauri) => {
|
|
605
|
+
// completed, replace the thesauri
|
|
584
606
|
this.store.update({
|
|
585
|
-
thesauri
|
|
607
|
+
thesauri,
|
|
608
|
+
loading: false
|
|
586
609
|
});
|
|
587
610
|
}, (error) => {
|
|
588
611
|
console.error(error);
|
|
@@ -593,6 +616,7 @@ class EditFragmentServiceBase {
|
|
|
593
616
|
});
|
|
594
617
|
}
|
|
595
618
|
else {
|
|
619
|
+
// without thesauri to be fetched, just fetch the part
|
|
596
620
|
this._itemService.getPart(partId).subscribe((part) => {
|
|
597
621
|
const layerPart = part;
|
|
598
622
|
const fr = layerPart.fragments.find((f) => f.location === loc);
|
|
@@ -616,32 +640,33 @@ class EditFragmentServiceBase {
|
|
|
616
640
|
}, (error) => {
|
|
617
641
|
console.error(error);
|
|
618
642
|
this.store.setLoading(false);
|
|
619
|
-
this.store.setError('Error loading part ' + partId);
|
|
643
|
+
this.store.setError('Error loading fragment\'s part ' + partId);
|
|
620
644
|
});
|
|
621
645
|
}
|
|
622
646
|
}
|
|
623
647
|
/**
|
|
624
|
-
* Save the fragments
|
|
625
|
-
* representing their part.
|
|
648
|
+
* Save the fragments in their layer part.
|
|
626
649
|
*
|
|
627
|
-
* @param
|
|
650
|
+
* @param part The part.
|
|
628
651
|
* @returns Promise which when successful returns the
|
|
629
652
|
* saved part (which contains the fragment being saved).
|
|
630
653
|
*/
|
|
631
|
-
save(
|
|
654
|
+
save(part) {
|
|
632
655
|
this.store.setSaving(true);
|
|
633
656
|
this.store.setDirty(true);
|
|
634
657
|
return new Promise((resolve, reject) => {
|
|
635
|
-
this._itemService.
|
|
636
|
-
this.store.update({
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
658
|
+
this._itemService.addPart(part).subscribe((saved) => {
|
|
659
|
+
this.store.update({
|
|
660
|
+
part: saved,
|
|
661
|
+
saving: false,
|
|
662
|
+
dirty: false,
|
|
663
|
+
error: null,
|
|
664
|
+
});
|
|
640
665
|
resolve(part);
|
|
641
666
|
}, (error) => {
|
|
642
667
|
console.error(error);
|
|
643
668
|
this.store.setSaving(false);
|
|
644
|
-
this.store.setError('Error saving fragment');
|
|
669
|
+
this.store.setError('Error saving fragment\'s part');
|
|
645
670
|
reject(error);
|
|
646
671
|
});
|
|
647
672
|
});
|
|
@@ -653,16 +678,17 @@ class EditFragmentServiceBase {
|
|
|
653
678
|
|
|
654
679
|
/**
|
|
655
680
|
* Base class for part feature editors.
|
|
656
|
-
* A part feature editor is a wrapper component, linking a part edit
|
|
657
|
-
* (accessed from a part query and loaded with a part service)
|
|
658
|
-
*
|
|
659
|
-
* It implements ComponentCanDeactivate to allow using the
|
|
660
|
-
* To this end, it tracks the dirty state of
|
|
661
|
-
* different sources: the wrapped editor
|
|
662
|
-
* the store edit state. This is
|
|
663
|
-
*
|
|
664
|
-
*
|
|
665
|
-
*
|
|
681
|
+
* A part feature editor is a wrapper component, linking a part edit
|
|
682
|
+
* state (accessed from a part query and loaded with a part service)
|
|
683
|
+
* to a corresponding wrapped UI editor.
|
|
684
|
+
* It implements ComponentCanDeactivate to allow using the
|
|
685
|
+
* PendingChangesGuard. To this end, it tracks the dirty state of
|
|
686
|
+
* the edited data coming from 2 different sources: the wrapped editor
|
|
687
|
+
* state (from its "root" form), and the store edit state. This is
|
|
688
|
+
* set to dirty when a save attempt fails.
|
|
689
|
+
* Thus, at the end the user will be prompted when closing an editor
|
|
690
|
+
* either because he has changed data in it, or because he attempted
|
|
691
|
+
* a save without success.
|
|
666
692
|
*/
|
|
667
693
|
class EditPartFeatureBase {
|
|
668
694
|
constructor(router, route, snackbar, _editPartQuery, _editPartService, _editItemQuery, _editItemService) {
|
|
@@ -672,18 +698,23 @@ class EditPartFeatureBase {
|
|
|
672
698
|
this._editPartService = _editPartService;
|
|
673
699
|
this._editItemQuery = _editItemQuery;
|
|
674
700
|
this._editItemService = _editItemService;
|
|
701
|
+
// item ID
|
|
675
702
|
this.itemId = route.snapshot.params.iid;
|
|
703
|
+
// type ID (from "TYPEID/:pid")
|
|
704
|
+
this.typeId = route.snapshot.routeConfig.path.substr(0, route.snapshot.routeConfig.path.indexOf('/'));
|
|
705
|
+
// part ID or null (if "new")
|
|
676
706
|
this.partId = route.snapshot.params.pid;
|
|
677
707
|
if (this.partId === 'new') {
|
|
678
708
|
this.partId = null;
|
|
679
709
|
}
|
|
710
|
+
// role ID or null (if "default")
|
|
680
711
|
this.roleId = route.snapshot.queryParams.rid;
|
|
681
712
|
if (this.roleId === 'default') {
|
|
682
713
|
this.roleId = null;
|
|
683
714
|
}
|
|
684
|
-
// connect _stateDirty to the value
|
|
715
|
+
// connect _stateDirty to the value observed in the part state
|
|
685
716
|
this._editPartQuery.selectDirty().subscribe((d) => {
|
|
686
|
-
console.log('part
|
|
717
|
+
console.log('part dirty change (from state): ' + d);
|
|
687
718
|
this._stateDirty = d;
|
|
688
719
|
});
|
|
689
720
|
}
|
|
@@ -704,43 +735,47 @@ class EditPartFeatureBase {
|
|
|
704
735
|
}
|
|
705
736
|
/**
|
|
706
737
|
* Initialize the editor. You MUST call this in your OnInit.
|
|
738
|
+
*
|
|
707
739
|
* @param thesauriIds The optional ID(s) of the thesauri sets you want
|
|
708
740
|
* to use in your editor.
|
|
709
741
|
*/
|
|
710
742
|
initEditor(thesauriIds) {
|
|
711
|
-
|
|
712
|
-
this.
|
|
713
|
-
this.json$.next(json);
|
|
714
|
-
});
|
|
743
|
+
// connect part and thesauri to state via query
|
|
744
|
+
this.part$ = this._editPartQuery.selectPart();
|
|
715
745
|
this.thesauri$ = this._editPartQuery.selectThesauri();
|
|
716
746
|
// load item if required
|
|
717
747
|
this.ensureItemLoaded(this.itemId);
|
|
718
748
|
// load part (none if new) and thesauri
|
|
719
|
-
this._editPartService.load(this.partId,
|
|
749
|
+
this._editPartService.load(this.partId, // a new part has null here
|
|
750
|
+
thesauriIds,
|
|
751
|
+
// for a new part, we must supply item and role
|
|
752
|
+
this.itemId, this.typeId, this.roleId);
|
|
720
753
|
}
|
|
721
754
|
/**
|
|
722
755
|
* Called when the wrapped editor dirty state changes.
|
|
723
756
|
* In the HTML template, you MUST bind this handler to the dirtyChange event
|
|
724
757
|
* emitted by your wrapped editor (i.e. (dirtyChange)="onDirtyChange($event)").
|
|
758
|
+
*
|
|
725
759
|
* @param value The value of the dirty state.
|
|
726
760
|
*/
|
|
727
761
|
onDirtyChange(value) {
|
|
728
|
-
console.log('part dirty change: ' + value);
|
|
762
|
+
console.log('part dirty change (from editor): ' + value);
|
|
729
763
|
this._formDirty = value;
|
|
730
764
|
}
|
|
731
765
|
/**
|
|
732
766
|
* Save the part.
|
|
733
|
-
*
|
|
767
|
+
*
|
|
768
|
+
* @param part The part to be saved.
|
|
734
769
|
*/
|
|
735
|
-
save(
|
|
736
|
-
|
|
737
|
-
|
|
770
|
+
save(part) {
|
|
771
|
+
// save via part service, which invokes item service
|
|
772
|
+
// for the backend, and then updates the part's store
|
|
773
|
+
this._editPartService.save(part).then((saved) => {
|
|
774
|
+
// update the route-defined part ID if it was null (new part)
|
|
738
775
|
if (!this.partId) {
|
|
739
|
-
this.partId =
|
|
776
|
+
this.partId = saved.id;
|
|
740
777
|
}
|
|
741
|
-
console.log('Part saved: ' +
|
|
742
|
-
// emit the updated saved part
|
|
743
|
-
this.json$.next(json);
|
|
778
|
+
console.log('Part saved: ' + saved.id);
|
|
744
779
|
this.snackbar.open('Part saved', 'OK', {
|
|
745
780
|
duration: 3000,
|
|
746
781
|
});
|
|
@@ -763,10 +798,9 @@ class EditPartFeatureBase {
|
|
|
763
798
|
* part's store to the constructor.
|
|
764
799
|
*/
|
|
765
800
|
class EditPartQueryBase extends Query {
|
|
766
|
-
constructor(store
|
|
801
|
+
constructor(store) {
|
|
767
802
|
super(store);
|
|
768
803
|
this.store = store;
|
|
769
|
-
this._utilService = _utilService;
|
|
770
804
|
}
|
|
771
805
|
selectDirty() {
|
|
772
806
|
return this.select((state) => state.dirty);
|
|
@@ -774,46 +808,60 @@ class EditPartQueryBase extends Query {
|
|
|
774
808
|
selectSaving() {
|
|
775
809
|
return this.select((state) => state.saving);
|
|
776
810
|
}
|
|
777
|
-
|
|
778
|
-
return this.select((state) => state.part)
|
|
779
|
-
// supply IDs
|
|
780
|
-
if (part) {
|
|
781
|
-
const clone = this._utilService.deepCopy(part);
|
|
782
|
-
clone.itemId = itemId;
|
|
783
|
-
clone.id = partId;
|
|
784
|
-
clone.roleId = roleId;
|
|
785
|
-
return JSON.stringify(clone);
|
|
786
|
-
}
|
|
787
|
-
else {
|
|
788
|
-
return '{}';
|
|
789
|
-
}
|
|
790
|
-
}));
|
|
811
|
+
selectPart() {
|
|
812
|
+
return this.select((state) => state.part);
|
|
791
813
|
}
|
|
792
814
|
selectThesauri() {
|
|
793
815
|
return this.select((state) => state.thesauri);
|
|
794
816
|
}
|
|
795
817
|
}
|
|
796
818
|
|
|
819
|
+
/**
|
|
820
|
+
* Base class for part editor services.
|
|
821
|
+
*/
|
|
797
822
|
class EditPartServiceBase {
|
|
798
823
|
constructor(itemService, thesaurusService) {
|
|
799
824
|
this.itemService = itemService;
|
|
800
825
|
this.thesaurusService = thesaurusService;
|
|
801
826
|
}
|
|
802
|
-
|
|
827
|
+
/**
|
|
828
|
+
* Load into the state the part with the specified ID
|
|
829
|
+
* and its thesauri.
|
|
830
|
+
* If the ID is not specified, it's a new part; in this case,
|
|
831
|
+
* it will get a null ID, but use the specified itemId and roleId.
|
|
832
|
+
*
|
|
833
|
+
* @param partId The part ID, unless it's a new part.
|
|
834
|
+
* @param thesauriIds The thesauri IDs array, or null.
|
|
835
|
+
* @param itemId The item ID for the new part.
|
|
836
|
+
* @param typeId The part type ID for the new part.
|
|
837
|
+
* @param roleId The role ID for the new part.
|
|
838
|
+
*/
|
|
839
|
+
load(partId, thesauriIds = null, itemId, typeId, roleId) {
|
|
840
|
+
// signal that we're loading
|
|
803
841
|
this.store.setLoading(true);
|
|
842
|
+
// if thesauri are required:
|
|
804
843
|
if (thesauriIds) {
|
|
805
844
|
// remove trailing ! from IDs if any
|
|
806
845
|
const unscopedIds = thesauriIds.map((id) => {
|
|
807
846
|
return this.thesaurusService.getScopedId(id, null);
|
|
808
847
|
});
|
|
848
|
+
// fetch part and thesauri
|
|
809
849
|
forkJoin({
|
|
810
850
|
part: this.itemService.getPart(partId),
|
|
811
851
|
thesauri: this.thesaurusService.getThesauriSet(unscopedIds),
|
|
812
852
|
}).subscribe((result) => {
|
|
813
853
|
var _a;
|
|
854
|
+
// loading has ended
|
|
814
855
|
this.store.setLoading(false);
|
|
856
|
+
// update the store with a new or existing part,
|
|
857
|
+
// and its requested thesauri
|
|
815
858
|
this.store.update({
|
|
816
|
-
part: result.part
|
|
859
|
+
part: result.part || {
|
|
860
|
+
id: null,
|
|
861
|
+
itemId,
|
|
862
|
+
typeId,
|
|
863
|
+
roleId,
|
|
864
|
+
},
|
|
817
865
|
thesauri: result.thesauri,
|
|
818
866
|
});
|
|
819
867
|
// if the loaded part has a thesaurus scope, reload the thesauri
|
|
@@ -821,10 +869,13 @@ class EditPartServiceBase {
|
|
|
821
869
|
const scopedIds = thesauriIds.map((id) => {
|
|
822
870
|
return this.thesaurusService.getScopedId(id, result.part.thesaurusScope);
|
|
823
871
|
});
|
|
872
|
+
// loading again
|
|
824
873
|
this.store.setLoading(true);
|
|
825
|
-
this.thesaurusService.getThesauriSet(
|
|
874
|
+
this.thesaurusService.getThesauriSet(scopedIds).subscribe((thesauri) => {
|
|
875
|
+
// completed, replace the thesauri
|
|
826
876
|
this.store.update({
|
|
827
877
|
thesauri,
|
|
878
|
+
loading: false,
|
|
828
879
|
});
|
|
829
880
|
}, (error) => {
|
|
830
881
|
console.error(error);
|
|
@@ -835,12 +886,15 @@ class EditPartServiceBase {
|
|
|
835
886
|
});
|
|
836
887
|
}
|
|
837
888
|
else {
|
|
838
|
-
|
|
839
|
-
return;
|
|
840
|
-
}
|
|
889
|
+
// without thesauri to be fetched, just fetch the part
|
|
841
890
|
this.itemService.getPart(partId).subscribe((part) => {
|
|
842
891
|
this.store.update({
|
|
843
|
-
part
|
|
892
|
+
part: part || {
|
|
893
|
+
id: null,
|
|
894
|
+
itemId,
|
|
895
|
+
typeId,
|
|
896
|
+
roleId,
|
|
897
|
+
},
|
|
844
898
|
loading: false,
|
|
845
899
|
error: null,
|
|
846
900
|
});
|
|
@@ -852,21 +906,22 @@ class EditPartServiceBase {
|
|
|
852
906
|
}
|
|
853
907
|
}
|
|
854
908
|
/**
|
|
855
|
-
* Save the
|
|
909
|
+
* Save the part.
|
|
856
910
|
*
|
|
857
|
-
* @param
|
|
858
|
-
* @returns Promise which when successful returns the
|
|
859
|
-
* saved part.
|
|
911
|
+
* @param part The part.
|
|
912
|
+
* @returns Promise which when successful returns the saved part.
|
|
860
913
|
*/
|
|
861
|
-
save(
|
|
914
|
+
save(part) {
|
|
862
915
|
this.store.setSaving(true);
|
|
863
916
|
this.store.setDirty(true);
|
|
864
917
|
return new Promise((resolve, reject) => {
|
|
865
|
-
this.itemService.
|
|
866
|
-
this.store.update({
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
918
|
+
this.itemService.addPart(part).subscribe((saved) => {
|
|
919
|
+
this.store.update({
|
|
920
|
+
part: saved,
|
|
921
|
+
saving: false,
|
|
922
|
+
dirty: false,
|
|
923
|
+
error: null,
|
|
924
|
+
});
|
|
870
925
|
resolve(part);
|
|
871
926
|
}, (error) => {
|
|
872
927
|
console.error(error);
|
|
@@ -887,7 +942,7 @@ const editPartInitialState = {
|
|
|
887
942
|
dirty: false,
|
|
888
943
|
saving: false,
|
|
889
944
|
loading: false,
|
|
890
|
-
error: null
|
|
945
|
+
error: null,
|
|
891
946
|
};
|
|
892
947
|
/**
|
|
893
948
|
* General-purpose edit-part store. This can be used with any part, so that
|
|
@@ -905,16 +960,17 @@ let EditPartStore = class EditPartStore extends Store {
|
|
|
905
960
|
this.update({ saving: value });
|
|
906
961
|
}
|
|
907
962
|
};
|
|
908
|
-
EditPartStore.ɵ
|
|
909
|
-
EditPartStore
|
|
910
|
-
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
911
|
-
];
|
|
912
|
-
EditPartStore.ctorParameters = () => [];
|
|
963
|
+
EditPartStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditPartStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
964
|
+
EditPartStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditPartStore, providedIn: 'root' });
|
|
913
965
|
EditPartStore = __decorate([
|
|
914
966
|
StoreConfig({ name: 'edit-part' })
|
|
915
|
-
], EditPartStore);
|
|
967
|
+
], EditPartStore);
|
|
968
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditPartStore, decorators: [{
|
|
969
|
+
type: Injectable,
|
|
970
|
+
args: [{ providedIn: 'root' }]
|
|
971
|
+
}], ctorParameters: function () { return []; } });
|
|
916
972
|
|
|
917
|
-
const initialState$
|
|
973
|
+
const initialState$1 = {
|
|
918
974
|
part: null,
|
|
919
975
|
baseText: null,
|
|
920
976
|
baseTextPart: null,
|
|
@@ -931,7 +987,7 @@ const initialState$2 = {
|
|
|
931
987
|
};
|
|
932
988
|
let EditLayerPartStore = class EditLayerPartStore extends Store {
|
|
933
989
|
constructor() {
|
|
934
|
-
super(initialState$
|
|
990
|
+
super(initialState$1);
|
|
935
991
|
}
|
|
936
992
|
setDeletingFragment(value = true) {
|
|
937
993
|
this.update({ deletingFragment: value });
|
|
@@ -952,14 +1008,15 @@ let EditLayerPartStore = class EditLayerPartStore extends Store {
|
|
|
952
1008
|
this.update({ locations });
|
|
953
1009
|
}
|
|
954
1010
|
};
|
|
955
|
-
EditLayerPartStore.ɵ
|
|
956
|
-
EditLayerPartStore
|
|
957
|
-
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
958
|
-
];
|
|
959
|
-
EditLayerPartStore.ctorParameters = () => [];
|
|
1011
|
+
EditLayerPartStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditLayerPartStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1012
|
+
EditLayerPartStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditLayerPartStore, providedIn: 'root' });
|
|
960
1013
|
EditLayerPartStore = __decorate([
|
|
961
1014
|
StoreConfig({ name: 'edit-layer-part' })
|
|
962
|
-
], EditLayerPartStore);
|
|
1015
|
+
], EditLayerPartStore);
|
|
1016
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditLayerPartStore, decorators: [{
|
|
1017
|
+
type: Injectable,
|
|
1018
|
+
args: [{ providedIn: 'root' }]
|
|
1019
|
+
}], ctorParameters: function () { return []; } });
|
|
963
1020
|
|
|
964
1021
|
class EditLayerPartQuery extends Query {
|
|
965
1022
|
constructor(store) {
|
|
@@ -985,20 +1042,18 @@ class EditLayerPartQuery extends Query {
|
|
|
985
1042
|
return this.select((state) => state.patchingLayer);
|
|
986
1043
|
}
|
|
987
1044
|
}
|
|
988
|
-
EditLayerPartQuery.ɵ
|
|
989
|
-
EditLayerPartQuery
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
];
|
|
1045
|
+
EditLayerPartQuery.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditLayerPartQuery, deps: [{ token: EditLayerPartStore }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1046
|
+
EditLayerPartQuery.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditLayerPartQuery, providedIn: 'root' });
|
|
1047
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditLayerPartQuery, decorators: [{
|
|
1048
|
+
type: Injectable,
|
|
1049
|
+
args: [{ providedIn: 'root' }]
|
|
1050
|
+
}], ctorParameters: function () { return [{ type: EditLayerPartStore }]; } });
|
|
995
1051
|
|
|
996
1052
|
class EditLayerPartService {
|
|
997
|
-
constructor(_store, _itemService, _facetService,
|
|
1053
|
+
constructor(_store, _itemService, _facetService, _thesaurusService) {
|
|
998
1054
|
this._store = _store;
|
|
999
1055
|
this._itemService = _itemService;
|
|
1000
1056
|
this._facetService = _facetService;
|
|
1001
|
-
this._utilService = _utilService;
|
|
1002
1057
|
this._thesaurusService = _thesaurusService;
|
|
1003
1058
|
}
|
|
1004
1059
|
getLocations(part) {
|
|
@@ -1146,7 +1201,7 @@ class EditLayerPartService {
|
|
|
1146
1201
|
}
|
|
1147
1202
|
// remove it from the part
|
|
1148
1203
|
// work on a copy, as store objects are immutable
|
|
1149
|
-
part =
|
|
1204
|
+
part = deepCopy(part);
|
|
1150
1205
|
part.fragments.splice(i, 1);
|
|
1151
1206
|
// update the part and reload state once done
|
|
1152
1207
|
this._itemService.addPart(part).subscribe((_) => {
|
|
@@ -1177,7 +1232,7 @@ class EditLayerPartService {
|
|
|
1177
1232
|
}
|
|
1178
1233
|
// add or replace it
|
|
1179
1234
|
// work on a copy, as store objects are immutable
|
|
1180
|
-
part =
|
|
1235
|
+
part = deepCopy(part);
|
|
1181
1236
|
// replace all the overlapping fragments with the new one
|
|
1182
1237
|
const newLoc = TokenLocation.parse(fragment.location);
|
|
1183
1238
|
let insertAt = 0;
|
|
@@ -1210,19 +1265,14 @@ class EditLayerPartService {
|
|
|
1210
1265
|
});
|
|
1211
1266
|
}
|
|
1212
1267
|
}
|
|
1213
|
-
EditLayerPartService.ɵ
|
|
1214
|
-
EditLayerPartService
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
{ type: ItemService },
|
|
1220
|
-
{ type: FacetService },
|
|
1221
|
-
{ type: UtilService },
|
|
1222
|
-
{ type: ThesaurusService }
|
|
1223
|
-
];
|
|
1268
|
+
EditLayerPartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditLayerPartService, deps: [{ token: EditLayerPartStore }, { token: i2.ItemService }, { token: i2.FacetService }, { token: i2.ThesaurusService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1269
|
+
EditLayerPartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditLayerPartService, providedIn: 'root' });
|
|
1270
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditLayerPartService, decorators: [{
|
|
1271
|
+
type: Injectable,
|
|
1272
|
+
args: [{ providedIn: 'root' }]
|
|
1273
|
+
}], ctorParameters: function () { return [{ type: EditLayerPartStore }, { type: i2.ItemService }, { type: i2.FacetService }, { type: i2.ThesaurusService }]; } });
|
|
1224
1274
|
|
|
1225
|
-
const initialState
|
|
1275
|
+
const initialState = {
|
|
1226
1276
|
thesaurus: null,
|
|
1227
1277
|
dirty: false,
|
|
1228
1278
|
saving: false,
|
|
@@ -1231,7 +1281,7 @@ const initialState$3 = {
|
|
|
1231
1281
|
};
|
|
1232
1282
|
let EditThesaurusStore = class EditThesaurusStore extends Store {
|
|
1233
1283
|
constructor() {
|
|
1234
|
-
super(initialState
|
|
1284
|
+
super(initialState);
|
|
1235
1285
|
}
|
|
1236
1286
|
setDirty(value = true) {
|
|
1237
1287
|
this.update({
|
|
@@ -1244,14 +1294,15 @@ let EditThesaurusStore = class EditThesaurusStore extends Store {
|
|
|
1244
1294
|
});
|
|
1245
1295
|
}
|
|
1246
1296
|
};
|
|
1247
|
-
EditThesaurusStore.ɵ
|
|
1248
|
-
EditThesaurusStore
|
|
1249
|
-
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
1250
|
-
];
|
|
1251
|
-
EditThesaurusStore.ctorParameters = () => [];
|
|
1297
|
+
EditThesaurusStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditThesaurusStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1298
|
+
EditThesaurusStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditThesaurusStore, providedIn: 'root' });
|
|
1252
1299
|
EditThesaurusStore = __decorate([
|
|
1253
1300
|
StoreConfig({ name: 'edit-thesaurus', resettable: true })
|
|
1254
|
-
], EditThesaurusStore);
|
|
1301
|
+
], EditThesaurusStore);
|
|
1302
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditThesaurusStore, decorators: [{
|
|
1303
|
+
type: Injectable,
|
|
1304
|
+
args: [{ providedIn: 'root' }]
|
|
1305
|
+
}], ctorParameters: function () { return []; } });
|
|
1255
1306
|
|
|
1256
1307
|
class EditThesaurusQuery extends Query {
|
|
1257
1308
|
constructor(store) {
|
|
@@ -1268,13 +1319,12 @@ class EditThesaurusQuery extends Query {
|
|
|
1268
1319
|
return this.select(state => state.saving);
|
|
1269
1320
|
}
|
|
1270
1321
|
}
|
|
1271
|
-
EditThesaurusQuery.ɵ
|
|
1272
|
-
EditThesaurusQuery
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
];
|
|
1322
|
+
EditThesaurusQuery.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditThesaurusQuery, deps: [{ token: EditThesaurusStore }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1323
|
+
EditThesaurusQuery.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditThesaurusQuery, providedIn: 'root' });
|
|
1324
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditThesaurusQuery, decorators: [{
|
|
1325
|
+
type: Injectable,
|
|
1326
|
+
args: [{ providedIn: 'root' }]
|
|
1327
|
+
}], ctorParameters: function () { return [{ type: EditThesaurusStore }]; } });
|
|
1278
1328
|
|
|
1279
1329
|
class EditThesaurusService {
|
|
1280
1330
|
constructor(_store, _thesaurusService) {
|
|
@@ -1324,28 +1374,40 @@ class EditThesaurusService {
|
|
|
1324
1374
|
});
|
|
1325
1375
|
}
|
|
1326
1376
|
}
|
|
1327
|
-
EditThesaurusService.ɵ
|
|
1328
|
-
EditThesaurusService
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
{ type: ThesaurusService }
|
|
1334
|
-
];
|
|
1377
|
+
EditThesaurusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditThesaurusService, deps: [{ token: EditThesaurusStore }, { token: i2.ThesaurusService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1378
|
+
EditThesaurusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditThesaurusService, providedIn: 'root' });
|
|
1379
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: EditThesaurusService, decorators: [{
|
|
1380
|
+
type: Injectable,
|
|
1381
|
+
args: [{ providedIn: 'root' }]
|
|
1382
|
+
}], ctorParameters: function () { return [{ type: EditThesaurusStore }, { type: i2.ThesaurusService }]; } });
|
|
1335
1383
|
|
|
1336
1384
|
class CadmusStateModule {
|
|
1337
1385
|
}
|
|
1338
|
-
CadmusStateModule
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1386
|
+
CadmusStateModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CadmusStateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1387
|
+
CadmusStateModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CadmusStateModule, imports: [CommonModule,
|
|
1388
|
+
// Cadmus
|
|
1389
|
+
CadmusCoreModule,
|
|
1390
|
+
CadmusApiModule,
|
|
1391
|
+
CadmusMaterialModule] });
|
|
1392
|
+
CadmusStateModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CadmusStateModule, imports: [[
|
|
1393
|
+
CommonModule,
|
|
1394
|
+
// Cadmus
|
|
1395
|
+
CadmusCoreModule,
|
|
1396
|
+
CadmusApiModule,
|
|
1397
|
+
CadmusMaterialModule,
|
|
1398
|
+
]] });
|
|
1399
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CadmusStateModule, decorators: [{
|
|
1400
|
+
type: NgModule,
|
|
1401
|
+
args: [{
|
|
1402
|
+
imports: [
|
|
1403
|
+
CommonModule,
|
|
1404
|
+
// Cadmus
|
|
1405
|
+
CadmusCoreModule,
|
|
1406
|
+
CadmusApiModule,
|
|
1407
|
+
CadmusMaterialModule,
|
|
1408
|
+
],
|
|
1409
|
+
}]
|
|
1410
|
+
}] });
|
|
1349
1411
|
|
|
1350
1412
|
/*
|
|
1351
1413
|
* Public API Surface of cadmus-state
|
|
@@ -1356,4 +1418,3 @@ CadmusStateModule.decorators = [
|
|
|
1356
1418
|
*/
|
|
1357
1419
|
|
|
1358
1420
|
export { AppQuery, AppService, AppStore, CadmusStateModule, EditFragmentFeatureBase, EditFragmentQueryBase, EditFragmentServiceBase, EditFragmentStore, EditItemQuery, EditItemService, EditItemStore, EditLayerPartQuery, EditLayerPartService, EditLayerPartStore, EditPartFeatureBase, EditPartQueryBase, EditPartServiceBase, EditPartStore, EditThesaurusQuery, EditThesaurusService, EditThesaurusStore, editFragmentInitialState, editPartInitialState };
|
|
1359
|
-
//# sourceMappingURL=myrmidon-cadmus-state.js.map
|