@myrmidon/cadmus-item-editor 18.0.0 → 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,1316 +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 { CustomValidators, PartBadgeComponent, getPartIdName } from '@myrmidon/cadmus-ui';
27
- import { MatCheckbox } from '@angular/material/checkbox';
28
- import * as i3 from '@myrmidon/ngx-mat-tools';
29
- import * as i5 from '@myrmidon/ngx-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
-
39
- /**
40
- * Edited item repository.
41
- */
42
- class EditedItemRepository {
43
- _appRepository;
44
- _itemService;
45
- _loading$;
46
- // the item being edited
47
- _item$;
48
- // the raw list of item's parts
49
- _parts$;
50
- _partGroups$;
51
- // the set of all the possible layer parts for this item, either
52
- // present or absent
53
- _layersPartInfo$;
54
- // the facet definition assigned to the item
55
- _facet$;
56
- // the part definitions for adding a new part, filtered by the selected
57
- // facet and the parts already present in the item.
58
- _newPartDefinitions$;
59
- get loading$() {
60
- return this._loading$.asObservable();
61
- }
62
- get item$() {
63
- return this._item$.asObservable();
64
- }
65
- get parts$() {
66
- return this._parts$.asObservable();
67
- }
68
- get partGroups$() {
69
- return this._partGroups$.asObservable();
70
- }
71
- get layers$() {
72
- return this._layersPartInfo$.asObservable();
73
- }
74
- get facet$() {
75
- return this._facet$.asObservable();
76
- }
77
- get newPartDefinitions$() {
78
- return this._newPartDefinitions$.asObservable();
79
- }
80
- constructor(_appRepository, _itemService) {
81
- this._appRepository = _appRepository;
82
- this._itemService = _itemService;
83
- this._loading$ = new BehaviorSubject(undefined);
84
- this._item$ = new BehaviorSubject(undefined);
85
- this._parts$ = new BehaviorSubject([]);
86
- this._partGroups$ = new BehaviorSubject([]);
87
- this._layersPartInfo$ = new BehaviorSubject([]);
88
- this._facet$ = new BehaviorSubject(undefined);
89
- this._newPartDefinitions$ = new BehaviorSubject([]);
90
- // ensure app data is loaded
91
- this._appRepository.load();
92
- }
93
- getItem() {
94
- return this._item$.value;
95
- }
96
- getFacet() {
97
- return this._facet$.value;
98
- }
99
- getExistingPartTypeAndRoleIds() {
100
- const groups = this.getPartGroups();
101
- if (!groups) {
102
- return [];
103
- }
104
- const results = [];
105
- for (const group of groups) {
106
- for (const part of group.parts) {
107
- results.push({
108
- typeId: part.typeId,
109
- roleId: part.roleId,
110
- });
111
- }
112
- }
113
- return results;
114
- }
115
- getNewPartDefinitions() {
116
- const facet = this.getFacet();
117
- if (!facet) {
118
- return [];
119
- }
120
- const existingTypeRoleIds = this.getExistingPartTypeAndRoleIds();
121
- const defs = [];
122
- for (const def of facet.partDefinitions) {
123
- // exclude layer parts, as these are in the layers tab
124
- if (def.roleId?.startsWith('fr.')) {
125
- continue;
126
- }
127
- // exclude parts present in the item
128
- if (existingTypeRoleIds.find((tr) => {
129
- return (tr.typeId === def.typeId &&
130
- ((!tr.roleId && !def.roleId) || tr.roleId === def.roleId));
131
- })) {
132
- continue;
133
- }
134
- defs.push(def);
135
- }
136
- // sort by sort key
137
- defs.sort((a, b) => {
138
- return (a.sortKey || '').localeCompare(b.sortKey || '');
139
- });
140
- return defs;
141
- }
142
- getPartGroups() {
143
- return this._partGroups$.value;
144
- }
145
- pickDefaultFacet(facets) {
146
- if (!facets.length) {
147
- return undefined;
148
- }
149
- // if there is a facet with id="default", pick it
150
- const defaultFacet = facets.find((f) => f.id === 'default');
151
- if (defaultFacet) {
152
- return defaultFacet;
153
- }
154
- // else just pick the first in the list
155
- return facets[0];
156
- }
157
- /**
158
- * Load the specified item or a new item.
159
- *
160
- * @param itemId The item ID, or falsy for a new item.
161
- */
162
- load(itemId) {
163
- const facets = this._appRepository.getFacets();
164
- this._loading$.next(true);
165
- if (!itemId) {
166
- // new item
167
- this._itemService.getItemLayerInfo('new', true).subscribe((layers) => {
168
- const facet = this.pickDefaultFacet(facets);
169
- this._loading$.next(false);
170
- this._item$.next({
171
- id: '',
172
- title: '',
173
- description: '',
174
- facetId: facet?.id || '',
175
- groupId: '',
176
- sortKey: '',
177
- flags: 0,
178
- timeCreated: new Date(),
179
- creatorId: '',
180
- timeModified: new Date(),
181
- userId: '',
182
- });
183
- this._parts$.next([]);
184
- this._partGroups$.next([]);
185
- this._layersPartInfo$.next(layers);
186
- this._facet$.next(facet);
187
- this._newPartDefinitions$.next(this.getNewPartDefinitions());
188
- });
189
- }
190
- else {
191
- // existing item
192
- forkJoin({
193
- item: this._itemService.getItem(itemId, true),
194
- layers: this._itemService.getItemLayerInfo(itemId, true),
195
- }).subscribe({
196
- next: (result) => {
197
- this._loading$.next(false);
198
- const itemFacet = facets.find((f) => {
199
- return f.id === result.item.facetId;
200
- });
201
- const facetParts = itemFacet ? itemFacet.partDefinitions : [];
202
- this._item$.next(result.item);
203
- this._parts$.next(result.item.parts || []);
204
- this._partGroups$.next(this._itemService.groupParts(result.item.parts || [], facetParts));
205
- this._layersPartInfo$.next(result.layers);
206
- this._facet$.next(itemFacet);
207
- this._newPartDefinitions$.next(this.getNewPartDefinitions());
208
- },
209
- });
210
- }
211
- }
212
- /**
213
- * Ensure that the item with the specified ID is loaded.
214
- *
215
- * @param id The item ID.
216
- */
217
- ensureItemLoaded(id) {
218
- if (this.getItem()?.id === id) {
219
- return;
220
- }
221
- this.load(id);
222
- }
223
- /**
224
- * Save the specified item in the backend and update this store.
225
- *
226
- * @param item The item.
227
- * @returns Promise with saved item.
228
- */
229
- save(item) {
230
- return new Promise((resolve, reject) => {
231
- this._itemService.addItem(item).subscribe({
232
- next: (saved) => {
233
- // update the item and the selected facet from it;
234
- // this is required when the item was new, and thus loaded
235
- // with the default facet before saving it
236
- const facets = this._appRepository.getFacets();
237
- const itemFacet = facets.find((f) => {
238
- return f.id === saved.facetId;
239
- });
240
- this._item$.next(saved);
241
- this._facet$.next(itemFacet);
242
- this._newPartDefinitions$.next(this.getNewPartDefinitions());
243
- resolve(saved);
244
- },
245
- error: (error) => {
246
- console.error(`Error saving item ${item.id}`, error);
247
- reject({ message: 'Error saving item ' + item.id, error: error });
248
- },
249
- });
250
- });
251
- }
252
- /**
253
- * Delete the specified part from this edited item.
254
- *
255
- * @param id The part's ID.
256
- * @returns Promise with part ID.
257
- */
258
- deletePart(id) {
259
- return new Promise((resolve, reject) => {
260
- const itemId = this._item$.value?.id;
261
- if (!itemId) {
262
- reject({
263
- message: 'Cannot delete part of unsaved item',
264
- });
265
- return;
266
- }
267
- this._itemService.deletePart(id).subscribe({
268
- next: (_) => {
269
- this.load(itemId);
270
- resolve(id);
271
- },
272
- error: (error) => {
273
- console.error(`Error deleting item's part ${id}`, error);
274
- reject({
275
- message: "Error deleting item's part " + id,
276
- error: error,
277
- });
278
- },
279
- });
280
- });
281
- }
282
- /**
283
- * Add a new layer part to this item.
284
- *
285
- * @param typeId The part type ID.
286
- * @param roleId The part role ID.
287
- * @returns Promise with new part.
288
- */
289
- addNewLayerPart(typeId, roleId) {
290
- return new Promise((resolve, reject) => {
291
- const itemId = this._item$.value?.id;
292
- if (!itemId) {
293
- reject({
294
- message: 'Cannot add part to unsaved item',
295
- });
296
- return;
297
- }
298
- const part = {
299
- itemId: itemId,
300
- typeId,
301
- roleId,
302
- id: '',
303
- creatorId: '',
304
- userId: '',
305
- timeCreated: new Date(),
306
- timeModified: new Date(),
307
- };
308
- this._itemService.addPart(part).subscribe({
309
- next: (part) => {
310
- this.load(itemId);
311
- resolve(part);
312
- },
313
- error: (error) => {
314
- console.error(`Error adding new layer part for item ${itemId}`, error);
315
- reject({
316
- message: 'Error adding new layer part for item ' + itemId,
317
- error: error,
318
- });
319
- },
320
- });
321
- });
322
- }
323
- /**
324
- * Set the scope for the specified parts in this item.
325
- *
326
- * @param ids The part IDs.
327
- * @param scope The scope to set.
328
- * @returns Promise.
329
- */
330
- setPartThesaurusScope(ids, scope) {
331
- return new Promise((resolve, reject) => {
332
- const itemId = this._item$.value?.id;
333
- if (!itemId) {
334
- reject({
335
- message: 'Cannot set scope for unsaved item',
336
- });
337
- return;
338
- }
339
- this._itemService.setPartThesaurusScope(ids, scope).subscribe({
340
- next: (_) => {
341
- this.load(itemId);
342
- resolve(true);
343
- },
344
- error: (error) => {
345
- console.error("Error setting item's part scope", error);
346
- reject({
347
- message: "Error setting item's part scope",
348
- error: error,
349
- });
350
- },
351
- });
352
- });
353
- }
354
- 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 });
355
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: EditedItemRepository, providedIn: 'root' });
356
- }
357
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: EditedItemRepository, decorators: [{
358
- type: Injectable,
359
- args: [{ providedIn: 'root' }]
360
- }], ctorParameters: () => [{ type: i1.AppRepository }, { type: i7.ItemService }] });
361
-
362
- class CurrentItemBarComponent {
363
- item;
364
- constructor(repository) {
365
- this.item = toSignal(repository.item$);
366
- }
367
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: CurrentItemBarComponent, deps: [{ token: EditedItemRepository }], target: i0.ɵɵFactoryTarget.Component });
368
- 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) {\r\n <div class=\"item-bar\">\r\n <span class=\"title\">{{ item.title }}</span>\r\n <span class=\"id\">{{ item.id }}</span>\r\n &#x2B24;\r\n <span class=\"dsc\">\r\n {{ item.description }} &#x2B24;\r\n <span matTooltip=\"Created\"\r\n >{{ item.timeCreated | date: \"yyyy-MM-dd HH:mm:ss\" }}\r\n {{ item.creatorId }}</span\r\n >\r\n &#x2B24;\r\n <span matTooltip=\"Last saved\"\r\n >{{ item.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\r\n {{ item.userId }}</span\r\n >\r\n </span>\r\n </div>\r\n}\r\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 });
369
- }
370
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: CurrentItemBarComponent, decorators: [{
371
- type: Component,
372
- args: [{ selector: 'cadmus-current-item-bar', changeDetection: ChangeDetectionStrategy.OnPush, imports: [DatePipe, MatTooltip], template: "@if (item(); as item) {\r\n <div class=\"item-bar\">\r\n <span class=\"title\">{{ item.title }}</span>\r\n <span class=\"id\">{{ item.id }}</span>\r\n &#x2B24;\r\n <span class=\"dsc\">\r\n {{ item.description }} &#x2B24;\r\n <span matTooltip=\"Created\"\r\n >{{ item.timeCreated | date: \"yyyy-MM-dd HH:mm:ss\" }}\r\n {{ item.creatorId }}</span\r\n >\r\n &#x2B24;\r\n <span matTooltip=\"Last saved\"\r\n >{{ item.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\r\n {{ item.userId }}</span\r\n >\r\n </span>\r\n </div>\r\n}\r\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"] }]
373
- }], ctorParameters: () => [{ type: EditedItemRepository }] });
374
-
375
- class CurrentLayerPartBarComponent {
376
- _appRepository;
377
- _editedItemRepository;
378
- _facetService;
379
- _facet;
380
- _part;
381
- typeId;
382
- roleId;
383
- color;
384
- constructor(_appRepository, _editedItemRepository, editedLayerRepository, _facetService) {
385
- this._appRepository = _appRepository;
386
- this._editedItemRepository = _editedItemRepository;
387
- this._facetService = _facetService;
388
- this._facet = toSignal(this._editedItemRepository.facet$);
389
- this._part = toSignal(editedLayerRepository.part$);
390
- this.typeId = computed(() => {
391
- const part = this._part();
392
- if (!part)
393
- return undefined;
394
- return this.getTypeIdName(part.typeId);
395
- }, /* @ts-ignore */
396
- ...(ngDevMode ? [{ debugName: "typeId" }] : /* istanbul ignore next */ []));
397
- this.roleId = computed(() => {
398
- const part = this._part();
399
- if (!part)
400
- return undefined;
401
- return this.getRoleIdName(part.roleId);
402
- }, /* @ts-ignore */
403
- ...(ngDevMode ? [{ debugName: "roleId" }] : /* istanbul ignore next */ []));
404
- this.color = computed(() => {
405
- const part = this._part();
406
- this._facet(); // declare dependency so color recomputes on facet change
407
- if (!part)
408
- return undefined;
409
- return this.getPartColor(part.typeId, part.roleId);
410
- }, /* @ts-ignore */
411
- ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
412
- }
413
- getTypeIdName(typeId) {
414
- const typeThesaurus = this._appRepository.getTypeThesaurus();
415
- if (!typeThesaurus) {
416
- return typeId;
417
- }
418
- // strip :suffix if any
419
- const i = typeId.lastIndexOf(':');
420
- if (i > -1) {
421
- typeId = typeId.substring(0, i);
422
- }
423
- const entry = typeThesaurus.entries?.find((e) => e.id === typeId);
424
- return entry ? entry.value : typeId;
425
- }
426
- getRoleIdName(roleId) {
427
- if (!roleId || !roleId.startsWith('fr.')) {
428
- return roleId;
429
- }
430
- return this.getTypeIdName(roleId);
431
- }
432
- getPartColor(typeId, roleId) {
433
- const facet = this._editedItemRepository.getFacet();
434
- return this._facetService.getPartColor(typeId, roleId, facet);
435
- }
436
- 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 });
437
- 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>\r\n <span class=\"type-id\" [style.background-color]=\"color()\">{{ typeId() }}</span>\r\n <span class=\"role-id\">{{ roleId() }}</span>\r\n</div>\r\n", styles: ["span.type-id{padding:4px;border-radius:6px}span.role-id{padding:4px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
438
- }
439
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: CurrentLayerPartBarComponent, decorators: [{
440
- type: Component,
441
- args: [{ selector: 'cadmus-current-layer-part-bar', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div>\r\n <span class=\"type-id\" [style.background-color]=\"color()\">{{ typeId() }}</span>\r\n <span class=\"role-id\">{{ roleId() }}</span>\r\n</div>\r\n", styles: ["span.type-id{padding:4px;border-radius:6px}span.role-id{padding:4px}\n"] }]
442
- }], ctorParameters: () => [{ type: i1.AppRepository }, { type: EditedItemRepository }, { type: i1.EditedLayerRepository }, { type: i7.FacetService }] });
443
-
444
- /**
445
- * Parts thesaurus scope dumb editor component.
446
- * This is used to set the thesaurus scope of multiple item's parts at once
447
- * in the item editor.
448
- */
449
- class PartsScopeEditorComponent {
450
- _formBuilder;
451
- _facetService;
452
- _dialogService;
453
- _appRepository;
454
- _colorService;
455
- _editedItemRepository;
456
- parts = input(/* @ts-ignore */
457
- ...(ngDevMode ? [undefined, { debugName: "parts" }] : /* istanbul ignore next */ []));
458
- readonly = input(/* @ts-ignore */
459
- ...(ngDevMode ? [undefined, { debugName: "readonly" }] : /* istanbul ignore next */ []));
460
- setScopeRequest = output();
461
- checks;
462
- scope;
463
- form;
464
- constructor(_formBuilder, _facetService, _dialogService, _appRepository, _colorService, _editedItemRepository) {
465
- this._formBuilder = _formBuilder;
466
- this._facetService = _facetService;
467
- this._dialogService = _dialogService;
468
- this._appRepository = _appRepository;
469
- this._colorService = _colorService;
470
- this._editedItemRepository = _editedItemRepository;
471
- this.checks = _formBuilder.array([], CustomValidators.minChecked(1));
472
- this.scope = _formBuilder.control(null, [
473
- Validators.maxLength(50),
474
- Validators.pattern(/^[-a-zA-Z0-9_]+$/),
475
- ]);
476
- this.form = _formBuilder.group({
477
- checks: this.checks,
478
- scope: this.scope,
479
- });
480
- // ensure app data is loaded
481
- this._appRepository.load();
482
- effect(() => {
483
- this.updateForm(this.parts());
484
- });
485
- }
486
- updateForm(parts) {
487
- this.checks.clear();
488
- if (!parts?.length) {
489
- return;
490
- }
491
- for (let i = 0; i < parts.length; i++) {
492
- this.checks.push(this._formBuilder.control(false));
493
- }
494
- this.form.updateValueAndValidity();
495
- }
496
- onCheckChanged() {
497
- this.form.updateValueAndValidity();
498
- }
499
- getPartColor(typeId, roleId) {
500
- const facet = this._editedItemRepository.getFacet();
501
- return this._facetService.getPartColor(typeId, roleId, facet);
502
- }
503
- getContrastColor(typeId, roleId) {
504
- const rgb = this.getPartColor(typeId, roleId);
505
- return this._colorService.getContrastColor(rgb);
506
- }
507
- getTypeIdName(typeId) {
508
- const typeThesaurus = this._appRepository.getTypeThesaurus();
509
- if (!typeThesaurus) {
510
- return typeId;
511
- }
512
- // strip :suffix if any
513
- const i = typeId.lastIndexOf(':');
514
- if (i > -1) {
515
- typeId = typeId.substring(0, i);
516
- }
517
- const entry = typeThesaurus.entries?.find((e) => e.id === typeId);
518
- return entry ? entry.value : typeId;
519
- }
520
- getRoleIdName(roleId) {
521
- if (!roleId || !roleId.startsWith('fr.')) {
522
- return roleId;
523
- }
524
- return this.getTypeIdName(roleId);
525
- }
526
- submit() {
527
- if (this.form.invalid || !this.parts()?.length) {
528
- return;
529
- }
530
- const ids = [];
531
- const parts = this.parts();
532
- for (let i = 0; i < this.checks.length; i++) {
533
- if (this.checks.controls[i].value === true) {
534
- ids.push(parts[i].id);
535
- }
536
- }
537
- let msg = this.scope.value
538
- ? `Assign scope "${this.scope.value}" to ${ids.length} part`
539
- : `Remove scope from ${ids.length} part`;
540
- msg += ids.length > 1 ? 's?' : '?';
541
- this._dialogService.confirm('Confirm Scopes', msg).subscribe((result) => {
542
- if (!result) {
543
- return;
544
- }
545
- this.setScopeRequest.emit({
546
- ids,
547
- scope: this.scope.value,
548
- });
549
- });
550
- }
551
- 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 });
552
- 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()\">\r\n <table id=\"parts\" formArrayName=\"checks\">\r\n <thead>\r\n <tr>\r\n <th aria-label=\"select\"></th>\r\n <th>type</th>\r\n <th>role</th>\r\n <th>scope</th>\r\n <th>modified</th>\r\n <th>user</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n @for (\r\n part of parts() ?? [];\r\n track part.typeId + \":\" + (part.roleId ?? \"\");\r\n let i = $index\r\n ) {\r\n <tr>\r\n <td class=\"fit-width\">\r\n <mat-checkbox [formControlName]=\"i\" (change)=\"onCheckChanged()\" />\r\n </td>\r\n <td>\r\n <span\r\n class=\"model-type\"\r\n [style.background-color]=\"getPartColor(part.typeId, part.roleId)\"\r\n [style.color]=\"getContrastColor(part.typeId, part.roleId)\"\r\n >{{ getTypeIdName(part.typeId) }}</span\r\n >\r\n </td>\r\n <td>{{ getRoleIdName(part.roleId ?? \"\") }}</td>\r\n <td>{{ part.thesaurusScope }}</td>\r\n <td>{{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}</td>\r\n <td>{{ part.userId }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n <div class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>scope</mat-label>\r\n <input matInput formControlName=\"scope\" />\r\n @if (scope.hasError(\"maxLength\") && (scope.dirty || scope.touched)) {\r\n <mat-error>too long</mat-error>\r\n }\r\n @if (scope.hasError(\"pattern\") && (scope.dirty || scope.touched)) {\r\n <mat-error>invalid scope</mat-error>\r\n }\r\n </mat-form-field>\r\n <button\r\n mat-flat-button\r\n class=\"mat-primary\"\r\n type=\"submit\"\r\n [disabled]=\"form.invalid || readonly()\"\r\n matTooltip=\"Assign the scope to the checked parts\"\r\n >\r\n assign\r\n </button>\r\n </div>\r\n</form>\r\n", styles: ["table{width:100%;border-collapse:collapse;color:var(--mat-sys-on-surface-variant)}tbody tr:nth-child(odd){background-color:var(--mat-sys-surface-container)}th{text-align:left;font-weight:400;color:var(--mat-sys-on-surface-variant)}tbody tr:hover{background-color:var(--mat-sys-surface-container-high)}td.fit-width{width:1px;white-space:nowrap}tbody tr.selected{background-color:var(--mat-sys-secondary-container);color:var(--mat-sys-on-secondary-container)}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 });
553
- }
554
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: PartsScopeEditorComponent, decorators: [{
555
- type: Component,
556
- args: [{ selector: 'cadmus-parts-scope-editor', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
557
- ReactiveFormsModule,
558
- MatCheckbox,
559
- MatFormField,
560
- MatLabel,
561
- MatInput,
562
- MatError,
563
- MatButton,
564
- MatTooltip,
565
- DatePipe,
566
- ], template: "<form [formGroup]=\"form\" (submit)=\"submit()\">\r\n <table id=\"parts\" formArrayName=\"checks\">\r\n <thead>\r\n <tr>\r\n <th aria-label=\"select\"></th>\r\n <th>type</th>\r\n <th>role</th>\r\n <th>scope</th>\r\n <th>modified</th>\r\n <th>user</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n @for (\r\n part of parts() ?? [];\r\n track part.typeId + \":\" + (part.roleId ?? \"\");\r\n let i = $index\r\n ) {\r\n <tr>\r\n <td class=\"fit-width\">\r\n <mat-checkbox [formControlName]=\"i\" (change)=\"onCheckChanged()\" />\r\n </td>\r\n <td>\r\n <span\r\n class=\"model-type\"\r\n [style.background-color]=\"getPartColor(part.typeId, part.roleId)\"\r\n [style.color]=\"getContrastColor(part.typeId, part.roleId)\"\r\n >{{ getTypeIdName(part.typeId) }}</span\r\n >\r\n </td>\r\n <td>{{ getRoleIdName(part.roleId ?? \"\") }}</td>\r\n <td>{{ part.thesaurusScope }}</td>\r\n <td>{{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}</td>\r\n <td>{{ part.userId }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n <div class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>scope</mat-label>\r\n <input matInput formControlName=\"scope\" />\r\n @if (scope.hasError(\"maxLength\") && (scope.dirty || scope.touched)) {\r\n <mat-error>too long</mat-error>\r\n }\r\n @if (scope.hasError(\"pattern\") && (scope.dirty || scope.touched)) {\r\n <mat-error>invalid scope</mat-error>\r\n }\r\n </mat-form-field>\r\n <button\r\n mat-flat-button\r\n class=\"mat-primary\"\r\n type=\"submit\"\r\n [disabled]=\"form.invalid || readonly()\"\r\n matTooltip=\"Assign the scope to the checked parts\"\r\n >\r\n assign\r\n </button>\r\n </div>\r\n</form>\r\n", styles: ["table{width:100%;border-collapse:collapse;color:var(--mat-sys-on-surface-variant)}tbody tr:nth-child(odd){background-color:var(--mat-sys-surface-container)}th{text-align:left;font-weight:400;color:var(--mat-sys-on-surface-variant)}tbody tr:hover{background-color:var(--mat-sys-surface-container-high)}td.fit-width{width:1px;white-space:nowrap}tbody tr.selected{background-color:var(--mat-sys-secondary-container);color:var(--mat-sys-on-secondary-container)}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"] }]
567
- }], 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"] }] } });
568
-
569
- /**
570
- * Simple item lookup dialog. This allows the user to select an item from
571
- * its title, and returns the selected item if not cancelled.
572
- */
573
- class ItemLookupDialogComponent {
574
- dialogRef;
575
- config;
576
- itemLookupService;
577
- constructor(dialogRef, config, itemLookupService) {
578
- this.dialogRef = dialogRef;
579
- this.config = config;
580
- this.itemLookupService = itemLookupService;
581
- }
582
- onCancel() {
583
- this.dialogRef.close(null);
584
- }
585
- onItemLookupChange(value) {
586
- this.dialogRef.close(value);
587
- }
588
- 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 });
589
- 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 });
590
- }
591
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ItemLookupDialogComponent, decorators: [{
592
- type: Component,
593
- 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"] }]
594
- }], ctorParameters: () => [{ type: i2.MatDialogRef }, { type: i2.MatDialogConfig, decorators: [{
595
- type: Inject,
596
- args: [MAT_DIALOG_DATA]
597
- }] }, { type: i2$1.ItemRefLookupService }] });
598
-
599
- /**
600
- * Simple item generate dialog. This allows the user to enter a title template
601
- * and flags, and returns the entered values if not cancelled.
602
- */
603
- class ItemGenerateDialogComponent {
604
- dialogRef;
605
- config;
606
- flags = signal([], /* @ts-ignore */
607
- ...(ngDevMode ? [{ debugName: "flags" }] : /* istanbul ignore next */ []));
608
- itemCount;
609
- itemTitle;
610
- itemFlags;
611
- form;
612
- constructor(formBuilder, dialogRef, config) {
613
- this.dialogRef = dialogRef;
614
- this.config = config;
615
- this.itemCount = formBuilder.control(1, {
616
- nonNullable: true,
617
- validators: [Validators.required, Validators.min(1), Validators.max(100)],
618
- });
619
- this.itemTitle = formBuilder.control('', {
620
- nonNullable: true,
621
- validators: [Validators.required, Validators.maxLength(500)],
622
- });
623
- this.itemFlags = formBuilder.control([], {
624
- nonNullable: true,
625
- });
626
- this.form = formBuilder.group({
627
- itemCount: this.itemCount,
628
- itemTitle: this.itemTitle,
629
- itemFlags: this.itemFlags,
630
- });
631
- // flags definitions
632
- this.flags.set(config?.flags || []);
633
- }
634
- apply() {
635
- if (!this.form.valid) {
636
- return;
637
- }
638
- // calculate flags value by ORing the IDs
639
- const flags = this.itemFlags.value.reduce((acc, f) => acc | f.id, 0);
640
- this.dialogRef.close({
641
- count: this.itemCount.value,
642
- title: this.itemTitle.value,
643
- flags: flags,
644
- });
645
- }
646
- 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 });
647
- 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\">\r\n <h3>Generate Items</h3>\r\n <form [formGroup]=\"form\" (submit)=\"apply()\">\r\n <!-- count -->\r\n <div>\r\n <mat-form-field class=\"input-nr\">\r\n <mat-label>count</mat-label>\r\n <input matInput type=\"number\" min=\"1\" [formControl]=\"itemCount\" />\r\n <mat-hint>number of items to generate</mat-hint>\r\n @if (\r\n itemCount.errors?.[\"required\"] && (itemCount.dirty || itemCount.touched)\r\n ) {\r\n <mat-error>count required</mat-error>\r\n }\r\n @if (\r\n itemCount.errors?.[\"min\"] && (itemCount.dirty || itemCount.touched)\r\n ) {\r\n <mat-error>count too low</mat-error>\r\n }\r\n @if (\r\n itemCount.errors?.[\"max\"] && (itemCount.dirty || itemCount.touched)\r\n ) {\r\n <mat-error>count too high</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- title -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label>title</mat-label>\r\n <input matInput [formControl]=\"itemTitle\" />\r\n <mat-hint>title template ({{ \"{0}\" }}=N)</mat-hint>\r\n @if (\r\n itemTitle.errors?.[\"required\"] &&\r\n (itemTitle.dirty || itemTitle.touched)\r\n ) {\r\n <mat-error>title required</mat-error>\r\n }\r\n @if (\r\n itemTitle.errors?.[\"maxlength\"] &&\r\n (itemTitle.dirty || itemTitle.touched)\r\n ) {\r\n <mat-error>title too long</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- flags -->\r\n @if (flags().length) {\r\n <div>\r\n <mat-form-field>\r\n <mat-label>flags</mat-label>\r\n <mat-select [formControl]=\"itemFlags\" multiple>\r\n @for (flag of flags(); track flag.id) {\r\n <mat-option [value]=\"flag\">\r\n <span class=\"flag-bullet\" [style.color]=\"'#' + flag.colorKey\"\r\n >&#x2b24;</span\r\n >\r\n {{ flag.label }}\r\n </mat-option>\r\n }\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n }\r\n\r\n <!-- apply button -->\r\n <div>\r\n <button\r\n mat-flat-button\r\n class=\"mat-primary\"\r\n type=\"submit\"\r\n [disabled]=\"form.invalid\"\r\n >\r\n generate\r\n </button>\r\n </div>\r\n </form>\r\n</div>\r\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 });
648
- }
649
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ItemGenerateDialogComponent, decorators: [{
650
- type: Component,
651
- args: [{ selector: 'cadmus-item-generate-dialog', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
652
- ReactiveFormsModule,
653
- MatFormField,
654
- MatLabel,
655
- MatInput,
656
- MatHint,
657
- MatError,
658
- MatSelect,
659
- MatOption,
660
- MatButton,
661
- ], template: "<div id=\"container\">\r\n <h3>Generate Items</h3>\r\n <form [formGroup]=\"form\" (submit)=\"apply()\">\r\n <!-- count -->\r\n <div>\r\n <mat-form-field class=\"input-nr\">\r\n <mat-label>count</mat-label>\r\n <input matInput type=\"number\" min=\"1\" [formControl]=\"itemCount\" />\r\n <mat-hint>number of items to generate</mat-hint>\r\n @if (\r\n itemCount.errors?.[\"required\"] && (itemCount.dirty || itemCount.touched)\r\n ) {\r\n <mat-error>count required</mat-error>\r\n }\r\n @if (\r\n itemCount.errors?.[\"min\"] && (itemCount.dirty || itemCount.touched)\r\n ) {\r\n <mat-error>count too low</mat-error>\r\n }\r\n @if (\r\n itemCount.errors?.[\"max\"] && (itemCount.dirty || itemCount.touched)\r\n ) {\r\n <mat-error>count too high</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- title -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label>title</mat-label>\r\n <input matInput [formControl]=\"itemTitle\" />\r\n <mat-hint>title template ({{ \"{0}\" }}=N)</mat-hint>\r\n @if (\r\n itemTitle.errors?.[\"required\"] &&\r\n (itemTitle.dirty || itemTitle.touched)\r\n ) {\r\n <mat-error>title required</mat-error>\r\n }\r\n @if (\r\n itemTitle.errors?.[\"maxlength\"] &&\r\n (itemTitle.dirty || itemTitle.touched)\r\n ) {\r\n <mat-error>title too long</mat-error>\r\n }\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- flags -->\r\n @if (flags().length) {\r\n <div>\r\n <mat-form-field>\r\n <mat-label>flags</mat-label>\r\n <mat-select [formControl]=\"itemFlags\" multiple>\r\n @for (flag of flags(); track flag.id) {\r\n <mat-option [value]=\"flag\">\r\n <span class=\"flag-bullet\" [style.color]=\"'#' + flag.colorKey\"\r\n >&#x2b24;</span\r\n >\r\n {{ flag.label }}\r\n </mat-option>\r\n }\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n }\r\n\r\n <!-- apply button -->\r\n <div>\r\n <button\r\n mat-flat-button\r\n class=\"mat-primary\"\r\n type=\"submit\"\r\n [disabled]=\"form.invalid\"\r\n >\r\n generate\r\n </button>\r\n </div>\r\n </form>\r\n</div>\r\n", styles: ["#container{padding:16px}.flag-bullet{margin-right:.5em}.input-nr{width:5em}\n"] }]
662
- }], ctorParameters: () => [{ type: i1$1.FormBuilder }, { type: i2.MatDialogRef }, { type: i2.MatDialogConfig, decorators: [{
663
- type: Inject,
664
- args: [MAT_DIALOG_DATA]
665
- }] }] });
666
-
667
- class MissingPartsComponent {
668
- facetDefinition = input(/* @ts-ignore */
669
- ...(ngDevMode ? [undefined, { debugName: "facetDefinition" }] : /* istanbul ignore next */ []));
670
- partDefinitions = input(/* @ts-ignore */
671
- ...(ngDevMode ? [undefined, { debugName: "partDefinitions" }] : /* istanbul ignore next */ []));
672
- parts = input(/* @ts-ignore */
673
- ...(ngDevMode ? [undefined, { debugName: "parts" }] : /* istanbul ignore next */ []));
674
- missingDefinitions = signal([], /* @ts-ignore */
675
- ...(ngDevMode ? [{ debugName: "missingDefinitions" }] : /* istanbul ignore next */ []));
676
- /**
677
- * The types thesaurus.
678
- */
679
- typeThesaurus = input(/* @ts-ignore */
680
- ...(ngDevMode ? [undefined, { debugName: "typeThesaurus" }] : /* istanbul ignore next */ []));
681
- /**
682
- * Emitted when the user requests to add a missing part.
683
- */
684
- addRequest = output();
685
- constructor() {
686
- effect(() => {
687
- this.updateMissing(this.partDefinitions(), this.parts());
688
- });
689
- }
690
- partExists(typeId, roleId, parts) {
691
- if (!parts) {
692
- return false;
693
- }
694
- return parts.some((p) => p.typeId === typeId && ((!p.roleId && !roleId) || p.roleId === roleId));
695
- }
696
- updateMissing(definitions, parts) {
697
- const missingDefinitions = [];
698
- if (!definitions) {
699
- return;
700
- }
701
- for (let i = 0; i < definitions.length; i++) {
702
- const def = definitions[i];
703
- if (def.isRequired && !this.partExists(def.typeId, def.roleId, parts)) {
704
- missingDefinitions.push(def);
705
- }
706
- }
707
- this.missingDefinitions.set(missingDefinitions);
708
- }
709
- requestAddPart(definition) {
710
- this.addRequest.emit(definition);
711
- }
712
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: MissingPartsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
713
- 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) {\r\n <div>\r\n <fieldset>\r\n <legend>\r\n <mat-icon class=\"mat-warn\">warning</mat-icon>&nbsp; Missing Parts\r\n </legend>\r\n <table>\r\n <tbody>\r\n @for (\r\n def of missingDefinitions();\r\n track def.typeId + \":\" + (def.roleId ?? \"\")\r\n ) {\r\n <tr>\r\n <td>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Add this part\"\r\n (click)=\"requestAddPart(def)\"\r\n >\r\n <mat-icon>add_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td [matTooltip]=\"def.description\">\r\n <cadmus-part-badge\r\n [partTypeIds]=\"def\"\r\n [facetDefinition]=\"facetDefinition()\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </fieldset>\r\n </div>\r\n}\r\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 });
714
- }
715
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: MissingPartsComponent, decorators: [{
716
- type: Component,
717
- args: [{ selector: 'cadmus-missing-parts', changeDetection: ChangeDetectionStrategy.OnPush, imports: [MatIcon, MatIconButton, MatTooltip, PartBadgeComponent], template: "@if (missingDefinitions().length) {\r\n <div>\r\n <fieldset>\r\n <legend>\r\n <mat-icon class=\"mat-warn\">warning</mat-icon>&nbsp; Missing Parts\r\n </legend>\r\n <table>\r\n <tbody>\r\n @for (\r\n def of missingDefinitions();\r\n track def.typeId + \":\" + (def.roleId ?? \"\")\r\n ) {\r\n <tr>\r\n <td>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Add this part\"\r\n (click)=\"requestAddPart(def)\"\r\n >\r\n <mat-icon>add_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td [matTooltip]=\"def.description\">\r\n <cadmus-part-badge\r\n [partTypeIds]=\"def\"\r\n [facetDefinition]=\"facetDefinition()\"\r\n [typeThesaurus]=\"typeThesaurus()\"\r\n />\r\n </td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </fieldset>\r\n </div>\r\n}\r\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"] }]
718
- }], 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"] }] } });
719
-
720
- /**
721
- * A pipe used locally in the item editor to determine whether
722
- * any of its parts can be previewed. To this end, this pipe requires
723
- * the part plus the list of available renderers keys and flatteners
724
- * keys. When the part is a base text, it is checked against flatteners
725
- * and renderers; else, it is checked against renderers only.
726
- * Ideally, a text part should have a flattener, while any other part
727
- * should have a renderer. When there is no flattener, we fallback
728
- * to the renderer if any.
729
- */
730
- class HasPreviewPipe {
731
- /**
732
- * Transform the received part into a boolean value telling whether
733
- * that part can be previewed or not.
734
- *
735
- * @param value The part.
736
- * @param rKeys The list of available renderers keys.
737
- * @param fKeys The list of available flatteners keys.
738
- * @returns True if preview available; else false.
739
- */
740
- transform(value, rKeys, fKeys) {
741
- if (!value) {
742
- return false;
743
- }
744
- // the preview key is equal to the typeId, optionally followed by
745
- // | and the roleId when present (except when it's "base-text")
746
- if (value.roleId === 'base-text') {
747
- return fKeys?.find((k) => k === value.typeId) ||
748
- rKeys?.find((k) => k === value.typeId)
749
- ? true
750
- : false;
751
- }
752
- const key = value.roleId ? `${value.typeId}|${value.roleId}` : value.typeId;
753
- return rKeys?.find((k) => k === key) ? true : false;
754
- }
755
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: HasPreviewPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
756
- static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.1", ngImport: i0, type: HasPreviewPipe, isStandalone: true, name: "hasPreview" });
757
- }
758
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: HasPreviewPipe, decorators: [{
759
- type: Pipe,
760
- args: [{ name: 'hasPreview' }]
761
- }] });
762
-
763
- /**
764
- * Item editor. This can edit a new or existing item's metadata and parts.
765
- * The ID of the item being edited is extracted from the route. For a new item
766
- * this is 'new', which here is stored as an empty string.
767
- */
768
- class ItemEditorComponent {
769
- itemLookupService;
770
- dialog;
771
- _router;
772
- _route;
773
- _snackbar;
774
- _appRepository;
775
- _repository;
776
- _itemService;
777
- _libraryRouteService;
778
- _dialogService;
779
- _authService;
780
- _userLevelService;
781
- _messaging;
782
- _envService;
783
- // signals from edited-item repository
784
- item;
785
- parts;
786
- partGroups;
787
- layerPartInfos;
788
- facet;
789
- newPartDefinitions;
790
- // signals from app repository
791
- facets;
792
- typeThesaurus;
793
- previewJKeys;
794
- previewFKeys;
795
- flagDefinitions;
796
- id = signal(undefined, /* @ts-ignore */
797
- ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
798
- _currentUser;
799
- user;
800
- userLevel;
801
- busy = signal(false, /* @ts-ignore */
802
- ...(ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []));
803
- hasMetadataBuilders = signal(false, /* @ts-ignore */
804
- ...(ngDevMode ? [{ debugName: "hasMetadataBuilders" }] : /* istanbul ignore next */ []));
805
- // flag-set signals
806
- _flagsValue;
807
- /** Flags adapted for FlagSetComponent; admin flags excluded for non-admins. */
808
- flagSetFlags;
809
- /** Admin-only flags shown read-only to non-admin users. */
810
- adminFlagDefs;
811
- /** Currently checked flag IDs derived from the flags form control value. */
812
- checkedFlagIds;
813
- // new part form
814
- newPartType;
815
- newPart;
816
- // item metadata form
817
- title;
818
- sortKey;
819
- description;
820
- facetCtrl;
821
- group;
822
- flags;
823
- metadata;
824
- constructor(itemLookupService, dialog, _router, _route, _snackbar, _appRepository, _repository, _itemService, _libraryRouteService, _dialogService, _authService, _userLevelService, _messaging, _envService, _formBuilder) {
825
- this.itemLookupService = itemLookupService;
826
- this.dialog = dialog;
827
- this._router = _router;
828
- this._route = _route;
829
- this._snackbar = _snackbar;
830
- this._appRepository = _appRepository;
831
- this._repository = _repository;
832
- this._itemService = _itemService;
833
- this._libraryRouteService = _libraryRouteService;
834
- this._dialogService = _dialogService;
835
- this._authService = _authService;
836
- this._userLevelService = _userLevelService;
837
- this._messaging = _messaging;
838
- this._envService = _envService;
839
- this.id.set(this._route.snapshot.params['id']);
840
- if (this.id() === 'new') {
841
- this.id.set(undefined);
842
- }
843
- this.hasMetadataBuilders.set(this._envService.get('hasMetadataBuilders') === 'true');
844
- // new part form
845
- this.newPartType = _formBuilder.control(null, Validators.required);
846
- this.newPart = _formBuilder.group({
847
- newPartType: this.newPartType,
848
- });
849
- // item metadata form
850
- this.title = _formBuilder.control(null, [
851
- Validators.required,
852
- Validators.maxLength(500),
853
- ]);
854
- this.sortKey = _formBuilder.control(null, [
855
- Validators.required,
856
- Validators.maxLength(500),
857
- ]);
858
- this.sortKey.disable();
859
- this.description = _formBuilder.control(null, [
860
- Validators.required,
861
- Validators.maxLength(1000),
862
- ]);
863
- this.facetCtrl = _formBuilder.control(null, Validators.required);
864
- this.group = _formBuilder.control(null, Validators.maxLength(100));
865
- this.flags = _formBuilder.control(0, { nonNullable: true });
866
- this.metadata = _formBuilder.group({
867
- title: this.title,
868
- sortKey: this.sortKey,
869
- description: this.description,
870
- facet: this.facetCtrl,
871
- group: this.group,
872
- flags: this.flags,
873
- });
874
- // signals from repositories
875
- this.item = toSignal(this._repository.item$);
876
- this.parts = toSignal(this._repository.parts$, { requireSync: true });
877
- this.partGroups = toSignal(this._repository.partGroups$, {
878
- requireSync: true,
879
- });
880
- this.layerPartInfos = toSignal(this._repository.layers$, {
881
- requireSync: true,
882
- });
883
- this.facet = toSignal(this._repository.facet$);
884
- this.newPartDefinitions = toSignal(this._repository.newPartDefinitions$, {
885
- requireSync: true,
886
- });
887
- this.facets = toSignal(this._appRepository.facets$, {
888
- requireSync: true,
889
- });
890
- this.typeThesaurus = toSignal(this._appRepository.typeThesaurus$);
891
- this.previewJKeys = toSignal(this._appRepository.previewJKeys$, {
892
- requireSync: true,
893
- });
894
- this.previewFKeys = toSignal(this._appRepository.previewFKeys$, {
895
- requireSync: true,
896
- });
897
- this.flagDefinitions = toSignal(this._appRepository.flags$, {
898
- requireSync: true,
899
- });
900
- // user signals
901
- this._currentUser = toSignal(this._authService.currentUser$, {
902
- initialValue: null,
903
- });
904
- this.user = computed(() => this._currentUser() ?? undefined, /* @ts-ignore */
905
- ...(ngDevMode ? [{ debugName: "user" }] : /* istanbul ignore next */ []));
906
- this.userLevel = computed(() => {
907
- // track user changes so userLevel is recomputed on login/logout
908
- this._currentUser();
909
- return this._userLevelService.getCurrentUserLevel();
910
- }, /* @ts-ignore */
911
- ...(ngDevMode ? [{ debugName: "userLevel" }] : /* istanbul ignore next */ []));
912
- // flags signal (tracks the flags form control value)
913
- this._flagsValue = toSignal(this.flags.valueChanges, { initialValue: 0 });
914
- // flags for FlagSetComponent: exclude admin flags for non-admins
915
- this.flagSetFlags = computed(() => this.flagDefinitions()
916
- .filter((def) => this.userLevel() >= 4 || !def.isAdmin)
917
- .map((def) => ({
918
- id: String(def.id),
919
- label: def.label,
920
- color: '#' + def.colorKey,
921
- })), /* @ts-ignore */
922
- ...(ngDevMode ? [{ debugName: "flagSetFlags" }] : /* istanbul ignore next */ []));
923
- // admin-only flags shown read-only when user is not admin
924
- this.adminFlagDefs = computed(() => {
925
- if (this.userLevel() >= 4)
926
- return [];
927
- return this.flagDefinitions().filter((def) => def.isAdmin === true);
928
- }, /* @ts-ignore */
929
- ...(ngDevMode ? [{ debugName: "adminFlagDefs" }] : /* istanbul ignore next */ []));
930
- // checked flag IDs derived from the bitmask value
931
- this.checkedFlagIds = computed(() => {
932
- const value = this._flagsValue();
933
- return this.flagDefinitions()
934
- .filter((def) => (value & def.id) !== 0)
935
- .map((def) => String(def.id));
936
- }, /* @ts-ignore */
937
- ...(ngDevMode ? [{ debugName: "checkedFlagIds" }] : /* istanbul ignore next */ []));
938
- // update the metadata form whenever the item changes
939
- effect(() => {
940
- this.updateMetadataForm(this.item());
941
- });
942
- }
943
- ngOnInit() {
944
- this._repository.load(this.id());
945
- }
946
- canDeactivate() {
947
- return !this.metadata.dirty;
948
- }
949
- updateMetadataForm(item) {
950
- if (!item) {
951
- this.metadata.reset();
952
- }
953
- else {
954
- this.title.setValue(item.title);
955
- this.sortKey.setValue(item.sortKey);
956
- this.description.setValue(item.description);
957
- this.facetCtrl.setValue(item.facetId ?? null);
958
- this.group.setValue(item.groupId ?? null);
959
- this.flags.setValue(item.flags);
960
- this.metadata.markAsPristine();
961
- }
962
- }
963
- /**
964
- * Called when the FlagSetComponent emits new checked flag IDs.
965
- * Converts the string IDs back to a bitmask integer and updates
966
- * the flags form control, preserving admin-flag bits for non-admins.
967
- */
968
- onFlagCheckedIdsChange(ids) {
969
- let value = 0;
970
- // non-admins cannot change admin flags: preserve their current bits
971
- if (this.userLevel() < 4) {
972
- const current = this.flags.value;
973
- for (const def of this.flagDefinitions()) {
974
- if (def.isAdmin && (current & def.id) !== 0) {
975
- value |= def.id;
976
- }
977
- }
978
- }
979
- for (const id of ids) {
980
- value |= Number(id);
981
- }
982
- this.flags.setValue(value);
983
- this.flags.markAsDirty();
984
- }
985
- getTypeIdName(typeId) {
986
- const typeThesaurus = this._appRepository.getTypeThesaurus();
987
- if (!typeThesaurus) {
988
- return typeId;
989
- }
990
- // strip :suffix if any
991
- const i = typeId.lastIndexOf(':');
992
- if (i > -1) {
993
- typeId = typeId.substring(0, i);
994
- }
995
- const entry = typeThesaurus.entries?.find((e) => e.id === typeId);
996
- return entry ? entry.value : typeId;
997
- }
998
- getRoleIdName(roleId) {
999
- if (!roleId || !roleId.startsWith('fr.')) {
1000
- return roleId;
1001
- }
1002
- return this.getTypeIdName(roleId);
1003
- }
1004
- save() {
1005
- if (this.busy() || !this.metadata.valid) {
1006
- return;
1007
- }
1008
- const currentItem = this._repository.getItem();
1009
- if (!currentItem) {
1010
- return;
1011
- }
1012
- const item = { ...currentItem };
1013
- item.title = this.title.value?.trim() || '';
1014
- item.sortKey = this.sortKey.value?.trim() || '';
1015
- item.description = this.description.value?.trim() || '';
1016
- item.facetId = this.facetCtrl.value?.trim() || '';
1017
- item.groupId = this.group.value?.trim() || '';
1018
- item.flags = this.flags.value;
1019
- this.busy.set(true);
1020
- this._repository
1021
- .save(item)
1022
- .then((saved) => {
1023
- this._messaging.sendMessage(MESSAGE_ITEM_LIST_REPOSITORY_RESET);
1024
- // mark form pristine immediately: in a zoneless app the effect that
1025
- // calls updateMetadataForm (and thus markAsPristine) is scheduled
1026
- // asynchronously, so without this explicit call the pending-changes
1027
- // guard would still see a dirty form and prompt the user even though
1028
- // the item was just saved successfully.
1029
- this.metadata.markAsPristine();
1030
- // reload to force change in page URL for new items
1031
- if (!item.id) {
1032
- this.id.set(saved.id);
1033
- this._router.navigate(['/items', saved.id]);
1034
- }
1035
- })
1036
- .finally(() => {
1037
- this.busy.set(false);
1038
- });
1039
- }
1040
- partExists(typeId, roleId) {
1041
- const groups = this._repository.getPartGroups();
1042
- if (!groups) {
1043
- return false;
1044
- }
1045
- return groups.some((g) => {
1046
- return g.parts.some((p) => p.typeId === typeId &&
1047
- ((!p.roleId && !roleId) || p.roleId === roleId));
1048
- });
1049
- }
1050
- getPartIdName(typeId, roleId) {
1051
- return getPartIdName(typeId, roleId, this._appRepository.getTypeThesaurus());
1052
- }
1053
- addPart(def) {
1054
- if (!def && !this.newPartType.valid) {
1055
- return;
1056
- }
1057
- if (!this.id()) {
1058
- this._snackbar.open('Please save the item before adding parts', 'OK', {
1059
- duration: 3000,
1060
- });
1061
- return;
1062
- }
1063
- const typeId = def ? def.typeId : this.newPartType.value.typeId;
1064
- const roleId = def ? def.roleId : this.newPartType.value.roleId;
1065
- if (this.partExists(typeId, roleId)) {
1066
- return;
1067
- }
1068
- const route = this._libraryRouteService.buildPartEditorRoute(this.id(), 'new', typeId, roleId);
1069
- this._router.navigate([route.route], route.rid ? { queryParams: { rid: route.rid } } : {});
1070
- }
1071
- editPart(part) {
1072
- const route = this._libraryRouteService.buildPartEditorRoute(part.itemId, part.id, part.typeId, part.roleId);
1073
- this._router.navigate([route.route], route.rid ? { queryParams: { rid: route.rid } } : {});
1074
- }
1075
- previewPart(part) {
1076
- if (part.roleId?.startsWith('fr.')) {
1077
- // layer parts redirect to base-text
1078
- this._itemService
1079
- .getBaseTextPart(part.itemId)
1080
- .pipe(take(1))
1081
- .subscribe((p) => {
1082
- this._router.navigate(['preview', part.itemId, p.part.id, 'text'], {
1083
- queryParams: { lid: part.roleId },
1084
- });
1085
- });
1086
- }
1087
- else if (part.roleId === 'base-text') {
1088
- this._router.navigate(['preview', part.itemId, part.id, 'text']);
1089
- }
1090
- else {
1091
- this._router.navigate(['preview', part.itemId, part.id]);
1092
- }
1093
- }
1094
- deletePart(part) {
1095
- if (this.busy()) {
1096
- return;
1097
- }
1098
- this._dialogService
1099
- .confirm('Confirm Deletion', `Delete part "${part.typeId}"?`)
1100
- .subscribe((result) => {
1101
- if (!result) {
1102
- return;
1103
- }
1104
- this.busy.set(true);
1105
- this._repository.deletePart(part.id).then((_) => {
1106
- this.busy.set(false);
1107
- }, (error) => {
1108
- this.busy.set(false);
1109
- console.error(error);
1110
- this._snackbar.open('Error deleting part', 'OK');
1111
- });
1112
- });
1113
- }
1114
- addLayerPart(part) {
1115
- if (this.busy()) {
1116
- return;
1117
- }
1118
- let name = this.getTypeIdName(part.typeId);
1119
- if (part.roleId) {
1120
- name += ' for ' + this.getRoleIdName(part.roleId);
1121
- }
1122
- this._dialogService
1123
- .confirm('Confirm Addition', `Add layer "${name}"?`)
1124
- .subscribe((result) => {
1125
- if (!result) {
1126
- return;
1127
- }
1128
- this.busy.set(true);
1129
- this._repository
1130
- .addNewLayerPart(part.typeId, part.roleId)
1131
- .finally(() => this.busy.set(false));
1132
- });
1133
- }
1134
- setPartsScope(request) {
1135
- this._repository.setPartThesaurusScope(request.ids, request.scope);
1136
- }
1137
- onCopyPart(part) {
1138
- if (this.busy()) {
1139
- return;
1140
- }
1141
- const dialogRef = this.dialog.open(ItemLookupDialogComponent, {
1142
- height: '180px',
1143
- width: '250px',
1144
- data: {},
1145
- });
1146
- dialogRef.afterClosed().subscribe((targetItem) => {
1147
- if (!targetItem || part.itemId === targetItem.id) {
1148
- return;
1149
- }
1150
- if (this.facetCtrl.value !== targetItem.facetId) {
1151
- this._snackbar.open('Cannot copy part to an item with a different facet', 'OK');
1152
- return;
1153
- }
1154
- this.busy.set(true);
1155
- this._itemService
1156
- .partWithTypeAndRoleExists(targetItem.id, part.typeId, part.roleId)
1157
- .subscribe((exists) => {
1158
- if (exists) {
1159
- this._snackbar.open('Part already exists in target item', 'OK');
1160
- this.busy.set(false);
1161
- return;
1162
- }
1163
- part.id = '';
1164
- part.itemId = targetItem.id;
1165
- this._itemService.addPart(part).subscribe({
1166
- next: (_) => {
1167
- this._snackbar.open('Part copied', 'OK', { duration: 3000 });
1168
- },
1169
- error: (error) => {
1170
- console.error(error);
1171
- this._snackbar.open('Error copying part', 'OK');
1172
- },
1173
- complete: () => {
1174
- this.busy.set(false);
1175
- },
1176
- });
1177
- });
1178
- });
1179
- }
1180
- onGenerateItems() {
1181
- if (this.busy()) {
1182
- return;
1183
- }
1184
- const dialogRef = this.dialog.open(ItemGenerateDialogComponent, {
1185
- height: '400px',
1186
- width: '350px',
1187
- data: {
1188
- flags: this.flagDefinitions(),
1189
- },
1190
- });
1191
- dialogRef
1192
- .afterClosed()
1193
- .subscribe((data) => {
1194
- if (!data) {
1195
- return;
1196
- }
1197
- this.busy.set(true);
1198
- this._itemService
1199
- .generateItems(data.count, this.id(), data.title, data.flags)
1200
- .subscribe({
1201
- next: (_) => {
1202
- this._messaging.sendMessage(MESSAGE_ITEM_LIST_REPOSITORY_RESET);
1203
- this._snackbar.open('Items generated', 'OK', { duration: 3000 });
1204
- },
1205
- error: (error) => {
1206
- console.error(error);
1207
- this._snackbar.open('Error generating items', 'OK');
1208
- },
1209
- complete: () => {
1210
- this.busy.set(false);
1211
- },
1212
- });
1213
- });
1214
- }
1215
- generateTitle() {
1216
- if (this.busy()) {
1217
- return;
1218
- }
1219
- this.busy.set(true);
1220
- this._itemService.getItemMetadata(this.id(), 'T').subscribe({
1221
- next: (title) => {
1222
- const result = title['T'];
1223
- if (result) {
1224
- this.title.setValue(result);
1225
- this.title.markAsDirty();
1226
- this.title.updateValueAndValidity();
1227
- }
1228
- else {
1229
- this._snackbar.open('No title generated', 'OK', { duration: 3000 });
1230
- }
1231
- },
1232
- error: (error) => {
1233
- console.error(error);
1234
- this._snackbar.open('Error generating title', 'OK');
1235
- },
1236
- complete: () => {
1237
- this.busy.set(false);
1238
- },
1239
- });
1240
- }
1241
- generateDescription() {
1242
- if (this.busy()) {
1243
- return;
1244
- }
1245
- this.busy.set(true);
1246
- this._itemService.getItemMetadata(this.id(), 'D').subscribe({
1247
- next: (description) => {
1248
- const result = description['D'];
1249
- if (result) {
1250
- this.description.setValue(result);
1251
- this.description.markAsDirty();
1252
- this.description.updateValueAndValidity();
1253
- }
1254
- else {
1255
- this._snackbar.open('No description generated', 'OK', {
1256
- duration: 3000,
1257
- });
1258
- }
1259
- },
1260
- error: (error) => {
1261
- console.error(error);
1262
- this._snackbar.open('Error generating description', 'OK');
1263
- },
1264
- complete: () => {
1265
- this.busy.set(false);
1266
- },
1267
- });
1268
- }
1269
- 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: i5.EnvService }, { token: i1$1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component });
1270
- 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 });
1271
- }
1272
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ItemEditorComponent, decorators: [{
1273
- type: Component,
1274
- args: [{ selector: 'cadmus-item-editor', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
1275
- MatCard,
1276
- MatCardContent,
1277
- MatTooltip,
1278
- CdkCopyToClipboard,
1279
- MatProgressBar,
1280
- MatTabGroup,
1281
- MatTab,
1282
- ReactiveFormsModule,
1283
- MatFormField,
1284
- MatLabel,
1285
- MatInput,
1286
- MatError,
1287
- MatSelect,
1288
- MatOption,
1289
- MatButton,
1290
- MatIcon,
1291
- MatDivider,
1292
- MatExpansionPanel,
1293
- MatExpansionPanelHeader,
1294
- MatExpansionPanelTitle,
1295
- MatExpansionPanelDescription,
1296
- MatIconButton,
1297
- MissingPartsComponent,
1298
- DatePipe,
1299
- HasPreviewPipe,
1300
- PartsScopeEditorComponent,
1301
- PartBadgeComponent,
1302
- CurrentItemBarComponent,
1303
- FlagSetComponent,
1304
- ], 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"] }]
1305
- }], 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: i5.EnvService }, { type: i1$1.FormBuilder }] });
1306
-
1307
- /*
1308
- * Public API Surface of cadmus-item-editor
1309
- */
1310
-
1311
- /**
1312
- * Generated bundle index. Do not edit.
1313
- */
1314
-
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
+ });
1315
2154
  export { CurrentItemBarComponent, CurrentLayerPartBarComponent, EditedItemRepository, ItemEditorComponent, ItemGenerateDialogComponent, ItemLookupDialogComponent };
1316
- //# sourceMappingURL=myrmidon-cadmus-item-editor.mjs.map
2155
+
2156
+ //# sourceMappingURL=myrmidon-cadmus-item-editor.mjs.map