@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,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ThesauriSet, ComponentCanDeactivate } from '@myrmidon/cadmus-core';
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { ThesauriSet, ComponentCanDeactivate, Part } from '@myrmidon/cadmus-core';
|
|
3
3
|
import { Router, ActivatedRoute } from '@angular/router';
|
|
4
4
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
|
5
5
|
import { EditPartQueryBase } from './edit-part-query-base';
|
|
@@ -8,16 +8,17 @@ import { EditItemQuery } from './edit-item.query';
|
|
|
8
8
|
import { EditItemService } from './edit-item.service';
|
|
9
9
|
/**
|
|
10
10
|
* Base class for part feature editors.
|
|
11
|
-
* A part feature editor is a wrapper component, linking a part edit
|
|
12
|
-
* (accessed from a part query and loaded with a part service)
|
|
13
|
-
*
|
|
14
|
-
* It implements ComponentCanDeactivate to allow using the
|
|
15
|
-
* To this end, it tracks the dirty state of
|
|
16
|
-
* different sources: the wrapped editor
|
|
17
|
-
* the store edit state. This is
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
11
|
+
* A part feature editor is a wrapper component, linking a part edit
|
|
12
|
+
* state (accessed from a part query and loaded with a part service)
|
|
13
|
+
* to a corresponding wrapped UI editor.
|
|
14
|
+
* It implements ComponentCanDeactivate to allow using the
|
|
15
|
+
* PendingChangesGuard. To this end, it tracks the dirty state of
|
|
16
|
+
* the edited data coming from 2 different sources: the wrapped editor
|
|
17
|
+
* state (from its "root" form), and the store edit state. This is
|
|
18
|
+
* set to dirty when a save attempt fails.
|
|
19
|
+
* Thus, at the end the user will be prompted when closing an editor
|
|
20
|
+
* either because he has changed data in it, or because he attempted
|
|
21
|
+
* a save without success.
|
|
21
22
|
*/
|
|
22
23
|
export declare abstract class EditPartFeatureBase implements ComponentCanDeactivate {
|
|
23
24
|
protected router: Router;
|
|
@@ -28,11 +29,32 @@ export declare abstract class EditPartFeatureBase implements ComponentCanDeactiv
|
|
|
28
29
|
private _editItemService;
|
|
29
30
|
private _formDirty;
|
|
30
31
|
private _stateDirty;
|
|
31
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The part being edited (from the local store).
|
|
34
|
+
*/
|
|
35
|
+
part$: Observable<Part>;
|
|
36
|
+
/**
|
|
37
|
+
* The thesauri requested for editing this part.
|
|
38
|
+
*/
|
|
32
39
|
thesauri$: Observable<ThesauriSet>;
|
|
40
|
+
/**
|
|
41
|
+
* The item ID of the edited part, as got from the route.
|
|
42
|
+
*/
|
|
33
43
|
itemId: string;
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
/**
|
|
45
|
+
* The part type ID of the edited part, as got from the route.
|
|
46
|
+
*/
|
|
47
|
+
typeId: string | null;
|
|
48
|
+
/**
|
|
49
|
+
* The part ID of the edited part, as got from the route;
|
|
50
|
+
* or null for a new part.
|
|
51
|
+
*/
|
|
52
|
+
partId: string | null;
|
|
53
|
+
/**
|
|
54
|
+
* The role ID of the edited part, as got from the route,
|
|
55
|
+
* or null.
|
|
56
|
+
*/
|
|
57
|
+
roleId: string | null;
|
|
36
58
|
constructor(router: Router, route: ActivatedRoute, snackbar: MatSnackBar, _editPartQuery: EditPartQueryBase, _editPartService: EditPartServiceBase, _editItemQuery: EditItemQuery, _editItemService: EditItemService);
|
|
37
59
|
/**
|
|
38
60
|
* Implementation of ComponentCanDeactivate. The editor can deactivate
|
|
@@ -44,6 +66,7 @@ export declare abstract class EditPartFeatureBase implements ComponentCanDeactiv
|
|
|
44
66
|
private ensureItemLoaded;
|
|
45
67
|
/**
|
|
46
68
|
* Initialize the editor. You MUST call this in your OnInit.
|
|
69
|
+
*
|
|
47
70
|
* @param thesauriIds The optional ID(s) of the thesauri sets you want
|
|
48
71
|
* to use in your editor.
|
|
49
72
|
*/
|
|
@@ -52,14 +75,16 @@ export declare abstract class EditPartFeatureBase implements ComponentCanDeactiv
|
|
|
52
75
|
* Called when the wrapped editor dirty state changes.
|
|
53
76
|
* In the HTML template, you MUST bind this handler to the dirtyChange event
|
|
54
77
|
* emitted by your wrapped editor (i.e. (dirtyChange)="onDirtyChange($event)").
|
|
78
|
+
*
|
|
55
79
|
* @param value The value of the dirty state.
|
|
56
80
|
*/
|
|
57
81
|
onDirtyChange(value: boolean): void;
|
|
58
82
|
/**
|
|
59
83
|
* Save the part.
|
|
60
|
-
*
|
|
84
|
+
*
|
|
85
|
+
* @param part The part to be saved.
|
|
61
86
|
*/
|
|
62
|
-
save(
|
|
87
|
+
save(part: Part): void;
|
|
63
88
|
/**
|
|
64
89
|
* Close the editor by navigating back to the part's item.
|
|
65
90
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Part, ThesauriSet } from '@myrmidon/cadmus-core';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { Query } from '@datorama/akita';
|
|
4
4
|
import { EditPartState } from './edit-part.store';
|
|
@@ -9,10 +9,9 @@ import { EditPartState } from './edit-part.store';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare abstract class EditPartQueryBase extends Query<EditPartState> {
|
|
11
11
|
protected store: any;
|
|
12
|
-
|
|
13
|
-
constructor(store: any, _utilService: UtilService);
|
|
12
|
+
constructor(store: any);
|
|
14
13
|
selectDirty(): Observable<boolean>;
|
|
15
14
|
selectSaving(): Observable<boolean>;
|
|
16
|
-
|
|
15
|
+
selectPart(): Observable<Part>;
|
|
17
16
|
selectThesauri(): Observable<ThesauriSet>;
|
|
18
17
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ItemService, ThesaurusService } from '@myrmidon/cadmus-api';
|
|
2
2
|
import { Part } from '@myrmidon/cadmus-core';
|
|
3
|
+
/**
|
|
4
|
+
* API provided by any Akita-based part store.
|
|
5
|
+
*/
|
|
3
6
|
export interface EditPartStoreApi {
|
|
4
7
|
update(value: any): void;
|
|
5
8
|
setLoading(value: boolean): void;
|
|
@@ -7,19 +10,33 @@ export interface EditPartStoreApi {
|
|
|
7
10
|
setSaving(value: boolean): void;
|
|
8
11
|
setError(value: string): void;
|
|
9
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Base class for part editor services.
|
|
15
|
+
*/
|
|
10
16
|
export declare abstract class EditPartServiceBase {
|
|
11
17
|
protected itemService: ItemService;
|
|
12
18
|
protected thesaurusService: ThesaurusService;
|
|
13
19
|
protected store: EditPartStoreApi;
|
|
14
20
|
constructor(itemService: ItemService, thesaurusService: ThesaurusService);
|
|
15
|
-
load(partId: string | null, thesauriIds?: string[] | null): void;
|
|
16
21
|
/**
|
|
17
|
-
*
|
|
22
|
+
* Load into the state the part with the specified ID
|
|
23
|
+
* and its thesauri.
|
|
24
|
+
* If the ID is not specified, it's a new part; in this case,
|
|
25
|
+
* it will get a null ID, but use the specified itemId and roleId.
|
|
18
26
|
*
|
|
19
|
-
* @param
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
27
|
+
* @param partId The part ID, unless it's a new part.
|
|
28
|
+
* @param thesauriIds The thesauri IDs array, or null.
|
|
29
|
+
* @param itemId The item ID for the new part.
|
|
30
|
+
* @param typeId The part type ID for the new part.
|
|
31
|
+
* @param roleId The role ID for the new part.
|
|
22
32
|
*/
|
|
23
|
-
|
|
33
|
+
load(partId?: string, thesauriIds?: string[] | null, itemId?: string, typeId?: string, roleId?: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Save the part.
|
|
36
|
+
*
|
|
37
|
+
* @param part The part.
|
|
38
|
+
* @returns Promise which when successful returns the saved part.
|
|
39
|
+
*/
|
|
40
|
+
save(part: Part): Promise<Part>;
|
|
24
41
|
setDirty(value?: boolean): void;
|
|
25
42
|
}
|
package/lib/edit-part.store.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ThesauriSet, Part } from '@myrmidon/cadmus-core';
|
|
2
2
|
import { Store } from '@datorama/akita';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
3
4
|
/**
|
|
4
5
|
* The state of the currently edited part, if any.
|
|
5
6
|
*/
|
|
@@ -27,4 +28,6 @@ export declare class EditPartStore extends Store<EditPartState> {
|
|
|
27
28
|
constructor();
|
|
28
29
|
setDirty(value: boolean): void;
|
|
29
30
|
setSaving(value: boolean): void;
|
|
31
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<EditPartStore, never>;
|
|
32
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<EditPartStore>;
|
|
30
33
|
}
|
|
@@ -2,10 +2,13 @@ import { EditThesaurusState, EditThesaurusStore } from './edit-thesaurus.store';
|
|
|
2
2
|
import { Query } from '@datorama/akita';
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
4
|
import { Thesaurus } from '@myrmidon/cadmus-core';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
5
6
|
export declare class EditThesaurusQuery extends Query<EditThesaurusState> {
|
|
6
7
|
protected store: EditThesaurusStore;
|
|
7
8
|
constructor(store: EditThesaurusStore);
|
|
8
9
|
selectThesaurus(): Observable<Thesaurus>;
|
|
9
10
|
selectLoading(): Observable<boolean>;
|
|
10
11
|
selectSaving(): Observable<boolean>;
|
|
12
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<EditThesaurusQuery, never>;
|
|
13
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<EditThesaurusQuery>;
|
|
11
14
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { EditThesaurusStore } from './edit-thesaurus.store';
|
|
2
1
|
import { ThesaurusService } from '@myrmidon/cadmus-api';
|
|
3
2
|
import { Thesaurus } from '@myrmidon/cadmus-core';
|
|
3
|
+
import { EditThesaurusStore } from './edit-thesaurus.store';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
4
5
|
export declare class EditThesaurusService {
|
|
5
6
|
private _store;
|
|
6
7
|
private _thesaurusService;
|
|
@@ -8,4 +9,6 @@ export declare class EditThesaurusService {
|
|
|
8
9
|
load(id: string | null): void;
|
|
9
10
|
reset(): void;
|
|
10
11
|
save(thesaurus: Thesaurus): Promise<Thesaurus>;
|
|
12
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<EditThesaurusService, never>;
|
|
13
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<EditThesaurusService>;
|
|
11
14
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Thesaurus } from '@myrmidon/cadmus-core';
|
|
2
2
|
import { Store } from '@datorama/akita';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
3
4
|
export interface EditThesaurusState {
|
|
4
5
|
thesaurus: Thesaurus | null;
|
|
5
6
|
dirty?: boolean;
|
|
@@ -11,4 +12,6 @@ export declare class EditThesaurusStore extends Store<EditThesaurusState> {
|
|
|
11
12
|
constructor();
|
|
12
13
|
setDirty(value?: boolean): void;
|
|
13
14
|
setSaving(value?: boolean): void;
|
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<EditThesaurusStore, never>;
|
|
16
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<EditThesaurusStore>;
|
|
14
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myrmidon/cadmus-state",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Cadmus - application edit state.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Cadmus"
|
|
@@ -14,21 +14,33 @@
|
|
|
14
14
|
"name": "Daniele Fusi"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@angular/common": "^
|
|
18
|
-
"@angular/core": "^
|
|
19
|
-
"@myrmidon/cadmus-core": "^0.0
|
|
20
|
-
"@myrmidon/cadmus-api": "^0.0
|
|
21
|
-
"@myrmidon/cadmus-material": "^0.0
|
|
17
|
+
"@angular/common": "^13.0.0",
|
|
18
|
+
"@angular/core": "^13.0.0",
|
|
19
|
+
"@myrmidon/cadmus-core": "^0.2.0",
|
|
20
|
+
"@myrmidon/cadmus-api": "^0.2.0",
|
|
21
|
+
"@myrmidon/cadmus-material": "^0.1.0"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"tslib": "^2.0.0"
|
|
25
25
|
},
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"fesm2015": "fesm2015/myrmidon-cadmus-state.
|
|
26
|
+
"module": "fesm2015/myrmidon-cadmus-state.mjs",
|
|
27
|
+
"es2020": "fesm2020/myrmidon-cadmus-state.mjs",
|
|
28
|
+
"esm2020": "esm2020/myrmidon-cadmus-state.mjs",
|
|
29
|
+
"fesm2020": "fesm2020/myrmidon-cadmus-state.mjs",
|
|
30
|
+
"fesm2015": "fesm2015/myrmidon-cadmus-state.mjs",
|
|
31
31
|
"typings": "myrmidon-cadmus-state.d.ts",
|
|
32
|
-
"
|
|
32
|
+
"exports": {
|
|
33
|
+
"./package.json": {
|
|
34
|
+
"default": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./myrmidon-cadmus-state.d.ts",
|
|
38
|
+
"esm2020": "./esm2020/myrmidon-cadmus-state.mjs",
|
|
39
|
+
"es2020": "./fesm2020/myrmidon-cadmus-state.mjs",
|
|
40
|
+
"es2015": "./fesm2015/myrmidon-cadmus-state.mjs",
|
|
41
|
+
"node": "./fesm2015/myrmidon-cadmus-state.mjs",
|
|
42
|
+
"default": "./fesm2020/myrmidon-cadmus-state.mjs"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
33
45
|
"sideEffects": false
|
|
34
|
-
}
|
|
46
|
+
}
|