@myrmidon/cadmus-refs-asserted-ids 2.0.0 → 2.1.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.
@@ -0,0 +1,67 @@
1
+ import { EventEmitter } from '@angular/core';
2
+ import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
3
+ import { IndexLookupDefinitions, ThesaurusEntry } from '@myrmidon/cadmus-core';
4
+ import { DialogService } from '@myrmidon/ng-mat-tools';
5
+ import { AssertedCompositeId } from '../asserted-composite-id/asserted-composite-id.component';
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * Asserted IDs editor.
9
+ */
10
+ export declare class AssertedCompositeIdsComponent {
11
+ private _dialogService;
12
+ private _ids;
13
+ private _editedIndex;
14
+ edited?: AssertedCompositeId;
15
+ /**
16
+ * The asserted IDs.
17
+ */
18
+ get ids(): AssertedCompositeId[];
19
+ set ids(value: AssertedCompositeId[]);
20
+ idScopeEntries?: ThesaurusEntry[];
21
+ idTagEntries?: ThesaurusEntry[];
22
+ assTagEntries?: ThesaurusEntry[];
23
+ refTypeEntries: ThesaurusEntry[] | undefined;
24
+ refTagEntries: ThesaurusEntry[] | undefined;
25
+ /**
26
+ * True when the internal UI preselected mode should be by type rather than
27
+ * by item. User can change mode unless modeSwitching is false.
28
+ */
29
+ pinByTypeMode?: boolean;
30
+ /**
31
+ * True when the user can switch between by-type and by-item mode in
32
+ * the internal UI.
33
+ */
34
+ canSwitchMode?: boolean;
35
+ /**
36
+ * True when the user can edit the target's gid/label for internal targets.
37
+ */
38
+ canEditTarget?: boolean;
39
+ /**
40
+ * The lookup definitions to be used for the by-type lookup in the internal UI.
41
+ * If not specified, the lookup definitions will be got via injection
42
+ * when available; if the injected definitions are empty, the
43
+ * lookup definitions will be built from the model-types thesaurus;
44
+ * if this is not available either, the by-type lookup will be
45
+ * disabled.
46
+ */
47
+ lookupDefinitions?: IndexLookupDefinitions;
48
+ /**
49
+ * Emitted whenever any ID changes.
50
+ */
51
+ idsChange: EventEmitter<AssertedCompositeId[]>;
52
+ entries: FormControl<AssertedCompositeId[]>;
53
+ form: FormGroup;
54
+ constructor(formBuilder: FormBuilder, _dialogService: DialogService);
55
+ private updateForm;
56
+ private emitIdsChange;
57
+ addId(): void;
58
+ editId(id: AssertedCompositeId, index: number): void;
59
+ closeId(): void;
60
+ saveId(entry: AssertedCompositeId): void;
61
+ deleteId(index: number): void;
62
+ moveIdUp(index: number): void;
63
+ moveIdDown(index: number): void;
64
+ onIdChange(id: AssertedCompositeId): void;
65
+ static ɵfac: i0.ɵɵFactoryDeclaration<AssertedCompositeIdsComponent, never>;
66
+ static ɵcmp: i0.ɵɵComponentDeclaration<AssertedCompositeIdsComponent, "cadmus-refs-asserted-composite-ids", never, { "ids": { "alias": "ids"; "required": false; }; "idScopeEntries": { "alias": "idScopeEntries"; "required": false; }; "idTagEntries": { "alias": "idTagEntries"; "required": false; }; "assTagEntries": { "alias": "assTagEntries"; "required": false; }; "refTypeEntries": { "alias": "refTypeEntries"; "required": false; }; "refTagEntries": { "alias": "refTagEntries"; "required": false; }; "pinByTypeMode": { "alias": "pinByTypeMode"; "required": false; }; "canSwitchMode": { "alias": "canSwitchMode"; "required": false; }; "canEditTarget": { "alias": "canEditTarget"; "required": false; }; "lookupDefinitions": { "alias": "lookupDefinitions"; "required": false; }; }, { "idsChange": "idsChange"; }, never, never, false, never>;
67
+ }
@@ -1,22 +1,28 @@
1
1
  import * as i0 from "@angular/core";
2
2
  import * as i1 from "./asserted-id/asserted-id.component";
3
3
  import * as i2 from "./asserted-ids/asserted-ids.component";
