@myrmidon/cadmus-item-editor 17.0.2 → 18.0.1

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,1317 +1,2156 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, ChangeDetectionStrategy, Component, computed, input, output, effect, Inject, signal, Pipe } from '@angular/core';
3
- import { BehaviorSubject, forkJoin } from 'rxjs';
4
- import * as i1 from '@myrmidon/cadmus-state';
5
- import * as i7 from '@myrmidon/cadmus-api';
6
- import { DatePipe } from '@angular/common';
7
- import { toSignal } from '@angular/core/rxjs-interop';
8
- import { MatTooltip } from '@angular/material/tooltip';
9
- import * as i1$1 from '@angular/forms';
10
- import { Validators, ReactiveFormsModule } from '@angular/forms';
11
- import { take } from 'rxjs/operators';
12
- import { MatCard, MatCardContent } from '@angular/material/card';
13
- import { CdkCopyToClipboard } from '@angular/cdk/clipboard';
14
- import { MatProgressBar } from '@angular/material/progress-bar';
15
- import { MatTabGroup, MatTab } from '@angular/material/tabs';
16
- import { MatFormField, MatLabel, MatError, MatHint } from '@angular/material/form-field';
17
- import { MatInput } from '@angular/material/input';
18
- import { MatSelect } from '@angular/material/select';
19
- import { MatOption } from '@angular/material/core';
20
- import { MatButton, MatIconButton } from '@angular/material/button';
21
- import { MatIcon } from '@angular/material/icon';
22
- import { MatDivider } from '@angular/material/divider';
23
- import { MatExpansionPanel, MatExpansionPanelHeader, MatExpansionPanelTitle, MatExpansionPanelDescription } from '@angular/material/expansion';
24
- import { FlagSetComponent } from '@myrmidon/cadmus-ui-flag-set';
25
- import { MESSAGE_ITEM_LIST_REPOSITORY_RESET } from '@myrmidon/cadmus-item-list';
26
- import * as i5 from '@myrmidon/cadmus-ui';
27
- import { CustomValidators, PartBadgeComponent, getPartIdName } from '@myrmidon/cadmus-ui';
28
- import { MatCheckbox } from '@angular/material/checkbox';
29
- import * as i3 from '@myrmidon/ngx-mat-tools';
30
- import * as i2 from '@angular/material/dialog';
31
- import { MAT_DIALOG_DATA } from '@angular/material/dialog';
32
- import { RefLookupComponent } from '@myrmidon/cadmus-refs-lookup';
33
- import * as i2$1 from '@myrmidon/cadmus-refs-asserted-ids';
34
- import * as i3$1 from '@angular/router';
35
- import * as i4 from '@angular/material/snack-bar';
36
- import * as i8 from '@myrmidon/cadmus-core';
37
- import * as i10 from '@myrmidon/auth-jwt-login';
38
- import * as i11 from '@myrmidon/ngx-tools';
39
-
40
- /**
41
- * Edited item repository.
42
- */
43
- class EditedItemRepository {
44
- _appRepository;
45
- _itemService;
46
- _loading$;
47
- // the item being edited
48
- _item$;
49
- // the raw list of item's parts
50
- _parts$;
51
- _partGroups$;
52
- // the set of all the possible layer parts for this item, either
53
- // present or absent
54
- _layersPartInfo$;
55
- // the facet definition assigned to the item
56
- _facet$;
57
- // the part definitions for adding a new part, filtered by the selected
58
- // facet and the parts already present in the item.
59
- _newPartDefinitions$;
60
- get loading$() {
61
- return this._loading$.asObservable();
62
- }
63
- get item$() {
64
- return this._item$.asObservable();
65
- }
66
- get parts$() {
67
- return this._parts$.asObservable();
68
- }
69
- get partGroups$() {
70
- return this._partGroups$.asObservable();
71
- }
72
- get layers$() {
73
- return this._layersPartInfo$.asObservable();
74
- }
75
- get facet$() {
76
- return this._facet$.asObservable();
77
- }
78
- get newPartDefinitions$() {
79
- return this._newPartDefinitions$.asObservable();
80
- }
81
- constructor(_appRepository, _itemService) {
82
- this._appRepository = _appRepository;
83
- this._itemService = _itemService;
84
- this._loading$ = new BehaviorSubject(undefined);
85
- this._item$ = new BehaviorSubject(undefined);
86
- this._parts$ = new BehaviorSubject([]);
87
- this._partGroups$ = new BehaviorSubject([]);
88
- this._layersPartInfo$ = new BehaviorSubject([]);
89
- this._facet$ = new BehaviorSubject(undefined);
90
- this._newPartDefinitions$ = new BehaviorSubject([]);
91
- // ensure app data is loaded
92
- this._appRepository.load();
93
- }
94
- getItem() {
95
- return this._item$.value;
96
- }
97
- getFacet() {
98
- return this._facet$.value;
99
- }
100
- getExistingPartTypeAndRoleIds() {
101
- const groups = this.getPartGroups();
102
- if (!groups) {
103
- return [];
104
- }
105
- const results = [];
106
- for (const group of groups) {
107
- for (const part of group.parts) {
108
- results.push({
109
- typeId: part.typeId,
110
- roleId: part.roleId,
111
- });
112
- }
113
- }
114
- return results;
115
- }
116
- getNewPartDefinitions() {
117
- const facet = this.getFacet();
118
- if (!facet) {
119
- return [];
120
- }
121
- const existingTypeRoleIds = this.getExistingPartTypeAndRoleIds();
122
- const defs = [];
123
- for (const def of facet.partDefinitions) {
124
- // exclude layer parts, as these are in the layers tab
125
- if (def.roleId?.startsWith('fr.')) {
126
- continue;
127
- }
128
- // exclude parts present in the item
129
- if (existingTypeRoleIds.find((tr) => {
130
- return (tr.typeId === def.typeId &&
131
- ((!tr.roleId && !def.roleId) || tr.roleId === def.roleId));
132
- })) {
133
- continue;
134
- }
135
- defs.push(def);
136
- }
137
- // sort by sort key
138
- defs.sort((a, b) => {
139
- return (a.sortKey || '').localeCompare(b.sortKey || '');
140
- });
141
- return defs;
142
- }
143
- getPartGroups() {
144
- return this._partGroups$.value;
145
- }
146
- pickDefaultFacet(facets) {
147
- if (!facets.length) {
148
- return undefined;
149
- }
150
- // if there is a facet with id="default", pick it
151
- const defaultFacet = facets.find((f) => f.id === 'default');
152
- if (defaultFacet) {
153
- return defaultFacet;
154
- }
155
- // else just pick the first in the list
156
- return facets[0];
157
- }
158
- /**
159
- * Load the specified item or a new item.
160
- *
161
- * @param itemId The item ID, or falsy for a new item.
162
- */
163
- load(itemId) {
164
- const facets = this._appRepository.getFacets();
165
- this._loading$.next(true);
166
- if (!itemId) {
167
- // new item
168
- this._itemService.getItemLayerInfo('new', true).subscribe((layers) => {
169
- const facet = this.pickDefaultFacet(facets);
170
- this._loading$.next(false);
171
- this._item$.next({
172
- id: '',
173
- title: '',
174
- description: '',
175
- facetId: facet?.id || '',
176
- groupId: '',
177
- sortKey: '',
178
- flags: 0,
179
- timeCreated: new Date(),
180
- creatorId: '',
181
- timeModified: new Date(),
182
- userId: '',
183
- });
184
- this._parts$.next([]);
185
- this._partGroups$.next([]);
186
- this._layersPartInfo$.next(layers);
187
- this._facet$.next(facet);
188
- this._newPartDefinitions$.next(this.getNewPartDefinitions());
189
- });
190
- }
191
- else {
192
- // existing item
193
- forkJoin({
194
- item: this._itemService.getItem(itemId, true),
195
- layers: this._itemService.getItemLayerInfo(itemId, true),
196
- }).subscribe({
197
- next: (result) => {
198
- this._loading$.next(false);
199
- const itemFacet = facets.find((f) => {
200
- return f.id === result.item.facetId;
201
- });
202
- const facetParts = itemFacet ? itemFacet.partDefinitions : [];
203
- this._item$.next(result.item);
204
- this._parts$.next(result.item.parts || []);
205
- this._partGroups$.next(this._itemService.groupParts(result.item.parts || [], facetParts));
206
- this._layersPartInfo$.next(result.layers);
207
- this._facet$.next(itemFacet);
208
- this._newPartDefinitions$.next(this.getNewPartDefinitions());
209
- },
210
- });
211
- }
212
- }
213
- /**
214
- * Ensure that the item with the specified ID is loaded.
215
- *
216
- * @param id The item ID.
217
- */
218
- ensureItemLoaded(id) {
219
- if (this.getItem()?.id === id) {
220
- return;
221
- }
222
- this.load(id);
223
- }
224
- /**
225
- * Save the specified item in the backend and update this store.
226
- *
227
- * @param item The item.
228
- * @returns Promise with saved item.
229
- */
230
- save(item) {
231
- return new Promise((resolve, reject) => {
232
- this._itemService.addItem(item).subscribe({
233
- next: (saved) => {
234
- // update the item and the selected facet from it;
235
- // this is required when the item was new, and thus loaded
236
- // with the default facet before saving it
237
- const facets = this._appRepository.getFacets();
238
- const itemFacet = facets.find((f) => {
239
- return f.id === saved.facetId;
240
- });
241
- this._item$.next(saved);
242
- this._facet$.next(itemFacet);
243
- this._newPartDefinitions$.next(this.getNewPartDefinitions());
244
- resolve(saved);
245
- },
246
- error: (error) => {
247
- console.error(`Error saving item ${item.id}`, error);
248
- reject({ message: 'Error saving item ' + item.id, error: error });
249
- },
250
- });
251
- });
252
- }
253
- /**
254
- * Delete the specified part from this edited item.
255
- *
256
- * @param id The part's ID.
257
- * @returns Promise with part ID.
258
- */
259
- deletePart(id) {
260
- return new Promise((resolve, reject) => {
261
- const itemId = this._item$.value?.id;
262
- if (!itemId) {
263
- reject({
264
- message: 'Cannot delete part of unsaved item',
265
- });
266
- return;
267
- }
268
- this._itemService.deletePart(id).subscribe({
269
- next: (_) => {
270
- this.load(itemId);
271
- resolve(id);
272
- },
273
- error: (error) => {
274
- console.error(`Error deleting item's part ${id}`, error);
275
- reject({
276
- message: "Error deleting item's part " + id,
277
- error: error,
278
- });
279
- },
280
- });
281
- });
282
- }
283
- /**
284
- * Add a new layer part to this item.
285
- *
286
- * @param typeId The part type ID.
287
- * @param roleId The part role ID.
288
- * @returns Promise with new part.
289
- */
290
- addNewLayerPart(typeId, roleId) {
291
- return new Promise((resolve, reject) => {
292
- const itemId = this._item$.value?.id;
293
- if (!itemId) {
294
- reject({
295
- message: 'Cannot add part to unsaved item',
296
- });
297
- return;
298
- }
299
- const part = {
300
- itemId: itemId,
301
- typeId,
302
- roleId,
303
- id: '',
304
- creatorId: '',
305
- userId: '',
306
- timeCreated: new Date(),
307
- timeModified: new Date(),
308
- };
309
- this._itemService.addPart(part).subscribe({
310
- next: (part) => {
311
- this.load(itemId);
312
- resolve(part);
313
- },
314
- error: (error) => {
315
- console.error(`Error adding new layer part for item ${itemId}`, error);
316
- reject({
317
- message: 'Error adding new layer part for item ' + itemId,
318
- error: error,
319
- });
320
- },
321
- });
322
- });
323
- }
324
- /**
325
- * Set the scope for the specified parts in this item.
326
- *
327
- * @param ids The part IDs.
328
- * @param scope The scope to set.
329
- * @returns Promise.
330
- */
331
- setPartThesaurusScope(ids, scope) {
332
- return new Promise((resolve, reject) => {
333
- const itemId = this._item$.value?.id;
334
- if (!itemId) {
335
- reject({
336
- message: 'Cannot set scope for unsaved item',
337
- });
338
- return;
339
- }
340
- this._itemService.setPartThesaurusScope(ids, scope).subscribe({
341
- next: (_) => {
342
- this.load(itemId);
343
- resolve(true);
344
- },
345
- error: (error) => {
346
- console.error("Error setting item's part scope", error);
347
- reject({
348
- message: "Error setting item's part scope",
349
- error: error,
350
- });
351
- },
352
- });
353
- });
354
- }
355
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: EditedItemRepository, deps: [{ token: i1.AppRepository }, { token: i7.ItemService }], target: i0.ɵɵFactoryTarget.Injectable });
356
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: EditedItemRepository, providedIn: 'root' });
357
- }
358
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: EditedItemRepository, decorators: [{
359
- type: Injectable,
360
- args: [{ providedIn: 'root' }]
361
- }], ctorParameters: () => [{ type: i1.AppRepository }, { type: i7.ItemService }] });
362
-
363
- class CurrentItemBarComponent {
364
- item;
365
- constructor(repository) {
366
- this.item = toSignal(repository.item$);
367
- }
368
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: CurrentItemBarComponent, deps: [{ token: EditedItemRepository }], target: i0.ɵɵFactoryTarget.Component });
369
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: CurrentItemBarComponent, isStandalone: true, selector: "cadmus-current-item-bar", ngImport: i0, template: "@if (item(); as item) {\n <div class=\"item-bar\">\n <span class=\"title\">{{ item.title }}</span>\n <span class=\"id\">{{ item.id }}</span>\n &#x2B24;\n <span class=\"dsc\">\n {{ item.description }} &#x2B24;\n <span matTooltip=\"Created\"\n >{{ item.timeCreated | date: \"yyyy-MM-dd HH:mm:ss\" }}\n {{ item.creatorId }}</span\n >\n &#x2B24;\n <span matTooltip=\"Last saved\"\n >{{ item.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\n {{ item.userId }}</span\n >\n </span>\n </div>\n}\n", styles: ["div.item-bar{border:1px solid var(--mat-sys-on-surface-variant);border-radius:4px;background-color:var(--mat-sys-surface-container);color:var(--mat-sys-on-primary-container);margin:6px;padding:8px}.title{font-size:1.2em;font-weight:700;margin-right:.5em}.id{font-size:.8em;font-family:Courier New,Courier,monospace;margin-right:.5em}.dsc{font-size:.9em}\n"], dependencies: [{ kind: "directive", type: MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "pipe", type: DatePipe, name: "date" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
370
- }
371
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: CurrentItemBarComponent, decorators: [{
372
- type: Component,
373
- args: [{ selector: 'cadmus-current-item-bar', changeDetection: ChangeDetectionStrategy.OnPush, imports: [DatePipe, MatTooltip], template: "@if (item(); as item) {\n <div class=\"item-bar\">\n <span class=\"title\">{{ item.title }}</span>\n <span class=\"id\">{{ item.id }}</span>\n &#x2B24;\n <span class=\"dsc\">\n {{ item.description }} &#x2B24;\n <span matTooltip=\"Created\"\n >{{ item.timeCreated | date: \"yyyy-MM-dd HH:mm:ss\" }}\n {{ item.creatorId }}</span\n >\n &#x2B24;\n <span matTooltip=\"Last saved\"\n >{{ item.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\n {{ item.userId }}</span\n >\n </span>\n </div>\n}\n", styles: ["div.item-bar{border:1px solid var(--mat-sys-on-surface-variant);border-radius:4px;background-color:var(--mat-sys-surface-container);color:var(--mat-sys-on-primary-container);margin:6px;padding:8px}.title{font-size:1.2em;font-weight:700;margin-right:.5em}.id{font-size:.8em;font-family:Courier New,Courier,monospace;margin-right:.5em}.dsc{font-size:.9em}\n"] }]
374
- }], ctorParameters: () => [{ type: EditedItemRepository }] });
375
-
376
- class CurrentLayerPartBarComponent {
377
- _appRepository;
378
- _editedItemRepository;
379
- _facetService;
380
- _facet;
381
- _part;
382
- typeId;
383
- roleId;
384
- color;
385
- constructor(_appRepository, _editedItemRepository, editedLayerRepository, _facetService) {
386
- this._appRepository = _appRepository;
387
- this._editedItemRepository = _editedItemRepository;
388
- this._facetService = _facetService;
389
- this._facet = toSignal(this._editedItemRepository.facet$);
390
- this._part = toSignal(editedLayerRepository.part$);
391
- this.typeId = computed(() => {
392
- const part = this._part();
393
- if (!part)
394
- return undefined;
395
- return this.getTypeIdName(part.typeId);
396
- }, /* @ts-ignore */
397
- ...(ngDevMode ? [{ debugName: "typeId" }] : /* istanbul ignore next */ []));
398
- this.roleId = computed(() => {
399
- const part = this._part();
400
- if (!part)
401
- return undefined;
402
- return this.getRoleIdName(part.roleId);
403
- }, /* @ts-ignore */
404
- ...(ngDevMode ? [{ debugName: "roleId" }] : /* istanbul ignore next */ []));
405
- this.color = computed(() => {
406
- const part = this._part();
407
- this._facet(); // declare dependency so color recomputes on facet change
408
- if (!part)
409
- return undefined;
410
- return this.getPartColor(part.typeId, part.roleId);
411
- }, /* @ts-ignore */
412
- ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
413
- }
414
- getTypeIdName(typeId) {
415
- const typeThesaurus = this._appRepository.getTypeThesaurus();
416
- if (!typeThesaurus) {
417
- return typeId;
418
- }
419
- // strip :suffix if any
420
- const i = typeId.lastIndexOf(':');
421
- if (i > -1) {
422
- typeId = typeId.substring(0, i);
423
- }
424
- const entry = typeThesaurus.entries?.find((e) => e.id === typeId);
425
- return entry ? entry.value : typeId;
426
- }
427
- getRoleIdName(roleId) {
428
- if (!roleId || !roleId.startsWith('fr.')) {
429
- return roleId;
430
- }
431
- return this.getTypeIdName(roleId);
432
- }
433
- getPartColor(typeId, roleId) {
434
- const facet = this._editedItemRepository.getFacet();
435
- return this._facetService.getPartColor(typeId, roleId, facet);
436
- }
437
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: CurrentLayerPartBarComponent, deps: [{ token: i1.AppRepository }, { token: EditedItemRepository }, { token: i1.EditedLayerRepository }, { token: i7.FacetService }], target: i0.ɵɵFactoryTarget.Component });
438
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.1", type: CurrentLayerPartBarComponent, isStandalone: true, selector: "cadmus-current-layer-part-bar", ngImport: i0, template: "<div>\n <span class=\"type-id\" [style.background-color]=\"color()\">{{ typeId() }}</span>\n <span class=\"role-id\">{{ roleId() }}</span>\n</div>\n", styles: ["span.type-id{padding:4px;border-radius:6px}span.role-id{padding:4px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
439
- }
440
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: CurrentLayerPartBarComponent, decorators: [{
441
- type: Component,
442
- args: [{ selector: 'cadmus-current-layer-part-bar', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div>\n <span class=\"type-id\" [style.background-color]=\"color()\">{{ typeId() }}</span>\n <span class=\"role-id\">{{ roleId() }}</span>\n</div>\n", styles: ["span.type-id{padding:4px;border-radius:6px}span.role-id{padding:4px}\n"] }]
443
- }], ctorParameters: () => [{ type: i1.AppRepository }, { type: EditedItemRepository }, { type: i1.EditedLayerRepository }, { type: i7.FacetService }] });
444
-
445
- /**
446
- * Parts thesaurus scope dumb editor component.
447
- * This is used to set the thesaurus scope of multiple item's parts at once
448
- * in the item editor.
449
- */
450
- class PartsScopeEditorComponent {
451
- _formBuilder;
452
- _facetService;
453
- _dialogService;
454
- _appRepository;
455
- _colorService;
456
- _editedItemRepository;
457
- parts = input(/* @ts-ignore */
458
- ...(ngDevMode ? [undefined, { debugName: "parts" }] : /* istanbul ignore next */ []));
459
- readonly = input(/* @ts-ignore */
460
- ...(ngDevMode ? [undefined, { debugName: "readonly" }] : /* istanbul ignore next */ []));
461
- setScopeRequest = output();
462
- checks;
463
- scope;
464
- form;
465
- constructor(_formBuilder, _facetService, _dialogService, _appRepository, _colorService, _editedItemRepository) {
466
- this._formBuilder = _formBuilder;
467
- this._facetService = _facetService;
468
- this._dialogService = _dialogService;
469
- this._appRepository = _appRepository;
470
- this._colorService = _colorService;
471
- this._editedItemRepository = _editedItemRepository;
472
- this.checks = _formBuilder.array([], CustomValidators.minChecked(1));
473
- this.scope = _formBuilder.control(null, [
474
- Validators.maxLength(50),
475
- Validators.pattern(/^[-a-zA-Z0-9_]+$/),
476
- ]);
477
- this.form = _formBuilder.group({
478
- checks: this.checks,
479
- scope: this.scope,
480
- });
481
- // ensure app data is loaded
482
- this._appRepository.load();
483
- effect(() => {
484
- this.updateForm(this.parts());
485
- });
486
- }
487
- updateForm(parts) {
488
- this.checks.clear();
489
- if (!parts?.length) {
490
- return;
491
- }
492
- for (let i = 0; i < parts.length; i++) {
493
- this.checks.push(this._formBuilder.control(false));
494
- }
495
- this.form.updateValueAndValidity();
496
- }
497
- onCheckChanged() {
498
- this.form.updateValueAndValidity();
499
- }
500
- getPartColor(typeId, roleId) {
501
- const facet = this._editedItemRepository.getFacet();
502
- return this._facetService.getPartColor(typeId, roleId, facet);
503
- }
504
- getContrastColor(typeId, roleId) {
505
- const rgb = this.getPartColor(typeId, roleId);
506
- return this._colorService.getContrastColor(rgb);
507
- }
508
- getTypeIdName(typeId) {
509
- const typeThesaurus = this._appRepository.getTypeThesaurus();
510
- if (!typeThesaurus) {
511
- return typeId;
512
- }
513
- // strip :suffix if any
514
- const i = typeId.lastIndexOf(':');
515
- if (i > -1) {
516
- typeId = typeId.substring(0, i);
517
- }
518
- const entry = typeThesaurus.entries?.find((e) => e.id === typeId);
519
- return entry ? entry.value : typeId;
520
- }
521
- getRoleIdName(roleId) {
522
- if (!roleId || !roleId.startsWith('fr.')) {
523
- return roleId;
524
- }
525
- return this.getTypeIdName(roleId);
526
- }
527
- submit() {
528
- if (this.form.invalid || !this.parts()?.length) {
529
- return;
530
- }
531
- const ids = [];
532
- const parts = this.parts();
533
- for (let i = 0; i < this.checks.length; i++) {
534
- if (this.checks.controls[i].value === true) {
535
- ids.push(parts[i].id);
536
- }
537
- }
538
- let msg = this.scope.value
539
- ? `Assign scope "${this.scope.value}" to ${ids.length} part`
540
- : `Remove scope from ${ids.length} part`;
541
- msg += ids.length > 1 ? 's?' : '?';
542
- this._dialogService.confirm('Confirm Scopes', msg).subscribe((result) => {
543
- if (!result) {
544
- return;
545
- }
546
- this.setScopeRequest.emit({
547
- ids,
548
- scope: this.scope.value,
549
- });
550
- });
551
- }
552
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: PartsScopeEditorComponent, deps: [{ token: i1$1.FormBuilder }, { token: i7.FacetService }, { token: i3.DialogService }, { token: i1.AppRepository }, { token: i5.ColorService }, { token: EditedItemRepository }], target: i0.ɵɵFactoryTarget.Component });
553
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: PartsScopeEditorComponent, isStandalone: true, selector: "cadmus-parts-scope-editor", inputs: { parts: { classPropertyName: "parts", publicName: "parts", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { setScopeRequest: "setScopeRequest" }, ngImport: i0, template: "<form [formGroup]=\"form\" (submit)=\"submit()\">\n <table id=\"parts\" formArrayName=\"checks\">\n <thead>\n <tr>\n <th aria-label=\"select\"></th>\n <th>type</th>\n <th>role</th>\n <th>scope</th>\n <th>modified</th>\n <th>user</th>\n </tr>\n </thead>\n <tbody>\n @for (\n part of parts() ?? [];\n track part.typeId + \":\" + (part.roleId ?? \"\");\n let i = $index\n ) {\n <tr>\n <td class=\"fit-width\">\n <mat-checkbox [formControlName]=\"i\" (change)=\"onCheckChanged()\" />\n </td>\n <td>\n <span\n class=\"model-type\"\n [style.background-color]=\"getPartColor(part.typeId, part.roleId)\"\n [style.color]=\"getContrastColor(part.typeId, part.roleId)\"\n >{{ getTypeIdName(part.typeId) }}</span\n >\n </td>\n <td>{{ getRoleIdName(part.roleId ?? \"\") }}</td>\n <td>{{ part.thesaurusScope }}</td>\n <td>{{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}</td>\n <td>{{ part.userId }}</td>\n </tr>\n }\n </tbody>\n </table>\n <div class=\"form-row\">\n <mat-form-field>\n <mat-label>scope</mat-label>\n <input matInput formControlName=\"scope\" />\n @if (scope.hasError(\"maxLength\") && (scope.dirty || scope.touched)) {\n <mat-error>too long</mat-error>\n }\n @if (scope.hasError(\"pattern\") && (scope.dirty || scope.touched)) {\n <mat-error>invalid scope</mat-error>\n }\n </mat-form-field>\n <button\n mat-flat-button\n class=\"mat-primary\"\n type=\"submit\"\n [disabled]=\"form.invalid || readonly()\"\n matTooltip=\"Assign the scope to the checked parts\"\n >\n assign\n </button>\n </div>\n</form>\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)}span.model-type{padding:4px;border-radius:6px}table#parts{border-collapse:separate;border-spacing:0 8px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}\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.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i1$1.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { 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: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: MatLabel, selector: "mat-label" }, { 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: MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "component", type: 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: "directive", type: MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "pipe", type: DatePipe, name: "date" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
554
- }
555
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: PartsScopeEditorComponent, decorators: [{
556
- type: Component,
557
- args: [{ selector: 'cadmus-parts-scope-editor', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
558
- ReactiveFormsModule,
559
- MatCheckbox,
560
- MatFormField,
561
- MatLabel,
562
- MatInput,
563
- MatError,
564
- MatButton,
565
- MatTooltip,
566
- DatePipe,
567
- ], template: "<form [formGroup]=\"form\" (submit)=\"submit()\">\n <table id=\"parts\" formArrayName=\"checks\">\n <thead>\n <tr>\n <th aria-label=\"select\"></th>\n <th>type</th>\n <th>role</th>\n <th>scope</th>\n <th>modified</th>\n <th>user</th>\n </tr>\n </thead>\n <tbody>\n @for (\n part of parts() ?? [];\n track part.typeId + \":\" + (part.roleId ?? \"\");\n let i = $index\n ) {\n <tr>\n <td class=\"fit-width\">\n <mat-checkbox [formControlName]=\"i\" (change)=\"onCheckChanged()\" />\n </td>\n <td>\n <span\n class=\"model-type\"\n [style.background-color]=\"getPartColor(part.typeId, part.roleId)\"\n [style.color]=\"getContrastColor(part.typeId, part.roleId)\"\n >{{ getTypeIdName(part.typeId) }}</span\n >\n </td>\n <td>{{ getRoleIdName(part.roleId ?? \"\") }}</td>\n <td>{{ part.thesaurusScope }}</td>\n <td>{{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}</td>\n <td>{{ part.userId }}</td>\n </tr>\n }\n </tbody>\n </table>\n <div class=\"form-row\">\n <mat-form-field>\n <mat-label>scope</mat-label>\n <input matInput formControlName=\"scope\" />\n @if (scope.hasError(\"maxLength\") && (scope.dirty || scope.touched)) {\n <mat-error>too long</mat-error>\n }\n @if (scope.hasError(\"pattern\") && (scope.dirty || scope.touched)) {\n <mat-error>invalid scope</mat-error>\n }\n </mat-form-field>\n <button\n mat-flat-button\n class=\"mat-primary\"\n type=\"submit\"\n [disabled]=\"form.invalid || readonly()\"\n matTooltip=\"Assign the scope to the checked parts\"\n >\n assign\n </button>\n </div>\n</form>\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)}span.model-type{padding:4px;border-radius:6px}table#parts{border-collapse:separate;border-spacing:0 8px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}\n"] }]
568
- }], ctorParameters: () => [{ type: i1$1.FormBuilder }, { type: i7.FacetService }, { type: i3.DialogService }, { type: i1.AppRepository }, { type: i5.ColorService }, { type: EditedItemRepository }], propDecorators: { parts: [{ type: i0.Input, args: [{ isSignal: true, alias: "parts", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], setScopeRequest: [{ type: i0.Output, args: ["setScopeRequest"] }] } });
569
-
570
- /**
571
- * Simple item lookup dialog. This allows the user to select an item from
572
- * its title, and returns the selected item if not cancelled.
573
- */
574
- class ItemLookupDialogComponent {
575
- dialogRef;
576
- config;
577
- itemLookupService;
578
- constructor(dialogRef, config, itemLookupService) {
579
- this.dialogRef = dialogRef;
580
- this.config = config;
581
- this.itemLookupService = itemLookupService;
582
- }
583
- onCancel() {
584
- this.dialogRef.close(null);
585
- }
586
- onItemLookupChange(value) {
587
- this.dialogRef.close(value);
588
- }
589
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ItemLookupDialogComponent, deps: [{ token: i2.MatDialogRef }, { token: MAT_DIALOG_DATA }, { token: i2$1.ItemRefLookupService }], target: i0.ɵɵFactoryTarget.Component });
590
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.1", type: ItemLookupDialogComponent, isStandalone: true, selector: "cadmus-item-lookup-dialog", ngImport: i0, template: "<div id=\"container\">\r\n <h3>Select Item</h3>\r\n <cadmus-refs-lookup\r\n [service]=\"itemLookupService\"\r\n label=\"item\"\r\n (itemChange)=\"onItemLookupChange($event)\"\r\n />\r\n</div>\r\n", styles: ["#container{padding:16px}\n"], dependencies: [{ kind: "component", type: RefLookupComponent, selector: "cadmus-refs-lookup", inputs: ["label", "limit", "baseFilter", "service", "item", "itemId", "required", "hasMore", "linkTemplate", "optDialog", "options", "lookupProviderOptions"], outputs: ["itemChange", "optionsChange", "moreRequest"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
591
- }
592
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ItemLookupDialogComponent, decorators: [{
593
- type: Component,
594
- args: [{ selector: 'cadmus-item-lookup-dialog', changeDetection: ChangeDetectionStrategy.OnPush, imports: [RefLookupComponent], template: "<div id=\"container\">\r\n <h3>Select Item</h3>\r\n <cadmus-refs-lookup\r\n [service]=\"itemLookupService\"\r\n label=\"item\"\r\n (itemChange)=\"onItemLookupChange($event)\"\r\n />\r\n</div>\r\n", styles: ["#container{padding:16px}\n"] }]
595
- }], ctorParameters: () => [{ type: i2.MatDialogRef }, { type: i2.MatDialogConfig, decorators: [{
596
- type: Inject,
597
- args: [MAT_DIALOG_DATA]
598
- }] }, { type: i2$1.ItemRefLookupService }] });
599
-
600
- /**
601
- * Simple item generate dialog. This allows the user to enter a title template
602
- * and flags, and returns the entered values if not cancelled.
603
- */
604
- class ItemGenerateDialogComponent {
605
- dialogRef;
606
- config;
607
- flags = signal([], /* @ts-ignore */
608
- ...(ngDevMode ? [{ debugName: "flags" }] : /* istanbul ignore next */ []));
609
- itemCount;
610
- itemTitle;
611
- itemFlags;
612
- form;
613
- constructor(formBuilder, dialogRef, config) {
614
- this.dialogRef = dialogRef;
615
- this.config = config;
616
- this.itemCount = formBuilder.control(1, {
617
- nonNullable: true,
618
- validators: [Validators.required, Validators.min(1), Validators.max(100)],
619
- });
620
- this.itemTitle = formBuilder.control('', {
621
- nonNullable: true,
622
- validators: [Validators.required, Validators.maxLength(500)],
623
- });
624
- this.itemFlags = formBuilder.control([], {
625
- nonNullable: true,
626
- });
627
- this.form = formBuilder.group({
628
- itemCount: this.itemCount,
629
- itemTitle: this.itemTitle,
630
- itemFlags: this.itemFlags,
631
- });
632
- // flags definitions
633
- this.flags.set(config?.flags || []);
634
- }
635
- apply() {
636
- if (!this.form.valid) {
637
- return;
638
- }
639
- // calculate flags value by ORing the IDs
640
- const flags = this.itemFlags.value.reduce((acc, f) => acc | f.id, 0);
641
- this.dialogRef.close({
642
- count: this.itemCount.value,
643
- title: this.itemTitle.value,
644
- flags: flags,
645
- });
646
- }
647
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ItemGenerateDialogComponent, deps: [{ token: i1$1.FormBuilder }, { token: i2.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
648
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: ItemGenerateDialogComponent, isStandalone: true, selector: "cadmus-item-generate-dialog", ngImport: i0, template: "<div id=\"container\">\n <h3>Generate Items</h3>\n <form [formGroup]=\"form\" (submit)=\"apply()\">\n <!-- count -->\n <div>\n <mat-form-field class=\"input-nr\">\n <mat-label>count</mat-label>\n <input matInput type=\"number\" min=\"1\" [formControl]=\"itemCount\" />\n <mat-hint>number of items to generate</mat-hint>\n @if (\n itemCount.errors?.[\"required\"] && (itemCount.dirty || itemCount.touched)\n ) {\n <mat-error>count required</mat-error>\n }\n @if (\n itemCount.errors?.[\"min\"] && (itemCount.dirty || itemCount.touched)\n ) {\n <mat-error>count too low</mat-error>\n }\n @if (\n itemCount.errors?.[\"max\"] && (itemCount.dirty || itemCount.touched)\n ) {\n <mat-error>count too high</mat-error>\n }\n </mat-form-field>\n </div>\n\n <!-- title -->\n <div>\n <mat-form-field>\n <mat-label>title</mat-label>\n <input matInput [formControl]=\"itemTitle\" />\n <mat-hint>title template ({{ \"{0}\" }}=N)</mat-hint>\n @if (\n itemTitle.errors?.[\"required\"] &&\n (itemTitle.dirty || itemTitle.touched)\n ) {\n <mat-error>title required</mat-error>\n }\n @if (\n itemTitle.errors?.[\"maxlength\"] &&\n (itemTitle.dirty || itemTitle.touched)\n ) {\n <mat-error>title too long</mat-error>\n }\n </mat-form-field>\n </div>\n\n <!-- flags -->\n @if (flags().length) {\n <div>\n <mat-form-field>\n <mat-label>flags</mat-label>\n <mat-select [formControl]=\"itemFlags\" multiple>\n @for (flag of flags(); track flag.id) {\n <mat-option [value]=\"flag\">\n <span class=\"flag-bullet\" [style.color]=\"'#' + flag.colorKey\"\n >&#x2b24;</span\n >\n {{ flag.label }}\n </mat-option>\n }\n </mat-select>\n </mat-form-field>\n </div>\n }\n\n <!-- apply button -->\n <div>\n <button\n mat-flat-button\n class=\"mat-primary\"\n type=\"submit\"\n [disabled]=\"form.invalid\"\n >\n generate\n </button>\n </div>\n </form>\n</div>\n", styles: ["#container{padding:16px}.flag-bullet{margin-right:.5em}.input-nr{width:5em}\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.NumberValueAccessor, selector: "input[type=number]:not([ngNoCva])[formControlName],input[type=number]:not([ngNoCva])[formControl],input[type=number]:not([ngNoCva])[ngModel]" }, { 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.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { 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: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: MatLabel, selector: "mat-label" }, { 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: MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { 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: "component", type: MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "component", type: 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"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
649
- }
650
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ItemGenerateDialogComponent, decorators: [{
651
- type: Component,
652
- args: [{ selector: 'cadmus-item-generate-dialog', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
653
- ReactiveFormsModule,
654
- MatFormField,
655
- MatLabel,
656
- MatInput,
657
- MatHint,
658
- MatError,
659
- MatSelect,
660
- MatOption,
661
- MatButton,
662
- ], template: "<div id=\"container\">\n <h3>Generate Items</h3>\n <form [formGroup]=\"form\" (submit)=\"apply()\">\n <!-- count -->\n <div>\n <mat-form-field class=\"input-nr\">\n <mat-label>count</mat-label>\n <input matInput type=\"number\" min=\"1\" [formControl]=\"itemCount\" />\n <mat-hint>number of items to generate</mat-hint>\n @if (\n itemCount.errors?.[\"required\"] && (itemCount.dirty || itemCount.touched)\n ) {\n <mat-error>count required</mat-error>\n }\n @if (\n itemCount.errors?.[\"min\"] && (itemCount.dirty || itemCount.touched)\n ) {\n <mat-error>count too low</mat-error>\n }\n @if (\n itemCount.errors?.[\"max\"] && (itemCount.dirty || itemCount.touched)\n ) {\n <mat-error>count too high</mat-error>\n }\n </mat-form-field>\n </div>\n\n <!-- title -->\n <div>\n <mat-form-field>\n <mat-label>title</mat-label>\n <input matInput [formControl]=\"itemTitle\" />\n <mat-hint>title template ({{ \"{0}\" }}=N)</mat-hint>\n @if (\n itemTitle.errors?.[\"required\"] &&\n (itemTitle.dirty || itemTitle.touched)\n ) {\n <mat-error>title required</mat-error>\n }\n @if (\n itemTitle.errors?.[\"maxlength\"] &&\n (itemTitle.dirty || itemTitle.touched)\n ) {\n <mat-error>title too long</mat-error>\n }\n </mat-form-field>\n </div>\n\n <!-- flags -->\n @if (flags().length) {\n <div>\n <mat-form-field>\n <mat-label>flags</mat-label>\n <mat-select [formControl]=\"itemFlags\" multiple>\n @for (flag of flags(); track flag.id) {\n <mat-option [value]=\"flag\">\n <span class=\"flag-bullet\" [style.color]=\"'#' + flag.colorKey\"\n >&#x2b24;</span\n >\n {{ flag.label }}\n </mat-option>\n }\n </mat-select>\n </mat-form-field>\n </div>\n }\n\n <!-- apply button -->\n <div>\n <button\n mat-flat-button\n class=\"mat-primary\"\n type=\"submit\"\n [disabled]=\"form.invalid\"\n >\n generate\n </button>\n </div>\n </form>\n</div>\n", styles: ["#container{padding:16px}.flag-bullet{margin-right:.5em}.input-nr{width:5em}\n"] }]
663
- }], ctorParameters: () => [{ type: i1$1.FormBuilder }, { type: i2.MatDialogRef }, { type: i2.MatDialogConfig, decorators: [{
664
- type: Inject,
665
- args: [MAT_DIALOG_DATA]
666
- }] }] });
667
-
668
- class MissingPartsComponent {
669
- facetDefinition = input(/* @ts-ignore */
670
- ...(ngDevMode ? [undefined, { debugName: "facetDefinition" }] : /* istanbul ignore next */ []));
671
- partDefinitions = input(/* @ts-ignore */
672
- ...(ngDevMode ? [undefined, { debugName: "partDefinitions" }] : /* istanbul ignore next */ []));
673
- parts = input(/* @ts-ignore */
674
- ...(ngDevMode ? [undefined, { debugName: "parts" }] : /* istanbul ignore next */ []));
675
- missingDefinitions = signal([], /* @ts-ignore */
676
- ...(ngDevMode ? [{ debugName: "missingDefinitions" }] : /* istanbul ignore next */ []));
677
- /**
678
- * The types thesaurus.
679
- */
680
- typeThesaurus = input(/* @ts-ignore */
681
- ...(ngDevMode ? [undefined, { debugName: "typeThesaurus" }] : /* istanbul ignore next */ []));
682
- /**
683
- * Emitted when the user requests to add a missing part.
684
- */
685
- addRequest = output();
686
- constructor() {
687
- effect(() => {
688
- this.updateMissing(this.partDefinitions(), this.parts());
689
- });
690
- }
691
- partExists(typeId, roleId, parts) {
692
- if (!parts) {
693
- return false;
694
- }
695
- return parts.some((p) => p.typeId === typeId && ((!p.roleId && !roleId) || p.roleId === roleId));
696
- }
697
- updateMissing(definitions, parts) {
698
- const missingDefinitions = [];
699
- if (!definitions) {
700
- return;
701
- }
702
- for (let i = 0; i < definitions.length; i++) {
703
- const def = definitions[i];
704
- if (def.isRequired && !this.partExists(def.typeId, def.roleId, parts)) {
705
- missingDefinitions.push(def);
706
- }
707
- }
708
- this.missingDefinitions.set(missingDefinitions);
709
- }
710
- requestAddPart(definition) {
711
- this.addRequest.emit(definition);
712
- }
713
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: MissingPartsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
714
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: MissingPartsComponent, isStandalone: true, selector: "cadmus-missing-parts", inputs: { facetDefinition: { classPropertyName: "facetDefinition", publicName: "facetDefinition", isSignal: true, isRequired: false, transformFunction: null }, partDefinitions: { classPropertyName: "partDefinitions", publicName: "partDefinitions", isSignal: true, isRequired: false, transformFunction: null }, parts: { classPropertyName: "parts", publicName: "parts", isSignal: true, isRequired: false, transformFunction: null }, typeThesaurus: { classPropertyName: "typeThesaurus", publicName: "typeThesaurus", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { addRequest: "addRequest" }, ngImport: i0, template: "@if (missingDefinitions().length) {\n <div>\n <fieldset>\n <legend>\n <mat-icon class=\"mat-warn\">warning</mat-icon>&nbsp; Missing Parts\n </legend>\n <table>\n <tbody>\n @for (\n def of missingDefinitions();\n track def.typeId + \":\" + (def.roleId ?? \"\")\n ) {\n <tr>\n <td>\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Add this part\"\n (click)=\"requestAddPart(def)\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td [matTooltip]=\"def.description\">\n <cadmus-part-badge\n [partTypeIds]=\"def\"\n [facetDefinition]=\"facetDefinition()\"\n [typeThesaurus]=\"typeThesaurus()\"\n />\n </td>\n </tr>\n }\n </tbody>\n </table>\n </fieldset>\n </div>\n}\n", styles: ["fieldset{border:1px solid var(--mat-sys-on-surface-variant);border-radius:6px;padding:6px}legend{color:var(--mat-sys-on-surface-variant)}\n"], dependencies: [{ 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: MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "component", type: PartBadgeComponent, selector: "cadmus-part-badge", inputs: ["badgeType", "typeThesaurus", "facetDefinition", "partTypeIds"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
715
- }
716
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: MissingPartsComponent, decorators: [{
717
- type: Component,
718
- args: [{ selector: 'cadmus-missing-parts', changeDetection: ChangeDetectionStrategy.OnPush, imports: [MatIcon, MatIconButton, MatTooltip, PartBadgeComponent], template: "@if (missingDefinitions().length) {\n <div>\n <fieldset>\n <legend>\n <mat-icon class=\"mat-warn\">warning</mat-icon>&nbsp; Missing Parts\n </legend>\n <table>\n <tbody>\n @for (\n def of missingDefinitions();\n track def.typeId + \":\" + (def.roleId ?? \"\")\n ) {\n <tr>\n <td>\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Add this part\"\n (click)=\"requestAddPart(def)\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td [matTooltip]=\"def.description\">\n <cadmus-part-badge\n [partTypeIds]=\"def\"\n [facetDefinition]=\"facetDefinition()\"\n [typeThesaurus]=\"typeThesaurus()\"\n />\n </td>\n </tr>\n }\n </tbody>\n </table>\n </fieldset>\n </div>\n}\n", styles: ["fieldset{border:1px solid var(--mat-sys-on-surface-variant);border-radius:6px;padding:6px}legend{color:var(--mat-sys-on-surface-variant)}\n"] }]
719
- }], ctorParameters: () => [], propDecorators: { facetDefinition: [{ type: i0.Input, args: [{ isSignal: true, alias: "facetDefinition", required: false }] }], partDefinitions: [{ type: i0.Input, args: [{ isSignal: true, alias: "partDefinitions", required: false }] }], parts: [{ type: i0.Input, args: [{ isSignal: true, alias: "parts", required: false }] }], typeThesaurus: [{ type: i0.Input, args: [{ isSignal: true, alias: "typeThesaurus", required: false }] }], addRequest: [{ type: i0.Output, args: ["addRequest"] }] } });
720
-
721
- /**
722
- * A pipe used locally in the item editor to determine whether
723
- * any of its parts can be previewed. To this end, this pipe requires
724
- * the part plus the list of available renderers keys and flatteners
725
- * keys. When the part is a base text, it is checked against flatteners
726
- * and renderers; else, it is checked against renderers only.
727
- * Ideally, a text part should have a flattener, while any other part
728
- * should have a renderer. When there is no flattener, we fallback
729
- * to the renderer if any.
730
- */
731
- class HasPreviewPipe {
732
- /**
733
- * Transform the received part into a boolean value telling whether
734
- * that part can be previewed or not.
735
- *
736
- * @param value The part.
737
- * @param rKeys The list of available renderers keys.
738
- * @param fKeys The list of available flatteners keys.
739
- * @returns True if preview available; else false.
740
- */
741
- transform(value, rKeys, fKeys) {
742
- if (!value) {
743
- return false;
744
- }
745
- // the preview key is equal to the typeId, optionally followed by
746
- // | and the roleId when present (except when it's "base-text")
747
- if (value.roleId === 'base-text') {
748
- return fKeys?.find((k) => k === value.typeId) ||
749
- rKeys?.find((k) => k === value.typeId)
750
- ? true
751
- : false;
752
- }
753
- const key = value.roleId ? `${value.typeId}|${value.roleId}` : value.typeId;
754
- return rKeys?.find((k) => k === key) ? true : false;
755
- }
756
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: HasPreviewPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
757
- static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.1", ngImport: i0, type: HasPreviewPipe, isStandalone: true, name: "hasPreview" });
758
- }
759
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: HasPreviewPipe, decorators: [{
760
- type: Pipe,
761
- args: [{ name: 'hasPreview' }]
762
- }] });
763
-
764
- /**
765
- * Item editor. This can edit a new or existing item's metadata and parts.
766
- * The ID of the item being edited is extracted from the route. For a new item
767
- * this is 'new', which here is stored as an empty string.
768
- */
769
- class ItemEditorComponent {
770
- itemLookupService;
771
- dialog;
772
- _router;
773
- _route;
774
- _snackbar;
775
- _appRepository;
776
- _repository;
777
- _itemService;
778
- _libraryRouteService;
779
- _dialogService;
780
- _authService;
781
- _userLevelService;
782
- _messaging;
783
- _envService;
784
- // signals from edited-item repository
785
- item;
786
- parts;
787
- partGroups;
788
- layerPartInfos;
789
- facet;
790
- newPartDefinitions;
791
- // signals from app repository
792
- facets;
793
- typeThesaurus;
794
- previewJKeys;
795
- previewFKeys;
796
- flagDefinitions;
797
- id = signal(undefined, /* @ts-ignore */
798
- ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
799
- _currentUser;
800
- user;
801
- userLevel;
802
- busy = signal(false, /* @ts-ignore */
803
- ...(ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []));
804
- hasMetadataBuilders = signal(false, /* @ts-ignore */
805
- ...(ngDevMode ? [{ debugName: "hasMetadataBuilders" }] : /* istanbul ignore next */ []));
806
- // flag-set signals
807
- _flagsValue;
808
- /** Flags adapted for FlagSetComponent; admin flags excluded for non-admins. */
809
- flagSetFlags;
810
- /** Admin-only flags shown read-only to non-admin users. */
811
- adminFlagDefs;
812
- /** Currently checked flag IDs derived from the flags form control value. */
813
- checkedFlagIds;
814
- // new part form
815
- newPartType;
816
- newPart;
817
- // item metadata form
818
- title;
819
- sortKey;
820
- description;
821
- facetCtrl;
822
- group;
823
- flags;
824
- metadata;
825
- constructor(itemLookupService, dialog, _router, _route, _snackbar, _appRepository, _repository, _itemService, _libraryRouteService, _dialogService, _authService, _userLevelService, _messaging, _envService, _formBuilder) {
826
- this.itemLookupService = itemLookupService;
827
- this.dialog = dialog;
828
- this._router = _router;
829
- this._route = _route;
830
- this._snackbar = _snackbar;
831
- this._appRepository = _appRepository;
832
- this._repository = _repository;
833
- this._itemService = _itemService;
834
- this._libraryRouteService = _libraryRouteService;
835
- this._dialogService = _dialogService;
836
- this._authService = _authService;
837
- this._userLevelService = _userLevelService;
838
- this._messaging = _messaging;
839
- this._envService = _envService;
840
- this.id.set(this._route.snapshot.params['id']);
841
- if (this.id() === 'new') {
842
- this.id.set(undefined);
843
- }
844
- this.hasMetadataBuilders.set(this._envService.get('hasMetadataBuilders') === 'true');
845
- // new part form
846
- this.newPartType = _formBuilder.control(null, Validators.required);
847
- this.newPart = _formBuilder.group({
848
- newPartType: this.newPartType,
849
- });
850
- // item metadata form
851
- this.title = _formBuilder.control(null, [
852
- Validators.required,
853
- Validators.maxLength(500),
854
- ]);
855
- this.sortKey = _formBuilder.control(null, [
856
- Validators.required,
857
- Validators.maxLength(500),
858
- ]);
859
- this.sortKey.disable();
860
- this.description = _formBuilder.control(null, [
861
- Validators.required,
862
- Validators.maxLength(1000),
863
- ]);
864
- this.facetCtrl = _formBuilder.control(null, Validators.required);
865
- this.group = _formBuilder.control(null, Validators.maxLength(100));
866
- this.flags = _formBuilder.control(0, { nonNullable: true });
867
- this.metadata = _formBuilder.group({
868
- title: this.title,
869
- sortKey: this.sortKey,
870
- description: this.description,
871
- facet: this.facetCtrl,
872
- group: this.group,
873
- flags: this.flags,
874
- });
875
- // signals from repositories
876
- this.item = toSignal(this._repository.item$);
877
- this.parts = toSignal(this._repository.parts$, { requireSync: true });
878
- this.partGroups = toSignal(this._repository.partGroups$, {
879
- requireSync: true,
880
- });
881
- this.layerPartInfos = toSignal(this._repository.layers$, {
882
- requireSync: true,
883
- });
884
- this.facet = toSignal(this._repository.facet$);
885
- this.newPartDefinitions = toSignal(this._repository.newPartDefinitions$, {
886
- requireSync: true,
887
- });
888
- this.facets = toSignal(this._appRepository.facets$, {
889
- requireSync: true,
890
- });
891
- this.typeThesaurus = toSignal(this._appRepository.typeThesaurus$);
892
- this.previewJKeys = toSignal(this._appRepository.previewJKeys$, {
893
- requireSync: true,
894
- });
895
- this.previewFKeys = toSignal(this._appRepository.previewFKeys$, {
896
- requireSync: true,
897
- });
898
- this.flagDefinitions = toSignal(this._appRepository.flags$, {
899
- requireSync: true,
900
- });
901
- // user signals
902
- this._currentUser = toSignal(this._authService.currentUser$, {
903
- initialValue: null,
904
- });
905
- this.user = computed(() => this._currentUser() ?? undefined, /* @ts-ignore */
906
- ...(ngDevMode ? [{ debugName: "user" }] : /* istanbul ignore next */ []));
907
- this.userLevel = computed(() => {
908
- // track user changes so userLevel is recomputed on login/logout
909
- this._currentUser();
910
- return this._userLevelService.getCurrentUserLevel();
911
- }, /* @ts-ignore */
912
- ...(ngDevMode ? [{ debugName: "userLevel" }] : /* istanbul ignore next */ []));
913
- // flags signal (tracks the flags form control value)
914
- this._flagsValue = toSignal(this.flags.valueChanges, { initialValue: 0 });
915
- // flags for FlagSetComponent: exclude admin flags for non-admins
916
- this.flagSetFlags = computed(() => this.flagDefinitions()
917
- .filter((def) => this.userLevel() >= 4 || !def.isAdmin)
918
- .map((def) => ({
919
- id: String(def.id),
920
- label: def.label,
921
- color: '#' + def.colorKey,
922
- })), /* @ts-ignore */
923
- ...(ngDevMode ? [{ debugName: "flagSetFlags" }] : /* istanbul ignore next */ []));
924
- // admin-only flags shown read-only when user is not admin
925
- this.adminFlagDefs = computed(() => {
926
- if (this.userLevel() >= 4)
927
- return [];
928
- return this.flagDefinitions().filter((def) => def.isAdmin === true);
929
- }, /* @ts-ignore */
930
- ...(ngDevMode ? [{ debugName: "adminFlagDefs" }] : /* istanbul ignore next */ []));
931
- // checked flag IDs derived from the bitmask value
932
- this.checkedFlagIds = computed(() => {
933
- const value = this._flagsValue();
934
- return this.flagDefinitions()
935
- .filter((def) => (value & def.id) !== 0)
936
- .map((def) => String(def.id));
937
- }, /* @ts-ignore */
938
- ...(ngDevMode ? [{ debugName: "checkedFlagIds" }] : /* istanbul ignore next */ []));
939
- // update the metadata form whenever the item changes
940
- effect(() => {
941
- this.updateMetadataForm(this.item());
942
- });
943
- }
944
- ngOnInit() {
945
- this._repository.load(this.id());
946
- }
947
- canDeactivate() {
948
- return !this.metadata.dirty;
949
- }
950
- updateMetadataForm(item) {
951
- if (!item) {
952
- this.metadata.reset();
953
- }
954
- else {
955
- this.title.setValue(item.title);
956
- this.sortKey.setValue(item.sortKey);
957
- this.description.setValue(item.description);
958
- this.facetCtrl.setValue(item.facetId ?? null);
959
- this.group.setValue(item.groupId ?? null);
960
- this.flags.setValue(item.flags);
961
- this.metadata.markAsPristine();
962
- }
963
- }
964
- /**
965
- * Called when the FlagSetComponent emits new checked flag IDs.
966
- * Converts the string IDs back to a bitmask integer and updates
967
- * the flags form control, preserving admin-flag bits for non-admins.
968
- */
969
- onFlagCheckedIdsChange(ids) {
970
- let value = 0;
971
- // non-admins cannot change admin flags: preserve their current bits
972
- if (this.userLevel() < 4) {
973
- const current = this.flags.value;
974
- for (const def of this.flagDefinitions()) {
975
- if (def.isAdmin && (current & def.id) !== 0) {
976
- value |= def.id;
977
- }
978
- }
979
- }
980
- for (const id of ids) {
981
- value |= Number(id);
982
- }
983
- this.flags.setValue(value);
984
- this.flags.markAsDirty();
985
- }
986
- getTypeIdName(typeId) {
987
- const typeThesaurus = this._appRepository.getTypeThesaurus();
988
- if (!typeThesaurus) {
989
- return typeId;
990
- }
991
- // strip :suffix if any
992
- const i = typeId.lastIndexOf(':');
993
- if (i > -1) {
994
- typeId = typeId.substring(0, i);
995
- }
996
- const entry = typeThesaurus.entries?.find((e) => e.id === typeId);
997
- return entry ? entry.value : typeId;
998
- }
999
- getRoleIdName(roleId) {
1000
- if (!roleId || !roleId.startsWith('fr.')) {
1001
- return roleId;
1002
- }
1003
- return this.getTypeIdName(roleId);
1004
- }
1005
- save() {
1006
- if (this.busy() || !this.metadata.valid) {
1007
- return;
1008
- }
1009
- const currentItem = this._repository.getItem();
1010
- if (!currentItem) {
1011
- return;
1012
- }
1013
- const item = { ...currentItem };
1014
- item.title = this.title.value?.trim() || '';
1015
- item.sortKey = this.sortKey.value?.trim() || '';
1016
- item.description = this.description.value?.trim() || '';
1017
- item.facetId = this.facetCtrl.value?.trim() || '';
1018
- item.groupId = this.group.value?.trim() || '';
1019
- item.flags = this.flags.value;
1020
- this.busy.set(true);
1021
- this._repository
1022
- .save(item)
1023
- .then((saved) => {
1024
- this._messaging.sendMessage(MESSAGE_ITEM_LIST_REPOSITORY_RESET);
1025
- // mark form pristine immediately: in a zoneless app the effect that
1026
- // calls updateMetadataForm (and thus markAsPristine) is scheduled
1027
- // asynchronously, so without this explicit call the pending-changes
1028
- // guard would still see a dirty form and prompt the user even though
1029
- // the item was just saved successfully.
1030
- this.metadata.markAsPristine();
1031
- // reload to force change in page URL for new items
1032
- if (!item.id) {
1033
- this.id.set(saved.id);
1034
- this._router.navigate(['/items', saved.id]);
1035
- }
1036
- })
1037
- .finally(() => {
1038
- this.busy.set(false);
1039
- });
1040
- }
1041
- partExists(typeId, roleId) {
1042
- const groups = this._repository.getPartGroups();
1043
- if (!groups) {
1044
- return false;
1045
- }
1046
- return groups.some((g) => {
1047
- return g.parts.some((p) => p.typeId === typeId &&
1048
- ((!p.roleId && !roleId) || p.roleId === roleId));
1049
- });
1050
- }
1051
- getPartIdName(typeId, roleId) {
1052
- return getPartIdName(typeId, roleId, this._appRepository.getTypeThesaurus());
1053
- }
1054
- addPart(def) {
1055
- if (!def && !this.newPartType.valid) {
1056
- return;
1057
- }
1058
- if (!this.id()) {
1059
- this._snackbar.open('Please save the item before adding parts', 'OK', {
1060
- duration: 3000,
1061
- });
1062
- return;
1063
- }
1064
- const typeId = def ? def.typeId : this.newPartType.value.typeId;
1065
- const roleId = def ? def.roleId : this.newPartType.value.roleId;
1066
- if (this.partExists(typeId, roleId)) {
1067
- return;
1068
- }
1069
- const route = this._libraryRouteService.buildPartEditorRoute(this.id(), 'new', typeId, roleId);
1070
- this._router.navigate([route.route], route.rid ? { queryParams: { rid: route.rid } } : {});
1071
- }
1072
- editPart(part) {
1073
- const route = this._libraryRouteService.buildPartEditorRoute(part.itemId, part.id, part.typeId, part.roleId);
1074
- this._router.navigate([route.route], route.rid ? { queryParams: { rid: route.rid } } : {});
1075
- }
1076
- previewPart(part) {
1077
- if (part.roleId?.startsWith('fr.')) {
1078
- // layer parts redirect to base-text
1079
- this._itemService
1080
- .getBaseTextPart(part.itemId)
1081
- .pipe(take(1))
1082
- .subscribe((p) => {
1083
- this._router.navigate(['preview', part.itemId, p.part.id, 'text'], {
1084
- queryParams: { lid: part.roleId },
1085
- });
1086
- });
1087
- }
1088
- else if (part.roleId === 'base-text') {
1089
- this._router.navigate(['preview', part.itemId, part.id, 'text']);
1090
- }
1091
- else {
1092
- this._router.navigate(['preview', part.itemId, part.id]);
1093
- }
1094
- }
1095
- deletePart(part) {
1096
- if (this.busy()) {
1097
- return;
1098
- }
1099
- this._dialogService
1100
- .confirm('Confirm Deletion', `Delete part "${part.typeId}"?`)
1101
- .subscribe((result) => {
1102
- if (!result) {
1103
- return;
1104
- }
1105
- this.busy.set(true);
1106
- this._repository.deletePart(part.id).then((_) => {
1107
- this.busy.set(false);
1108
- }, (error) => {
1109
- this.busy.set(false);
1110
- console.error(error);
1111
- this._snackbar.open('Error deleting part', 'OK');
1112
- });
1113
- });
1114
- }
1115
- addLayerPart(part) {
1116
- if (this.busy()) {
1117
- return;
1118
- }
1119
- let name = this.getTypeIdName(part.typeId);
1120
- if (part.roleId) {
1121
- name += ' for ' + this.getRoleIdName(part.roleId);
1122
- }
1123
- this._dialogService
1124
- .confirm('Confirm Addition', `Add layer "${name}"?`)
1125
- .subscribe((result) => {
1126
- if (!result) {
1127
- return;
1128
- }
1129
- this.busy.set(true);
1130
- this._repository
1131
- .addNewLayerPart(part.typeId, part.roleId)
1132
- .finally(() => this.busy.set(false));
1133
- });
1134
- }
1135
- setPartsScope(request) {
1136
- this._repository.setPartThesaurusScope(request.ids, request.scope);
1137
- }
1138
- onCopyPart(part) {
1139
- if (this.busy()) {
1140
- return;
1141
- }
1142
- const dialogRef = this.dialog.open(ItemLookupDialogComponent, {
1143
- height: '180px',
1144
- width: '250px',
1145
- data: {},
1146
- });
1147
- dialogRef.afterClosed().subscribe((targetItem) => {
1148
- if (!targetItem || part.itemId === targetItem.id) {
1149
- return;
1150
- }
1151
- if (this.facetCtrl.value !== targetItem.facetId) {
1152
- this._snackbar.open('Cannot copy part to an item with a different facet', 'OK');
1153
- return;
1154
- }
1155
- this.busy.set(true);
1156
- this._itemService
1157
- .partWithTypeAndRoleExists(targetItem.id, part.typeId, part.roleId)
1158
- .subscribe((exists) => {
1159
- if (exists) {
1160
- this._snackbar.open('Part already exists in target item', 'OK');
1161
- this.busy.set(false);
1162
- return;
1163
- }
1164
- part.id = '';
1165
- part.itemId = targetItem.id;
1166
- this._itemService.addPart(part).subscribe({
1167
- next: (_) => {
1168
- this._snackbar.open('Part copied', 'OK', { duration: 3000 });
1169
- },
1170
- error: (error) => {
1171
- console.error(error);
1172
- this._snackbar.open('Error copying part', 'OK');
1173
- },
1174
- complete: () => {
1175
- this.busy.set(false);
1176
- },
1177
- });
1178
- });
1179
- });
1180
- }
1181
- onGenerateItems() {
1182
- if (this.busy()) {
1183
- return;
1184
- }
1185
- const dialogRef = this.dialog.open(ItemGenerateDialogComponent, {
1186
- height: '400px',
1187
- width: '350px',
1188
- data: {
1189
- flags: this.flagDefinitions(),
1190
- },
1191
- });
1192
- dialogRef
1193
- .afterClosed()
1194
- .subscribe((data) => {
1195
- if (!data) {
1196
- return;
1197
- }
1198
- this.busy.set(true);
1199
- this._itemService
1200
- .generateItems(data.count, this.id(), data.title, data.flags)
1201
- .subscribe({
1202
- next: (_) => {
1203
- this._messaging.sendMessage(MESSAGE_ITEM_LIST_REPOSITORY_RESET);
1204
- this._snackbar.open('Items generated', 'OK', { duration: 3000 });
1205
- },
1206
- error: (error) => {
1207
- console.error(error);
1208
- this._snackbar.open('Error generating items', 'OK');
1209
- },
1210
- complete: () => {
1211
- this.busy.set(false);
1212
- },
1213
- });
1214
- });
1215
- }
1216
- generateTitle() {
1217
- if (this.busy()) {
1218
- return;
1219
- }
1220
- this.busy.set(true);
1221
- this._itemService.getItemMetadata(this.id(), 'T').subscribe({
1222
- next: (title) => {
1223
- const result = title['T'];
1224
- if (result) {
1225
- this.title.setValue(result);
1226
- this.title.markAsDirty();
1227
- this.title.updateValueAndValidity();
1228
- }
1229
- else {
1230
- this._snackbar.open('No title generated', 'OK', { duration: 3000 });
1231
- }
1232
- },
1233
- error: (error) => {
1234
- console.error(error);
1235
- this._snackbar.open('Error generating title', 'OK');
1236
- },
1237
- complete: () => {
1238
- this.busy.set(false);
1239
- },
1240
- });
1241
- }
1242
- generateDescription() {
1243
- if (this.busy()) {
1244
- return;
1245
- }
1246
- this.busy.set(true);
1247
- this._itemService.getItemMetadata(this.id(), 'D').subscribe({
1248
- next: (description) => {
1249
- const result = description['D'];
1250
- if (result) {
1251
- this.description.setValue(result);
1252
- this.description.markAsDirty();
1253
- this.description.updateValueAndValidity();
1254
- }
1255
- else {
1256
- this._snackbar.open('No description generated', 'OK', {
1257
- duration: 3000,
1258
- });
1259
- }
1260
- },
1261
- error: (error) => {
1262
- console.error(error);
1263
- this._snackbar.open('Error generating description', 'OK');
1264
- },
1265
- complete: () => {
1266
- this.busy.set(false);
1267
- },
1268
- });
1269
- }
1270
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ItemEditorComponent, deps: [{ token: i2$1.ItemRefLookupService }, { token: i2.MatDialog }, { token: i3$1.Router }, { token: i3$1.ActivatedRoute }, { token: i4.MatSnackBar }, { token: i1.AppRepository }, { token: EditedItemRepository }, { token: i7.ItemService }, { token: i8.LibraryRouteService }, { token: i3.DialogService }, { token: i10.AuthJwtService }, { token: i7.UserLevelService }, { token: i7.MessagingService }, { token: i11.EnvService }, { token: i1$1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component });
1271
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: ItemEditorComponent, isStandalone: true, selector: "cadmus-item-editor", ngImport: i0, template: "<mat-card appearance=\"outlined\">\r\n <mat-card-content>\r\n <div>\r\n <cadmus-current-item-bar />\r\n </div>\r\n @if (busy()) {\r\n <mat-progress-bar mode=\"indeterminate\" />\r\n }\r\n\r\n <!-- item content -->\r\n <mat-tab-group [selectedIndex]=\"id() ? 1 : 0\">\r\n <!-- metadata -->\r\n <mat-tab label=\"Metadata\">\r\n <form [formGroup]=\"metadata\" (ngSubmit)=\"save()\">\r\n <div class=\"form-row\">\r\n <!-- title -->\r\n <mat-form-field class=\"flex-field\">\r\n <mat-label>title</mat-label>\r\n <input matInput type=\"text\" id=\"title\" [formControl]=\"title\" />\r\n @if (\r\n title.hasError(\"required\") && (title.touched || title.dirty)\r\n ) {\r\n <mat-error>enter title</mat-error>\r\n }\r\n @if (\r\n title.hasError(\"maxLength\") && (title.touched || title.dirty)\r\n ) {\r\n <mat-error>title too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n @if (hasMetadataBuilders()) {\r\n <!-- auto title -->\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n [disabled]=\"busy()\"\r\n (click)=\"generateTitle()\"\r\n >\r\n <mat-icon matTooltip=\"Generate title\">auto_awesome</mat-icon>\r\n </button>\r\n }\r\n\r\n <!-- sortKey -->\r\n <mat-form-field class=\"flex-field\">\r\n <mat-label>sort key</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"sortKey\"\r\n [formControl]=\"sortKey\"\r\n />\r\n @if (\r\n sortKey.hasError(\"required\") &&\r\n (sortKey.touched || sortKey.dirty)\r\n ) {\r\n <mat-error>enter sort key</mat-error>\r\n }\r\n @if (\r\n sortKey.hasError(\"maxLength\") &&\r\n (sortKey.touched || sortKey.dirty)\r\n ) {\r\n <mat-error>sort key too long</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- description -->\r\n <div class=\"flex-row\">\r\n <mat-form-field class=\"item\">\r\n <mat-label>description</mat-label>\r\n <textarea\r\n rows=\"2\"\r\n matInput\r\n id=\"description\"\r\n [formControl]=\"description\"\r\n ></textarea>\r\n @if (\r\n description.hasError(\"required\") &&\r\n (description.touched || description.dirty)\r\n ) {\r\n <mat-error>enter description</mat-error>\r\n }\r\n @if (\r\n description.hasError(\"maxLength\") &&\r\n (description.touched || description.dirty)\r\n ) {\r\n <mat-error>description too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n @if (hasMetadataBuilders()) {\r\n <!-- auto description -->\r\n <button\r\n class=\"item fit\"\r\n type=\"button\"\r\n mat-icon-button\r\n [disabled]=\"busy()\"\r\n (click)=\"generateDescription()\"\r\n >\r\n <mat-icon matTooltip=\"Generate description\"\r\n >auto_awesome</mat-icon\r\n >\r\n </button>\r\n }\r\n </div>\r\n\r\n <!-- facet -->\r\n <div class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>facet</mat-label>\r\n <mat-select [formControl]=\"facetCtrl\" required=\"true\">\r\n @for (f of facets(); track f.id) {\r\n <mat-option [value]=\"f.id\">\r\n {{ f.label }}\r\n </mat-option>\r\n }\r\n </mat-select>\r\n <mat-error>please select a facet</mat-error>\r\n </mat-form-field>\r\n\r\n <!-- group -->\r\n <mat-form-field>\r\n <mat-label>group ID</mat-label>\r\n <input matInput [formControl]=\"group\" />\r\n @if (\r\n group.hasError(\"maxLength\") && (group.dirty || group.touched)\r\n ) {\r\n <mat-error>too long</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- flags -->\r\n <fieldset>\r\n <legend>flags</legend>\r\n <!-- read-only admin flags for non-admin users -->\r\n @if (adminFlagDefs().length) {\r\n <div class=\"admin-flags\">\r\n @for (def of adminFlagDefs(); track def.id) {\r\n <span class=\"admin-flag\">\r\n <span [style.color]=\"'#' + def.colorKey\">&#x25c6;</span>\r\n &nbsp;{{ def.label }}\r\n </span>\r\n }\r\n </div>\r\n }\r\n <!-- editable flags -->\r\n @if (flagSetFlags().length) {\r\n <cadmus-ui-flag-set\r\n [hideToolbar]=\"true\"\r\n [flags]=\"flagSetFlags()\"\r\n [checkedIds]=\"checkedFlagIds()\"\r\n (checkedIdsChange)=\"onFlagCheckedIdsChange($event)\"\r\n />\r\n }\r\n </fieldset>\r\n <br />\r\n\r\n <!-- action buttons -->\r\n @if (userLevel() > 1) {\r\n <div class=\"form-row\">\r\n <button\r\n type=\"button\"\r\n mat-flat-button\r\n class=\"mat-warn\"\r\n (click)=\"onGenerateItems()\"\r\n >\r\n <mat-icon>copy_all</mat-icon> generate\r\n </button>\r\n <button\r\n type=\"submit\"\r\n mat-flat-button\r\n class=\"mat-primary\"\r\n [disabled]=\"busy()\"\r\n matTooltip=\"Save metadata\"\r\n (click)=\"save()\"\r\n >\r\n <mat-icon>save</mat-icon> save\r\n </button>\r\n </div>\r\n }\r\n </form>\r\n </mat-tab>\r\n\r\n <!-- parts -->\r\n @if (id()) {\r\n <mat-tab label=\"Parts\">\r\n <div class=\"new-part\">\r\n <form [formGroup]=\"newPart\" class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>part</mat-label>\r\n <mat-select [formControl]=\"newPartType\" required>\r\n @for (\r\n p of newPartDefinitions();\r\n track p.typeId + \":\" + (p.roleId || \"\")\r\n ) {\r\n <mat-option [value]=\"p\">\r\n <span\r\n [style.color]=\"'#' + p.colorKey\"\r\n class=\"new-part-icon\"\r\n >&#x2b24;</span\r\n >\r\n {{ getPartIdName(p.typeId, p.roleId) }}\r\n </mat-option>\r\n }\r\n </mat-select>\r\n <mat-error>part type required</mat-error>\r\n </mat-form-field>\r\n <button\r\n mat-flat-button\r\n class=\"mat-primary\"\r\n type=\"button\"\r\n [disabled]=\"userLevel() < 2 || busy() || !newPart.valid\"\r\n (click)=\"addPart()\"\r\n matTooltip=\"Add a new part of the selected type\"\r\n >\r\n <mat-icon>add_circle</mat-icon>\r\n part\r\n </button>\r\n </form>\r\n </div>\r\n <mat-divider></mat-divider>\r\n @for (group of partGroups(); track group.key) {\r\n <mat-expansion-panel expanded=\"true\" class=\"group-header\">\r\n <mat-expansion-panel-header>\r\n <mat-panel-title\r\n ><strong>{{ group.label }}</strong></mat-panel-title\r\n >\r\n <mat-panel-description>{{\r\n group.parts.length\r\n }}</mat-panel-description>\r\n </mat-expansion-panel-header>\r\n <table class=\"parts-table\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>type</th>\r\n <th>role</th>\r\n <th class=\"noif-lt-xs\">modified</th>\r\n <th class=\"noif-lt-xs\">user</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n @for (\r\n part of group.parts;\r\n track part.typeId + \":\" + (part.roleId || \"\")\r\n ) {\r\n <tr>\r\n <!-- edit -->\r\n <td class=\"fit-width\">\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n [disabled]=\"busy()\"\r\n (click)=\"editPart(part)\"\r\n matTooltip=\"Edit this part\"\r\n >\r\n <mat-icon class=\"mat-primary\">create</mat-icon>\r\n </button>\r\n <!-- delete -->\r\n @if (\r\n user()?.roles?.length &&\r\n (user()?.roles?.includes(\"admin\") ||\r\n user()?.roles?.includes(\"editor\") ||\r\n user()?.roles?.includes(\"operator\"))\r\n ) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n [disabled]=\"userLevel() < 2 || busy()\"\r\n (click)=\"deletePart(part)\"\r\n matTooltip=\"Delete this part\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete</mat-icon>\r\n </button>\r\n }\r\n <!-- copy ID -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Copy this part ID\"\r\n [cdkCopyToClipboard]=\"part.id\"\r\n >\r\n <mat-icon>assignment</mat-icon>\r\n </button>\r\n <!-- copy into item -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Copy part into another item\"\r\n (click)=\"onCopyPart(part)\"\r\n >\r\n <mat-icon>open_in_new</mat-icon>\r\n </button>\r\n <!-- preview -->\r\n @if (\r\n part | hasPreview: previewJKeys() : previewFKeys()\r\n ) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Preview this part\"\r\n (click)=\"previewPart(part)\"\r\n >\r\n <mat-icon>preview</mat-icon>\r\n </button>\r\n }\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td class=\"noif-lt-xs\">\r\n {{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\r\n </td>\r\n <td class=\"noif-lt-xs\">{{ part.userId }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </mat-expansion-panel>\r\n }\r\n <cadmus-missing-parts\r\n [facetDefinition]=\"facet()\"\r\n [partDefinitions]=\"\r\n $safeNavigationMigration(facet()?.partDefinitions)\r\n \"\r\n [parts]=\"parts()\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n (addRequest)=\"addPart($event)\"\r\n />\r\n </mat-tab>\r\n }\r\n\r\n <!-- layers -->\r\n @if (id()) {\r\n <mat-tab label=\"Layers\">\r\n <table id=\"layers\">\r\n <thead>\r\n <th aria-label=\"actions\"></th>\r\n <th>type</th>\r\n <th>role</th>\r\n <th>frr.</th>\r\n <th>last modified</th>\r\n </thead>\r\n <tbody>\r\n @for (\r\n part of layerPartInfos();\r\n track part.typeId + \":\" + (part.roleId || \"\")\r\n ) {\r\n <tr>\r\n <td class=\"fit-width\">\r\n @if (!part.isAbsent) {\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Edit this layer part\"\r\n (click)=\"editPart(part)\"\r\n >\r\n <mat-icon class=\"mat-primary\">edit</mat-icon>\r\n </button>\r\n }\r\n @if (part.isAbsent) {\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Add this layer part\"\r\n [disabled]=\"userLevel() < 2\"\r\n (click)=\"addLayerPart(part)\"\r\n >\r\n <mat-icon class=\"mat-primary\">add_circle</mat-icon>\r\n </button>\r\n }\r\n @if (!part.isAbsent) {\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Delete this layer part\"\r\n [disabled]=\"userLevel() < 2\"\r\n (click)=\"deletePart(part)\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete</mat-icon>\r\n </button>\r\n }\r\n @if (!part.isAbsent) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Copy this part ID\"\r\n [cdkCopyToClipboard]=\"part.id\"\r\n >\r\n <mat-icon>assignment</mat-icon>\r\n </button>\r\n }\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td\r\n [class.count-n]=\"part.fragmentCount\"\r\n [class.count-z]=\"!part.fragmentCount\"\r\n >\r\n {{ part.fragmentCount }}\r\n </td>\r\n <td>\r\n @if (!part.isAbsent) {\r\n <span>\r\n {{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\r\n </span>\r\n }\r\n </td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </mat-tab>\r\n }\r\n\r\n <!-- thesaurus scopes -->\r\n @if (parts().length) {\r\n <mat-tab label=\"Th-Scopes\">\r\n <cadmus-parts-scope-editor\r\n [parts]=\"parts()\"\r\n [readonly]=\"userLevel() < 2 || busy() ? true : false\"\r\n (setScopeRequest)=\"setPartsScope($event)\"\r\n />\r\n </mat-tab>\r\n }\r\n </mat-tab-group>\r\n </mat-card-content>\r\n</mat-card>\r\n", styles: [".full-width{width:100%}.flex-field{flex:1 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)}table#layers td{padding:0 6px}table#layers th{text-align:left}div.new-part{margin-left:32px}span.new-part-role{color:var(--mat-sys-on-surface-variant);margin-left:8px;vertical-align:middle}span.new-part-icon{margin:0 4px;vertical-align:middle}td.count-n{text-align:center;color:var(--mat-sys-success)}td.count-z{text-align:center;color:var(--mat-sys-error)}input.id{font-family:Courier New,Courier,monospace;color:var(--mat-sys-on-surface-variant);min-width:22em}.admin-flags{margin-bottom:4px}.admin-flag{margin-left:12px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.group-header{margin-top:6px}table.parts-table{width:100%}table.parts-table th{text-align:left}fieldset{border:1px solid var(--mat-sys-on-surface-variant);border-radius:6px;padding:6px;margin:8px 0}@media only screen and (max-width:599px){.noif-lt-xs{display:none}}.flex-row{display:flex;flex-wrap:wrap}.flex-row .item{box-sizing:border-box}.flex-row .item.fit{flex:0 0 auto}.flex-row .item:not(.fit){flex:1 1 auto}\n"], dependencies: [{ kind: "component", type: MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: MatCardContent, selector: "mat-card-content" }, { kind: "directive", type: MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "directive", type: CdkCopyToClipboard, selector: "[cdkCopyToClipboard]", inputs: ["cdkCopyToClipboard", "cdkCopyToClipboardAttempts"], outputs: ["cdkCopyToClipboardCopied"] }, { kind: "component", type: MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { 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: "component", type: MatTab, selector: "mat-tab", inputs: ["disabled", "label", "aria-label", "aria-labelledby", "labelClass", "bodyClass", "id"], exportAs: ["matTab"] }, { 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.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { 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: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: MatLabel, selector: "mat-label" }, { 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: MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { 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: "component", type: MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "component", type: 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: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { 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: "directive", type: MatExpansionPanelDescription, selector: "mat-panel-description" }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: MissingPartsComponent, selector: "cadmus-missing-parts", inputs: ["facetDefinition", "partDefinitions", "parts", "typeThesaurus"], outputs: ["addRequest"] }, { kind: "component", type: PartsScopeEditorComponent, selector: "cadmus-parts-scope-editor", inputs: ["parts", "readonly"], outputs: ["setScopeRequest"] }, { kind: "component", type: PartBadgeComponent, selector: "cadmus-part-badge", inputs: ["badgeType", "typeThesaurus", "facetDefinition", "partTypeIds"] }, { kind: "component", type: CurrentItemBarComponent, selector: "cadmus-current-item-bar" }, { kind: "component", type: FlagSetComponent, selector: "cadmus-ui-flag-set", inputs: ["flags", "checkedIds", "allowCustom", "hideToolbar", "numbering"], outputs: ["checkedIdsChange"] }, { kind: "pipe", type: DatePipe, name: "date" }, { kind: "pipe", type: HasPreviewPipe, name: "hasPreview" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1272
- }
1273
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ItemEditorComponent, decorators: [{
1274
- type: Component,
1275
- args: [{ selector: 'cadmus-item-editor', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
1276
- MatCard,
1277
- MatCardContent,
1278
- MatTooltip,
1279
- CdkCopyToClipboard,
1280
- MatProgressBar,
1281
- MatTabGroup,
1282
- MatTab,
1283
- ReactiveFormsModule,
1284
- MatFormField,
1285
- MatLabel,
1286
- MatInput,
1287
- MatError,
1288
- MatSelect,
1289
- MatOption,
1290
- MatButton,
1291
- MatIcon,
1292
- MatDivider,
1293
- MatExpansionPanel,
1294
- MatExpansionPanelHeader,
1295
- MatExpansionPanelTitle,
1296
- MatExpansionPanelDescription,
1297
- MatIconButton,
1298
- MissingPartsComponent,
1299
- DatePipe,
1300
- HasPreviewPipe,
1301
- PartsScopeEditorComponent,
1302
- PartBadgeComponent,
1303
- CurrentItemBarComponent,
1304
- FlagSetComponent,
1305
- ], template: "<mat-card appearance=\"outlined\">\r\n <mat-card-content>\r\n <div>\r\n <cadmus-current-item-bar />\r\n </div>\r\n @if (busy()) {\r\n <mat-progress-bar mode=\"indeterminate\" />\r\n }\r\n\r\n <!-- item content -->\r\n <mat-tab-group [selectedIndex]=\"id() ? 1 : 0\">\r\n <!-- metadata -->\r\n <mat-tab label=\"Metadata\">\r\n <form [formGroup]=\"metadata\" (ngSubmit)=\"save()\">\r\n <div class=\"form-row\">\r\n <!-- title -->\r\n <mat-form-field class=\"flex-field\">\r\n <mat-label>title</mat-label>\r\n <input matInput type=\"text\" id=\"title\" [formControl]=\"title\" />\r\n @if (\r\n title.hasError(\"required\") && (title.touched || title.dirty)\r\n ) {\r\n <mat-error>enter title</mat-error>\r\n }\r\n @if (\r\n title.hasError(\"maxLength\") && (title.touched || title.dirty)\r\n ) {\r\n <mat-error>title too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n @if (hasMetadataBuilders()) {\r\n <!-- auto title -->\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n [disabled]=\"busy()\"\r\n (click)=\"generateTitle()\"\r\n >\r\n <mat-icon matTooltip=\"Generate title\">auto_awesome</mat-icon>\r\n </button>\r\n }\r\n\r\n <!-- sortKey -->\r\n <mat-form-field class=\"flex-field\">\r\n <mat-label>sort key</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"sortKey\"\r\n [formControl]=\"sortKey\"\r\n />\r\n @if (\r\n sortKey.hasError(\"required\") &&\r\n (sortKey.touched || sortKey.dirty)\r\n ) {\r\n <mat-error>enter sort key</mat-error>\r\n }\r\n @if (\r\n sortKey.hasError(\"maxLength\") &&\r\n (sortKey.touched || sortKey.dirty)\r\n ) {\r\n <mat-error>sort key too long</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- description -->\r\n <div class=\"flex-row\">\r\n <mat-form-field class=\"item\">\r\n <mat-label>description</mat-label>\r\n <textarea\r\n rows=\"2\"\r\n matInput\r\n id=\"description\"\r\n [formControl]=\"description\"\r\n ></textarea>\r\n @if (\r\n description.hasError(\"required\") &&\r\n (description.touched || description.dirty)\r\n ) {\r\n <mat-error>enter description</mat-error>\r\n }\r\n @if (\r\n description.hasError(\"maxLength\") &&\r\n (description.touched || description.dirty)\r\n ) {\r\n <mat-error>description too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n @if (hasMetadataBuilders()) {\r\n <!-- auto description -->\r\n <button\r\n class=\"item fit\"\r\n type=\"button\"\r\n mat-icon-button\r\n [disabled]=\"busy()\"\r\n (click)=\"generateDescription()\"\r\n >\r\n <mat-icon matTooltip=\"Generate description\"\r\n >auto_awesome</mat-icon\r\n >\r\n </button>\r\n }\r\n </div>\r\n\r\n <!-- facet -->\r\n <div class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>facet</mat-label>\r\n <mat-select [formControl]=\"facetCtrl\" required=\"true\">\r\n @for (f of facets(); track f.id) {\r\n <mat-option [value]=\"f.id\">\r\n {{ f.label }}\r\n </mat-option>\r\n }\r\n </mat-select>\r\n <mat-error>please select a facet</mat-error>\r\n </mat-form-field>\r\n\r\n <!-- group -->\r\n <mat-form-field>\r\n <mat-label>group ID</mat-label>\r\n <input matInput [formControl]=\"group\" />\r\n @if (\r\n group.hasError(\"maxLength\") && (group.dirty || group.touched)\r\n ) {\r\n <mat-error>too long</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- flags -->\r\n <fieldset>\r\n <legend>flags</legend>\r\n <!-- read-only admin flags for non-admin users -->\r\n @if (adminFlagDefs().length) {\r\n <div class=\"admin-flags\">\r\n @for (def of adminFlagDefs(); track def.id) {\r\n <span class=\"admin-flag\">\r\n <span [style.color]=\"'#' + def.colorKey\">&#x25c6;</span>\r\n &nbsp;{{ def.label }}\r\n </span>\r\n }\r\n </div>\r\n }\r\n <!-- editable flags -->\r\n @if (flagSetFlags().length) {\r\n <cadmus-ui-flag-set\r\n [hideToolbar]=\"true\"\r\n [flags]=\"flagSetFlags()\"\r\n [checkedIds]=\"checkedFlagIds()\"\r\n (checkedIdsChange)=\"onFlagCheckedIdsChange($event)\"\r\n />\r\n }\r\n </fieldset>\r\n <br />\r\n\r\n <!-- action buttons -->\r\n @if (userLevel() > 1) {\r\n <div class=\"form-row\">\r\n <button\r\n type=\"button\"\r\n mat-flat-button\r\n class=\"mat-warn\"\r\n (click)=\"onGenerateItems()\"\r\n >\r\n <mat-icon>copy_all</mat-icon> generate\r\n </button>\r\n <button\r\n type=\"submit\"\r\n mat-flat-button\r\n class=\"mat-primary\"\r\n [disabled]=\"busy()\"\r\n matTooltip=\"Save metadata\"\r\n (click)=\"save()\"\r\n >\r\n <mat-icon>save</mat-icon> save\r\n </button>\r\n </div>\r\n }\r\n </form>\r\n </mat-tab>\r\n\r\n <!-- parts -->\r\n @if (id()) {\r\n <mat-tab label=\"Parts\">\r\n <div class=\"new-part\">\r\n <form [formGroup]=\"newPart\" class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>part</mat-label>\r\n <mat-select [formControl]=\"newPartType\" required>\r\n @for (\r\n p of newPartDefinitions();\r\n track p.typeId + \":\" + (p.roleId || \"\")\r\n ) {\r\n <mat-option [value]=\"p\">\r\n <span\r\n [style.color]=\"'#' + p.colorKey\"\r\n class=\"new-part-icon\"\r\n >&#x2b24;</span\r\n >\r\n {{ getPartIdName(p.typeId, p.roleId) }}\r\n </mat-option>\r\n }\r\n </mat-select>\r\n <mat-error>part type required</mat-error>\r\n </mat-form-field>\r\n <button\r\n mat-flat-button\r\n class=\"mat-primary\"\r\n type=\"button\"\r\n [disabled]=\"userLevel() < 2 || busy() || !newPart.valid\"\r\n (click)=\"addPart()\"\r\n matTooltip=\"Add a new part of the selected type\"\r\n >\r\n <mat-icon>add_circle</mat-icon>\r\n part\r\n </button>\r\n </form>\r\n </div>\r\n <mat-divider></mat-divider>\r\n @for (group of partGroups(); track group.key) {\r\n <mat-expansion-panel expanded=\"true\" class=\"group-header\">\r\n <mat-expansion-panel-header>\r\n <mat-panel-title\r\n ><strong>{{ group.label }}</strong></mat-panel-title\r\n >\r\n <mat-panel-description>{{\r\n group.parts.length\r\n }}</mat-panel-description>\r\n </mat-expansion-panel-header>\r\n <table class=\"parts-table\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>type</th>\r\n <th>role</th>\r\n <th class=\"noif-lt-xs\">modified</th>\r\n <th class=\"noif-lt-xs\">user</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n @for (\r\n part of group.parts;\r\n track part.typeId + \":\" + (part.roleId || \"\")\r\n ) {\r\n <tr>\r\n <!-- edit -->\r\n <td class=\"fit-width\">\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n [disabled]=\"busy()\"\r\n (click)=\"editPart(part)\"\r\n matTooltip=\"Edit this part\"\r\n >\r\n <mat-icon class=\"mat-primary\">create</mat-icon>\r\n </button>\r\n <!-- delete -->\r\n @if (\r\n user()?.roles?.length &&\r\n (user()?.roles?.includes(\"admin\") ||\r\n user()?.roles?.includes(\"editor\") ||\r\n user()?.roles?.includes(\"operator\"))\r\n ) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n [disabled]=\"userLevel() < 2 || busy()\"\r\n (click)=\"deletePart(part)\"\r\n matTooltip=\"Delete this part\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete</mat-icon>\r\n </button>\r\n }\r\n <!-- copy ID -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Copy this part ID\"\r\n [cdkCopyToClipboard]=\"part.id\"\r\n >\r\n <mat-icon>assignment</mat-icon>\r\n </button>\r\n <!-- copy into item -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Copy part into another item\"\r\n (click)=\"onCopyPart(part)\"\r\n >\r\n <mat-icon>open_in_new</mat-icon>\r\n </button>\r\n <!-- preview -->\r\n @if (\r\n part | hasPreview: previewJKeys() : previewFKeys()\r\n ) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Preview this part\"\r\n (click)=\"previewPart(part)\"\r\n >\r\n <mat-icon>preview</mat-icon>\r\n </button>\r\n }\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td class=\"noif-lt-xs\">\r\n {{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\r\n </td>\r\n <td class=\"noif-lt-xs\">{{ part.userId }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </mat-expansion-panel>\r\n }\r\n <cadmus-missing-parts\r\n [facetDefinition]=\"facet()\"\r\n [partDefinitions]=\"\r\n $safeNavigationMigration(facet()?.partDefinitions)\r\n \"\r\n [parts]=\"parts()\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n (addRequest)=\"addPart($event)\"\r\n />\r\n </mat-tab>\r\n }\r\n\r\n <!-- layers -->\r\n @if (id()) {\r\n <mat-tab label=\"Layers\">\r\n <table id=\"layers\">\r\n <thead>\r\n <th aria-label=\"actions\"></th>\r\n <th>type</th>\r\n <th>role</th>\r\n <th>frr.</th>\r\n <th>last modified</th>\r\n </thead>\r\n <tbody>\r\n @for (\r\n part of layerPartInfos();\r\n track part.typeId + \":\" + (part.roleId || \"\")\r\n ) {\r\n <tr>\r\n <td class=\"fit-width\">\r\n @if (!part.isAbsent) {\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Edit this layer part\"\r\n (click)=\"editPart(part)\"\r\n >\r\n <mat-icon class=\"mat-primary\">edit</mat-icon>\r\n </button>\r\n }\r\n @if (part.isAbsent) {\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Add this layer part\"\r\n [disabled]=\"userLevel() < 2\"\r\n (click)=\"addLayerPart(part)\"\r\n >\r\n <mat-icon class=\"mat-primary\">add_circle</mat-icon>\r\n </button>\r\n }\r\n @if (!part.isAbsent) {\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Delete this layer part\"\r\n [disabled]=\"userLevel() < 2\"\r\n (click)=\"deletePart(part)\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete</mat-icon>\r\n </button>\r\n }\r\n @if (!part.isAbsent) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Copy this part ID\"\r\n [cdkCopyToClipboard]=\"part.id\"\r\n >\r\n <mat-icon>assignment</mat-icon>\r\n </button>\r\n }\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td\r\n [class.count-n]=\"part.fragmentCount\"\r\n [class.count-z]=\"!part.fragmentCount\"\r\n >\r\n {{ part.fragmentCount }}\r\n </td>\r\n <td>\r\n @if (!part.isAbsent) {\r\n <span>\r\n {{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\r\n </span>\r\n }\r\n </td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </mat-tab>\r\n }\r\n\r\n <!-- thesaurus scopes -->\r\n @if (parts().length) {\r\n <mat-tab label=\"Th-Scopes\">\r\n <cadmus-parts-scope-editor\r\n [parts]=\"parts()\"\r\n [readonly]=\"userLevel() < 2 || busy() ? true : false\"\r\n (setScopeRequest)=\"setPartsScope($event)\"\r\n />\r\n </mat-tab>\r\n }\r\n </mat-tab-group>\r\n </mat-card-content>\r\n</mat-card>\r\n", styles: [".full-width{width:100%}.flex-field{flex:1 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)}table#layers td{padding:0 6px}table#layers th{text-align:left}div.new-part{margin-left:32px}span.new-part-role{color:var(--mat-sys-on-surface-variant);margin-left:8px;vertical-align:middle}span.new-part-icon{margin:0 4px;vertical-align:middle}td.count-n{text-align:center;color:var(--mat-sys-success)}td.count-z{text-align:center;color:var(--mat-sys-error)}input.id{font-family:Courier New,Courier,monospace;color:var(--mat-sys-on-surface-variant);min-width:22em}.admin-flags{margin-bottom:4px}.admin-flag{margin-left:12px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.group-header{margin-top:6px}table.parts-table{width:100%}table.parts-table th{text-align:left}fieldset{border:1px solid var(--mat-sys-on-surface-variant);border-radius:6px;padding:6px;margin:8px 0}@media only screen and (max-width:599px){.noif-lt-xs{display:none}}.flex-row{display:flex;flex-wrap:wrap}.flex-row .item{box-sizing:border-box}.flex-row .item.fit{flex:0 0 auto}.flex-row .item:not(.fit){flex:1 1 auto}\n"] }]
1306
- }], ctorParameters: () => [{ type: i2$1.ItemRefLookupService }, { type: i2.MatDialog }, { type: i3$1.Router }, { type: i3$1.ActivatedRoute }, { type: i4.MatSnackBar }, { type: i1.AppRepository }, { type: EditedItemRepository }, { type: i7.ItemService }, { type: i8.LibraryRouteService }, { type: i3.DialogService }, { type: i10.AuthJwtService }, { type: i7.UserLevelService }, { type: i7.MessagingService }, { type: i11.EnvService }, { type: i1$1.FormBuilder }] });
1307
-
1308
- /*
1309
- * Public API Surface of cadmus-item-editor
1310
- */
1311
-
1312
- /**
1313
- * Generated bundle index. Do not edit.
1314
- */
1315
-
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, Inject, Injectable, Pipe, computed, effect, input, output, signal } from "@angular/core";
3
+ import { BehaviorSubject, forkJoin } from "rxjs";
4
+ import * as i1$2 from "@myrmidon/cadmus-state";
5
+ import * as i2$1 from "@myrmidon/cadmus-api";
6
+ import { DatePipe } from "@angular/common";
7
+ import { toSignal } from "@angular/core/rxjs-interop";
8
+ import { MatTooltip } from "@angular/material/tooltip";
9
+ import * as i1$1 from "@angular/forms";
10
+ import { ReactiveFormsModule, Validators } from "@angular/forms";
11
+ import { take } from "rxjs/operators";
12
+ import { MatCard, MatCardContent } from "@angular/material/card";
13
+ import { CdkCopyToClipboard } from "@angular/cdk/clipboard";
14
+ import { MatProgressBar } from "@angular/material/progress-bar";
15
+ import { MatTab, MatTabGroup } from "@angular/material/tabs";
16
+ import { MatError, MatFormField, MatHint, MatLabel } from "@angular/material/form-field";
17
+ import { MatInput } from "@angular/material/input";
18
+ import { MatSelect } from "@angular/material/select";
19
+ import { MatOption } from "@angular/material/core";
20
+ import { MatButton, MatIconButton } from "@angular/material/button";
21
+ import { MatIcon } from "@angular/material/icon";
22
+ import { MatDivider } from "@angular/material/divider";
23
+ import { MatExpansionPanel, MatExpansionPanelDescription, MatExpansionPanelHeader, MatExpansionPanelTitle } from "@angular/material/expansion";
24
+ import { FlagSetComponent } from "@myrmidon/cadmus-ui-flag-set";
25
+ import { MESSAGE_ITEM_LIST_REPOSITORY_RESET } from "@myrmidon/cadmus-item-list";
26
+ import { CustomValidators, PartBadgeComponent, getPartIdName } from "@myrmidon/cadmus-ui";
27
+ import { MatCheckbox } from "@angular/material/checkbox";
28
+ import * as i3$1 from "@myrmidon/ngx-mat-tools";
29
+ import * as i5 from "@myrmidon/ngx-tools";
30
+ import * as i1 from "@angular/material/dialog";
31
+ import { MAT_DIALOG_DATA } from "@angular/material/dialog";
32
+ import { RefLookupComponent } from "@myrmidon/cadmus-refs-lookup";
33
+ import * as i2 from "@myrmidon/cadmus-refs-asserted-ids";
34
+ import * as i3 from "@angular/router";
35
+ import * as i4 from "@angular/material/snack-bar";
36
+ import * as i8 from "@myrmidon/cadmus-core";
37
+ import * as i10 from "@myrmidon/auth-jwt-login";
38
+ var EditedItemRepository = class EditedItemRepository {
39
+ _appRepository;
40
+ _itemService;
41
+ _loading$;
42
+ _item$;
43
+ _parts$;
44
+ _partGroups$;
45
+ _layersPartInfo$;
46
+ _facet$;
47
+ _newPartDefinitions$;
48
+ get loading$() {
49
+ return this._loading$.asObservable();
50
+ }
51
+ get item$() {
52
+ return this._item$.asObservable();
53
+ }
54
+ get parts$() {
55
+ return this._parts$.asObservable();
56
+ }
57
+ get partGroups$() {
58
+ return this._partGroups$.asObservable();
59
+ }
60
+ get layers$() {
61
+ return this._layersPartInfo$.asObservable();
62
+ }
63
+ get facet$() {
64
+ return this._facet$.asObservable();
65
+ }
66
+ get newPartDefinitions$() {
67
+ return this._newPartDefinitions$.asObservable();
68
+ }
69
+ constructor(_appRepository, _itemService) {
70
+ this._appRepository = _appRepository;
71
+ this._itemService = _itemService;
72
+ this._loading$ = new BehaviorSubject(void 0);
73
+ this._item$ = new BehaviorSubject(void 0);
74
+ this._parts$ = new BehaviorSubject([]);
75
+ this._partGroups$ = new BehaviorSubject([]);
76
+ this._layersPartInfo$ = new BehaviorSubject([]);
77
+ this._facet$ = new BehaviorSubject(void 0);
78
+ this._newPartDefinitions$ = new BehaviorSubject([]);
79
+ this._appRepository.load();
80
+ }
81
+ getItem() {
82
+ return this._item$.value;
83
+ }
84
+ getFacet() {
85
+ return this._facet$.value;
86
+ }
87
+ getExistingPartTypeAndRoleIds() {
88
+ const groups = this.getPartGroups();
89
+ if (!groups) return [];
90
+ const results = [];
91
+ for (const group of groups) for (const part of group.parts) results.push({
92
+ typeId: part.typeId,
93
+ roleId: part.roleId
94
+ });
95
+ return results;
96
+ }
97
+ getNewPartDefinitions() {
98
+ const facet = this.getFacet();
99
+ if (!facet) return [];
100
+ const existingTypeRoleIds = this.getExistingPartTypeAndRoleIds();
101
+ const defs = [];
102
+ for (const def of facet.partDefinitions) {
103
+ if (def.roleId?.startsWith("fr.")) continue;
104
+ if (existingTypeRoleIds.find((tr) => {
105
+ return tr.typeId === def.typeId && (!tr.roleId && !def.roleId || tr.roleId === def.roleId);
106
+ })) continue;
107
+ defs.push(def);
108
+ }
109
+ defs.sort((a, b) => {
110
+ return (a.sortKey || "").localeCompare(b.sortKey || "");
111
+ });
112
+ return defs;
113
+ }
114
+ getPartGroups() {
115
+ return this._partGroups$.value;
116
+ }
117
+ pickDefaultFacet(facets) {
118
+ if (!facets.length) return;
119
+ const defaultFacet = facets.find((f) => f.id === "default");
120
+ if (defaultFacet) return defaultFacet;
121
+ return facets[0];
122
+ }
123
+ load(itemId) {
124
+ const facets = this._appRepository.getFacets();
125
+ this._loading$.next(true);
126
+ if (!itemId) this._itemService.getItemLayerInfo("new", true).subscribe((layers) => {
127
+ const facet = this.pickDefaultFacet(facets);
128
+ this._loading$.next(false);
129
+ this._item$.next({
130
+ id: "",
131
+ title: "",
132
+ description: "",
133
+ facetId: facet?.id || "",
134
+ groupId: "",
135
+ sortKey: "",
136
+ flags: 0,
137
+ timeCreated: /* @__PURE__ */ new Date(),
138
+ creatorId: "",
139
+ timeModified: /* @__PURE__ */ new Date(),
140
+ userId: ""
141
+ });
142
+ this._parts$.next([]);
143
+ this._partGroups$.next([]);
144
+ this._layersPartInfo$.next(layers);
145
+ this._facet$.next(facet);
146
+ this._newPartDefinitions$.next(this.getNewPartDefinitions());
147
+ });
148
+ else forkJoin({
149
+ item: this._itemService.getItem(itemId, true),
150
+ layers: this._itemService.getItemLayerInfo(itemId, true)
151
+ }).subscribe({ next: (result) => {
152
+ this._loading$.next(false);
153
+ const itemFacet = facets.find((f) => {
154
+ return f.id === result.item.facetId;
155
+ });
156
+ const facetParts = itemFacet ? itemFacet.partDefinitions : [];
157
+ this._item$.next(result.item);
158
+ this._parts$.next(result.item.parts || []);
159
+ this._partGroups$.next(this._itemService.groupParts(result.item.parts || [], facetParts));
160
+ this._layersPartInfo$.next(result.layers);
161
+ this._facet$.next(itemFacet);
162
+ this._newPartDefinitions$.next(this.getNewPartDefinitions());
163
+ } });
164
+ }
165
+ ensureItemLoaded(id) {
166
+ if (this.getItem()?.id === id) return;
167
+ this.load(id);
168
+ }
169
+ save(item) {
170
+ return new Promise((resolve, reject) => {
171
+ this._itemService.addItem(item).subscribe({
172
+ next: (saved) => {
173
+ const itemFacet = this._appRepository.getFacets().find((f) => {
174
+ return f.id === saved.facetId;
175
+ });
176
+ this._item$.next(saved);
177
+ this._facet$.next(itemFacet);
178
+ this._newPartDefinitions$.next(this.getNewPartDefinitions());
179
+ resolve(saved);
180
+ },
181
+ error: (error) => {
182
+ console.error(`Error saving item ${item.id}`, error);
183
+ reject({
184
+ message: "Error saving item " + item.id,
185
+ error
186
+ });
187
+ }
188
+ });
189
+ });
190
+ }
191
+ deletePart(id) {
192
+ return new Promise((resolve, reject) => {
193
+ const itemId = this._item$.value?.id;
194
+ if (!itemId) {
195
+ reject({ message: "Cannot delete part of unsaved item" });
196
+ return;
197
+ }
198
+ this._itemService.deletePart(id).subscribe({
199
+ next: (_) => {
200
+ this.load(itemId);
201
+ resolve(id);
202
+ },
203
+ error: (error) => {
204
+ console.error(`Error deleting item's part ${id}`, error);
205
+ reject({
206
+ message: "Error deleting item's part " + id,
207
+ error
208
+ });
209
+ }
210
+ });
211
+ });
212
+ }
213
+ addNewLayerPart(typeId, roleId) {
214
+ return new Promise((resolve, reject) => {
215
+ const itemId = this._item$.value?.id;
216
+ if (!itemId) {
217
+ reject({ message: "Cannot add part to unsaved item" });
218
+ return;
219
+ }
220
+ const part = {
221
+ itemId,
222
+ typeId,
223
+ roleId,
224
+ id: "",
225
+ creatorId: "",
226
+ userId: "",
227
+ timeCreated: /* @__PURE__ */ new Date(),
228
+ timeModified: /* @__PURE__ */ new Date()
229
+ };
230
+ this._itemService.addPart(part).subscribe({
231
+ next: (part) => {
232
+ this.load(itemId);
233
+ resolve(part);
234
+ },
235
+ error: (error) => {
236
+ console.error(`Error adding new layer part for item ${itemId}`, error);
237
+ reject({
238
+ message: "Error adding new layer part for item " + itemId,
239
+ error
240
+ });
241
+ }
242
+ });
243
+ });
244
+ }
245
+ setPartThesaurusScope(ids, scope) {
246
+ return new Promise((resolve, reject) => {
247
+ const itemId = this._item$.value?.id;
248
+ if (!itemId) {
249
+ reject({ message: "Cannot set scope for unsaved item" });
250
+ return;
251
+ }
252
+ this._itemService.setPartThesaurusScope(ids, scope).subscribe({
253
+ next: (_) => {
254
+ this.load(itemId);
255
+ resolve(true);
256
+ },
257
+ error: (error) => {
258
+ console.error("Error setting item's part scope", error);
259
+ reject({
260
+ message: "Error setting item's part scope",
261
+ error
262
+ });
263
+ }
264
+ });
265
+ });
266
+ }
267
+ static ɵfac = i0.ɵɵngDeclareFactory({
268
+ minVersion: "12.0.0",
269
+ version: "22.2.0",
270
+ ngImport: i0,
271
+ type: EditedItemRepository,
272
+ deps: [{ token: i1$2.AppRepository }, { token: i2$1.ItemService }],
273
+ target: i0.ɵɵFactoryTarget.Injectable
274
+ });
275
+ static ɵprov = i0.ɵɵngDeclareInjectable({
276
+ minVersion: "12.0.0",
277
+ version: "22.2.0",
278
+ ngImport: i0,
279
+ type: EditedItemRepository,
280
+ providedIn: "root"
281
+ });
282
+ };
283
+ i0.ɵɵngDeclareClassMetadata({
284
+ minVersion: "12.0.0",
285
+ version: "22.2.0",
286
+ ngImport: i0,
287
+ type: EditedItemRepository,
288
+ decorators: [{
289
+ type: Injectable,
290
+ args: [{ providedIn: "root" }]
291
+ }],
292
+ ctorParameters: () => [{ type: i1$2.AppRepository }, { type: i2$1.ItemService }]
293
+ });
294
+ var CurrentItemBarComponent = class CurrentItemBarComponent {
295
+ item;
296
+ constructor(repository) {
297
+ this.item = toSignal(repository.item$);
298
+ }
299
+ static ɵfac = i0.ɵɵngDeclareFactory({
300
+ minVersion: "12.0.0",
301
+ version: "22.2.0",
302
+ ngImport: i0,
303
+ type: CurrentItemBarComponent,
304
+ deps: [{ token: EditedItemRepository }],
305
+ target: i0.ɵɵFactoryTarget.Component
306
+ });
307
+ static ɵcmp = i0.ɵɵngDeclareComponent({
308
+ minVersion: "17.0.0",
309
+ version: "22.2.0",
310
+ type: CurrentItemBarComponent,
311
+ isStandalone: true,
312
+ selector: "cadmus-current-item-bar",
313
+ ngImport: i0,
314
+ template: "@if (item(); as item) {\n <div class=\"item-bar\">\n <span class=\"title\">{{ item.title }}</span>\n <span class=\"id\">{{ item.id }}</span>\n &#x2B24;\n <span class=\"dsc\">\n {{ item.description }} &#x2B24;\n <span matTooltip=\"Created\"\n >{{ item.timeCreated | date: \"yyyy-MM-dd HH:mm:ss\" }}\n {{ item.creatorId }}</span\n >\n &#x2B24;\n <span matTooltip=\"Last saved\"\n >{{ item.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\n {{ item.userId }}</span\n >\n </span>\n </div>\n}\n",
315
+ styles: ["div.item-bar{border:1px solid var(--mat-sys-on-surface-variant);border-radius:4px;background-color:var(--mat-sys-surface-container);color:var(--mat-sys-on-primary-container);margin:6px;padding:8px}.title{font-size:1.2em;font-weight:700;margin-right:.5em}.id{font-size:.8em;font-family:Courier New,Courier,monospace;margin-right:.5em}.dsc{font-size:.9em}\n"],
316
+ dependencies: [{
317
+ kind: "directive",
318
+ type: MatTooltip,
319
+ selector: "[matTooltip]",
320
+ inputs: [
321
+ "matTooltipPosition",
322
+ "matTooltipPositionAtOrigin",
323
+ "matTooltipDisabled",
324
+ "matTooltipShowDelay",
325
+ "matTooltipHideDelay",
326
+ "matTooltipTouchGestures",
327
+ "matTooltip",
328
+ "matTooltipClass"
329
+ ],
330
+ exportAs: ["matTooltip"]
331
+ }, {
332
+ kind: "pipe",
333
+ type: DatePipe,
334
+ name: "date"
335
+ }],
336
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
337
+ });
338
+ };
339
+ i0.ɵɵngDeclareClassMetadata({
340
+ minVersion: "12.0.0",
341
+ version: "22.2.0",
342
+ ngImport: i0,
343
+ type: CurrentItemBarComponent,
344
+ decorators: [{
345
+ type: Component,
346
+ args: [{
347
+ selector: "cadmus-current-item-bar",
348
+ changeDetection: ChangeDetectionStrategy.OnPush,
349
+ imports: [DatePipe, MatTooltip],
350
+ template: "@if (item(); as item) {\n <div class=\"item-bar\">\n <span class=\"title\">{{ item.title }}</span>\n <span class=\"id\">{{ item.id }}</span>\n &#x2B24;\n <span class=\"dsc\">\n {{ item.description }} &#x2B24;\n <span matTooltip=\"Created\"\n >{{ item.timeCreated | date: \"yyyy-MM-dd HH:mm:ss\" }}\n {{ item.creatorId }}</span\n >\n &#x2B24;\n <span matTooltip=\"Last saved\"\n >{{ item.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\n {{ item.userId }}</span\n >\n </span>\n </div>\n}\n",
351
+ styles: ["div.item-bar{border:1px solid var(--mat-sys-on-surface-variant);border-radius:4px;background-color:var(--mat-sys-surface-container);color:var(--mat-sys-on-primary-container);margin:6px;padding:8px}.title{font-size:1.2em;font-weight:700;margin-right:.5em}.id{font-size:.8em;font-family:Courier New,Courier,monospace;margin-right:.5em}.dsc{font-size:.9em}\n"]
352
+ }]
353
+ }],
354
+ ctorParameters: () => [{ type: EditedItemRepository }]
355
+ });
356
+ var CurrentLayerPartBarComponent = class CurrentLayerPartBarComponent {
357
+ _appRepository;
358
+ _editedItemRepository;
359
+ _facetService;
360
+ _facet;
361
+ _part;
362
+ typeId;
363
+ roleId;
364
+ color;
365
+ constructor(_appRepository, _editedItemRepository, editedLayerRepository, _facetService) {
366
+ this._appRepository = _appRepository;
367
+ this._editedItemRepository = _editedItemRepository;
368
+ this._facetService = _facetService;
369
+ this._facet = toSignal(this._editedItemRepository.facet$);
370
+ this._part = toSignal(editedLayerRepository.part$);
371
+ this.typeId = computed(() => {
372
+ const part = this._part();
373
+ if (!part) return void 0;
374
+ return this.getTypeIdName(part.typeId);
375
+ }, ...ngDevMode ? [{ debugName: "typeId" }] : /* istanbul ignore next */ []);
376
+ this.roleId = computed(() => {
377
+ const part = this._part();
378
+ if (!part) return void 0;
379
+ return this.getRoleIdName(part.roleId);
380
+ }, ...ngDevMode ? [{ debugName: "roleId" }] : /* istanbul ignore next */ []);
381
+ this.color = computed(() => {
382
+ const part = this._part();
383
+ this._facet();
384
+ if (!part) return void 0;
385
+ return this.getPartColor(part.typeId, part.roleId);
386
+ }, ...ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []);
387
+ }
388
+ getTypeIdName(typeId) {
389
+ const typeThesaurus = this._appRepository.getTypeThesaurus();
390
+ if (!typeThesaurus) return typeId;
391
+ const i = typeId.lastIndexOf(":");
392
+ if (i > -1) typeId = typeId.substring(0, i);
393
+ const entry = typeThesaurus.entries?.find((e) => e.id === typeId);
394
+ return entry ? entry.value : typeId;
395
+ }
396
+ getRoleIdName(roleId) {
397
+ if (!roleId || !roleId.startsWith("fr.")) return roleId;
398
+ return this.getTypeIdName(roleId);
399
+ }
400
+ getPartColor(typeId, roleId) {
401
+ const facet = this._editedItemRepository.getFacet();
402
+ return this._facetService.getPartColor(typeId, roleId, facet);
403
+ }
404
+ static ɵfac = i0.ɵɵngDeclareFactory({
405
+ minVersion: "12.0.0",
406
+ version: "22.2.0",
407
+ ngImport: i0,
408
+ type: CurrentLayerPartBarComponent,
409
+ deps: [
410
+ { token: i1$2.AppRepository },
411
+ { token: EditedItemRepository },
412
+ { token: i1$2.EditedLayerRepository },
413
+ { token: i2$1.FacetService }
414
+ ],
415
+ target: i0.ɵɵFactoryTarget.Component
416
+ });
417
+ static ɵcmp = i0.ɵɵngDeclareComponent({
418
+ minVersion: "14.0.0",
419
+ version: "22.2.0",
420
+ type: CurrentLayerPartBarComponent,
421
+ isStandalone: true,
422
+ selector: "cadmus-current-layer-part-bar",
423
+ ngImport: i0,
424
+ template: "<div>\n <span class=\"type-id\" [style.background-color]=\"color()\">{{ typeId() }}</span>\n <span class=\"role-id\">{{ roleId() }}</span>\n</div>\n",
425
+ styles: ["span.type-id{padding:4px;border-radius:6px}span.role-id{padding:4px}\n"],
426
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
427
+ });
428
+ };
429
+ i0.ɵɵngDeclareClassMetadata({
430
+ minVersion: "12.0.0",
431
+ version: "22.2.0",
432
+ ngImport: i0,
433
+ type: CurrentLayerPartBarComponent,
434
+ decorators: [{
435
+ type: Component,
436
+ args: [{
437
+ selector: "cadmus-current-layer-part-bar",
438
+ changeDetection: ChangeDetectionStrategy.OnPush,
439
+ template: "<div>\n <span class=\"type-id\" [style.background-color]=\"color()\">{{ typeId() }}</span>\n <span class=\"role-id\">{{ roleId() }}</span>\n</div>\n",
440
+ styles: ["span.type-id{padding:4px;border-radius:6px}span.role-id{padding:4px}\n"]
441
+ }]
442
+ }],
443
+ ctorParameters: () => [
444
+ { type: i1$2.AppRepository },
445
+ { type: EditedItemRepository },
446
+ { type: i1$2.EditedLayerRepository },
447
+ { type: i2$1.FacetService }
448
+ ]
449
+ });
450
+ var PartsScopeEditorComponent = class PartsScopeEditorComponent {
451
+ _formBuilder;
452
+ _facetService;
453
+ _dialogService;
454
+ _appRepository;
455
+ _colorService;
456
+ _editedItemRepository;
457
+ parts = input(...ngDevMode ? [void 0, { debugName: "parts" }] : /* istanbul ignore next */ []);
458
+ readonly = input(...ngDevMode ? [void 0, { debugName: "readonly" }] : /* istanbul ignore next */ []);
459
+ setScopeRequest = output();
460
+ checks;
461
+ scope;
462
+ form;
463
+ constructor(_formBuilder, _facetService, _dialogService, _appRepository, _colorService, _editedItemRepository) {
464
+ this._formBuilder = _formBuilder;
465
+ this._facetService = _facetService;
466
+ this._dialogService = _dialogService;
467
+ this._appRepository = _appRepository;
468
+ this._colorService = _colorService;
469
+ this._editedItemRepository = _editedItemRepository;
470
+ this.checks = _formBuilder.array([], CustomValidators.minChecked(1));
471
+ this.scope = _formBuilder.control(null, [Validators.maxLength(50), Validators.pattern(/^[-a-zA-Z0-9_]+$/)]);
472
+ this.form = _formBuilder.group({
473
+ checks: this.checks,
474
+ scope: this.scope
475
+ });
476
+ this._appRepository.load();
477
+ effect(() => {
478
+ this.updateForm(this.parts());
479
+ });
480
+ }
481
+ updateForm(parts) {
482
+ this.checks.clear();
483
+ if (!parts?.length) return;
484
+ for (let i = 0; i < parts.length; i++) this.checks.push(this._formBuilder.control(false));
485
+ this.form.updateValueAndValidity();
486
+ }
487
+ onCheckChanged() {
488
+ this.form.updateValueAndValidity();
489
+ }
490
+ getPartColor(typeId, roleId) {
491
+ const facet = this._editedItemRepository.getFacet();
492
+ return this._facetService.getPartColor(typeId, roleId, facet);
493
+ }
494
+ getContrastColor(typeId, roleId) {
495
+ const rgb = this.getPartColor(typeId, roleId);
496
+ return this._colorService.getContrastColor(rgb);
497
+ }
498
+ getTypeIdName(typeId) {
499
+ const typeThesaurus = this._appRepository.getTypeThesaurus();
500
+ if (!typeThesaurus) return typeId;
501
+ const i = typeId.lastIndexOf(":");
502
+ if (i > -1) typeId = typeId.substring(0, i);
503
+ const entry = typeThesaurus.entries?.find((e) => e.id === typeId);
504
+ return entry ? entry.value : typeId;
505
+ }
506
+ getRoleIdName(roleId) {
507
+ if (!roleId || !roleId.startsWith("fr.")) return roleId;
508
+ return this.getTypeIdName(roleId);
509
+ }
510
+ submit() {
511
+ if (this.form.invalid || !this.parts()?.length) return;
512
+ const ids = [];
513
+ const parts = this.parts();
514
+ for (let i = 0; i < this.checks.length; i++) if (this.checks.controls[i].value === true) ids.push(parts[i].id);
515
+ let msg = this.scope.value ? `Assign scope "${this.scope.value}" to ${ids.length} part` : `Remove scope from ${ids.length} part`;
516
+ msg += ids.length > 1 ? "s?" : "?";
517
+ this._dialogService.confirm("Confirm Scopes", msg).subscribe((result) => {
518
+ if (!result) return;
519
+ this.setScopeRequest.emit({
520
+ ids,
521
+ scope: this.scope.value
522
+ });
523
+ });
524
+ }
525
+ static ɵfac = i0.ɵɵngDeclareFactory({
526
+ minVersion: "12.0.0",
527
+ version: "22.2.0",
528
+ ngImport: i0,
529
+ type: PartsScopeEditorComponent,
530
+ deps: [
531
+ { token: i1$1.FormBuilder },
532
+ { token: i2$1.FacetService },
533
+ { token: i3$1.DialogService },
534
+ { token: i1$2.AppRepository },
535
+ { token: i5.ColorService },
536
+ { token: EditedItemRepository }
537
+ ],
538
+ target: i0.ɵɵFactoryTarget.Component
539
+ });
540
+ static ɵcmp = i0.ɵɵngDeclareComponent({
541
+ minVersion: "17.0.0",
542
+ version: "22.2.0",
543
+ type: PartsScopeEditorComponent,
544
+ isStandalone: true,
545
+ selector: "cadmus-parts-scope-editor",
546
+ inputs: {
547
+ parts: {
548
+ classPropertyName: "parts",
549
+ publicName: "parts",
550
+ isSignal: true,
551
+ isRequired: false,
552
+ transformFunction: null
553
+ },
554
+ readonly: {
555
+ classPropertyName: "readonly",
556
+ publicName: "readonly",
557
+ isSignal: true,
558
+ isRequired: false,
559
+ transformFunction: null
560
+ }
561
+ },
562
+ outputs: { setScopeRequest: "setScopeRequest" },
563
+ ngImport: i0,
564
+ template: "<form [formGroup]=\"form\" (submit)=\"submit()\">\n <table id=\"parts\" formArrayName=\"checks\">\n <thead>\n <tr>\n <th aria-label=\"select\"></th>\n <th>type</th>\n <th>role</th>\n <th>scope</th>\n <th>modified</th>\n <th>user</th>\n </tr>\n </thead>\n <tbody>\n @for (\n part of parts() ?? [];\n track part.typeId + \":\" + (part.roleId ?? \"\");\n let i = $index\n ) {\n <tr>\n <td class=\"fit-width\">\n <mat-checkbox [formControlName]=\"i\" (change)=\"onCheckChanged()\" />\n </td>\n <td>\n <span\n class=\"model-type\"\n [style.background-color]=\"getPartColor(part.typeId, part.roleId)\"\n [style.color]=\"getContrastColor(part.typeId, part.roleId)\"\n >{{ getTypeIdName(part.typeId) }}</span\n >\n </td>\n <td>{{ getRoleIdName(part.roleId ?? \"\") }}</td>\n <td>{{ part.thesaurusScope }}</td>\n <td>{{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}</td>\n <td>{{ part.userId }}</td>\n </tr>\n }\n </tbody>\n </table>\n <div class=\"form-row\">\n <mat-form-field>\n <mat-label>scope</mat-label>\n <input matInput formControlName=\"scope\" />\n @if (scope.hasError(\"maxLength\") && (scope.dirty || scope.touched)) {\n <mat-error>too long</mat-error>\n }\n @if (scope.hasError(\"pattern\") && (scope.dirty || scope.touched)) {\n <mat-error>invalid scope</mat-error>\n }\n </mat-form-field>\n <button\n mat-flat-button\n class=\"mat-primary\"\n type=\"submit\"\n [disabled]=\"form.invalid || readonly()\"\n matTooltip=\"Assign the scope to the checked parts\"\n >\n assign\n </button>\n </div>\n</form>\n",
565
+ 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)}span.model-type{padding:4px;border-radius:6px}table#parts{border-collapse:separate;border-spacing:0 8px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}\n"],
566
+ dependencies: [
567
+ {
568
+ kind: "ngmodule",
569
+ type: ReactiveFormsModule
570
+ },
571
+ {
572
+ kind: "directive",
573
+ type: i1$1.ɵNgNoValidate,
574
+ selector: "form:not([ngNoForm]):not([ngNativeValidate])"
575
+ },
576
+ {
577
+ kind: "directive",
578
+ type: i1$1.DefaultValueAccessor,
579
+ 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]"
580
+ },
581
+ {
582
+ kind: "directive",
583
+ type: i1$1.NgControlStatus,
584
+ selector: "[formControlName],[ngModel],[formControl]"
585
+ },
586
+ {
587
+ kind: "directive",
588
+ type: i1$1.NgControlStatusGroup,
589
+ selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
590
+ },
591
+ {
592
+ kind: "directive",
593
+ type: i1$1.FormGroupDirective,
594
+ selector: "[formGroup]",
595
+ inputs: ["formGroup"],
596
+ outputs: ["ngSubmit"],
597
+ exportAs: ["ngForm"]
598
+ },
599
+ {
600
+ kind: "directive",
601
+ type: i1$1.FormControlName,
602
+ selector: "[formControlName]",
603
+ inputs: [
604
+ "formControlName",
605
+ "disabled",
606
+ "ngModel"
607
+ ],
608
+ outputs: ["ngModelChange"]
609
+ },
610
+ {
611
+ kind: "directive",
612
+ type: i1$1.FormArrayName,
613
+ selector: "[formArrayName]",
614
+ inputs: ["formArrayName"]
615
+ },
616
+ {
617
+ kind: "component",
618
+ type: MatCheckbox,
619
+ selector: "mat-checkbox",
620
+ inputs: [
621
+ "aria-label",
622
+ "aria-labelledby",
623
+ "aria-describedby",
624
+ "aria-expanded",
625
+ "aria-controls",
626
+ "aria-owns",
627
+ "id",
628
+ "required",
629
+ "labelPosition",
630
+ "name",
631
+ "value",
632
+ "disableRipple",
633
+ "tabIndex",
634
+ "color",
635
+ "disabledInteractive",
636
+ "checked",
637
+ "disabled",
638
+ "indeterminate"
639
+ ],
640
+ outputs: ["change", "indeterminateChange"],
641
+ exportAs: ["matCheckbox"]
642
+ },
643
+ {
644
+ kind: "component",
645
+ type: MatFormField,
646
+ selector: "mat-form-field",
647
+ inputs: [
648
+ "hideRequiredMarker",
649
+ "color",
650
+ "floatLabel",
651
+ "appearance",
652
+ "subscriptSizing",
653
+ "hintLabel"
654
+ ],
655
+ exportAs: ["matFormField"]
656
+ },
657
+ {
658
+ kind: "directive",
659
+ type: MatLabel,
660
+ selector: "mat-label"
661
+ },
662
+ {
663
+ kind: "directive",
664
+ type: MatInput,
665
+ selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
666
+ inputs: [
667
+ "disabled",
668
+ "id",
669
+ "placeholder",
670
+ "name",
671
+ "required",
672
+ "type",
673
+ "errorStateMatcher",
674
+ "aria-describedby",
675
+ "value",
676
+ "readonly",
677
+ "disabledInteractive"
678
+ ],
679
+ exportAs: ["matInput"]
680
+ },
681
+ {
682
+ kind: "directive",
683
+ type: MatError,
684
+ selector: "mat-error, [matError]",
685
+ inputs: ["id"]
686
+ },
687
+ {
688
+ kind: "component",
689
+ type: MatButton,
690
+ 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] ",
691
+ inputs: ["matButton"],
692
+ exportAs: ["matButton", "matAnchor"]
693
+ },
694
+ {
695
+ kind: "directive",
696
+ type: MatTooltip,
697
+ selector: "[matTooltip]",
698
+ inputs: [
699
+ "matTooltipPosition",
700
+ "matTooltipPositionAtOrigin",
701
+ "matTooltipDisabled",
702
+ "matTooltipShowDelay",
703
+ "matTooltipHideDelay",
704
+ "matTooltipTouchGestures",
705
+ "matTooltip",
706
+ "matTooltipClass"
707
+ ],
708
+ exportAs: ["matTooltip"]
709
+ },
710
+ {
711
+ kind: "pipe",
712
+ type: DatePipe,
713
+ name: "date"
714
+ }
715
+ ],
716
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
717
+ });
718
+ };
719
+ i0.ɵɵngDeclareClassMetadata({
720
+ minVersion: "12.0.0",
721
+ version: "22.2.0",
722
+ ngImport: i0,
723
+ type: PartsScopeEditorComponent,
724
+ decorators: [{
725
+ type: Component,
726
+ args: [{
727
+ selector: "cadmus-parts-scope-editor",
728
+ changeDetection: ChangeDetectionStrategy.OnPush,
729
+ imports: [
730
+ ReactiveFormsModule,
731
+ MatCheckbox,
732
+ MatFormField,
733
+ MatLabel,
734
+ MatInput,
735
+ MatError,
736
+ MatButton,
737
+ MatTooltip,
738
+ DatePipe
739
+ ],
740
+ template: "<form [formGroup]=\"form\" (submit)=\"submit()\">\n <table id=\"parts\" formArrayName=\"checks\">\n <thead>\n <tr>\n <th aria-label=\"select\"></th>\n <th>type</th>\n <th>role</th>\n <th>scope</th>\n <th>modified</th>\n <th>user</th>\n </tr>\n </thead>\n <tbody>\n @for (\n part of parts() ?? [];\n track part.typeId + \":\" + (part.roleId ?? \"\");\n let i = $index\n ) {\n <tr>\n <td class=\"fit-width\">\n <mat-checkbox [formControlName]=\"i\" (change)=\"onCheckChanged()\" />\n </td>\n <td>\n <span\n class=\"model-type\"\n [style.background-color]=\"getPartColor(part.typeId, part.roleId)\"\n [style.color]=\"getContrastColor(part.typeId, part.roleId)\"\n >{{ getTypeIdName(part.typeId) }}</span\n >\n </td>\n <td>{{ getRoleIdName(part.roleId ?? \"\") }}</td>\n <td>{{ part.thesaurusScope }}</td>\n <td>{{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}</td>\n <td>{{ part.userId }}</td>\n </tr>\n }\n </tbody>\n </table>\n <div class=\"form-row\">\n <mat-form-field>\n <mat-label>scope</mat-label>\n <input matInput formControlName=\"scope\" />\n @if (scope.hasError(\"maxLength\") && (scope.dirty || scope.touched)) {\n <mat-error>too long</mat-error>\n }\n @if (scope.hasError(\"pattern\") && (scope.dirty || scope.touched)) {\n <mat-error>invalid scope</mat-error>\n }\n </mat-form-field>\n <button\n mat-flat-button\n class=\"mat-primary\"\n type=\"submit\"\n [disabled]=\"form.invalid || readonly()\"\n matTooltip=\"Assign the scope to the checked parts\"\n >\n assign\n </button>\n </div>\n</form>\n",
741
+ 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)}span.model-type{padding:4px;border-radius:6px}table#parts{border-collapse:separate;border-spacing:0 8px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}\n"]
742
+ }]
743
+ }],
744
+ ctorParameters: () => [
745
+ { type: i1$1.FormBuilder },
746
+ { type: i2$1.FacetService },
747
+ { type: i3$1.DialogService },
748
+ { type: i1$2.AppRepository },
749
+ { type: i5.ColorService },
750
+ { type: EditedItemRepository }
751
+ ],
752
+ propDecorators: {
753
+ parts: [{
754
+ type: i0.Input,
755
+ args: [{
756
+ isSignal: true,
757
+ alias: "parts",
758
+ required: false
759
+ }]
760
+ }],
761
+ readonly: [{
762
+ type: i0.Input,
763
+ args: [{
764
+ isSignal: true,
765
+ alias: "readonly",
766
+ required: false
767
+ }]
768
+ }],
769
+ setScopeRequest: [{
770
+ type: i0.Output,
771
+ args: ["setScopeRequest"]
772
+ }]
773
+ }
774
+ });
775
+ var ItemLookupDialogComponent = class ItemLookupDialogComponent {
776
+ dialogRef;
777
+ config;
778
+ itemLookupService;
779
+ constructor(dialogRef, config, itemLookupService) {
780
+ this.dialogRef = dialogRef;
781
+ this.config = config;
782
+ this.itemLookupService = itemLookupService;
783
+ }
784
+ onCancel() {
785
+ this.dialogRef.close(null);
786
+ }
787
+ onItemLookupChange(value) {
788
+ this.dialogRef.close(value);
789
+ }
790
+ static ɵfac = i0.ɵɵngDeclareFactory({
791
+ minVersion: "12.0.0",
792
+ version: "22.2.0",
793
+ ngImport: i0,
794
+ type: ItemLookupDialogComponent,
795
+ deps: [
796
+ { token: i1.MatDialogRef },
797
+ { token: MAT_DIALOG_DATA },
798
+ { token: i2.ItemRefLookupService }
799
+ ],
800
+ target: i0.ɵɵFactoryTarget.Component
801
+ });
802
+ static ɵcmp = i0.ɵɵngDeclareComponent({
803
+ minVersion: "14.0.0",
804
+ version: "22.2.0",
805
+ type: ItemLookupDialogComponent,
806
+ isStandalone: true,
807
+ selector: "cadmus-item-lookup-dialog",
808
+ ngImport: i0,
809
+ template: "<div id=\"container\">\r\n <h3>Select Item</h3>\r\n <cadmus-refs-lookup\r\n [service]=\"itemLookupService\"\r\n label=\"item\"\r\n (itemChange)=\"onItemLookupChange($event)\"\r\n />\r\n</div>\r\n",
810
+ styles: ["#container{padding:16px}\n"],
811
+ dependencies: [{
812
+ kind: "component",
813
+ type: RefLookupComponent,
814
+ selector: "cadmus-refs-lookup",
815
+ inputs: [
816
+ "label",
817
+ "limit",
818
+ "baseFilter",
819
+ "service",
820
+ "item",
821
+ "itemId",
822
+ "required",
823
+ "hasMore",
824
+ "linkTemplate",
825
+ "optDialog",
826
+ "options",
827
+ "lookupProviderOptions"
828
+ ],
829
+ outputs: [
830
+ "itemChange",
831
+ "optionsChange",
832
+ "moreRequest"
833
+ ]
834
+ }],
835
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
836
+ });
837
+ };
838
+ i0.ɵɵngDeclareClassMetadata({
839
+ minVersion: "12.0.0",
840
+ version: "22.2.0",
841
+ ngImport: i0,
842
+ type: ItemLookupDialogComponent,
843
+ decorators: [{
844
+ type: Component,
845
+ args: [{
846
+ selector: "cadmus-item-lookup-dialog",
847
+ changeDetection: ChangeDetectionStrategy.OnPush,
848
+ imports: [RefLookupComponent],
849
+ template: "<div id=\"container\">\r\n <h3>Select Item</h3>\r\n <cadmus-refs-lookup\r\n [service]=\"itemLookupService\"\r\n label=\"item\"\r\n (itemChange)=\"onItemLookupChange($event)\"\r\n />\r\n</div>\r\n",
850
+ styles: ["#container{padding:16px}\n"]
851
+ }]
852
+ }],
853
+ ctorParameters: () => [
854
+ { type: i1.MatDialogRef },
855
+ {
856
+ type: i1.MatDialogConfig,
857
+ decorators: [{
858
+ type: Inject,
859
+ args: [MAT_DIALOG_DATA]
860
+ }]
861
+ },
862
+ { type: i2.ItemRefLookupService }
863
+ ]
864
+ });
865
+ var ItemGenerateDialogComponent = class ItemGenerateDialogComponent {
866
+ dialogRef;
867
+ config;
868
+ flags = signal([], ...ngDevMode ? [{ debugName: "flags" }] : /* istanbul ignore next */ []);
869
+ itemCount;
870
+ itemTitle;
871
+ itemFlags;
872
+ form;
873
+ constructor(formBuilder, dialogRef, config) {
874
+ this.dialogRef = dialogRef;
875
+ this.config = config;
876
+ this.itemCount = formBuilder.control(1, {
877
+ nonNullable: true,
878
+ validators: [
879
+ Validators.required,
880
+ Validators.min(1),
881
+ Validators.max(100)
882
+ ]
883
+ });
884
+ this.itemTitle = formBuilder.control("", {
885
+ nonNullable: true,
886
+ validators: [Validators.required, Validators.maxLength(500)]
887
+ });
888
+ this.itemFlags = formBuilder.control([], { nonNullable: true });
889
+ this.form = formBuilder.group({
890
+ itemCount: this.itemCount,
891
+ itemTitle: this.itemTitle,
892
+ itemFlags: this.itemFlags
893
+ });
894
+ this.flags.set(config?.flags || []);
895
+ }
896
+ apply() {
897
+ if (!this.form.valid) return;
898
+ const flags = this.itemFlags.value.reduce((acc, f) => acc | f.id, 0);
899
+ this.dialogRef.close({
900
+ count: this.itemCount.value,
901
+ title: this.itemTitle.value,
902
+ flags
903
+ });
904
+ }
905
+ static ɵfac = i0.ɵɵngDeclareFactory({
906
+ minVersion: "12.0.0",
907
+ version: "22.2.0",
908
+ ngImport: i0,
909
+ type: ItemGenerateDialogComponent,
910
+ deps: [
911
+ { token: i1$1.FormBuilder },
912
+ { token: i1.MatDialogRef },
913
+ { token: MAT_DIALOG_DATA }
914
+ ],
915
+ target: i0.ɵɵFactoryTarget.Component
916
+ });
917
+ static ɵcmp = i0.ɵɵngDeclareComponent({
918
+ minVersion: "17.0.0",
919
+ version: "22.2.0",
920
+ type: ItemGenerateDialogComponent,
921
+ isStandalone: true,
922
+ selector: "cadmus-item-generate-dialog",
923
+ ngImport: i0,
924
+ template: "<div id=\"container\">\n <h3>Generate Items</h3>\n <form [formGroup]=\"form\" (submit)=\"apply()\">\n <!-- count -->\n <div>\n <mat-form-field class=\"input-nr\">\n <mat-label>count</mat-label>\n <input matInput type=\"number\" min=\"1\" [formControl]=\"itemCount\" />\n <mat-hint>number of items to generate</mat-hint>\n @if (\n itemCount.errors?.[\"required\"] && (itemCount.dirty || itemCount.touched)\n ) {\n <mat-error>count required</mat-error>\n }\n @if (\n itemCount.errors?.[\"min\"] && (itemCount.dirty || itemCount.touched)\n ) {\n <mat-error>count too low</mat-error>\n }\n @if (\n itemCount.errors?.[\"max\"] && (itemCount.dirty || itemCount.touched)\n ) {\n <mat-error>count too high</mat-error>\n }\n </mat-form-field>\n </div>\n\n <!-- title -->\n <div>\n <mat-form-field>\n <mat-label>title</mat-label>\n <input matInput [formControl]=\"itemTitle\" />\n <mat-hint>title template ({{ \"{0}\" }}=N)</mat-hint>\n @if (\n itemTitle.errors?.[\"required\"] &&\n (itemTitle.dirty || itemTitle.touched)\n ) {\n <mat-error>title required</mat-error>\n }\n @if (\n itemTitle.errors?.[\"maxlength\"] &&\n (itemTitle.dirty || itemTitle.touched)\n ) {\n <mat-error>title too long</mat-error>\n }\n </mat-form-field>\n </div>\n\n <!-- flags -->\n @if (flags().length) {\n <div>\n <mat-form-field>\n <mat-label>flags</mat-label>\n <mat-select [formControl]=\"itemFlags\" multiple>\n @for (flag of flags(); track flag.id) {\n <mat-option [value]=\"flag\">\n <span class=\"flag-bullet\" [style.color]=\"'#' + flag.colorKey\"\n >&#x2b24;</span\n >\n {{ flag.label }}\n </mat-option>\n }\n </mat-select>\n </mat-form-field>\n </div>\n }\n\n <!-- apply button -->\n <div>\n <button\n mat-flat-button\n class=\"mat-primary\"\n type=\"submit\"\n [disabled]=\"form.invalid\"\n >\n generate\n </button>\n </div>\n </form>\n</div>\n",
925
+ styles: ["#container{padding:16px}.flag-bullet{margin-right:.5em}.input-nr{width:5em}\n"],
926
+ dependencies: [
927
+ {
928
+ kind: "ngmodule",
929
+ type: ReactiveFormsModule
930
+ },
931
+ {
932
+ kind: "directive",
933
+ type: i1$1.ɵNgNoValidate,
934
+ selector: "form:not([ngNoForm]):not([ngNativeValidate])"
935
+ },
936
+ {
937
+ kind: "directive",
938
+ type: i1$1.DefaultValueAccessor,
939
+ 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]"
940
+ },
941
+ {
942
+ kind: "directive",
943
+ type: i1$1.NumberValueAccessor,
944
+ selector: "input[type=number]:not([ngNoCva])[formControlName],input[type=number]:not([ngNoCva])[formControl],input[type=number]:not([ngNoCva])[ngModel]"
945
+ },
946
+ {
947
+ kind: "directive",
948
+ type: i1$1.NgControlStatus,
949
+ selector: "[formControlName],[ngModel],[formControl]"
950
+ },
951
+ {
952
+ kind: "directive",
953
+ type: i1$1.NgControlStatusGroup,
954
+ selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
955
+ },
956
+ {
957
+ kind: "directive",
958
+ type: i1$1.MinValidator,
959
+ selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]",
960
+ inputs: ["min"]
961
+ },
962
+ {
963
+ kind: "directive",
964
+ type: i1$1.FormControlDirective,
965
+ selector: "[formControl]",
966
+ inputs: [
967
+ "formControl",
968
+ "disabled",
969
+ "ngModel"
970
+ ],
971
+ outputs: ["ngModelChange"],
972
+ exportAs: ["ngForm"]
973
+ },
974
+ {
975
+ kind: "directive",
976
+ type: i1$1.FormGroupDirective,
977
+ selector: "[formGroup]",
978
+ inputs: ["formGroup"],
979
+ outputs: ["ngSubmit"],
980
+ exportAs: ["ngForm"]
981
+ },
982
+ {
983
+ kind: "component",
984
+ type: MatFormField,
985
+ selector: "mat-form-field",
986
+ inputs: [
987
+ "hideRequiredMarker",
988
+ "color",
989
+ "floatLabel",
990
+ "appearance",
991
+ "subscriptSizing",
992
+ "hintLabel"
993
+ ],
994
+ exportAs: ["matFormField"]
995
+ },
996
+ {
997
+ kind: "directive",
998
+ type: MatLabel,
999
+ selector: "mat-label"
1000
+ },
1001
+ {
1002
+ kind: "directive",
1003
+ type: MatInput,
1004
+ selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
1005
+ inputs: [
1006
+ "disabled",
1007
+ "id",
1008
+ "placeholder",
1009
+ "name",
1010
+ "required",
1011
+ "type",
1012
+ "errorStateMatcher",
1013
+ "aria-describedby",
1014
+ "value",
1015
+ "readonly",
1016
+ "disabledInteractive"
1017
+ ],
1018
+ exportAs: ["matInput"]
1019
+ },
1020
+ {
1021
+ kind: "directive",
1022
+ type: MatHint,
1023
+ selector: "mat-hint",
1024
+ inputs: ["align", "id"]
1025
+ },
1026
+ {
1027
+ kind: "directive",
1028
+ type: MatError,
1029
+ selector: "mat-error, [matError]",
1030
+ inputs: ["id"]
1031
+ },
1032
+ {
1033
+ kind: "component",
1034
+ type: MatSelect,
1035
+ selector: "mat-select",
1036
+ inputs: [
1037
+ "aria-describedby",
1038
+ "panelClass",
1039
+ "disabled",
1040
+ "disableRipple",
1041
+ "tabIndex",
1042
+ "hideSingleSelectionIndicator",
1043
+ "placeholder",
1044
+ "required",
1045
+ "multiple",
1046
+ "disableOptionCentering",
1047
+ "compareWith",
1048
+ "value",
1049
+ "aria-label",
1050
+ "aria-labelledby",
1051
+ "errorStateMatcher",
1052
+ "typeaheadDebounceInterval",
1053
+ "sortComparator",
1054
+ "id",
1055
+ "panelWidth",
1056
+ "canSelectNullableOptions"
1057
+ ],
1058
+ outputs: [
1059
+ "openedChange",
1060
+ "opened",
1061
+ "closed",
1062
+ "selectionChange",
1063
+ "valueChange"
1064
+ ],
1065
+ exportAs: ["matSelect"]
1066
+ },
1067
+ {
1068
+ kind: "component",
1069
+ type: MatOption,
1070
+ selector: "mat-option",
1071
+ inputs: [
1072
+ "value",
1073
+ "id",
1074
+ "disabled"
1075
+ ],
1076
+ outputs: ["onSelectionChange"],
1077
+ exportAs: ["matOption"]
1078
+ },
1079
+ {
1080
+ kind: "component",
1081
+ type: MatButton,
1082
+ 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] ",
1083
+ inputs: ["matButton"],
1084
+ exportAs: ["matButton", "matAnchor"]
1085
+ }
1086
+ ],
1087
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
1088
+ });
1089
+ };
1090
+ i0.ɵɵngDeclareClassMetadata({
1091
+ minVersion: "12.0.0",
1092
+ version: "22.2.0",
1093
+ ngImport: i0,
1094
+ type: ItemGenerateDialogComponent,
1095
+ decorators: [{
1096
+ type: Component,
1097
+ args: [{
1098
+ selector: "cadmus-item-generate-dialog",
1099
+ changeDetection: ChangeDetectionStrategy.OnPush,
1100
+ imports: [
1101
+ ReactiveFormsModule,
1102
+ MatFormField,
1103
+ MatLabel,
1104
+ MatInput,
1105
+ MatHint,
1106
+ MatError,
1107
+ MatSelect,
1108
+ MatOption,
1109
+ MatButton
1110
+ ],
1111
+ template: "<div id=\"container\">\n <h3>Generate Items</h3>\n <form [formGroup]=\"form\" (submit)=\"apply()\">\n <!-- count -->\n <div>\n <mat-form-field class=\"input-nr\">\n <mat-label>count</mat-label>\n <input matInput type=\"number\" min=\"1\" [formControl]=\"itemCount\" />\n <mat-hint>number of items to generate</mat-hint>\n @if (\n itemCount.errors?.[\"required\"] && (itemCount.dirty || itemCount.touched)\n ) {\n <mat-error>count required</mat-error>\n }\n @if (\n itemCount.errors?.[\"min\"] && (itemCount.dirty || itemCount.touched)\n ) {\n <mat-error>count too low</mat-error>\n }\n @if (\n itemCount.errors?.[\"max\"] && (itemCount.dirty || itemCount.touched)\n ) {\n <mat-error>count too high</mat-error>\n }\n </mat-form-field>\n </div>\n\n <!-- title -->\n <div>\n <mat-form-field>\n <mat-label>title</mat-label>\n <input matInput [formControl]=\"itemTitle\" />\n <mat-hint>title template ({{ \"{0}\" }}=N)</mat-hint>\n @if (\n itemTitle.errors?.[\"required\"] &&\n (itemTitle.dirty || itemTitle.touched)\n ) {\n <mat-error>title required</mat-error>\n }\n @if (\n itemTitle.errors?.[\"maxlength\"] &&\n (itemTitle.dirty || itemTitle.touched)\n ) {\n <mat-error>title too long</mat-error>\n }\n </mat-form-field>\n </div>\n\n <!-- flags -->\n @if (flags().length) {\n <div>\n <mat-form-field>\n <mat-label>flags</mat-label>\n <mat-select [formControl]=\"itemFlags\" multiple>\n @for (flag of flags(); track flag.id) {\n <mat-option [value]=\"flag\">\n <span class=\"flag-bullet\" [style.color]=\"'#' + flag.colorKey\"\n >&#x2b24;</span\n >\n {{ flag.label }}\n </mat-option>\n }\n </mat-select>\n </mat-form-field>\n </div>\n }\n\n <!-- apply button -->\n <div>\n <button\n mat-flat-button\n class=\"mat-primary\"\n type=\"submit\"\n [disabled]=\"form.invalid\"\n >\n generate\n </button>\n </div>\n </form>\n</div>\n",
1112
+ styles: ["#container{padding:16px}.flag-bullet{margin-right:.5em}.input-nr{width:5em}\n"]
1113
+ }]
1114
+ }],
1115
+ ctorParameters: () => [
1116
+ { type: i1$1.FormBuilder },
1117
+ { type: i1.MatDialogRef },
1118
+ {
1119
+ type: i1.MatDialogConfig,
1120
+ decorators: [{
1121
+ type: Inject,
1122
+ args: [MAT_DIALOG_DATA]
1123
+ }]
1124
+ }
1125
+ ]
1126
+ });
1127
+ var MissingPartsComponent = class MissingPartsComponent {
1128
+ facetDefinition = input(...ngDevMode ? [void 0, { debugName: "facetDefinition" }] : /* istanbul ignore next */ []);
1129
+ partDefinitions = input(...ngDevMode ? [void 0, { debugName: "partDefinitions" }] : /* istanbul ignore next */ []);
1130
+ parts = input(...ngDevMode ? [void 0, { debugName: "parts" }] : /* istanbul ignore next */ []);
1131
+ missingDefinitions = signal([], ...ngDevMode ? [{ debugName: "missingDefinitions" }] : /* istanbul ignore next */ []);
1132
+ typeThesaurus = input(...ngDevMode ? [void 0, { debugName: "typeThesaurus" }] : /* istanbul ignore next */ []);
1133
+ addRequest = output();
1134
+ constructor() {
1135
+ effect(() => {
1136
+ this.updateMissing(this.partDefinitions(), this.parts());
1137
+ });
1138
+ }
1139
+ partExists(typeId, roleId, parts) {
1140
+ if (!parts) return false;
1141
+ return parts.some((p) => p.typeId === typeId && (!p.roleId && !roleId || p.roleId === roleId));
1142
+ }
1143
+ updateMissing(definitions, parts) {
1144
+ const missingDefinitions = [];
1145
+ if (!definitions) return;
1146
+ for (let i = 0; i < definitions.length; i++) {
1147
+ const def = definitions[i];
1148
+ if (def.isRequired && !this.partExists(def.typeId, def.roleId, parts)) missingDefinitions.push(def);
1149
+ }
1150
+ this.missingDefinitions.set(missingDefinitions);
1151
+ }
1152
+ requestAddPart(definition) {
1153
+ this.addRequest.emit(definition);
1154
+ }
1155
+ static ɵfac = i0.ɵɵngDeclareFactory({
1156
+ minVersion: "12.0.0",
1157
+ version: "22.2.0",
1158
+ ngImport: i0,
1159
+ type: MissingPartsComponent,
1160
+ deps: [],
1161
+ target: i0.ɵɵFactoryTarget.Component
1162
+ });
1163
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1164
+ minVersion: "17.0.0",
1165
+ version: "22.2.0",
1166
+ type: MissingPartsComponent,
1167
+ isStandalone: true,
1168
+ selector: "cadmus-missing-parts",
1169
+ inputs: {
1170
+ facetDefinition: {
1171
+ classPropertyName: "facetDefinition",
1172
+ publicName: "facetDefinition",
1173
+ isSignal: true,
1174
+ isRequired: false,
1175
+ transformFunction: null
1176
+ },
1177
+ partDefinitions: {
1178
+ classPropertyName: "partDefinitions",
1179
+ publicName: "partDefinitions",
1180
+ isSignal: true,
1181
+ isRequired: false,
1182
+ transformFunction: null
1183
+ },
1184
+ parts: {
1185
+ classPropertyName: "parts",
1186
+ publicName: "parts",
1187
+ isSignal: true,
1188
+ isRequired: false,
1189
+ transformFunction: null
1190
+ },
1191
+ typeThesaurus: {
1192
+ classPropertyName: "typeThesaurus",
1193
+ publicName: "typeThesaurus",
1194
+ isSignal: true,
1195
+ isRequired: false,
1196
+ transformFunction: null
1197
+ }
1198
+ },
1199
+ outputs: { addRequest: "addRequest" },
1200
+ ngImport: i0,
1201
+ template: "@if (missingDefinitions().length) {\n <div>\n <fieldset>\n <legend>\n <mat-icon class=\"mat-warn\">warning</mat-icon>&nbsp; Missing Parts\n </legend>\n <table>\n <tbody>\n @for (\n def of missingDefinitions();\n track def.typeId + \":\" + (def.roleId ?? \"\")\n ) {\n <tr>\n <td>\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Add this part\"\n (click)=\"requestAddPart(def)\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td [matTooltip]=\"def.description\">\n <cadmus-part-badge\n [partTypeIds]=\"def\"\n [facetDefinition]=\"facetDefinition()\"\n [typeThesaurus]=\"typeThesaurus()\"\n />\n </td>\n </tr>\n }\n </tbody>\n </table>\n </fieldset>\n </div>\n}\n",
1202
+ styles: ["fieldset{border:1px solid var(--mat-sys-on-surface-variant);border-radius:6px;padding:6px}legend{color:var(--mat-sys-on-surface-variant)}\n"],
1203
+ dependencies: [
1204
+ {
1205
+ kind: "component",
1206
+ type: MatIcon,
1207
+ selector: "mat-icon",
1208
+ inputs: [
1209
+ "color",
1210
+ "inline",
1211
+ "svgIcon",
1212
+ "fontSet",
1213
+ "fontIcon"
1214
+ ],
1215
+ exportAs: ["matIcon"]
1216
+ },
1217
+ {
1218
+ kind: "component",
1219
+ type: MatIconButton,
1220
+ selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
1221
+ exportAs: ["matButton", "matAnchor"]
1222
+ },
1223
+ {
1224
+ kind: "directive",
1225
+ type: MatTooltip,
1226
+ selector: "[matTooltip]",
1227
+ inputs: [
1228
+ "matTooltipPosition",
1229
+ "matTooltipPositionAtOrigin",
1230
+ "matTooltipDisabled",
1231
+ "matTooltipShowDelay",
1232
+ "matTooltipHideDelay",
1233
+ "matTooltipTouchGestures",
1234
+ "matTooltip",
1235
+ "matTooltipClass"
1236
+ ],
1237
+ exportAs: ["matTooltip"]
1238
+ },
1239
+ {
1240
+ kind: "component",
1241
+ type: PartBadgeComponent,
1242
+ selector: "cadmus-part-badge",
1243
+ inputs: [
1244
+ "badgeType",
1245
+ "typeThesaurus",
1246
+ "facetDefinition",
1247
+ "partTypeIds"
1248
+ ]
1249
+ }
1250
+ ],
1251
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
1252
+ });
1253
+ };
1254
+ i0.ɵɵngDeclareClassMetadata({
1255
+ minVersion: "12.0.0",
1256
+ version: "22.2.0",
1257
+ ngImport: i0,
1258
+ type: MissingPartsComponent,
1259
+ decorators: [{
1260
+ type: Component,
1261
+ args: [{
1262
+ selector: "cadmus-missing-parts",
1263
+ changeDetection: ChangeDetectionStrategy.OnPush,
1264
+ imports: [
1265
+ MatIcon,
1266
+ MatIconButton,
1267
+ MatTooltip,
1268
+ PartBadgeComponent
1269
+ ],
1270
+ template: "@if (missingDefinitions().length) {\n <div>\n <fieldset>\n <legend>\n <mat-icon class=\"mat-warn\">warning</mat-icon>&nbsp; Missing Parts\n </legend>\n <table>\n <tbody>\n @for (\n def of missingDefinitions();\n track def.typeId + \":\" + (def.roleId ?? \"\")\n ) {\n <tr>\n <td>\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Add this part\"\n (click)=\"requestAddPart(def)\"\n >\n <mat-icon>add_circle</mat-icon>\n </button>\n </td>\n <td [matTooltip]=\"def.description\">\n <cadmus-part-badge\n [partTypeIds]=\"def\"\n [facetDefinition]=\"facetDefinition()\"\n [typeThesaurus]=\"typeThesaurus()\"\n />\n </td>\n </tr>\n }\n </tbody>\n </table>\n </fieldset>\n </div>\n}\n",
1271
+ styles: ["fieldset{border:1px solid var(--mat-sys-on-surface-variant);border-radius:6px;padding:6px}legend{color:var(--mat-sys-on-surface-variant)}\n"]
1272
+ }]
1273
+ }],
1274
+ ctorParameters: () => [],
1275
+ propDecorators: {
1276
+ facetDefinition: [{
1277
+ type: i0.Input,
1278
+ args: [{
1279
+ isSignal: true,
1280
+ alias: "facetDefinition",
1281
+ required: false
1282
+ }]
1283
+ }],
1284
+ partDefinitions: [{
1285
+ type: i0.Input,
1286
+ args: [{
1287
+ isSignal: true,
1288
+ alias: "partDefinitions",
1289
+ required: false
1290
+ }]
1291
+ }],
1292
+ parts: [{
1293
+ type: i0.Input,
1294
+ args: [{
1295
+ isSignal: true,
1296
+ alias: "parts",
1297
+ required: false
1298
+ }]
1299
+ }],
1300
+ typeThesaurus: [{
1301
+ type: i0.Input,
1302
+ args: [{
1303
+ isSignal: true,
1304
+ alias: "typeThesaurus",
1305
+ required: false
1306
+ }]
1307
+ }],
1308
+ addRequest: [{
1309
+ type: i0.Output,
1310
+ args: ["addRequest"]
1311
+ }]
1312
+ }
1313
+ });
1314
+ var HasPreviewPipe = class HasPreviewPipe {
1315
+ transform(value, rKeys, fKeys) {
1316
+ if (!value) return false;
1317
+ if (value.roleId === "base-text") return fKeys?.find((k) => k === value.typeId) || rKeys?.find((k) => k === value.typeId) ? true : false;
1318
+ const key = value.roleId ? `${value.typeId}|${value.roleId}` : value.typeId;
1319
+ return rKeys?.find((k) => k === key) ? true : false;
1320
+ }
1321
+ static ɵfac = i0.ɵɵngDeclareFactory({
1322
+ minVersion: "12.0.0",
1323
+ version: "22.2.0",
1324
+ ngImport: i0,
1325
+ type: HasPreviewPipe,
1326
+ deps: [],
1327
+ target: i0.ɵɵFactoryTarget.Pipe
1328
+ });
1329
+ static ɵpipe = i0.ɵɵngDeclarePipe({
1330
+ minVersion: "14.0.0",
1331
+ version: "22.2.0",
1332
+ ngImport: i0,
1333
+ type: HasPreviewPipe,
1334
+ isStandalone: true,
1335
+ name: "hasPreview"
1336
+ });
1337
+ };
1338
+ i0.ɵɵngDeclareClassMetadata({
1339
+ minVersion: "12.0.0",
1340
+ version: "22.2.0",
1341
+ ngImport: i0,
1342
+ type: HasPreviewPipe,
1343
+ decorators: [{
1344
+ type: Pipe,
1345
+ args: [{ name: "hasPreview" }]
1346
+ }]
1347
+ });
1348
+ var ItemEditorComponent = class ItemEditorComponent {
1349
+ itemLookupService;
1350
+ dialog;
1351
+ _router;
1352
+ _route;
1353
+ _snackbar;
1354
+ _appRepository;
1355
+ _repository;
1356
+ _itemService;
1357
+ _libraryRouteService;
1358
+ _dialogService;
1359
+ _authService;
1360
+ _userLevelService;
1361
+ _messaging;
1362
+ _envService;
1363
+ item;
1364
+ parts;
1365
+ partGroups;
1366
+ layerPartInfos;
1367
+ facet;
1368
+ newPartDefinitions;
1369
+ facets;
1370
+ typeThesaurus;
1371
+ previewJKeys;
1372
+ previewFKeys;
1373
+ flagDefinitions;
1374
+ id = signal(void 0, ...ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []);
1375
+ _currentUser;
1376
+ user;
1377
+ userLevel;
1378
+ busy = signal(false, ...ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []);
1379
+ hasMetadataBuilders = signal(false, ...ngDevMode ? [{ debugName: "hasMetadataBuilders" }] : /* istanbul ignore next */ []);
1380
+ _flagsValue;
1381
+ flagSetFlags;
1382
+ adminFlagDefs;
1383
+ checkedFlagIds;
1384
+ newPartType;
1385
+ newPart;
1386
+ title;
1387
+ sortKey;
1388
+ description;
1389
+ facetCtrl;
1390
+ group;
1391
+ flags;
1392
+ metadata;
1393
+ constructor(itemLookupService, dialog, _router, _route, _snackbar, _appRepository, _repository, _itemService, _libraryRouteService, _dialogService, _authService, _userLevelService, _messaging, _envService, _formBuilder) {
1394
+ this.itemLookupService = itemLookupService;
1395
+ this.dialog = dialog;
1396
+ this._router = _router;
1397
+ this._route = _route;
1398
+ this._snackbar = _snackbar;
1399
+ this._appRepository = _appRepository;
1400
+ this._repository = _repository;
1401
+ this._itemService = _itemService;
1402
+ this._libraryRouteService = _libraryRouteService;
1403
+ this._dialogService = _dialogService;
1404
+ this._authService = _authService;
1405
+ this._userLevelService = _userLevelService;
1406
+ this._messaging = _messaging;
1407
+ this._envService = _envService;
1408
+ this.id.set(this._route.snapshot.params["id"]);
1409
+ if (this.id() === "new") this.id.set(void 0);
1410
+ this.hasMetadataBuilders.set(String(this._envService.get("hasMetadataBuilders")) === "true");
1411
+ this.newPartType = _formBuilder.control(null, Validators.required);
1412
+ this.newPart = _formBuilder.group({ newPartType: this.newPartType });
1413
+ this.title = _formBuilder.control(null, [Validators.required, Validators.maxLength(500)]);
1414
+ this.sortKey = _formBuilder.control(null, [Validators.required, Validators.maxLength(500)]);
1415
+ this.sortKey.disable();
1416
+ this.description = _formBuilder.control(null, [Validators.required, Validators.maxLength(1e3)]);
1417
+ this.facetCtrl = _formBuilder.control(null, Validators.required);
1418
+ this.group = _formBuilder.control(null, Validators.maxLength(100));
1419
+ this.flags = _formBuilder.control(0, { nonNullable: true });
1420
+ this.metadata = _formBuilder.group({
1421
+ title: this.title,
1422
+ sortKey: this.sortKey,
1423
+ description: this.description,
1424
+ facet: this.facetCtrl,
1425
+ group: this.group,
1426
+ flags: this.flags
1427
+ });
1428
+ this.item = toSignal(this._repository.item$);
1429
+ this.parts = toSignal(this._repository.parts$, { requireSync: true });
1430
+ this.partGroups = toSignal(this._repository.partGroups$, { requireSync: true });
1431
+ this.layerPartInfos = toSignal(this._repository.layers$, { requireSync: true });
1432
+ this.facet = toSignal(this._repository.facet$);
1433
+ this.newPartDefinitions = toSignal(this._repository.newPartDefinitions$, { requireSync: true });
1434
+ this.facets = toSignal(this._appRepository.facets$, { requireSync: true });
1435
+ this.typeThesaurus = toSignal(this._appRepository.typeThesaurus$);
1436
+ this.previewJKeys = toSignal(this._appRepository.previewJKeys$, { requireSync: true });
1437
+ this.previewFKeys = toSignal(this._appRepository.previewFKeys$, { requireSync: true });
1438
+ this.flagDefinitions = toSignal(this._appRepository.flags$, { requireSync: true });
1439
+ this._currentUser = toSignal(this._authService.currentUser$, { initialValue: null });
1440
+ this.user = computed(() => this._currentUser() ?? void 0, ...ngDevMode ? [{ debugName: "user" }] : /* istanbul ignore next */ []);
1441
+ this.userLevel = computed(() => {
1442
+ this._currentUser();
1443
+ return this._userLevelService.getCurrentUserLevel();
1444
+ }, ...ngDevMode ? [{ debugName: "userLevel" }] : /* istanbul ignore next */ []);
1445
+ this._flagsValue = toSignal(this.flags.valueChanges, { initialValue: 0 });
1446
+ this.flagSetFlags = computed(() => this.flagDefinitions().filter((def) => this.userLevel() >= 4 || !def.isAdmin).map((def) => ({
1447
+ id: String(def.id),
1448
+ label: def.label,
1449
+ color: "#" + def.colorKey
1450
+ })), ...ngDevMode ? [{ debugName: "flagSetFlags" }] : /* istanbul ignore next */ []);
1451
+ this.adminFlagDefs = computed(() => {
1452
+ if (this.userLevel() >= 4) return [];
1453
+ return this.flagDefinitions().filter((def) => def.isAdmin === true);
1454
+ }, ...ngDevMode ? [{ debugName: "adminFlagDefs" }] : /* istanbul ignore next */ []);
1455
+ this.checkedFlagIds = computed(() => {
1456
+ const value = this._flagsValue();
1457
+ return this.flagDefinitions().filter((def) => (value & def.id) !== 0).map((def) => String(def.id));
1458
+ }, ...ngDevMode ? [{ debugName: "checkedFlagIds" }] : /* istanbul ignore next */ []);
1459
+ effect(() => {
1460
+ this.updateMetadataForm(this.item());
1461
+ });
1462
+ }
1463
+ ngOnInit() {
1464
+ this._repository.load(this.id());
1465
+ }
1466
+ canDeactivate() {
1467
+ return !this.metadata.dirty;
1468
+ }
1469
+ updateMetadataForm(item) {
1470
+ if (!item) this.metadata.reset();
1471
+ else {
1472
+ this.title.setValue(item.title);
1473
+ this.sortKey.setValue(item.sortKey);
1474
+ this.description.setValue(item.description);
1475
+ this.facetCtrl.setValue(item.facetId ?? null);
1476
+ this.group.setValue(item.groupId ?? null);
1477
+ this.flags.setValue(item.flags);
1478
+ this.metadata.markAsPristine();
1479
+ }
1480
+ }
1481
+ onFlagCheckedIdsChange(ids) {
1482
+ let value = 0;
1483
+ if (this.userLevel() < 4) {
1484
+ const current = this.flags.value;
1485
+ for (const def of this.flagDefinitions()) if (def.isAdmin && (current & def.id) !== 0) value |= def.id;
1486
+ }
1487
+ for (const id of ids) value |= Number(id);
1488
+ this.flags.setValue(value);
1489
+ this.flags.markAsDirty();
1490
+ }
1491
+ getTypeIdName(typeId) {
1492
+ const typeThesaurus = this._appRepository.getTypeThesaurus();
1493
+ if (!typeThesaurus) return typeId;
1494
+ const i = typeId.lastIndexOf(":");
1495
+ if (i > -1) typeId = typeId.substring(0, i);
1496
+ const entry = typeThesaurus.entries?.find((e) => e.id === typeId);
1497
+ return entry ? entry.value : typeId;
1498
+ }
1499
+ getRoleIdName(roleId) {
1500
+ if (!roleId || !roleId.startsWith("fr.")) return roleId;
1501
+ return this.getTypeIdName(roleId);
1502
+ }
1503
+ save() {
1504
+ if (this.busy() || !this.metadata.valid) return;
1505
+ const currentItem = this._repository.getItem();
1506
+ if (!currentItem) return;
1507
+ const item = { ...currentItem };
1508
+ item.title = this.title.value?.trim() || "";
1509
+ item.sortKey = this.sortKey.value?.trim() || "";
1510
+ item.description = this.description.value?.trim() || "";
1511
+ item.facetId = this.facetCtrl.value?.trim() || "";
1512
+ item.groupId = this.group.value?.trim() || "";
1513
+ item.flags = this.flags.value;
1514
+ this.busy.set(true);
1515
+ this._repository.save(item).then((saved) => {
1516
+ this._messaging.sendMessage(MESSAGE_ITEM_LIST_REPOSITORY_RESET);
1517
+ this.metadata.markAsPristine();
1518
+ if (!item.id) {
1519
+ this.id.set(saved.id);
1520
+ this._router.navigate(["/items", saved.id]);
1521
+ }
1522
+ }).finally(() => {
1523
+ this.busy.set(false);
1524
+ });
1525
+ }
1526
+ partExists(typeId, roleId) {
1527
+ const groups = this._repository.getPartGroups();
1528
+ if (!groups) return false;
1529
+ return groups.some((g) => {
1530
+ return g.parts.some((p) => p.typeId === typeId && (!p.roleId && !roleId || p.roleId === roleId));
1531
+ });
1532
+ }
1533
+ getPartIdName(typeId, roleId) {
1534
+ return getPartIdName(typeId, roleId, this._appRepository.getTypeThesaurus());
1535
+ }
1536
+ addPart(def) {
1537
+ if (!def && !this.newPartType.valid) return;
1538
+ if (!this.id()) {
1539
+ this._snackbar.open("Please save the item before adding parts", "OK", { duration: 3e3 });
1540
+ return;
1541
+ }
1542
+ const typeId = def ? def.typeId : this.newPartType.value.typeId;
1543
+ const roleId = def ? def.roleId : this.newPartType.value.roleId;
1544
+ if (this.partExists(typeId, roleId)) return;
1545
+ const route = this._libraryRouteService.buildPartEditorRoute(this.id(), "new", typeId, roleId);
1546
+ this._router.navigate([route.route], route.rid ? { queryParams: { rid: route.rid } } : {});
1547
+ }
1548
+ editPart(part) {
1549
+ const route = this._libraryRouteService.buildPartEditorRoute(part.itemId, part.id, part.typeId, part.roleId);
1550
+ this._router.navigate([route.route], route.rid ? { queryParams: { rid: route.rid } } : {});
1551
+ }
1552
+ previewPart(part) {
1553
+ if (part.roleId?.startsWith("fr.")) this._itemService.getBaseTextPart(part.itemId).pipe(take(1)).subscribe((p) => {
1554
+ this._router.navigate([
1555
+ "preview",
1556
+ part.itemId,
1557
+ p.part.id,
1558
+ "text"
1559
+ ], { queryParams: { lid: part.roleId } });
1560
+ });
1561
+ else if (part.roleId === "base-text") this._router.navigate([
1562
+ "preview",
1563
+ part.itemId,
1564
+ part.id,
1565
+ "text"
1566
+ ]);
1567
+ else this._router.navigate([
1568
+ "preview",
1569
+ part.itemId,
1570
+ part.id
1571
+ ]);
1572
+ }
1573
+ deletePart(part) {
1574
+ if (this.busy()) return;
1575
+ this._dialogService.confirm("Confirm Deletion", `Delete part "${part.typeId}"?`).subscribe((result) => {
1576
+ if (!result) return;
1577
+ this.busy.set(true);
1578
+ this._repository.deletePart(part.id).then((_) => {
1579
+ this.busy.set(false);
1580
+ }, (error) => {
1581
+ this.busy.set(false);
1582
+ console.error(error);
1583
+ this._snackbar.open("Error deleting part", "OK");
1584
+ });
1585
+ });
1586
+ }
1587
+ addLayerPart(part) {
1588
+ if (this.busy()) return;
1589
+ let name = this.getTypeIdName(part.typeId);
1590
+ if (part.roleId) name += " for " + this.getRoleIdName(part.roleId);
1591
+ this._dialogService.confirm("Confirm Addition", `Add layer "${name}"?`).subscribe((result) => {
1592
+ if (!result) return;
1593
+ this.busy.set(true);
1594
+ this._repository.addNewLayerPart(part.typeId, part.roleId).finally(() => this.busy.set(false));
1595
+ });
1596
+ }
1597
+ setPartsScope(request) {
1598
+ this._repository.setPartThesaurusScope(request.ids, request.scope);
1599
+ }
1600
+ onCopyPart(part) {
1601
+ if (this.busy()) return;
1602
+ this.dialog.open(ItemLookupDialogComponent, {
1603
+ height: "180px",
1604
+ width: "250px",
1605
+ data: {}
1606
+ }).afterClosed().subscribe((targetItem) => {
1607
+ if (!targetItem || part.itemId === targetItem.id) return;
1608
+ if (this.facetCtrl.value !== targetItem.facetId) {
1609
+ this._snackbar.open("Cannot copy part to an item with a different facet", "OK");
1610
+ return;
1611
+ }
1612
+ this.busy.set(true);
1613
+ this._itemService.partWithTypeAndRoleExists(targetItem.id, part.typeId, part.roleId).subscribe((exists) => {
1614
+ if (exists) {
1615
+ this._snackbar.open("Part already exists in target item", "OK");
1616
+ this.busy.set(false);
1617
+ return;
1618
+ }
1619
+ part.id = "";
1620
+ part.itemId = targetItem.id;
1621
+ this._itemService.addPart(part).subscribe({
1622
+ next: (_) => {
1623
+ this._snackbar.open("Part copied", "OK", { duration: 3e3 });
1624
+ },
1625
+ error: (error) => {
1626
+ console.error(error);
1627
+ this._snackbar.open("Error copying part", "OK");
1628
+ },
1629
+ complete: () => {
1630
+ this.busy.set(false);
1631
+ }
1632
+ });
1633
+ });
1634
+ });
1635
+ }
1636
+ onGenerateItems() {
1637
+ if (this.busy()) return;
1638
+ this.dialog.open(ItemGenerateDialogComponent, {
1639
+ height: "400px",
1640
+ width: "350px",
1641
+ data: { flags: this.flagDefinitions() }
1642
+ }).afterClosed().subscribe((data) => {
1643
+ if (!data) return;
1644
+ this.busy.set(true);
1645
+ this._itemService.generateItems(data.count, this.id(), data.title, data.flags).subscribe({
1646
+ next: (_) => {
1647
+ this._messaging.sendMessage(MESSAGE_ITEM_LIST_REPOSITORY_RESET);
1648
+ this._snackbar.open("Items generated", "OK", { duration: 3e3 });
1649
+ },
1650
+ error: (error) => {
1651
+ console.error(error);
1652
+ this._snackbar.open("Error generating items", "OK");
1653
+ },
1654
+ complete: () => {
1655
+ this.busy.set(false);
1656
+ }
1657
+ });
1658
+ });
1659
+ }
1660
+ generateTitle() {
1661
+ if (this.busy()) return;
1662
+ this.busy.set(true);
1663
+ this._itemService.getItemMetadata(this.id(), "T").subscribe({
1664
+ next: (title) => {
1665
+ const result = title["T"];
1666
+ if (result) {
1667
+ this.title.setValue(result);
1668
+ this.title.markAsDirty();
1669
+ this.title.updateValueAndValidity();
1670
+ } else this._snackbar.open("No title generated", "OK", { duration: 3e3 });
1671
+ },
1672
+ error: (error) => {
1673
+ console.error(error);
1674
+ this._snackbar.open("Error generating title", "OK");
1675
+ },
1676
+ complete: () => {
1677
+ this.busy.set(false);
1678
+ }
1679
+ });
1680
+ }
1681
+ generateDescription() {
1682
+ if (this.busy()) return;
1683
+ this.busy.set(true);
1684
+ this._itemService.getItemMetadata(this.id(), "D").subscribe({
1685
+ next: (description) => {
1686
+ const result = description["D"];
1687
+ if (result) {
1688
+ this.description.setValue(result);
1689
+ this.description.markAsDirty();
1690
+ this.description.updateValueAndValidity();
1691
+ } else this._snackbar.open("No description generated", "OK", { duration: 3e3 });
1692
+ },
1693
+ error: (error) => {
1694
+ console.error(error);
1695
+ this._snackbar.open("Error generating description", "OK");
1696
+ },
1697
+ complete: () => {
1698
+ this.busy.set(false);
1699
+ }
1700
+ });
1701
+ }
1702
+ static ɵfac = i0.ɵɵngDeclareFactory({
1703
+ minVersion: "12.0.0",
1704
+ version: "22.2.0",
1705
+ ngImport: i0,
1706
+ type: ItemEditorComponent,
1707
+ deps: [
1708
+ { token: i2.ItemRefLookupService },
1709
+ { token: i1.MatDialog },
1710
+ { token: i3.Router },
1711
+ { token: i3.ActivatedRoute },
1712
+ { token: i4.MatSnackBar },
1713
+ { token: i1$2.AppRepository },
1714
+ { token: EditedItemRepository },
1715
+ { token: i2$1.ItemService },
1716
+ { token: i8.LibraryRouteService },
1717
+ { token: i3$1.DialogService },
1718
+ { token: i10.AuthJwtService },
1719
+ { token: i2$1.UserLevelService },
1720
+ { token: i2$1.MessagingService },
1721
+ { token: i5.EnvService },
1722
+ { token: i1$1.FormBuilder }
1723
+ ],
1724
+ target: i0.ɵɵFactoryTarget.Component
1725
+ });
1726
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1727
+ minVersion: "17.0.0",
1728
+ version: "22.2.0",
1729
+ type: ItemEditorComponent,
1730
+ isStandalone: true,
1731
+ selector: "cadmus-item-editor",
1732
+ ngImport: i0,
1733
+ template: "<mat-card appearance=\"outlined\">\r\n <mat-card-content>\r\n <div>\r\n <cadmus-current-item-bar />\r\n </div>\r\n @if (busy()) {\r\n <mat-progress-bar mode=\"indeterminate\" />\r\n }\r\n\r\n <!-- item content -->\r\n <mat-tab-group [selectedIndex]=\"id() ? 1 : 0\">\r\n <!-- metadata -->\r\n <mat-tab label=\"Metadata\">\r\n <form [formGroup]=\"metadata\" (ngSubmit)=\"save()\">\r\n <div class=\"form-row\">\r\n <!-- title -->\r\n <mat-form-field class=\"flex-field\">\r\n <mat-label>title</mat-label>\r\n <input matInput type=\"text\" id=\"title\" [formControl]=\"title\" />\r\n @if (\r\n title.hasError(\"required\") && (title.touched || title.dirty)\r\n ) {\r\n <mat-error>enter title</mat-error>\r\n }\r\n @if (\r\n title.hasError(\"maxLength\") && (title.touched || title.dirty)\r\n ) {\r\n <mat-error>title too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n @if (hasMetadataBuilders()) {\r\n <!-- auto title -->\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n [disabled]=\"busy()\"\r\n (click)=\"generateTitle()\"\r\n >\r\n <mat-icon matTooltip=\"Generate title\">auto_awesome</mat-icon>\r\n </button>\r\n }\r\n\r\n <!-- sortKey -->\r\n <mat-form-field class=\"flex-field\">\r\n <mat-label>sort key</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"sortKey\"\r\n [formControl]=\"sortKey\"\r\n />\r\n @if (\r\n sortKey.hasError(\"required\") &&\r\n (sortKey.touched || sortKey.dirty)\r\n ) {\r\n <mat-error>enter sort key</mat-error>\r\n }\r\n @if (\r\n sortKey.hasError(\"maxLength\") &&\r\n (sortKey.touched || sortKey.dirty)\r\n ) {\r\n <mat-error>sort key too long</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- description -->\r\n <div class=\"flex-row\">\r\n <mat-form-field class=\"item\">\r\n <mat-label>description</mat-label>\r\n <textarea\r\n rows=\"2\"\r\n matInput\r\n id=\"description\"\r\n [formControl]=\"description\"\r\n ></textarea>\r\n @if (\r\n description.hasError(\"required\") &&\r\n (description.touched || description.dirty)\r\n ) {\r\n <mat-error>enter description</mat-error>\r\n }\r\n @if (\r\n description.hasError(\"maxLength\") &&\r\n (description.touched || description.dirty)\r\n ) {\r\n <mat-error>description too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n @if (hasMetadataBuilders()) {\r\n <!-- auto description -->\r\n <button\r\n class=\"item fit\"\r\n type=\"button\"\r\n mat-icon-button\r\n [disabled]=\"busy()\"\r\n (click)=\"generateDescription()\"\r\n >\r\n <mat-icon matTooltip=\"Generate description\"\r\n >auto_awesome</mat-icon\r\n >\r\n </button>\r\n }\r\n </div>\r\n\r\n <!-- facet -->\r\n <div class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>facet</mat-label>\r\n <mat-select [formControl]=\"facetCtrl\" required=\"true\">\r\n @for (f of facets(); track f.id) {\r\n <mat-option [value]=\"f.id\">\r\n {{ f.label }}\r\n </mat-option>\r\n }\r\n </mat-select>\r\n <mat-error>please select a facet</mat-error>\r\n </mat-form-field>\r\n\r\n <!-- group -->\r\n <mat-form-field>\r\n <mat-label>group ID</mat-label>\r\n <input matInput [formControl]=\"group\" />\r\n @if (\r\n group.hasError(\"maxLength\") && (group.dirty || group.touched)\r\n ) {\r\n <mat-error>too long</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- flags -->\r\n <fieldset>\r\n <legend>flags</legend>\r\n <!-- read-only admin flags for non-admin users -->\r\n @if (adminFlagDefs().length) {\r\n <div class=\"admin-flags\">\r\n @for (def of adminFlagDefs(); track def.id) {\r\n <span class=\"admin-flag\">\r\n <span [style.color]=\"'#' + def.colorKey\">&#x25c6;</span>\r\n &nbsp;{{ def.label }}\r\n </span>\r\n }\r\n </div>\r\n }\r\n <!-- editable flags -->\r\n @if (flagSetFlags().length) {\r\n <cadmus-ui-flag-set\r\n [hideToolbar]=\"true\"\r\n [flags]=\"flagSetFlags()\"\r\n [checkedIds]=\"checkedFlagIds()\"\r\n (checkedIdsChange)=\"onFlagCheckedIdsChange($event)\"\r\n />\r\n }\r\n </fieldset>\r\n <br />\r\n\r\n <!-- action buttons -->\r\n @if (userLevel() > 1) {\r\n <div class=\"form-row\">\r\n <button\r\n type=\"button\"\r\n mat-flat-button\r\n class=\"mat-warn\"\r\n (click)=\"onGenerateItems()\"\r\n >\r\n <mat-icon>copy_all</mat-icon> generate\r\n </button>\r\n <button\r\n type=\"submit\"\r\n mat-flat-button\r\n class=\"mat-primary\"\r\n [disabled]=\"busy()\"\r\n matTooltip=\"Save metadata\"\r\n (click)=\"save()\"\r\n >\r\n <mat-icon>save</mat-icon> save\r\n </button>\r\n </div>\r\n }\r\n </form>\r\n </mat-tab>\r\n\r\n <!-- parts -->\r\n @if (id()) {\r\n <mat-tab label=\"Parts\">\r\n <div class=\"new-part\">\r\n <form [formGroup]=\"newPart\" class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>part</mat-label>\r\n <mat-select [formControl]=\"newPartType\" required>\r\n @for (\r\n p of newPartDefinitions();\r\n track p.typeId + \":\" + (p.roleId || \"\")\r\n ) {\r\n <mat-option [value]=\"p\">\r\n <span\r\n [style.color]=\"'#' + p.colorKey\"\r\n class=\"new-part-icon\"\r\n >&#x2b24;</span\r\n >\r\n {{ getPartIdName(p.typeId, p.roleId) }}\r\n </mat-option>\r\n }\r\n </mat-select>\r\n <mat-error>part type required</mat-error>\r\n </mat-form-field>\r\n <button\r\n mat-flat-button\r\n class=\"mat-primary\"\r\n type=\"button\"\r\n [disabled]=\"userLevel() < 2 || busy() || !newPart.valid\"\r\n (click)=\"addPart()\"\r\n matTooltip=\"Add a new part of the selected type\"\r\n >\r\n <mat-icon>add_circle</mat-icon>\r\n part\r\n </button>\r\n </form>\r\n </div>\r\n <mat-divider></mat-divider>\r\n @for (group of partGroups(); track group.key) {\r\n <mat-expansion-panel expanded=\"true\" class=\"group-header\">\r\n <mat-expansion-panel-header>\r\n <mat-panel-title\r\n ><strong>{{ group.label }}</strong></mat-panel-title\r\n >\r\n <mat-panel-description>{{\r\n group.parts.length\r\n }}</mat-panel-description>\r\n </mat-expansion-panel-header>\r\n <table class=\"parts-table\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>type</th>\r\n <th>role</th>\r\n <th class=\"noif-lt-xs\">modified</th>\r\n <th class=\"noif-lt-xs\">user</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n @for (\r\n part of group.parts;\r\n track part.typeId + \":\" + (part.roleId || \"\")\r\n ) {\r\n <tr>\r\n <!-- edit -->\r\n <td class=\"fit-width\">\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n [disabled]=\"busy()\"\r\n (click)=\"editPart(part)\"\r\n matTooltip=\"Edit this part\"\r\n >\r\n <mat-icon class=\"mat-primary\">create</mat-icon>\r\n </button>\r\n <!-- delete -->\r\n @if (\r\n user()?.roles?.length &&\r\n (user()?.roles?.includes(\"admin\") ||\r\n user()?.roles?.includes(\"editor\") ||\r\n user()?.roles?.includes(\"operator\"))\r\n ) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n [disabled]=\"userLevel() < 2 || busy()\"\r\n (click)=\"deletePart(part)\"\r\n matTooltip=\"Delete this part\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete</mat-icon>\r\n </button>\r\n }\r\n <!-- copy ID -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Copy this part ID\"\r\n [cdkCopyToClipboard]=\"part.id\"\r\n >\r\n <mat-icon>assignment</mat-icon>\r\n </button>\r\n <!-- copy into item -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Copy part into another item\"\r\n (click)=\"onCopyPart(part)\"\r\n >\r\n <mat-icon>open_in_new</mat-icon>\r\n </button>\r\n <!-- preview -->\r\n @if (\r\n part | hasPreview: previewJKeys() : previewFKeys()\r\n ) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Preview this part\"\r\n (click)=\"previewPart(part)\"\r\n >\r\n <mat-icon>preview</mat-icon>\r\n </button>\r\n }\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td class=\"noif-lt-xs\">\r\n {{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\r\n </td>\r\n <td class=\"noif-lt-xs\">{{ part.userId }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </mat-expansion-panel>\r\n }\r\n <cadmus-missing-parts\r\n [facetDefinition]=\"facet()\"\r\n [partDefinitions]=\"\r\n $safeNavigationMigration(facet()?.partDefinitions)\r\n \"\r\n [parts]=\"parts()\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n (addRequest)=\"addPart($event)\"\r\n />\r\n </mat-tab>\r\n }\r\n\r\n <!-- layers -->\r\n @if (id()) {\r\n <mat-tab label=\"Layers\">\r\n <table id=\"layers\">\r\n <thead>\r\n <th aria-label=\"actions\"></th>\r\n <th>type</th>\r\n <th>role</th>\r\n <th>frr.</th>\r\n <th>last modified</th>\r\n </thead>\r\n <tbody>\r\n @for (\r\n part of layerPartInfos();\r\n track part.typeId + \":\" + (part.roleId || \"\")\r\n ) {\r\n <tr>\r\n <td class=\"fit-width\">\r\n @if (!part.isAbsent) {\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Edit this layer part\"\r\n (click)=\"editPart(part)\"\r\n >\r\n <mat-icon class=\"mat-primary\">edit</mat-icon>\r\n </button>\r\n }\r\n @if (part.isAbsent) {\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Add this layer part\"\r\n [disabled]=\"userLevel() < 2\"\r\n (click)=\"addLayerPart(part)\"\r\n >\r\n <mat-icon class=\"mat-primary\">add_circle</mat-icon>\r\n </button>\r\n }\r\n @if (!part.isAbsent) {\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Delete this layer part\"\r\n [disabled]=\"userLevel() < 2\"\r\n (click)=\"deletePart(part)\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete</mat-icon>\r\n </button>\r\n }\r\n @if (!part.isAbsent) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Copy this part ID\"\r\n [cdkCopyToClipboard]=\"part.id\"\r\n >\r\n <mat-icon>assignment</mat-icon>\r\n </button>\r\n }\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td\r\n [class.count-n]=\"part.fragmentCount\"\r\n [class.count-z]=\"!part.fragmentCount\"\r\n >\r\n {{ part.fragmentCount }}\r\n </td>\r\n <td>\r\n @if (!part.isAbsent) {\r\n <span>\r\n {{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\r\n </span>\r\n }\r\n </td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </mat-tab>\r\n }\r\n\r\n <!-- thesaurus scopes -->\r\n @if (parts().length) {\r\n <mat-tab label=\"Th-Scopes\">\r\n <cadmus-parts-scope-editor\r\n [parts]=\"parts()\"\r\n [readonly]=\"userLevel() < 2 || busy() ? true : false\"\r\n (setScopeRequest)=\"setPartsScope($event)\"\r\n />\r\n </mat-tab>\r\n }\r\n </mat-tab-group>\r\n </mat-card-content>\r\n</mat-card>\r\n",
1734
+ styles: [".full-width{width:100%}.flex-field{flex:1 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)}table#layers td{padding:0 6px}table#layers th{text-align:left}div.new-part{margin-left:32px}span.new-part-role{color:var(--mat-sys-on-surface-variant);margin-left:8px;vertical-align:middle}span.new-part-icon{margin:0 4px;vertical-align:middle}td.count-n{text-align:center;color:var(--mat-sys-success)}td.count-z{text-align:center;color:var(--mat-sys-error)}input.id{font-family:Courier New,Courier,monospace;color:var(--mat-sys-on-surface-variant);min-width:22em}.admin-flags{margin-bottom:4px}.admin-flag{margin-left:12px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.group-header{margin-top:6px}table.parts-table{width:100%}table.parts-table th{text-align:left}fieldset{border:1px solid var(--mat-sys-on-surface-variant);border-radius:6px;padding:6px;margin:8px 0}@media only screen and (max-width:599px){.noif-lt-xs{display:none}}.flex-row{display:flex;flex-wrap:wrap}.flex-row .item{box-sizing:border-box}.flex-row .item.fit{flex:0 0 auto}.flex-row .item:not(.fit){flex:1 1 auto}\n"],
1735
+ dependencies: [
1736
+ {
1737
+ kind: "component",
1738
+ type: MatCard,
1739
+ selector: "mat-card",
1740
+ inputs: ["appearance"],
1741
+ exportAs: ["matCard"]
1742
+ },
1743
+ {
1744
+ kind: "directive",
1745
+ type: MatCardContent,
1746
+ selector: "mat-card-content"
1747
+ },
1748
+ {
1749
+ kind: "directive",
1750
+ type: MatTooltip,
1751
+ selector: "[matTooltip]",
1752
+ inputs: [
1753
+ "matTooltipPosition",
1754
+ "matTooltipPositionAtOrigin",
1755
+ "matTooltipDisabled",
1756
+ "matTooltipShowDelay",
1757
+ "matTooltipHideDelay",
1758
+ "matTooltipTouchGestures",
1759
+ "matTooltip",
1760
+ "matTooltipClass"
1761
+ ],
1762
+ exportAs: ["matTooltip"]
1763
+ },
1764
+ {
1765
+ kind: "directive",
1766
+ type: CdkCopyToClipboard,
1767
+ selector: "[cdkCopyToClipboard]",
1768
+ inputs: ["cdkCopyToClipboard", "cdkCopyToClipboardAttempts"],
1769
+ outputs: ["cdkCopyToClipboardCopied"]
1770
+ },
1771
+ {
1772
+ kind: "component",
1773
+ type: MatProgressBar,
1774
+ selector: "mat-progress-bar",
1775
+ inputs: [
1776
+ "color",
1777
+ "value",
1778
+ "bufferValue",
1779
+ "mode"
1780
+ ],
1781
+ outputs: ["animationEnd"],
1782
+ exportAs: ["matProgressBar"]
1783
+ },
1784
+ {
1785
+ kind: "component",
1786
+ type: MatTabGroup,
1787
+ selector: "mat-tab-group",
1788
+ inputs: [
1789
+ "color",
1790
+ "fitInkBarToContent",
1791
+ "mat-stretch-tabs",
1792
+ "mat-align-tabs",
1793
+ "dynamicHeight",
1794
+ "selectedIndex",
1795
+ "headerPosition",
1796
+ "animationDuration",
1797
+ "contentTabIndex",
1798
+ "disablePagination",
1799
+ "disableRipple",
1800
+ "preserveContent",
1801
+ "backgroundColor",
1802
+ "aria-label",
1803
+ "aria-labelledby"
1804
+ ],
1805
+ outputs: [
1806
+ "selectedIndexChange",
1807
+ "focusChange",
1808
+ "animationDone",
1809
+ "selectedTabChange"
1810
+ ],
1811
+ exportAs: ["matTabGroup"]
1812
+ },
1813
+ {
1814
+ kind: "component",
1815
+ type: MatTab,
1816
+ selector: "mat-tab",
1817
+ inputs: [
1818
+ "disabled",
1819
+ "label",
1820
+ "aria-label",
1821
+ "aria-labelledby",
1822
+ "labelClass",
1823
+ "bodyClass",
1824
+ "id"
1825
+ ],
1826
+ exportAs: ["matTab"]
1827
+ },
1828
+ {
1829
+ kind: "ngmodule",
1830
+ type: ReactiveFormsModule
1831
+ },
1832
+ {
1833
+ kind: "directive",
1834
+ type: i1$1.ɵNgNoValidate,
1835
+ selector: "form:not([ngNoForm]):not([ngNativeValidate])"
1836
+ },
1837
+ {
1838
+ kind: "directive",
1839
+ type: i1$1.DefaultValueAccessor,
1840
+ 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]"
1841
+ },
1842
+ {
1843
+ kind: "directive",
1844
+ type: i1$1.NgControlStatus,
1845
+ selector: "[formControlName],[ngModel],[formControl]"
1846
+ },
1847
+ {
1848
+ kind: "directive",
1849
+ type: i1$1.NgControlStatusGroup,
1850
+ selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
1851
+ },
1852
+ {
1853
+ kind: "directive",
1854
+ type: i1$1.RequiredValidator,
1855
+ selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]",
1856
+ inputs: ["required"]
1857
+ },
1858
+ {
1859
+ kind: "directive",
1860
+ type: i1$1.FormControlDirective,
1861
+ selector: "[formControl]",
1862
+ inputs: [
1863
+ "formControl",
1864
+ "disabled",
1865
+ "ngModel"
1866
+ ],
1867
+ outputs: ["ngModelChange"],
1868
+ exportAs: ["ngForm"]
1869
+ },
1870
+ {
1871
+ kind: "directive",
1872
+ type: i1$1.FormGroupDirective,
1873
+ selector: "[formGroup]",
1874
+ inputs: ["formGroup"],
1875
+ outputs: ["ngSubmit"],
1876
+ exportAs: ["ngForm"]
1877
+ },
1878
+ {
1879
+ kind: "component",
1880
+ type: MatFormField,
1881
+ selector: "mat-form-field",
1882
+ inputs: [
1883
+ "hideRequiredMarker",
1884
+ "color",
1885
+ "floatLabel",
1886
+ "appearance",
1887
+ "subscriptSizing",
1888
+ "hintLabel"
1889
+ ],
1890
+ exportAs: ["matFormField"]
1891
+ },
1892
+ {
1893
+ kind: "directive",
1894
+ type: MatLabel,
1895
+ selector: "mat-label"
1896
+ },
1897
+ {
1898
+ kind: "directive",
1899
+ type: MatInput,
1900
+ selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
1901
+ inputs: [
1902
+ "disabled",
1903
+ "id",
1904
+ "placeholder",
1905
+ "name",
1906
+ "required",
1907
+ "type",
1908
+ "errorStateMatcher",
1909
+ "aria-describedby",
1910
+ "value",
1911
+ "readonly",
1912
+ "disabledInteractive"
1913
+ ],
1914
+ exportAs: ["matInput"]
1915
+ },
1916
+ {
1917
+ kind: "directive",
1918
+ type: MatError,
1919
+ selector: "mat-error, [matError]",
1920
+ inputs: ["id"]
1921
+ },
1922
+ {
1923
+ kind: "component",
1924
+ type: MatSelect,
1925
+ selector: "mat-select",
1926
+ inputs: [
1927
+ "aria-describedby",
1928
+ "panelClass",
1929
+ "disabled",
1930
+ "disableRipple",
1931
+ "tabIndex",
1932
+ "hideSingleSelectionIndicator",
1933
+ "placeholder",
1934
+ "required",
1935
+ "multiple",
1936
+ "disableOptionCentering",
1937
+ "compareWith",
1938
+ "value",
1939
+ "aria-label",
1940
+ "aria-labelledby",
1941
+ "errorStateMatcher",
1942
+ "typeaheadDebounceInterval",
1943
+ "sortComparator",
1944
+ "id",
1945
+ "panelWidth",
1946
+ "canSelectNullableOptions"
1947
+ ],
1948
+ outputs: [
1949
+ "openedChange",
1950
+ "opened",
1951
+ "closed",
1952
+ "selectionChange",
1953
+ "valueChange"
1954
+ ],
1955
+ exportAs: ["matSelect"]
1956
+ },
1957
+ {
1958
+ kind: "component",
1959
+ type: MatOption,
1960
+ selector: "mat-option",
1961
+ inputs: [
1962
+ "value",
1963
+ "id",
1964
+ "disabled"
1965
+ ],
1966
+ outputs: ["onSelectionChange"],
1967
+ exportAs: ["matOption"]
1968
+ },
1969
+ {
1970
+ kind: "component",
1971
+ type: MatButton,
1972
+ 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] ",
1973
+ inputs: ["matButton"],
1974
+ exportAs: ["matButton", "matAnchor"]
1975
+ },
1976
+ {
1977
+ kind: "component",
1978
+ type: MatIcon,
1979
+ selector: "mat-icon",
1980
+ inputs: [
1981
+ "color",
1982
+ "inline",
1983
+ "svgIcon",
1984
+ "fontSet",
1985
+ "fontIcon"
1986
+ ],
1987
+ exportAs: ["matIcon"]
1988
+ },
1989
+ {
1990
+ kind: "component",
1991
+ type: MatDivider,
1992
+ selector: "mat-divider",
1993
+ inputs: ["vertical", "inset"]
1994
+ },
1995
+ {
1996
+ kind: "component",
1997
+ type: MatExpansionPanel,
1998
+ selector: "mat-expansion-panel",
1999
+ inputs: ["hideToggle", "togglePosition"],
2000
+ outputs: ["afterExpand", "afterCollapse"],
2001
+ exportAs: ["matExpansionPanel"]
2002
+ },
2003
+ {
2004
+ kind: "component",
2005
+ type: MatExpansionPanelHeader,
2006
+ selector: "mat-expansion-panel-header",
2007
+ inputs: [
2008
+ "expandedHeight",
2009
+ "collapsedHeight",
2010
+ "tabIndex"
2011
+ ]
2012
+ },
2013
+ {
2014
+ kind: "directive",
2015
+ type: MatExpansionPanelTitle,
2016
+ selector: "mat-panel-title"
2017
+ },
2018
+ {
2019
+ kind: "directive",
2020
+ type: MatExpansionPanelDescription,
2021
+ selector: "mat-panel-description"
2022
+ },
2023
+ {
2024
+ kind: "component",
2025
+ type: MatIconButton,
2026
+ selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
2027
+ exportAs: ["matButton", "matAnchor"]
2028
+ },
2029
+ {
2030
+ kind: "component",
2031
+ type: MissingPartsComponent,
2032
+ selector: "cadmus-missing-parts",
2033
+ inputs: [
2034
+ "facetDefinition",
2035
+ "partDefinitions",
2036
+ "parts",
2037
+ "typeThesaurus"
2038
+ ],
2039
+ outputs: ["addRequest"]
2040
+ },
2041
+ {
2042
+ kind: "component",
2043
+ type: PartsScopeEditorComponent,
2044
+ selector: "cadmus-parts-scope-editor",
2045
+ inputs: ["parts", "readonly"],
2046
+ outputs: ["setScopeRequest"]
2047
+ },
2048
+ {
2049
+ kind: "component",
2050
+ type: PartBadgeComponent,
2051
+ selector: "cadmus-part-badge",
2052
+ inputs: [
2053
+ "badgeType",
2054
+ "typeThesaurus",
2055
+ "facetDefinition",
2056
+ "partTypeIds"
2057
+ ]
2058
+ },
2059
+ {
2060
+ kind: "component",
2061
+ type: CurrentItemBarComponent,
2062
+ selector: "cadmus-current-item-bar"
2063
+ },
2064
+ {
2065
+ kind: "component",
2066
+ type: FlagSetComponent,
2067
+ selector: "cadmus-ui-flag-set",
2068
+ inputs: [
2069
+ "flags",
2070
+ "checkedIds",
2071
+ "allowCustom",
2072
+ "hideToolbar",
2073
+ "numbering"
2074
+ ],
2075
+ outputs: ["checkedIdsChange"]
2076
+ },
2077
+ {
2078
+ kind: "pipe",
2079
+ type: DatePipe,
2080
+ name: "date"
2081
+ },
2082
+ {
2083
+ kind: "pipe",
2084
+ type: HasPreviewPipe,
2085
+ name: "hasPreview"
2086
+ }
2087
+ ],
2088
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
2089
+ });
2090
+ };
2091
+ i0.ɵɵngDeclareClassMetadata({
2092
+ minVersion: "12.0.0",
2093
+ version: "22.2.0",
2094
+ ngImport: i0,
2095
+ type: ItemEditorComponent,
2096
+ decorators: [{
2097
+ type: Component,
2098
+ args: [{
2099
+ selector: "cadmus-item-editor",
2100
+ changeDetection: ChangeDetectionStrategy.OnPush,
2101
+ imports: [
2102
+ MatCard,
2103
+ MatCardContent,
2104
+ MatTooltip,
2105
+ CdkCopyToClipboard,
2106
+ MatProgressBar,
2107
+ MatTabGroup,
2108
+ MatTab,
2109
+ ReactiveFormsModule,
2110
+ MatFormField,
2111
+ MatLabel,
2112
+ MatInput,
2113
+ MatError,
2114
+ MatSelect,
2115
+ MatOption,
2116
+ MatButton,
2117
+ MatIcon,
2118
+ MatDivider,
2119
+ MatExpansionPanel,
2120
+ MatExpansionPanelHeader,
2121
+ MatExpansionPanelTitle,
2122
+ MatExpansionPanelDescription,
2123
+ MatIconButton,
2124
+ MissingPartsComponent,
2125
+ DatePipe,
2126
+ HasPreviewPipe,
2127
+ PartsScopeEditorComponent,
2128
+ PartBadgeComponent,
2129
+ CurrentItemBarComponent,
2130
+ FlagSetComponent
2131
+ ],
2132
+ template: "<mat-card appearance=\"outlined\">\r\n <mat-card-content>\r\n <div>\r\n <cadmus-current-item-bar />\r\n </div>\r\n @if (busy()) {\r\n <mat-progress-bar mode=\"indeterminate\" />\r\n }\r\n\r\n <!-- item content -->\r\n <mat-tab-group [selectedIndex]=\"id() ? 1 : 0\">\r\n <!-- metadata -->\r\n <mat-tab label=\"Metadata\">\r\n <form [formGroup]=\"metadata\" (ngSubmit)=\"save()\">\r\n <div class=\"form-row\">\r\n <!-- title -->\r\n <mat-form-field class=\"flex-field\">\r\n <mat-label>title</mat-label>\r\n <input matInput type=\"text\" id=\"title\" [formControl]=\"title\" />\r\n @if (\r\n title.hasError(\"required\") && (title.touched || title.dirty)\r\n ) {\r\n <mat-error>enter title</mat-error>\r\n }\r\n @if (\r\n title.hasError(\"maxLength\") && (title.touched || title.dirty)\r\n ) {\r\n <mat-error>title too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n @if (hasMetadataBuilders()) {\r\n <!-- auto title -->\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n [disabled]=\"busy()\"\r\n (click)=\"generateTitle()\"\r\n >\r\n <mat-icon matTooltip=\"Generate title\">auto_awesome</mat-icon>\r\n </button>\r\n }\r\n\r\n <!-- sortKey -->\r\n <mat-form-field class=\"flex-field\">\r\n <mat-label>sort key</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"sortKey\"\r\n [formControl]=\"sortKey\"\r\n />\r\n @if (\r\n sortKey.hasError(\"required\") &&\r\n (sortKey.touched || sortKey.dirty)\r\n ) {\r\n <mat-error>enter sort key</mat-error>\r\n }\r\n @if (\r\n sortKey.hasError(\"maxLength\") &&\r\n (sortKey.touched || sortKey.dirty)\r\n ) {\r\n <mat-error>sort key too long</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- description -->\r\n <div class=\"flex-row\">\r\n <mat-form-field class=\"item\">\r\n <mat-label>description</mat-label>\r\n <textarea\r\n rows=\"2\"\r\n matInput\r\n id=\"description\"\r\n [formControl]=\"description\"\r\n ></textarea>\r\n @if (\r\n description.hasError(\"required\") &&\r\n (description.touched || description.dirty)\r\n ) {\r\n <mat-error>enter description</mat-error>\r\n }\r\n @if (\r\n description.hasError(\"maxLength\") &&\r\n (description.touched || description.dirty)\r\n ) {\r\n <mat-error>description too long</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n @if (hasMetadataBuilders()) {\r\n <!-- auto description -->\r\n <button\r\n class=\"item fit\"\r\n type=\"button\"\r\n mat-icon-button\r\n [disabled]=\"busy()\"\r\n (click)=\"generateDescription()\"\r\n >\r\n <mat-icon matTooltip=\"Generate description\"\r\n >auto_awesome</mat-icon\r\n >\r\n </button>\r\n }\r\n </div>\r\n\r\n <!-- facet -->\r\n <div class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>facet</mat-label>\r\n <mat-select [formControl]=\"facetCtrl\" required=\"true\">\r\n @for (f of facets(); track f.id) {\r\n <mat-option [value]=\"f.id\">\r\n {{ f.label }}\r\n </mat-option>\r\n }\r\n </mat-select>\r\n <mat-error>please select a facet</mat-error>\r\n </mat-form-field>\r\n\r\n <!-- group -->\r\n <mat-form-field>\r\n <mat-label>group ID</mat-label>\r\n <input matInput [formControl]=\"group\" />\r\n @if (\r\n group.hasError(\"maxLength\") && (group.dirty || group.touched)\r\n ) {\r\n <mat-error>too long</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- flags -->\r\n <fieldset>\r\n <legend>flags</legend>\r\n <!-- read-only admin flags for non-admin users -->\r\n @if (adminFlagDefs().length) {\r\n <div class=\"admin-flags\">\r\n @for (def of adminFlagDefs(); track def.id) {\r\n <span class=\"admin-flag\">\r\n <span [style.color]=\"'#' + def.colorKey\">&#x25c6;</span>\r\n &nbsp;{{ def.label }}\r\n </span>\r\n }\r\n </div>\r\n }\r\n <!-- editable flags -->\r\n @if (flagSetFlags().length) {\r\n <cadmus-ui-flag-set\r\n [hideToolbar]=\"true\"\r\n [flags]=\"flagSetFlags()\"\r\n [checkedIds]=\"checkedFlagIds()\"\r\n (checkedIdsChange)=\"onFlagCheckedIdsChange($event)\"\r\n />\r\n }\r\n </fieldset>\r\n <br />\r\n\r\n <!-- action buttons -->\r\n @if (userLevel() > 1) {\r\n <div class=\"form-row\">\r\n <button\r\n type=\"button\"\r\n mat-flat-button\r\n class=\"mat-warn\"\r\n (click)=\"onGenerateItems()\"\r\n >\r\n <mat-icon>copy_all</mat-icon> generate\r\n </button>\r\n <button\r\n type=\"submit\"\r\n mat-flat-button\r\n class=\"mat-primary\"\r\n [disabled]=\"busy()\"\r\n matTooltip=\"Save metadata\"\r\n (click)=\"save()\"\r\n >\r\n <mat-icon>save</mat-icon> save\r\n </button>\r\n </div>\r\n }\r\n </form>\r\n </mat-tab>\r\n\r\n <!-- parts -->\r\n @if (id()) {\r\n <mat-tab label=\"Parts\">\r\n <div class=\"new-part\">\r\n <form [formGroup]=\"newPart\" class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>part</mat-label>\r\n <mat-select [formControl]=\"newPartType\" required>\r\n @for (\r\n p of newPartDefinitions();\r\n track p.typeId + \":\" + (p.roleId || \"\")\r\n ) {\r\n <mat-option [value]=\"p\">\r\n <span\r\n [style.color]=\"'#' + p.colorKey\"\r\n class=\"new-part-icon\"\r\n >&#x2b24;</span\r\n >\r\n {{ getPartIdName(p.typeId, p.roleId) }}\r\n </mat-option>\r\n }\r\n </mat-select>\r\n <mat-error>part type required</mat-error>\r\n </mat-form-field>\r\n <button\r\n mat-flat-button\r\n class=\"mat-primary\"\r\n type=\"button\"\r\n [disabled]=\"userLevel() < 2 || busy() || !newPart.valid\"\r\n (click)=\"addPart()\"\r\n matTooltip=\"Add a new part of the selected type\"\r\n >\r\n <mat-icon>add_circle</mat-icon>\r\n part\r\n </button>\r\n </form>\r\n </div>\r\n <mat-divider></mat-divider>\r\n @for (group of partGroups(); track group.key) {\r\n <mat-expansion-panel expanded=\"true\" class=\"group-header\">\r\n <mat-expansion-panel-header>\r\n <mat-panel-title\r\n ><strong>{{ group.label }}</strong></mat-panel-title\r\n >\r\n <mat-panel-description>{{\r\n group.parts.length\r\n }}</mat-panel-description>\r\n </mat-expansion-panel-header>\r\n <table class=\"parts-table\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>type</th>\r\n <th>role</th>\r\n <th class=\"noif-lt-xs\">modified</th>\r\n <th class=\"noif-lt-xs\">user</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n @for (\r\n part of group.parts;\r\n track part.typeId + \":\" + (part.roleId || \"\")\r\n ) {\r\n <tr>\r\n <!-- edit -->\r\n <td class=\"fit-width\">\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n [disabled]=\"busy()\"\r\n (click)=\"editPart(part)\"\r\n matTooltip=\"Edit this part\"\r\n >\r\n <mat-icon class=\"mat-primary\">create</mat-icon>\r\n </button>\r\n <!-- delete -->\r\n @if (\r\n user()?.roles?.length &&\r\n (user()?.roles?.includes(\"admin\") ||\r\n user()?.roles?.includes(\"editor\") ||\r\n user()?.roles?.includes(\"operator\"))\r\n ) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n [disabled]=\"userLevel() < 2 || busy()\"\r\n (click)=\"deletePart(part)\"\r\n matTooltip=\"Delete this part\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete</mat-icon>\r\n </button>\r\n }\r\n <!-- copy ID -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Copy this part ID\"\r\n [cdkCopyToClipboard]=\"part.id\"\r\n >\r\n <mat-icon>assignment</mat-icon>\r\n </button>\r\n <!-- copy into item -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Copy part into another item\"\r\n (click)=\"onCopyPart(part)\"\r\n >\r\n <mat-icon>open_in_new</mat-icon>\r\n </button>\r\n <!-- preview -->\r\n @if (\r\n part | hasPreview: previewJKeys() : previewFKeys()\r\n ) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Preview this part\"\r\n (click)=\"previewPart(part)\"\r\n >\r\n <mat-icon>preview</mat-icon>\r\n </button>\r\n }\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td class=\"noif-lt-xs\">\r\n {{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\r\n </td>\r\n <td class=\"noif-lt-xs\">{{ part.userId }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </mat-expansion-panel>\r\n }\r\n <cadmus-missing-parts\r\n [facetDefinition]=\"facet()\"\r\n [partDefinitions]=\"\r\n $safeNavigationMigration(facet()?.partDefinitions)\r\n \"\r\n [parts]=\"parts()\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n (addRequest)=\"addPart($event)\"\r\n />\r\n </mat-tab>\r\n }\r\n\r\n <!-- layers -->\r\n @if (id()) {\r\n <mat-tab label=\"Layers\">\r\n <table id=\"layers\">\r\n <thead>\r\n <th aria-label=\"actions\"></th>\r\n <th>type</th>\r\n <th>role</th>\r\n <th>frr.</th>\r\n <th>last modified</th>\r\n </thead>\r\n <tbody>\r\n @for (\r\n part of layerPartInfos();\r\n track part.typeId + \":\" + (part.roleId || \"\")\r\n ) {\r\n <tr>\r\n <td class=\"fit-width\">\r\n @if (!part.isAbsent) {\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Edit this layer part\"\r\n (click)=\"editPart(part)\"\r\n >\r\n <mat-icon class=\"mat-primary\">edit</mat-icon>\r\n </button>\r\n }\r\n @if (part.isAbsent) {\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Add this layer part\"\r\n [disabled]=\"userLevel() < 2\"\r\n (click)=\"addLayerPart(part)\"\r\n >\r\n <mat-icon class=\"mat-primary\">add_circle</mat-icon>\r\n </button>\r\n }\r\n @if (!part.isAbsent) {\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Delete this layer part\"\r\n [disabled]=\"userLevel() < 2\"\r\n (click)=\"deletePart(part)\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete</mat-icon>\r\n </button>\r\n }\r\n @if (!part.isAbsent) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Copy this part ID\"\r\n [cdkCopyToClipboard]=\"part.id\"\r\n >\r\n <mat-icon>assignment</mat-icon>\r\n </button>\r\n }\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet()\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n <td\r\n [class.count-n]=\"part.fragmentCount\"\r\n [class.count-z]=\"!part.fragmentCount\"\r\n >\r\n {{ part.fragmentCount }}\r\n </td>\r\n <td>\r\n @if (!part.isAbsent) {\r\n <span>\r\n {{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\r\n </span>\r\n }\r\n </td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </mat-tab>\r\n }\r\n\r\n <!-- thesaurus scopes -->\r\n @if (parts().length) {\r\n <mat-tab label=\"Th-Scopes\">\r\n <cadmus-parts-scope-editor\r\n [parts]=\"parts()\"\r\n [readonly]=\"userLevel() < 2 || busy() ? true : false\"\r\n (setScopeRequest)=\"setPartsScope($event)\"\r\n />\r\n </mat-tab>\r\n }\r\n </mat-tab-group>\r\n </mat-card-content>\r\n</mat-card>\r\n",
2133
+ styles: [".full-width{width:100%}.flex-field{flex:1 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)}table#layers td{padding:0 6px}table#layers th{text-align:left}div.new-part{margin-left:32px}span.new-part-role{color:var(--mat-sys-on-surface-variant);margin-left:8px;vertical-align:middle}span.new-part-icon{margin:0 4px;vertical-align:middle}td.count-n{text-align:center;color:var(--mat-sys-success)}td.count-z{text-align:center;color:var(--mat-sys-error)}input.id{font-family:Courier New,Courier,monospace;color:var(--mat-sys-on-surface-variant);min-width:22em}.admin-flags{margin-bottom:4px}.admin-flag{margin-left:12px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.group-header{margin-top:6px}table.parts-table{width:100%}table.parts-table th{text-align:left}fieldset{border:1px solid var(--mat-sys-on-surface-variant);border-radius:6px;padding:6px;margin:8px 0}@media only screen and (max-width:599px){.noif-lt-xs{display:none}}.flex-row{display:flex;flex-wrap:wrap}.flex-row .item{box-sizing:border-box}.flex-row .item.fit{flex:0 0 auto}.flex-row .item:not(.fit){flex:1 1 auto}\n"]
2134
+ }]
2135
+ }],
2136
+ ctorParameters: () => [
2137
+ { type: i2.ItemRefLookupService },
2138
+ { type: i1.MatDialog },
2139
+ { type: i3.Router },
2140
+ { type: i3.ActivatedRoute },
2141
+ { type: i4.MatSnackBar },
2142
+ { type: i1$2.AppRepository },
2143
+ { type: EditedItemRepository },
2144
+ { type: i2$1.ItemService },
2145
+ { type: i8.LibraryRouteService },
2146
+ { type: i3$1.DialogService },
2147
+ { type: i10.AuthJwtService },
2148
+ { type: i2$1.UserLevelService },
2149
+ { type: i2$1.MessagingService },
2150
+ { type: i5.EnvService },
2151
+ { type: i1$1.FormBuilder }
2152
+ ]
2153
+ });
1316
2154
  export { CurrentItemBarComponent, CurrentLayerPartBarComponent, EditedItemRepository, ItemEditorComponent, ItemGenerateDialogComponent, ItemLookupDialogComponent };
1317
- //# sourceMappingURL=myrmidon-cadmus-item-editor.mjs.map
2155
+
2156
+ //# sourceMappingURL=myrmidon-cadmus-item-editor.mjs.map