@myrmidon/cadmus-refs-asserted-ids 1.0.3 → 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.
- package/README.md +30 -11
- package/esm2020/lib/asserted-id/asserted-id.component.mjs +44 -18
- package/esm2020/lib/asserted-ids/asserted-ids.component.mjs +91 -156
- package/esm2020/lib/cadmus-refs-asserted-ids.module.mjs +30 -9
- package/esm2020/lib/scoped-pin-lookup/scoped-pin-lookup.component.mjs +125 -0
- package/esm2020/lib/services/pin-ref-lookup.service.mjs +71 -0
- package/esm2020/public-api.mjs +3 -1
- package/fesm2015/myrmidon-cadmus-refs-asserted-ids.mjs +340 -175
- package/fesm2015/myrmidon-cadmus-refs-asserted-ids.mjs.map +1 -1
- package/fesm2020/myrmidon-cadmus-refs-asserted-ids.mjs +334 -174
- package/fesm2020/myrmidon-cadmus-refs-asserted-ids.mjs.map +1 -1
- package/lib/asserted-id/asserted-id.component.d.ts +14 -3
- package/lib/asserted-ids/asserted-ids.component.d.ts +20 -30
- package/lib/cadmus-refs-asserted-ids.module.d.ts +15 -12
- package/lib/scoped-pin-lookup/scoped-pin-lookup.component.d.ts +39 -0
- package/lib/services/pin-ref-lookup.service.d.ts +18 -0
- package/package.json +1 -1
- package/public-api.d.ts +2 -0
|
@@ -1,32 +1,218 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { EventEmitter, Component,
|
|
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
|
|
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
|
|
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
|
|
15
|
+
import * as i7 from '@angular/material/form-field';
|
|
11
16
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
12
|
-
import * as
|
|
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
|
|
21
|
+
import * as i10 from '@angular/material/select';
|
|
15
22
|
import { MatSelectModule } from '@angular/material/select';
|
|
16
|
-
import * as
|
|
17
|
-
import * as
|
|
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
|
|
20
|
-
import {
|
|
21
|
-
import * as
|
|
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 === null || item === void 0 ? void 0 : 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
|
+
var _a;
|
|
81
|
+
if (w.error) {
|
|
82
|
+
console.error(w.error);
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
return ((_a = w.value) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
87
|
+
}
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
PinRefLookupService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: PinRefLookupService, deps: [{ token: i1.ItemService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
92
|
+
PinRefLookupService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: PinRefLookupService, providedIn: 'root' });
|
|
93
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: PinRefLookupService, decorators: [{
|
|
94
|
+
type: Injectable,
|
|
95
|
+
args: [{
|
|
96
|
+
providedIn: 'root',
|
|
97
|
+
}]
|
|
98
|
+
}], ctorParameters: function () { return [{ type: i1.ItemService }]; } });
|
|
99
|
+
|
|
100
|
+
// from Cadmus general parts
|
|
101
|
+
const METADATA_PART_ID = 'it.vedph.metadata';
|
|
102
|
+
/*
|
|
103
|
+
* Scoped pin-based lookup component. This component provides a list
|
|
104
|
+
* of pin-based searches, with a lookup control. Whenever the user
|
|
105
|
+
* picks a pin value, he gets the details about its item and part, and
|
|
106
|
+
* item's metadata part, if any. He can then use these data to build
|
|
107
|
+
* some EID by variously assembling these components.
|
|
108
|
+
*/
|
|
109
|
+
class ScopedPinLookupComponent {
|
|
110
|
+
constructor(formBuilder, _itemService, lookupService, lookupDefs) {
|
|
111
|
+
this._itemService = _itemService;
|
|
112
|
+
this.lookupService = lookupService;
|
|
113
|
+
this.lookupDefs = lookupDefs;
|
|
114
|
+
// lookup
|
|
115
|
+
// keys are all the defined lookup searches
|
|
116
|
+
this.keys = Object.keys(lookupDefs);
|
|
117
|
+
// the selected key defines the lookup scope
|
|
118
|
+
this.key = formBuilder.control(null);
|
|
119
|
+
this.keyForm = formBuilder.group({
|
|
120
|
+
key: this.key,
|
|
121
|
+
});
|
|
122
|
+
// id
|
|
123
|
+
this.id = formBuilder.control(null, [
|
|
124
|
+
Validators.required,
|
|
125
|
+
Validators.maxLength(300),
|
|
126
|
+
]);
|
|
127
|
+
this.idForm = formBuilder.group({
|
|
128
|
+
id: this.id,
|
|
129
|
+
});
|
|
130
|
+
// event
|
|
131
|
+
this.idPick = new EventEmitter();
|
|
132
|
+
}
|
|
133
|
+
ngOnInit() {
|
|
134
|
+
// pre-select a unique key
|
|
135
|
+
if (this.keys.length === 1) {
|
|
136
|
+
this.key.setValue(this.keys[0]);
|
|
137
|
+
this.key.markAsDirty();
|
|
138
|
+
this.key.updateValueAndValidity();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
onItemChange(item) {
|
|
142
|
+
const info = {
|
|
143
|
+
pin: item,
|
|
144
|
+
};
|
|
145
|
+
// lookup item and its metadata part if any
|
|
146
|
+
forkJoin({
|
|
147
|
+
item: this._itemService.getItem(item.itemId, false),
|
|
148
|
+
part: this._itemService.getPartFromTypeAndRole(item.itemId, METADATA_PART_ID),
|
|
149
|
+
})
|
|
150
|
+
.pipe(take(1))
|
|
151
|
+
.subscribe({
|
|
152
|
+
next: (result) => {
|
|
153
|
+
info.item = result.item;
|
|
154
|
+
info.part = result.part;
|
|
155
|
+
this.info = info;
|
|
156
|
+
},
|
|
157
|
+
error: (error) => {
|
|
158
|
+
console.error(error ? JSON.stringify(error) : 'Error loading item/metadata');
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
appendIdComponent(type, metaIndex = -1) {
|
|
163
|
+
var _a, _b, _c, _d;
|
|
164
|
+
let id = this.id.value || '';
|
|
165
|
+
switch (type) {
|
|
166
|
+
case 'itemId':
|
|
167
|
+
id += ((_a = this.info.item) === null || _a === void 0 ? void 0 : _a.id) || '';
|
|
168
|
+
break;
|
|
169
|
+
case 'partId':
|
|
170
|
+
id += ((_b = this.info.part) === null || _b === void 0 ? void 0 : _b.id) || '';
|
|
171
|
+
break;
|
|
172
|
+
case 'partTypeId':
|
|
173
|
+
id += ((_c = this.info.part) === null || _c === void 0 ? void 0 : _c.typeId) || '';
|
|
174
|
+
break;
|
|
175
|
+
case 'partRoleId':
|
|
176
|
+
id += ((_d = this.info.part) === null || _d === void 0 ? void 0 : _d.roleId) || '';
|
|
177
|
+
break;
|
|
178
|
+
case 'metadata':
|
|
179
|
+
id += this.info.part.metadata[metaIndex].value;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
this.id.setValue(id);
|
|
183
|
+
this.id.markAsDirty();
|
|
184
|
+
this.id.updateValueAndValidity();
|
|
185
|
+
}
|
|
186
|
+
pickId() {
|
|
187
|
+
if (this.idForm.invalid) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
this.idPick.emit(this.id.value);
|
|
191
|
+
}
|
|
192
|
+
resetId() {
|
|
193
|
+
this.id.reset();
|
|
194
|
+
this.id.markAsDirty();
|
|
195
|
+
this.id.updateValueAndValidity();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
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 });
|
|
199
|
+
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"] }] });
|
|
200
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: ScopedPinLookupComponent, decorators: [{
|
|
201
|
+
type: Component,
|
|
202
|
+
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"] }]
|
|
203
|
+
}], ctorParameters: function () {
|
|
204
|
+
return [{ type: i1$1.FormBuilder }, { type: i1.ItemService }, { type: PinRefLookupService }, { type: undefined, decorators: [{
|
|
205
|
+
type: Inject,
|
|
206
|
+
args: ['indexLookupDefinitions']
|
|
207
|
+
}] }];
|
|
208
|
+
}, propDecorators: { idPick: [{
|
|
209
|
+
type: Output
|
|
210
|
+
}] } });
|
|
211
|
+
|
|
26
212
|
class AssertedIdComponent {
|
|
27
|
-
constructor(formBuilder) {
|
|
28
|
-
this.
|
|
29
|
-
|
|
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,8 @@ class AssertedIdComponent {
|
|
|
38
224
|
value: this.value,
|
|
39
225
|
scope: this.scope,
|
|
40
226
|
});
|
|
227
|
+
this.lookupExpanded = false;
|
|
228
|
+
this.idChange = new EventEmitter();
|
|
41
229
|
}
|
|
42
230
|
get id() {
|
|
43
231
|
return this._id;
|
|
@@ -59,6 +247,12 @@ class AssertedIdComponent {
|
|
|
59
247
|
this.assertion = assertion;
|
|
60
248
|
setTimeout(() => this.emitIdChange(), 0);
|
|
61
249
|
}
|
|
250
|
+
onIdPick(id) {
|
|
251
|
+
this.value.setValue(id);
|
|
252
|
+
this.value.markAsDirty();
|
|
253
|
+
this.value.updateValueAndValidity();
|
|
254
|
+
this.lookupExpanded = false;
|
|
255
|
+
}
|
|
62
256
|
updateForm(value) {
|
|
63
257
|
this._updatingForm = true;
|
|
64
258
|
if (!value) {
|
|
@@ -85,15 +279,27 @@ class AssertedIdComponent {
|
|
|
85
279
|
};
|
|
86
280
|
}
|
|
87
281
|
emitIdChange() {
|
|
88
|
-
|
|
282
|
+
if (!this.hasSubmit) {
|
|
283
|
+
this.idChange.emit(this.getId());
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
save() {
|
|
287
|
+
if (this.form.valid) {
|
|
288
|
+
this.idChange.emit(this.getId());
|
|
289
|
+
}
|
|
89
290
|
}
|
|
90
291
|
}
|
|
91
|
-
AssertedIdComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
92
|
-
AssertedIdComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.
|
|
93
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
292
|
+
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 });
|
|
293
|
+
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"] }] });
|
|
294
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: AssertedIdComponent, decorators: [{
|
|
94
295
|
type: Component,
|
|
95
|
-
args: [{ selector: 'cadmus-refs-asserted-id', template: "<form [formGroup]=\"form\">\n <div>\n <!-- tag (bound) -->\n
|
|
96
|
-
}], ctorParameters: function () {
|
|
296
|
+
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"] }]
|
|
297
|
+
}], ctorParameters: function () {
|
|
298
|
+
return [{ type: i1$1.FormBuilder }, { type: PinRefLookupService }, { type: undefined, decorators: [{
|
|
299
|
+
type: Inject,
|
|
300
|
+
args: ['indexLookupDefinitions']
|
|
301
|
+
}] }];
|
|
302
|
+
}, propDecorators: { scopeEntries: [{
|
|
97
303
|
type: Input
|
|
98
304
|
}], idTagEntries: [{
|
|
99
305
|
type: Input
|
|
@@ -105,21 +311,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImpor
|
|
|
105
311
|
type: Input
|
|
106
312
|
}], id: [{
|
|
107
313
|
type: Input
|
|
314
|
+
}], noEidLookup: [{
|
|
315
|
+
type: Input
|
|
316
|
+
}], hasSubmit: [{
|
|
317
|
+
type: Input
|
|
108
318
|
}], idChange: [{
|
|
109
319
|
type: Output
|
|
110
320
|
}] } });
|
|
111
321
|
|
|
322
|
+
/**
|
|
323
|
+
* Asserted IDs editor.
|
|
324
|
+
*/
|
|
112
325
|
class AssertedIdsComponent {
|
|
113
|
-
constructor(
|
|
114
|
-
this.
|
|
326
|
+
constructor(formBuilder, _dialogService) {
|
|
327
|
+
this._dialogService = _dialogService;
|
|
115
328
|
this._ids = [];
|
|
116
|
-
this.
|
|
329
|
+
this._editedIndex = -1;
|
|
117
330
|
this.idsChange = new EventEmitter();
|
|
118
|
-
this.
|
|
331
|
+
this.entries = formBuilder.control([], { nonNullable: true });
|
|
119
332
|
// form
|
|
120
|
-
this.
|
|
121
|
-
|
|
122
|
-
idsArr: this.idsArr,
|
|
333
|
+
this.form = formBuilder.group({
|
|
334
|
+
ids: this.entries,
|
|
123
335
|
});
|
|
124
336
|
}
|
|
125
337
|
/**
|
|
@@ -134,164 +346,100 @@ class AssertedIdsComponent {
|
|
|
134
346
|
this.updateForm(value);
|
|
135
347
|
}
|
|
136
348
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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();
|
|
349
|
+
updateForm(ids) {
|
|
350
|
+
if (!(ids === null || ids === void 0 ? void 0 : ids.length)) {
|
|
351
|
+
this.form.reset();
|
|
352
|
+
return;
|
|
149
353
|
}
|
|
354
|
+
this.entries.setValue(ids, { emitEvent: false });
|
|
355
|
+
this.entries.updateValueAndValidity();
|
|
356
|
+
this.form.markAsPristine();
|
|
150
357
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
this.unsubscribeIds();
|
|
154
|
-
(_a = this._idSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
155
|
-
}
|
|
156
|
-
getIdGroup(id) {
|
|
157
|
-
return this._formBuilder.group({
|
|
158
|
-
value: this._formBuilder.control(id === null || id === void 0 ? void 0 : id.value, [
|
|
159
|
-
Validators.required,
|
|
160
|
-
Validators.maxLength(500),
|
|
161
|
-
]),
|
|
162
|
-
scope: this._formBuilder.control(id === null || id === void 0 ? void 0 : id.scope, Validators.maxLength(50)),
|
|
163
|
-
tag: this._formBuilder.control(id === null || id === void 0 ? void 0 : id.tag, Validators.maxLength(50)),
|
|
164
|
-
assertion: this._formBuilder.control(id === null || id === void 0 ? void 0 : id.assertion),
|
|
165
|
-
});
|
|
358
|
+
emitIdsChange() {
|
|
359
|
+
this.idsChange.emit(this.entries.value);
|
|
166
360
|
}
|
|
167
|
-
addId(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
})
|
|
172
|
-
this.idsArr.push(g);
|
|
173
|
-
if (!this._updatingForm) {
|
|
174
|
-
this.emitIdsChange();
|
|
175
|
-
}
|
|
361
|
+
addId() {
|
|
362
|
+
this.editId({
|
|
363
|
+
scope: '',
|
|
364
|
+
value: '',
|
|
365
|
+
}, -1);
|
|
176
366
|
}
|
|
177
|
-
|
|
178
|
-
this.
|
|
179
|
-
this.
|
|
180
|
-
this._idsSubs.splice(index, 1);
|
|
181
|
-
this.idsArr.removeAt(index);
|
|
182
|
-
this.emitIdsChange();
|
|
367
|
+
editId(id, index) {
|
|
368
|
+
this._editedIndex = index;
|
|
369
|
+
this.edited = id;
|
|
183
370
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
371
|
+
closeId() {
|
|
372
|
+
this._editedIndex = -1;
|
|
373
|
+
this.edited = undefined;
|
|
374
|
+
}
|
|
375
|
+
saveId(entry) {
|
|
376
|
+
const entries = [...this.entries.value];
|
|
377
|
+
if (this._editedIndex === -1) {
|
|
378
|
+
entries.push(entry);
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
entries.splice(this._editedIndex, 1, entry);
|
|
187
382
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
383
|
+
this.entries.setValue(entries);
|
|
384
|
+
this.entries.markAsDirty();
|
|
385
|
+
this.entries.updateValueAndValidity();
|
|
386
|
+
this.closeId();
|
|
387
|
+
}
|
|
388
|
+
deleteId(index) {
|
|
389
|
+
this._dialogService
|
|
390
|
+
.confirm('Confirmation', 'Delete ID?')
|
|
391
|
+
.pipe(take(1))
|
|
392
|
+
.subscribe((yes) => {
|
|
393
|
+
if (yes) {
|
|
394
|
+
if (this._editedIndex === index) {
|
|
395
|
+
this.closeId();
|
|
396
|
+
}
|
|
397
|
+
const entries = [...this.entries.value];
|
|
398
|
+
entries.splice(index, 1);
|
|
399
|
+
this.entries.setValue(entries);
|
|
400
|
+
this.entries.markAsDirty();
|
|
401
|
+
this.entries.updateValueAndValidity();
|
|
402
|
+
this.emitIdsChange();
|
|
403
|
+
}
|
|
404
|
+
});
|
|
191
405
|
}
|
|
192
406
|
moveIdUp(index) {
|
|
193
407
|
if (index < 1) {
|
|
194
408
|
return;
|
|
195
409
|
}
|
|
196
|
-
this.
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
this.
|
|
410
|
+
const entry = this.entries.value[index];
|
|
411
|
+
const entries = [...this.entries.value];
|
|
412
|
+
entries.splice(index, 1);
|
|
413
|
+
entries.splice(index - 1, 0, entry);
|
|
414
|
+
this.entries.setValue(entries);
|
|
415
|
+
this.entries.markAsDirty();
|
|
416
|
+
this.entries.updateValueAndValidity();
|
|
201
417
|
this.emitIdsChange();
|
|
202
418
|
}
|
|
203
419
|
moveIdDown(index) {
|
|
204
|
-
if (index + 1 >= this.
|
|
420
|
+
if (index + 1 >= this.entries.value.length) {
|
|
205
421
|
return;
|
|
206
422
|
}
|
|
207
|
-
this.
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
this.
|
|
423
|
+
const entry = this.entries.value[index];
|
|
424
|
+
const entries = [...this.entries.value];
|
|
425
|
+
entries.splice(index, 1);
|
|
426
|
+
entries.splice(index + 1, 0, entry);
|
|
427
|
+
this.entries.setValue(entries);
|
|
428
|
+
this.entries.markAsDirty();
|
|
429
|
+
this.entries.updateValueAndValidity();
|
|
212
430
|
this.emitIdsChange();
|
|
213
431
|
}
|
|
214
|
-
|
|
215
|
-
this.
|
|
216
|
-
this.idsArr.clear();
|
|
217
|
-
this.unsubscribeIds();
|
|
218
|
-
this._idsSubs = [];
|
|
219
|
-
if (!this._updatingForm) {
|
|
220
|
-
this.emitIdsChange();
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
editAssertion(index) {
|
|
224
|
-
// save the currently edited assertion if any
|
|
225
|
-
this.saveAssertion();
|
|
226
|
-
// edit the new assertion
|
|
227
|
-
this.initialAssertion = this.idsArr.at(index).controls['assertion'].value;
|
|
228
|
-
this.assertionNr = index + 1;
|
|
229
|
-
this.assEdOpen = true;
|
|
230
|
-
}
|
|
231
|
-
onAssertionChange(assertion) {
|
|
232
|
-
this.assertion = assertion;
|
|
233
|
-
}
|
|
234
|
-
saveAssertion() {
|
|
235
|
-
// save the currently edited assertion if any
|
|
236
|
-
if (this.assertionNr) {
|
|
237
|
-
const g = this.idsArr.at(this.assertionNr - 1);
|
|
238
|
-
g.controls['assertion'].setValue(this.assertion);
|
|
239
|
-
this.closeAssertion();
|
|
240
|
-
this.emitIdsChange();
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
closeAssertion() {
|
|
244
|
-
if (this.assertionNr) {
|
|
245
|
-
this.assEdOpen = false;
|
|
246
|
-
this.assertionNr = 0;
|
|
247
|
-
this.initialAssertion = undefined;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
updateForm(ids) {
|
|
251
|
-
if (!this.idsArr) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
this._updatingForm = true;
|
|
255
|
-
this.clearIds();
|
|
256
|
-
if (!ids) {
|
|
257
|
-
this.form.reset();
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
for (const id of ids) {
|
|
261
|
-
this.addId(id);
|
|
262
|
-
}
|
|
263
|
-
this.form.markAsPristine();
|
|
264
|
-
}
|
|
265
|
-
this._updatingForm = false;
|
|
432
|
+
onIdChange(id) {
|
|
433
|
+
this.saveId(id);
|
|
266
434
|
this.emitIdsChange();
|
|
267
435
|
}
|
|
268
|
-
getIds() {
|
|
269
|
-
var _a, _b, _c;
|
|
270
|
-
const ids = [];
|
|
271
|
-
for (let i = 0; i < this.idsArr.length; i++) {
|
|
272
|
-
const g = this.idsArr.controls[i];
|
|
273
|
-
ids.push({
|
|
274
|
-
value: (_a = g.controls.value.value) === null || _a === void 0 ? void 0 : _a.trim(),
|
|
275
|
-
scope: (_b = g.controls.scope.value) === null || _b === void 0 ? void 0 : _b.trim(),
|
|
276
|
-
tag: (_c = g.controls.tag.value) === null || _c === void 0 ? void 0 : _c.trim(),
|
|
277
|
-
assertion: g.controls.assertion.value,
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
return ids;
|
|
281
|
-
}
|
|
282
|
-
emitIdsChange() {
|
|
283
|
-
this.idsChange.emit(this.getIds());
|
|
284
|
-
}
|
|
285
436
|
}
|
|
286
|
-
AssertedIdsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
287
|
-
AssertedIdsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.
|
|
288
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
437
|
+
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 });
|
|
438
|
+
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"] }] });
|
|
439
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: AssertedIdsComponent, decorators: [{
|
|
289
440
|
type: Component,
|
|
290
|
-
args: [{ selector: 'cadmus-refs-asserted-ids', template: "<form [formGroup]=\"form\">\r\n <div
|
|
291
|
-
}], ctorParameters: function () { return [{ type: i1.FormBuilder }]; }, propDecorators: {
|
|
292
|
-
type: ViewChildren,
|
|
293
|
-
args: ['id']
|
|
294
|
-
}], ids: [{
|
|
441
|
+
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"] }]
|
|
442
|
+
}], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: i2.DialogService }]; }, propDecorators: { ids: [{
|
|
295
443
|
type: Input
|
|
296
444
|
}], scopeEntries: [{
|
|
297
445
|
type: Input
|
|
@@ -309,8 +457,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImpor
|
|
|
309
457
|
|
|
310
458
|
class CadmusRefsAssertedIdsModule {
|
|
311
459
|
}
|
|
312
|
-
CadmusRefsAssertedIdsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
313
|
-
CadmusRefsAssertedIdsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.
|
|
460
|
+
CadmusRefsAssertedIdsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: CadmusRefsAssertedIdsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
461
|
+
CadmusRefsAssertedIdsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.1", ngImport: i0, type: CadmusRefsAssertedIdsModule, declarations: [AssertedIdComponent,
|
|
462
|
+
AssertedIdsComponent,
|
|
463
|
+
ScopedPinLookupComponent], imports: [CommonModule,
|
|
314
464
|
FormsModule,
|
|
315
465
|
ReactiveFormsModule,
|
|
316
466
|
// material
|
|
@@ -323,8 +473,12 @@ CadmusRefsAssertedIdsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0
|
|
|
323
473
|
// Cadmus
|
|
324
474
|
CadmusCoreModule,
|
|
325
475
|
CadmusRefsDocReferencesModule,
|
|
326
|
-
CadmusRefsAssertionModule
|
|
327
|
-
|
|
476
|
+
CadmusRefsAssertionModule,
|
|
477
|
+
CadmusRefsLookupModule,
|
|
478
|
+
CadmusApiModule], exports: [AssertedIdComponent,
|
|
479
|
+
AssertedIdsComponent,
|
|
480
|
+
ScopedPinLookupComponent] });
|
|
481
|
+
CadmusRefsAssertedIdsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: CadmusRefsAssertedIdsModule, imports: [CommonModule,
|
|
328
482
|
FormsModule,
|
|
329
483
|
ReactiveFormsModule,
|
|
330
484
|
// material
|
|
@@ -337,11 +491,17 @@ CadmusRefsAssertedIdsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0
|
|
|
337
491
|
// Cadmus
|
|
338
492
|
CadmusCoreModule,
|
|
339
493
|
CadmusRefsDocReferencesModule,
|
|
340
|
-
CadmusRefsAssertionModule
|
|
341
|
-
|
|
494
|
+
CadmusRefsAssertionModule,
|
|
495
|
+
CadmusRefsLookupModule,
|
|
496
|
+
CadmusApiModule] });
|
|
497
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: CadmusRefsAssertedIdsModule, decorators: [{
|
|
342
498
|
type: NgModule,
|
|
343
499
|
args: [{
|
|
344
|
-
declarations: [
|
|
500
|
+
declarations: [
|
|
501
|
+
AssertedIdComponent,
|
|
502
|
+
AssertedIdsComponent,
|
|
503
|
+
ScopedPinLookupComponent,
|
|
504
|
+
],
|
|
345
505
|
imports: [
|
|
346
506
|
CommonModule,
|
|
347
507
|
FormsModule,
|
|
@@ -357,8 +517,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImpor
|
|
|
357
517
|
CadmusCoreModule,
|
|
358
518
|
CadmusRefsDocReferencesModule,
|
|
359
519
|
CadmusRefsAssertionModule,
|
|
520
|
+
CadmusRefsLookupModule,
|
|
521
|
+
CadmusApiModule,
|
|
522
|
+
],
|
|
523
|
+
exports: [
|
|
524
|
+
AssertedIdComponent,
|
|
525
|
+
AssertedIdsComponent,
|
|
526
|
+
ScopedPinLookupComponent,
|
|
360
527
|
],
|
|
361
|
-
exports: [AssertedIdComponent, AssertedIdsComponent],
|
|
362
528
|
}]
|
|
363
529
|
}] });
|
|
364
530
|
|
|
@@ -370,6 +536,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImpor
|
|
|
370
536
|
* Generated bundle index. Do not edit.
|
|
371
537
|
*/
|
|
372
538
|
|
|
373
|
-
export { AssertedIdComponent, AssertedIdsComponent, CadmusRefsAssertedIdsModule };
|
|
374
|
-
//# sourceMappingURL=myrmidon-cadmus-refs-asserted-ids.mjs.map
|
|
539
|
+
export { AssertedIdComponent, AssertedIdsComponent, CadmusRefsAssertedIdsModule, PinRefLookupService, ScopedPinLookupComponent };
|
|
375
540
|
//# sourceMappingURL=myrmidon-cadmus-refs-asserted-ids.mjs.map
|