4
- import * as i3 from "./scoped-pin-lookup/scoped-pin-lookup.component";
5
- import * as i4 from "@angular/common";
6
- import * as i5 from "@angular/forms";
7
- import * as i6 from "@angular/material/button";
8
- import * as i7 from "@angular/material/expansion";
9
- import * as i8 from "@angular/material/form-field";
10
- import * as i9 from "@angular/material/icon";
11
- import * as i10 from "@angular/material/input";
12
- import * as i11 from "@angular/material/select";
13
- import * as i12 from "@myrmidon/cadmus-core";
14
- import * as i13 from "@myrmidon/cadmus-refs-doc-references";
15
- import * as i14 from "@myrmidon/cadmus-refs-assertion";
16
- import * as i15 from "@myrmidon/cadmus-refs-lookup";
17
- import * as i16 from "@myrmidon/cadmus-api";
4
+ import * as i3 from "./asserted-composite-id/asserted-composite-id.component";
5
+ import * as i4 from "./asserted-composite-ids/asserted-composite-ids.component";
6
+ import * as i5 from "./pin-target-lookup/pin-target-lookup.component";
7
+ import * as i6 from "./scoped-pin-lookup/scoped-pin-lookup.component";
8
+ import * as i7 from "@angular/common";
9
+ import * as i8 from "@angular/forms";
10
+ import * as i9 from "@angular/cdk/clipboard";
11
+ import * as i10 from "@angular/material/button";
12
+ import * as i11 from "@angular/material/checkbox";
13
+ import * as i12 from "@angular/material/expansion";
14
+ import * as i13 from "@angular/material/form-field";
15
+ import * as i14 from "@angular/material/icon";
16
+ import * as i15 from "@angular/material/input";
17
+ import * as i16 from "@angular/material/select";
18
+ import * as i17 from "@myrmidon/ng-tools";
19
+ import * as i18 from "@myrmidon/cadmus-core";
20
+ import * as i19 from "@myrmidon/cadmus-refs-doc-references";
21
+ import * as i20 from "@myrmidon/cadmus-refs-assertion";
22
+ import * as i21 from "@myrmidon/cadmus-refs-lookup";
23
+ import * as i22 from "@myrmidon/cadmus-api";
18
24
  export declare class CadmusRefsAssertedIdsModule {
19
25
  static ɵfac: i0.ɵɵFactoryDeclaration<CadmusRefsAssertedIdsModule, never>;
20
- static ɵmod: i0.ɵɵNgModuleDeclaration<CadmusRefsAssertedIdsModule, [typeof i1.AssertedIdComponent, typeof i2.AssertedIdsComponent, typeof i3.ScopedPinLookupComponent], [typeof i4.CommonModule, typeof i5.FormsModule, typeof i5.ReactiveFormsModule, typeof i6.MatButtonModule, typeof i7.MatExpansionModule, typeof i8.MatFormFieldModule, typeof i9.MatIconModule, typeof i10.MatInputModule, typeof i11.MatSelectModule, typeof i12.CadmusCoreModule, typeof i13.CadmusRefsDocReferencesModule, typeof i14.CadmusRefsAssertionModule, typeof i15.CadmusRefsLookupModule, typeof i16.CadmusApiModule], [typeof i1.AssertedIdComponent, typeof i2.AssertedIdsComponent, typeof i3.ScopedPinLookupComponent]>;
26
+ static ɵmod: i0.ɵɵNgModuleDeclaration<CadmusRefsAssertedIdsModule, [typeof i1.AssertedIdComponent, typeof i2.AssertedIdsComponent, typeof i3.AssertedCompositeIdComponent, typeof i4.AssertedCompositeIdsComponent, typeof i5.PinTargetLookupComponent, typeof i6.ScopedPinLookupComponent], [typeof i7.CommonModule, typeof i8.FormsModule, typeof i8.ReactiveFormsModule, typeof i9.ClipboardModule, typeof i10.MatButtonModule, typeof i11.MatCheckboxModule, typeof i12.MatExpansionModule, typeof i13.MatFormFieldModule, typeof i14.MatIconModule, typeof i15.MatInputModule, typeof i16.MatSelectModule, typeof i17.NgToolsModule, typeof i18.CadmusCoreModule, typeof i19.CadmusRefsDocReferencesModule, typeof i20.CadmusRefsAssertionModule, typeof i21.CadmusRefsLookupModule, typeof i22.CadmusApiModule], [typeof i1.AssertedIdComponent, typeof i2.AssertedIdsComponent, typeof i3.AssertedCompositeIdComponent, typeof i4.AssertedCompositeIdsComponent, typeof i5.PinTargetLookupComponent, typeof i6.ScopedPinLookupComponent]>;
21
27
  static ɵinj: i0.ɵɵInjectorDeclaration<CadmusRefsAssertedIdsModule>;
22
28
  }
