@myrmidon/cadmus-state 0.2.0 → 0.3.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.
Files changed (47) hide show
  1. package/esm2020/lib/app.query.mjs +1 -1
  2. package/esm2020/lib/app.service.mjs +1 -1
  3. package/esm2020/lib/app.store.mjs +1 -3
  4. package/esm2020/lib/cadmus-state.module.mjs +6 -2
  5. package/esm2020/lib/edit-fragment-feature-base.mjs +6 -3
  6. package/esm2020/lib/edit-fragment-query-base.mjs +1 -1
  7. package/esm2020/lib/edit-fragment-service-base.mjs +7 -4
  8. package/esm2020/lib/edit-fragment.store.mjs +1 -4
  9. package/esm2020/lib/edit-item.query.mjs +3 -3
  10. package/esm2020/lib/edit-item.service.mjs +18 -18
  11. package/esm2020/lib/edit-item.store.mjs +4 -11
  12. package/esm2020/lib/edit-layer-part.query.mjs +1 -1
  13. package/esm2020/lib/edit-layer-part.service.mjs +7 -7
  14. package/esm2020/lib/edit-layer-part.store.mjs +1 -5
  15. package/esm2020/lib/edit-part-feature-base.mjs +3 -3
  16. package/esm2020/lib/edit-part-query-base.mjs +3 -3
  17. package/esm2020/lib/edit-part-service-base.mjs +7 -7
  18. package/esm2020/lib/edit-part.store.mjs +2 -10
  19. package/esm2020/lib/edit-thesaurus.query.mjs +4 -4
  20. package/esm2020/lib/edit-thesaurus.service.mjs +2 -2
  21. package/esm2020/lib/edit-thesaurus.store.mjs +2 -9
  22. package/fesm2015/myrmidon-cadmus-state.mjs +77 -89
  23. package/fesm2015/myrmidon-cadmus-state.mjs.map +1 -1
  24. package/fesm2020/myrmidon-cadmus-state.mjs +68 -89
  25. package/fesm2020/myrmidon-cadmus-state.mjs.map +1 -1
  26. package/lib/app.query.d.ts +4 -4
  27. package/lib/app.service.d.ts +1 -1
  28. package/lib/app.store.d.ts +2 -2
  29. package/lib/cadmus-state.module.d.ts +2 -1
  30. package/lib/edit-fragment-feature-base.d.ts +7 -7
  31. package/lib/edit-fragment-query-base.d.ts +5 -5
  32. package/lib/edit-fragment-service-base.d.ts +1 -1
  33. package/lib/edit-fragment.store.d.ts +2 -2
  34. package/lib/edit-item.query.d.ts +6 -6
  35. package/lib/edit-item.service.d.ts +2 -2
  36. package/lib/edit-item.store.d.ts +5 -5
  37. package/lib/edit-layer-part.query.d.ts +6 -6
  38. package/lib/edit-layer-part.service.d.ts +1 -1
  39. package/lib/edit-layer-part.store.d.ts +3 -3
  40. package/lib/edit-part-feature-base.d.ts +9 -9
  41. package/lib/edit-part-query-base.d.ts +4 -4
  42. package/lib/edit-part-service-base.d.ts +3 -3
  43. package/lib/edit-part.store.d.ts +2 -3
  44. package/lib/edit-thesaurus.query.d.ts +2 -3
  45. package/lib/edit-thesaurus.service.d.ts +1 -1
  46. package/lib/edit-thesaurus.store.d.ts +1 -1
  47. package/package.json +3 -3
@@ -2,16 +2,9 @@ import { __decorate } from "tslib";
2
2
  import { Injectable } from '@angular/core';
3
3
  import { StoreConfig, Store } from '@datorama/akita';
4
4
  import * as i0 from "@angular/core";
