@myrmidon/cadmus-profile-editor 1.0.0 → 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,1029 +1,1417 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, model, input, computed, output, effect, ChangeDetectionStrategy, Component, signal } from '@angular/core';
3
- import { of, from } from 'rxjs';
4
- import { map, tap, take, concatMap, catchError, toArray } from 'rxjs/operators';
5
- import * as i1 from '@myrmidon/cadmus-api';
6
- import * as i1$1 from '@angular/forms';
7
- import { Validators, ReactiveFormsModule } from '@angular/forms';
8
- import * as i3 from '@angular/material/button';
9
- import { MatIconButton, MatButtonModule } from '@angular/material/button';
10
- import { MatCheckbox } from '@angular/material/checkbox';
11
- import { MatSuffix, MatError as MatError$1, MatFormField as MatFormField$1, MatLabel as MatLabel$1 } from '@angular/material/form-field';
12
- import { MatExpansionPanel, MatExpansionPanelHeader, MatExpansionPanelTitle, MatExpansionPanelDescription } from '@angular/material/expansion';
13
- import { MatIcon } from '@angular/material/icon';
14
- import { MatError, MatFormField, MatInput, MatLabel } from '@angular/material/input';
15
- import { MatTab, MatTabGroup } from '@angular/material/tabs';
16
- import { MatTooltip } from '@angular/material/tooltip';
17
- import { ColorToContrastPipe, EllipsisPipe, StringToColorPipe } from '@myrmidon/ngx-tools';
18
- import { toSignal } from '@angular/core/rxjs-interop';
19
- import { MatOption, MatSelect } from '@angular/material/select';
20
- import * as i2 from '@myrmidon/ngx-mat-tools';
21
- import { MatProgressBar } from '@angular/material/progress-bar';
22
- import * as i4 from '@angular/material/snack-bar';
23
- import { MatCard, MatCardContent, MatCardHeader, MatCardTitle } from '@angular/material/card';
24
- import { pendingChangesGuard } from '@myrmidon/cadmus-core';
25
-
26
- /**
27
- * Validates a list of {@link FacetDefinition} objects before they are persisted.
28
- *
29
- * Rules:
30
- * - duplicate facet ID → error
31
- * - facet ID still set to "new" → warning (unfilled placeholder)
32
- * - duplicate facet label → error
33
- * - duplicate facet color → info
34
- * - duplicate facet description → info
35
- * - facet with no part definitions → error
36
- * - within a facet: two parts with same typeId AND same roleId
37
- * (including both empty/null) → error
38
- * (one with a roleId and one without is valid: they serve different roles)
39
- * - within a facet: duplicate part color → info
40
- * - within a facet: duplicate part description → info
41
- * - (when facetModelSettings is provided) for each part/fragment entry in the
42
- * settings, each thesaurus ID listed in thesauriIds is checked against the
43
- * existing thesauri: missing required thesauri (prefixed with "*") → error;
44
- * missing optional thesauri → info.
45
- */
46
- class FacetDefinitionValidatorService {
47
- _thesaurusService;
48
- constructor(_thesaurusService) {
49
- this._thesaurusService = _thesaurusService;
50
- }
51
- buildResult(issues) {
52
- return {
53
- issues,
54
- hasErrors: issues.some((i) => i.severity === 'error'),
55
- hasWarnings: issues.some((i) => i.severity === 'warning'),
56
- hasInfos: issues.some((i) => i.severity === 'info'),
57
- };
58
- }
59
- checkThesauri(issues, existingIds, entries, kind) {
60
- for (const [typeId, entry] of Object.entries(entries)) {
61
- for (const rawId of entry.thesauriIds ?? []) {
62
- const required = rawId.startsWith('*');
63
- const bareId = required ? rawId.substring(1) : rawId;
64
- if (!existingIds.has(bareId)) {
65
- if (required) {
66
- issues.push({
67
- severity: 'error',
68
- message: `${kind} "${typeId}" requires thesaurus "${bareId}" which does not exist.`,
69
- });
70
- }
71
- else {
72
- issues.push({
73
- severity: 'info',
74
- message: `${kind} "${typeId}" uses optional thesaurus "${bareId}" which does not exist.`,
75
- });
76
- }
77
- }
78
- }
79
- }
80
- }
81
- /**
82
- * Validate the given list of facet definitions and return a result
83
- * containing all issues found.
84
- * @param facets The list of facet definitions to validate.
85
- * @param facetModelSettings Optional settings; when provided the thesauri
86
- * referenced by each part/fragment are checked against the server.
87
- */
88
- validate(facets, facetModelSettings) {
89
- const issues = [];
90
- const seenIds = new Set();
91
- const seenLabels = new Set();
92
- const seenColors = new Set();
93
- const seenDescriptions = new Set();
94
- for (const facet of facets) {
95
- const label = `facet "${facet.id}"`;
96
- // duplicate / placeholder ID
97
- if (!facet.id) {
98
- issues.push({ severity: 'error', message: 'A facet has an empty ID.' });
99
- }
100
- else if (facet.id === 'new') {
101
- issues.push({
102
- severity: 'warning',
103
- message: `Facet has placeholder ID "new" — please assign a real ID.`,
104
- });
105
- }
106
- else if (seenIds.has(facet.id)) {
107
- issues.push({
108
- severity: 'error',
109
- message: `Duplicate facet ID: "${facet.id}".`,
110
- });
111
- }
112
- else {
113
- seenIds.add(facet.id);
114
- }
115
- // duplicate label
116
- if (facet.label) {
117
- if (seenLabels.has(facet.label)) {
118
- issues.push({
119
- severity: 'error',
120
- message: `Duplicate facet label "${facet.label}" in ${label}.`,
121
- });
122
- }
123
- else {
124
- seenLabels.add(facet.label);
125
- }
126
- }
127
- // duplicate color (info)
128
- if (facet.colorKey) {
129
- if (seenColors.has(facet.colorKey)) {
130
- issues.push({
131
- severity: 'info',
132
- message: `Duplicate facet color "${facet.colorKey}" in ${label}.`,
133
- });
134
- }
135
- else {
136
- seenColors.add(facet.colorKey);
137
- }
138
- }
139
- // duplicate description (info)
140
- if (facet.description) {
141
- if (seenDescriptions.has(facet.description)) {
142
- issues.push({
143
- severity: 'info',
144
- message: `Duplicate facet description "${facet.description}" in ${label}.`,
145
- });
146
- }
147
- else {
148
- seenDescriptions.add(facet.description);
149
- }
150
- }
151
- // no part definitions
152
- if (!facet.partDefinitions.length) {
153
- issues.push({
154
- severity: 'error',
155
- message: `${label} has no part definitions.`,
156
- });
157
- }
158
- // within-facet checks
159
- const seenPartKeys = new Set();
160
- const seenPartColors = new Set();
161
- const seenPartDescriptions = new Set();
162
- for (const part of facet.partDefinitions) {
163
- // duplicate typeId + roleId combination
164
- // key uses empty string for absent roleId so that
165
- // (typeId, undefined) vs (typeId, "r1") are treated as different
166
- const key = `${part.typeId}|${part.roleId ?? ''}`;
167
- if (seenPartKeys.has(key)) {
168
- issues.push({
169
- severity: 'error',
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.0", ngImport: i0, type: FacetDefinitionValidatorService, deps: [{ token: i1.ThesaurusService }], target: i0.ɵɵFactoryTarget.Injectable });
219
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.0", 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
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: FacetDefinitionValidatorService, decorators: [{
222
- type: Injectable,
223
- args: [{ providedIn: 'root' }]
224
- }], ctorParameters: () => [{ type: i1.ThesaurusService }] });
225
-
226
- /**
227
- * Editor for a single part definition. This allows users to edit the part definition
228
- * properties: type ID, selected from a list if facet model settings are provided,
229
- * or entered freely if not (but this should not happen, as at least part definitions
230
- * should be present and these provide fallback model settings); role ID, selected
231
- * from a closed list when the part type is a base text part, or entered freely otherwise;
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.0", 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.0", 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()\">\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 [formControl]=\"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 $any(typeId).errors?.required && (typeId.dirty || 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 [formControl]=\"typeId\" />\r\n @if (\r\n $any(typeId).errors?.required && (typeId.dirty || typeId.touched)\r\n ) {\r\n <mat-error>type ID required</mat-error>\r\n }\r\n @if (\r\n $any(typeId).errors?.maxLength && (typeId.dirty || 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 [formControl]=\"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 $any(roleId).errors?.required && (roleId.dirty || 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 [formControl]=\"roleId\" />\r\n @if (\r\n $any(roleId).errors?.required && (roleId.dirty || roleId.touched)\r\n ) {\r\n <mat-error>role ID required</mat-error>\r\n }\r\n @if (\r\n $any(roleId).errors?.maxLength && (roleId.dirty || 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 [formControl]=\"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 [formControl]=\"name\" />\r\n @if ($any(name).errors?.required && (name.dirty || name.touched)) {\r\n <mat-error>name required</mat-error>\r\n }\r\n @if ($any(name).errors?.maxLength && (name.dirty || 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 [formControl]=\"colorKey\" />\r\n @if (\r\n $any(colorKey).errors?.pattern && (colorKey.dirty || 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 colorKey.value?.length === 6 ? '#' + colorKey.value : '#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]=\"'#' + colorKey.value\"></div>\r\n\r\n <!-- group -->\r\n <mat-form-field>\r\n <mat-label>group</mat-label>\r\n <input matInput [formControl]=\"groupKey\" />\r\n @if (\r\n $any(groupKey).errors?.maxLength && (groupKey.dirty || 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 [formControl]=\"sortKey\" />\r\n @if (\r\n $any(sortKey).errors?.maxLength && (sortKey.dirty || 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 [formControl]=\"description\" rows=\"2\"></textarea>\r\n @if (\r\n $any(description).errors?.maxLength &&\r\n (description.dirty || 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=\"submit\"\r\n mat-icon-button\r\n matTooltip=\"Accept changes\"\r\n [disabled]=\"form.invalid || form.pristine\"\r\n >\r\n <mat-icon class=\"mat-primary\">check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</form>\r\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
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: PartDefinitionEditorComponent, decorators: [{
411
- type: Component,
412
- args: [{ selector: 'cadmus-part-definition-editor', imports: [
413
- ReactiveFormsModule,
414
- MatCheckbox,
415
- MatError,
416
- MatFormField,
417
- MatIcon,
418
- MatIconButton,
419
- MatInput,
420
- MatLabel,
421
- MatOption,
422
- MatSelect,
423
- MatSuffix,
424
- MatTooltip,
425
- ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<form [formGroup]=\"form\" (submit)=\"save()\">\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 [formControl]=\"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 $any(typeId).errors?.required && (typeId.dirty || 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 [formControl]=\"typeId\" />\r\n @if (\r\n $any(typeId).errors?.required && (typeId.dirty || typeId.touched)\r\n ) {\r\n <mat-error>type ID required</mat-error>\r\n }\r\n @if (\r\n $any(typeId).errors?.maxLength && (typeId.dirty || 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 [formControl]=\"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 $any(roleId).errors?.required && (roleId.dirty || 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 [formControl]=\"roleId\" />\r\n @if (\r\n $any(roleId).errors?.required && (roleId.dirty || roleId.touched)\r\n ) {\r\n <mat-error>role ID required</mat-error>\r\n }\r\n @if (\r\n $any(roleId).errors?.maxLength && (roleId.dirty || 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 [formControl]=\"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 [formControl]=\"name\" />\r\n @if ($any(name).errors?.required && (name.dirty || name.touched)) {\r\n <mat-error>name required</mat-error>\r\n }\r\n @if ($any(name).errors?.maxLength && (name.dirty || 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 [formControl]=\"colorKey\" />\r\n @if (\r\n $any(colorKey).errors?.pattern && (colorKey.dirty || 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 colorKey.value?.length === 6 ? '#' + colorKey.value : '#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]=\"'#' + colorKey.value\"></div>\r\n\r\n <!-- group -->\r\n <mat-form-field>\r\n <mat-label>group</mat-label>\r\n <input matInput [formControl]=\"groupKey\" />\r\n @if (\r\n $any(groupKey).errors?.maxLength && (groupKey.dirty || 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 [formControl]=\"sortKey\" />\r\n @if (\r\n $any(sortKey).errors?.maxLength && (sortKey.dirty || 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 [formControl]=\"description\" rows=\"2\"></textarea>\r\n @if (\r\n $any(description).errors?.maxLength &&\r\n (description.dirty || 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=\"submit\"\r\n mat-icon-button\r\n matTooltip=\"Accept changes\"\r\n [disabled]=\"form.invalid || form.pristine\"\r\n >\r\n <mat-icon class=\"mat-primary\">check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</form>\r\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"] }]
426
- }], ctorParameters: () => [{ type: i1$1.FormBuilder }], 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 }] }], hideSortKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideSortKey", required: false }] }], cancelEdit: [{ type: i0.Output, args: ["cancelEdit"] }] } });
427
-
428
- /**
429
- * Editor for a single facet definition and its part definitions.
430
- * This editor is used as a descendant of the facet definition list editor, and allows
431
- * to edit a single facet definition and its part definitions.
432
- */
433
- class FacetDefinitionEditorComponent {
434
- _dialogService;
435
- /**
436
- * The facet definition to edit.
437
- */
438
- definition = model(/* @ts-ignore */
439
- ...(ngDevMode ? [undefined, { debugName: "definition" }] : /* istanbul ignore next */ []));
440
- /**
441
- * The facet models settings, used to get the list of available part type IDs,
442
- * and whether they are base text parts; in this case, the same settings also
443
- * provide the list of their available role IDs from the fragments property.
444
- */
445
- facetModelSettings = input(undefined, /* @ts-ignore */
446
- ...(ngDevMode ? [{ debugName: "facetModelSettings" }] : /* istanbul ignore next */ []));
447
- /**
448
- * The list of available part type IDs, taken from the facet model settings.
449
- * If the facet model settings are not provided, or do not contain any part
450
- * definition, this list is empty and the type ID must be entered freely.
451
- */
452
- availablePartTypeIds = computed(() => {
453
- const settings = this.facetModelSettings();
454
- return settings?.parts ? Object.keys(settings.parts) : [];
455
- }, /* @ts-ignore */
456
- ...(ngDevMode ? [{ debugName: "availablePartTypeIds" }] : /* istanbul ignore next */ []));
457
- /**
458
- * Emitted when user requests to cancel the edit and close this editor.
459
- */
460
- cancelEdit = output();
461
- // edited part definition
462
- edited = signal(undefined, /* @ts-ignore */
463
- ...(ngDevMode ? [{ debugName: "edited" }] : /* istanbul ignore next */ []));
464
- editedIndex = signal(-1, /* @ts-ignore */
465
- ...(ngDevMode ? [{ debugName: "editedIndex" }] : /* istanbul ignore next */ []));
466
- id;
467
- label;
468
- colorKey;
469
- description;
470
- partDefinitions;
471
- form;
472
- constructor(formBuilder, _dialogService) {
473
- this._dialogService = _dialogService;
474
- // form
475
- this.id = formBuilder.control('', {
476
- validators: [Validators.required, Validators.maxLength(100)],
477
- nonNullable: true,
478
- });
479
- this.label = formBuilder.control('', {
480
- validators: [Validators.required, Validators.maxLength(100)],
481
- nonNullable: true,
482
- });
483
- // color key is a 6-digit hex string (without #)
484
- this.colorKey = formBuilder.control('', {
485
- validators: [Validators.pattern('^[0-9a-fA-F]{6}$')],
486
- nonNullable: true,
487
- });
488
- this.description = formBuilder.control('', {
489
- validators: [Validators.maxLength(1000)],
490
- nonNullable: true,
491
- });
492
- this.partDefinitions = formBuilder.control([], {
493
- validators: [Validators.required],
494
- nonNullable: true,
495
- });
496
- this.form = formBuilder.group({
497
- id: this.id,
498
- label: this.label,
499
- colorKey: this.colorKey,
500
- description: this.description,
501
- partDefinitions: this.partDefinitions,
502
- });
503
- // when model changes, update form
504
- effect(() => {
505
- const data = this.definition();
506
- this.updateForm(data);
507
- });
508
- }
509
- updateForm(data) {
510
- if (!data) {
511
- this.form.reset();
512
- }
513
- else {
514
- this.id.setValue(data.id);
515
- this.label.setValue(data.label);
516
- this.colorKey.setValue(data.colorKey);
517
- this.description.setValue(data.description);
518
- // sort by sortKey so that the displayed order always matches the key order
519
- const sorted = [...data.partDefinitions].sort((a, b) => (a.sortKey ?? '').localeCompare(b.sortKey ?? ''));
520
- this.partDefinitions.setValue(sorted);
521
- this.form.markAsPristine();
522
- }
523
- }
524
- getDefinition() {
525
- return {
526
- id: this.id.value.trim(),
527
- label: this.label.value.trim(),
528
- colorKey: this.colorKey.value,
529
- description: this.description.value.trim(),
530
- partDefinitions: this.partDefinitions.value,
531
- };
532
- }
533
- //#region Part definitions
534
- updatePartDefinitionSortKeys() {
535
- // assign an ordinal number as a 2-digits number to the sortKey
536
- // of each part definition, so that they are sorted in the order of the list
537
- const entries = this.partDefinitions.value.map((entry, index) => {
538
- return {
539
- ...entry,
540
- sortKey: (index + 1).toString().padStart(2, '0'),
541
- };
542
- });
543
- this.partDefinitions.setValue(entries);
544
- }
545
- addPartDefinition() {
546
- const definition = {
547
- typeId: this.availablePartTypeIds().length
548
- ? this.availablePartTypeIds()[0]
549
- : '',
550
- name: 'new',
551
- };
552
- this.editedIndex.set(-1);
553
- this.edited.set(definition);
554
- }
555
- editPartDefinition(entry, index) {
556
- this.editedIndex.set(index);
557
- this.edited.set(structuredClone(entry));
558
- }
559
- closePartDefinition() {
560
- this.editedIndex.set(-1);
561
- this.edited.set(undefined);
562
- }
563
- savePartDefinition(entry) {
564
- const entries = [...this.partDefinitions.value];
565
- if (this.editedIndex() === -1) {
566
- entries.push(entry);
567
- }
568
- else {
569
- entries.splice(this.editedIndex(), 1, entry);
570
- }
571
- this.partDefinitions.setValue(entries);
572
- this.partDefinitions.markAsDirty();
573
- this.partDefinitions.updateValueAndValidity();
574
- this.updatePartDefinitionSortKeys();
575
- this.closePartDefinition();
576
- }
577
- deletePartDefinition(index) {
578
- const definition = this.partDefinitions.value[index];
579
- this._dialogService
580
- .confirm('Confirmation', `Delete part "${definition.name}"?`)
581
- .subscribe((yes) => {
582
- if (yes) {
583
- if (this.editedIndex() === index) {
584
- this.closePartDefinition();
585
- }
586
- const definitions = [...this.partDefinitions.value];
587
- definitions.splice(index, 1);
588
- this.partDefinitions.setValue(definitions);
589
- this.partDefinitions.markAsDirty();
590
- this.partDefinitions.updateValueAndValidity();
591
- this.updatePartDefinitionSortKeys();
592
- }
593
- });
594
- }
595
- movePartDefinitionUp(index) {
596
- if (index < 1) {
597
- return;
598
- }
599
- const definition = this.partDefinitions.value[index];
600
- const definitions = [...this.partDefinitions.value];
601
- definitions.splice(index, 1);
602
- definitions.splice(index - 1, 0, definition);
603
- this.partDefinitions.setValue(definitions);
604
- this.partDefinitions.markAsDirty();
605
- this.partDefinitions.updateValueAndValidity();
606
- // keep editedIndex in sync
607
- if (this.editedIndex() === index) {
608
- this.editedIndex.set(index - 1);
609
- }
610
- else if (this.editedIndex() === index - 1) {
611
- this.editedIndex.set(index);
612
- }
613
- this.updatePartDefinitionSortKeys();
614
- }
615
- movePartDefinitionDown(index) {
616
- if (index + 1 >= this.partDefinitions.value.length) {
617
- return;
618
- }
619
- const definition = this.partDefinitions.value[index];
620
- const definitions = [...this.partDefinitions.value];
621
- definitions.splice(index, 1);
622
- definitions.splice(index + 1, 0, definition);
623
- this.partDefinitions.setValue(definitions);
624
- this.partDefinitions.markAsDirty();
625
- this.partDefinitions.updateValueAndValidity();
626
- // keep editedIndex in sync
627
- if (this.editedIndex() === index) {
628
- this.editedIndex.set(index + 1);
629
- }
630
- else if (this.editedIndex() === index + 1) {
631
- this.editedIndex.set(index);
632
- }
633
- this.updatePartDefinitionSortKeys();
634
- }
635
- //#endregion
636
- onColorPick(value) {
637
- // native color input returns "#rrggbb" — strip the leading "#"
638
- this.colorKey.setValue(value.slice(1));
639
- this.colorKey.markAsDirty();
640
- }
641
- cancel() {
642
- this.cancelEdit.emit();
643
- }
644
- /**
645
- * Saves the current form data by updating the `definition` model signal.
646
- * This method can be called manually (e.g., by a Save button) or
647
- * automatically (via auto-save).
648
- * @param pristine If true (default), the form is marked as pristine
649
- * after saving.
650
- * Set to false for auto-save if you want the form to remain dirty.
651
- */
652
- save(pristine = true) {
653
- if (this.form.invalid) {
654
- // show validation errors
655
- this.form.markAllAsTouched();
656
- return;
657
- }
658
- const data = this.getDefinition();
659
- this.definition.set(data);
660
- if (pristine) {
661
- this.form.markAsPristine();
662
- }
663
- }
664
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: FacetDefinitionEditorComponent, deps: [{ token: i1$1.FormBuilder }, { token: i2.DialogService }], target: i0.ɵɵFactoryTarget.Component });
665
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", 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()\">\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 [formControl]=\"id\" />\r\n @if ($any(id).errors?.required && (id.dirty || id.touched)) {\r\n <mat-error>ID required</mat-error>\r\n }\r\n @if ($any(id).errors?.maxLength && (id.dirty || 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 [formControl]=\"label\" />\r\n @if ($any(label).errors?.required && (label.dirty || label.touched)) {\r\n <mat-error>label required</mat-error>\r\n }\r\n @if (\r\n $any(label).errors?.maxLength && (label.dirty || 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 [formControl]=\"colorKey\" />\r\n @if (\r\n $any(colorKey).errors?.pattern &&\r\n (colorKey.dirty || 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 colorKey.value.length === 6 ? '#' + colorKey.value : '#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]=\"'#' + 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 [formControl]=\"description\" rows=\"2\"></textarea>\r\n @if (\r\n $any(description).errors?.maxLength &&\r\n (description.dirty || 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 (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 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=\"submit\"\r\n mat-icon-button\r\n matTooltip=\"Accept changes\"\r\n [disabled]=\"form.invalid || form.pristine\"\r\n >\r\n <mat-icon class=\"mat-primary\">check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</form>\r\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
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: FacetDefinitionEditorComponent, decorators: [{
668
- type: Component,
669
- args: [{ selector: 'cadmus-facet-definition-editor', imports: [
670
- ReactiveFormsModule,
671
- MatButtonModule,
672
- MatCheckbox,
673
- MatError$1,
674
- MatExpansionPanel,
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
- StringToColorPipe,
688
- PartDefinitionEditorComponent,
689
- ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<form [formGroup]=\"form\" (submit)=\"save()\">\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 [formControl]=\"id\" />\r\n @if ($any(id).errors?.required && (id.dirty || id.touched)) {\r\n <mat-error>ID required</mat-error>\r\n }\r\n @if ($any(id).errors?.maxLength && (id.dirty || 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 [formControl]=\"label\" />\r\n @if ($any(label).errors?.required && (label.dirty || label.touched)) {\r\n <mat-error>label required</mat-error>\r\n }\r\n @if (\r\n $any(label).errors?.maxLength && (label.dirty || 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 [formControl]=\"colorKey\" />\r\n @if (\r\n $any(colorKey).errors?.pattern &&\r\n (colorKey.dirty || 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 colorKey.value.length === 6 ? '#' + colorKey.value : '#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]=\"'#' + 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 [formControl]=\"description\" rows=\"2\"></textarea>\r\n @if (\r\n $any(description).errors?.maxLength &&\r\n (description.dirty || 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 (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 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=\"submit\"\r\n mat-icon-button\r\n matTooltip=\"Accept changes\"\r\n [disabled]=\"form.invalid || form.pristine\"\r\n >\r\n <mat-icon class=\"mat-primary\">check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</form>\r\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"] }]
690
- }], 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"] }] } });
691
-
692
- /**
693
- * Editor for a list of facet definitions. Cadmus facet definitions represent the data
694
- * types of items, and define all the parts which can be included in an item. Some of
695
- * them are required, others are optional. There can be multiple parts of the same type
696
- * in the same item, provided that their roleId is different.
697
- * This editor is used to edit the list of facet definitions from the current profile.
698
- * As the top level editor, it loads and saves the facet definitions list via API
699
- * services, and allows to add, edit, delete and reorder facet definitions.
700
- * The actual editing of a facet definition is delegated to descendant dumb components.
701
- * All edits happen in memory until the user clicks the Save button, which saves all
702
- * facet definitions to the server, and shows the result of the operation.
703
- */
704
- class FacetDefinitionListEditorComponent {
705
- _dialogService;
706
- _facetService;
707
- _validator;
708
- _snackbar;
709
- edited = signal(undefined, /* @ts-ignore */
710
- ...(ngDevMode ? [{ debugName: "edited" }] : /* istanbul ignore next */ []));
711
- editedIndex = signal(-1, /* @ts-ignore */
712
- ...(ngDevMode ? [{ debugName: "editedIndex" }] : /* istanbul ignore next */ []));
713
- dirty = signal(false, /* @ts-ignore */
714
- ...(ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []));
715
- facets = signal([], /* @ts-ignore */
716
- ...(ngDevMode ? [{ debugName: "facets" }] : /* istanbul ignore next */ []));
717
- busy = signal(false, /* @ts-ignore */
718
- ...(ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []));
719
- saveResult = signal(undefined, /* @ts-ignore */
720
- ...(ngDevMode ? [{ debugName: "saveResult" }] : /* istanbul ignore next */ []));
721
- /** True after at least one facet was successfully saved; prompts an app reload. */
722
- reloadNeeded = signal(false, /* @ts-ignore */
723
- ...(ngDevMode ? [{ debugName: "reloadNeeded" }] : /* istanbul ignore next */ []));
724
- /** Last validation result, set by validate() and by save(). */
725
- validationResult = signal(undefined, /* @ts-ignore */
726
- ...(ngDevMode ? [{ debugName: "validationResult" }] : /* istanbul ignore next */ []));
727
- validationResultHasIssues = computed(() => {
728
- const vr = this.validationResult();
729
- return vr ? vr.hasErrors || vr.hasWarnings : false;
730
- }, /* @ts-ignore */
731
- ...(ngDevMode ? [{ debugName: "validationResultHasIssues" }] : /* istanbul ignore next */ []));
732
- /**
733
- * The facet models settings, used to get the list of available part type IDs,
734
- * and whether they are base text parts; in this case, the same settings also
735
- * provide the list of their available role IDs from the fragments property.
736
- */
737
- facetModelSettings = signal(undefined, /* @ts-ignore */
738
- ...(ngDevMode ? [{ debugName: "facetModelSettings" }] : /* istanbul ignore next */ []));
739
- dirtyChange = output();
740
- editorClose = output();
741
- constructor(_dialogService, _facetService, _validator, _snackbar) {
742
- this._dialogService = _dialogService;
743
- this._facetService = _facetService;
744
- this._validator = _validator;
745
- this._snackbar = _snackbar;
746
- }
747
- ngOnInit() {
748
- // load facets once at start
749
- this.busy.set(true);
750
- this._facetService.getFacets().subscribe({
751
- next: (facets) => {
752
- this.facets.set(facets);
753
- this.busy.set(false);
754
- },
755
- error: (error) => {
756
- console.error(error);
757
- this.busy.set(false);
758
- this._snackbar.open('Error loading facets', 'Close');
759
- },
760
- });
761
- // load facet model settings once at start
762
- this._facetService.getFacetModelSettings().subscribe({
763
- next: (settings) => {
764
- this.facetModelSettings.set(settings);
765
- },
766
- error: (error) => {
767
- console.error(error);
768
- this._snackbar.open('Error loading facet model settings', 'Close');
769
- },
770
- });
771
- }
772
- addFacet() {
773
- const entry = {
774
- id: 'new',
775
- label: 'New facet',
776
- colorKey: 'default',
777
- description: '',
778
- partDefinitions: [],
779
- };
780
- this.editedIndex.set(-1);
781
- this.edited.set(entry);
782
- }
783
- editFacet(facet, index) {
784
- this.editedIndex.set(index);
785
- this.edited.set(structuredClone(facet));
786
- }
787
- closeFacet() {
788
- this.editedIndex.set(-1);
789
- this.edited.set(undefined);
790
- }
791
- saveFacet(facet) {
792
- const entries = [...this.facets()];
793
- if (this.editedIndex() === -1) {
794
- entries.push(facet);
795
- }
796
- else {
797
- entries.splice(this.editedIndex(), 1, facet);
798
- }
799
- this.facets.set(entries);
800
- this.closeFacet();
801
- this.dirty.set(true);
802
- this.dirtyChange.emit(true);
803
- }
804
- deleteFacet(index) {
805
- this._dialogService
806
- .confirm('Confirmation', `Delete facet ${this.edited()?.label}?`)
807
- .subscribe((yes) => {
808
- if (yes) {
809
- if (this.editedIndex() === index) {
810
- this.closeFacet();
811
- }
812
- const entries = [...this.facets()];
813
- entries.splice(index, 1);
814
- this.facets.set(entries);
815
- this.dirty.set(true);
816
- this.dirtyChange.emit(true);
817
- }
818
- });
819
- }
820
- moveFacetUp(index) {
821
- if (index < 1) {
822
- return;
823
- }
824
- const facet = this.facets()[index];
825
- const facets = [...this.facets()];
826
- facets.splice(index, 1);
827
- facets.splice(index - 1, 0, facet);
828
- this.facets.set(facets);
829
- this.dirty.set(true);
830
- this.dirtyChange.emit(true);
831
- // keep editedIndex in sync
832
- if (this.editedIndex() === index) {
833
- this.editedIndex.set(index - 1);
834
- }
835
- else if (this.editedIndex() === index - 1) {
836
- this.editedIndex.set(index);
837
- }
838
- }
839
- moveFacetDown(index) {
840
- if (index + 1 >= this.facets().length) {
841
- return;
842
- }
843
- const facet = this.facets()[index];
844
- const facets = [...this.facets()];
845
- facets.splice(index, 1);
846
- facets.splice(index + 1, 0, facet);
847
- this.facets.set(facets);
848
- this.dirty.set(true);
849
- this.dirtyChange.emit(true);
850
- // keep editedIndex in sync
851
- if (this.editedIndex() === index) {
852
- this.editedIndex.set(index + 1);
853
- }
854
- else if (this.editedIndex() === index + 1) {
855
- this.editedIndex.set(index);
856
- }
857
- }
858
- reloadApp() {
859
- window.location.href = '/';
860
- }
861
- close() {
862
- this.editorClose.emit();
863
- }
864
- /** Run validation and update validationResult; returns the observable. */
865
- runValidation() {
866
- return this._validator
867
- .validate(this.facets(), this.facetModelSettings())
868
- .pipe(tap((result) => this.validationResult.set(result)));
869
- }
870
- /** Trigger validation from the template and update the displayed result. */
871
- validate() {
872
- this.runValidation().pipe(take(1)).subscribe();
873
- }
874
- /** Persist all facets to the server; called only after all gates pass. */
875
- doSave() {
876
- const facets = this.facets();
877
- this.busy.set(true);
878
- this.saveResult.set(undefined);
879
- from(facets)
880
- .pipe(concatMap((facet) => this._facetService.addFacet(facet).pipe(map(() => true), catchError(() => of(false)))), toArray())
881
- .subscribe((results) => {
882
- const saved = [];
883
- const failed = [];
884
- results.forEach((ok, i) => {
885
- if (ok) {
886
- saved.push(facets[i].id);
887
- }
888
- else {
889
- failed.push(facets[i].id);
890
- }
891
- });
892
- this.busy.set(false);
893
- this.dirty.set(failed.length > 0);
894
- this.dirtyChange.emit(failed.length > 0);
895
- if (saved.length > 0) {
896
- this.reloadNeeded.set(true);
897
- }
898
- const parts = [];
899
- if (saved.length) {
900
- parts.push(`Saved: ${saved.join(', ')}`);
901
- }
902
- if (failed.length) {
903
- parts.push(`Failed: ${failed.join(', ')}`);
904
- }
905
- this.saveResult.set(parts.join(' | '));
906
- });
907
- }
908
- /**
909
- * Final confirmation gate before the actual write.
910
- * Always shown, even when there are no warnings or errors.
911
- */
912
- confirmAndSave() {
913
- this._dialogService
914
- .confirm('Save facets', 'Saving replaces ALL facet definitions on the server. ' +
915
- 'This may affect every item in the database. Proceed?')
916
- .subscribe((ok) => {
917
- if (ok) {
918
- this.doSave();
919
- }
920
- });
921
- }
922
- downloadFacets() {
923
- const replacer = (_key, value) => value === null || value === false ? undefined : value;
924
- const dataStr = 'data:text/json;charset=utf-8,' +
925
- encodeURIComponent(JSON.stringify(this.facets(), replacer, 2));
926
- const dlAnchorElem = document.createElement('a');
927
- dlAnchorElem.setAttribute('href', dataStr);
928
- dlAnchorElem.setAttribute('download', 'facets.json');
929
- dlAnchorElem.click();
930
- }
931
- /**
932
- * Validate the current facets, then — if there are no blocking errors —
933
- * walk the user through confirmation gates before saving.
934
- *
935
- * Gates (in order):
936
- * 1. Validation errors → block save, show results.
937
- * 2. Validation warnings → ask user to confirm before continuing.
938
- * 3. Final critical-operation confirmation → always shown.
939
- */
940
- save() {
941
- if (!this.facets().length) {
942
- return;
943
- }
944
- this.runValidation()
945
- .pipe(take(1))
946
- .subscribe((result) => {
947
- if (result.hasErrors) {
948
- // validation result is already displayed; nothing more to do
949
- return;
950
- }
951
- if (result.hasWarnings) {
952
- const warnCount = result.issues.filter((i) => i.severity === 'warning').length;
953
- this._dialogService
954
- .confirm('Warnings', `There ${warnCount === 1 ? 'is 1 warning' : `are ${warnCount} warnings`}. ` +
955
- 'Review the validation results below. Proceed anyway?')
956
- .subscribe((ok) => {
957
- if (ok) {
958
- this.confirmAndSave();
959
- }
960
- });
961
- }
962
- else {
963
- this.confirmAndSave();
964
- }
965
- });
966
- }
967
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: FacetDefinitionListEditorComponent, deps: [{ token: i2.DialogService }, { token: i1.FacetService }, { token: FacetDefinitionValidatorService }, { token: i4.MatSnackBar }], target: i0.ɵɵFactoryTarget.Component });
968
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", 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
+ };
969
524
  }
970
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: FacetDefinitionListEditorComponent, decorators: [{
971
- type: Component,
972
- args: [{ selector: 'cadmus-facet-definition-list-editor', imports: [
973
- MatButtonModule,
974
- MatExpansionPanel,
975
- MatExpansionPanelDescription,
976
- MatExpansionPanelHeader,
977
- MatExpansionPanelTitle,
978
- MatIcon,
979
- MatTooltip,
980
- MatProgressBar,
981
- ColorToContrastPipe,
982
- EllipsisPipe,
983
- FacetDefinitionEditorComponent,
984
- ], 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"] }]
985
- }], 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"] }] } });
986
-
987
- class FacetEditPageComponent {
988
- _dirty = signal(false, /* @ts-ignore */
989
- ...(ngDevMode ? [{ debugName: "_dirty" }] : /* istanbul ignore next */ []));
990
- canDeactivate() {
991
- return !this._dirty();
992
- }
993
- onDirtyChange(dirty) {
994
- this._dirty.set(dirty);
995
- }
996
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: FacetEditPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
997
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.0", 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
+ };
998
533
  }
999
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: FacetEditPageComponent, decorators: [{
1000
- type: Component,
1001
- args: [{ selector: 'cadmus-facet-edit-page', imports: [
1002
- MatCard,
1003
- MatCardContent,
1004
- MatCardHeader,
1005
- MatCardTitle,
1006
- MatIcon,
1007
- FacetDefinitionListEditorComponent,
1008
- ], changeDetection: ChangeDetectionStrategy.OnPush, 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"] }]
1009
- }] });
1010
-
1011
- const CADMUS_PROFILE_EDIT_ROUTES = [
1012
- {
1013
- path: 'facets',
1014
- pathMatch: 'full',
1015
- component: FacetEditPageComponent,
1016
- canDeactivate: [pendingChangesGuard],
1017
- },
1018
- ];
1019
-
1020
- /*
1021
- * Public API Surface of cadmus-profile-editor
1022
- */
1023
-
1024
- /**
1025
- * Generated bundle index. Do not edit.
1026
- */
1027
-
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
+ }];
1028
1415
  export { CADMUS_PROFILE_EDIT_ROUTES, FacetDefinitionEditorComponent, FacetDefinitionListEditorComponent, FacetDefinitionValidatorService, FacetEditPageComponent, PartDefinitionEditorComponent };
1029
- //# sourceMappingURL=myrmidon-cadmus-profile-editor.mjs.map
1416
+
1417
+ //# sourceMappingURL=myrmidon-cadmus-profile-editor.mjs.map