@@ -0,0 +1,139 @@
1
+ import { EventEmitter, OnDestroy, OnInit } from '@angular/core';
2
+ import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
3
+ import { MatSnackBar } from '@angular/material/snack-bar';
4
+ import { ItemService, ThesaurusService } from '@myrmidon/cadmus-api';
5
+ import { DataPinInfo, IndexLookupDefinition, IndexLookupDefinitions, Item, Part, ThesaurusEntry } from '@myrmidon/cadmus-core';
6
+ import { PinRefLookupFilter, PinRefLookupService } from '../services/pin-ref-lookup.service';
7
+ import { ItemRefLookupService } from '../services/item-ref-lookup.service';
8
+ import * as i0 from "@angular/core";
9
+ interface MetadataPart extends Part {
10
+ metadata: {
11
+ type?: string;
12
+ name: string;
13
+ value: string;
14
+ }[];
15
+ }
16
+ /**
17
+ * Pin lookup data used internally by the component.
18
+ */
19
+ export interface PinLookupData {
20
+ pin: DataPinInfo;
21
+ item?: Item;
22
+ metaPart?: MetadataPart;
23
+ }
24
+ /**
25
+ * A pin-based target. This includes pin's name and value, and
26
+ * the item's ID and optional part IDs. The label is a user friendly
27
+ * string representation of the target, while the gid is a globally
28
+ * unique identifier for the target.
29
+ */
30
+ export interface PinTarget {
31
+ gid: string;
32
+ label: string;
33
+ itemId?: string;
34
+ partId?: string;
35
+ partTypeId?: string;
36
+ roleId?: string;
37
+ name?: string;
38
+ value?: string;
39
+ }
40
+ export declare class PinTargetLookupComponent implements OnInit, OnDestroy {
41
+ private _presetLookupDefs;
42
+ itemLookupService: ItemRefLookupService;
43
+ pinLookupService: PinRefLookupService;
44
+ private _itemService;
45
+ private _thesService;
46
+ private _snackbar;
47
+ private _subs;
48
+ private _target;
49
+ private _noFormUpdate?;
50
+ private _startWithByTypeMode?;
51
+ /**
52
+ * True when the by-type pin lookup mode is active.
53
+ * User can change mode unless modeSwitching is false.
54
+ */
55
+ get pinByTypeMode(): boolean | undefined;
56
+ set pinByTypeMode(value: boolean | undefined);
57
+ /**
58
+ * True when the user can switch between by-type and by-item mode.
59
+ */
60
+ canSwitchMode?: boolean;
61
+ /**
62
+ * True when the user can edit the target's gid/label for internal
63
+ * targets.
64
+ */
65
+ canEditTarget?: boolean;
66
+ /**
67
+ * The lookup definitions to be used for the by-type lookup. If
68
+ * not specified, the lookup definitions will be got via injection
69
+ * when available; if the injected definitions are empty, the
70
+ * lookup definitions will be built from the model-types thesaurus;
71
+ * if this is not available either, the by-type lookup will be
72
+ * disabled.
73
+ */
74
+ lookupDefinitions?: IndexLookupDefinitions;
75
+ /**
76
+ * The target to be edited.
77
+ */
78
+ get target(): PinTarget | undefined | null;
79
+ set target(value: PinTarget | undefined | null);
80
+ /**
81
+ * Emitted when user closes the editor.
82
+ */
83
+ editorClose: EventEmitter<any>;
84
+ /**
85
+ * Emitted whenever the target changes.
86
+ * The event's value is the new target.
87
+ */
88
+ targetChange: EventEmitter<PinTarget>;
89
+ modelEntries: ThesaurusEntry[];
90
+ partTypeKeys: string[];
91
+ itemParts: Part[];
92
+ item: FormControl<Item | null>;
93
+ itemPart: FormControl<Part | null>;
94
+ partTypeKey: FormControl<string | null>;
95
+ gid: FormControl<string | null>;
96
+ label: FormControl<string | null>;
97
+ byTypeMode: FormControl<boolean>;
98
+ external: FormControl<boolean>;
99
+ form: FormGroup;
100
+ filter: PinRefLookupFilter;
101
+ pinFilterOptions?: IndexLookupDefinition;
102
+ lookupData?: PinLookupData;
103
+ constructor(_presetLookupDefs: IndexLookupDefinitions, itemLookupService: ItemRefLookupService, pinLookupService: PinRefLookupService, _itemService: ItemService, _thesService: ThesaurusService, _snackbar: MatSnackBar, formBuilder: FormBuilder);
104
+ private forceByItem;
105
+ private setupKeys;
106
+ private canBuildGid;
107
+ private canBuildLabel;
108
+ ngOnInit(): void;
109
+ ngOnDestroy(): void;
110
+ private buildGid;
111
+ private buildLabel;
112
+ private getTarget;
113
+ private updateTarget;
114
+ private updateForm;
115
+ /**
116
+ * Called when the item lookup changes (item is looked up
117
+ * by its title).
118
+ *
119
+ * @param item The item got from lookup.
120
+ */
121
+ onItemLookupChange(item: Item): void;
122
+ private loadItemInfo;
123
+ /**
124
+ * Called when the pin lookup change. A pin is looked up by its
125
+ * name and value (=the filter's text), and optionally by:
126
+ * - its index lookup definition (selected by partTypeKey).
127
+ * - its item (defined by item, in filter).
128
+ * - its part (defined by itemPart, in filter).
129
+ *
130
+ * @param info The pin info from pin lookup.
131
+ */
132
+ onPinLookupChange(info: DataPinInfo): void;
133
+ onCopied(): void;
134
+ close(): void;
135
+ save(): void;
136
+ static ɵfac: i0.ɵɵFactoryDeclaration<PinTargetLookupComponent, never>;
137
+ static ɵcmp: i0.ɵɵComponentDeclaration<PinTargetLookupComponent, "cadmus-pin-target-lookup", never, { "pinByTypeMode": { "alias": "pinByTypeMode"; "required": false; }; "canSwitchMode": { "alias": "canSwitchMode"; "required": false; }; "canEditTarget": { "alias": "canEditTarget"; "required": false; }; "lookupDefinitions": { "alias": "lookupDefinitions"; "required": false; }; "target": { "alias": "target"; "required": false; }; }, { "editorClose": "editorClose"; "targetChange": "targetChange"; }, never, never, false, never>;
138
+ }
139
+ export {};
@@ -0,0 +1,13 @@
1
+ import { Observable } from 'rxjs';
2
+ import { ItemService } from '@myrmidon/cadmus-api';
3
+ import { Item } from '@myrmidon/cadmus-core';
4
+ import { RefLookupFilter, RefLookupService } from '@myrmidon/cadmus-refs-lookup';
5
+ import * as i0 from "@angular/core";
6
+ export declare class ItemRefLookupService implements RefLookupService {
7
+ private _itemService;
8
+ constructor(_itemService: ItemService);
9
+ lookup(filter: RefLookupFilter, options?: any): Observable<Item[]>;
10
+ getName(item: Item): string;
11
+ static ɵfac: i0.ɵɵFactoryDeclaration<ItemRefLookupService, never>;
12
+ static ɵprov: i0.ɵɵInjectableDeclaration<ItemRefLookupService>;
13
+ }
@@ -2,6 +2,15 @@ import { Observable } from 'rxjs';
2
2
  import { ItemService } from '@myrmidon/cadmus-api';