5
- const initialState = {
6
- thesaurus: null,
7
- dirty: false,
8
- saving: false,
9
- loading: false,
10
- error: null,
11
- };
12
5
  let EditThesaurusStore = class EditThesaurusStore extends Store {
13
6
  constructor() {
14
- super(initialState);
7
+ super({});
15
8
  }
16
9
  setDirty(value = true) {
17
10
  this.update({
@@ -34,4 +27,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
34
27
  type: Injectable,
35
28
  args: [{ providedIn: 'root' }]
36
29
  }], ctorParameters: function () { return []; } });
37
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWRpdC10aGVzYXVydXMuc3RvcmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9teXJtaWRvbi9jYWRtdXMtc3RhdGUvc3JjL2xpYi9lZGl0LXRoZXNhdXJ1cy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9KTtcclxuICB9XHJcblxyXG4gIHB1YmxpYyBzZXRTYXZpbmcodmFsdWUgPSB0cnVlKTogdm9pZCB7XHJcbiAgICB0aGlzLnVwZGF0ZSh7XHJcbiAgICAgIHNhdmluZzogdmFsdWUsXHJcbiAgICB9KTtcclxuICB9XHJcbn1cclxuIl19
@@ -7,19 +7,17 @@ import * as i2 from '@myrmidon/cadmus-api';
7
7
  import { CadmusApiModule } from '@myrmidon/cadmus-api';
8
8
  import * as i2$1 from '@myrmidon/cadmus-core';
9
9
  import { TokenLocation, CadmusCoreModule } from '@myrmidon/cadmus-core';
10
- import { deepCopy } from '@myrmidon/ng-tools';
10
+ import { deepCopy, NgToolsModule } from '@myrmidon/ng-tools';
11
11
  import { CommonModule } from '@angular/common';
12
12
  import { CadmusMaterialModule } from '@myrmidon/cadmus-material';
13
13
 
14
- const initialState$3 = {
14
+ const initialState$2 = {
15
15
  facets: [],
16
16
  flags: [],
17
- typeThesaurus: null,
18
- itemBrowserThesaurus: null,
19
17
  };
20
18
  let AppStore = class AppStore extends Store {
21
19
  constructor() {
22
- super(initialState$3);
20
+ super(initialState$2);
23
21
  }
24
22
  };
25
23
  AppStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AppStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
@@ -95,35 +93,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
95
93
  args: [{ providedIn: 'root' }]
96
94
  }], ctorParameters: function () { return [{ type: AppStore }, { type: i2.FacetService }, { type: i2.FlagService }, { type: i2.ThesaurusService }]; } });
97
95
 
