@myrmidon/cadmus-profile-editor 1.0.1 → 20.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,1028 +1,1417 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import * as i1 from
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
import * as
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
message: `Duplicate part (typeId "${part.typeId}", ` +
|
|
171
|
-
`roleId "${part.roleId ?? '(none)'}") in ${label}.`,
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
seenPartKeys.add(key);
|
|
176
|
-
}
|
|
177
|
-
// duplicate part color (info)
|
|
178
|
-
if (part.colorKey) {
|
|
179
|
-
if (seenPartColors.has(part.colorKey)) {
|
|
180
|
-
issues.push({
|
|
181
|
-
severity: 'info',
|
|
182
|
-
message: `Duplicate part color "${part.colorKey}" in ${label}.`,
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
seenPartColors.add(part.colorKey);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
// duplicate part description (info)
|
|
190
|
-
if (part.description) {
|
|
191
|
-
if (seenPartDescriptions.has(part.description)) {
|
|
192
|
-
issues.push({
|
|
193
|
-
severity: 'info',
|
|
194
|
-
message: `Duplicate part description "${part.description}" for type "${part.typeId}" in ${label}.`,
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
seenPartDescriptions.add(part.description);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
// thesaurus coverage check (only when model settings are available)
|
|
204
|
-
if (!facetModelSettings) {
|
|
205
|
-
return of(this.buildResult(issues));
|
|
206
|
-
}
|
|
207
|
-
return this._thesaurusService.getThesaurusIds().pipe(map((ids) => {
|
|
208
|
-
// remove final @language from IDs for comparison, as facet model settings
|
|
209
|
-
// do not include the language suffix
|
|
210
|
-
const existingIds = new Set(ids.map((id) => id.replace(/\@[a-z]+$/g, '')));
|
|
211
|
-
this.checkThesauri(issues, existingIds, facetModelSettings.parts, 'Part');
|
|
212
|
-
if (facetModelSettings.fragments) {
|
|
213
|
-
this.checkThesauri(issues, existingIds, facetModelSettings.fragments, 'Fragment');
|
|
214
|
-
}
|
|
215
|
-
return this.buildResult(issues);
|
|
216
|
-
}));
|
|
217
|
-
}
|
|
218
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: FacetDefinitionValidatorService, deps: [{ token: i1.ThesaurusService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
219
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: FacetDefinitionValidatorService, providedIn: 'root' });
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, Injectable, computed, effect, input, linkedSignal, model, output, signal, untracked } from "@angular/core";
|
|
3
|
+
import { from, of } from "rxjs";
|
|
4
|
+
import { catchError, concatMap, map, take, tap, toArray } from "rxjs/operators";
|
|
5
|
+
import * as i1$1 from "@myrmidon/cadmus-api";
|
|
6
|
+
import { FormField, form, maxLength, pattern, required, validate } from "@angular/forms/signals";
|
|
7
|
+
import * as i2 from "@angular/material/button";
|
|
8
|
+
import { MatButtonModule, MatIconButton } from "@angular/material/button";
|
|
9
|
+
import { MatCheckbox } from "@angular/material/checkbox";
|
|
10
|
+
import { MatError, MatFormField, MatLabel, MatSuffix } from "@angular/material/form-field";
|
|
11
|
+
import { MatExpansionPanel, MatExpansionPanelDescription, MatExpansionPanelHeader, MatExpansionPanelTitle } from "@angular/material/expansion";
|
|
12
|
+
import { MatIcon } from "@angular/material/icon";
|
|
13
|
+
import { MatError as MatError$1, MatFormField as MatFormField$1, MatInput, MatLabel as MatLabel$1 } from "@angular/material/input";
|
|
14
|
+
import { MatTab, MatTabGroup } from "@angular/material/tabs";
|
|
15
|
+
import { MatTooltip } from "@angular/material/tooltip";
|
|
16
|
+
import { ColorToContrastPipe, EllipsisPipe } from "@myrmidon/ngx-tools";
|
|
17
|
+
import { MatOption, MatSelect } from "@angular/material/select";
|
|
18
|
+
import * as i1 from "@myrmidon/ngx-mat-tools";
|
|
19
|
+
import { MatProgressBar } from "@angular/material/progress-bar";
|
|
20
|
+
import * as i4 from "@angular/material/snack-bar";
|
|
21
|
+
import { MatCard, MatCardContent, MatCardHeader, MatCardTitle } from "@angular/material/card";
|
|
22
|
+
import { pendingChangesGuard } from "@myrmidon/cadmus-core";
|
|
23
|
+
var FacetDefinitionValidatorService = class FacetDefinitionValidatorService {
|
|
24
|
+
_thesaurusService;
|
|
25
|
+
constructor(_thesaurusService) {
|
|
26
|
+
this._thesaurusService = _thesaurusService;
|
|
27
|
+
}
|
|
28
|
+
buildResult(issues) {
|
|
29
|
+
return {
|
|
30
|
+
issues,
|
|
31
|
+
hasErrors: issues.some((i) => i.severity === "error"),
|
|
32
|
+
hasWarnings: issues.some((i) => i.severity === "warning"),
|
|
33
|
+
hasInfos: issues.some((i) => i.severity === "info")
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
checkThesauri(issues, existingIds, entries, kind) {
|
|
37
|
+
for (const [typeId, entry] of Object.entries(entries)) for (const rawId of entry.thesauriIds ?? []) {
|
|
38
|
+
const required = rawId.startsWith("*");
|
|
39
|
+
const bareId = required ? rawId.substring(1) : rawId;
|
|
40
|
+
if (!existingIds.has(bareId)) {
|
|
41
|
+
if (required) issues.push({
|
|
42
|
+
severity: "error",
|
|
43
|
+
message: `${kind} "${typeId}" requires thesaurus "${bareId}" which does not exist.`
|
|
44
|
+
});
|
|
45
|
+
else issues.push({
|
|
46
|
+
severity: "info",
|
|
47
|
+
message: `${kind} "${typeId}" uses optional thesaurus "${bareId}" which does not exist.`
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
validate(facets, facetModelSettings) {
|
|
53
|
+
const issues = [];
|
|
54
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
55
|
+
const seenLabels = /* @__PURE__ */ new Set();
|
|
56
|
+
const seenColors = /* @__PURE__ */ new Set();
|
|
57
|
+
const seenDescriptions = /* @__PURE__ */ new Set();
|
|
58
|
+
for (const facet of facets) {
|
|
59
|
+
const label = `facet "${facet.id}"`;
|
|
60
|
+
if (!facet.id) issues.push({
|
|
61
|
+
severity: "error",
|
|
62
|
+
message: "A facet has an empty ID."
|
|
63
|
+
});
|
|
64
|
+
else if (facet.id === "new") issues.push({
|
|
65
|
+
severity: "warning",
|
|
66
|
+
message: `Facet has placeholder ID "new" — please assign a real ID.`
|
|
67
|
+
});
|
|
68
|
+
else if (seenIds.has(facet.id)) issues.push({
|
|
69
|
+
severity: "error",
|
|
70
|
+
message: `Duplicate facet ID: "${facet.id}".`
|
|
71
|
+
});
|
|
72
|
+
else seenIds.add(facet.id);
|
|
73
|
+
if (facet.label) {
|
|
74
|
+
if (seenLabels.has(facet.label)) issues.push({
|
|
75
|
+
severity: "error",
|
|
76
|
+
message: `Duplicate facet label "${facet.label}" in ${label}.`
|
|
77
|
+
});
|
|
78
|
+
else seenLabels.add(facet.label);
|
|
79
|
+
}
|
|
80
|
+
if (facet.colorKey) {
|
|
81
|
+
if (seenColors.has(facet.colorKey)) issues.push({
|
|
82
|
+
severity: "info",
|
|
83
|
+
message: `Duplicate facet color "${facet.colorKey}" in ${label}.`
|
|
84
|
+
});
|
|
85
|
+
else seenColors.add(facet.colorKey);
|
|
86
|
+
}
|
|
87
|
+
if (facet.description) {
|
|
88
|
+
if (seenDescriptions.has(facet.description)) issues.push({
|
|
89
|
+
severity: "info",
|
|
90
|
+
message: `Duplicate facet description "${facet.description}" in ${label}.`
|
|
91
|
+
});
|
|
92
|
+
else seenDescriptions.add(facet.description);
|
|
93
|
+
}
|
|
94
|
+
if (!facet.partDefinitions.length) issues.push({
|
|
95
|
+
severity: "error",
|
|
96
|
+
message: `${label} has no part definitions.`
|
|
97
|
+
});
|
|
98
|
+
const seenPartKeys = /* @__PURE__ */ new Set();
|
|
99
|
+
const seenPartColors = /* @__PURE__ */ new Set();
|
|
100
|
+
const seenPartDescriptions = /* @__PURE__ */ new Set();
|
|
101
|
+
for (const part of facet.partDefinitions) {
|
|
102
|
+
const key = `${part.typeId}|${part.roleId ?? ""}`;
|
|
103
|
+
if (seenPartKeys.has(key)) issues.push({
|
|
104
|
+
severity: "error",
|
|
105
|
+
message: `Duplicate part (typeId "${part.typeId}", roleId "${part.roleId ?? "(none)"}") in ${label}.`
|
|
106
|
+
});
|
|
107
|
+
else seenPartKeys.add(key);
|
|
108
|
+
if (part.colorKey) {
|
|
109
|
+
if (seenPartColors.has(part.colorKey)) issues.push({
|
|
110
|
+
severity: "info",
|
|
111
|
+
message: `Duplicate part color "${part.colorKey}" in ${label}.`
|
|
112
|
+
});
|
|
113
|
+
else seenPartColors.add(part.colorKey);
|
|
114
|
+
}
|
|
115
|
+
if (part.description) {
|
|
116
|
+
if (seenPartDescriptions.has(part.description)) issues.push({
|
|
117
|
+
severity: "info",
|
|
118
|
+
message: `Duplicate part description "${part.description}" for type "${part.typeId}" in ${label}.`
|
|
119
|
+
});
|
|
120
|
+
else seenPartDescriptions.add(part.description);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (!facetModelSettings) return of(this.buildResult(issues));
|
|
125
|
+
return this._thesaurusService.getThesaurusIds().pipe(map((ids) => {
|
|
126
|
+
const existingIds = new Set(ids.map((id) => id.replace(/\@[a-z]+$/g, "")));
|
|
127
|
+
this.checkThesauri(issues, existingIds, facetModelSettings.parts, "Part");
|
|
128
|
+
if (facetModelSettings.fragments) this.checkThesauri(issues, existingIds, facetModelSettings.fragments, "Fragment");
|
|
129
|
+
return this.buildResult(issues);
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
133
|
+
minVersion: "12.0.0",
|
|
134
|
+
version: "22.2.0",
|
|
135
|
+
ngImport: i0,
|
|
136
|
+
type: FacetDefinitionValidatorService,
|
|
137
|
+
deps: [{ token: i1$1.ThesaurusService }],
|
|
138
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
139
|
+
});
|
|
140
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
141
|
+
minVersion: "12.0.0",
|
|
142
|
+
version: "22.2.0",
|
|
143
|
+
ngImport: i0,
|
|
144
|
+
type: FacetDefinitionValidatorService,
|
|
145
|
+
providedIn: "root"
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
149
|
+
minVersion: "12.0.0",
|
|
150
|
+
version: "22.2.0",
|
|
151
|
+
ngImport: i0,
|
|
152
|
+
type: FacetDefinitionValidatorService,
|
|
153
|
+
decorators: [{
|
|
154
|
+
type: Injectable,
|
|
155
|
+
args: [{ providedIn: "root" }]
|
|
156
|
+
}],
|
|
157
|
+
ctorParameters: () => [{ type: i1$1.ThesaurusService }]
|
|
158
|
+
});
|
|
159
|
+
function toDraft$1(data) {
|
|
160
|
+
return {
|
|
161
|
+
typeId: data?.typeId || "",
|
|
162
|
+
roleId: data?.roleId || "",
|
|
163
|
+
name: data?.name || "",
|
|
164
|
+
required: data?.isRequired || false,
|
|
165
|
+
description: data?.description || "",
|
|
166
|
+
colorKey: data?.colorKey || "",
|
|
167
|
+
groupKey: data?.groupKey || "",
|
|
168
|
+
sortKey: data?.sortKey || ""
|
|
169
|
+
};
|
|
220
170
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
* name; color; group; sort key; description; and whether the part is required or not
|
|
233
|
-
* in its facet.
|
|
234
|
-
* NOTE: part definition settings are not edited here. They are defined server-side
|
|
235
|
-
* and will later be obsoleted.
|
|
236
|
-
*/
|
|
237
|
-
class PartDefinitionEditorComponent {
|
|
238
|
-
/**
|
|
239
|
-
* The part to edit.
|
|
240
|
-
*/
|
|
241
|
-
definition = model(/* @ts-ignore */
|
|
242
|
-
...(ngDevMode ? [undefined, { debugName: "definition" }] : /* istanbul ignore next */ []));
|
|
243
|
-
/**
|
|
244
|
-
* The facet models settings, used to get the list of available part type IDs,
|
|
245
|
-
* and whether they are base text parts; in this case, the same settings also
|
|
246
|
-
* provide the list of their available role IDs from the fragments property.
|
|
247
|
-
*/
|
|
248
|
-
facetModelSettings = input(undefined, /* @ts-ignore */
|
|
249
|
-
...(ngDevMode ? [{ debugName: "facetModelSettings" }] : /* istanbul ignore next */ []));
|
|
250
|
-
/**
|
|
251
|
-
* The list of available part type IDs, taken from the facet model settings.
|
|
252
|
-
* If the facet model settings are not provided, or do not contain any part
|
|
253
|
-
* definition, this list is empty and the type ID must be entered freely.
|
|
254
|
-
*/
|
|
255
|
-
availablePartTypeIds = computed(() => {
|
|
256
|
-
const settings = this.facetModelSettings();
|
|
257
|
-
return settings?.parts ? Object.keys(settings.parts) : [];
|
|
258
|
-
}, /* @ts-ignore */
|
|
259
|
-
...(ngDevMode ? [{ debugName: "availablePartTypeIds" }] : /* istanbul ignore next */ []));
|
|
260
|
-
/**
|
|
261
|
-
* The list of available fragment IDs, taken from the facet model settings.
|
|
262
|
-
* This is used to populate the role ID select when the part type is a base
|
|
263
|
-
* text part (i.e. its baseText property in settings is true).
|
|
264
|
-
*/
|
|
265
|
-
availableFragmentIds = computed(() => {
|
|
266
|
-
const settings = this.facetModelSettings();
|
|
267
|
-
return settings?.fragments ? Object.keys(settings.fragments) : [];
|
|
268
|
-
}, /* @ts-ignore */
|
|
269
|
-
...(ngDevMode ? [{ debugName: "availableFragmentIds" }] : /* istanbul ignore next */ []));
|
|
270
|
-
/**
|
|
271
|
-
* True if the part type is a base text part, i.e. if the facet model settings
|
|
272
|
-
* for the current part type ID has the baseText property set to true. In this
|
|
273
|
-
* case, the role ID select is shown with the list of available fragment IDs
|
|
274
|
-
* from the facet model settings; otherwise, a free text input is shown for
|
|
275
|
-
* the role ID.
|
|
276
|
-
* Initialized in the constructor so it can reactively track typeId changes
|
|
277
|
-
* via a toSignal-wrapped valueChanges observable.
|
|
278
|
-
*/
|
|
279
|
-
isBaseTextPart;
|
|
280
|
-
/** Signal that mirrors typeId.valueChanges so computed() can track it. */
|
|
281
|
-
_typeIdValue;
|
|
282
|
-
/**
|
|
283
|
-
* True to hide the sort key field. This is used when the sort key is
|
|
284
|
-
* defined at the level of the part definitions list, and not at the level
|
|
285
|
-
* of each part definition.
|
|
286
|
-
*/
|
|
287
|
-
hideSortKey = input(false, /* @ts-ignore */
|
|
288
|
-
...(ngDevMode ? [{ debugName: "hideSortKey" }] : /* istanbul ignore next */ []));
|
|
289
|
-
/**
|
|
290
|
-
* Emitted when user requests to cancel the edit and close this editor.
|
|
291
|
-
*/
|
|
292
|
-
cancelEdit = output();
|
|
293
|
-
typeId;
|
|
294
|
-
roleId;
|
|
295
|
-
name;
|
|
296
|
-
required;
|
|
297
|
-
description;
|
|
298
|
-
colorKey;
|
|
299
|
-
groupKey;
|
|
300
|
-
sortKey;
|
|
301
|
-
form;
|
|
302
|
-
constructor(formBuilder) {
|
|
303
|
-
// form
|
|
304
|
-
this.typeId = formBuilder.control('', {
|
|
305
|
-
validators: [Validators.required, Validators.maxLength(100)],
|
|
306
|
-
nonNullable: true,
|
|
307
|
-
});
|
|
308
|
-
// mirror typeId value as a signal so computed() tracks it reactively
|
|
309
|
-
this._typeIdValue = toSignal(this.typeId.valueChanges, {
|
|
310
|
-
initialValue: this.typeId.value,
|
|
311
|
-
});
|
|
312
|
-
this.isBaseTextPart = computed(() => {
|
|
313
|
-
const settings = this.facetModelSettings();
|
|
314
|
-
return settings?.parts?.[this._typeIdValue()]?.baseText === true;
|
|
315
|
-
}, /* @ts-ignore */
|
|
316
|
-
...(ngDevMode ? [{ debugName: "isBaseTextPart" }] : /* istanbul ignore next */ []));
|
|
317
|
-
this.roleId = formBuilder.control(null);
|
|
318
|
-
this.name = formBuilder.control('', {
|
|
319
|
-
validators: [Validators.required, Validators.maxLength(100)],
|
|
320
|
-
nonNullable: true,
|
|
321
|
-
});
|
|
322
|
-
this.required = formBuilder.control(false, {
|
|
323
|
-
nonNullable: true,
|
|
324
|
-
});
|
|
325
|
-
this.description = formBuilder.control(null, {
|
|
326
|
-
validators: Validators.maxLength(1000),
|
|
327
|
-
});
|
|
328
|
-
// color key has form RRGGBB, where RR, GG and BB are hex values
|
|
329
|
-
// for red, green and blue
|
|
330
|
-
this.colorKey = formBuilder.control(null, {
|
|
331
|
-
validators: Validators.pattern('^[0-9a-fA-F]{6}$'),
|
|
332
|
-
});
|
|
333
|
-
this.groupKey = formBuilder.control(null);
|
|
334
|
-
this.sortKey = formBuilder.control(null);
|
|
335
|
-
this.form = formBuilder.group({
|
|
336
|
-
typeId: this.typeId,
|
|
337
|
-
roleId: this.roleId,
|
|
338
|
-
name: this.name,
|
|
339
|
-
required: this.required,
|
|
340
|
-
description: this.description,
|
|
341
|
-
colorKey: this.colorKey,
|
|
342
|
-
groupKey: this.groupKey,
|
|
343
|
-
sortKey: this.sortKey,
|
|
344
|
-
});
|
|
345
|
-
// when model changes, update form
|
|
346
|
-
effect(() => {
|
|
347
|
-
const data = this.definition();
|
|
348
|
-
this.updateForm(data);
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
updateForm(data) {
|
|
352
|
-
if (!data) {
|
|
353
|
-
this.form.reset();
|
|
354
|
-
}
|
|
355
|
-
else {
|
|
356
|
-
this.typeId.setValue(data.typeId);
|
|
357
|
-
this.roleId.setValue(data.roleId || null);
|
|
358
|
-
this.name.setValue(data.name || '');
|
|
359
|
-
this.required.setValue(data.isRequired || false);
|
|
360
|
-
this.description.setValue(data.description || null);
|
|
361
|
-
this.colorKey.setValue(data.colorKey || null);
|
|
362
|
-
this.groupKey.setValue(data.groupKey || null);
|
|
363
|
-
this.sortKey.setValue(data.sortKey || null);
|
|
364
|
-
this.form.markAsPristine();
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
getData() {
|
|
368
|
-
return {
|
|
369
|
-
typeId: this.typeId.value.trim(),
|
|
370
|
-
roleId: this.roleId.value?.trim() || undefined,
|
|
371
|
-
name: this.name.value.trim(),
|
|
372
|
-
isRequired: this.required.value,
|
|
373
|
-
description: this.description.value?.trim() || undefined,
|
|
374
|
-
colorKey: this.colorKey.value?.trim() || undefined,
|
|
375
|
-
groupKey: this.groupKey.value?.trim() || undefined,
|
|
376
|
-
sortKey: this.sortKey.value?.trim() || undefined,
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
onColorPick(value) {
|
|
380
|
-
// native color input returns "#rrggbb" — strip the leading "#"
|
|
381
|
-
this.colorKey.setValue(value.slice(1));
|
|
382
|
-
this.colorKey.markAsDirty();
|
|
383
|
-
}
|
|
384
|
-
cancel() {
|
|
385
|
-
this.cancelEdit.emit();
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* Saves the current form data by updating the `data` model signal.
|
|
389
|
-
* This method can be called manually (e.g., by a Save button) or
|
|
390
|
-
* automatically (via auto-save).
|
|
391
|
-
* @param pristine If true (default), the form is marked as pristine
|
|
392
|
-
* after saving.
|
|
393
|
-
* Set to false for auto-save if you want the form to remain dirty.
|
|
394
|
-
*/
|
|
395
|
-
save(pristine = true) {
|
|
396
|
-
if (this.form.invalid) {
|
|
397
|
-
// show validation errors
|
|
398
|
-
this.form.markAllAsTouched();
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
const data = this.getData();
|
|
402
|
-
this.definition.set(data);
|
|
403
|
-
if (pristine) {
|
|
404
|
-
this.form.markAsPristine();
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: PartDefinitionEditorComponent, deps: [{ token: i1$1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component });
|
|
408
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: PartDefinitionEditorComponent, isStandalone: true, selector: "cadmus-part-definition-editor", inputs: { definition: { classPropertyName: "definition", publicName: "definition", isSignal: true, isRequired: false, transformFunction: null }, facetModelSettings: { classPropertyName: "facetModelSettings", publicName: "facetModelSettings", isSignal: true, isRequired: false, transformFunction: null }, hideSortKey: { classPropertyName: "hideSortKey", publicName: "hideSortKey", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { definition: "definitionChange", cancelEdit: "cancelEdit" }, ngImport: i0, template: "<form [formGroup]=\"form\" (submit)=\"save()\">\n <div class=\"form-row\">\n <!-- typeId (bound) -->\n @if (availablePartTypeIds().length) {\n <mat-form-field>\n <mat-label>type</mat-label>\n <mat-select [formControl]=\"typeId\">\n @for (id of availablePartTypeIds(); track id) {\n <mat-option [value]=\"id\">{{ id }}</mat-option>\n }\n </mat-select>\n @if (\n $any(typeId).errors?.required && (typeId.dirty || typeId.touched)\n ) {\n <mat-error>type ID required</mat-error>\n }\n </mat-form-field>\n } @else {\n <!-- typeId (free) -->\n <mat-form-field>\n <mat-label>type ID</mat-label>\n <input matInput [formControl]=\"typeId\" />\n @if (\n $any(typeId).errors?.required && (typeId.dirty || typeId.touched)\n ) {\n <mat-error>type ID required</mat-error>\n }\n @if (\n $any(typeId).errors?.maxlength && (typeId.dirty || typeId.touched)\n ) {\n <mat-error>type ID too long</mat-error>\n }\n </mat-form-field>\n }\n\n <!-- roleId is to be selected from a list if the part is a base text part -->\n @if (isBaseTextPart()) {\n <mat-form-field>\n <mat-label>role ID</mat-label>\n <mat-select [formControl]=\"roleId\">\n @for (e of availableFragmentIds(); track e) {\n <mat-option [value]=\"e\">{{ e }}</mat-option>\n }\n </mat-select>\n @if (\n $any(roleId).errors?.required && (roleId.dirty || roleId.touched)\n ) {\n <mat-error>role ID required</mat-error>\n }\n </mat-form-field>\n } @else {\n <!-- else roleId is free -->\n <mat-form-field>\n <mat-label>role ID</mat-label>\n <input matInput [formControl]=\"roleId\" />\n @if (\n $any(roleId).errors?.required && (roleId.dirty || roleId.touched)\n ) {\n <mat-error>role ID required</mat-error>\n }\n @if (\n $any(roleId).errors?.maxlength && (roleId.dirty || roleId.touched)\n ) {\n <mat-error>role ID too long</mat-error>\n }\n </mat-form-field>\n }\n\n <!-- required -->\n <mat-checkbox [formControl]=\"required\">required</mat-checkbox>\n </div>\n\n <div class=\"form-row\">\n <!-- name -->\n <mat-form-field>\n <mat-label>name</mat-label>\n <input matInput [formControl]=\"name\" />\n @if ($any(name).errors?.required && (name.dirty || name.touched)) {\n <mat-error>name required</mat-error>\n }\n @if ($any(name).errors?.maxlength && (name.dirty || name.touched)) {\n <mat-error>name too long</mat-error>\n }\n </mat-form-field>\n\n <!-- color -->\n <mat-form-field class=\"color-input\">\n <mat-label>color</mat-label>\n <input matInput [formControl]=\"colorKey\" />\n @if (\n $any(colorKey).errors?.pattern && (colorKey.dirty || colorKey.touched)\n ) {\n <mat-error>invalid color key</mat-error>\n }\n <input\n type=\"color\"\n class=\"color-picker-input\"\n #colorPicker\n [value]=\"\n colorKey.value?.length === 6 ? '#' + colorKey.value : '#000000'\n \"\n (input)=\"onColorPick(colorPicker.value)\"\n />\n <button\n type=\"button\"\n mat-icon-button\n matSuffix\n matTooltip=\"Pick color\"\n (click)=\"colorPicker.click()\"\n >\n <mat-icon>palette</mat-icon>\n </button>\n </mat-form-field>\n <div class=\"color-sample\" [style.--swatch-color]=\"'#' + colorKey.value\"></div>\n\n <!-- group -->\n <mat-form-field>\n <mat-label>group</mat-label>\n <input matInput [formControl]=\"groupKey\" />\n @if (\n $any(groupKey).errors?.maxlength && (groupKey.dirty || groupKey.touched)\n ) {\n <mat-error>group key too long</mat-error>\n }\n </mat-form-field>\n\n <!-- sortKey -->\n @if (!hideSortKey()) {\n <mat-form-field>\n <mat-label>sort key</mat-label>\n <input matInput [formControl]=\"sortKey\" />\n @if (\n $any(sortKey).errors?.maxlength && (sortKey.dirty || sortKey.touched)\n ) {\n <mat-error>sort key too long</mat-error>\n }\n </mat-form-field>\n }\n </div>\n\n <!-- description -->\n <div>\n <mat-form-field class=\"long-text\">\n <mat-label>description</mat-label>\n <textarea matInput [formControl]=\"description\" rows=\"2\"></textarea>\n @if (\n $any(description).errors?.maxlength &&\n (description.dirty || description.touched)\n ) {\n <mat-error>description too long</mat-error>\n }\n </mat-form-field>\n </div>\n\n <!-- buttons -->\n <div>\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Discard changes\"\n (click)=\"cancel()\"\n >\n <mat-icon class=\"mat-warn\">clear</mat-icon>\n </button>\n <button\n type=\"submit\"\n mat-icon-button\n matTooltip=\"Accept changes\"\n [disabled]=\"form.invalid || form.pristine\"\n >\n <mat-icon class=\"mat-primary\">check_circle</mat-icon>\n </button>\n </div>\n</form>\n", styles: ["input[type=color].color-picker-input{display:none}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.long-text{width:100%;max-width:800px}.color-input{width:9em}.color-sample{width:32px;height:32px;border-radius:50%;background:var(--swatch-color);margin-top:-16px}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],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: MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "aria-expanded", "aria-controls", "aria-owns", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "directive", type: MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "directive", type: MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "directive", type: MatLabel, selector: "mat-label" }, { kind: "component", type: MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "component", type: MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "directive", type: MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
171
|
+
function toData$1(v) {
|
|
172
|
+
return {
|
|
173
|
+
typeId: v.typeId.trim(),
|
|
174
|
+
roleId: v.roleId.trim() || void 0,
|
|
175
|
+
name: v.name.trim(),
|
|
176
|
+
isRequired: v.required,
|
|
177
|
+
description: v.description.trim() || void 0,
|
|
178
|
+
colorKey: v.colorKey.trim() || void 0,
|
|
179
|
+
groupKey: v.groupKey.trim() || void 0,
|
|
180
|
+
sortKey: v.sortKey.trim() || void 0
|
|
181
|
+
};
|
|
409
182
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: FacetDefinitionEditorComponent, isStandalone: true, selector: "cadmus-facet-definition-editor", inputs: { definition: { classPropertyName: "definition", publicName: "definition", isSignal: true, isRequired: false, transformFunction: null }, facetModelSettings: { classPropertyName: "facetModelSettings", publicName: "facetModelSettings", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { definition: "definitionChange", cancelEdit: "cancelEdit" }, ngImport: i0, template: "<form [formGroup]=\"form\" (submit)=\"save()\">\n <mat-tab-group>\n <!-- GENERAL -->\n <mat-tab label=\"general\">\n <div class=\"form-row\">\n <!-- id -->\n <mat-form-field>\n <mat-label>ID</mat-label>\n <input matInput [formControl]=\"id\" />\n @if ($any(id).errors?.required && (id.dirty || id.touched)) {\n <mat-error>ID required</mat-error>\n }\n @if ($any(id).errors?.maxlength && (id.dirty || id.touched)) {\n <mat-error>ID too long</mat-error>\n }\n </mat-form-field>\n\n <!-- label -->\n <mat-form-field>\n <mat-label>label</mat-label>\n <input matInput [formControl]=\"label\" />\n @if ($any(label).errors?.required && (label.dirty || label.touched)) {\n <mat-error>label required</mat-error>\n }\n @if (\n $any(label).errors?.maxlength && (label.dirty || label.touched)\n ) {\n <mat-error>label too long</mat-error>\n }\n </mat-form-field>\n\n <!-- color -->\n <mat-form-field class=\"color-input\">\n <mat-label>color</mat-label>\n <input matInput [formControl]=\"colorKey\" />\n @if (\n $any(colorKey).errors?.pattern &&\n (colorKey.dirty || colorKey.touched)\n ) {\n <mat-error>invalid color key</mat-error>\n }\n <input\n type=\"color\"\n class=\"color-picker-input\"\n #colorPicker\n [value]=\"\n colorKey.value.length === 6 ? '#' + colorKey.value : '#000000'\n \"\n (input)=\"onColorPick(colorPicker.value)\"\n />\n <button\n type=\"button\"\n mat-icon-button\n matSuffix\n matTooltip=\"Pick color\"\n (click)=\"colorPicker.click()\"\n >\n <mat-icon>palette</mat-icon>\n </button>\n </mat-form-field>\n <div class=\"color-sample\" [style.--swatch-color]=\"'#' + colorKey.value\"></div>\n </div>\n\n <!-- description -->\n <div>\n <mat-form-field class=\"long-text\">\n <mat-label>description</mat-label>\n <textarea matInput [formControl]=\"description\" rows=\"2\"></textarea>\n @if (\n $any(description).errors?.maxlength &&\n (description.dirty || description.touched)\n ) {\n <mat-error>description too long</mat-error>\n }\n </mat-form-field>\n </div>\n </mat-tab>\n\n <!-- PARTS -->\n <mat-tab label=\"parts\">\n <div>\n <button\n type=\"button\"\n mat-flat-button\n color=\"primary\"\n (click)=\"addPartDefinition()\"\n >\n <mat-icon>add_circle</mat-icon> part\n </button>\n </div>\n @if (partDefinitions.value.length) {\n <table>\n <thead>\n <tr>\n <th></th>\n <th>required</th>\n <th>type ID</th>\n <th>role ID</th>\n <th>name</th>\n <th>group</th>\n <th>color</th>\n <th>description</th>\n </tr>\n </thead>\n <tbody>\n @for (\n entry of partDefinitions.value;\n track entry;\n let i = $index;\n let first = $first;\n let last = $last\n ) {\n <tr [class.selected]=\"i === editedIndex()\">\n <td class=\"fit-width\">\n <button\n type=\"button\"\n mat-icon-button\n color=\"primary\"\n matTooltip=\"Edit this part definition\"\n (click)=\"editPartDefinition(entry, i)\"\n >\n <mat-icon class=\"mat-primary\">edit</mat-icon>\n </button>\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Move this part definition up\"\n [disabled]=\"first\"\n (click)=\"movePartDefinitionUp(i)\"\n >\n <mat-icon>arrow_upward</mat-icon>\n </button>\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Move this part definition down\"\n [disabled]=\"last\"\n (click)=\"movePartDefinitionDown(i)\"\n >\n <mat-icon>arrow_downward</mat-icon>\n </button>\n <button\n type=\"button\"\n mat-icon-button\n color=\"warn\"\n matTooltip=\"Delete this part definition\"\n (click)=\"deletePartDefinition(i)\"\n >\n <mat-icon class=\"mat-warn\">remove_circle</mat-icon>\n </button>\n </td>\n <td class=\"fit-width\">\n <mat-checkbox\n [checked]=\"entry.isRequired\"\n disabled\n ></mat-checkbox>\n </td>\n <td>{{ entry.typeId }}</td>\n <td>{{ entry.roleId }}</td>\n <td>{{ entry.name }}</td>\n <td>{{ entry.groupKey }}</td>\n <td>\n <span\n class=\"color-swatch\"\n [style.background-color]=\"'#' + entry.colorKey\"\n [style.color]=\"('#' + entry.colorKey) | colorToContrast\"\n >\n {{ entry.colorKey }}\n </span>\n </td>\n <td>{{ entry.description | ellipsis: 50 }}</td>\n </tr>\n }\n </tbody>\n </table>\n }\n @if (edited()) {\n <fieldset>\n <mat-expansion-panel [expanded]=\"edited()\" [disabled]=\"!edited()\">\n <mat-expansion-panel-header>\n <mat-panel-title>Part #{{ editedIndex() + 1 }}</mat-panel-title>\n </mat-expansion-panel-header>\n <cadmus-part-definition-editor\n [facetModelSettings]=\"facetModelSettings()\"\n [hideSortKey]=\"true\"\n [definition]=\"edited()\"\n (definitionChange)=\"savePartDefinition($event!)\"\n (cancelEdit)=\"closePartDefinition()\"\n />\n </mat-expansion-panel>\n </fieldset>\n }\n </mat-tab>\n </mat-tab-group>\n\n <!-- buttons -->\n <div>\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Discard changes\"\n (click)=\"cancel()\"\n >\n <mat-icon class=\"mat-warn\">clear</mat-icon>\n </button>\n <button\n type=\"submit\"\n mat-icon-button\n matTooltip=\"Accept changes\"\n [disabled]=\"form.invalid || form.pristine\"\n >\n <mat-icon class=\"mat-primary\">check_circle</mat-icon>\n </button>\n </div>\n</form>\n", styles: ["input[type=color].color-picker-input{display:none}.long-text{width:100%;max-width:800px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}table{width:100%;border-collapse:collapse;color:var(--mat-sys-on-surface-variant)}tbody tr:nth-child(odd){background-color:var(--mat-sys-surface-container)}th{text-align:left;font-weight:400;color:var(--mat-sys-on-surface-variant)}tbody tr:hover{background-color:var(--mat-sys-surface-container-high)}td.fit-width{width:1px;white-space:nowrap}tbody tr.selected{background-color:var(--mat-sys-secondary-container);color:var(--mat-sys-on-secondary-container)}.color-swatch{padding:2px 6px;border-radius:4px}.color-input{width:9em}.color-sample{width:32px;height:32px;border-radius:50%;background:var(--swatch-color);margin-top:-16px}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],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: "ngmodule", type: MatButtonModule }, { kind: "component", type: i3.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: i3.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "aria-expanded", "aria-controls", "aria-owns", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "directive", type: MatError$1, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "component", type: MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["hideToggle", "togglePosition"], outputs: ["afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { kind: "component", type: MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["expandedHeight", "collapsedHeight", "tabIndex"] }, { kind: "directive", type: MatExpansionPanelTitle, selector: "mat-panel-title" }, { kind: "component", type: MatFormField$1, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "directive", type: MatLabel$1, selector: "mat-label" }, { kind: "directive", type: MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "component", type: MatTab, selector: "mat-tab", inputs: ["disabled", "label", "aria-label", "aria-labelledby", "labelClass", "bodyClass", "id"], exportAs: ["matTab"] }, { kind: "component", type: MatTabGroup, selector: "mat-tab-group", inputs: ["color", "fitInkBarToContent", "mat-stretch-tabs", "mat-align-tabs", "dynamicHeight", "selectedIndex", "headerPosition", "animationDuration", "contentTabIndex", "disablePagination", "disableRipple", "preserveContent", "backgroundColor", "aria-label", "aria-labelledby"], outputs: ["selectedIndexChange", "focusChange", "animationDone", "selectedTabChange"], exportAs: ["matTabGroup"] }, { kind: "directive", type: MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "component", type: PartDefinitionEditorComponent, selector: "cadmus-part-definition-editor", inputs: ["definition", "facetModelSettings", "hideSortKey"], outputs: ["definitionChange", "cancelEdit"] }, { kind: "pipe", type: ColorToContrastPipe, name: "colorToContrast" }, { kind: "pipe", type: EllipsisPipe, name: "ellipsis" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
183
|
+
var PartDefinitionEditorComponent = class PartDefinitionEditorComponent {
|
|
184
|
+
definition = model(...ngDevMode ? [void 0, { debugName: "definition" }] : /* istanbul ignore next */ []);
|
|
185
|
+
facetModelSettings = input(void 0, ...ngDevMode ? [{ debugName: "facetModelSettings" }] : /* istanbul ignore next */ []);
|
|
186
|
+
availablePartTypeIds = computed(() => {
|
|
187
|
+
const settings = this.facetModelSettings();
|
|
188
|
+
return settings?.parts ? Object.keys(settings.parts) : [];
|
|
189
|
+
}, ...ngDevMode ? [{ debugName: "availablePartTypeIds" }] : /* istanbul ignore next */ []);
|
|
190
|
+
availableFragmentIds = computed(() => {
|
|
191
|
+
const settings = this.facetModelSettings();
|
|
192
|
+
return settings?.fragments ? Object.keys(settings.fragments) : [];
|
|
193
|
+
}, ...ngDevMode ? [{ debugName: "availableFragmentIds" }] : /* istanbul ignore next */ []);
|
|
194
|
+
hideSortKey = input(false, ...ngDevMode ? [{ debugName: "hideSortKey" }] : /* istanbul ignore next */ []);
|
|
195
|
+
cancelEdit = output();
|
|
196
|
+
_draft = linkedSignal({
|
|
197
|
+
...ngDevMode ? { debugName: "_draft" } : /* istanbul ignore next */ {},
|
|
198
|
+
source: () => this.definition(),
|
|
199
|
+
computation: (data, previous) => previous && JSON.stringify(data) === JSON.stringify(toData$1(previous.value)) ? previous.value : toDraft$1(data)
|
|
200
|
+
});
|
|
201
|
+
form = form(this._draft, (path) => {
|
|
202
|
+
required(path.typeId);
|
|
203
|
+
maxLength(path.typeId, 100);
|
|
204
|
+
required(path.name);
|
|
205
|
+
maxLength(path.name, 100);
|
|
206
|
+
maxLength(path.description, 1e3);
|
|
207
|
+
pattern(path.colorKey, /^[0-9a-fA-F]{6}$/);
|
|
208
|
+
});
|
|
209
|
+
isBaseTextPart = computed(() => {
|
|
210
|
+
return this.facetModelSettings()?.parts?.[this.form.typeId().value()]?.baseText === true;
|
|
211
|
+
}, ...ngDevMode ? [{ debugName: "isBaseTextPart" }] : /* istanbul ignore next */ []);
|
|
212
|
+
constructor() {
|
|
213
|
+
effect(() => {
|
|
214
|
+
const draft = this._draft();
|
|
215
|
+
untracked(() => {
|
|
216
|
+
if (JSON.stringify(draft) === JSON.stringify(toDraft$1(this.definition()))) this.form().reset();
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
onColorPick(value) {
|
|
221
|
+
this.form.colorKey().value.set(value.slice(1));
|
|
222
|
+
this.form.colorKey().markAsDirty();
|
|
223
|
+
}
|
|
224
|
+
cancel() {
|
|
225
|
+
this.cancelEdit.emit();
|
|
226
|
+
}
|
|
227
|
+
save(pristine = true) {
|
|
228
|
+
if (this.form().invalid()) {
|
|
229
|
+
this.form().markAsTouched();
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
this.definition.set(toData$1(this._draft()));
|
|
233
|
+
if (pristine) this.form().reset();
|
|
234
|
+
}
|
|
235
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
236
|
+
minVersion: "12.0.0",
|
|
237
|
+
version: "22.2.0",
|
|
238
|
+
ngImport: i0,
|
|
239
|
+
type: PartDefinitionEditorComponent,
|
|
240
|
+
deps: [],
|
|
241
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
242
|
+
});
|
|
243
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
244
|
+
minVersion: "17.0.0",
|
|
245
|
+
version: "22.2.0",
|
|
246
|
+
type: PartDefinitionEditorComponent,
|
|
247
|
+
isStandalone: true,
|
|
248
|
+
selector: "cadmus-part-definition-editor",
|
|
249
|
+
inputs: {
|
|
250
|
+
definition: {
|
|
251
|
+
classPropertyName: "definition",
|
|
252
|
+
publicName: "definition",
|
|
253
|
+
isSignal: true,
|
|
254
|
+
isRequired: false,
|
|
255
|
+
transformFunction: null
|
|
256
|
+
},
|
|
257
|
+
facetModelSettings: {
|
|
258
|
+
classPropertyName: "facetModelSettings",
|
|
259
|
+
publicName: "facetModelSettings",
|
|
260
|
+
isSignal: true,
|
|
261
|
+
isRequired: false,
|
|
262
|
+
transformFunction: null
|
|
263
|
+
},
|
|
264
|
+
hideSortKey: {
|
|
265
|
+
classPropertyName: "hideSortKey",
|
|
266
|
+
publicName: "hideSortKey",
|
|
267
|
+
isSignal: true,
|
|
268
|
+
isRequired: false,
|
|
269
|
+
transformFunction: null
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
outputs: {
|
|
273
|
+
definition: "definitionChange",
|
|
274
|
+
cancelEdit: "cancelEdit"
|
|
275
|
+
},
|
|
276
|
+
ngImport: i0,
|
|
277
|
+
template: "<div>\r\n <div class=\"form-row\">\r\n <!-- typeId (bound) -->\r\n @if (availablePartTypeIds().length) {\r\n <mat-form-field>\r\n <mat-label>type</mat-label>\r\n <mat-select [formField]=\"form.typeId\">\r\n @for (id of availablePartTypeIds(); track id) {\r\n <mat-option [value]=\"id\">{{ id }}</mat-option>\r\n }\r\n </mat-select>\r\n @if (\r\n form.typeId().getError('required') && (form.typeId().dirty() || form.typeId().touched())\r\n ) {\r\n <mat-error>type ID required</mat-error>\r\n }\r\n </mat-form-field>\r\n } @else {\r\n <!-- typeId (free) -->\r\n <mat-form-field>\r\n <mat-label>type ID</mat-label>\r\n <input matInput [formField]=\"form.typeId\" />\r\n @if (\r\n form.typeId().getError('required') && (form.typeId().dirty() || form.typeId().touched())\r\n ) {\r\n <mat-error>type ID required</mat-error>\r\n }\r\n @if (\r\n form.typeId().getError('maxLength') && (form.typeId().dirty() || form.typeId().touched())\r\n ) {\r\n <mat-error>type ID too long</mat-error>\r\n }\r\n </mat-form-field>\r\n }\r\n\r\n <!-- roleId is to be selected from a list if the part is a base text part -->\r\n @if (isBaseTextPart()) {\r\n <mat-form-field>\r\n <mat-label>role ID</mat-label>\r\n <mat-select [formField]=\"form.roleId\">\r\n @for (e of availableFragmentIds(); track e) {\r\n <mat-option [value]=\"e\">{{ e }}</mat-option>\r\n }\r\n </mat-select>\r\n @if (\r\n form.roleId().getError('required') && (form.roleId().dirty() || form.roleId().touched())\r\n ) {\r\n <mat-error>role ID required</mat-error>\r\n }\r\n </mat-form-field>\r\n } @else {\r\n <!-- else roleId is free -->\r\n <mat-form-field>\r\n <mat-label>role ID</mat-label>\r\n <input matInput [formField]=\"form.roleId\" />\r\n @if (\r\n form.roleId().getError('required') && (form.roleId().dirty() || form.roleId().touched())\r\n ) {\r\n <mat-error>role ID required</mat-error>\r\n }\r\n @if (\r\n form.roleId().getError('maxLength') && (form.roleId().dirty() || form.roleId().touched())\r\n ) {\r\n <mat-error>role ID too long</mat-error>\r\n }\r\n </mat-form-field>\r\n }\r\n\r\n <!-- required -->\r\n <mat-checkbox [formField]=\"form.required\">required</mat-checkbox>\r\n </div>\r\n\r\n <div class=\"form-row\">\r\n <!-- name -->\r\n <mat-form-field>\r\n <mat-label>name</mat-label>\r\n <input matInput [formField]=\"form.name\" />\r\n @if (form.name().getError('required') && (form.name().dirty() || form.name().touched())) {\r\n <mat-error>name required</mat-error>\r\n }\r\n @if (form.name().getError('maxLength') && (form.name().dirty() || form.name().touched())) {\r\n <mat-error>name too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n <!-- color -->\r\n <mat-form-field class=\"color-input\">\r\n <mat-label>color</mat-label>\r\n <input matInput [formField]=\"form.colorKey\" />\r\n @if (\r\n form.colorKey().getError('pattern') && (form.colorKey().dirty() || form.colorKey().touched())\r\n ) {\r\n <mat-error>invalid color key</mat-error>\r\n }\r\n <input\r\n type=\"color\"\r\n class=\"color-picker-input\"\r\n #colorPicker\r\n [value]=\"\r\n form.colorKey().value().length === 6\r\n ? '#' + form.colorKey().value()\r\n : '#000000'\r\n \"\r\n (input)=\"onColorPick(colorPicker.value)\"\r\n />\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matSuffix\r\n matTooltip=\"Pick color\"\r\n (click)=\"colorPicker.click()\"\r\n >\r\n <mat-icon>palette</mat-icon>\r\n </button>\r\n </mat-form-field>\r\n <div class=\"color-sample\" [style.--swatch-color]=\"'#' + form.colorKey().value()\"></div>\r\n\r\n <!-- group -->\r\n <mat-form-field>\r\n <mat-label>group</mat-label>\r\n <input matInput [formField]=\"form.groupKey\" />\r\n @if (\r\n form.groupKey().getError('maxLength') && (form.groupKey().dirty() || form.groupKey().touched())\r\n ) {\r\n <mat-error>group key too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n <!-- sortKey -->\r\n @if (!hideSortKey()) {\r\n <mat-form-field>\r\n <mat-label>sort key</mat-label>\r\n <input matInput [formField]=\"form.sortKey\" />\r\n @if (\r\n form.sortKey().getError('maxLength') && (form.sortKey().dirty() || form.sortKey().touched())\r\n ) {\r\n <mat-error>sort key too long</mat-error>\r\n }\r\n </mat-form-field>\r\n }\r\n </div>\r\n\r\n <!-- description -->\r\n <div>\r\n <mat-form-field class=\"long-text\">\r\n <mat-label>description</mat-label>\r\n <textarea matInput [formField]=\"form.description\" rows=\"2\"></textarea>\r\n @if (\r\n form.description().getError('maxLength') &&\r\n (form.description().dirty() || form.description().touched())\r\n ) {\r\n <mat-error>description too long</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- buttons -->\r\n <div>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Discard changes\"\r\n (click)=\"cancel()\"\r\n >\r\n <mat-icon class=\"mat-warn\">clear</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Accept changes\"\r\n [disabled]=\"form().invalid() || !form().dirty()\"\r\n (click)=\"save()\"\r\n >\r\n <mat-icon class=\"mat-primary\">check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</div>\r\n",
|
|
278
|
+
styles: ["input[type=color].color-picker-input{display:none}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.long-text{width:100%;max-width:800px}.color-input{width:9em}.color-sample{width:32px;height:32px;border-radius:50%;background:var(--swatch-color);margin-top:-16px}\n"],
|
|
279
|
+
dependencies: [
|
|
280
|
+
{
|
|
281
|
+
kind: "directive",
|
|
282
|
+
type: FormField,
|
|
283
|
+
selector: "[formField]",
|
|
284
|
+
inputs: ["formField"],
|
|
285
|
+
exportAs: ["formField"]
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
kind: "component",
|
|
289
|
+
type: MatCheckbox,
|
|
290
|
+
selector: "mat-checkbox",
|
|
291
|
+
inputs: [
|
|
292
|
+
"aria-label",
|
|
293
|
+
"aria-labelledby",
|
|
294
|
+
"aria-describedby",
|
|
295
|
+
"aria-expanded",
|
|
296
|
+
"aria-controls",
|
|
297
|
+
"aria-owns",
|
|
298
|
+
"id",
|
|
299
|
+
"required",
|
|
300
|
+
"labelPosition",
|
|
301
|
+
"name",
|
|
302
|
+
"value",
|
|
303
|
+
"disableRipple",
|
|
304
|
+
"tabIndex",
|
|
305
|
+
"color",
|
|
306
|
+
"disabledInteractive",
|
|
307
|
+
"checked",
|
|
308
|
+
"disabled",
|
|
309
|
+
"indeterminate"
|
|
310
|
+
],
|
|
311
|
+
outputs: ["change", "indeterminateChange"],
|
|
312
|
+
exportAs: ["matCheckbox"]
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
kind: "directive",
|
|
316
|
+
type: MatError$1,
|
|
317
|
+
selector: "mat-error, [matError]",
|
|
318
|
+
inputs: ["id"]
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
kind: "component",
|
|
322
|
+
type: MatFormField$1,
|
|
323
|
+
selector: "mat-form-field",
|
|
324
|
+
inputs: [
|
|
325
|
+
"hideRequiredMarker",
|
|
326
|
+
"color",
|
|
327
|
+
"floatLabel",
|
|
328
|
+
"appearance",
|
|
329
|
+
"subscriptSizing",
|
|
330
|
+
"hintLabel"
|
|
331
|
+
],
|
|
332
|
+
exportAs: ["matFormField"]
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
kind: "component",
|
|
336
|
+
type: MatIcon,
|
|
337
|
+
selector: "mat-icon",
|
|
338
|
+
inputs: [
|
|
339
|
+
"color",
|
|
340
|
+
"inline",
|
|
341
|
+
"svgIcon",
|
|
342
|
+
"fontSet",
|
|
343
|
+
"fontIcon"
|
|
344
|
+
],
|
|
345
|
+
exportAs: ["matIcon"]
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
kind: "component",
|
|
349
|
+
type: MatIconButton,
|
|
350
|
+
selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
|
|
351
|
+
exportAs: ["matButton", "matAnchor"]
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
kind: "directive",
|
|
355
|
+
type: MatInput,
|
|
356
|
+
selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
|
|
357
|
+
inputs: [
|
|
358
|
+
"disabled",
|
|
359
|
+
"id",
|
|
360
|
+
"placeholder",
|
|
361
|
+
"name",
|
|
362
|
+
"required",
|
|
363
|
+
"type",
|
|
364
|
+
"errorStateMatcher",
|
|
365
|
+
"aria-describedby",
|
|
366
|
+
"value",
|
|
367
|
+
"readonly",
|
|
368
|
+
"disabledInteractive"
|
|
369
|
+
],
|
|
370
|
+
exportAs: ["matInput"]
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
kind: "directive",
|
|
374
|
+
type: MatLabel$1,
|
|
375
|
+
selector: "mat-label"
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
kind: "component",
|
|
379
|
+
type: MatOption,
|
|
380
|
+
selector: "mat-option",
|
|
381
|
+
inputs: [
|
|
382
|
+
"value",
|
|
383
|
+
"id",
|
|
384
|
+
"disabled"
|
|
385
|
+
],
|
|
386
|
+
outputs: ["onSelectionChange"],
|
|
387
|
+
exportAs: ["matOption"]
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
kind: "component",
|
|
391
|
+
type: MatSelect,
|
|
392
|
+
selector: "mat-select",
|
|
393
|
+
inputs: [
|
|
394
|
+
"aria-describedby",
|
|
395
|
+
"panelClass",
|
|
396
|
+
"disabled",
|
|
397
|
+
"disableRipple",
|
|
398
|
+
"tabIndex",
|
|
399
|
+
"hideSingleSelectionIndicator",
|
|
400
|
+
"placeholder",
|
|
401
|
+
"required",
|
|
402
|
+
"multiple",
|
|
403
|
+
"disableOptionCentering",
|
|
404
|
+
"compareWith",
|
|
405
|
+
"value",
|
|
406
|
+
"aria-label",
|
|
407
|
+
"aria-labelledby",
|
|
408
|
+
"errorStateMatcher",
|
|
409
|
+
"typeaheadDebounceInterval",
|
|
410
|
+
"sortComparator",
|
|
411
|
+
"id",
|
|
412
|
+
"panelWidth",
|
|
413
|
+
"canSelectNullableOptions"
|
|
414
|
+
],
|
|
415
|
+
outputs: [
|
|
416
|
+
"openedChange",
|
|
417
|
+
"opened",
|
|
418
|
+
"closed",
|
|
419
|
+
"selectionChange",
|
|
420
|
+
"valueChange"
|
|
421
|
+
],
|
|
422
|
+
exportAs: ["matSelect"]
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
kind: "directive",
|
|
426
|
+
type: MatSuffix,
|
|
427
|
+
selector: "[matSuffix], [matIconSuffix], [matTextSuffix]",
|
|
428
|
+
inputs: ["matTextSuffix"]
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
kind: "directive",
|
|
432
|
+
type: MatTooltip,
|
|
433
|
+
selector: "[matTooltip]",
|
|
434
|
+
inputs: [
|
|
435
|
+
"matTooltipPosition",
|
|
436
|
+
"matTooltipPositionAtOrigin",
|
|
437
|
+
"matTooltipDisabled",
|
|
438
|
+
"matTooltipShowDelay",
|
|
439
|
+
"matTooltipHideDelay",
|
|
440
|
+
"matTooltipTouchGestures",
|
|
441
|
+
"matTooltip",
|
|
442
|
+
"matTooltipClass"
|
|
443
|
+
],
|
|
444
|
+
exportAs: ["matTooltip"]
|
|
445
|
+
}
|
|
446
|
+
],
|
|
447
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
448
|
+
});
|
|
449
|
+
};
|
|
450
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
451
|
+
minVersion: "12.0.0",
|
|
452
|
+
version: "22.2.0",
|
|
453
|
+
ngImport: i0,
|
|
454
|
+
type: PartDefinitionEditorComponent,
|
|
455
|
+
decorators: [{
|
|
456
|
+
type: Component,
|
|
457
|
+
args: [{
|
|
458
|
+
selector: "cadmus-part-definition-editor",
|
|
459
|
+
imports: [
|
|
460
|
+
FormField,
|
|
461
|
+
MatCheckbox,
|
|
462
|
+
MatError$1,
|
|
463
|
+
MatFormField$1,
|
|
464
|
+
MatIcon,
|
|
465
|
+
MatIconButton,
|
|
466
|
+
MatInput,
|
|
467
|
+
MatLabel$1,
|
|
468
|
+
MatOption,
|
|
469
|
+
MatSelect,
|
|
470
|
+
MatSuffix,
|
|
471
|
+
MatTooltip
|
|
472
|
+
],
|
|
473
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
474
|
+
template: "<div>\r\n <div class=\"form-row\">\r\n <!-- typeId (bound) -->\r\n @if (availablePartTypeIds().length) {\r\n <mat-form-field>\r\n <mat-label>type</mat-label>\r\n <mat-select [formField]=\"form.typeId\">\r\n @for (id of availablePartTypeIds(); track id) {\r\n <mat-option [value]=\"id\">{{ id }}</mat-option>\r\n }\r\n </mat-select>\r\n @if (\r\n form.typeId().getError('required') && (form.typeId().dirty() || form.typeId().touched())\r\n ) {\r\n <mat-error>type ID required</mat-error>\r\n }\r\n </mat-form-field>\r\n } @else {\r\n <!-- typeId (free) -->\r\n <mat-form-field>\r\n <mat-label>type ID</mat-label>\r\n <input matInput [formField]=\"form.typeId\" />\r\n @if (\r\n form.typeId().getError('required') && (form.typeId().dirty() || form.typeId().touched())\r\n ) {\r\n <mat-error>type ID required</mat-error>\r\n }\r\n @if (\r\n form.typeId().getError('maxLength') && (form.typeId().dirty() || form.typeId().touched())\r\n ) {\r\n <mat-error>type ID too long</mat-error>\r\n }\r\n </mat-form-field>\r\n }\r\n\r\n <!-- roleId is to be selected from a list if the part is a base text part -->\r\n @if (isBaseTextPart()) {\r\n <mat-form-field>\r\n <mat-label>role ID</mat-label>\r\n <mat-select [formField]=\"form.roleId\">\r\n @for (e of availableFragmentIds(); track e) {\r\n <mat-option [value]=\"e\">{{ e }}</mat-option>\r\n }\r\n </mat-select>\r\n @if (\r\n form.roleId().getError('required') && (form.roleId().dirty() || form.roleId().touched())\r\n ) {\r\n <mat-error>role ID required</mat-error>\r\n }\r\n </mat-form-field>\r\n } @else {\r\n <!-- else roleId is free -->\r\n <mat-form-field>\r\n <mat-label>role ID</mat-label>\r\n <input matInput [formField]=\"form.roleId\" />\r\n @if (\r\n form.roleId().getError('required') && (form.roleId().dirty() || form.roleId().touched())\r\n ) {\r\n <mat-error>role ID required</mat-error>\r\n }\r\n @if (\r\n form.roleId().getError('maxLength') && (form.roleId().dirty() || form.roleId().touched())\r\n ) {\r\n <mat-error>role ID too long</mat-error>\r\n }\r\n </mat-form-field>\r\n }\r\n\r\n <!-- required -->\r\n <mat-checkbox [formField]=\"form.required\">required</mat-checkbox>\r\n </div>\r\n\r\n <div class=\"form-row\">\r\n <!-- name -->\r\n <mat-form-field>\r\n <mat-label>name</mat-label>\r\n <input matInput [formField]=\"form.name\" />\r\n @if (form.name().getError('required') && (form.name().dirty() || form.name().touched())) {\r\n <mat-error>name required</mat-error>\r\n }\r\n @if (form.name().getError('maxLength') && (form.name().dirty() || form.name().touched())) {\r\n <mat-error>name too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n <!-- color -->\r\n <mat-form-field class=\"color-input\">\r\n <mat-label>color</mat-label>\r\n <input matInput [formField]=\"form.colorKey\" />\r\n @if (\r\n form.colorKey().getError('pattern') && (form.colorKey().dirty() || form.colorKey().touched())\r\n ) {\r\n <mat-error>invalid color key</mat-error>\r\n }\r\n <input\r\n type=\"color\"\r\n class=\"color-picker-input\"\r\n #colorPicker\r\n [value]=\"\r\n form.colorKey().value().length === 6\r\n ? '#' + form.colorKey().value()\r\n : '#000000'\r\n \"\r\n (input)=\"onColorPick(colorPicker.value)\"\r\n />\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matSuffix\r\n matTooltip=\"Pick color\"\r\n (click)=\"colorPicker.click()\"\r\n >\r\n <mat-icon>palette</mat-icon>\r\n </button>\r\n </mat-form-field>\r\n <div class=\"color-sample\" [style.--swatch-color]=\"'#' + form.colorKey().value()\"></div>\r\n\r\n <!-- group -->\r\n <mat-form-field>\r\n <mat-label>group</mat-label>\r\n <input matInput [formField]=\"form.groupKey\" />\r\n @if (\r\n form.groupKey().getError('maxLength') && (form.groupKey().dirty() || form.groupKey().touched())\r\n ) {\r\n <mat-error>group key too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n <!-- sortKey -->\r\n @if (!hideSortKey()) {\r\n <mat-form-field>\r\n <mat-label>sort key</mat-label>\r\n <input matInput [formField]=\"form.sortKey\" />\r\n @if (\r\n form.sortKey().getError('maxLength') && (form.sortKey().dirty() || form.sortKey().touched())\r\n ) {\r\n <mat-error>sort key too long</mat-error>\r\n }\r\n </mat-form-field>\r\n }\r\n </div>\r\n\r\n <!-- description -->\r\n <div>\r\n <mat-form-field class=\"long-text\">\r\n <mat-label>description</mat-label>\r\n <textarea matInput [formField]=\"form.description\" rows=\"2\"></textarea>\r\n @if (\r\n form.description().getError('maxLength') &&\r\n (form.description().dirty() || form.description().touched())\r\n ) {\r\n <mat-error>description too long</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- buttons -->\r\n <div>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Discard changes\"\r\n (click)=\"cancel()\"\r\n >\r\n <mat-icon class=\"mat-warn\">clear</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Accept changes\"\r\n [disabled]=\"form().invalid() || !form().dirty()\"\r\n (click)=\"save()\"\r\n >\r\n <mat-icon class=\"mat-primary\">check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</div>\r\n",
|
|
475
|
+
styles: ["input[type=color].color-picker-input{display:none}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.long-text{width:100%;max-width:800px}.color-input{width:9em}.color-sample{width:32px;height:32px;border-radius:50%;background:var(--swatch-color);margin-top:-16px}\n"]
|
|
476
|
+
}]
|
|
477
|
+
}],
|
|
478
|
+
ctorParameters: () => [],
|
|
479
|
+
propDecorators: {
|
|
480
|
+
definition: [{
|
|
481
|
+
type: i0.Input,
|
|
482
|
+
args: [{
|
|
483
|
+
isSignal: true,
|
|
484
|
+
alias: "definition",
|
|
485
|
+
required: false
|
|
486
|
+
}]
|
|
487
|
+
}, {
|
|
488
|
+
type: i0.Output,
|
|
489
|
+
args: ["definitionChange"]
|
|
490
|
+
}],
|
|
491
|
+
facetModelSettings: [{
|
|
492
|
+
type: i0.Input,
|
|
493
|
+
args: [{
|
|
494
|
+
isSignal: true,
|
|
495
|
+
alias: "facetModelSettings",
|
|
496
|
+
required: false
|
|
497
|
+
}]
|
|
498
|
+
}],
|
|
499
|
+
hideSortKey: [{
|
|
500
|
+
type: i0.Input,
|
|
501
|
+
args: [{
|
|
502
|
+
isSignal: true,
|
|
503
|
+
alias: "hideSortKey",
|
|
504
|
+
required: false
|
|
505
|
+
}]
|
|
506
|
+
}],
|
|
507
|
+
cancelEdit: [{
|
|
508
|
+
type: i0.Output,
|
|
509
|
+
args: ["cancelEdit"]
|
|
510
|
+
}]
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
function copyPart(d) {
|
|
514
|
+
return Object.fromEntries(Object.entries(d));
|
|
666
515
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
MatExpansionPanelHeader,
|
|
676
|
-
MatExpansionPanelTitle,
|
|
677
|
-
MatFormField$1,
|
|
678
|
-
MatIcon,
|
|
679
|
-
MatInput,
|
|
680
|
-
MatLabel$1,
|
|
681
|
-
MatSuffix,
|
|
682
|
-
MatTab,
|
|
683
|
-
MatTabGroup,
|
|
684
|
-
MatTooltip,
|
|
685
|
-
ColorToContrastPipe,
|
|
686
|
-
EllipsisPipe,
|
|
687
|
-
PartDefinitionEditorComponent,
|
|
688
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<form [formGroup]=\"form\" (submit)=\"save()\">\n <mat-tab-group>\n <!-- GENERAL -->\n <mat-tab label=\"general\">\n <div class=\"form-row\">\n <!-- id -->\n <mat-form-field>\n <mat-label>ID</mat-label>\n <input matInput [formControl]=\"id\" />\n @if ($any(id).errors?.required && (id.dirty || id.touched)) {\n <mat-error>ID required</mat-error>\n }\n @if ($any(id).errors?.maxlength && (id.dirty || id.touched)) {\n <mat-error>ID too long</mat-error>\n }\n </mat-form-field>\n\n <!-- label -->\n <mat-form-field>\n <mat-label>label</mat-label>\n <input matInput [formControl]=\"label\" />\n @if ($any(label).errors?.required && (label.dirty || label.touched)) {\n <mat-error>label required</mat-error>\n }\n @if (\n $any(label).errors?.maxlength && (label.dirty || label.touched)\n ) {\n <mat-error>label too long</mat-error>\n }\n </mat-form-field>\n\n <!-- color -->\n <mat-form-field class=\"color-input\">\n <mat-label>color</mat-label>\n <input matInput [formControl]=\"colorKey\" />\n @if (\n $any(colorKey).errors?.pattern &&\n (colorKey.dirty || colorKey.touched)\n ) {\n <mat-error>invalid color key</mat-error>\n }\n <input\n type=\"color\"\n class=\"color-picker-input\"\n #colorPicker\n [value]=\"\n colorKey.value.length === 6 ? '#' + colorKey.value : '#000000'\n \"\n (input)=\"onColorPick(colorPicker.value)\"\n />\n <button\n type=\"button\"\n mat-icon-button\n matSuffix\n matTooltip=\"Pick color\"\n (click)=\"colorPicker.click()\"\n >\n <mat-icon>palette</mat-icon>\n </button>\n </mat-form-field>\n <div class=\"color-sample\" [style.--swatch-color]=\"'#' + colorKey.value\"></div>\n </div>\n\n <!-- description -->\n <div>\n <mat-form-field class=\"long-text\">\n <mat-label>description</mat-label>\n <textarea matInput [formControl]=\"description\" rows=\"2\"></textarea>\n @if (\n $any(description).errors?.maxlength &&\n (description.dirty || description.touched)\n ) {\n <mat-error>description too long</mat-error>\n }\n </mat-form-field>\n </div>\n </mat-tab>\n\n <!-- PARTS -->\n <mat-tab label=\"parts\">\n <div>\n <button\n type=\"button\"\n mat-flat-button\n color=\"primary\"\n (click)=\"addPartDefinition()\"\n >\n <mat-icon>add_circle</mat-icon> part\n </button>\n </div>\n @if (partDefinitions.value.length) {\n <table>\n <thead>\n <tr>\n <th></th>\n <th>required</th>\n <th>type ID</th>\n <th>role ID</th>\n <th>name</th>\n <th>group</th>\n <th>color</th>\n <th>description</th>\n </tr>\n </thead>\n <tbody>\n @for (\n entry of partDefinitions.value;\n track entry;\n let i = $index;\n let first = $first;\n let last = $last\n ) {\n <tr [class.selected]=\"i === editedIndex()\">\n <td class=\"fit-width\">\n <button\n type=\"button\"\n mat-icon-button\n color=\"primary\"\n matTooltip=\"Edit this part definition\"\n (click)=\"editPartDefinition(entry, i)\"\n >\n <mat-icon class=\"mat-primary\">edit</mat-icon>\n </button>\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Move this part definition up\"\n [disabled]=\"first\"\n (click)=\"movePartDefinitionUp(i)\"\n >\n <mat-icon>arrow_upward</mat-icon>\n </button>\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Move this part definition down\"\n [disabled]=\"last\"\n (click)=\"movePartDefinitionDown(i)\"\n >\n <mat-icon>arrow_downward</mat-icon>\n </button>\n <button\n type=\"button\"\n mat-icon-button\n color=\"warn\"\n matTooltip=\"Delete this part definition\"\n (click)=\"deletePartDefinition(i)\"\n >\n <mat-icon class=\"mat-warn\">remove_circle</mat-icon>\n </button>\n </td>\n <td class=\"fit-width\">\n <mat-checkbox\n [checked]=\"entry.isRequired\"\n disabled\n ></mat-checkbox>\n </td>\n <td>{{ entry.typeId }}</td>\n <td>{{ entry.roleId }}</td>\n <td>{{ entry.name }}</td>\n <td>{{ entry.groupKey }}</td>\n <td>\n <span\n class=\"color-swatch\"\n [style.background-color]=\"'#' + entry.colorKey\"\n [style.color]=\"('#' + entry.colorKey) | colorToContrast\"\n >\n {{ entry.colorKey }}\n </span>\n </td>\n <td>{{ entry.description | ellipsis: 50 }}</td>\n </tr>\n }\n </tbody>\n </table>\n }\n @if (edited()) {\n <fieldset>\n <mat-expansion-panel [expanded]=\"edited()\" [disabled]=\"!edited()\">\n <mat-expansion-panel-header>\n <mat-panel-title>Part #{{ editedIndex() + 1 }}</mat-panel-title>\n </mat-expansion-panel-header>\n <cadmus-part-definition-editor\n [facetModelSettings]=\"facetModelSettings()\"\n [hideSortKey]=\"true\"\n [definition]=\"edited()\"\n (definitionChange)=\"savePartDefinition($event!)\"\n (cancelEdit)=\"closePartDefinition()\"\n />\n </mat-expansion-panel>\n </fieldset>\n }\n </mat-tab>\n </mat-tab-group>\n\n <!-- buttons -->\n <div>\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Discard changes\"\n (click)=\"cancel()\"\n >\n <mat-icon class=\"mat-warn\">clear</mat-icon>\n </button>\n <button\n type=\"submit\"\n mat-icon-button\n matTooltip=\"Accept changes\"\n [disabled]=\"form.invalid || form.pristine\"\n >\n <mat-icon class=\"mat-primary\">check_circle</mat-icon>\n </button>\n </div>\n</form>\n", styles: ["input[type=color].color-picker-input{display:none}.long-text{width:100%;max-width:800px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}table{width:100%;border-collapse:collapse;color:var(--mat-sys-on-surface-variant)}tbody tr:nth-child(odd){background-color:var(--mat-sys-surface-container)}th{text-align:left;font-weight:400;color:var(--mat-sys-on-surface-variant)}tbody tr:hover{background-color:var(--mat-sys-surface-container-high)}td.fit-width{width:1px;white-space:nowrap}tbody tr.selected{background-color:var(--mat-sys-secondary-container);color:var(--mat-sys-on-secondary-container)}.color-swatch{padding:2px 6px;border-radius:4px}.color-input{width:9em}.color-sample{width:32px;height:32px;border-radius:50%;background:var(--swatch-color);margin-top:-16px}\n"] }]
|
|
689
|
-
}], ctorParameters: () => [{ type: i1$1.FormBuilder }, { type: i2.DialogService }], propDecorators: { definition: [{ type: i0.Input, args: [{ isSignal: true, alias: "definition", required: false }] }, { type: i0.Output, args: ["definitionChange"] }], facetModelSettings: [{ type: i0.Input, args: [{ isSignal: true, alias: "facetModelSettings", required: false }] }], cancelEdit: [{ type: i0.Output, args: ["cancelEdit"] }] } });
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
* Editor for a list of facet definitions. Cadmus facet definitions represent the data
|
|
693
|
-
* types of items, and define all the parts which can be included in an item. Some of
|
|
694
|
-
* them are required, others are optional. There can be multiple parts of the same type
|
|
695
|
-
* in the same item, provided that their roleId is different.
|
|
696
|
-
* This editor is used to edit the list of facet definitions from the current profile.
|
|
697
|
-
* As the top level editor, it loads and saves the facet definitions list via API
|
|
698
|
-
* services, and allows to add, edit, delete and reorder facet definitions.
|
|
699
|
-
* The actual editing of a facet definition is delegated to descendant dumb components.
|
|
700
|
-
* All edits happen in memory until the user clicks the Save button, which saves all
|
|
701
|
-
* facet definitions to the server, and shows the result of the operation.
|
|
702
|
-
*/
|
|
703
|
-
class FacetDefinitionListEditorComponent {
|
|
704
|
-
_dialogService;
|
|
705
|
-
_facetService;
|
|
706
|
-
_validator;
|
|
707
|
-
_snackbar;
|
|
708
|
-
edited = signal(undefined, /* @ts-ignore */
|
|
709
|
-
...(ngDevMode ? [{ debugName: "edited" }] : /* istanbul ignore next */ []));
|
|
710
|
-
editedIndex = signal(-1, /* @ts-ignore */
|
|
711
|
-
...(ngDevMode ? [{ debugName: "editedIndex" }] : /* istanbul ignore next */ []));
|
|
712
|
-
dirty = signal(false, /* @ts-ignore */
|
|
713
|
-
...(ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []));
|
|
714
|
-
facets = signal([], /* @ts-ignore */
|
|
715
|
-
...(ngDevMode ? [{ debugName: "facets" }] : /* istanbul ignore next */ []));
|
|
716
|
-
busy = signal(false, /* @ts-ignore */
|
|
717
|
-
...(ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []));
|
|
718
|
-
saveResult = signal(undefined, /* @ts-ignore */
|
|
719
|
-
...(ngDevMode ? [{ debugName: "saveResult" }] : /* istanbul ignore next */ []));
|
|
720
|
-
/** True after at least one facet was successfully saved; prompts an app reload. */
|
|
721
|
-
reloadNeeded = signal(false, /* @ts-ignore */
|
|
722
|
-
...(ngDevMode ? [{ debugName: "reloadNeeded" }] : /* istanbul ignore next */ []));
|
|
723
|
-
/** Last validation result, set by validate() and by save(). */
|
|
724
|
-
validationResult = signal(undefined, /* @ts-ignore */
|
|
725
|
-
...(ngDevMode ? [{ debugName: "validationResult" }] : /* istanbul ignore next */ []));
|
|
726
|
-
validationResultHasIssues = computed(() => {
|
|
727
|
-
const vr = this.validationResult();
|
|
728
|
-
return vr ? vr.hasErrors || vr.hasWarnings : false;
|
|
729
|
-
}, /* @ts-ignore */
|
|
730
|
-
...(ngDevMode ? [{ debugName: "validationResultHasIssues" }] : /* istanbul ignore next */ []));
|
|
731
|
-
/**
|
|
732
|
-
* The facet models settings, used to get the list of available part type IDs,
|
|
733
|
-
* and whether they are base text parts; in this case, the same settings also
|
|
734
|
-
* provide the list of their available role IDs from the fragments property.
|
|
735
|
-
*/
|
|
736
|
-
facetModelSettings = signal(undefined, /* @ts-ignore */
|
|
737
|
-
...(ngDevMode ? [{ debugName: "facetModelSettings" }] : /* istanbul ignore next */ []));
|
|
738
|
-
dirtyChange = output();
|
|
739
|
-
editorClose = output();
|
|
740
|
-
constructor(_dialogService, _facetService, _validator, _snackbar) {
|
|
741
|
-
this._dialogService = _dialogService;
|
|
742
|
-
this._facetService = _facetService;
|
|
743
|
-
this._validator = _validator;
|
|
744
|
-
this._snackbar = _snackbar;
|
|
745
|
-
}
|
|
746
|
-
ngOnInit() {
|
|
747
|
-
// load facets once at start
|
|
748
|
-
this.busy.set(true);
|
|
749
|
-
this._facetService.getFacets().subscribe({
|
|
750
|
-
next: (facets) => {
|
|
751
|
-
this.facets.set(facets);
|
|
752
|
-
this.busy.set(false);
|
|
753
|
-
},
|
|
754
|
-
error: (error) => {
|
|
755
|
-
console.error(error);
|
|
756
|
-
this.busy.set(false);
|
|
757
|
-
this._snackbar.open('Error loading facets', 'Close');
|
|
758
|
-
},
|
|
759
|
-
});
|
|
760
|
-
// load facet model settings once at start
|
|
761
|
-
this._facetService.getFacetModelSettings().subscribe({
|
|
762
|
-
next: (settings) => {
|
|
763
|
-
this.facetModelSettings.set(settings);
|
|
764
|
-
},
|
|
765
|
-
error: (error) => {
|
|
766
|
-
console.error(error);
|
|
767
|
-
this._snackbar.open('Error loading facet model settings', 'Close');
|
|
768
|
-
},
|
|
769
|
-
});
|
|
770
|
-
}
|
|
771
|
-
addFacet() {
|
|
772
|
-
const entry = {
|
|
773
|
-
id: 'new',
|
|
774
|
-
label: 'New facet',
|
|
775
|
-
colorKey: 'default',
|
|
776
|
-
description: '',
|
|
777
|
-
partDefinitions: [],
|
|
778
|
-
};
|
|
779
|
-
this.editedIndex.set(-1);
|
|
780
|
-
this.edited.set(entry);
|
|
781
|
-
}
|
|
782
|
-
editFacet(facet, index) {
|
|
783
|
-
this.editedIndex.set(index);
|
|
784
|
-
this.edited.set(structuredClone(facet));
|
|
785
|
-
}
|
|
786
|
-
closeFacet() {
|
|
787
|
-
this.editedIndex.set(-1);
|
|
788
|
-
this.edited.set(undefined);
|
|
789
|
-
}
|
|
790
|
-
saveFacet(facet) {
|
|
791
|
-
const entries = [...this.facets()];
|
|
792
|
-
if (this.editedIndex() === -1) {
|
|
793
|
-
entries.push(facet);
|
|
794
|
-
}
|
|
795
|
-
else {
|
|
796
|
-
entries.splice(this.editedIndex(), 1, facet);
|
|
797
|
-
}
|
|
798
|
-
this.facets.set(entries);
|
|
799
|
-
this.closeFacet();
|
|
800
|
-
this.dirty.set(true);
|
|
801
|
-
this.dirtyChange.emit(true);
|
|
802
|
-
}
|
|
803
|
-
deleteFacet(index) {
|
|
804
|
-
this._dialogService
|
|
805
|
-
.confirm('Confirmation', `Delete facet ${this.edited()?.label}?`)
|
|
806
|
-
.subscribe((yes) => {
|
|
807
|
-
if (yes) {
|
|
808
|
-
if (this.editedIndex() === index) {
|
|
809
|
-
this.closeFacet();
|
|
810
|
-
}
|
|
811
|
-
const entries = [...this.facets()];
|
|
812
|
-
entries.splice(index, 1);
|
|
813
|
-
this.facets.set(entries);
|
|
814
|
-
this.dirty.set(true);
|
|
815
|
-
this.dirtyChange.emit(true);
|
|
816
|
-
}
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
moveFacetUp(index) {
|
|
820
|
-
if (index < 1) {
|
|
821
|
-
return;
|
|
822
|
-
}
|
|
823
|
-
const facet = this.facets()[index];
|
|
824
|
-
const facets = [...this.facets()];
|
|
825
|
-
facets.splice(index, 1);
|
|
826
|
-
facets.splice(index - 1, 0, facet);
|
|
827
|
-
this.facets.set(facets);
|
|
828
|
-
this.dirty.set(true);
|
|
829
|
-
this.dirtyChange.emit(true);
|
|
830
|
-
// keep editedIndex in sync
|
|
831
|
-
if (this.editedIndex() === index) {
|
|
832
|
-
this.editedIndex.set(index - 1);
|
|
833
|
-
}
|
|
834
|
-
else if (this.editedIndex() === index - 1) {
|
|
835
|
-
this.editedIndex.set(index);
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
moveFacetDown(index) {
|
|
839
|
-
if (index + 1 >= this.facets().length) {
|
|
840
|
-
return;
|
|
841
|
-
}
|
|
842
|
-
const facet = this.facets()[index];
|
|
843
|
-
const facets = [...this.facets()];
|
|
844
|
-
facets.splice(index, 1);
|
|
845
|
-
facets.splice(index + 1, 0, facet);
|
|
846
|
-
this.facets.set(facets);
|
|
847
|
-
this.dirty.set(true);
|
|
848
|
-
this.dirtyChange.emit(true);
|
|
849
|
-
// keep editedIndex in sync
|
|
850
|
-
if (this.editedIndex() === index) {
|
|
851
|
-
this.editedIndex.set(index + 1);
|
|
852
|
-
}
|
|
853
|
-
else if (this.editedIndex() === index + 1) {
|
|
854
|
-
this.editedIndex.set(index);
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
reloadApp() {
|
|
858
|
-
window.location.href = '/';
|
|
859
|
-
}
|
|
860
|
-
close() {
|
|
861
|
-
this.editorClose.emit();
|
|
862
|
-
}
|
|
863
|
-
/** Run validation and update validationResult; returns the observable. */
|
|
864
|
-
runValidation() {
|
|
865
|
-
return this._validator
|
|
866
|
-
.validate(this.facets(), this.facetModelSettings())
|
|
867
|
-
.pipe(tap((result) => this.validationResult.set(result)));
|
|
868
|
-
}
|
|
869
|
-
/** Trigger validation from the template and update the displayed result. */
|
|
870
|
-
validate() {
|
|
871
|
-
this.runValidation().pipe(take(1)).subscribe();
|
|
872
|
-
}
|
|
873
|
-
/** Persist all facets to the server; called only after all gates pass. */
|
|
874
|
-
doSave() {
|
|
875
|
-
const facets = this.facets();
|
|
876
|
-
this.busy.set(true);
|
|
877
|
-
this.saveResult.set(undefined);
|
|
878
|
-
from(facets)
|
|
879
|
-
.pipe(concatMap((facet) => this._facetService.addFacet(facet).pipe(map(() => true), catchError(() => of(false)))), toArray())
|
|
880
|
-
.subscribe((results) => {
|
|
881
|
-
const saved = [];
|
|
882
|
-
const failed = [];
|
|
883
|
-
results.forEach((ok, i) => {
|
|
884
|
-
if (ok) {
|
|
885
|
-
saved.push(facets[i].id);
|
|
886
|
-
}
|
|
887
|
-
else {
|
|
888
|
-
failed.push(facets[i].id);
|
|
889
|
-
}
|
|
890
|
-
});
|
|
891
|
-
this.busy.set(false);
|
|
892
|
-
this.dirty.set(failed.length > 0);
|
|
893
|
-
this.dirtyChange.emit(failed.length > 0);
|
|
894
|
-
if (saved.length > 0) {
|
|
895
|
-
this.reloadNeeded.set(true);
|
|
896
|
-
}
|
|
897
|
-
const parts = [];
|
|
898
|
-
if (saved.length) {
|
|
899
|
-
parts.push(`Saved: ${saved.join(', ')}`);
|
|
900
|
-
}
|
|
901
|
-
if (failed.length) {
|
|
902
|
-
parts.push(`Failed: ${failed.join(', ')}`);
|
|
903
|
-
}
|
|
904
|
-
this.saveResult.set(parts.join(' | '));
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
/**
|
|
908
|
-
* Final confirmation gate before the actual write.
|
|
909
|
-
* Always shown, even when there are no warnings or errors.
|
|
910
|
-
*/
|
|
911
|
-
confirmAndSave() {
|
|
912
|
-
this._dialogService
|
|
913
|
-
.confirm('Save facets', 'Saving replaces ALL facet definitions on the server. ' +
|
|
914
|
-
'This may affect every item in the database. Proceed?')
|
|
915
|
-
.subscribe((ok) => {
|
|
916
|
-
if (ok) {
|
|
917
|
-
this.doSave();
|
|
918
|
-
}
|
|
919
|
-
});
|
|
920
|
-
}
|
|
921
|
-
downloadFacets() {
|
|
922
|
-
const replacer = (_key, value) => value === null || value === false ? undefined : value;
|
|
923
|
-
const dataStr = 'data:text/json;charset=utf-8,' +
|
|
924
|
-
encodeURIComponent(JSON.stringify(this.facets(), replacer, 2));
|
|
925
|
-
const dlAnchorElem = document.createElement('a');
|
|
926
|
-
dlAnchorElem.setAttribute('href', dataStr);
|
|
927
|
-
dlAnchorElem.setAttribute('download', 'facets.json');
|
|
928
|
-
dlAnchorElem.click();
|
|
929
|
-
}
|
|
930
|
-
/**
|
|
931
|
-
* Validate the current facets, then — if there are no blocking errors —
|
|
932
|
-
* walk the user through confirmation gates before saving.
|
|
933
|
-
*
|
|
934
|
-
* Gates (in order):
|
|
935
|
-
* 1. Validation errors → block save, show results.
|
|
936
|
-
* 2. Validation warnings → ask user to confirm before continuing.
|
|
937
|
-
* 3. Final critical-operation confirmation → always shown.
|
|
938
|
-
*/
|
|
939
|
-
save() {
|
|
940
|
-
if (!this.facets().length) {
|
|
941
|
-
return;
|
|
942
|
-
}
|
|
943
|
-
this.runValidation()
|
|
944
|
-
.pipe(take(1))
|
|
945
|
-
.subscribe((result) => {
|
|
946
|
-
if (result.hasErrors) {
|
|
947
|
-
// validation result is already displayed; nothing more to do
|
|
948
|
-
return;
|
|
949
|
-
}
|
|
950
|
-
if (result.hasWarnings) {
|
|
951
|
-
const warnCount = result.issues.filter((i) => i.severity === 'warning').length;
|
|
952
|
-
this._dialogService
|
|
953
|
-
.confirm('Warnings', `There ${warnCount === 1 ? 'is 1 warning' : `are ${warnCount} warnings`}. ` +
|
|
954
|
-
'Review the validation results below. Proceed anyway?')
|
|
955
|
-
.subscribe((ok) => {
|
|
956
|
-
if (ok) {
|
|
957
|
-
this.confirmAndSave();
|
|
958
|
-
}
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
else {
|
|
962
|
-
this.confirmAndSave();
|
|
963
|
-
}
|
|
964
|
-
});
|
|
965
|
-
}
|
|
966
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: FacetDefinitionListEditorComponent, deps: [{ token: i2.DialogService }, { token: i1.FacetService }, { token: FacetDefinitionValidatorService }, { token: i4.MatSnackBar }], target: i0.ɵɵFactoryTarget.Component });
|
|
967
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: FacetDefinitionListEditorComponent, isStandalone: true, selector: "cadmus-facet-definition-list-editor", outputs: { dirtyChange: "dirtyChange", editorClose: "editorClose" }, ngImport: i0, template: "<div>\r\n <div class=\"form-row\">\r\n <button type=\"button\" mat-flat-button color=\"primary\" (click)=\"addFacet()\">\r\n <mat-icon>add_circle</mat-icon> facet\r\n </button>\r\n <button type=\"button\" mat-flat-button (click)=\"validate()\">\r\n <mat-icon>fact_check</mat-icon> validate\r\n </button>\r\n <button type=\"button\" mat-flat-button (click)=\"downloadFacets()\">\r\n <mat-icon>download</mat-icon> download\r\n </button>\r\n <button type=\"button\" mat-flat-button color=\"warn\" (click)=\"save()\">\r\n <mat-icon>save</mat-icon> save\r\n </button>\r\n </div>\r\n <div>\r\n @if (busy()) {\r\n <mat-progress-bar mode=\"indeterminate\" color=\"accent\" />\r\n }\r\n </div>\r\n @if (validationResult(); as vr) {\r\n <mat-expansion-panel [expanded]=\"true\">\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>Validation result</mat-panel-title>\r\n <mat-panel-description\r\n [style.color]=\"validationResultHasIssues() ? 'warn' : 'primary'\"\r\n >\r\n {{ vr.issues.length }} result{{ vr.issues.length !== 1 ? \"s\" : \"\" }}\r\n </mat-panel-description>\r\n </mat-expansion-panel-header>\r\n <div class=\"validation-result\">\r\n @if (!vr.issues.length) {\r\n <span>No issues found.</span>\r\n } @else {\r\n <div class=\"validation-issues\">\r\n @for (issue of vr.issues; track $index) {\r\n <div class=\"validation-issue {{ issue.severity }}\">\r\n <mat-icon>{{\r\n issue.severity === \"error\"\r\n ? \"error\"\r\n : issue.severity === \"warning\"\r\n ? \"warning\"\r\n : \"info\"\r\n }}</mat-icon>\r\n <span>{{ issue.message }}</span>\r\n </div>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </mat-expansion-panel>\r\n }\r\n @if (reloadNeeded()) {\r\n <div class=\"reload-notice\">\r\n <mat-icon>info</mat-icon>\r\n <span\r\n >Facet definitions are cached at startup. Please reload the app to apply\r\n the changes.</span\r\n >\r\n <button\r\n type=\"button\"\r\n mat-flat-button\r\n color=\"primary\"\r\n (click)=\"reloadApp()\"\r\n >\r\n <mat-icon>refresh</mat-icon>\r\n reload app\r\n </button>\r\n </div>\r\n }\r\n @if (facets().length) {\r\n <table class=\"margin-top\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>ID</th>\r\n <th>label</th>\r\n <th>color</th>\r\n <th>parts</th>\r\n <th>description</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n @for (\r\n entry of facets();\r\n track entry;\r\n let i = $index;\r\n let first = $first;\r\n let last = $last\r\n ) {\r\n <tr [class.selected]=\"i === editedIndex()\">\r\n <td class=\"fit-width\">\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"primary\"\r\n matTooltip=\"Edit this facet\"\r\n (click)=\"editFacet(entry, i)\"\r\n >\r\n <mat-icon class=\"mat-primary\">edit</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Move this facet up\"\r\n [disabled]=\"first\"\r\n (click)=\"moveFacetUp(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 facet down\"\r\n [disabled]=\"last\"\r\n (click)=\"moveFacetDown(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 facet\"\r\n (click)=\"deleteFacet(i)\"\r\n >\r\n <mat-icon class=\"mat-warn\">remove_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ entry.id }}</td>\r\n <td>{{ entry.label }}</td>\r\n <td>\r\n <span\r\n class=\"color-swatch\"\r\n [style.background-color]=\"'#' + entry.colorKey\"\r\n [style.color]=\"'#' + entry.colorKey | colorToContrast\"\r\n >\r\n {{ entry.colorKey }}\r\n </span>\r\n </td>\r\n <td>{{ entry.partDefinitions.length }}</td>\r\n <td>{{ entry.description | ellipsis: 50 }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n }\r\n @if (edited()) {\r\n <fieldset>\r\n <mat-expansion-panel [expanded]=\"edited()\" [disabled]=\"!edited()\">\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>Facet #{{ editedIndex() + 1 }}</mat-panel-title>\r\n </mat-expansion-panel-header>\r\n <cadmus-facet-definition-editor\r\n [facetModelSettings]=\"facetModelSettings()\"\r\n [definition]=\"edited()\"\r\n (definitionChange)=\"saveFacet($event!)\"\r\n (cancelEdit)=\"closeFacet()\"\r\n />\r\n </mat-expansion-panel>\r\n </fieldset>\r\n }\r\n</div>\r\n", styles: ["table{width:100%;border-collapse:collapse;color:var(--mat-sys-on-surface-variant)}tbody tr:nth-child(odd){background-color:var(--mat-sys-surface-container)}th{text-align:left;font-weight:400;color:var(--mat-sys-on-surface-variant)}tbody tr:hover{background-color:var(--mat-sys-surface-container-high)}td.fit-width{width:1px;white-space:nowrap}tbody tr.selected{background-color:var(--mat-sys-secondary-container);color:var(--mat-sys-on-secondary-container)}fieldset{border:1px solid silver;border-radius:6px;padding:6px}.validation-result{margin:8px 0;max-height:800px;overflow:auto}.validation-issues{display:flex;flex-direction:column;gap:4px;margin:8px 0;font-size:.9em}.validation-issue{display:flex;align-items:center;gap:4px}.validation-issue.error{color:var(--mat-sys-error)}.validation-issue.warning{color:var(--mat-sys-tertiary)}.reload-notice{display:flex;gap:8px;align-items:center;margin:16px 0;padding:12px;background-color:var(--mat-sys-warning);border:1px solid var(--mat-sys-warning);border-radius:4px;color:var(--mat-sys-on-warning)}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.color-swatch{padding:2px 6px;border-radius:4px}.margin-top{margin-top:1rem}\n"], dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i3.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: i3.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["hideToggle", "togglePosition"], outputs: ["afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { kind: "directive", type: MatExpansionPanelDescription, selector: "mat-panel-description" }, { kind: "component", type: MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["expandedHeight", "collapsedHeight", "tabIndex"] }, { kind: "directive", type: MatExpansionPanelTitle, selector: "mat-panel-title" }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "component", type: MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "component", type: FacetDefinitionEditorComponent, selector: "cadmus-facet-definition-editor", inputs: ["definition", "facetModelSettings"], outputs: ["definitionChange", "cancelEdit"] }, { kind: "pipe", type: ColorToContrastPipe, name: "colorToContrast" }, { kind: "pipe", type: EllipsisPipe, name: "ellipsis" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
516
|
+
function toDraft(data) {
|
|
517
|
+
return {
|
|
518
|
+
id: data?.id || "",
|
|
519
|
+
label: data?.label || "",
|
|
520
|
+
colorKey: data?.colorKey || "",
|
|
521
|
+
description: data?.description || "",
|
|
522
|
+
partDefinitions: [...data?.partDefinitions || []].sort((a, b) => (a.sortKey ?? "").localeCompare(b.sortKey ?? "")).map(copyPart)
|
|
523
|
+
};
|
|
968
524
|
}
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
MatIcon,
|
|
978
|
-
MatTooltip,
|
|
979
|
-
MatProgressBar,
|
|
980
|
-
ColorToContrastPipe,
|
|
981
|
-
EllipsisPipe,
|
|
982
|
-
FacetDefinitionEditorComponent,
|
|
983
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div>\r\n <div class=\"form-row\">\r\n <button type=\"button\" mat-flat-button color=\"primary\" (click)=\"addFacet()\">\r\n <mat-icon>add_circle</mat-icon> facet\r\n </button>\r\n <button type=\"button\" mat-flat-button (click)=\"validate()\">\r\n <mat-icon>fact_check</mat-icon> validate\r\n </button>\r\n <button type=\"button\" mat-flat-button (click)=\"downloadFacets()\">\r\n <mat-icon>download</mat-icon> download\r\n </button>\r\n <button type=\"button\" mat-flat-button color=\"warn\" (click)=\"save()\">\r\n <mat-icon>save</mat-icon> save\r\n </button>\r\n </div>\r\n <div>\r\n @if (busy()) {\r\n <mat-progress-bar mode=\"indeterminate\" color=\"accent\" />\r\n }\r\n </div>\r\n @if (validationResult(); as vr) {\r\n <mat-expansion-panel [expanded]=\"true\">\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>Validation result</mat-panel-title>\r\n <mat-panel-description\r\n [style.color]=\"validationResultHasIssues() ? 'warn' : 'primary'\"\r\n >\r\n {{ vr.issues.length }} result{{ vr.issues.length !== 1 ? \"s\" : \"\" }}\r\n </mat-panel-description>\r\n </mat-expansion-panel-header>\r\n <div class=\"validation-result\">\r\n @if (!vr.issues.length) {\r\n <span>No issues found.</span>\r\n } @else {\r\n <div class=\"validation-issues\">\r\n @for (issue of vr.issues; track $index) {\r\n <div class=\"validation-issue {{ issue.severity }}\">\r\n <mat-icon>{{\r\n issue.severity === \"error\"\r\n ? \"error\"\r\n : issue.severity === \"warning\"\r\n ? \"warning\"\r\n : \"info\"\r\n }}</mat-icon>\r\n <span>{{ issue.message }}</span>\r\n </div>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </mat-expansion-panel>\r\n }\r\n @if (reloadNeeded()) {\r\n <div class=\"reload-notice\">\r\n <mat-icon>info</mat-icon>\r\n <span\r\n >Facet definitions are cached at startup. Please reload the app to apply\r\n the changes.</span\r\n >\r\n <button\r\n type=\"button\"\r\n mat-flat-button\r\n color=\"primary\"\r\n (click)=\"reloadApp()\"\r\n >\r\n <mat-icon>refresh</mat-icon>\r\n reload app\r\n </button>\r\n </div>\r\n }\r\n @if (facets().length) {\r\n <table class=\"margin-top\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>ID</th>\r\n <th>label</th>\r\n <th>color</th>\r\n <th>parts</th>\r\n <th>description</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n @for (\r\n entry of facets();\r\n track entry;\r\n let i = $index;\r\n let first = $first;\r\n let last = $last\r\n ) {\r\n <tr [class.selected]=\"i === editedIndex()\">\r\n <td class=\"fit-width\">\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"primary\"\r\n matTooltip=\"Edit this facet\"\r\n (click)=\"editFacet(entry, i)\"\r\n >\r\n <mat-icon class=\"mat-primary\">edit</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Move this facet up\"\r\n [disabled]=\"first\"\r\n (click)=\"moveFacetUp(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 facet down\"\r\n [disabled]=\"last\"\r\n (click)=\"moveFacetDown(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 facet\"\r\n (click)=\"deleteFacet(i)\"\r\n >\r\n <mat-icon class=\"mat-warn\">remove_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ entry.id }}</td>\r\n <td>{{ entry.label }}</td>\r\n <td>\r\n <span\r\n class=\"color-swatch\"\r\n [style.background-color]=\"'#' + entry.colorKey\"\r\n [style.color]=\"'#' + entry.colorKey | colorToContrast\"\r\n >\r\n {{ entry.colorKey }}\r\n </span>\r\n </td>\r\n <td>{{ entry.partDefinitions.length }}</td>\r\n <td>{{ entry.description | ellipsis: 50 }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n }\r\n @if (edited()) {\r\n <fieldset>\r\n <mat-expansion-panel [expanded]=\"edited()\" [disabled]=\"!edited()\">\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>Facet #{{ editedIndex() + 1 }}</mat-panel-title>\r\n </mat-expansion-panel-header>\r\n <cadmus-facet-definition-editor\r\n [facetModelSettings]=\"facetModelSettings()\"\r\n [definition]=\"edited()\"\r\n (definitionChange)=\"saveFacet($event!)\"\r\n (cancelEdit)=\"closeFacet()\"\r\n />\r\n </mat-expansion-panel>\r\n </fieldset>\r\n }\r\n</div>\r\n", styles: ["table{width:100%;border-collapse:collapse;color:var(--mat-sys-on-surface-variant)}tbody tr:nth-child(odd){background-color:var(--mat-sys-surface-container)}th{text-align:left;font-weight:400;color:var(--mat-sys-on-surface-variant)}tbody tr:hover{background-color:var(--mat-sys-surface-container-high)}td.fit-width{width:1px;white-space:nowrap}tbody tr.selected{background-color:var(--mat-sys-secondary-container);color:var(--mat-sys-on-secondary-container)}fieldset{border:1px solid silver;border-radius:6px;padding:6px}.validation-result{margin:8px 0;max-height:800px;overflow:auto}.validation-issues{display:flex;flex-direction:column;gap:4px;margin:8px 0;font-size:.9em}.validation-issue{display:flex;align-items:center;gap:4px}.validation-issue.error{color:var(--mat-sys-error)}.validation-issue.warning{color:var(--mat-sys-tertiary)}.reload-notice{display:flex;gap:8px;align-items:center;margin:16px 0;padding:12px;background-color:var(--mat-sys-warning);border:1px solid var(--mat-sys-warning);border-radius:4px;color:var(--mat-sys-on-warning)}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.color-swatch{padding:2px 6px;border-radius:4px}.margin-top{margin-top:1rem}\n"] }]
|
|
984
|
-
}], ctorParameters: () => [{ type: i2.DialogService }, { type: i1.FacetService }, { type: FacetDefinitionValidatorService }, { type: i4.MatSnackBar }], propDecorators: { dirtyChange: [{ type: i0.Output, args: ["dirtyChange"] }], editorClose: [{ type: i0.Output, args: ["editorClose"] }] } });
|
|
985
|
-
|
|
986
|
-
class FacetEditPageComponent {
|
|
987
|
-
_dirty = signal(false, /* @ts-ignore */
|
|
988
|
-
...(ngDevMode ? [{ debugName: "_dirty" }] : /* istanbul ignore next */ []));
|
|
989
|
-
canDeactivate() {
|
|
990
|
-
return !this._dirty();
|
|
991
|
-
}
|
|
992
|
-
onDirtyChange(dirty) {
|
|
993
|
-
this._dirty.set(dirty);
|
|
994
|
-
}
|
|
995
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: FacetEditPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
996
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.1", type: FacetEditPageComponent, isStandalone: true, selector: "cadmus-facet-edit-page", ngImport: i0, template: "<mat-card>\r\n <mat-card-header>\r\n <mat-icon mat-card-avatar>dashboard</mat-icon>\r\n <mat-card-title>Edit Facets</mat-card-title>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <div class=\"margin-top\">\r\n <cadmus-facet-definition-list-editor (dirtyChange)=\"onDirtyChange($event)\" />\r\n </div>\r\n </mat-card-content>\r\n</mat-card>\r\n", styles: [".margin-top{margin-top:1rem}\n"], dependencies: [{ kind: "component", type: MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: MatCardContent, selector: "mat-card-content" }, { kind: "component", type: MatCardHeader, selector: "mat-card-header" }, { kind: "directive", type: MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: FacetDefinitionListEditorComponent, selector: "cadmus-facet-definition-list-editor", outputs: ["dirtyChange", "editorClose"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
525
|
+
function toData(v) {
|
|
526
|
+
return {
|
|
527
|
+
id: v.id.trim(),
|
|
528
|
+
label: v.label.trim(),
|
|
529
|
+
colorKey: v.colorKey,
|
|
530
|
+
description: v.description.trim(),
|
|
531
|
+
partDefinitions: v.partDefinitions.map(copyPart)
|
|
532
|
+
};
|
|
997
533
|
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
534
|
+
var FacetDefinitionEditorComponent = class FacetDefinitionEditorComponent {
|
|
535
|
+
_dialogService;
|
|
536
|
+
definition = model(...ngDevMode ? [void 0, { debugName: "definition" }] : /* istanbul ignore next */ []);
|
|
537
|
+
facetModelSettings = input(void 0, ...ngDevMode ? [{ debugName: "facetModelSettings" }] : /* istanbul ignore next */ []);
|
|
538
|
+
availablePartTypeIds = computed(() => {
|
|
539
|
+
const settings = this.facetModelSettings();
|
|
540
|
+
return settings?.parts ? Object.keys(settings.parts) : [];
|
|
541
|
+
}, ...ngDevMode ? [{ debugName: "availablePartTypeIds" }] : /* istanbul ignore next */ []);
|
|
542
|
+
cancelEdit = output();
|
|
543
|
+
edited = signal(void 0, ...ngDevMode ? [{ debugName: "edited" }] : /* istanbul ignore next */ []);
|
|
544
|
+
editedIndex = signal(-1, ...ngDevMode ? [{ debugName: "editedIndex" }] : /* istanbul ignore next */ []);
|
|
545
|
+
_draft = linkedSignal({
|
|
546
|
+
...ngDevMode ? { debugName: "_draft" } : /* istanbul ignore next */ {},
|
|
547
|
+
source: () => this.definition(),
|
|
548
|
+
computation: (data, previous) => previous && JSON.stringify(data) === JSON.stringify(toData(previous.value)) ? previous.value : toDraft(data)
|
|
549
|
+
});
|
|
550
|
+
form = form(this._draft, (path) => {
|
|
551
|
+
required(path.id);
|
|
552
|
+
maxLength(path.id, 100);
|
|
553
|
+
required(path.label);
|
|
554
|
+
maxLength(path.label, 100);
|
|
555
|
+
pattern(path.colorKey, /^[0-9a-fA-F]{6}$/);
|
|
556
|
+
maxLength(path.description, 1e3);
|
|
557
|
+
validate(path.partDefinitions, ({ value }) => value().length ? null : { kind: "required" });
|
|
558
|
+
});
|
|
559
|
+
constructor(_dialogService) {
|
|
560
|
+
this._dialogService = _dialogService;
|
|
561
|
+
effect(() => {
|
|
562
|
+
const draft = this._draft();
|
|
563
|
+
untracked(() => {
|
|
564
|
+
if (JSON.stringify(draft) === JSON.stringify(toDraft(this.definition()))) this.form().reset();
|
|
565
|
+
});
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
setPartDefinitions(definitions) {
|
|
569
|
+
this.form.partDefinitions().value.set(definitions.map((entry, index) => ({
|
|
570
|
+
...entry,
|
|
571
|
+
sortKey: (index + 1).toString().padStart(2, "0")
|
|
572
|
+
})));
|
|
573
|
+
this.form.partDefinitions().markAsDirty();
|
|
574
|
+
}
|
|
575
|
+
addPartDefinition() {
|
|
576
|
+
const definition = {
|
|
577
|
+
typeId: this.availablePartTypeIds().length ? this.availablePartTypeIds()[0] : "",
|
|
578
|
+
name: "new"
|
|
579
|
+
};
|
|
580
|
+
this.editedIndex.set(-1);
|
|
581
|
+
this.edited.set(definition);
|
|
582
|
+
}
|
|
583
|
+
editPartDefinition(entry, index) {
|
|
584
|
+
this.editedIndex.set(index);
|
|
585
|
+
this.edited.set(structuredClone(entry));
|
|
586
|
+
}
|
|
587
|
+
closePartDefinition() {
|
|
588
|
+
this.editedIndex.set(-1);
|
|
589
|
+
this.edited.set(void 0);
|
|
590
|
+
}
|
|
591
|
+
savePartDefinition(entry) {
|
|
592
|
+
const entries = [...this.form.partDefinitions().value()];
|
|
593
|
+
if (this.editedIndex() === -1) entries.push(entry);
|
|
594
|
+
else entries.splice(this.editedIndex(), 1, entry);
|
|
595
|
+
this.setPartDefinitions(entries);
|
|
596
|
+
this.closePartDefinition();
|
|
597
|
+
}
|
|
598
|
+
deletePartDefinition(index) {
|
|
599
|
+
const definition = this.form.partDefinitions().value()[index];
|
|
600
|
+
this._dialogService.confirm("Confirmation", `Delete part "${definition.name}"?`).subscribe((yes) => {
|
|
601
|
+
if (yes) {
|
|
602
|
+
if (this.editedIndex() === index) this.closePartDefinition();
|
|
603
|
+
const definitions = [...this.form.partDefinitions().value()];
|
|
604
|
+
definitions.splice(index, 1);
|
|
605
|
+
this.setPartDefinitions(definitions);
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
movePartDefinitionUp(index) {
|
|
610
|
+
if (index < 1) return;
|
|
611
|
+
const definitions = [...this.form.partDefinitions().value()];
|
|
612
|
+
const definition = definitions[index];
|
|
613
|
+
definitions.splice(index, 1);
|
|
614
|
+
definitions.splice(index - 1, 0, definition);
|
|
615
|
+
if (this.editedIndex() === index) this.editedIndex.set(index - 1);
|
|
616
|
+
else if (this.editedIndex() === index - 1) this.editedIndex.set(index);
|
|
617
|
+
this.setPartDefinitions(definitions);
|
|
618
|
+
}
|
|
619
|
+
movePartDefinitionDown(index) {
|
|
620
|
+
if (index + 1 >= this.form.partDefinitions().value().length) return;
|
|
621
|
+
const definitions = [...this.form.partDefinitions().value()];
|
|
622
|
+
const definition = definitions[index];
|
|
623
|
+
definitions.splice(index, 1);
|
|
624
|
+
definitions.splice(index + 1, 0, definition);
|
|
625
|
+
if (this.editedIndex() === index) this.editedIndex.set(index + 1);
|
|
626
|
+
else if (this.editedIndex() === index + 1) this.editedIndex.set(index);
|
|
627
|
+
this.setPartDefinitions(definitions);
|
|
628
|
+
}
|
|
629
|
+
onColorPick(value) {
|
|
630
|
+
this.form.colorKey().value.set(value.slice(1));
|
|
631
|
+
this.form.colorKey().markAsDirty();
|
|
632
|
+
}
|
|
633
|
+
cancel() {
|
|
634
|
+
this.cancelEdit.emit();
|
|
635
|
+
}
|
|
636
|
+
save(pristine = true) {
|
|
637
|
+
if (this.form().invalid()) {
|
|
638
|
+
this.form().markAsTouched();
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
this.definition.set(toData(this._draft()));
|
|
642
|
+
if (pristine) this.form().reset();
|
|
643
|
+
}
|
|
644
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
645
|
+
minVersion: "12.0.0",
|
|
646
|
+
version: "22.2.0",
|
|
647
|
+
ngImport: i0,
|
|
648
|
+
type: FacetDefinitionEditorComponent,
|
|
649
|
+
deps: [{ token: i1.DialogService }],
|
|
650
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
651
|
+
});
|
|
652
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
653
|
+
minVersion: "17.0.0",
|
|
654
|
+
version: "22.2.0",
|
|
655
|
+
type: FacetDefinitionEditorComponent,
|
|
656
|
+
isStandalone: true,
|
|
657
|
+
selector: "cadmus-facet-definition-editor",
|
|
658
|
+
inputs: {
|
|
659
|
+
definition: {
|
|
660
|
+
classPropertyName: "definition",
|
|
661
|
+
publicName: "definition",
|
|
662
|
+
isSignal: true,
|
|
663
|
+
isRequired: false,
|
|
664
|
+
transformFunction: null
|
|
665
|
+
},
|
|
666
|
+
facetModelSettings: {
|
|
667
|
+
classPropertyName: "facetModelSettings",
|
|
668
|
+
publicName: "facetModelSettings",
|
|
669
|
+
isSignal: true,
|
|
670
|
+
isRequired: false,
|
|
671
|
+
transformFunction: null
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
outputs: {
|
|
675
|
+
definition: "definitionChange",
|
|
676
|
+
cancelEdit: "cancelEdit"
|
|
677
|
+
},
|
|
678
|
+
ngImport: i0,
|
|
679
|
+
template: "<div>\r\n <mat-tab-group>\r\n <!-- GENERAL -->\r\n <mat-tab label=\"general\">\r\n <div class=\"form-row\">\r\n <!-- id -->\r\n <mat-form-field>\r\n <mat-label>ID</mat-label>\r\n <input matInput [formField]=\"form.id\" />\r\n @if (form.id().getError('required') && (form.id().dirty() || form.id().touched())) {\r\n <mat-error>ID required</mat-error>\r\n }\r\n @if (form.id().getError('maxLength') && (form.id().dirty() || form.id().touched())) {\r\n <mat-error>ID too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n <!-- label -->\r\n <mat-form-field>\r\n <mat-label>label</mat-label>\r\n <input matInput [formField]=\"form.label\" />\r\n @if (form.label().getError('required') && (form.label().dirty() || form.label().touched())) {\r\n <mat-error>label required</mat-error>\r\n }\r\n @if (\r\n form.label().getError('maxLength') && (form.label().dirty() || form.label().touched())\r\n ) {\r\n <mat-error>label too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n <!-- color -->\r\n <mat-form-field class=\"color-input\">\r\n <mat-label>color</mat-label>\r\n <input matInput [formField]=\"form.colorKey\" />\r\n @if (\r\n form.colorKey().getError('pattern') &&\r\n (form.colorKey().dirty() || form.colorKey().touched())\r\n ) {\r\n <mat-error>invalid color key</mat-error>\r\n }\r\n <input\r\n type=\"color\"\r\n class=\"color-picker-input\"\r\n #colorPicker\r\n [value]=\"\r\n form.colorKey().value().length === 6\r\n ? '#' + form.colorKey().value()\r\n : '#000000'\r\n \"\r\n (input)=\"onColorPick(colorPicker.value)\"\r\n />\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matSuffix\r\n matTooltip=\"Pick color\"\r\n (click)=\"colorPicker.click()\"\r\n >\r\n <mat-icon>palette</mat-icon>\r\n </button>\r\n </mat-form-field>\r\n <div class=\"color-sample\" [style.--swatch-color]=\"'#' + form.colorKey().value()\"></div>\r\n </div>\r\n\r\n <!-- description -->\r\n <div>\r\n <mat-form-field class=\"long-text\">\r\n <mat-label>description</mat-label>\r\n <textarea matInput [formField]=\"form.description\" rows=\"2\"></textarea>\r\n @if (\r\n form.description().getError('maxLength') &&\r\n (form.description().dirty() || form.description().touched())\r\n ) {\r\n <mat-error>description too long</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n </mat-tab>\r\n\r\n <!-- PARTS -->\r\n <mat-tab label=\"parts\">\r\n <div>\r\n <button\r\n type=\"button\"\r\n mat-flat-button\r\n color=\"primary\"\r\n (click)=\"addPartDefinition()\"\r\n >\r\n <mat-icon>add_circle</mat-icon> part\r\n </button>\r\n </div>\r\n @if (form.partDefinitions().value().length) {\r\n <table>\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>required</th>\r\n <th>type ID</th>\r\n <th>role ID</th>\r\n <th>name</th>\r\n <th>group</th>\r\n <th>color</th>\r\n <th>description</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n @for (\r\n entry of form.partDefinitions().value();\r\n track entry;\r\n let i = $index;\r\n let first = $first;\r\n let last = $last\r\n ) {\r\n <tr [class.selected]=\"i === editedIndex()\">\r\n <td class=\"fit-width\">\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"primary\"\r\n matTooltip=\"Edit this part definition\"\r\n (click)=\"editPartDefinition(entry, i)\"\r\n >\r\n <mat-icon class=\"mat-primary\">edit</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Move this part definition up\"\r\n [disabled]=\"first\"\r\n (click)=\"movePartDefinitionUp(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 part definition down\"\r\n [disabled]=\"last\"\r\n (click)=\"movePartDefinitionDown(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 part definition\"\r\n (click)=\"deletePartDefinition(i)\"\r\n >\r\n <mat-icon class=\"mat-warn\">remove_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td class=\"fit-width\">\r\n <mat-checkbox\r\n [checked]=\"entry.isRequired\"\r\n disabled\r\n ></mat-checkbox>\r\n </td>\r\n <td>{{ entry.typeId }}</td>\r\n <td>{{ entry.roleId }}</td>\r\n <td>{{ entry.name }}</td>\r\n <td>{{ entry.groupKey }}</td>\r\n <td>\r\n <span\r\n class=\"color-swatch\"\r\n [style.background-color]=\"'#' + entry.colorKey\"\r\n [style.color]=\"('#' + entry.colorKey) | colorToContrast\"\r\n >\r\n {{ entry.colorKey }}\r\n </span>\r\n </td>\r\n <td>{{ entry.description | ellipsis: 50 }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n }\r\n @if (edited()) {\r\n <fieldset>\r\n <mat-expansion-panel [expanded]=\"edited()\" [disabled]=\"!edited()\">\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>Part #{{ editedIndex() + 1 }}</mat-panel-title>\r\n </mat-expansion-panel-header>\r\n <cadmus-part-definition-editor\r\n [facetModelSettings]=\"facetModelSettings()\"\r\n [hideSortKey]=\"true\"\r\n [definition]=\"edited()\"\r\n (definitionChange)=\"savePartDefinition($event!)\"\r\n (cancelEdit)=\"closePartDefinition()\"\r\n />\r\n </mat-expansion-panel>\r\n </fieldset>\r\n }\r\n </mat-tab>\r\n </mat-tab-group>\r\n\r\n <!-- buttons -->\r\n <div>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Discard changes\"\r\n (click)=\"cancel()\"\r\n >\r\n <mat-icon class=\"mat-warn\">clear</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Accept changes\"\r\n [disabled]=\"form().invalid() || !form().dirty()\"\r\n (click)=\"save()\"\r\n >\r\n <mat-icon class=\"mat-primary\">check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</div>\r\n",
|
|
680
|
+
styles: ["input[type=color].color-picker-input{display:none}.long-text{width:100%;max-width:800px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}table{width:100%;border-collapse:collapse;color:var(--mat-sys-on-surface-variant)}tbody tr:nth-child(odd){background-color:var(--mat-sys-surface-container)}th{text-align:left;font-weight:400;color:var(--mat-sys-on-surface-variant)}tbody tr:hover{background-color:var(--mat-sys-surface-container-high)}td.fit-width{width:1px;white-space:nowrap}tbody tr.selected{background-color:var(--mat-sys-secondary-container);color:var(--mat-sys-on-secondary-container)}.color-swatch{padding:2px 6px;border-radius:4px}.color-input{width:9em}.color-sample{width:32px;height:32px;border-radius:50%;background:var(--swatch-color);margin-top:-16px}\n"],
|
|
681
|
+
dependencies: [
|
|
682
|
+
{
|
|
683
|
+
kind: "directive",
|
|
684
|
+
type: FormField,
|
|
685
|
+
selector: "[formField]",
|
|
686
|
+
inputs: ["formField"],
|
|
687
|
+
exportAs: ["formField"]
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
kind: "ngmodule",
|
|
691
|
+
type: MatButtonModule
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
kind: "component",
|
|
695
|
+
type: i2.MatButton,
|
|
696
|
+
selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ",
|
|
697
|
+
inputs: ["matButton"],
|
|
698
|
+
exportAs: ["matButton", "matAnchor"]
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
kind: "component",
|
|
702
|
+
type: i2.MatIconButton,
|
|
703
|
+
selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
|
|
704
|
+
exportAs: ["matButton", "matAnchor"]
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
kind: "component",
|
|
708
|
+
type: MatCheckbox,
|
|
709
|
+
selector: "mat-checkbox",
|
|
710
|
+
inputs: [
|
|
711
|
+
"aria-label",
|
|
712
|
+
"aria-labelledby",
|
|
713
|
+
"aria-describedby",
|
|
714
|
+
"aria-expanded",
|
|
715
|
+
"aria-controls",
|
|
716
|
+
"aria-owns",
|
|
717
|
+
"id",
|
|
718
|
+
"required",
|
|
719
|
+
"labelPosition",
|
|
720
|
+
"name",
|
|
721
|
+
"value",
|
|
722
|
+
"disableRipple",
|
|
723
|
+
"tabIndex",
|
|
724
|
+
"color",
|
|
725
|
+
"disabledInteractive",
|
|
726
|
+
"checked",
|
|
727
|
+
"disabled",
|
|
728
|
+
"indeterminate"
|
|
729
|
+
],
|
|
730
|
+
outputs: ["change", "indeterminateChange"],
|
|
731
|
+
exportAs: ["matCheckbox"]
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
kind: "directive",
|
|
735
|
+
type: MatError,
|
|
736
|
+
selector: "mat-error, [matError]",
|
|
737
|
+
inputs: ["id"]
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
kind: "component",
|
|
741
|
+
type: MatExpansionPanel,
|
|
742
|
+
selector: "mat-expansion-panel",
|
|
743
|
+
inputs: ["hideToggle", "togglePosition"],
|
|
744
|
+
outputs: ["afterExpand", "afterCollapse"],
|
|
745
|
+
exportAs: ["matExpansionPanel"]
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
kind: "component",
|
|
749
|
+
type: MatExpansionPanelHeader,
|
|
750
|
+
selector: "mat-expansion-panel-header",
|
|
751
|
+
inputs: [
|
|
752
|
+
"expandedHeight",
|
|
753
|
+
"collapsedHeight",
|
|
754
|
+
"tabIndex"
|
|
755
|
+
]
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
kind: "directive",
|
|
759
|
+
type: MatExpansionPanelTitle,
|
|
760
|
+
selector: "mat-panel-title"
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
kind: "component",
|
|
764
|
+
type: MatFormField,
|
|
765
|
+
selector: "mat-form-field",
|
|
766
|
+
inputs: [
|
|
767
|
+
"hideRequiredMarker",
|
|
768
|
+
"color",
|
|
769
|
+
"floatLabel",
|
|
770
|
+
"appearance",
|
|
771
|
+
"subscriptSizing",
|
|
772
|
+
"hintLabel"
|
|
773
|
+
],
|
|
774
|
+
exportAs: ["matFormField"]
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
kind: "component",
|
|
778
|
+
type: MatIcon,
|
|
779
|
+
selector: "mat-icon",
|
|
780
|
+
inputs: [
|
|
781
|
+
"color",
|
|
782
|
+
"inline",
|
|
783
|
+
"svgIcon",
|
|
784
|
+
"fontSet",
|
|
785
|
+
"fontIcon"
|
|
786
|
+
],
|
|
787
|
+
exportAs: ["matIcon"]
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
kind: "directive",
|
|
791
|
+
type: MatInput,
|
|
792
|
+
selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
|
|
793
|
+
inputs: [
|
|
794
|
+
"disabled",
|
|
795
|
+
"id",
|
|
796
|
+
"placeholder",
|
|
797
|
+
"name",
|
|
798
|
+
"required",
|
|
799
|
+
"type",
|
|
800
|
+
"errorStateMatcher",
|
|
801
|
+
"aria-describedby",
|
|
802
|
+
"value",
|
|
803
|
+
"readonly",
|
|
804
|
+
"disabledInteractive"
|
|
805
|
+
],
|
|
806
|
+
exportAs: ["matInput"]
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
kind: "directive",
|
|
810
|
+
type: MatLabel,
|
|
811
|
+
selector: "mat-label"
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
kind: "directive",
|
|
815
|
+
type: MatSuffix,
|
|
816
|
+
selector: "[matSuffix], [matIconSuffix], [matTextSuffix]",
|
|
817
|
+
inputs: ["matTextSuffix"]
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
kind: "component",
|
|
821
|
+
type: MatTab,
|
|
822
|
+
selector: "mat-tab",
|
|
823
|
+
inputs: [
|
|
824
|
+
"disabled",
|
|
825
|
+
"label",
|
|
826
|
+
"aria-label",
|
|
827
|
+
"aria-labelledby",
|
|
828
|
+
"labelClass",
|
|
829
|
+
"bodyClass",
|
|
830
|
+
"id"
|
|
831
|
+
],
|
|
832
|
+
exportAs: ["matTab"]
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
kind: "component",
|
|
836
|
+
type: MatTabGroup,
|
|
837
|
+
selector: "mat-tab-group",
|
|
838
|
+
inputs: [
|
|
839
|
+
"color",
|
|
840
|
+
"fitInkBarToContent",
|
|
841
|
+
"mat-stretch-tabs",
|
|
842
|
+
"mat-align-tabs",
|
|
843
|
+
"dynamicHeight",
|
|
844
|
+
"selectedIndex",
|
|
845
|
+
"headerPosition",
|
|
846
|
+
"animationDuration",
|
|
847
|
+
"contentTabIndex",
|
|
848
|
+
"disablePagination",
|
|
849
|
+
"disableRipple",
|
|
850
|
+
"preserveContent",
|
|
851
|
+
"backgroundColor",
|
|
852
|
+
"aria-label",
|
|
853
|
+
"aria-labelledby"
|
|
854
|
+
],
|
|
855
|
+
outputs: [
|
|
856
|
+
"selectedIndexChange",
|
|
857
|
+
"focusChange",
|
|
858
|
+
"animationDone",
|
|
859
|
+
"selectedTabChange"
|
|
860
|
+
],
|
|
861
|
+
exportAs: ["matTabGroup"]
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
kind: "directive",
|
|
865
|
+
type: MatTooltip,
|
|
866
|
+
selector: "[matTooltip]",
|
|
867
|
+
inputs: [
|
|
868
|
+
"matTooltipPosition",
|
|
869
|
+
"matTooltipPositionAtOrigin",
|
|
870
|
+
"matTooltipDisabled",
|
|
871
|
+
"matTooltipShowDelay",
|
|
872
|
+
"matTooltipHideDelay",
|
|
873
|
+
"matTooltipTouchGestures",
|
|
874
|
+
"matTooltip",
|
|
875
|
+
"matTooltipClass"
|
|
876
|
+
],
|
|
877
|
+
exportAs: ["matTooltip"]
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
kind: "component",
|
|
881
|
+
type: PartDefinitionEditorComponent,
|
|
882
|
+
selector: "cadmus-part-definition-editor",
|
|
883
|
+
inputs: [
|
|
884
|
+
"definition",
|
|
885
|
+
"facetModelSettings",
|
|
886
|
+
"hideSortKey"
|
|
887
|
+
],
|
|
888
|
+
outputs: ["definitionChange", "cancelEdit"]
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
kind: "pipe",
|
|
892
|
+
type: ColorToContrastPipe,
|
|
893
|
+
name: "colorToContrast"
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
kind: "pipe",
|
|
897
|
+
type: EllipsisPipe,
|
|
898
|
+
name: "ellipsis"
|
|
899
|
+
}
|
|
900
|
+
],
|
|
901
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
902
|
+
});
|
|
903
|
+
};
|
|
904
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
905
|
+
minVersion: "12.0.0",
|
|
906
|
+
version: "22.2.0",
|
|
907
|
+
ngImport: i0,
|
|
908
|
+
type: FacetDefinitionEditorComponent,
|
|
909
|
+
decorators: [{
|
|
910
|
+
type: Component,
|
|
911
|
+
args: [{
|
|
912
|
+
selector: "cadmus-facet-definition-editor",
|
|
913
|
+
imports: [
|
|
914
|
+
FormField,
|
|
915
|
+
MatButtonModule,
|
|
916
|
+
MatCheckbox,
|
|
917
|
+
MatError,
|
|
918
|
+
MatExpansionPanel,
|
|
919
|
+
MatExpansionPanelHeader,
|
|
920
|
+
MatExpansionPanelTitle,
|
|
921
|
+
MatFormField,
|
|
922
|
+
MatIcon,
|
|
923
|
+
MatInput,
|
|
924
|
+
MatLabel,
|
|
925
|
+
MatSuffix,
|
|
926
|
+
MatTab,
|
|
927
|
+
MatTabGroup,
|
|
928
|
+
MatTooltip,
|
|
929
|
+
ColorToContrastPipe,
|
|
930
|
+
EllipsisPipe,
|
|
931
|
+
PartDefinitionEditorComponent
|
|
932
|
+
],
|
|
933
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
934
|
+
template: "<div>\r\n <mat-tab-group>\r\n <!-- GENERAL -->\r\n <mat-tab label=\"general\">\r\n <div class=\"form-row\">\r\n <!-- id -->\r\n <mat-form-field>\r\n <mat-label>ID</mat-label>\r\n <input matInput [formField]=\"form.id\" />\r\n @if (form.id().getError('required') && (form.id().dirty() || form.id().touched())) {\r\n <mat-error>ID required</mat-error>\r\n }\r\n @if (form.id().getError('maxLength') && (form.id().dirty() || form.id().touched())) {\r\n <mat-error>ID too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n <!-- label -->\r\n <mat-form-field>\r\n <mat-label>label</mat-label>\r\n <input matInput [formField]=\"form.label\" />\r\n @if (form.label().getError('required') && (form.label().dirty() || form.label().touched())) {\r\n <mat-error>label required</mat-error>\r\n }\r\n @if (\r\n form.label().getError('maxLength') && (form.label().dirty() || form.label().touched())\r\n ) {\r\n <mat-error>label too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n <!-- color -->\r\n <mat-form-field class=\"color-input\">\r\n <mat-label>color</mat-label>\r\n <input matInput [formField]=\"form.colorKey\" />\r\n @if (\r\n form.colorKey().getError('pattern') &&\r\n (form.colorKey().dirty() || form.colorKey().touched())\r\n ) {\r\n <mat-error>invalid color key</mat-error>\r\n }\r\n <input\r\n type=\"color\"\r\n class=\"color-picker-input\"\r\n #colorPicker\r\n [value]=\"\r\n form.colorKey().value().length === 6\r\n ? '#' + form.colorKey().value()\r\n : '#000000'\r\n \"\r\n (input)=\"onColorPick(colorPicker.value)\"\r\n />\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matSuffix\r\n matTooltip=\"Pick color\"\r\n (click)=\"colorPicker.click()\"\r\n >\r\n <mat-icon>palette</mat-icon>\r\n </button>\r\n </mat-form-field>\r\n <div class=\"color-sample\" [style.--swatch-color]=\"'#' + form.colorKey().value()\"></div>\r\n </div>\r\n\r\n <!-- description -->\r\n <div>\r\n <mat-form-field class=\"long-text\">\r\n <mat-label>description</mat-label>\r\n <textarea matInput [formField]=\"form.description\" rows=\"2\"></textarea>\r\n @if (\r\n form.description().getError('maxLength') &&\r\n (form.description().dirty() || form.description().touched())\r\n ) {\r\n <mat-error>description too long</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n </mat-tab>\r\n\r\n <!-- PARTS -->\r\n <mat-tab label=\"parts\">\r\n <div>\r\n <button\r\n type=\"button\"\r\n mat-flat-button\r\n color=\"primary\"\r\n (click)=\"addPartDefinition()\"\r\n >\r\n <mat-icon>add_circle</mat-icon> part\r\n </button>\r\n </div>\r\n @if (form.partDefinitions().value().length) {\r\n <table>\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>required</th>\r\n <th>type ID</th>\r\n <th>role ID</th>\r\n <th>name</th>\r\n <th>group</th>\r\n <th>color</th>\r\n <th>description</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n @for (\r\n entry of form.partDefinitions().value();\r\n track entry;\r\n let i = $index;\r\n let first = $first;\r\n let last = $last\r\n ) {\r\n <tr [class.selected]=\"i === editedIndex()\">\r\n <td class=\"fit-width\">\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"primary\"\r\n matTooltip=\"Edit this part definition\"\r\n (click)=\"editPartDefinition(entry, i)\"\r\n >\r\n <mat-icon class=\"mat-primary\">edit</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Move this part definition up\"\r\n [disabled]=\"first\"\r\n (click)=\"movePartDefinitionUp(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 part definition down\"\r\n [disabled]=\"last\"\r\n (click)=\"movePartDefinitionDown(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 part definition\"\r\n (click)=\"deletePartDefinition(i)\"\r\n >\r\n <mat-icon class=\"mat-warn\">remove_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td class=\"fit-width\">\r\n <mat-checkbox\r\n [checked]=\"entry.isRequired\"\r\n disabled\r\n ></mat-checkbox>\r\n </td>\r\n <td>{{ entry.typeId }}</td>\r\n <td>{{ entry.roleId }}</td>\r\n <td>{{ entry.name }}</td>\r\n <td>{{ entry.groupKey }}</td>\r\n <td>\r\n <span\r\n class=\"color-swatch\"\r\n [style.background-color]=\"'#' + entry.colorKey\"\r\n [style.color]=\"('#' + entry.colorKey) | colorToContrast\"\r\n >\r\n {{ entry.colorKey }}\r\n </span>\r\n </td>\r\n <td>{{ entry.description | ellipsis: 50 }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n }\r\n @if (edited()) {\r\n <fieldset>\r\n <mat-expansion-panel [expanded]=\"edited()\" [disabled]=\"!edited()\">\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>Part #{{ editedIndex() + 1 }}</mat-panel-title>\r\n </mat-expansion-panel-header>\r\n <cadmus-part-definition-editor\r\n [facetModelSettings]=\"facetModelSettings()\"\r\n [hideSortKey]=\"true\"\r\n [definition]=\"edited()\"\r\n (definitionChange)=\"savePartDefinition($event!)\"\r\n (cancelEdit)=\"closePartDefinition()\"\r\n />\r\n </mat-expansion-panel>\r\n </fieldset>\r\n }\r\n </mat-tab>\r\n </mat-tab-group>\r\n\r\n <!-- buttons -->\r\n <div>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Discard changes\"\r\n (click)=\"cancel()\"\r\n >\r\n <mat-icon class=\"mat-warn\">clear</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Accept changes\"\r\n [disabled]=\"form().invalid() || !form().dirty()\"\r\n (click)=\"save()\"\r\n >\r\n <mat-icon class=\"mat-primary\">check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</div>\r\n",
|
|
935
|
+
styles: ["input[type=color].color-picker-input{display:none}.long-text{width:100%;max-width:800px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}table{width:100%;border-collapse:collapse;color:var(--mat-sys-on-surface-variant)}tbody tr:nth-child(odd){background-color:var(--mat-sys-surface-container)}th{text-align:left;font-weight:400;color:var(--mat-sys-on-surface-variant)}tbody tr:hover{background-color:var(--mat-sys-surface-container-high)}td.fit-width{width:1px;white-space:nowrap}tbody tr.selected{background-color:var(--mat-sys-secondary-container);color:var(--mat-sys-on-secondary-container)}.color-swatch{padding:2px 6px;border-radius:4px}.color-input{width:9em}.color-sample{width:32px;height:32px;border-radius:50%;background:var(--swatch-color);margin-top:-16px}\n"]
|
|
936
|
+
}]
|
|
937
|
+
}],
|
|
938
|
+
ctorParameters: () => [{ type: i1.DialogService }],
|
|
939
|
+
propDecorators: {
|
|
940
|
+
definition: [{
|
|
941
|
+
type: i0.Input,
|
|
942
|
+
args: [{
|
|
943
|
+
isSignal: true,
|
|
944
|
+
alias: "definition",
|
|
945
|
+
required: false
|
|
946
|
+
}]
|
|
947
|
+
}, {
|
|
948
|
+
type: i0.Output,
|
|
949
|
+
args: ["definitionChange"]
|
|
950
|
+
}],
|
|
951
|
+
facetModelSettings: [{
|
|
952
|
+
type: i0.Input,
|
|
953
|
+
args: [{
|
|
954
|
+
isSignal: true,
|
|
955
|
+
alias: "facetModelSettings",
|
|
956
|
+
required: false
|
|
957
|
+
}]
|
|
958
|
+
}],
|
|
959
|
+
cancelEdit: [{
|
|
960
|
+
type: i0.Output,
|
|
961
|
+
args: ["cancelEdit"]
|
|
962
|
+
}]
|
|
963
|
+
}
|
|
964
|
+
});
|
|
965
|
+
var FacetDefinitionListEditorComponent = class FacetDefinitionListEditorComponent {
|
|
966
|
+
_dialogService;
|
|
967
|
+
_facetService;
|
|
968
|
+
_validator;
|
|
969
|
+
_snackbar;
|
|
970
|
+
edited = signal(void 0, ...ngDevMode ? [{ debugName: "edited" }] : /* istanbul ignore next */ []);
|
|
971
|
+
editedIndex = signal(-1, ...ngDevMode ? [{ debugName: "editedIndex" }] : /* istanbul ignore next */ []);
|
|
972
|
+
dirty = signal(false, ...ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []);
|
|
973
|
+
facets = signal([], ...ngDevMode ? [{ debugName: "facets" }] : /* istanbul ignore next */ []);
|
|
974
|
+
busy = signal(false, ...ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []);
|
|
975
|
+
saveResult = signal(void 0, ...ngDevMode ? [{ debugName: "saveResult" }] : /* istanbul ignore next */ []);
|
|
976
|
+
reloadNeeded = signal(false, ...ngDevMode ? [{ debugName: "reloadNeeded" }] : /* istanbul ignore next */ []);
|
|
977
|
+
validationResult = signal(void 0, ...ngDevMode ? [{ debugName: "validationResult" }] : /* istanbul ignore next */ []);
|
|
978
|
+
validationResultHasIssues = computed(() => {
|
|
979
|
+
const vr = this.validationResult();
|
|
980
|
+
return vr ? vr.hasErrors || vr.hasWarnings : false;
|
|
981
|
+
}, ...ngDevMode ? [{ debugName: "validationResultHasIssues" }] : /* istanbul ignore next */ []);
|
|
982
|
+
facetModelSettings = signal(void 0, ...ngDevMode ? [{ debugName: "facetModelSettings" }] : /* istanbul ignore next */ []);
|
|
983
|
+
dirtyChange = output();
|
|
984
|
+
editorClose = output();
|
|
985
|
+
constructor(_dialogService, _facetService, _validator, _snackbar) {
|
|
986
|
+
this._dialogService = _dialogService;
|
|
987
|
+
this._facetService = _facetService;
|
|
988
|
+
this._validator = _validator;
|
|
989
|
+
this._snackbar = _snackbar;
|
|
990
|
+
}
|
|
991
|
+
ngOnInit() {
|
|
992
|
+
this.busy.set(true);
|
|
993
|
+
this._facetService.getFacets().subscribe({
|
|
994
|
+
next: (facets) => {
|
|
995
|
+
this.facets.set(facets);
|
|
996
|
+
this.busy.set(false);
|
|
997
|
+
},
|
|
998
|
+
error: (error) => {
|
|
999
|
+
console.error(error);
|
|
1000
|
+
this.busy.set(false);
|
|
1001
|
+
this._snackbar.open("Error loading facets", "Close");
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
1004
|
+
this._facetService.getFacetModelSettings().subscribe({
|
|
1005
|
+
next: (settings) => {
|
|
1006
|
+
this.facetModelSettings.set(settings);
|
|
1007
|
+
},
|
|
1008
|
+
error: (error) => {
|
|
1009
|
+
console.error(error);
|
|
1010
|
+
this._snackbar.open("Error loading facet model settings", "Close");
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
addFacet() {
|
|
1015
|
+
const entry = {
|
|
1016
|
+
id: "new",
|
|
1017
|
+
label: "New facet",
|
|
1018
|
+
colorKey: "default",
|
|
1019
|
+
description: "",
|
|
1020
|
+
partDefinitions: []
|
|
1021
|
+
};
|
|
1022
|
+
this.editedIndex.set(-1);
|
|
1023
|
+
this.edited.set(entry);
|
|
1024
|
+
}
|
|
1025
|
+
editFacet(facet, index) {
|
|
1026
|
+
this.editedIndex.set(index);
|
|
1027
|
+
this.edited.set(structuredClone(facet));
|
|
1028
|
+
}
|
|
1029
|
+
closeFacet() {
|
|
1030
|
+
this.editedIndex.set(-1);
|
|
1031
|
+
this.edited.set(void 0);
|
|
1032
|
+
}
|
|
1033
|
+
saveFacet(facet) {
|
|
1034
|
+
const entries = [...this.facets()];
|
|
1035
|
+
if (this.editedIndex() === -1) entries.push(facet);
|
|
1036
|
+
else entries.splice(this.editedIndex(), 1, facet);
|
|
1037
|
+
this.facets.set(entries);
|
|
1038
|
+
this.closeFacet();
|
|
1039
|
+
this.dirty.set(true);
|
|
1040
|
+
this.dirtyChange.emit(true);
|
|
1041
|
+
}
|
|
1042
|
+
deleteFacet(index) {
|
|
1043
|
+
this._dialogService.confirm("Confirmation", `Delete facet ${this.edited()?.label}?`).subscribe((yes) => {
|
|
1044
|
+
if (yes) {
|
|
1045
|
+
if (this.editedIndex() === index) this.closeFacet();
|
|
1046
|
+
const entries = [...this.facets()];
|
|
1047
|
+
entries.splice(index, 1);
|
|
1048
|
+
this.facets.set(entries);
|
|
1049
|
+
this.dirty.set(true);
|
|
1050
|
+
this.dirtyChange.emit(true);
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
moveFacetUp(index) {
|
|
1055
|
+
if (index < 1) return;
|
|
1056
|
+
const facet = this.facets()[index];
|
|
1057
|
+
const facets = [...this.facets()];
|
|
1058
|
+
facets.splice(index, 1);
|
|
1059
|
+
facets.splice(index - 1, 0, facet);
|
|
1060
|
+
this.facets.set(facets);
|
|
1061
|
+
this.dirty.set(true);
|
|
1062
|
+
this.dirtyChange.emit(true);
|
|
1063
|
+
if (this.editedIndex() === index) this.editedIndex.set(index - 1);
|
|
1064
|
+
else if (this.editedIndex() === index - 1) this.editedIndex.set(index);
|
|
1065
|
+
}
|
|
1066
|
+
moveFacetDown(index) {
|
|
1067
|
+
if (index + 1 >= this.facets().length) return;
|
|
1068
|
+
const facet = this.facets()[index];
|
|
1069
|
+
const facets = [...this.facets()];
|
|
1070
|
+
facets.splice(index, 1);
|
|
1071
|
+
facets.splice(index + 1, 0, facet);
|
|
1072
|
+
this.facets.set(facets);
|
|
1073
|
+
this.dirty.set(true);
|
|
1074
|
+
this.dirtyChange.emit(true);
|
|
1075
|
+
if (this.editedIndex() === index) this.editedIndex.set(index + 1);
|
|
1076
|
+
else if (this.editedIndex() === index + 1) this.editedIndex.set(index);
|
|
1077
|
+
}
|
|
1078
|
+
reloadApp() {
|
|
1079
|
+
window.location.href = "/";
|
|
1080
|
+
}
|
|
1081
|
+
close() {
|
|
1082
|
+
this.editorClose.emit();
|
|
1083
|
+
}
|
|
1084
|
+
runValidation() {
|
|
1085
|
+
return this._validator.validate(this.facets(), this.facetModelSettings()).pipe(tap((result) => this.validationResult.set(result)));
|
|
1086
|
+
}
|
|
1087
|
+
validate() {
|
|
1088
|
+
this.runValidation().pipe(take(1)).subscribe();
|
|
1089
|
+
}
|
|
1090
|
+
doSave() {
|
|
1091
|
+
const facets = this.facets();
|
|
1092
|
+
this.busy.set(true);
|
|
1093
|
+
this.saveResult.set(void 0);
|
|
1094
|
+
from(facets).pipe(concatMap((facet) => this._facetService.addFacet(facet).pipe(map(() => true), catchError(() => of(false)))), toArray()).subscribe((results) => {
|
|
1095
|
+
const saved = [];
|
|
1096
|
+
const failed = [];
|
|
1097
|
+
results.forEach((ok, i) => {
|
|
1098
|
+
if (ok) saved.push(facets[i].id);
|
|
1099
|
+
else failed.push(facets[i].id);
|
|
1100
|
+
});
|
|
1101
|
+
this.busy.set(false);
|
|
1102
|
+
this.dirty.set(failed.length > 0);
|
|
1103
|
+
this.dirtyChange.emit(failed.length > 0);
|
|
1104
|
+
if (saved.length > 0) this.reloadNeeded.set(true);
|
|
1105
|
+
const parts = [];
|
|
1106
|
+
if (saved.length) parts.push(`Saved: ${saved.join(", ")}`);
|
|
1107
|
+
if (failed.length) parts.push(`Failed: ${failed.join(", ")}`);
|
|
1108
|
+
this.saveResult.set(parts.join(" | "));
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
confirmAndSave() {
|
|
1112
|
+
this._dialogService.confirm("Save facets", "Saving replaces ALL facet definitions on the server. This may affect every item in the database. Proceed?").subscribe((ok) => {
|
|
1113
|
+
if (ok) this.doSave();
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
downloadFacets() {
|
|
1117
|
+
const replacer = (_key, value) => value === null || value === false ? void 0 : value;
|
|
1118
|
+
const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(this.facets(), replacer, 2));
|
|
1119
|
+
const dlAnchorElem = document.createElement("a");
|
|
1120
|
+
dlAnchorElem.setAttribute("href", dataStr);
|
|
1121
|
+
dlAnchorElem.setAttribute("download", "facets.json");
|
|
1122
|
+
dlAnchorElem.click();
|
|
1123
|
+
}
|
|
1124
|
+
save() {
|
|
1125
|
+
if (!this.facets().length) return;
|
|
1126
|
+
this.runValidation().pipe(take(1)).subscribe((result) => {
|
|
1127
|
+
if (result.hasErrors) return;
|
|
1128
|
+
if (result.hasWarnings) {
|
|
1129
|
+
const warnCount = result.issues.filter((i) => i.severity === "warning").length;
|
|
1130
|
+
this._dialogService.confirm("Warnings", `There ${warnCount === 1 ? "is 1 warning" : `are ${warnCount} warnings`}. Review the validation results below. Proceed anyway?`).subscribe((ok) => {
|
|
1131
|
+
if (ok) this.confirmAndSave();
|
|
1132
|
+
});
|
|
1133
|
+
} else this.confirmAndSave();
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1137
|
+
minVersion: "12.0.0",
|
|
1138
|
+
version: "22.2.0",
|
|
1139
|
+
ngImport: i0,
|
|
1140
|
+
type: FacetDefinitionListEditorComponent,
|
|
1141
|
+
deps: [
|
|
1142
|
+
{ token: i1.DialogService },
|
|
1143
|
+
{ token: i1$1.FacetService },
|
|
1144
|
+
{ token: FacetDefinitionValidatorService },
|
|
1145
|
+
{ token: i4.MatSnackBar }
|
|
1146
|
+
],
|
|
1147
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
1148
|
+
});
|
|
1149
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
1150
|
+
minVersion: "17.0.0",
|
|
1151
|
+
version: "22.2.0",
|
|
1152
|
+
type: FacetDefinitionListEditorComponent,
|
|
1153
|
+
isStandalone: true,
|
|
1154
|
+
selector: "cadmus-facet-definition-list-editor",
|
|
1155
|
+
outputs: {
|
|
1156
|
+
dirtyChange: "dirtyChange",
|
|
1157
|
+
editorClose: "editorClose"
|
|
1158
|
+
},
|
|
1159
|
+
ngImport: i0,
|
|
1160
|
+
template: "<div>\r\n <div class=\"form-row\">\r\n <button type=\"button\" mat-flat-button color=\"primary\" (click)=\"addFacet()\">\r\n <mat-icon>add_circle</mat-icon> facet\r\n </button>\r\n <button type=\"button\" mat-flat-button (click)=\"validate()\">\r\n <mat-icon>fact_check</mat-icon> validate\r\n </button>\r\n <button type=\"button\" mat-flat-button (click)=\"downloadFacets()\">\r\n <mat-icon>download</mat-icon> download\r\n </button>\r\n <button type=\"button\" mat-flat-button color=\"warn\" (click)=\"save()\">\r\n <mat-icon>save</mat-icon> save\r\n </button>\r\n </div>\r\n <div>\r\n @if (busy()) {\r\n <mat-progress-bar mode=\"indeterminate\" color=\"accent\" />\r\n }\r\n </div>\r\n @if (validationResult(); as vr) {\r\n <mat-expansion-panel [expanded]=\"true\">\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>Validation result</mat-panel-title>\r\n <mat-panel-description\r\n [style.color]=\"validationResultHasIssues() ? 'warn' : 'primary'\"\r\n >\r\n {{ vr.issues.length }} result{{ vr.issues.length !== 1 ? \"s\" : \"\" }}\r\n </mat-panel-description>\r\n </mat-expansion-panel-header>\r\n <div class=\"validation-result\">\r\n @if (!vr.issues.length) {\r\n <span>No issues found.</span>\r\n } @else {\r\n <div class=\"validation-issues\">\r\n @for (issue of vr.issues; track $index) {\r\n <div class=\"validation-issue {{ issue.severity }}\">\r\n <mat-icon>{{\r\n issue.severity === \"error\"\r\n ? \"error\"\r\n : issue.severity === \"warning\"\r\n ? \"warning\"\r\n : \"info\"\r\n }}</mat-icon>\r\n <span>{{ issue.message }}</span>\r\n </div>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </mat-expansion-panel>\r\n }\r\n @if (reloadNeeded()) {\r\n <div class=\"reload-notice\">\r\n <mat-icon>info</mat-icon>\r\n <span\r\n >Facet definitions are cached at startup. Please reload the app to apply\r\n the changes.</span\r\n >\r\n <button\r\n type=\"button\"\r\n mat-flat-button\r\n color=\"primary\"\r\n (click)=\"reloadApp()\"\r\n >\r\n <mat-icon>refresh</mat-icon>\r\n reload app\r\n </button>\r\n </div>\r\n }\r\n @if (facets().length) {\r\n <table class=\"margin-top\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>ID</th>\r\n <th>label</th>\r\n <th>color</th>\r\n <th>parts</th>\r\n <th>description</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n @for (\r\n entry of facets();\r\n track entry;\r\n let i = $index;\r\n let first = $first;\r\n let last = $last\r\n ) {\r\n <tr [class.selected]=\"i === editedIndex()\">\r\n <td class=\"fit-width\">\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"primary\"\r\n matTooltip=\"Edit this facet\"\r\n (click)=\"editFacet(entry, i)\"\r\n >\r\n <mat-icon class=\"mat-primary\">edit</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Move this facet up\"\r\n [disabled]=\"first\"\r\n (click)=\"moveFacetUp(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 facet down\"\r\n [disabled]=\"last\"\r\n (click)=\"moveFacetDown(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 facet\"\r\n (click)=\"deleteFacet(i)\"\r\n >\r\n <mat-icon class=\"mat-warn\">remove_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ entry.id }}</td>\r\n <td>{{ entry.label }}</td>\r\n <td>\r\n <span\r\n class=\"color-swatch\"\r\n [style.background-color]=\"'#' + entry.colorKey\"\r\n [style.color]=\"'#' + entry.colorKey | colorToContrast\"\r\n >\r\n {{ entry.colorKey }}\r\n </span>\r\n </td>\r\n <td>{{ entry.partDefinitions.length }}</td>\r\n <td>{{ entry.description | ellipsis: 50 }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n }\r\n @if (edited()) {\r\n <fieldset>\r\n <mat-expansion-panel [expanded]=\"edited()\" [disabled]=\"!edited()\">\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>Facet #{{ editedIndex() + 1 }}</mat-panel-title>\r\n </mat-expansion-panel-header>\r\n <cadmus-facet-definition-editor\r\n [facetModelSettings]=\"facetModelSettings()\"\r\n [definition]=\"edited()\"\r\n (definitionChange)=\"saveFacet($event!)\"\r\n (cancelEdit)=\"closeFacet()\"\r\n />\r\n </mat-expansion-panel>\r\n </fieldset>\r\n }\r\n</div>\r\n",
|
|
1161
|
+
styles: ["table{width:100%;border-collapse:collapse;color:var(--mat-sys-on-surface-variant)}tbody tr:nth-child(odd){background-color:var(--mat-sys-surface-container)}th{text-align:left;font-weight:400;color:var(--mat-sys-on-surface-variant)}tbody tr:hover{background-color:var(--mat-sys-surface-container-high)}td.fit-width{width:1px;white-space:nowrap}tbody tr.selected{background-color:var(--mat-sys-secondary-container);color:var(--mat-sys-on-secondary-container)}fieldset{border:1px solid silver;border-radius:6px;padding:6px}.validation-result{margin:8px 0;max-height:800px;overflow:auto}.validation-issues{display:flex;flex-direction:column;gap:4px;margin:8px 0;font-size:.9em}.validation-issue{display:flex;align-items:center;gap:4px}.validation-issue.error{color:var(--mat-sys-error)}.validation-issue.warning{color:var(--mat-sys-tertiary)}.reload-notice{display:flex;gap:8px;align-items:center;margin:16px 0;padding:12px;background-color:var(--mat-sys-warning);border:1px solid var(--mat-sys-warning);border-radius:4px;color:var(--mat-sys-on-warning)}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.color-swatch{padding:2px 6px;border-radius:4px}.margin-top{margin-top:1rem}\n"],
|
|
1162
|
+
dependencies: [
|
|
1163
|
+
{
|
|
1164
|
+
kind: "ngmodule",
|
|
1165
|
+
type: MatButtonModule
|
|
1166
|
+
},
|
|
1167
|
+
{
|
|
1168
|
+
kind: "component",
|
|
1169
|
+
type: i2.MatButton,
|
|
1170
|
+
selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ",
|
|
1171
|
+
inputs: ["matButton"],
|
|
1172
|
+
exportAs: ["matButton", "matAnchor"]
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
kind: "component",
|
|
1176
|
+
type: i2.MatIconButton,
|
|
1177
|
+
selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
|
|
1178
|
+
exportAs: ["matButton", "matAnchor"]
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
kind: "component",
|
|
1182
|
+
type: MatExpansionPanel,
|
|
1183
|
+
selector: "mat-expansion-panel",
|
|
1184
|
+
inputs: ["hideToggle", "togglePosition"],
|
|
1185
|
+
outputs: ["afterExpand", "afterCollapse"],
|
|
1186
|
+
exportAs: ["matExpansionPanel"]
|
|
1187
|
+
},
|
|
1188
|
+
{
|
|
1189
|
+
kind: "directive",
|
|
1190
|
+
type: MatExpansionPanelDescription,
|
|
1191
|
+
selector: "mat-panel-description"
|
|
1192
|
+
},
|
|
1193
|
+
{
|
|
1194
|
+
kind: "component",
|
|
1195
|
+
type: MatExpansionPanelHeader,
|
|
1196
|
+
selector: "mat-expansion-panel-header",
|
|
1197
|
+
inputs: [
|
|
1198
|
+
"expandedHeight",
|
|
1199
|
+
"collapsedHeight",
|
|
1200
|
+
"tabIndex"
|
|
1201
|
+
]
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
kind: "directive",
|
|
1205
|
+
type: MatExpansionPanelTitle,
|
|
1206
|
+
selector: "mat-panel-title"
|
|
1207
|
+
},
|
|
1208
|
+
{
|
|
1209
|
+
kind: "component",
|
|
1210
|
+
type: MatIcon,
|
|
1211
|
+
selector: "mat-icon",
|
|
1212
|
+
inputs: [
|
|
1213
|
+
"color",
|
|
1214
|
+
"inline",
|
|
1215
|
+
"svgIcon",
|
|
1216
|
+
"fontSet",
|
|
1217
|
+
"fontIcon"
|
|
1218
|
+
],
|
|
1219
|
+
exportAs: ["matIcon"]
|
|
1220
|
+
},
|
|
1221
|
+
{
|
|
1222
|
+
kind: "directive",
|
|
1223
|
+
type: MatTooltip,
|
|
1224
|
+
selector: "[matTooltip]",
|
|
1225
|
+
inputs: [
|
|
1226
|
+
"matTooltipPosition",
|
|
1227
|
+
"matTooltipPositionAtOrigin",
|
|
1228
|
+
"matTooltipDisabled",
|
|
1229
|
+
"matTooltipShowDelay",
|
|
1230
|
+
"matTooltipHideDelay",
|
|
1231
|
+
"matTooltipTouchGestures",
|
|
1232
|
+
"matTooltip",
|
|
1233
|
+
"matTooltipClass"
|
|
1234
|
+
],
|
|
1235
|
+
exportAs: ["matTooltip"]
|
|
1236
|
+
},
|
|
1237
|
+
{
|
|
1238
|
+
kind: "component",
|
|
1239
|
+
type: MatProgressBar,
|
|
1240
|
+
selector: "mat-progress-bar",
|
|
1241
|
+
inputs: [
|
|
1242
|
+
"color",
|
|
1243
|
+
"value",
|
|
1244
|
+
"bufferValue",
|
|
1245
|
+
"mode"
|
|
1246
|
+
],
|
|
1247
|
+
outputs: ["animationEnd"],
|
|
1248
|
+
exportAs: ["matProgressBar"]
|
|
1249
|
+
},
|
|
1250
|
+
{
|
|
1251
|
+
kind: "component",
|
|
1252
|
+
type: FacetDefinitionEditorComponent,
|
|
1253
|
+
selector: "cadmus-facet-definition-editor",
|
|
1254
|
+
inputs: ["definition", "facetModelSettings"],
|
|
1255
|
+
outputs: ["definitionChange", "cancelEdit"]
|
|
1256
|
+
},
|
|
1257
|
+
{
|
|
1258
|
+
kind: "pipe",
|
|
1259
|
+
type: ColorToContrastPipe,
|
|
1260
|
+
name: "colorToContrast"
|
|
1261
|
+
},
|
|
1262
|
+
{
|
|
1263
|
+
kind: "pipe",
|
|
1264
|
+
type: EllipsisPipe,
|
|
1265
|
+
name: "ellipsis"
|
|
1266
|
+
}
|
|
1267
|
+
],
|
|
1268
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
1269
|
+
});
|
|
1270
|
+
};
|
|
1271
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1272
|
+
minVersion: "12.0.0",
|
|
1273
|
+
version: "22.2.0",
|
|
1274
|
+
ngImport: i0,
|
|
1275
|
+
type: FacetDefinitionListEditorComponent,
|
|
1276
|
+
decorators: [{
|
|
1277
|
+
type: Component,
|
|
1278
|
+
args: [{
|
|
1279
|
+
selector: "cadmus-facet-definition-list-editor",
|
|
1280
|
+
imports: [
|
|
1281
|
+
MatButtonModule,
|
|
1282
|
+
MatExpansionPanel,
|
|
1283
|
+
MatExpansionPanelDescription,
|
|
1284
|
+
MatExpansionPanelHeader,
|
|
1285
|
+
MatExpansionPanelTitle,
|
|
1286
|
+
MatIcon,
|
|
1287
|
+
MatTooltip,
|
|
1288
|
+
MatProgressBar,
|
|
1289
|
+
ColorToContrastPipe,
|
|
1290
|
+
EllipsisPipe,
|
|
1291
|
+
FacetDefinitionEditorComponent
|
|
1292
|
+
],
|
|
1293
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1294
|
+
template: "<div>\r\n <div class=\"form-row\">\r\n <button type=\"button\" mat-flat-button color=\"primary\" (click)=\"addFacet()\">\r\n <mat-icon>add_circle</mat-icon> facet\r\n </button>\r\n <button type=\"button\" mat-flat-button (click)=\"validate()\">\r\n <mat-icon>fact_check</mat-icon> validate\r\n </button>\r\n <button type=\"button\" mat-flat-button (click)=\"downloadFacets()\">\r\n <mat-icon>download</mat-icon> download\r\n </button>\r\n <button type=\"button\" mat-flat-button color=\"warn\" (click)=\"save()\">\r\n <mat-icon>save</mat-icon> save\r\n </button>\r\n </div>\r\n <div>\r\n @if (busy()) {\r\n <mat-progress-bar mode=\"indeterminate\" color=\"accent\" />\r\n }\r\n </div>\r\n @if (validationResult(); as vr) {\r\n <mat-expansion-panel [expanded]=\"true\">\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>Validation result</mat-panel-title>\r\n <mat-panel-description\r\n [style.color]=\"validationResultHasIssues() ? 'warn' : 'primary'\"\r\n >\r\n {{ vr.issues.length }} result{{ vr.issues.length !== 1 ? \"s\" : \"\" }}\r\n </mat-panel-description>\r\n </mat-expansion-panel-header>\r\n <div class=\"validation-result\">\r\n @if (!vr.issues.length) {\r\n <span>No issues found.</span>\r\n } @else {\r\n <div class=\"validation-issues\">\r\n @for (issue of vr.issues; track $index) {\r\n <div class=\"validation-issue {{ issue.severity }}\">\r\n <mat-icon>{{\r\n issue.severity === \"error\"\r\n ? \"error\"\r\n : issue.severity === \"warning\"\r\n ? \"warning\"\r\n : \"info\"\r\n }}</mat-icon>\r\n <span>{{ issue.message }}</span>\r\n </div>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </mat-expansion-panel>\r\n }\r\n @if (reloadNeeded()) {\r\n <div class=\"reload-notice\">\r\n <mat-icon>info</mat-icon>\r\n <span\r\n >Facet definitions are cached at startup. Please reload the app to apply\r\n the changes.</span\r\n >\r\n <button\r\n type=\"button\"\r\n mat-flat-button\r\n color=\"primary\"\r\n (click)=\"reloadApp()\"\r\n >\r\n <mat-icon>refresh</mat-icon>\r\n reload app\r\n </button>\r\n </div>\r\n }\r\n @if (facets().length) {\r\n <table class=\"margin-top\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>ID</th>\r\n <th>label</th>\r\n <th>color</th>\r\n <th>parts</th>\r\n <th>description</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n @for (\r\n entry of facets();\r\n track entry;\r\n let i = $index;\r\n let first = $first;\r\n let last = $last\r\n ) {\r\n <tr [class.selected]=\"i === editedIndex()\">\r\n <td class=\"fit-width\">\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"primary\"\r\n matTooltip=\"Edit this facet\"\r\n (click)=\"editFacet(entry, i)\"\r\n >\r\n <mat-icon class=\"mat-primary\">edit</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Move this facet up\"\r\n [disabled]=\"first\"\r\n (click)=\"moveFacetUp(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 facet down\"\r\n [disabled]=\"last\"\r\n (click)=\"moveFacetDown(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 facet\"\r\n (click)=\"deleteFacet(i)\"\r\n >\r\n <mat-icon class=\"mat-warn\">remove_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ entry.id }}</td>\r\n <td>{{ entry.label }}</td>\r\n <td>\r\n <span\r\n class=\"color-swatch\"\r\n [style.background-color]=\"'#' + entry.colorKey\"\r\n [style.color]=\"'#' + entry.colorKey | colorToContrast\"\r\n >\r\n {{ entry.colorKey }}\r\n </span>\r\n </td>\r\n <td>{{ entry.partDefinitions.length }}</td>\r\n <td>{{ entry.description | ellipsis: 50 }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n }\r\n @if (edited()) {\r\n <fieldset>\r\n <mat-expansion-panel [expanded]=\"edited()\" [disabled]=\"!edited()\">\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>Facet #{{ editedIndex() + 1 }}</mat-panel-title>\r\n </mat-expansion-panel-header>\r\n <cadmus-facet-definition-editor\r\n [facetModelSettings]=\"facetModelSettings()\"\r\n [definition]=\"edited()\"\r\n (definitionChange)=\"saveFacet($event!)\"\r\n (cancelEdit)=\"closeFacet()\"\r\n />\r\n </mat-expansion-panel>\r\n </fieldset>\r\n }\r\n</div>\r\n",
|
|
1295
|
+
styles: ["table{width:100%;border-collapse:collapse;color:var(--mat-sys-on-surface-variant)}tbody tr:nth-child(odd){background-color:var(--mat-sys-surface-container)}th{text-align:left;font-weight:400;color:var(--mat-sys-on-surface-variant)}tbody tr:hover{background-color:var(--mat-sys-surface-container-high)}td.fit-width{width:1px;white-space:nowrap}tbody tr.selected{background-color:var(--mat-sys-secondary-container);color:var(--mat-sys-on-secondary-container)}fieldset{border:1px solid silver;border-radius:6px;padding:6px}.validation-result{margin:8px 0;max-height:800px;overflow:auto}.validation-issues{display:flex;flex-direction:column;gap:4px;margin:8px 0;font-size:.9em}.validation-issue{display:flex;align-items:center;gap:4px}.validation-issue.error{color:var(--mat-sys-error)}.validation-issue.warning{color:var(--mat-sys-tertiary)}.reload-notice{display:flex;gap:8px;align-items:center;margin:16px 0;padding:12px;background-color:var(--mat-sys-warning);border:1px solid var(--mat-sys-warning);border-radius:4px;color:var(--mat-sys-on-warning)}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.color-swatch{padding:2px 6px;border-radius:4px}.margin-top{margin-top:1rem}\n"]
|
|
1296
|
+
}]
|
|
1297
|
+
}],
|
|
1298
|
+
ctorParameters: () => [
|
|
1299
|
+
{ type: i1.DialogService },
|
|
1300
|
+
{ type: i1$1.FacetService },
|
|
1301
|
+
{ type: FacetDefinitionValidatorService },
|
|
1302
|
+
{ type: i4.MatSnackBar }
|
|
1303
|
+
],
|
|
1304
|
+
propDecorators: {
|
|
1305
|
+
dirtyChange: [{
|
|
1306
|
+
type: i0.Output,
|
|
1307
|
+
args: ["dirtyChange"]
|
|
1308
|
+
}],
|
|
1309
|
+
editorClose: [{
|
|
1310
|
+
type: i0.Output,
|
|
1311
|
+
args: ["editorClose"]
|
|
1312
|
+
}]
|
|
1313
|
+
}
|
|
1314
|
+
});
|
|
1315
|
+
var FacetEditPageComponent = class FacetEditPageComponent {
|
|
1316
|
+
_dirty = signal(false, ...ngDevMode ? [{ debugName: "_dirty" }] : /* istanbul ignore next */ []);
|
|
1317
|
+
canDeactivate() {
|
|
1318
|
+
return !this._dirty();
|
|
1319
|
+
}
|
|
1320
|
+
onDirtyChange(dirty) {
|
|
1321
|
+
this._dirty.set(dirty);
|
|
1322
|
+
}
|
|
1323
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1324
|
+
minVersion: "12.0.0",
|
|
1325
|
+
version: "22.2.0",
|
|
1326
|
+
ngImport: i0,
|
|
1327
|
+
type: FacetEditPageComponent,
|
|
1328
|
+
deps: [],
|
|
1329
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
1330
|
+
});
|
|
1331
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
1332
|
+
minVersion: "14.0.0",
|
|
1333
|
+
version: "22.2.0",
|
|
1334
|
+
type: FacetEditPageComponent,
|
|
1335
|
+
isStandalone: true,
|
|
1336
|
+
selector: "cadmus-facet-edit-page",
|
|
1337
|
+
ngImport: i0,
|
|
1338
|
+
template: "<mat-card>\r\n <mat-card-header>\r\n <mat-icon mat-card-avatar>dashboard</mat-icon>\r\n <mat-card-title>Edit Facets</mat-card-title>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <div class=\"margin-top\">\r\n <cadmus-facet-definition-list-editor (dirtyChange)=\"onDirtyChange($event)\" />\r\n </div>\r\n </mat-card-content>\r\n</mat-card>\r\n",
|
|
1339
|
+
styles: [".margin-top{margin-top:1rem}\n"],
|
|
1340
|
+
dependencies: [
|
|
1341
|
+
{
|
|
1342
|
+
kind: "component",
|
|
1343
|
+
type: MatCard,
|
|
1344
|
+
selector: "mat-card",
|
|
1345
|
+
inputs: ["appearance"],
|
|
1346
|
+
exportAs: ["matCard"]
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
kind: "directive",
|
|
1350
|
+
type: MatCardContent,
|
|
1351
|
+
selector: "mat-card-content"
|
|
1352
|
+
},
|
|
1353
|
+
{
|
|
1354
|
+
kind: "component",
|
|
1355
|
+
type: MatCardHeader,
|
|
1356
|
+
selector: "mat-card-header"
|
|
1357
|
+
},
|
|
1358
|
+
{
|
|
1359
|
+
kind: "directive",
|
|
1360
|
+
type: MatCardTitle,
|
|
1361
|
+
selector: "mat-card-title, [mat-card-title], [matCardTitle]"
|
|
1362
|
+
},
|
|
1363
|
+
{
|
|
1364
|
+
kind: "component",
|
|
1365
|
+
type: MatIcon,
|
|
1366
|
+
selector: "mat-icon",
|
|
1367
|
+
inputs: [
|
|
1368
|
+
"color",
|
|
1369
|
+
"inline",
|
|
1370
|
+
"svgIcon",
|
|
1371
|
+
"fontSet",
|
|
1372
|
+
"fontIcon"
|
|
1373
|
+
],
|
|
1374
|
+
exportAs: ["matIcon"]
|
|
1375
|
+
},
|
|
1376
|
+
{
|
|
1377
|
+
kind: "component",
|
|
1378
|
+
type: FacetDefinitionListEditorComponent,
|
|
1379
|
+
selector: "cadmus-facet-definition-list-editor",
|
|
1380
|
+
outputs: ["dirtyChange", "editorClose"]
|
|
1381
|
+
}
|
|
1382
|
+
],
|
|
1383
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
1384
|
+
});
|
|
1385
|
+
};
|
|
1386
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1387
|
+
minVersion: "12.0.0",
|
|
1388
|
+
version: "22.2.0",
|
|
1389
|
+
ngImport: i0,
|
|
1390
|
+
type: FacetEditPageComponent,
|
|
1391
|
+
decorators: [{
|
|
1392
|
+
type: Component,
|
|
1393
|
+
args: [{
|
|
1394
|
+
selector: "cadmus-facet-edit-page",
|
|
1395
|
+
imports: [
|
|
1396
|
+
MatCard,
|
|
1397
|
+
MatCardContent,
|
|
1398
|
+
MatCardHeader,
|
|
1399
|
+
MatCardTitle,
|
|
1400
|
+
MatIcon,
|
|
1401
|
+
FacetDefinitionListEditorComponent
|
|
1402
|
+
],
|
|
1403
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1404
|
+
template: "<mat-card>\r\n <mat-card-header>\r\n <mat-icon mat-card-avatar>dashboard</mat-icon>\r\n <mat-card-title>Edit Facets</mat-card-title>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <div class=\"margin-top\">\r\n <cadmus-facet-definition-list-editor (dirtyChange)=\"onDirtyChange($event)\" />\r\n </div>\r\n </mat-card-content>\r\n</mat-card>\r\n",
|
|
1405
|
+
styles: [".margin-top{margin-top:1rem}\n"]
|
|
1406
|
+
}]
|
|
1407
|
+
}]
|
|
1408
|
+
});
|
|
1409
|
+
const CADMUS_PROFILE_EDIT_ROUTES = [{
|
|
1410
|
+
path: "facets",
|
|
1411
|
+
pathMatch: "full",
|
|
1412
|
+
component: FacetEditPageComponent,
|
|
1413
|
+
canDeactivate: [pendingChangesGuard]
|
|
1414
|
+
}];
|
|
1027
1415
|
export { CADMUS_PROFILE_EDIT_ROUTES, FacetDefinitionEditorComponent, FacetDefinitionListEditorComponent, FacetDefinitionValidatorService, FacetEditPageComponent, PartDefinitionEditorComponent };
|
|
1028
|
-
|
|
1416
|
+
|
|
1417
|
+
//# sourceMappingURL=myrmidon-cadmus-profile-editor.mjs.map
|