@myrmidon/cadmus-refs-asserted-ids 1.0.3 → 1.0.6

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,218 @@
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 'pin':
165
+ id += this.info?.pin.value;
166
+ break;
167
+ case 'itemId':
168
+ id += this.info.item?.id || '';
169
+ break;
170
+ case 'partId':
171
+ id += this.info.part?.id || '';
172
+ break;
173
+ case 'partTypeId':
174
+ id += this.info.part?.typeId || '';
175
+ break;
176
+ case 'partRoleId':
177
+ id += this.info.part?.roleId || '';
178
+ break;
179
+ case 'metadata':
180
+ id += this.info.part.metadata[metaIndex].value;
181
+ break;
182
+ }
183
+ this.id.setValue(id);
184
+ this.id.markAsDirty();
185
+ this.id.updateValueAndValidity();
186
+ }
187
+ pickId() {
188
+ if (this.idForm.invalid) {
189
+ return;
190
+ }
191
+ this.idPick.emit(this.id.value);
192
+ this.info = undefined;
193
+ }
194
+ resetId() {
195
+ this.id.reset();
196
+ this.id.markAsDirty();
197
+ this.id.updateValueAndValidity();
198
+ }
199
+ }
200
+ 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 });
201
+ 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 <!-- pin -->\n <tr>\n <td>\n <button\n type=\"button\"\n mat-icon-button\n color=\"primary\"\n (click)=\"appendIdComponent('pin')\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td>pin</td>\n <td>{{ info!.pin.value }}</td>\n </tr>\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"] }] });
202
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: ScopedPinLookupComponent, decorators: [{
203
+ type: Component,
204
+ 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 <!-- pin -->\n <tr>\n <td>\n <button\n type=\"button\"\n mat-icon-button\n color=\"primary\"\n (click)=\"appendIdComponent('pin')\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td>pin</td>\n <td>{{ info!.pin.value }}</td>\n </tr>\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"] }]
205
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: i1.ItemService }, { type: PinRefLookupService }, { type: undefined, decorators: [{
206
+ type: Inject,
207
+ args: ['indexLookupDefinitions']
208
+ }] }]; }, propDecorators: { idPick: [{
209
+ type: Output
210
+ }] } });
211
+
26
212
  class AssertedIdComponent {
27
- constructor(formBuilder) {
28
- this.idChange = new EventEmitter();
29
- // form
213
+ constructor(formBuilder, lookupService, lookupDefs) {
214
+ this.lookupService = lookupService;
215
+ this.lookupDefs = lookupDefs;
30
216
  this.tag = formBuilder.control(null, Validators.maxLength(50));
31
217
  this.value = formBuilder.control(null, [
32
218
  Validators.required,
@@ -38,6 +224,10 @@ class AssertedIdComponent {
38
224
  value: this.value,
39
225
  scope: this.scope,
40
226
  });
227
+ this.lookupExpanded = false;
228
+ // events
229
+ this.idChange = new EventEmitter();
230
+ this.editorClose = new EventEmitter();
41
231
  }
42
232
  get id() {
43
233
  return this._id;
@@ -59,6 +249,12 @@ class AssertedIdComponent {
59
249
  this.assertion = assertion;
60
250
  setTimeout(() => this.emitIdChange(), 0);
61
251
  }
252
+ onIdPick(id) {
253
+ this.value.setValue(id);
254
+ this.value.markAsDirty();
255
+ this.value.updateValueAndValidity();
256
+ this.lookupExpanded = false;
257
+ }
62
258
  updateForm(value) {
63
259
  this._updatingForm = true;
64
260
  if (!value) {
@@ -84,15 +280,28 @@ class AssertedIdComponent {
84
280
  };
85
281
  }
86
282
  emitIdChange() {
87
- this.idChange.emit(this.getId());
283
+ if (!this.hasSubmit) {
284
+ this.idChange.emit(this.getId());
285
+ }
286
+ }
287
+ cancel() {
288
+ this.editorClose.emit();
289
+ }
290
+ save() {
291
+ if (this.form.valid) {
292
+ this.idChange.emit(this.getId());
293
+ }
88
294
  }
89
295
  }
90
- AssertedIdComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: AssertedIdComponent, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component });
91
- AssertedIdComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", 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"] }] });
92
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: AssertedIdComponent, decorators: [{
296
+ 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 });
297
+ 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", editorClose: "editorClose" }, 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\" (click)=\"cancel()\">\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"] }] });
298
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: AssertedIdComponent, decorators: [{
93
299
  type: Component,
94
- 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" }]
95
- }], ctorParameters: function () { return [{ type: i1.FormBuilder }]; }, propDecorators: { scopeEntries: [{
300
+ 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\" (click)=\"cancel()\">\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"] }]
301
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: PinRefLookupService }, { type: undefined, decorators: [{
302
+ type: Inject,
303
+ args: ['indexLookupDefinitions']
304
+ }] }]; }, propDecorators: { scopeEntries: [{
96
305
  type: Input
97
306
  }], idTagEntries: [{
98
307
  type: Input
@@ -104,21 +313,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImpor
104
313
  type: Input
105
314
  }], id: [{
106
315
  type: Input
316
+ }], noEidLookup: [{
317
+ type: Input
318
+ }], hasSubmit: [{
319
+ type: Input
107
320
  }], idChange: [{
108
321
  type: Output
322
+ }], editorClose: [{
323
+ type: Output
109
324
  }] } });