98
- const initialState$2 = {
99
- item: null,
96
+ const initialState$1 = {
100
97
  parts: [],
101
98
  partGroups: [],
102
99
  layerPartInfos: [],
103
- facet: null,
104
- dirty: false,
105
- saving: false,
106
- deletingPart: false,
107
- loading: false,
108
- error: null
109
100
  };
110
101
  let EditItemStore = class EditItemStore extends Store {
111
102
  constructor() {
112
- super(initialState$2);
103
+ super(initialState$1);
113
104
  }
114
105
  setDirty(value = true) {
115
106
  this.update({
116
- dirty: value
107
+ dirty: value,
117
108
  });
118
109
  }
119
110
  setSaving(value = true) {
120
111
  this.update({
121
- saving: value
112
+ saving: value,
122
113
  });
123
114
  }
124
115
  setDeletingPart(value = true) {
125
116
  this.update({
126
- deletingPart: value
117
+ deletingPart: value,
127
118
  });
128
119
  }
129
120
  };
@@ -161,14 +152,14 @@ class EditItemQuery extends Query {
161
152
  selectDeletingPart() {
162
153
  return this.select((state) => state.deletingPart);
163
154
  }
164
- hasItem(id = null) {
155
+ hasItem(id) {
165
156
  const item = this.getValue().item;
166
157
  if (!item || (id && id !== item.id)) {
167
158
  return false;
168
159
  }
169
160
  return true;
170
161
  }
171
- getEditorKeyFromPartTypeId(typeId, roleId = null) {
162
+ getEditorKeyFromPartTypeId(typeId, roleId) {
172
163
  const facet = this.getValue().facet;
173
164
  if (!facet) {
174
165
  return 'default';
@@ -195,7 +186,7 @@ class EditItemService {
195
186
  }
196
187
  pickDefaultFacet(facets) {
197
188
  if (!facets.length) {
198
- return null;
189
+ return undefined;
199
190
  }
200
191
  // if there is a facet with id="default", pick it
201
192
  const defaultFacet = facets.find((f) => f.id === 'default');
@@ -211,9 +202,9 @@ class EditItemService {
211
202
  */
212
203
  load(itemId) {
213
204
  this._store.setLoading(true);
214
- const layers$ = this._itemService.getItemLayerInfo(itemId, true);
215
205
  const appState = this._appQuery.getValue();
216
206
  // if not a new item, include it in load
207
+ const layers$ = this._itemService.getItemLayerInfo(itemId || '', true);
217
208
  if (itemId) {
218
209
  forkJoin({
219
210
  item: this._itemService.getItem(itemId, true),
@@ -228,7 +219,7 @@ class EditItemService {
228
219
  this._store.update({
229
220
  item: result.item,
230
221
  parts: result.item.parts,
231
- partGroups: this._itemService.groupParts(result.item.parts, facetParts),
222
+ partGroups: this._itemService.groupParts(result.item.parts || [], facetParts),
232
223
  layerPartInfos: result.layers,
233
224
  facet: appState.facets.find((f) => f.id === result.item.facetId),
234
225
  });
@@ -247,17 +238,17 @@ class EditItemService {
247
238
  this._store.setError(null);
248
239
  this._store.update({
249
240
  item: {
250
- id: null,
251
- title: null,
252
- description: null,
253
- facetId: null,
254
- groupId: null,
255
- sortKey: null,
241
+ id: '',
242
+ title: '',
243
+ description: '',
244
+ facetId: '',
245
+ groupId: '',
246
+ sortKey: '',
256
247
  flags: 0,
257
248
  timeCreated: new Date(),
258
- creatorId: null,
249
+ creatorId: '',
259
250
  timeModified: new Date(),
260
- userId: null,
251
+ userId: '',
261
252
  },
262
253
  parts: [],
263
254
  partGroups: [],
@@ -306,9 +297,10 @@ class EditItemService {
306
297
  return new Promise((resolve, reject) => {
307
298
  // delete from server
308
299
  this._itemService.deletePart(id).subscribe((_) => {
300
+ var _a;
309
301
  this._store.setDeletingPart(false);
310
302
  // reload the store
311
- this.load(this._store.getValue().item.id);
303
+ this.load((_a = this._store.getValue().item) === null || _a === void 0 ? void 0 : _a.id);
312
304
  resolve(id);
313
305
  }, (error) => {
314
306
  console.log(error);
@@ -323,17 +315,18 @@ class EditItemService {
323
315
  itemId,
324
316
  typeId,
325
317
  roleId,
326
- id: null,
327
- creatorId: null,
328
- userId: null,
318
+ id: '',
319
+ creatorId: '',
320
+ userId: '',
329
321
  timeCreated: new Date(),
330
322
  timeModified: new Date(),
331
323
  };
332
324
  this._store.setSaving();
333
325
  this._itemService.addPart(part).subscribe((_) => {
326
+ var _a;
334
327
  this._store.setSaving(false);
335
328
  // reload the store
336
- this.load(this._store.getValue().item.id);
329
+ this.load((_a = this._store.getValue().item) === null || _a === void 0 ? void 0 : _a.id);
337
330
  }, (error) => {
338
331
  console.log(error);
339
332
  this._store.setSaving(false);
@@ -343,9 +336,10 @@ class EditItemService {
343
336
  setPartThesaurusScope(ids, scope) {
344
337
  this._store.setSaving();
345
338
  this._itemService.setPartThesaurusScope(ids, scope).subscribe((_) => {
339
+ var _a;
346
340
  this._store.setSaving(false);
347
341
  // reload the store
348
- this.load(this._store.getValue().item.id);
342
+ this.load((_a = this._store.getValue().item) === null || _a === void 0 ? void 0 : _a.id);
349
343
  }, (error) => {
350
344
  console.log(error);
351
345
  this._store.setSaving(false);
@@ -376,6 +370,9 @@ class EditFragmentFeatureBase {
376
370
  this._editLayersQuery = _editLayersQuery;
377
371
  this._editLayersService = _editLayersService;
378
372
  this._libraryRouteService = _libraryRouteService;
373
+ this.fragment$ = this._editFrQuery.selectFragment();
374
+ this.thesauri$ = this._editFrQuery.selectThesauri();
375
+ this.baseText$ = this._editLayersQuery.select((state) => state.baseText);
379
376
  this.itemId = route.snapshot.params.iid;
380
377
  this.partId = route.snapshot.params.pid;
381
378
  this.frTypeId = (_a = route.snapshot.url[2]) === null || _a === void 0 ? void 0 : _a.path;
@@ -384,7 +381,7 @@ class EditFragmentFeatureBase {
384
381
  // connect _stateDirty to the value of the edit state
385
382
  this._editFrQuery.selectDirty().subscribe((d) => {
386
383
  console.log('fr dirty change (from state): ' + d);
387
- this._stateDirty = d;
384
+ this._stateDirty = d ? true : false;
388
385
  });
389
386
  }
390
387
  /**
@@ -414,10 +411,11 @@ class EditFragmentFeatureBase {
414
411
  * to use in your editor.
415
412
  */
416
413
  initEditor(thesauriIds) {
414
+ var _a;
417
415
  this.fragment$ = this._editFrQuery.selectFragment();
418
416
  this.thesauri$ = this._editFrQuery.selectThesauri();
419
417
  this.baseText$ = this._editLayersQuery.select((state) => state.baseText);
420
- this.frLoc = TokenLocation.parse(this.loc);
418
+ this.frLoc = (_a = TokenLocation.parse(this.loc)) !== null && _a !== void 0 ? _a : undefined;
421
419
  // load item if required
422
420
  this.ensureItemLoaded(this.itemId);
423
421
  // load layers if required
@@ -507,12 +505,9 @@ class EditFragmentQueryBase extends Query {
507
505
  }
508
506
 
509
507
  const editFragmentInitialState = {
510
- fragment: null,
511
- thesauri: null,
512
508
  dirty: false,
513
509
  saving: false,
514
510
  loading: false,
515
- error: null,
516
511
  };
517
512
  /**
518
513
  * General-purpose edit-fragment store. This can be used with any fragment,
@@ -557,19 +552,23 @@ class EditFragmentServiceBase {
557
552
  * @param thesauriIds The thesauri IDs array, or null.
558
553
  */
559
554
  load(partId, loc, thesauriIds = null) {
555
+ if (!this.store) {
556
+ return;
557
+ }
560
558
  // signal that we're loading
561
559
  this.store.setLoading(true);
562
560
  // if thesauri are required:
563
561
  if (thesauriIds) {
564
562
  // remove trailing ! from IDs if any
565
563
  const unscopedIds = thesauriIds.map((id) => {
566
- return this._thesaurusService.getScopedId(id, null);
564
+ return this._thesaurusService.getScopedId(id);
567
565
  });
568
566
  // fetch fragment and thesauri
569
567
  forkJoin({
570
568
  part: this._itemService.getPart(partId),
571
569
  thesauri: this._thesaurusService.getThesauriSet(unscopedIds),
572
570
  }).subscribe((result) => {
571
+ var _a;
573
572
  // loading has ended
574
573
  this.store.setLoading(false);
575
574
  const layerPart = result.part;
@@ -595,9 +594,10 @@ class EditFragmentServiceBase {
595
594
  });
596
595
  }
597
596
  // if the loaded layer part has a thesaurus scope, reload the thesauri
598
- if (result.part.thesaurusScope) {
597
+ if ((_a = result.part) === null || _a === void 0 ? void 0 : _a.thesaurusScope) {
599
598
  const scopedIds = thesauriIds.map((id) => {
600
- return this._thesaurusService.getScopedId(id, result.part.thesaurusScope);
599
+ var _a;
600
+ return this._thesaurusService.getScopedId(id, (_a = result.part) === null || _a === void 0 ? void 0 : _a.thesaurusScope);
601
601
  });
602
602
  // loading again
603
603
  this.store.setLoading(true);
@@ -705,12 +705,12 @@ class EditPartFeatureBase {
705
705
  // part ID or null (if "new")
706
706
  this.partId = route.snapshot.params.pid;
707
707
  if (this.partId === 'new') {
708
- this.partId = null;
708
+ this.partId = undefined;
709
709
  }
710
710
  // role ID or null (if "default")
711
711
  this.roleId = route.snapshot.queryParams.rid;
712
712
  if (this.roleId === 'default') {
713
- this.roleId = null;
713
+ this.roleId = undefined;
714
714
  }
715
715
  // connect _stateDirty to the value observed in the part state
716
716
  this._editPartQuery.selectDirty().subscribe((d) => {
@@ -809,10 +809,10 @@ class EditPartQueryBase extends Query {
809
809
  return this.select((state) => state.saving);
810
810
  }
811
811
  selectPart() {
812
- return this.select((state) => state.part);
812
+ return this.select((state) => state.part || undefined);
813
813
  }
814
814
  selectThesauri() {
815
- return this.select((state) => state.thesauri);
815
+ return this.select((state) => state.thesauri || undefined);
816
816
  }
817
817
  }
818
818
 
@@ -831,23 +831,23 @@ class EditPartServiceBase {
831
831
  * it will get a null ID, but use the specified itemId and roleId.
832
832
  *
833
833
  * @param partId The part ID, unless it's a new part.
834
- * @param thesauriIds The thesauri IDs array, or null.
834
+ * @param thesauriIds The thesauri IDs array.
835
835
  * @param itemId The item ID for the new part.
836
836
  * @param typeId The part type ID for the new part.
837
837
  * @param roleId The role ID for the new part.
838
838
  */
839
- load(partId, thesauriIds = null, itemId, typeId, roleId) {
839
+ load(partId, thesauriIds, itemId, typeId, roleId) {
840
840
  // signal that we're loading
841
841
  this.store.setLoading(true);
842
842
  // if thesauri are required:
843
843
  if (thesauriIds) {
844
844
  // remove trailing ! from IDs if any
845
845
  const unscopedIds = thesauriIds.map((id) => {
846
- return this.thesaurusService.getScopedId(id, null);
846
+ return this.thesaurusService.getScopedId(id);
847
847
  });
848
848
  // fetch part and thesauri
849
849
  forkJoin({
850
- part: this.itemService.getPart(partId),
850
+ part: this.itemService.getPart(partId || ''),
851
851
  thesauri: this.thesaurusService.getThesauriSet(unscopedIds),
852
852
  }).subscribe((result) => {
853
853
  var _a;
@@ -867,7 +867,8 @@ class EditPartServiceBase {
867
867
  // if the loaded part has a thesaurus scope, reload the thesauri
868
868
  if ((_a = result.part) === null || _a === void 0 ? void 0 : _a.thesaurusScope) {
869
869
  const scopedIds = thesauriIds.map((id) => {
870
- return this.thesaurusService.getScopedId(id, result.part.thesaurusScope);
870
+ var _a;
871
+ return this.thesaurusService.getScopedId(id, (_a = result.part) === null || _a === void 0 ? void 0 : _a.thesaurusScope);
871
872
  });
872
873
  // loading again
873
874
  this.store.setLoading(true);
@@ -887,7 +888,7 @@ class EditPartServiceBase {
887
888
  }
888
889
  else {
889
890
  // without thesauri to be fetched, just fetch the part
890
- this.itemService.getPart(partId).subscribe((part) => {
891
+ this.itemService.getPart(partId || '').subscribe((part) => {
891
892
  this.store.update({
892
893
  part: part || {
893
894
  id: null,
@@ -936,14 +937,6 @@ class EditPartServiceBase {
936
937
  }
937
938
  }
938
939
 
939
- const editPartInitialState = {
940
- part: null,
941
- thesauri: null,
942
- dirty: false,
943
- saving: false,
944
- loading: false,
945
- error: null,
946
- };
947
940
  /**
948
941
  * General-purpose edit-part store. This can be used with any part, so that
949
942
  * you should only provide your part store, query, and service (usually
@@ -951,7 +944,7 @@ const editPartInitialState = {
951
944
  */
952
945
  let EditPartStore = class EditPartStore extends Store {
953
946
  constructor() {
954
- super(editPartInitialState);
947
+ super({});
955
948
  }
956
949
  setDirty(value) {
957
950
  this.update({ dirty: value });
@@ -970,16 +963,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
970
963
  args: [{ providedIn: 'root' }]
971
964
  }], ctorParameters: function () { return []; } });
972
965
 
973
- const initialState$1 = {
974
- part: null,
975
- baseText: null,
976
- baseTextPart: null,
966
+ const initialState = {
977
967
  locations: [],
978
968
  breakChance: -1,
979
969
  layerHints: [],
980
970
  thesauri: {},
981
971
  loading: false,
982
- error: null,
983
972
  deletingFragment: false,
984
973
  savingFragment: false,
985
974
  refreshingBreakChance: false,
@@ -987,7 +976,7 @@ const initialState$1 = {
987
976
  };
988
977
  let EditLayerPartStore = class EditLayerPartStore extends Store {
989
978
  constructor() {
990
- super(initialState$1);
979
+ super(initialState);
991
980
  }
992
981
  setDeletingFragment(value = true) {
993
982
  this.update({ deletingFragment: value });
@@ -1072,7 +1061,7 @@ class EditLayerPartService {
1072
1061
  * @param partId The layer part ID.
1073
1062
  * @param thesauriIds The optional thesauri IDs to load.
1074
1063
  */
1075
- load(itemId, partId, thesauriIds = null) {
1064
+ load(itemId, partId, thesauriIds) {
1076
1065
  if (this._store.getValue().loading) {
1077
1066
  return;
1078
1067
  }
@@ -1080,7 +1069,7 @@ class EditLayerPartService {
1080
1069
  if (thesauriIds) {
1081
1070
  // remove trailing ! from IDs if any
1082
1071
  const unscopedIds = thesauriIds.map((id) => {
1083
- return this._thesaurusService.getScopedId(id, null);
1072
+ return this._thesaurusService.getScopedId(id);
1084
1073
  });
1085
1074
  forkJoin({
1086
1075
  // TODO: eventually optimize by adding method param to load only fragments locations
@@ -1091,6 +1080,7 @@ class EditLayerPartService {
1091
1080
  layerHints: this._itemService.getLayerPartHints(partId),
1092
1081
  thesauri: this._thesaurusService.getThesauriSet(unscopedIds),
1093
1082
  }).subscribe((result) => {
1083
+ var _a;
1094
1084
  this._store.update({
1095
1085
  part: result.layerPart,
1096
1086
  baseText: result.baseText.text,
@@ -1100,10 +1090,10 @@ class EditLayerPartService {
1100
1090
  layerHints: result.layerHints,
1101
1091
  thesauri: result.thesauri,
1102
1092
  loading: false,
1103
- error: null,
1093
+ error: undefined,
1104
1094
  });
1105
1095
  // if the loaded part has a thesaurus scope, reload the thesauri
1106
- if (result.layerPart.thesaurusScope) {
1096
+ if ((_a = result.layerPart) === null || _a === void 0 ? void 0 : _a.thesaurusScope) {
1107
1097
  const scopedIds = thesauriIds.map((id) => {
1108
1098
  return this._thesaurusService.getScopedId(id, result.layerPart.thesaurusScope);
1109
1099
  });
@@ -1141,7 +1131,7 @@ class EditLayerPartService {
1141
1131
  breakChance: result.breakChance.chance,
1142
1132
  layerHints: result.layerHints,
1143
1133
  loading: false,
1144
- error: null,
1134
+ error: undefined,
1145
1135
  });
1146
1136
  }, (error) => {
1147
1137
  console.error(error);
@@ -1194,7 +1184,8 @@ class EditLayerPartService {
1194
1184
  return;
1195
1185
  }
1196
1186
  const i = part.fragments.findIndex((p) => {
1197
- return TokenLocation.parse(p.location).overlaps(loc);
1187
+ var _a;
1188
+ return (_a = TokenLocation.parse(p.location)) === null || _a === void 0 ? void 0 : _a.overlaps(loc);
1198
1189
  });
1199
1190
  if (i === -1) {
1200
1191
  return;
@@ -1272,16 +1263,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
1272
1263
  args: [{ providedIn: 'root' }]
1273
1264
  }], ctorParameters: function () { return [{ type: EditLayerPartStore }, { type: i2.ItemService }, { type: i2.FacetService }, { type: i2.ThesaurusService }]; } });
1274
1265
 
1275
- const initialState = {
1276
- thesaurus: null,
1277
- dirty: false,
1278
- saving: false,
1279
- loading: false,
1280
- error: null,
1281
- };
1282
1266
  let EditThesaurusStore = class EditThesaurusStore extends Store {
1283
1267
  constructor() {
1284
- super(initialState);
1268
+ super({});
1285
1269
  }
1286
1270
  setDirty(value = true) {
1287
1271
  this.update({
@@ -1312,9 +1296,9 @@ class EditThesaurusQuery extends Query {
1312
1296
  selectThesaurus() {
1313
1297
  return this.select(state => state.thesaurus);
1314
1298
  }
1315
- selectLoading() {
1316
- return this.select(state => state.loading);
1317
- }
1299
+ // public selectLoading(): Observable<boolean | undefined> {
1300
+ // return this.select(state => state.loading);
1301
+ // }
1318
1302
  selectSaving() {
1319
1303
  return this.select(state => state.saving);
1320
1304
  }
@@ -1348,7 +1332,7 @@ class EditThesaurusService {
1348
1332
  else {
1349
1333
  this._store.update({
1350
1334
  thesaurus: {
1351
- id: null,
1335
+ id: '',
1352
1336
  language: 'en',
1353
1337
  entries: [],
1354
1338
  },
@@ -1388,13 +1372,15 @@ CadmusStateModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", versi
1388
1372
  // Cadmus
1389
1373
  CadmusCoreModule,
1390
1374
  CadmusApiModule,
1391
- CadmusMaterialModule] });
1375
+ CadmusMaterialModule,
1376
+ NgToolsModule] });
1392
1377
  CadmusStateModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CadmusStateModule, imports: [[
1393
1378
  CommonModule,
1394
1379
  // Cadmus
1395
1380
  CadmusCoreModule,
1396
1381
  CadmusApiModule,
1397
1382
  CadmusMaterialModule,
1383
+ NgToolsModule
1398
1384
  ]] });
1399
1385
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CadmusStateModule, decorators: [{
1400
1386
  type: NgModule,
@@ -1405,6 +1391,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
1405
1391
  CadmusCoreModule,
1406
1392
  CadmusApiModule,
1407
1393
  CadmusMaterialModule,
1394
+ NgToolsModule
1408
1395
  ],
1409
1396
  }]
1410
1397
  }] });
@@ -1417,4 +1404,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
1417
1404
  * Generated bundle index. Do not edit.
1418
1405
  */
1419
1406
 
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 };
1407
+ export { AppQuery, AppService, AppStore, CadmusStateModule, EditFragmentFeatureBase, EditFragmentQueryBase, EditFragmentServiceBase, EditFragmentStore, EditItemQuery, EditItemService, EditItemStore, EditLayerPartQuery, EditLayerPartService, EditLayerPartStore, EditPartFeatureBase, EditPartQueryBase, EditPartServiceBase, EditPartStore, EditThesaurusQuery, EditThesaurusService, EditThesaurusStore, editFragmentInitialState };
1408
+ //# sourceMappingURL=myrmidon-cadmus-state.mjs.map