3
3
  import { RefLookupFilter, RefLookupService } from '@myrmidon/cadmus-refs-lookup';
4
4
  import * as i0 from "@angular/core";
5
+ /**
6
+ * Pin-based lookup filter. This is a RefLookupFilter with the addition
7
+ * of the item ID and part ID, which are used to filter the results
8
+ * by the ItemPinLookupComponent.
9
+ */
10
+ export interface PinRefLookupFilter extends RefLookupFilter {
11
+ itemId?: string;
12
+ partId?: string;
13
+ }
5
14
  /**
6
15
  * Cadmus pin-based lookup data service. The text being searched here is just
7
16
  * the pin's value, according to the options specified. These options correspond
@@ -12,7 +21,7 @@ export declare class PinRefLookupService implements RefLookupService {
12
21
  constructor(_itemService: ItemService);
13
22
  getName(item: any | undefined): string;
14
23
  private buildQuery;
15
- lookup(filter: RefLookupFilter, options?: any): Observable<any[]>;
24
+ lookup(filter: PinRefLookupFilter, options?: any): Observable<any[]>;
16
25
  static ɵfac: i0.ɵɵFactoryDeclaration<PinRefLookupService, never>;
17
26
  static ɵprov: i0.ɵɵInjectableDeclaration<PinRefLookupService>;
18
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myrmidon/cadmus-refs-asserted-ids",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Cadmus - asserted IDs components.",
5
5
  "keywords": [
6
6
  "Cadmus",
package/public-api.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  export * from './lib/asserted-id/asserted-id.component';
2
2
  export * from './lib/asserted-ids/asserted-ids.component';
3
3
  export * from './lib/scoped-pin-lookup/scoped-pin-lookup.component';
4
+ export * from './lib/asserted-composite-id/asserted-composite-id.component';
5
+ export * from './lib/asserted-composite-ids/asserted-composite-ids.component';
6
+ export * from './lib/pin-target-lookup/pin-target-lookup.component';
4
7
  export * from './lib/services/pin-ref-lookup.service';
8
+ export * from './lib/services/item-ref-lookup.service';
5
9
  export * from './lib/cadmus-refs-asserted-ids.module';