@myrmidon/cadmus-refs-asserted-ids 1.0.2 → 1.0.4

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.
@@ -1,32 +1,214 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, Component, Input, Output, ViewChildren, NgModule } from '@angular/core';
3
- import * as i1 from '@angular/forms';
2
+ import { Injectable, EventEmitter, Component, Inject, Output, Input, NgModule } from '@angular/core';
3
+ import * as i1$1 from '@angular/forms';
4
4
  import { Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
5
5
  import { debounceTime } from 'rxjs/operators';
6
- import * as i2 from '@angular/common';
6
+ import { of, map, forkJoin, take } from 'rxjs';
7
+ import * as i1 from '@myrmidon/cadmus-api';
8
+ import { CadmusApiModule } from '@myrmidon/cadmus-api';
9
+ import * as i3 from '@angular/common';
7
10
  import { CommonModule } from '@angular/common';
8
- import * as i3 from '@angular/material/expansion';
11
+ import * as i4 from '@angular/material/button';
12
+ import { MatButtonModule } from '@angular/material/button';
13
+ import * as i5 from '@angular/material/expansion';
9
14
  import { MatExpansionModule } from '@angular/material/expansion';
10
- import * as i4 from '@angular/material/form-field';
15
+ import * as i7 from '@angular/material/form-field';
11
16
  import { MatFormFieldModule } from '@angular/material/form-field';
12
- import * as i5 from '@angular/material/input';
17
+ import * as i8 from '@angular/material/icon';
18
+ import { MatIconModule } from '@angular/material/icon';
19
+ import * as i9 from '@angular/material/input';
13
20
  import { MatInputModule } from '@angular/material/input';
14
- import * as i6 from '@angular/material/select';
21
+ import * as i10 from '@angular/material/select';
15
22
  import { MatSelectModule } from '@angular/material/select';
16
- import * as i7 from '@angular/material/core';
17
- import * as i8 from '@myrmidon/cadmus-refs-assertion';
23
+ import * as i11 from '@angular/material/core';
24
+ import * as i11$1 from '@myrmidon/cadmus-refs-assertion';
18
25
  import { CadmusRefsAssertionModule } from '@myrmidon/cadmus-refs-assertion';
19
- import * as i3$1 from '@angular/material/button';
20
- import { MatButtonModule } from '@angular/material/button';
21
- import * as i6$1 from '@angular/material/icon';
22
- import { MatIconModule } from '@angular/material/icon';
26
+ import * as i12 from '@myrmidon/cadmus-refs-lookup';
27
+ import { CadmusRefsLookupModule } from '@myrmidon/cadmus-refs-lookup';
28
+ import * as i2 from '@myrmidon/ng-mat-tools';
23
29
  import { CadmusCoreModule } from '@myrmidon/cadmus-core';
24
30
  import { CadmusRefsDocReferencesModule } from '@myrmidon/cadmus-refs-doc-references';
25
31
 
32
+ /**
33
+ * Cadmus pin-based lookup data service. The text being searched here is just
34
+ * the pin's value, according to the options specified. These options correspond
35
+ * to an index lookup definition. The resulting items are of type DataPinInfo.
36
+ */
37
+ class PinRefLookupService {
38
+ constructor(_itemService) {
39
+ this._itemService = _itemService;
40
+ }
41
+ getName(item) {
42
+ return item?.value || '';
43
+ }
44
+ buildQuery(def, text) {
45
+ const sb = [];
46
+ const AND = ' AND ';
47
+ if (def.typeId) {
48
+ sb.push(`[partTypeId=${def.typeId}]`);
49
+ }
50
+ if (def.roleId) {
51
+ if (sb.length) {
52
+ sb.push(AND);
53
+ }
54
+ sb.push(`[roleId=${def.roleId}]`);
55
+ }
56
+ if (def.name) {
57
+ if (sb.length) {
58
+ sb.push(AND);
59
+ }
60
+ sb.push(`[name=${def.name}]`);
61
+ }
62
+ if (text) {
63
+ if (sb.length) {
64
+ sb.push(AND);
65
+ }
66
+ sb.push(`[value^=${text}]`); // ^= is starts-with
67
+ }
68
+ return sb.join('');
69
+ }
70
+ lookup(filter, options) {
71
+ // the index lookup definition is required
72
+ const def = options;
73
+ if (!def) {
74
+ return of([]);
75
+ }
76
+ // build the corresponding pin query
77
+ const query = this.buildQuery(def, filter.text);
78
+ // search the index
79
+ return this._itemService.searchPins(query, 1, filter.limit).pipe(map((w) => {
80
+ if (w.error) {
81
+ console.error(w.error);
82
+ return [];
83
+ }
84
+ else {
85
+ return w.value?.items || [];
86
+ }
87
+ }));
88
+ }
89
+ }
90
+ PinRefLookupService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: PinRefLookupService, deps: [{ token: i1.ItemService }], target: i0.ɵɵFactoryTarget.Injectable });
91
+ PinRefLookupService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: PinRefLookupService, providedIn: 'root' });
92
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: PinRefLookupService, decorators: [{
93
+ type: Injectable,
94
+ args: [{
95
+ providedIn: 'root',
96
+ }]
97
+ }], ctorParameters: function () { return [{ type: i1.ItemService }]; } });
98
+
99
+ // from Cadmus general parts
100
+ const METADATA_PART_ID = 'it.vedph.metadata';
101
+ /*
102
+ * Scoped pin-based lookup component. This component provides a list
103
+ * of pin-based searches, with a lookup control. Whenever the user
104
+ * picks a pin value, he gets the details about its item and part, and
105
+ * item's metadata part, if any. He can then use these data to build
106
+ * some EID by variously assembling these components.
107
+ */
108
+ class ScopedPinLookupComponent {
109
+ constructor(formBuilder, _itemService, lookupService, lookupDefs) {
110
+ this._itemService = _itemService;
111
+ this.lookupService = lookupService;
112
+ this.lookupDefs = lookupDefs;
113
+ // lookup
114
+ // keys are all the defined lookup searches
115
+ this.keys = Object.keys(lookupDefs);
116
+ // the selected key defines the lookup scope
117
+ this.key = formBuilder.control(null);
118
+ this.keyForm = formBuilder.group({
119
+ key: this.key,
120
+ });
121
+ // id
122
+ this.id = formBuilder.control(null, [
123
+ Validators.required,
124
+ Validators.maxLength(300),
125
+ ]);
126
+ this.idForm = formBuilder.group({
127
+ id: this.id,
128
+ });
129
+ // event
130
+ this.idPick = new EventEmitter();
131
+ }
132
+ ngOnInit() {
133
+ // pre-select a unique key
134
+ if (this.keys.length === 1) {
135
+ this.key.setValue(this.keys[0]);
136
+ this.key.markAsDirty();
137
+ this.key.updateValueAndValidity();
138
+ }
139
+ }
140
+ onItemChange(item) {
141
+ const info = {
142
+ pin: item,
143
+ };
144
+ // lookup item and its metadata part if any
145
+ forkJoin({
146
+ item: this._itemService.getItem(item.itemId, false),
147
+ part: this._itemService.getPartFromTypeAndRole(item.itemId, METADATA_PART_ID),
148
+ })
149
+ .pipe(take(1))
150
+ .subscribe({
151
+ next: (result) => {
152
+ info.item = result.item;
153
+ info.part = result.part;
154
+ this.info = info;
155
+ },
156
+ error: (error) => {
157
+ console.error(error ? JSON.stringify(error) : 'Error loading item/metadata');
158
+ },
159
+ });
160
+ }
161
+ appendIdComponent(type, metaIndex = -1) {
162
+ let id = this.id.value || '';
163
+ switch (type) {
164
+ case 'itemId':
165
+ id += this.info.item?.id || '';
166
+ break;
167
+ case 'partId':
168
+ id += this.info.part?.id || '';
169
+ break;
170
+ case 'partTypeId':
171
+ id += this.info.part?.typeId || '';
172
+ break;
173
+ case 'partRoleId':
174
+ id += this.info.part?.roleId || '';
175
+ break;
176
+ case 'metadata':
177
+ id += this.info.part.metadata[metaIndex].value;
178
+ break;
179
+ }
180
+ this.id.setValue(id);
181
+ this.id.markAsDirty();
182
+ this.id.updateValueAndValidity();
183
+ }
184
+ pickId() {
185
+ if (this.idForm.invalid) {
186
+ return;
187
+ }
188
+ this.idPick.emit(this.id.value);
189
+ }
190
+ resetId() {
191
+ this.id.reset();
192
+ this.id.markAsDirty();
193
+ this.id.updateValueAndValidity();
194
+ }
195
+ }
196
+ ScopedPinLookupComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: ScopedPinLookupComponent, deps: [{ token: i1$1.FormBuilder }, { token: i1.ItemService }, { token: PinRefLookupService }, { token: 'indexLookupDefinitions' }], target: i0.ɵɵFactoryTarget.Component });
197
+ ScopedPinLookupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.1", type: ScopedPinLookupComponent, selector: "cadmus-scoped-pin-lookup", outputs: { idPick: "idPick" }, ngImport: i0, template: "<div>\n <!-- lookup -->\n <div>\n <form [formGroup]=\"keyForm\" class=\"form-row\">\n <!-- key -->\n <mat-form-field *ngIf=\"keys.length > 1\">\n <mat-label>type</mat-label>\n <mat-select [formControl]=\"key\">\n <mat-option *ngFor=\"let k of keys\" [value]=\"k\">{{ k }}</mat-option>\n </mat-select>\n <mat-error\n *ngIf=\"$any(key).errors?.required && (key.dirty || key.touched)\"\n >type required</mat-error\n >\n </mat-form-field>\n <cadmus-ref-lookup\n [service]=\"lookupService\"\n label=\"pin\"\n [options]=\"key.value ? lookupDefs[key.value] : undefined\"\n (itemChange)=\"onItemChange($event)\"\n ></cadmus-ref-lookup>\n </form>\n </div>\n\n <!-- builder -->\n <mat-expansion-panel *ngIf=\"info\" [expanded]=\"info\" [disabled]=\"!info\">\n <mat-expansion-panel-header>ID builder</mat-expansion-panel-header>\n <!-- ID -->\n <div>\n <form [formGroup]=\"idForm\" (submit)=\"pickId()\">\n <mat-form-field style=\"width: 100%\">\n <input matInput [formControl]=\"id\" />\n <mat-error\n *ngIf=\"$any(id).errors?.required && (id.dirty || id.touched)\"\n >ID required</mat-error\n >\n <mat-error\n *ngIf=\"$any(id).errors?.maxLength && (id.dirty || id.touched)\"\n >ID too long</mat-error\n >\n <button\n mat-icon-button\n type=\"button\"\n matSuffix\n (click)=\"resetId()\"\n [disabled]=\"!id.value\"\n >\n <mat-icon color=\"warn\">close</mat-icon>\n </button>\n <button\n mat-icon-button\n type=\"button\"\n matSuffix\n (click)=\"pickId()\"\n [disabled]=\"idForm.invalid\"\n >\n <mat-icon color=\"primary\">check_circle</mat-icon>\n </button>\n </mat-form-field>\n </form>\n </div>\n <!-- table -->\n <table>\n <thead>\n <th></th>\n <th>source</th>\n <th>value</th>\n </thead>\n <tbody>\n <!-- item ID -->\n <tr>\n <td>\n <button\n type=\"button\"\n mat-icon-button\n color=\"primary\"\n (click)=\"appendIdComponent('itemId')\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td>item ID</td>\n <td>{{ info!.item?.id }}</td>\n </tr>\n <!-- item title -->\n <tr>\n <td></td>\n <td>item title</td>\n <td>{{ info!.item?.title }}</td>\n </tr>\n <!-- part ID -->\n <tr>\n <td>\n <button\n type=\"button\"\n mat-icon-button\n color=\"primary\"\n (click)=\"appendIdComponent('partId')\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td>part ID</td>\n <td>{{ info!.part?.id }}</td>\n </tr>\n <!-- part type ID -->\n <tr>\n <td>\n <button\n type=\"button\"\n mat-icon-button\n color=\"primary\"\n (click)=\"appendIdComponent('partTypeId')\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td>part type ID</td>\n <td>{{ info!.part?.typeId }}</td>\n </tr>\n <!-- part role ID -->\n <tr>\n <td>\n <button\n type=\"button\"\n mat-icon-button\n color=\"primary\"\n (click)=\"appendIdComponent('partRoleId')\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td>part role ID</td>\n <td>{{ info!.part?.roleId }}</td>\n </tr>\n\n <!-- part's metadata -->\n <tr *ngFor=\"let m of info!.part?.metadata; let i = index\">\n <td>\n <button\n type=\"button\"\n mat-icon-button\n color=\"primary\"\n (click)=\"appendIdComponent('metadata', i)\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td class=\"metadata\">{{ m.name }}</td>\n <td class=\"metadata\">{{ m.value }}</td>\n </tr>\n </tbody>\n </table>\n </mat-expansion-panel>\n</div>\n", styles: [".metadata{color:#4a3001}table{border:1px solid silver;border-radius:6px;padding:4px;margin-top:8px}tr:nth-child(odd){background-color:#f0f0f0}th{font-weight:400;text-align:left;color:silver}\n"], dependencies: [{ kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i4.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i5.MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["disabled", "expanded", "hideToggle", "togglePosition"], outputs: ["opened", "closed", "expandedChange", "afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { kind: "component", type: i5.MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["tabIndex", "expandedHeight", "collapsedHeight"] }, { kind: "component", type: i7.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i7.MatLabel, selector: "mat-label" }, { kind: "directive", type: i7.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i7.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "component", type: i8.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i9.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i10.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { kind: "component", type: i11.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "component", type: i12.RefLookupComponent, selector: "cadmus-ref-lookup", inputs: ["label", "limit", "baseFilter", "service", "item", "required", "hasMore", "linkTemplate", "optDialog", "options"], outputs: ["itemChange", "moreRequest"] }] });
198
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: ScopedPinLookupComponent, decorators: [{
199
+ type: Component,
200
+ args: [{ selector: 'cadmus-scoped-pin-lookup', template: "<div>\n <!-- lookup -->\n <div>\n <form [formGroup]=\"keyForm\" class=\"form-row\">\n <!-- key -->\n <mat-form-field *ngIf=\"keys.length > 1\">\n <mat-label>type</mat-label>\n <mat-select [formControl]=\"key\">\n <mat-option *ngFor=\"let k of keys\" [value]=\"k\">{{ k }}</mat-option>\n </mat-select>\n <mat-error\n *ngIf=\"$any(key).errors?.required && (key.dirty || key.touched)\"\n >type required</mat-error\n >\n </mat-form-field>\n <cadmus-ref-lookup\n [service]=\"lookupService\"\n label=\"pin\"\n [options]=\"key.value ? lookupDefs[key.value] : undefined\"\n (itemChange)=\"onItemChange($event)\"\n ></cadmus-ref-lookup>\n </form>\n </div>\n\n <!-- builder -->\n <mat-expansion-panel *ngIf=\"info\" [expanded]=\"info\" [disabled]=\"!info\">\n <mat-expansion-panel-header>ID builder</mat-expansion-panel-header>\n <!-- ID -->\n <div>\n <form [formGroup]=\"idForm\" (submit)=\"pickId()\">\n <mat-form-field style=\"width: 100%\">\n <input matInput [formControl]=\"id\" />\n <mat-error\n *ngIf=\"$any(id).errors?.required && (id.dirty || id.touched)\"\n >ID required</mat-error\n >\n <mat-error\n *ngIf=\"$any(id).errors?.maxLength && (id.dirty || id.touched)\"\n >ID too long</mat-error\n >\n <button\n mat-icon-button\n type=\"button\"\n matSuffix\n (click)=\"resetId()\"\n [disabled]=\"!id.value\"\n >\n <mat-icon color=\"warn\">close</mat-icon>\n </button>\n <button\n mat-icon-button\n type=\"button\"\n matSuffix\n (click)=\"pickId()\"\n [disabled]=\"idForm.invalid\"\n >\n <mat-icon color=\"primary\">check_circle</mat-icon>\n </button>\n </mat-form-field>\n </form>\n </div>\n <!-- table -->\n <table>\n <thead>\n <th></th>\n <th>source</th>\n <th>value</th>\n </thead>\n <tbody>\n <!-- item ID -->\n <tr>\n <td>\n <button\n type=\"button\"\n mat-icon-button\n color=\"primary\"\n (click)=\"appendIdComponent('itemId')\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td>item ID</td>\n <td>{{ info!.item?.id }}</td>\n </tr>\n <!-- item title -->\n <tr>\n <td></td>\n <td>item title</td>\n <td>{{ info!.item?.title }}</td>\n </tr>\n <!-- part ID -->\n <tr>\n <td>\n <button\n type=\"button\"\n mat-icon-button\n color=\"primary\"\n (click)=\"appendIdComponent('partId')\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td>part ID</td>\n <td>{{ info!.part?.id }}</td>\n </tr>\n <!-- part type ID -->\n <tr>\n <td>\n <button\n type=\"button\"\n mat-icon-button\n color=\"primary\"\n (click)=\"appendIdComponent('partTypeId')\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td>part type ID</td>\n <td>{{ info!.part?.typeId }}</td>\n </tr>\n <!-- part role ID -->\n <tr>\n <td>\n <button\n type=\"button\"\n mat-icon-button\n color=\"primary\"\n (click)=\"appendIdComponent('partRoleId')\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td>part role ID</td>\n <td>{{ info!.part?.roleId }}</td>\n </tr>\n\n <!-- part's metadata -->\n <tr *ngFor=\"let m of info!.part?.metadata; let i = index\">\n <td>\n <button\n type=\"button\"\n mat-icon-button\n color=\"primary\"\n (click)=\"appendIdComponent('metadata', i)\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td class=\"metadata\">{{ m.name }}</td>\n <td class=\"metadata\">{{ m.value }}</td>\n </tr>\n </tbody>\n </table>\n </mat-expansion-panel>\n</div>\n", styles: [".metadata{color:#4a3001}table{border:1px solid silver;border-radius:6px;padding:4px;margin-top:8px}tr:nth-child(odd){background-color:#f0f0f0}th{font-weight:400;text-align:left;color:silver}\n"] }]
201
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: i1.ItemService }, { type: PinRefLookupService }, { type: undefined, decorators: [{
202
+ type: Inject,
203
+ args: ['indexLookupDefinitions']
204
+ }] }]; }, propDecorators: { idPick: [{
205
+ type: Output
206
+ }] } });
207
+
26
208
  class AssertedIdComponent {
27
- constructor(formBuilder) {
28
- this.idChange = new EventEmitter();
29
- // form
209
+ constructor(formBuilder, lookupService, lookupDefs) {
210
+ this.lookupService = lookupService;
211
+ this.lookupDefs = lookupDefs;
30
212
  this.tag = formBuilder.control(null, Validators.maxLength(50));
31
213
  this.value = formBuilder.control(null, [
32
214
  Validators.required,
@@ -38,13 +220,17 @@ class AssertedIdComponent {
38
220
  value: this.value,
39
221
  scope: this.scope,
40
222
  });
223
+ this.lookupExpanded = false;
224
+ this.idChange = new EventEmitter();
41
225
  }
42
226
  get id() {
43
227
  return this._id;
44
228
  }
45
229
  set id(value) {
46
- this._id = value;
47
- this.updateForm(value);
230
+ if (this._id !== value) {
231
+ this._id = value;
232
+ this.updateForm(value);
233
+ }
48
234
  }
49
235
  ngOnInit() {
50
236
  this.form.valueChanges.pipe(debounceTime(300)).subscribe((_) => {
@@ -57,6 +243,12 @@ class AssertedIdComponent {
57
243
  this.assertion = assertion;
58
244
  setTimeout(() => this.emitIdChange(), 0);
59
245
  }
246
+ onIdPick(id) {
247
+ this.value.setValue(id);
248
+ this.value.markAsDirty();
249
+ this.value.updateValueAndValidity();
250
+ this.lookupExpanded = false;
251
+ }
60
252
  updateForm(value) {
61
253
  this._updatingForm = true;
62
254
  if (!value) {
@@ -82,15 +274,25 @@ class AssertedIdComponent {
82
274
  };
83
275
  }
84
276
  emitIdChange() {
85
- this.idChange.emit(this.getId());
277
+ if (!this.hasSubmit) {
278
+ this.idChange.emit(this.getId());
279
+ }
280
+ }
281
+ save() {
282
+ if (this.form.valid) {
283
+ this.idChange.emit(this.getId());
284
+ }
86
285
  }
87
286
  }
88
- AssertedIdComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: AssertedIdComponent, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component });
89
- AssertedIdComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.2", type: AssertedIdComponent, selector: "cadmus-refs-asserted-id", inputs: { scopeEntries: "scopeEntries", idTagEntries: "idTagEntries", assTagEntries: "assTagEntries", refTypeEntries: "refTypeEntries", refTagEntries: "refTagEntries", id: "id" }, outputs: { idChange: "idChange" }, ngImport: i0, template: "<form [formGroup]=\"form\">\n <div>\n <!-- tag (bound) -->\n <mat-form-field *ngIf=\"idTagEntries?.length\" style=\"width: 8em\">\n <mat-label>tag</mat-label>\n <mat-select [formControl]=\"tag\">\n <mat-option *ngFor=\"let e of idTagEntries\" [value]=\"e.id\">{{\n e.value\n }}</mat-option>\n </mat-select>\n </mat-form-field>\n <!-- tag (free) -->\n <mat-form-field *ngIf=\"!idTagEntries?.length\" style=\"width: 8em\">\n <mat-label>tag</mat-label>\n <input matInput [formControl]=\"tag\" />\n <mat-error *ngIf=\"tag.errors?.maxLength && (tag.dirty || tag.touched)\"\n >tag too long</mat-error\n >\n </mat-form-field>\n &nbsp;\n\n <!-- scope (bound) -->\n <mat-form-field *ngIf=\"scopeEntries?.length\" style=\"width: 8em\">\n <mat-label>scope</mat-label>\n <mat-select [formControl]=\"scope\">\n <mat-option *ngFor=\"let e of scopeEntries\" [value]=\"e.id\">{{\n e.value\n }}</mat-option>\n </mat-select>\n </mat-form-field>\n <!-- scope (free) -->\n <mat-form-field *ngIf=\"!scopeEntries?.length\" style=\"width: 8em\">\n <mat-label>scope</mat-label>\n <input matInput [formControl]=\"scope\" />\n <mat-error\n *ngIf=\"scope.errors?.maxLength && (scope.dirty || scope.touched)\"\n >scope too long</mat-error\n >\n </mat-form-field>\n <!-- value -->\n &nbsp;\n <mat-form-field>\n <mat-label>value</mat-label>\n <input matInput [formControl]=\"value\" />\n <mat-error\n *ngIf=\"value.errors?.required && (value.dirty || value.touched)\"\n >value required</mat-error\n >\n <mat-error\n *ngIf=\"value.errors?.maxLength && (value.dirty || value.touched)\"\n >value too long</mat-error\n >\n </mat-form-field>\n </div>\n\n <!-- assertion -->\n <mat-expansion-panel>\n <mat-expansion-panel-header>assertion</mat-expansion-panel-header>\n <cadmus-refs-assertion\n [assTagEntries]=\"assTagEntries\"\n [refTypeEntries]=\"refTypeEntries\"\n [refTagEntries]=\"refTagEntries\"\n [assertion]=\"initialAssertion\"\n (assertionChange)=\"onAssertionChange($event)\"\n >\n </cadmus-refs-assertion>\n </mat-expansion-panel>\n</form>\n", styles: [""], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i3.MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["disabled", "expanded", "hideToggle", "togglePosition"], outputs: ["opened", "closed", "expandedChange", "afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { kind: "component", type: i3.MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["tabIndex", "expandedHeight", "collapsedHeight"] }, { kind: "component", type: i4.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i4.MatLabel, selector: "mat-label" }, { kind: "directive", type: i4.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i5.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i6.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { kind: "component", type: i7.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "component", type: i8.AssertionComponent, selector: "cadmus-refs-assertion", inputs: ["assTagEntries", "refTypeEntries", "refTagEntries", "assertion"], outputs: ["assertionChange"] }] });
90
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: AssertedIdComponent, decorators: [{
287
+ AssertedIdComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: AssertedIdComponent, deps: [{ token: i1$1.FormBuilder }, { token: PinRefLookupService }, { token: 'indexLookupDefinitions' }], target: i0.ɵɵFactoryTarget.Component });
288
+ AssertedIdComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.1", type: AssertedIdComponent, selector: "cadmus-refs-asserted-id", inputs: { scopeEntries: "scopeEntries", idTagEntries: "idTagEntries", assTagEntries: "assTagEntries", refTypeEntries: "refTypeEntries", refTagEntries: "refTagEntries", id: "id", noEidLookup: "noEidLookup", hasSubmit: "hasSubmit" }, outputs: { idChange: "idChange" }, ngImport: i0, template: "<form [formGroup]=\"form\" (submit)=\"save()\">\n <div>\n <div class=\"form-row\">\n <!-- tag (bound) -->\n <mat-form-field *ngIf=\"idTagEntries?.length\" style=\"width: 8em\">\n <mat-label>tag</mat-label>\n <mat-select [formControl]=\"tag\">\n <mat-option *ngFor=\"let e of idTagEntries\" [value]=\"e.id\">{{\n e.value\n }}</mat-option>\n </mat-select>\n </mat-form-field>\n <!-- tag (free) -->\n <mat-form-field *ngIf=\"!idTagEntries?.length\" style=\"width: 8em\">\n <mat-label>tag</mat-label>\n <input matInput [formControl]=\"tag\" />\n <mat-error *ngIf=\"tag.errors?.maxLength && (tag.dirty || tag.touched)\"\n >tag too long</mat-error\n >\n </mat-form-field>\n\n <!-- scope (bound) -->\n <mat-form-field *ngIf=\"scopeEntries?.length\" style=\"width: 8em\">\n <mat-label>scope</mat-label>\n <mat-select [formControl]=\"scope\">\n <mat-option *ngFor=\"let e of scopeEntries\" [value]=\"e.id\">{{\n e.value\n }}</mat-option>\n </mat-select>\n </mat-form-field>\n <!-- scope (free) -->\n <mat-form-field *ngIf=\"!scopeEntries?.length\" style=\"width: 8em\">\n <mat-label>scope</mat-label>\n <input matInput [formControl]=\"scope\" />\n <mat-error\n *ngIf=\"scope.errors?.maxLength && (scope.dirty || scope.touched)\"\n >scope too long</mat-error\n >\n </mat-form-field>\n\n <!-- value -->\n <mat-form-field>\n <mat-label>value</mat-label>\n <input matInput [formControl]=\"value\" />\n <mat-error\n *ngIf=\"value.errors?.required && (value.dirty || value.touched)\"\n >value required</mat-error\n >\n <mat-error\n *ngIf=\"value.errors?.maxLength && (value.dirty || value.touched)\"\n >value too long</mat-error\n >\n </mat-form-field>\n\n <!-- lookup -->\n <div *ngIf=\"!noEidLookup\" style=\"margin-top: 4px\">\n <mat-expansion-panel [(expanded)]=\"lookupExpanded\">\n <mat-expansion-panel-header>lookup</mat-expansion-panel-header>\n <cadmus-scoped-pin-lookup\n (idPick)=\"onIdPick($event)\"\n ></cadmus-scoped-pin-lookup>\n </mat-expansion-panel>\n </div>\n </div>\n\n <!-- assertion -->\n <mat-expansion-panel>\n <mat-expansion-panel-header>assertion</mat-expansion-panel-header>\n <cadmus-refs-assertion\n [assTagEntries]=\"assTagEntries\"\n [refTypeEntries]=\"refTypeEntries\"\n [refTagEntries]=\"refTagEntries\"\n [assertion]=\"initialAssertion\"\n (assertionChange)=\"onAssertionChange($event)\"\n >\n </cadmus-refs-assertion>\n </mat-expansion-panel>\n </div>\n\n <!-- buttons -->\n <div *ngIf=\"hasSubmit\">\n <button mat-icon-button color=\"warn\" type=\"button\">\n <mat-icon>close</mat-icon>\n </button>\n <button\n mat-icon-button\n color=\"primary\"\n type=\"submit\"\n [disabled]=\"form.invalid\"\n >\n <mat-icon>check_circle</mat-icon>\n </button>\n </div>\n</form>\n", styles: [".form-row{display:flex;gap:8px;align-items:flex-start;flex-wrap:wrap}.form-row *{flex:0 0 auto}.pin-info{font-size:90%;color:silver}fieldset{border:1px solid silver;border-radius:6px;padding:6px}@media only screen and (max-width: 959px){div#container{grid-template-rows:1fr auto;grid-template-columns:1fr;grid-template-areas:\"editor\" \"lookup\"}}\n"], dependencies: [{ kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i4.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i5.MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["disabled", "expanded", "hideToggle", "togglePosition"], outputs: ["opened", "closed", "expandedChange", "afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { kind: "component", type: i5.MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["tabIndex", "expandedHeight", "collapsedHeight"] }, { kind: "component", type: i7.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i7.MatLabel, selector: "mat-label" }, { kind: "directive", type: i7.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "component", type: i8.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i9.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i10.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { kind: "component", type: i11.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "component", type: i11$1.AssertionComponent, selector: "cadmus-refs-assertion", inputs: ["assTagEntries", "refTypeEntries", "refTagEntries", "assertion"], outputs: ["assertionChange"] }, { kind: "component", type: ScopedPinLookupComponent, selector: "cadmus-scoped-pin-lookup", outputs: ["idPick"] }] });
289
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: AssertedIdComponent, decorators: [{
91
290
  type: Component,
92
- args: [{ selector: 'cadmus-refs-asserted-id', template: "<form [formGroup]=\"form\">\n <div>\n <!-- tag (bound) -->\n <mat-form-field *ngIf=\"idTagEntries?.length\" style=\"width: 8em\">\n <mat-label>tag</mat-label>\n <mat-select [formControl]=\"tag\">\n <mat-option *ngFor=\"let e of idTagEntries\" [value]=\"e.id\">{{\n e.value\n }}</mat-option>\n </mat-select>\n </mat-form-field>\n <!-- tag (free) -->\n <mat-form-field *ngIf=\"!idTagEntries?.length\" style=\"width: 8em\">\n <mat-label>tag</mat-label>\n <input matInput [formControl]=\"tag\" />\n <mat-error *ngIf=\"tag.errors?.maxLength && (tag.dirty || tag.touched)\"\n >tag too long</mat-error\n >\n </mat-form-field>\n &nbsp;\n\n <!-- scope (bound) -->\n <mat-form-field *ngIf=\"scopeEntries?.length\" style=\"width: 8em\">\n <mat-label>scope</mat-label>\n <mat-select [formControl]=\"scope\">\n <mat-option *ngFor=\"let e of scopeEntries\" [value]=\"e.id\">{{\n e.value\n }}</mat-option>\n </mat-select>\n </mat-form-field>\n <!-- scope (free) -->\n <mat-form-field *ngIf=\"!scopeEntries?.length\" style=\"width: 8em\">\n <mat-label>scope</mat-label>\n <input matInput [formControl]=\"scope\" />\n <mat-error\n *ngIf=\"scope.errors?.maxLength && (scope.dirty || scope.touched)\"\n >scope too long</mat-error\n >\n </mat-form-field>\n <!-- value -->\n &nbsp;\n <mat-form-field>\n <mat-label>value</mat-label>\n <input matInput [formControl]=\"value\" />\n <mat-error\n *ngIf=\"value.errors?.required && (value.dirty || value.touched)\"\n >value required</mat-error\n >\n <mat-error\n *ngIf=\"value.errors?.maxLength && (value.dirty || value.touched)\"\n >value too long</mat-error\n >\n </mat-form-field>\n </div>\n\n <!-- assertion -->\n <mat-expansion-panel>\n <mat-expansion-panel-header>assertion</mat-expansion-panel-header>\n <cadmus-refs-assertion\n [assTagEntries]=\"assTagEntries\"\n [refTypeEntries]=\"refTypeEntries\"\n [refTagEntries]=\"refTagEntries\"\n [assertion]=\"initialAssertion\"\n (assertionChange)=\"onAssertionChange($event)\"\n >\n </cadmus-refs-assertion>\n </mat-expansion-panel>\n</form>\n" }]
93
- }], ctorParameters: function () { return [{ type: i1.FormBuilder }]; }, propDecorators: { scopeEntries: [{
291
+ args: [{ selector: 'cadmus-refs-asserted-id', template: "<form [formGroup]=\"form\" (submit)=\"save()\">\n <div>\n <div class=\"form-row\">\n <!-- tag (bound) -->\n <mat-form-field *ngIf=\"idTagEntries?.length\" style=\"width: 8em\">\n <mat-label>tag</mat-label>\n <mat-select [formControl]=\"tag\">\n <mat-option *ngFor=\"let e of idTagEntries\" [value]=\"e.id\">{{\n e.value\n }}</mat-option>\n </mat-select>\n </mat-form-field>\n <!-- tag (free) -->\n <mat-form-field *ngIf=\"!idTagEntries?.length\" style=\"width: 8em\">\n <mat-label>tag</mat-label>\n <input matInput [formControl]=\"tag\" />\n <mat-error *ngIf=\"tag.errors?.maxLength && (tag.dirty || tag.touched)\"\n >tag too long</mat-error\n >\n </mat-form-field>\n\n <!-- scope (bound) -->\n <mat-form-field *ngIf=\"scopeEntries?.length\" style=\"width: 8em\">\n <mat-label>scope</mat-label>\n <mat-select [formControl]=\"scope\">\n <mat-option *ngFor=\"let e of scopeEntries\" [value]=\"e.id\">{{\n e.value\n }}</mat-option>\n </mat-select>\n </mat-form-field>\n <!-- scope (free) -->\n <mat-form-field *ngIf=\"!scopeEntries?.length\" style=\"width: 8em\">\n <mat-label>scope</mat-label>\n <input matInput [formControl]=\"scope\" />\n <mat-error\n *ngIf=\"scope.errors?.maxLength && (scope.dirty || scope.touched)\"\n >scope too long</mat-error\n >\n </mat-form-field>\n\n <!-- value -->\n <mat-form-field>\n <mat-label>value</mat-label>\n <input matInput [formControl]=\"value\" />\n <mat-error\n *ngIf=\"value.errors?.required && (value.dirty || value.touched)\"\n >value required</mat-error\n >\n <mat-error\n *ngIf=\"value.errors?.maxLength && (value.dirty || value.touched)\"\n >value too long</mat-error\n >\n </mat-form-field>\n\n <!-- lookup -->\n <div *ngIf=\"!noEidLookup\" style=\"margin-top: 4px\">\n <mat-expansion-panel [(expanded)]=\"lookupExpanded\">\n <mat-expansion-panel-header>lookup</mat-expansion-panel-header>\n <cadmus-scoped-pin-lookup\n (idPick)=\"onIdPick($event)\"\n ></cadmus-scoped-pin-lookup>\n </mat-expansion-panel>\n </div>\n </div>\n\n <!-- assertion -->\n <mat-expansion-panel>\n <mat-expansion-panel-header>assertion</mat-expansion-panel-header>\n <cadmus-refs-assertion\n [assTagEntries]=\"assTagEntries\"\n [refTypeEntries]=\"refTypeEntries\"\n [refTagEntries]=\"refTagEntries\"\n [assertion]=\"initialAssertion\"\n (assertionChange)=\"onAssertionChange($event)\"\n >\n </cadmus-refs-assertion>\n </mat-expansion-panel>\n </div>\n\n <!-- buttons -->\n <div *ngIf=\"hasSubmit\">\n <button mat-icon-button color=\"warn\" type=\"button\">\n <mat-icon>close</mat-icon>\n </button>\n <button\n mat-icon-button\n color=\"primary\"\n type=\"submit\"\n [disabled]=\"form.invalid\"\n >\n <mat-icon>check_circle</mat-icon>\n </button>\n </div>\n</form>\n", styles: [".form-row{display:flex;gap:8px;align-items:flex-start;flex-wrap:wrap}.form-row *{flex:0 0 auto}.pin-info{font-size:90%;color:silver}fieldset{border:1px solid silver;border-radius:6px;padding:6px}@media only screen and (max-width: 959px){div#container{grid-template-rows:1fr auto;grid-template-columns:1fr;grid-template-areas:\"editor\" \"lookup\"}}\n"] }]
292
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: PinRefLookupService }, { type: undefined, decorators: [{
293
+ type: Inject,
294
+ args: ['indexLookupDefinitions']
295
+ }] }]; }, propDecorators: { scopeEntries: [{
94
296
  type: Input
95
297
  }], idTagEntries: [{
96
298
  type: Input
@@ -102,21 +304,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImpor
102
304
  type: Input
103
305
  }], id: [{
104
306
  type: Input
307
+ }], noEidLookup: [{
308
+ type: Input
309
+ }], hasSubmit: [{
310
+ type: Input
105
311
  }], idChange: [{
106
312
  type: Output
107
313
  }] } });
108
314
 
315
+ /**
316
+ * Asserted IDs editor.
317
+ */
109
318
  class AssertedIdsComponent {
110
- constructor(_formBuilder) {
111
- this._formBuilder = _formBuilder;
319
+ constructor(formBuilder, _dialogService) {
320
+ this._dialogService = _dialogService;
112
321
  this._ids = [];
113
- this._idsSubs = [];
322
+ this._editedIndex = -1;
114
323
  this.idsChange = new EventEmitter();
115
- this.assEdOpen = false;
324
+ this.entries = formBuilder.control([], { nonNullable: true });
116
325
  // form
117
- this.idsArr = _formBuilder.array([]);
118
- this.form = _formBuilder.group({
119
- idsArr: this.idsArr,
326
+ this.form = formBuilder.group({
327
+ ids: this.entries,
120
328
  });
121
329
  }
122
330
  /**
@@ -126,166 +334,105 @@ class AssertedIdsComponent {
126
334
  return this._ids;
127
335
  }
128
336
  set ids(value) {
129
- this._ids = value || [];
130
- this.updateForm(value);
131
- }
132
- ngAfterViewInit() {
133
- // focus on newly added ID
134
- this._idSubscription = this.idQueryList?.changes
135
- .pipe(debounceTime(300))
136
- .subscribe((lst) => {
137
- if (!this._updatingForm && lst.length > 0) {
138
- lst.last.nativeElement.focus();
139
- }
140
- });
337
+ if (this._ids !== value) {
338
+ this._ids = value || [];
339
+ this.updateForm(value);
340
+ }
141
341
  }
142
- unsubscribeIds() {
143
- for (let i = 0; i < this._idsSubs.length; i++) {
144
- this._idsSubs[i].unsubscribe();
342
+ updateForm(ids) {
343
+ if (!ids?.length) {
344
+ this.form.reset();
345
+ return;
145
346
  }
347
+ this.entries.setValue(ids, { emitEvent: false });
348
+ this.entries.updateValueAndValidity();
349
+ this.form.markAsPristine();
146
350
  }
147
- ngOnDestroy() {
148
- this.unsubscribeIds();
149
- this._idSubscription?.unsubscribe();
150
- }
151
- getIdGroup(id) {
152
- return this._formBuilder.group({
153
- value: this._formBuilder.control(id?.value, [
154
- Validators.required,
155
- Validators.maxLength(500),
156
- ]),
157
- scope: this._formBuilder.control(id?.scope, Validators.maxLength(50)),
158
- tag: this._formBuilder.control(id?.tag, Validators.maxLength(50)),
159
- assertion: this._formBuilder.control(id?.assertion),
160
- });
351
+ emitIdsChange() {
352
+ this.idsChange.emit(this.entries.value);
161
353
  }
162
- addId(id) {
163
- const g = this.getIdGroup(id);
164
- this._idsSubs.push(g.valueChanges.pipe(debounceTime(300)).subscribe((_) => {
165
- this.emitIdsChange();
166
- }));
167
- this.idsArr.push(g);
168
- if (!this._updatingForm) {
169
- this.emitIdsChange();
170
- }
354
+ addId() {
355
+ this.editId({
356
+ scope: '',
357
+ value: '',
358
+ }, -1);
171
359
  }
172
- removeId(index) {
173
- this.closeAssertion();
174
- this._idsSubs[index].unsubscribe();
175
- this._idsSubs.splice(index, 1);
176
- this.idsArr.removeAt(index);
177
- this.emitIdsChange();
360
+ editId(id, index) {
361
+ this._editedIndex = index;
362
+ this.edited = id;
178
363
  }
179
- swapArrElems(a, i, j) {
180
- if (i === j) {
181
- return;
364
+ closeId() {
365
+ this._editedIndex = -1;
366
+ this.edited = undefined;
367
+ }
368
+ saveId(entry) {
369
+ const entries = [...this.entries.value];
370
+ if (this._editedIndex === -1) {
371
+ entries.push(entry);
182
372
  }
183
- const t = a[i];
184
- a[i] = a[j];
185
- a[j] = t;
373
+ else {
374
+ entries.splice(this._editedIndex, 1, entry);
375
+ }
376
+ this.entries.setValue(entries);
377
+ this.entries.markAsDirty();
378
+ this.entries.updateValueAndValidity();
379
+ this.closeId();
380
+ }
381
+ deleteId(index) {
382
+ this._dialogService
383
+ .confirm('Confirmation', 'Delete ID?')
384
+ .pipe(take(1))
385
+ .subscribe((yes) => {
386
+ if (yes) {
387
+ if (this._editedIndex === index) {
388
+ this.closeId();
389
+ }
390
+ const entries = [...this.entries.value];
391
+ entries.splice(index, 1);
392
+ this.entries.setValue(entries);
393
+ this.entries.markAsDirty();
394
+ this.entries.updateValueAndValidity();
395
+ this.emitIdsChange();
396
+ }
397
+ });
186
398
  }
187
399
  moveIdUp(index) {
188
400
  if (index < 1) {
189
401
  return;
190
402
  }
191
- this.closeAssertion();
192
- const ctl = this.idsArr.controls[index];
193
- this.idsArr.removeAt(index);
194
- this.idsArr.insert(index - 1, ctl);
195
- this.swapArrElems(this._idsSubs, index, index - 1);
403
+ const entry = this.entries.value[index];
404
+ const entries = [...this.entries.value];
405
+ entries.splice(index, 1);
406
+ entries.splice(index - 1, 0, entry);
407
+ this.entries.setValue(entries);
408
+ this.entries.markAsDirty();
409
+ this.entries.updateValueAndValidity();
196
410
  this.emitIdsChange();
197
411
  }
198
412
  moveIdDown(index) {
199
- if (index + 1 >= this.idsArr.length) {
413
+ if (index + 1 >= this.entries.value.length) {
200
414
  return;
201
415
  }
202
- this.closeAssertion();
203
- const item = this.idsArr.controls[index];
204
- this.idsArr.removeAt(index);
205
- this.idsArr.insert(index + 1, item);
206
- this.swapArrElems(this._idsSubs, index, index + 1);
416
+ const entry = this.entries.value[index];
417
+ const entries = [...this.entries.value];
418
+ entries.splice(index, 1);
419
+ entries.splice(index + 1, 0, entry);
420
+ this.entries.setValue(entries);
421
+ this.entries.markAsDirty();
422
+ this.entries.updateValueAndValidity();
207
423
  this.emitIdsChange();
208
424
  }
209
- clearIds() {
210
- this.closeAssertion();
211
- this.idsArr.clear();
212
- this.unsubscribeIds();
213
- this._idsSubs = [];
214
- if (!this._updatingForm) {
215
- this.emitIdsChange();
216
- }
217
- }
218
- editAssertion(index) {
219
- // save the currently edited assertion if any
220
- this.saveAssertion();
221
- // edit the new assertion
222
- this.initialAssertion = this.idsArr.at(index).controls['assertion'].value;
223
- this.assertionNr = index + 1;
224
- this.assEdOpen = true;
225
- }
226
- onAssertionChange(assertion) {
227
- this.assertion = assertion;
228
- }
229
- saveAssertion() {
230
- // save the currently edited assertion if any
231
- if (this.assertionNr) {
232
- const g = this.idsArr.at(this.assertionNr - 1);
233
- g.controls['assertion'].setValue(this.assertion);
234
- this.closeAssertion();
235
- this.emitIdsChange();
236
- }
237
- }
238
- closeAssertion() {
239
- if (this.assertionNr) {
240
- this.assEdOpen = false;
241
- this.assertionNr = 0;
242
- this.initialAssertion = undefined;
243
- }
244
- }
245
- updateForm(ids) {
246
- if (!this.idsArr) {
247
- return;
248
- }
249
- this._updatingForm = true;
250
- this.clearIds();
251
- if (!ids) {
252
- this.form.reset();
253
- }
254
- else {
255
- for (const id of ids) {
256
- this.addId(id);
257
- }
258
- this.form.markAsPristine();
259
- }
260
- this._updatingForm = false;
425
+ onIdChange(id) {
426
+ this.saveId(id);
261
427
  this.emitIdsChange();
262
428
  }
263
- getIds() {
264
- const ids = [];
265
- for (let i = 0; i < this.idsArr.length; i++) {
266
- const g = this.idsArr.controls[i];
267
- ids.push({
268
- value: g.controls.value.value?.trim(),
269
- scope: g.controls.scope.value?.trim(),
270
- tag: g.controls.tag.value?.trim(),
271
- assertion: g.controls.assertion.value,
272
- });
273
- }
274
- return ids;
275
- }
276
- emitIdsChange() {
277
- this.idsChange.emit(this.getIds());
278
- }
279
429
  }
280
- AssertedIdsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: AssertedIdsComponent, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component });
281
- AssertedIdsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.2", type: AssertedIdsComponent, selector: "cadmus-refs-asserted-ids", inputs: { ids: "ids", scopeEntries: "scopeEntries", tagEntries: "tagEntries", assTagEntries: "assTagEntries", refTypeEntries: "refTypeEntries", refTagEntries: "refTagEntries" }, outputs: { idsChange: "idsChange" }, viewQueries: [{ propertyName: "idQueryList", predicate: ["id"], descendants: true }], ngImport: i0, template: "<form [formGroup]=\"form\">\r\n <div formArrayName=\"idsArr\">\r\n <div>\r\n <button\r\n type=\"button\"\r\n mat-flat-button\r\n color=\"primary\"\r\n (click)=\"addId()\"\r\n >\r\n <mat-icon>add_circle</mat-icon> add ID\r\n </button>\r\n </div>\r\n <div\r\n *ngFor=\"\r\n let item of idsArr.controls;\r\n let i = index;\r\n let first = first;\r\n let last = last\r\n \"\r\n >\r\n <!-- child form -->\r\n <div [formGroupName]=\"i\">\r\n <!-- child actions -->\r\n {{ i + 1 }}.\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Remove this ID\"\r\n color=\"warn\"\r\n (click)=\"removeId(i)\"\r\n >\r\n <mat-icon>remove_circle</mat-icon>\r\n </button>\r\n <button\r\n [disabled]=\"first\"\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Move ID up\"\r\n (click)=\"moveIdUp(i)\"\r\n >\r\n <mat-icon>arrow_upward</mat-icon>\r\n </button>\r\n <button\r\n [disabled]=\"last\"\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Move ID down\"\r\n (click)=\"moveIdDown(i)\"\r\n >\r\n <mat-icon>arrow_downward</mat-icon>\r\n </button>\r\n\r\n <!-- child controls -->\r\n <!-- value -->\r\n <mat-form-field>\r\n <mat-label>external ID</mat-label>\r\n <input #id autofocus matInput formControlName=\"value\" />\r\n <mat-error\r\n *ngIf=\"\r\n $any(item)['controls'].value?.hasError('required') &&\r\n ($any(item)['controls'].value.dirty ||\r\n $any(item)['controls'].value.touched)\r\n \"\r\n >ID required\r\n </mat-error>\r\n <mat-error\r\n *ngIf=\"\r\n $any(item)['controls'].value?.hasError('max-length') &&\r\n ($any(item)['controls'].value.dirty ||\r\n $any(item)['controls'].value.touched)\r\n \"\r\n >ID too long\r\n </mat-error>\r\n </mat-form-field>\r\n\r\n &nbsp;\r\n <!-- scope (bound) -->\r\n <ng-container *ngIf=\"scopeEntries\">\r\n <mat-form-field style=\"width: 8em\">\r\n <mat-label>scope</mat-label>\r\n <mat-select formControlName=\"scope\">\r\n <mat-option *ngFor=\"let e of scopeEntries\" [value]=\"e.id\">\r\n {{ e.value }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <!-- scope (free) -->\r\n <ng-container *ngIf=\"!scopeEntries\">\r\n <mat-form-field style=\"width: 8em\">\r\n <mat-label>scope</mat-label>\r\n <input matInput formControlName=\"scope\" />\r\n <mat-error\r\n *ngIf=\"\r\n $any(item)['controls'].scope?.hasError('max-length') &&\r\n ($any(item)['controls'].scope.dirty ||\r\n $any(item)['controls'].scope.touched)\r\n \"\r\n >scope too long\r\n </mat-error>\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n &nbsp;\r\n <!-- tag (bound) -->\r\n <ng-container *ngIf=\"tagEntries\">\r\n <mat-form-field style=\"width: 8em\">\r\n <mat-label>tag</mat-label>\r\n <mat-select formControlName=\"tag\">\r\n <mat-option *ngFor=\"let e of tagEntries\" [value]=\"e.id\">\r\n {{ e.value }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <!-- tag (free) -->\r\n <ng-container *ngIf=\"!tagEntries\">\r\n <mat-form-field style=\"width: 8em\">\r\n <mat-label>tag</mat-label>\r\n <input matInput formControlName=\"tag\" />\r\n <mat-error\r\n *ngIf=\"\r\n $any(item)['controls'].tag?.hasError('max-length') &&\r\n ($any(item)['controls'].tag.dirty ||\r\n $any(item)['controls'].tag.touched)\r\n \"\r\n >tag too long\r\n </mat-error>\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <!-- assertion -->\r\n &nbsp;\r\n <button\r\n type=\"button\"\r\n color=\"primary\"\r\n mat-icon-button\r\n matTooltip=\"Edit assertion\"\r\n (click)=\"editAssertion(i)\"\r\n >\r\n <mat-icon>feedback</mat-icon>\r\n </button>\r\n </div>\r\n </div>\r\n <!-- assertion -->\r\n <mat-expansion-panel\r\n *ngIf=\"idsArr?.length\"\r\n [disabled]=\"!assertionNr\"\r\n [(expanded)]=\"assEdOpen\"\r\n >\r\n <mat-expansion-panel-header\r\n >#{{ assertionNr }} assertion</mat-expansion-panel-header\r\n >\r\n <cadmus-refs-assertion\r\n [assertion]=\"initialAssertion\"\r\n [assTagEntries]=\"assTagEntries\"\r\n [refTagEntries]=\"refTagEntries\"\r\n [refTypeEntries]=\"refTypeEntries\"\r\n (assertionChange)=\"onAssertionChange($event)\"\r\n ></cadmus-refs-assertion>\r\n <button\r\n color=\"primary\"\r\n type=\"button\"\r\n mat-flat-button\r\n style=\"margin-top: 6px;\"\r\n (click)=\"saveAssertion()\"\r\n >\r\n <mat-icon>check_circle</mat-icon> assertion\r\n </button>\r\n </mat-expansion-panel>\r\n </div>\r\n</form>\r\n", styles: [""], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i1.FormGroupName, selector: "[formGroupName]", inputs: ["formGroupName"] }, { kind: "directive", type: i1.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { kind: "component", type: i3$1.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i3$1.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i3.MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["disabled", "expanded", "hideToggle", "togglePosition"], outputs: ["opened", "closed", "expandedChange", "afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { kind: "component", type: i3.MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["tabIndex", "expandedHeight", "collapsedHeight"] }, { kind: "component", type: i4.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i4.MatLabel, selector: "mat-label" }, { kind: "directive", type: i4.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "component", type: i6$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i5.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i6.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { kind: "component", type: i7.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "component", type: i8.AssertionComponent, selector: "cadmus-refs-assertion", inputs: ["assTagEntries", "refTypeEntries", "refTagEntries", "assertion"], outputs: ["assertionChange"] }] });
282
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: AssertedIdsComponent, decorators: [{
430
+ AssertedIdsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: AssertedIdsComponent, deps: [{ token: i1$1.FormBuilder }, { token: i2.DialogService }], target: i0.ɵɵFactoryTarget.Component });
431
+ AssertedIdsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.1", type: AssertedIdsComponent, selector: "cadmus-refs-asserted-ids", inputs: { ids: "ids", scopeEntries: "scopeEntries", tagEntries: "tagEntries", assTagEntries: "assTagEntries", refTypeEntries: "refTypeEntries", refTagEntries: "refTagEntries" }, outputs: { idsChange: "idsChange" }, ngImport: i0, template: "<form [formGroup]=\"form\">\r\n <div>\r\n <button type=\"button\" mat-flat-button color=\"primary\" (click)=\"addId()\">\r\n <mat-icon>add_circle</mat-icon> ID\r\n </button>\r\n </div>\r\n <table *ngIf=\"entries.value?.length\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>scope</th>\r\n <th>value</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr\r\n *ngFor=\"\r\n let entry of entries.value;\r\n let i = index;\r\n let first = first;\r\n let last = last\r\n \"\r\n >\r\n <td>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"primary\"\r\n matTooltip=\"Edit this ID\"\r\n (click)=\"editId(entry, i)\"\r\n >\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Move this ID up\"\r\n [disabled]=\"first\"\r\n (click)=\"moveIdUp(i)\"\r\n >\r\n <mat-icon>arrow_upward</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Move this ID down\"\r\n [disabled]=\"last\"\r\n (click)=\"moveIdDown(i)\"\r\n >\r\n <mat-icon>arrow_downward</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"warn\"\r\n matTooltip=\"Delete this ID\"\r\n (click)=\"deleteId(i)\"\r\n >\r\n <mat-icon>remove_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ entry.scope }}</td>\r\n <td>{{ entry.value }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n\r\n <mat-expansion-panel [expanded]=\"edited\" [disabled]=\"!edited\">\r\n <mat-expansion-panel-header>ID</mat-expansion-panel-header>\r\n <cadmus-refs-asserted-id\r\n [hasSubmit]=\"true\"\r\n [id]=\"edited\"\r\n (idChange)=\"onIdChange($event)\"\r\n ></cadmus-refs-asserted-id>\r\n </mat-expansion-panel>\r\n</form>\r\n", styles: ["th{font-weight:400;color:silver;text-align:left}\n"], dependencies: [{ kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i4.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i4.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i5.MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["disabled", "expanded", "hideToggle", "togglePosition"], outputs: ["opened", "closed", "expandedChange", "afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { kind: "component", type: i5.MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["tabIndex", "expandedHeight", "collapsedHeight"] }, { kind: "component", type: i8.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: AssertedIdComponent, selector: "cadmus-refs-asserted-id", inputs: ["scopeEntries", "idTagEntries", "assTagEntries", "refTypeEntries", "refTagEntries", "id", "noEidLookup", "hasSubmit"], outputs: ["idChange"] }] });
432
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: AssertedIdsComponent, decorators: [{
283
433
  type: Component,
284
- args: [{ selector: 'cadmus-refs-asserted-ids', template: "<form [formGroup]=\"form\">\r\n <div formArrayName=\"idsArr\">\r\n <div>\r\n <button\r\n type=\"button\"\r\n mat-flat-button\r\n color=\"primary\"\r\n (click)=\"addId()\"\r\n >\r\n <mat-icon>add_circle</mat-icon> add ID\r\n </button>\r\n </div>\r\n <div\r\n *ngFor=\"\r\n let item of idsArr.controls;\r\n let i = index;\r\n let first = first;\r\n let last = last\r\n \"\r\n >\r\n <!-- child form -->\r\n <div [formGroupName]=\"i\">\r\n <!-- child actions -->\r\n {{ i + 1 }}.\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Remove this ID\"\r\n color=\"warn\"\r\n (click)=\"removeId(i)\"\r\n >\r\n <mat-icon>remove_circle</mat-icon>\r\n </button>\r\n <button\r\n [disabled]=\"first\"\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Move ID up\"\r\n (click)=\"moveIdUp(i)\"\r\n >\r\n <mat-icon>arrow_upward</mat-icon>\r\n </button>\r\n <button\r\n [disabled]=\"last\"\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Move ID down\"\r\n (click)=\"moveIdDown(i)\"\r\n >\r\n <mat-icon>arrow_downward</mat-icon>\r\n </button>\r\n\r\n <!-- child controls -->\r\n <!-- value -->\r\n <mat-form-field>\r\n <mat-label>external ID</mat-label>\r\n <input #id autofocus matInput formControlName=\"value\" />\r\n <mat-error\r\n *ngIf=\"\r\n $any(item)['controls'].value?.hasError('required') &&\r\n ($any(item)['controls'].value.dirty ||\r\n $any(item)['controls'].value.touched)\r\n \"\r\n >ID required\r\n </mat-error>\r\n <mat-error\r\n *ngIf=\"\r\n $any(item)['controls'].value?.hasError('max-length') &&\r\n ($any(item)['controls'].value.dirty ||\r\n $any(item)['controls'].value.touched)\r\n \"\r\n >ID too long\r\n </mat-error>\r\n </mat-form-field>\r\n\r\n &nbsp;\r\n <!-- scope (bound) -->\r\n <ng-container *ngIf=\"scopeEntries\">\r\n <mat-form-field style=\"width: 8em\">\r\n <mat-label>scope</mat-label>\r\n <mat-select formControlName=\"scope\">\r\n <mat-option *ngFor=\"let e of scopeEntries\" [value]=\"e.id\">\r\n {{ e.value }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <!-- scope (free) -->\r\n <ng-container *ngIf=\"!scopeEntries\">\r\n <mat-form-field style=\"width: 8em\">\r\n <mat-label>scope</mat-label>\r\n <input matInput formControlName=\"scope\" />\r\n <mat-error\r\n *ngIf=\"\r\n $any(item)['controls'].scope?.hasError('max-length') &&\r\n ($any(item)['controls'].scope.dirty ||\r\n $any(item)['controls'].scope.touched)\r\n \"\r\n >scope too long\r\n </mat-error>\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n &nbsp;\r\n <!-- tag (bound) -->\r\n <ng-container *ngIf=\"tagEntries\">\r\n <mat-form-field style=\"width: 8em\">\r\n <mat-label>tag</mat-label>\r\n <mat-select formControlName=\"tag\">\r\n <mat-option *ngFor=\"let e of tagEntries\" [value]=\"e.id\">\r\n {{ e.value }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <!-- tag (free) -->\r\n <ng-container *ngIf=\"!tagEntries\">\r\n <mat-form-field style=\"width: 8em\">\r\n <mat-label>tag</mat-label>\r\n <input matInput formControlName=\"tag\" />\r\n <mat-error\r\n *ngIf=\"\r\n $any(item)['controls'].tag?.hasError('max-length') &&\r\n ($any(item)['controls'].tag.dirty ||\r\n $any(item)['controls'].tag.touched)\r\n \"\r\n >tag too long\r\n </mat-error>\r\n </mat-form-field>\r\n </ng-container>\r\n\r\n <!-- assertion -->\r\n &nbsp;\r\n <button\r\n type=\"button\"\r\n color=\"primary\"\r\n mat-icon-button\r\n matTooltip=\"Edit assertion\"\r\n (click)=\"editAssertion(i)\"\r\n >\r\n <mat-icon>feedback</mat-icon>\r\n </button>\r\n </div>\r\n </div>\r\n <!-- assertion -->\r\n <mat-expansion-panel\r\n *ngIf=\"idsArr?.length\"\r\n [disabled]=\"!assertionNr\"\r\n [(expanded)]=\"assEdOpen\"\r\n >\r\n <mat-expansion-panel-header\r\n >#{{ assertionNr }} assertion</mat-expansion-panel-header\r\n >\r\n <cadmus-refs-assertion\r\n [assertion]=\"initialAssertion\"\r\n [assTagEntries]=\"assTagEntries\"\r\n [refTagEntries]=\"refTagEntries\"\r\n [refTypeEntries]=\"refTypeEntries\"\r\n (assertionChange)=\"onAssertionChange($event)\"\r\n ></cadmus-refs-assertion>\r\n <button\r\n color=\"primary\"\r\n type=\"button\"\r\n mat-flat-button\r\n style=\"margin-top: 6px;\"\r\n (click)=\"saveAssertion()\"\r\n >\r\n <mat-icon>check_circle</mat-icon> assertion\r\n </button>\r\n </mat-expansion-panel>\r\n </div>\r\n</form>\r\n" }]
285
- }], ctorParameters: function () { return [{ type: i1.FormBuilder }]; }, propDecorators: { idQueryList: [{
286
- type: ViewChildren,
287
- args: ['id']
288
- }], ids: [{
434
+ args: [{ selector: 'cadmus-refs-asserted-ids', template: "<form [formGroup]=\"form\">\r\n <div>\r\n <button type=\"button\" mat-flat-button color=\"primary\" (click)=\"addId()\">\r\n <mat-icon>add_circle</mat-icon> ID\r\n </button>\r\n </div>\r\n <table *ngIf=\"entries.value?.length\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>scope</th>\r\n <th>value</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr\r\n *ngFor=\"\r\n let entry of entries.value;\r\n let i = index;\r\n let first = first;\r\n let last = last\r\n \"\r\n >\r\n <td>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"primary\"\r\n matTooltip=\"Edit this ID\"\r\n (click)=\"editId(entry, i)\"\r\n >\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Move this ID up\"\r\n [disabled]=\"first\"\r\n (click)=\"moveIdUp(i)\"\r\n >\r\n <mat-icon>arrow_upward</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Move this ID down\"\r\n [disabled]=\"last\"\r\n (click)=\"moveIdDown(i)\"\r\n >\r\n <mat-icon>arrow_downward</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"warn\"\r\n matTooltip=\"Delete this ID\"\r\n (click)=\"deleteId(i)\"\r\n >\r\n <mat-icon>remove_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ entry.scope }}</td>\r\n <td>{{ entry.value }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n\r\n <mat-expansion-panel [expanded]=\"edited\" [disabled]=\"!edited\">\r\n <mat-expansion-panel-header>ID</mat-expansion-panel-header>\r\n <cadmus-refs-asserted-id\r\n [hasSubmit]=\"true\"\r\n [id]=\"edited\"\r\n (idChange)=\"onIdChange($event)\"\r\n ></cadmus-refs-asserted-id>\r\n </mat-expansion-panel>\r\n</form>\r\n", styles: ["th{font-weight:400;color:silver;text-align:left}\n"] }]
435
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: i2.DialogService }]; }, propDecorators: { ids: [{
289
436
  type: Input
290
437
  }], scopeEntries: [{
291
438
  type: Input
@@ -303,8 +450,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImpor
303
450
 
304
451
  class CadmusRefsAssertedIdsModule {
305
452
  }
306
- CadmusRefsAssertedIdsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: CadmusRefsAssertedIdsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
307
- CadmusRefsAssertedIdsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.0.2", ngImport: i0, type: CadmusRefsAssertedIdsModule, declarations: [AssertedIdComponent, AssertedIdsComponent], imports: [CommonModule,
453
+ CadmusRefsAssertedIdsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: CadmusRefsAssertedIdsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
454
+ CadmusRefsAssertedIdsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.1", ngImport: i0, type: CadmusRefsAssertedIdsModule, declarations: [AssertedIdComponent,
455
+ AssertedIdsComponent,
456
+ ScopedPinLookupComponent], imports: [CommonModule,
308
457
  FormsModule,
309
458
  ReactiveFormsModule,
310
459
  // material
@@ -317,8 +466,12 @@ CadmusRefsAssertedIdsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0
317
466
  // Cadmus
318
467
  CadmusCoreModule,
319
468
  CadmusRefsDocReferencesModule,
320
- CadmusRefsAssertionModule], exports: [AssertedIdComponent, AssertedIdsComponent] });
321
- CadmusRefsAssertedIdsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: CadmusRefsAssertedIdsModule, imports: [CommonModule,
469
+ CadmusRefsAssertionModule,
470
+ CadmusRefsLookupModule,
471
+ CadmusApiModule], exports: [AssertedIdComponent,
472
+ AssertedIdsComponent,
473
+ ScopedPinLookupComponent] });
474
+ CadmusRefsAssertedIdsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: CadmusRefsAssertedIdsModule, imports: [CommonModule,
322
475
  FormsModule,
323
476
  ReactiveFormsModule,
324
477
  // material
@@ -331,11 +484,17 @@ CadmusRefsAssertedIdsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0
331
484
  // Cadmus
332
485
  CadmusCoreModule,
333
486
  CadmusRefsDocReferencesModule,
334
- CadmusRefsAssertionModule] });
335
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: CadmusRefsAssertedIdsModule, decorators: [{
487
+ CadmusRefsAssertionModule,
488
+ CadmusRefsLookupModule,
489
+ CadmusApiModule] });
490
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: CadmusRefsAssertedIdsModule, decorators: [{
336
491
  type: NgModule,
337
492
  args: [{
338
- declarations: [AssertedIdComponent, AssertedIdsComponent],
493
+ declarations: [
494
+ AssertedIdComponent,
495
+ AssertedIdsComponent,
496
+ ScopedPinLookupComponent,
497
+ ],
339
498
  imports: [
340
499
  CommonModule,
341
500
  FormsModule,
@@ -351,8 +510,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImpor
351
510
  CadmusCoreModule,
352
511
  CadmusRefsDocReferencesModule,
353
512
  CadmusRefsAssertionModule,
513
+ CadmusRefsLookupModule,
514
+ CadmusApiModule,
515
+ ],
516
+ exports: [
517
+ AssertedIdComponent,
518
+ AssertedIdsComponent,
519
+ ScopedPinLookupComponent,
354
520
  ],
355
- exports: [AssertedIdComponent, AssertedIdsComponent],
356
521
  }]
357
522
  }] });
358
523
 
@@ -364,6 +529,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImpor
364
529
  * Generated bundle index. Do not edit.
365
530
  */
366
531
 
367
- export { AssertedIdComponent, AssertedIdsComponent, CadmusRefsAssertedIdsModule };
368
- //# sourceMappingURL=myrmidon-cadmus-refs-asserted-ids.mjs.map
532
+ export { AssertedIdComponent, AssertedIdsComponent, CadmusRefsAssertedIdsModule, PinRefLookupService, ScopedPinLookupComponent };
369
533
  //# sourceMappingURL=myrmidon-cadmus-refs-asserted-ids.mjs.map