110
325
 
326
+ /**
327
+ * Asserted IDs editor.
328
+ */
111
329
  class AssertedIdsComponent {
112
- constructor(_formBuilder) {
113
- this._formBuilder = _formBuilder;
330
+ constructor(formBuilder, _dialogService) {
331
+ this._dialogService = _dialogService;
114
332
  this._ids = [];
115
- this._idsSubs = [];
333
+ this._editedIndex = -1;
116
334
  this.idsChange = new EventEmitter();
117
- this.assEdOpen = false;
335
+ this.entries = formBuilder.control([], { nonNullable: true });
118
336
  // form
119
- this.idsArr = _formBuilder.array([]);
120
- this.form = _formBuilder.group({
121
- idsArr: this.idsArr,
337
+ this.form = formBuilder.group({
338
+ ids: this.entries,
122
339
  });
123
340
  }
124
341
  /**
@@ -133,163 +350,100 @@ class AssertedIdsComponent {
133
350
  this.updateForm(value);
134
351
  }
135
352
  }
136
- ngAfterViewInit() {
137
- // focus on newly added ID
138
- this._idSubscription = this.idQueryList?.changes
139
- .pipe(debounceTime(300))
140
- .subscribe((lst) => {
141
- if (!this._updatingForm && lst.length > 0) {
142
- lst.last.nativeElement.focus();
143
- }
144
- });
145
- }
146
- unsubscribeIds() {
147
- for (let i = 0; i < this._idsSubs.length; i++) {
148
- this._idsSubs[i].unsubscribe();
353
+ updateForm(ids) {
354
+ if (!ids?.length) {
355
+ this.form.reset();
356
+ return;
149
357
  }
358
+ this.entries.setValue(ids, { emitEvent: false });
359
+ this.entries.updateValueAndValidity();
360
+ this.form.markAsPristine();
150
361
  }
151
- ngOnDestroy() {
152
- this.unsubscribeIds();
153
- this._idSubscription?.unsubscribe();
154
- }
155
- getIdGroup(id) {
156
- return this._formBuilder.group({
157
- value: this._formBuilder.control(id?.value, [
158
- Validators.required,
159
- Validators.maxLength(500),
160
- ]),
161
- scope: this._formBuilder.control(id?.scope, Validators.maxLength(50)),
162
- tag: this._formBuilder.control(id?.tag, Validators.maxLength(50)),
163
- assertion: this._formBuilder.control(id?.assertion),
164
- });
362
+ emitIdsChange() {
363
+ this.idsChange.emit(this.entries.value);
165
364
  }
166
- addId(id) {
167
- const g = this.getIdGroup(id);
168
- this._idsSubs.push(g.valueChanges.pipe(debounceTime(300)).subscribe((_) => {
169
- this.emitIdsChange();
170
- }));
171
- this.idsArr.push(g);
172
- if (!this._updatingForm) {
173
- this.emitIdsChange();
174
- }
365
+ addId() {
366
+ this.editId({
367
+ scope: '',
368
+ value: '',
369
+ }, -1);
175
370
  }
176
- removeId(index) {
177
- this.closeAssertion();
178
- this._idsSubs[index].unsubscribe();
179
- this._idsSubs.splice(index, 1);
180
- this.idsArr.removeAt(index);
181
- this.emitIdsChange();
371
+ editId(id, index) {
372
+ this._editedIndex = index;
373
+ this.edited = id;
182
374
  }
183
- swapArrElems(a, i, j) {
184
- if (i === j) {
185
- return;
375
+ closeId() {
376
+ this._editedIndex = -1;
377
+ this.edited = undefined;
378
+ }
379
+ saveId(entry) {
380
+ const entries = [...this.entries.value];
381
+ if (this._editedIndex === -1) {
382
+ entries.push(entry);
186
383
  }
187
- const t = a[i];
188
- a[i] = a[j];
189
- a[j] = t;
384
+ else {
385
+ entries.splice(this._editedIndex, 1, entry);
386
+ }
387
+ this.entries.setValue(entries);
388
+ this.entries.markAsDirty();
389
+ this.entries.updateValueAndValidity();
390
+ this.closeId();
391
+ }
392
+ deleteId(index) {
393
+ this._dialogService
394
+ .confirm('Confirmation', 'Delete ID?')
395
+ .pipe(take(1))
396
+ .subscribe((yes) => {
397
+ if (yes) {
398
+ if (this._editedIndex === index) {
399
+ this.closeId();
400
+ }
401
+ const entries = [...this.entries.value];
402
+ entries.splice(index, 1);
403
+ this.entries.setValue(entries);
404
+ this.entries.markAsDirty();
405
+ this.entries.updateValueAndValidity();
406
+ this.emitIdsChange();
407
+ }
408
+ });
190
409
  }
191
410
  moveIdUp(index) {
192
411
  if (index < 1) {
193
412
  return;
194
413
  }
195
- this.closeAssertion();
196
- const ctl = this.idsArr.controls[index];
197
- this.idsArr.removeAt(index);
198
- this.idsArr.insert(index - 1, ctl);
199
- this.swapArrElems(this._idsSubs, index, index - 1);
414
+ const entry = this.entries.value[index];
415
+ const entries = [...this.entries.value];
416
+ entries.splice(index, 1);
417
+ entries.splice(index - 1, 0, entry);
418
+ this.entries.setValue(entries);
419
+ this.entries.markAsDirty();
420
+ this.entries.updateValueAndValidity();
200
421
  this.emitIdsChange();
201
422
  }
202
423
  moveIdDown(index) {
203
- if (index + 1 >= this.idsArr.length) {
424
+ if (index + 1 >= this.entries.value.length) {
204
425
  return;
205
426
  }
206
- this.closeAssertion();
207
- const item = this.idsArr.controls[index];
208
- this.idsArr.removeAt(index);
209
- this.idsArr.insert(index + 1, item);
210
- this.swapArrElems(this._idsSubs, index, index + 1);
427
+ const entry = this.entries.value[index];
428
+ const entries = [...this.entries.value];
429
+ entries.splice(index, 1);
430
+ entries.splice(index + 1, 0, entry);
431
+ this.entries.setValue(entries);
432
+ this.entries.markAsDirty();
433
+ this.entries.updateValueAndValidity();
211
434
  this.emitIdsChange();
212
435
  }
213
- clearIds() {
214
- this.closeAssertion();
215
- this.idsArr.clear();
216
- this.unsubscribeIds();
217
- this._idsSubs = [];
218
- if (!this._updatingForm) {
219
- this.emitIdsChange();
220
- }
221
- }
222
- editAssertion(index) {
223
- // save the currently edited assertion if any
224
- this.saveAssertion();
225
- // edit the new assertion
226
- this.initialAssertion = this.idsArr.at(index).controls['assertion'].value;
227
- this.assertionNr = index + 1;
228
- this.assEdOpen = true;
229
- }
230
- onAssertionChange(assertion) {
231
- this.assertion = assertion;
232
- }
233
- saveAssertion() {
234
- // save the currently edited assertion if any
235
- if (this.assertionNr) {
236
- const g = this.idsArr.at(this.assertionNr - 1);
237
- g.controls['assertion'].setValue(this.assertion);
238
- this.closeAssertion();
239
- this.emitIdsChange();
240
- }
241
- }
242
- closeAssertion() {
243
- if (this.assertionNr) {
244
- this.assEdOpen = false;
245
- this.assertionNr = 0;
246
- this.initialAssertion = undefined;
247
- }
248
- }
249
- updateForm(ids) {
250
- if (!this.idsArr) {
251
- return;
252
- }
253
- this._updatingForm = true;
254
- this.clearIds();
255
- if (!ids) {
256
- this.form.reset();
257
- }
258
- else {
259
- for (const id of ids) {
260
- this.addId(id);
261
- }
262
- this.form.markAsPristine();
263
- }
264
- this._updatingForm = false;
436
+ onIdChange(id) {
437
+ this.saveId(id);
265
438
  this.emitIdsChange();
266
439
  }
267
- getIds() {
268
- const ids = [];
269
- for (let i = 0; i < this.idsArr.length; i++) {
270
- const g = this.idsArr.controls[i];
271
- ids.push({
272
- value: g.controls.value.value?.trim(),
273
- scope: g.controls.scope.value?.trim(),
274
- tag: g.controls.tag.value?.trim(),
275
- assertion: g.controls.assertion.value,
276
- });
277
- }
278
- return ids;
279
- }
280
- emitIdsChange() {
281
- this.idsChange.emit(this.getIds());
282
- }
283
440
  }
284
- AssertedIdsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: AssertedIdsComponent, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component });
285
- AssertedIdsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", 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"] }] });
286
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: AssertedIdsComponent, decorators: [{
441
+ 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 });
442
+ 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 (editorClose)=\"closeId()\"\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", "editorClose"] }] });
443
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: AssertedIdsComponent, decorators: [{
287
444
  type: Component,
288
- 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" }]
289
- }], ctorParameters: function () { return [{ type: i1.FormBuilder }]; }, propDecorators: { idQueryList: [{
290
- type: ViewChildren,
291
- args: ['id']
292
- }], ids: [{
445
+ 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 (editorClose)=\"closeId()\"\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"] }]
446
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: i2.DialogService }]; }, propDecorators: { ids: [{
293
447
  type: Input
294
448
  }], scopeEntries: [{
295
449
  type: Input
@@ -307,8 +461,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImpor
307
461
 
308
462
  class CadmusRefsAssertedIdsModule {
309
463
  }
310
- CadmusRefsAssertedIdsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: CadmusRefsAssertedIdsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
311
- CadmusRefsAssertedIdsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.0.4", ngImport: i0, type: CadmusRefsAssertedIdsModule, declarations: [AssertedIdComponent, AssertedIdsComponent], imports: [CommonModule,
464
+ CadmusRefsAssertedIdsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: CadmusRefsAssertedIdsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
465
+ CadmusRefsAssertedIdsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.1", ngImport: i0, type: CadmusRefsAssertedIdsModule, declarations: [AssertedIdComponent,
466
+ AssertedIdsComponent,
467
+ ScopedPinLookupComponent], imports: [CommonModule,
312
468
  FormsModule,
313
469
  ReactiveFormsModule,
314
470
  // material
@@ -321,8 +477,12 @@ CadmusRefsAssertedIdsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0
321
477
  // Cadmus
322
478
  CadmusCoreModule,
323
479
  CadmusRefsDocReferencesModule,
324
- CadmusRefsAssertionModule], exports: [AssertedIdComponent, AssertedIdsComponent] });
325
- CadmusRefsAssertedIdsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: CadmusRefsAssertedIdsModule, imports: [CommonModule,
480
+ CadmusRefsAssertionModule,
481
+ CadmusRefsLookupModule,
482
+ CadmusApiModule], exports: [AssertedIdComponent,
483
+ AssertedIdsComponent,
484
+ ScopedPinLookupComponent] });
485
+ CadmusRefsAssertedIdsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: CadmusRefsAssertedIdsModule, imports: [CommonModule,
326
486
  FormsModule,
327
487
  ReactiveFormsModule,
328
488
  // material
@@ -335,11 +495,17 @@ CadmusRefsAssertedIdsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0
335
495
  // Cadmus
336
496
  CadmusCoreModule,
337
497
  CadmusRefsDocReferencesModule,
338
- CadmusRefsAssertionModule] });
339
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: CadmusRefsAssertedIdsModule, decorators: [{
498
+ CadmusRefsAssertionModule,
499
+ CadmusRefsLookupModule,
500
+ CadmusApiModule] });
501
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: CadmusRefsAssertedIdsModule, decorators: [{
340
502
  type: NgModule,
341
503
  args: [{
342
- declarations: [AssertedIdComponent, AssertedIdsComponent],
504
+ declarations: [
505
+ AssertedIdComponent,
506
+ AssertedIdsComponent,
507
+ ScopedPinLookupComponent,
508
+ ],
343
509
  imports: [
344
510
  CommonModule,
345
511
  FormsModule,
@@ -355,8 +521,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImpor
355
521
  CadmusCoreModule,
356
522
  CadmusRefsDocReferencesModule,
357
523
  CadmusRefsAssertionModule,
524
+ CadmusRefsLookupModule,
525
+ CadmusApiModule,
526
+ ],
527
+ exports: [
528
+ AssertedIdComponent,
529
+ AssertedIdsComponent,
530
+ ScopedPinLookupComponent,
358
531
  ],
359
- exports: [AssertedIdComponent, AssertedIdsComponent],
360
532
  }]
361
533
  }] });
362
534
 
@@ -368,6 +540,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImpor
368
540
  * Generated bundle index. Do not edit.
369
541
  */
370
542
 
371
- export { AssertedIdComponent, AssertedIdsComponent, CadmusRefsAssertedIdsModule };
543
+ export { AssertedIdComponent, AssertedIdsComponent, CadmusRefsAssertedIdsModule, PinRefLookupService, ScopedPinLookupComponent };
372
544
  //# sourceMappingURL=myrmidon-cadmus-refs-asserted-ids.mjs.map
373
545
  //# sourceMappingURL=myrmidon-cadmus-refs-asserted-ids.mjs.map