@myrmidon/cadmus-item-editor 18.0.1 → 20.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { ChangeDetectionStrategy, Component, Inject, Injectable, Pipe, computed, effect, input, output, signal } from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, Inject, Injectable, Pipe, computed, effect, input, linkedSignal, output, signal, untracked } from "@angular/core";
|
|
3
3
|
import { BehaviorSubject, forkJoin } from "rxjs";
|
|
4
|
-
import * as i1$
|
|
5
|
-
import * as i2$
|
|
4
|
+
import * as i1$1 from "@myrmidon/cadmus-state";
|
|
5
|
+
import * as i2$2 from "@myrmidon/cadmus-api";
|
|
6
6
|
import { DatePipe } from "@angular/common";
|
|
7
7
|
import { toSignal } from "@angular/core/rxjs-interop";
|
|
8
8
|
import { MatTooltip } from "@angular/material/tooltip";
|
|
9
|
-
import
|
|
10
|
-
import { ReactiveFormsModule, Validators } from "@angular/forms";
|
|
9
|
+
import { FormField, FormRoot, disabled, form, max, maxLength, min, pattern, required, validate } from "@angular/forms/signals";
|
|
11
10
|
import { take } from "rxjs/operators";
|
|
12
11
|
import { MatCard, MatCardContent } from "@angular/material/card";
|
|
13
12
|
import { CdkCopyToClipboard } from "@angular/cdk/clipboard";
|
|
@@ -23,10 +22,10 @@ import { MatDivider } from "@angular/material/divider";
|
|
|
23
22
|
import { MatExpansionPanel, MatExpansionPanelDescription, MatExpansionPanelHeader, MatExpansionPanelTitle } from "@angular/material/expansion";
|
|
24
23
|
import { FlagSetComponent } from "@myrmidon/cadmus-ui-flag-set";
|
|
25
24
|
import { MESSAGE_ITEM_LIST_REPOSITORY_RESET } from "@myrmidon/cadmus-item-list";
|
|
26
|
-
import {
|
|
25
|
+
import { PartBadgeComponent, getPartIdName } from "@myrmidon/cadmus-ui";
|
|
27
26
|
import { MatCheckbox } from "@angular/material/checkbox";
|
|
28
|
-
import * as
|
|
29
|
-
import * as
|
|
27
|
+
import * as i2$1 from "@myrmidon/ngx-mat-tools";
|
|
28
|
+
import * as i4$1 from "@myrmidon/ngx-tools";
|
|
30
29
|
import * as i1 from "@angular/material/dialog";
|
|
31
30
|
import { MAT_DIALOG_DATA } from "@angular/material/dialog";
|
|
32
31
|
import { RefLookupComponent } from "@myrmidon/cadmus-refs-lookup";
|
|
@@ -269,7 +268,7 @@ var EditedItemRepository = class EditedItemRepository {
|
|
|
269
268
|
version: "22.2.0",
|
|
270
269
|
ngImport: i0,
|
|
271
270
|
type: EditedItemRepository,
|
|
272
|
-
deps: [{ token: i1$
|
|
271
|
+
deps: [{ token: i1$1.AppRepository }, { token: i2$2.ItemService }],
|
|
273
272
|
target: i0.ɵɵFactoryTarget.Injectable
|
|
274
273
|
});
|
|
275
274
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
@@ -289,7 +288,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
289
288
|
type: Injectable,
|
|
290
289
|
args: [{ providedIn: "root" }]
|
|
291
290
|
}],
|
|
292
|
-
ctorParameters: () => [{ type: i1$
|
|
291
|
+
ctorParameters: () => [{ type: i1$1.AppRepository }, { type: i2$2.ItemService }]
|
|
293
292
|
});
|
|
294
293
|
var CurrentItemBarComponent = class CurrentItemBarComponent {
|
|
295
294
|
item;
|
|
@@ -407,10 +406,10 @@ var CurrentLayerPartBarComponent = class CurrentLayerPartBarComponent {
|
|
|
407
406
|
ngImport: i0,
|
|
408
407
|
type: CurrentLayerPartBarComponent,
|
|
409
408
|
deps: [
|
|
410
|
-
{ token: i1$
|
|
409
|
+
{ token: i1$1.AppRepository },
|
|
411
410
|
{ token: EditedItemRepository },
|
|
412
|
-
{ token: i1$
|
|
413
|
-
{ token: i2$
|
|
411
|
+
{ token: i1$1.EditedLayerRepository },
|
|
412
|
+
{ token: i2$2.FacetService }
|
|
414
413
|
],
|
|
415
414
|
target: i0.ɵɵFactoryTarget.Component
|
|
416
415
|
});
|
|
@@ -441,14 +440,13 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
441
440
|
}]
|
|
442
441
|
}],
|
|
443
442
|
ctorParameters: () => [
|
|
444
|
-
{ type: i1$
|
|
443
|
+
{ type: i1$1.AppRepository },
|
|
445
444
|
{ type: EditedItemRepository },
|
|
446
|
-
{ type: i1$
|
|
447
|
-
{ type: i2$
|
|
445
|
+
{ type: i1$1.EditedLayerRepository },
|
|
446
|
+
{ type: i2$2.FacetService }
|
|
448
447
|
]
|
|
449
448
|
});
|
|
450
449
|
var PartsScopeEditorComponent = class PartsScopeEditorComponent {
|
|
451
|
-
_formBuilder;
|
|
452
450
|
_facetService;
|
|
453
451
|
_dialogService;
|
|
454
452
|
_appRepository;
|
|
@@ -457,35 +455,26 @@ var PartsScopeEditorComponent = class PartsScopeEditorComponent {
|
|
|
457
455
|
parts = input(...ngDevMode ? [void 0, { debugName: "parts" }] : /* istanbul ignore next */ []);
|
|
458
456
|
readonly = input(...ngDevMode ? [void 0, { debugName: "readonly" }] : /* istanbul ignore next */ []);
|
|
459
457
|
setScopeRequest = output();
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
458
|
+
_draft = linkedSignal({
|
|
459
|
+
...ngDevMode ? { debugName: "_draft" } : /* istanbul ignore next */ {},
|
|
460
|
+
source: () => this.parts(),
|
|
461
|
+
computation: (parts, previous) => ({
|
|
462
|
+
checks: (parts || []).map(() => false),
|
|
463
|
+
scope: previous?.value.scope ?? ""
|
|
464
|
+
})
|
|
465
|
+
});
|
|
466
|
+
form = form(this._draft, (path) => {
|
|
467
|
+
validate(path.checks, ({ value }) => value().some((c) => c) ? null : { kind: "minChecked" });
|
|
468
|
+
maxLength(path.scope, 50);
|
|
469
|
+
pattern(path.scope, /^[-a-zA-Z0-9_]+$/);
|
|
470
|
+
});
|
|
471
|
+
constructor(_facetService, _dialogService, _appRepository, _colorService, _editedItemRepository) {
|
|
465
472
|
this._facetService = _facetService;
|
|
466
473
|
this._dialogService = _dialogService;
|
|
467
474
|
this._appRepository = _appRepository;
|
|
468
475
|
this._colorService = _colorService;
|
|
469
476
|
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
477
|
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
478
|
}
|
|
490
479
|
getPartColor(typeId, roleId) {
|
|
491
480
|
const facet = this._editedItemRepository.getFacet();
|
|
@@ -508,17 +497,16 @@ var PartsScopeEditorComponent = class PartsScopeEditorComponent {
|
|
|
508
497
|
return this.getTypeIdName(roleId);
|
|
509
498
|
}
|
|
510
499
|
submit() {
|
|
511
|
-
if (this.form.invalid || !this.parts()?.length) return;
|
|
512
|
-
const
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
let msg = this.scope.value ? `Assign scope "${this.scope.value}" to ${ids.length} part` : `Remove scope from ${ids.length} part`;
|
|
500
|
+
if (this.form().invalid() || !this.parts()?.length) return;
|
|
501
|
+
const { checks, scope } = this._draft();
|
|
502
|
+
const ids = this.parts().filter((_, i) => checks[i]).map((p) => p.id);
|
|
503
|
+
let msg = scope ? `Assign scope "${scope}" to ${ids.length} part` : `Remove scope from ${ids.length} part`;
|
|
516
504
|
msg += ids.length > 1 ? "s?" : "?";
|
|
517
505
|
this._dialogService.confirm("Confirm Scopes", msg).subscribe((result) => {
|
|
518
506
|
if (!result) return;
|
|
519
507
|
this.setScopeRequest.emit({
|
|
520
508
|
ids,
|
|
521
|
-
scope:
|
|
509
|
+
scope: scope || null
|
|
522
510
|
});
|
|
523
511
|
});
|
|
524
512
|
}
|
|
@@ -528,11 +516,10 @@ var PartsScopeEditorComponent = class PartsScopeEditorComponent {
|
|
|
528
516
|
ngImport: i0,
|
|
529
517
|
type: PartsScopeEditorComponent,
|
|
530
518
|
deps: [
|
|
531
|
-
{ token:
|
|
532
|
-
{ token: i2$1.
|
|
533
|
-
{ token:
|
|
534
|
-
{ token:
|
|
535
|
-
{ token: i5.ColorService },
|
|
519
|
+
{ token: i2$2.FacetService },
|
|
520
|
+
{ token: i2$1.DialogService },
|
|
521
|
+
{ token: i1$1.AppRepository },
|
|
522
|
+
{ token: i4$1.ColorService },
|
|
536
523
|
{ token: EditedItemRepository }
|
|
537
524
|
],
|
|
538
525
|
target: i0.ɵɵFactoryTarget.Component
|
|
@@ -561,57 +548,15 @@ var PartsScopeEditorComponent = class PartsScopeEditorComponent {
|
|
|
561
548
|
},
|
|
562
549
|
outputs: { setScopeRequest: "setScopeRequest" },
|
|
563
550
|
ngImport: i0,
|
|
564
|
-
template: "<
|
|
551
|
+
template: "<div>\r\n <table id=\"parts\">\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 [formField]=\"form.checks[i]\" />\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\r\n matInput\r\n [formField]=\"form.scope\"\r\n (keydown.enter)=\"!readonly() && submit()\"\r\n />\r\n @if (\r\n form.scope().getError(\"maxLength\") &&\r\n (form.scope().dirty() || form.scope().touched())\r\n ) {\r\n <mat-error>too long</mat-error>\r\n }\r\n @if (\r\n form.scope().getError(\"pattern\") &&\r\n (form.scope().dirty() || form.scope().touched())\r\n ) {\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=\"button\"\r\n [disabled]=\"form().invalid() || readonly()\"\r\n (click)=\"submit()\"\r\n matTooltip=\"Assign the scope to the checked parts\"\r\n >\r\n assign\r\n </button>\r\n </div>\r\n</div>\r\n",
|
|
565
552
|
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
553
|
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
554
|
{
|
|
582
555
|
kind: "directive",
|
|
583
|
-
type:
|
|
584
|
-
selector: "[
|
|
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"]
|
|
556
|
+
type: FormField,
|
|
557
|
+
selector: "[formField]",
|
|
558
|
+
inputs: ["formField"],
|
|
559
|
+
exportAs: ["formField"]
|
|
615
560
|
},
|
|
616
561
|
{
|
|
617
562
|
kind: "component",
|
|
@@ -727,7 +672,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
727
672
|
selector: "cadmus-parts-scope-editor",
|
|
728
673
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
729
674
|
imports: [
|
|
730
|
-
|
|
675
|
+
FormField,
|
|
731
676
|
MatCheckbox,
|
|
732
677
|
MatFormField,
|
|
733
678
|
MatLabel,
|
|
@@ -737,16 +682,15 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
737
682
|
MatTooltip,
|
|
738
683
|
DatePipe
|
|
739
684
|
],
|
|
740
|
-
template: "<
|
|
685
|
+
template: "<div>\r\n <table id=\"parts\">\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 [formField]=\"form.checks[i]\" />\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\r\n matInput\r\n [formField]=\"form.scope\"\r\n (keydown.enter)=\"!readonly() && submit()\"\r\n />\r\n @if (\r\n form.scope().getError(\"maxLength\") &&\r\n (form.scope().dirty() || form.scope().touched())\r\n ) {\r\n <mat-error>too long</mat-error>\r\n }\r\n @if (\r\n form.scope().getError(\"pattern\") &&\r\n (form.scope().dirty() || form.scope().touched())\r\n ) {\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=\"button\"\r\n [disabled]=\"form().invalid() || readonly()\"\r\n (click)=\"submit()\"\r\n matTooltip=\"Assign the scope to the checked parts\"\r\n >\r\n assign\r\n </button>\r\n </div>\r\n</div>\r\n",
|
|
741
686
|
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
687
|
}]
|
|
743
688
|
}],
|
|
744
689
|
ctorParameters: () => [
|
|
745
|
-
{ type:
|
|
746
|
-
{ type: i2$1.
|
|
747
|
-
{ type:
|
|
748
|
-
{ type:
|
|
749
|
-
{ type: i5.ColorService },
|
|
690
|
+
{ type: i2$2.FacetService },
|
|
691
|
+
{ type: i2$1.DialogService },
|
|
692
|
+
{ type: i1$1.AppRepository },
|
|
693
|
+
{ type: i4$1.ColorService },
|
|
750
694
|
{ type: EditedItemRepository }
|
|
751
695
|
],
|
|
752
696
|
propDecorators: {
|
|
@@ -866,39 +810,32 @@ var ItemGenerateDialogComponent = class ItemGenerateDialogComponent {
|
|
|
866
810
|
dialogRef;
|
|
867
811
|
config;
|
|
868
812
|
flags = signal([], ...ngDevMode ? [{ debugName: "flags" }] : /* istanbul ignore next */ []);
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
813
|
+
_draft = signal({
|
|
814
|
+
itemCount: 1,
|
|
815
|
+
itemTitle: "",
|
|
816
|
+
itemFlags: []
|
|
817
|
+
}, ...ngDevMode ? [{ debugName: "_draft" }] : /* istanbul ignore next */ []);
|
|
818
|
+
form = form(this._draft, (path) => {
|
|
819
|
+
required(path.itemCount);
|
|
820
|
+
min(path.itemCount, 1);
|
|
821
|
+
max(path.itemCount, 100);
|
|
822
|
+
required(path.itemTitle);
|
|
823
|
+
maxLength(path.itemTitle, 500);
|
|
824
|
+
}, { submission: { action: async () => {
|
|
825
|
+
this.apply();
|
|
826
|
+
} } });
|
|
827
|
+
constructor(dialogRef, config) {
|
|
874
828
|
this.dialogRef = dialogRef;
|
|
875
829
|
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
830
|
this.flags.set(config?.flags || []);
|
|
895
831
|
}
|
|
896
832
|
apply() {
|
|
897
|
-
if (!this.form.valid) return;
|
|
898
|
-
const
|
|
833
|
+
if (!this.form().valid()) return;
|
|
834
|
+
const v = this._draft();
|
|
835
|
+
const flags = v.itemFlags.reduce((acc, id) => acc | id, 0);
|
|
899
836
|
this.dialogRef.close({
|
|
900
|
-
count:
|
|
901
|
-
title:
|
|
837
|
+
count: v.itemCount,
|
|
838
|
+
title: v.itemTitle,
|
|
902
839
|
flags
|
|
903
840
|
});
|
|
904
841
|
}
|
|
@@ -907,11 +844,7 @@ var ItemGenerateDialogComponent = class ItemGenerateDialogComponent {
|
|
|
907
844
|
version: "22.2.0",
|
|
908
845
|
ngImport: i0,
|
|
909
846
|
type: ItemGenerateDialogComponent,
|
|
910
|
-
deps: [
|
|
911
|
-
{ token: i1$1.FormBuilder },
|
|
912
|
-
{ token: i1.MatDialogRef },
|
|
913
|
-
{ token: MAT_DIALOG_DATA }
|
|
914
|
-
],
|
|
847
|
+
deps: [{ token: i1.MatDialogRef }, { token: MAT_DIALOG_DATA }],
|
|
915
848
|
target: i0.ɵɵFactoryTarget.Component
|
|
916
849
|
});
|
|
917
850
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
@@ -921,63 +854,21 @@ var ItemGenerateDialogComponent = class ItemGenerateDialogComponent {
|
|
|
921
854
|
isStandalone: true,
|
|
922
855
|
selector: "cadmus-item-generate-dialog",
|
|
923
856
|
ngImport: i0,
|
|
924
|
-
template: "<div id=\"container\">\n <h3>Generate Items</h3>\n <form [
|
|
857
|
+
template: "<div id=\"container\">\r\n <h3>Generate Items</h3>\r\n <form [formRoot]=\"form\">\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\" [formField]=\"form.itemCount\" />\r\n <mat-hint>number of items to generate</mat-hint>\r\n @if (\r\n form.itemCount().getError('required') && (form.itemCount().dirty() || form.itemCount().touched())\r\n ) {\r\n <mat-error>count required</mat-error>\r\n }\r\n @if (\r\n form.itemCount().getError('min') && (form.itemCount().dirty() || form.itemCount().touched())\r\n ) {\r\n <mat-error>count too low</mat-error>\r\n }\r\n @if (\r\n form.itemCount().getError('max') && (form.itemCount().dirty() || form.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 [formField]=\"form.itemTitle\" />\r\n <mat-hint>title template ({{ \"{0}\" }}=N)</mat-hint>\r\n @if (\r\n form.itemTitle().getError('required') &&\r\n (form.itemTitle().dirty() || form.itemTitle().touched())\r\n ) {\r\n <mat-error>title required</mat-error>\r\n }\r\n @if (\r\n form.itemTitle().getError('maxLength') &&\r\n (form.itemTitle().dirty() || form.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 [formField]=\"form.itemFlags\" multiple>\r\n @for (flag of flags(); track flag.id) {\r\n <mat-option [value]=\"flag.id\">\r\n <span class=\"flag-bullet\" [style.color]=\"'#' + flag.colorKey\"\r\n >⬤</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",
|
|
925
858
|
styles: ["#container{padding:16px}.flag-bullet{margin-right:.5em}.input-nr{width:5em}\n"],
|
|
926
859
|
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
860
|
{
|
|
952
861
|
kind: "directive",
|
|
953
|
-
type:
|
|
954
|
-
selector: "[
|
|
862
|
+
type: FormField,
|
|
863
|
+
selector: "[formField]",
|
|
864
|
+
inputs: ["formField"],
|
|
865
|
+
exportAs: ["formField"]
|
|
955
866
|
},
|
|
956
867
|
{
|
|
957
868
|
kind: "directive",
|
|
958
|
-
type:
|
|
959
|
-
selector: "
|
|
960
|
-
inputs: ["
|
|
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"]
|
|
869
|
+
type: FormRoot,
|
|
870
|
+
selector: "form[formRoot]",
|
|
871
|
+
inputs: ["formRoot"]
|
|
981
872
|
},
|
|
982
873
|
{
|
|
983
874
|
kind: "component",
|
|
@@ -1098,7 +989,8 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1098
989
|
selector: "cadmus-item-generate-dialog",
|
|
1099
990
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1100
991
|
imports: [
|
|
1101
|
-
|
|
992
|
+
FormField,
|
|
993
|
+
FormRoot,
|
|
1102
994
|
MatFormField,
|
|
1103
995
|
MatLabel,
|
|
1104
996
|
MatInput,
|
|
@@ -1108,21 +1000,17 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1108
1000
|
MatOption,
|
|
1109
1001
|
MatButton
|
|
1110
1002
|
],
|
|
1111
|
-
template: "<div id=\"container\">\n <h3>Generate Items</h3>\n <form [
|
|
1003
|
+
template: "<div id=\"container\">\r\n <h3>Generate Items</h3>\r\n <form [formRoot]=\"form\">\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\" [formField]=\"form.itemCount\" />\r\n <mat-hint>number of items to generate</mat-hint>\r\n @if (\r\n form.itemCount().getError('required') && (form.itemCount().dirty() || form.itemCount().touched())\r\n ) {\r\n <mat-error>count required</mat-error>\r\n }\r\n @if (\r\n form.itemCount().getError('min') && (form.itemCount().dirty() || form.itemCount().touched())\r\n ) {\r\n <mat-error>count too low</mat-error>\r\n }\r\n @if (\r\n form.itemCount().getError('max') && (form.itemCount().dirty() || form.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 [formField]=\"form.itemTitle\" />\r\n <mat-hint>title template ({{ \"{0}\" }}=N)</mat-hint>\r\n @if (\r\n form.itemTitle().getError('required') &&\r\n (form.itemTitle().dirty() || form.itemTitle().touched())\r\n ) {\r\n <mat-error>title required</mat-error>\r\n }\r\n @if (\r\n form.itemTitle().getError('maxLength') &&\r\n (form.itemTitle().dirty() || form.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 [formField]=\"form.itemFlags\" multiple>\r\n @for (flag of flags(); track flag.id) {\r\n <mat-option [value]=\"flag.id\">\r\n <span class=\"flag-bullet\" [style.color]=\"'#' + flag.colorKey\"\r\n >⬤</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",
|
|
1112
1004
|
styles: ["#container{padding:16px}.flag-bullet{margin-right:.5em}.input-nr{width:5em}\n"]
|
|
1113
1005
|
}]
|
|
1114
1006
|
}],
|
|
1115
|
-
ctorParameters: () => [
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
args: [MAT_DIALOG_DATA]
|
|
1123
|
-
}]
|
|
1124
|
-
}
|
|
1125
|
-
]
|
|
1007
|
+
ctorParameters: () => [{ type: i1.MatDialogRef }, {
|
|
1008
|
+
type: i1.MatDialogConfig,
|
|
1009
|
+
decorators: [{
|
|
1010
|
+
type: Inject,
|
|
1011
|
+
args: [MAT_DIALOG_DATA]
|
|
1012
|
+
}]
|
|
1013
|
+
}]
|
|
1126
1014
|
});
|
|
1127
1015
|
var MissingPartsComponent = class MissingPartsComponent {
|
|
1128
1016
|
facetDefinition = input(...ngDevMode ? [void 0, { debugName: "facetDefinition" }] : /* istanbul ignore next */ []);
|
|
@@ -1345,6 +1233,36 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1345
1233
|
args: [{ name: "hasPreview" }]
|
|
1346
1234
|
}]
|
|
1347
1235
|
});
|
|
1236
|
+
function toMetadataDraft(item) {
|
|
1237
|
+
return {
|
|
1238
|
+
title: item?.title || "",
|
|
1239
|
+
sortKey: item?.sortKey || "",
|
|
1240
|
+
description: item?.description || "",
|
|
1241
|
+
facet: item?.facetId ?? null,
|
|
1242
|
+
group: item?.groupId ?? "",
|
|
1243
|
+
flags: item?.flags ?? 0
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
function toMetadata(v) {
|
|
1247
|
+
return {
|
|
1248
|
+
title: v.title.trim(),
|
|
1249
|
+
sortKey: v.sortKey.trim(),
|
|
1250
|
+
description: v.description.trim(),
|
|
1251
|
+
facetId: v.facet?.trim() || "",
|
|
1252
|
+
groupId: v.group.trim(),
|
|
1253
|
+
flags: v.flags
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
function metadataOf(item) {
|
|
1257
|
+
return item ? {
|
|
1258
|
+
title: item.title,
|
|
1259
|
+
sortKey: item.sortKey,
|
|
1260
|
+
description: item.description,
|
|
1261
|
+
facetId: item.facetId,
|
|
1262
|
+
groupId: item.groupId,
|
|
1263
|
+
flags: item.flags
|
|
1264
|
+
} : void 0;
|
|
1265
|
+
}
|
|
1348
1266
|
var ItemEditorComponent = class ItemEditorComponent {
|
|
1349
1267
|
itemLookupService;
|
|
1350
1268
|
dialog;
|
|
@@ -1381,16 +1299,12 @@ var ItemEditorComponent = class ItemEditorComponent {
|
|
|
1381
1299
|
flagSetFlags;
|
|
1382
1300
|
adminFlagDefs;
|
|
1383
1301
|
checkedFlagIds;
|
|
1384
|
-
newPartType
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
description;
|
|
1389
|
-
facetCtrl;
|
|
1390
|
-
group;
|
|
1391
|
-
flags;
|
|
1302
|
+
newPart = form(signal({ newPartType: null }), (path) => {
|
|
1303
|
+
required(path.newPartType);
|
|
1304
|
+
});
|
|
1305
|
+
_metadata;
|
|
1392
1306
|
metadata;
|
|
1393
|
-
constructor(itemLookupService, dialog, _router, _route, _snackbar, _appRepository, _repository, _itemService, _libraryRouteService, _dialogService, _authService, _userLevelService, _messaging, _envService
|
|
1307
|
+
constructor(itemLookupService, dialog, _router, _route, _snackbar, _appRepository, _repository, _itemService, _libraryRouteService, _dialogService, _authService, _userLevelService, _messaging, _envService) {
|
|
1394
1308
|
this.itemLookupService = itemLookupService;
|
|
1395
1309
|
this.dialog = dialog;
|
|
1396
1310
|
this._router = _router;
|
|
@@ -1408,23 +1322,6 @@ var ItemEditorComponent = class ItemEditorComponent {
|
|
|
1408
1322
|
this.id.set(this._route.snapshot.params["id"]);
|
|
1409
1323
|
if (this.id() === "new") this.id.set(void 0);
|
|
1410
1324
|
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
1325
|
this.item = toSignal(this._repository.item$);
|
|
1429
1326
|
this.parts = toSignal(this._repository.parts$, { requireSync: true });
|
|
1430
1327
|
this.partGroups = toSignal(this._repository.partGroups$, { requireSync: true });
|
|
@@ -1442,7 +1339,31 @@ var ItemEditorComponent = class ItemEditorComponent {
|
|
|
1442
1339
|
this._currentUser();
|
|
1443
1340
|
return this._userLevelService.getCurrentUserLevel();
|
|
1444
1341
|
}, ...ngDevMode ? [{ debugName: "userLevel" }] : /* istanbul ignore next */ []);
|
|
1445
|
-
this.
|
|
1342
|
+
this._metadata = linkedSignal({
|
|
1343
|
+
...ngDevMode ? { debugName: "_metadata" } : /* istanbul ignore next */ {},
|
|
1344
|
+
source: this.item,
|
|
1345
|
+
computation: (item, previous) => previous && (item?.id === previous.source?.id && JSON.stringify(metadataOf(item)) === JSON.stringify(metadataOf(previous.source)) || JSON.stringify(metadataOf(item)) === JSON.stringify(toMetadata(previous.value))) ? previous.value : toMetadataDraft(item)
|
|
1346
|
+
});
|
|
1347
|
+
this.metadata = form(this._metadata, (path) => {
|
|
1348
|
+
required(path.title);
|
|
1349
|
+
maxLength(path.title, 500);
|
|
1350
|
+
disabled(path.sortKey);
|
|
1351
|
+
required(path.sortKey);
|
|
1352
|
+
maxLength(path.sortKey, 500);
|
|
1353
|
+
required(path.description);
|
|
1354
|
+
maxLength(path.description, 1e3);
|
|
1355
|
+
required(path.facet);
|
|
1356
|
+
maxLength(path.group, 100);
|
|
1357
|
+
}, { submission: { action: async () => {
|
|
1358
|
+
this.save();
|
|
1359
|
+
} } });
|
|
1360
|
+
effect(() => {
|
|
1361
|
+
const draft = this._metadata();
|
|
1362
|
+
untracked(() => {
|
|
1363
|
+
if (JSON.stringify(draft) === JSON.stringify(toMetadataDraft(this.item()))) this.metadata().reset();
|
|
1364
|
+
});
|
|
1365
|
+
});
|
|
1366
|
+
this._flagsValue = computed(() => this.metadata.flags().value(), ...ngDevMode ? [{ debugName: "_flagsValue" }] : /* istanbul ignore next */ []);
|
|
1446
1367
|
this.flagSetFlags = computed(() => this.flagDefinitions().filter((def) => this.userLevel() >= 4 || !def.isAdmin).map((def) => ({
|
|
1447
1368
|
id: String(def.id),
|
|
1448
1369
|
label: def.label,
|
|
@@ -1456,37 +1377,22 @@ var ItemEditorComponent = class ItemEditorComponent {
|
|
|
1456
1377
|
const value = this._flagsValue();
|
|
1457
1378
|
return this.flagDefinitions().filter((def) => (value & def.id) !== 0).map((def) => String(def.id));
|
|
1458
1379
|
}, ...ngDevMode ? [{ debugName: "checkedFlagIds" }] : /* istanbul ignore next */ []);
|
|
1459
|
-
effect(() => {
|
|
1460
|
-
this.updateMetadataForm(this.item());
|
|
1461
|
-
});
|
|
1462
1380
|
}
|
|
1463
1381
|
ngOnInit() {
|
|
1464
1382
|
this._repository.load(this.id());
|
|
1465
1383
|
}
|
|
1466
1384
|
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
|
-
}
|
|
1385
|
+
return !this.metadata().dirty();
|
|
1480
1386
|
}
|
|
1481
1387
|
onFlagCheckedIdsChange(ids) {
|
|
1482
1388
|
let value = 0;
|
|
1483
1389
|
if (this.userLevel() < 4) {
|
|
1484
|
-
const current = this.flags.value;
|
|
1390
|
+
const current = this.metadata.flags().value();
|
|
1485
1391
|
for (const def of this.flagDefinitions()) if (def.isAdmin && (current & def.id) !== 0) value |= def.id;
|
|
1486
1392
|
}
|
|
1487
1393
|
for (const id of ids) value |= Number(id);
|
|
1488
|
-
this.flags.
|
|
1489
|
-
this.flags.markAsDirty();
|
|
1394
|
+
this.metadata.flags().value.set(value);
|
|
1395
|
+
this.metadata.flags().markAsDirty();
|
|
1490
1396
|
}
|
|
1491
1397
|
getTypeIdName(typeId) {
|
|
1492
1398
|
const typeThesaurus = this._appRepository.getTypeThesaurus();
|
|
@@ -1501,20 +1407,17 @@ var ItemEditorComponent = class ItemEditorComponent {
|
|
|
1501
1407
|
return this.getTypeIdName(roleId);
|
|
1502
1408
|
}
|
|
1503
1409
|
save() {
|
|
1504
|
-
if (this.busy() || !this.metadata.valid) return;
|
|
1410
|
+
if (this.busy() || !this.metadata().valid()) return;
|
|
1505
1411
|
const currentItem = this._repository.getItem();
|
|
1506
1412
|
if (!currentItem) return;
|
|
1507
|
-
const item = {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
item.facetId = this.facetCtrl.value?.trim() || "";
|
|
1512
|
-
item.groupId = this.group.value?.trim() || "";
|
|
1513
|
-
item.flags = this.flags.value;
|
|
1413
|
+
const item = {
|
|
1414
|
+
...currentItem,
|
|
1415
|
+
...toMetadata(this._metadata())
|
|
1416
|
+
};
|
|
1514
1417
|
this.busy.set(true);
|
|
1515
1418
|
this._repository.save(item).then((saved) => {
|
|
1516
1419
|
this._messaging.sendMessage(MESSAGE_ITEM_LIST_REPOSITORY_RESET);
|
|
1517
|
-
this.metadata.
|
|
1420
|
+
this.metadata().reset();
|
|
1518
1421
|
if (!item.id) {
|
|
1519
1422
|
this.id.set(saved.id);
|
|
1520
1423
|
this._router.navigate(["/items", saved.id]);
|
|
@@ -1534,13 +1437,13 @@ var ItemEditorComponent = class ItemEditorComponent {
|
|
|
1534
1437
|
return getPartIdName(typeId, roleId, this._appRepository.getTypeThesaurus());
|
|
1535
1438
|
}
|
|
1536
1439
|
addPart(def) {
|
|
1537
|
-
if (!def && !this.
|
|
1440
|
+
if (!def && !this.newPart().valid()) return;
|
|
1538
1441
|
if (!this.id()) {
|
|
1539
1442
|
this._snackbar.open("Please save the item before adding parts", "OK", { duration: 3e3 });
|
|
1540
1443
|
return;
|
|
1541
1444
|
}
|
|
1542
|
-
const typeId = def ? def.typeId : this.newPartType.value.typeId;
|
|
1543
|
-
const roleId = def ? def.roleId : this.newPartType.value.roleId;
|
|
1445
|
+
const typeId = def ? def.typeId : this.newPart.newPartType().value().typeId;
|
|
1446
|
+
const roleId = def ? def.roleId : this.newPart.newPartType().value().roleId;
|
|
1544
1447
|
if (this.partExists(typeId, roleId)) return;
|
|
1545
1448
|
const route = this._libraryRouteService.buildPartEditorRoute(this.id(), "new", typeId, roleId);
|
|
1546
1449
|
this._router.navigate([route.route], route.rid ? { queryParams: { rid: route.rid } } : {});
|
|
@@ -1605,7 +1508,7 @@ var ItemEditorComponent = class ItemEditorComponent {
|
|
|
1605
1508
|
data: {}
|
|
1606
1509
|
}).afterClosed().subscribe((targetItem) => {
|
|
1607
1510
|
if (!targetItem || part.itemId === targetItem.id) return;
|
|
1608
|
-
if (this.
|
|
1511
|
+
if (this.metadata.facet().value() !== targetItem.facetId) {
|
|
1609
1512
|
this._snackbar.open("Cannot copy part to an item with a different facet", "OK");
|
|
1610
1513
|
return;
|
|
1611
1514
|
}
|
|
@@ -1664,9 +1567,8 @@ var ItemEditorComponent = class ItemEditorComponent {
|
|
|
1664
1567
|
next: (title) => {
|
|
1665
1568
|
const result = title["T"];
|
|
1666
1569
|
if (result) {
|
|
1667
|
-
this.title.
|
|
1668
|
-
this.title.markAsDirty();
|
|
1669
|
-
this.title.updateValueAndValidity();
|
|
1570
|
+
this.metadata.title().value.set(result);
|
|
1571
|
+
this.metadata.title().markAsDirty();
|
|
1670
1572
|
} else this._snackbar.open("No title generated", "OK", { duration: 3e3 });
|
|
1671
1573
|
},
|
|
1672
1574
|
error: (error) => {
|
|
@@ -1685,9 +1587,8 @@ var ItemEditorComponent = class ItemEditorComponent {
|
|
|
1685
1587
|
next: (description) => {
|
|
1686
1588
|
const result = description["D"];
|
|
1687
1589
|
if (result) {
|
|
1688
|
-
this.description.
|
|
1689
|
-
this.description.markAsDirty();
|
|
1690
|
-
this.description.updateValueAndValidity();
|
|
1590
|
+
this.metadata.description().value.set(result);
|
|
1591
|
+
this.metadata.description().markAsDirty();
|
|
1691
1592
|
} else this._snackbar.open("No description generated", "OK", { duration: 3e3 });
|
|
1692
1593
|
},
|
|
1693
1594
|
error: (error) => {
|
|
@@ -1710,16 +1611,15 @@ var ItemEditorComponent = class ItemEditorComponent {
|
|
|
1710
1611
|
{ token: i3.Router },
|
|
1711
1612
|
{ token: i3.ActivatedRoute },
|
|
1712
1613
|
{ token: i4.MatSnackBar },
|
|
1713
|
-
{ token: i1$
|
|
1614
|
+
{ token: i1$1.AppRepository },
|
|
1714
1615
|
{ token: EditedItemRepository },
|
|
1715
|
-
{ token: i2$
|
|
1616
|
+
{ token: i2$2.ItemService },
|
|
1716
1617
|
{ token: i8.LibraryRouteService },
|
|
1717
|
-
{ token:
|
|
1618
|
+
{ token: i2$1.DialogService },
|
|
1718
1619
|
{ token: i10.AuthJwtService },
|
|
1719
|
-
{ token: i2$
|
|
1720
|
-
{ token: i2$
|
|
1721
|
-
{ token:
|
|
1722
|
-
{ token: i1$1.FormBuilder }
|
|
1620
|
+
{ token: i2$2.UserLevelService },
|
|
1621
|
+
{ token: i2$2.MessagingService },
|
|
1622
|
+
{ token: i4$1.EnvService }
|
|
1723
1623
|
],
|
|
1724
1624
|
target: i0.ɵɵFactoryTarget.Component
|
|
1725
1625
|
});
|
|
@@ -1730,7 +1630,7 @@ var ItemEditorComponent = class ItemEditorComponent {
|
|
|
1730
1630
|
isStandalone: true,
|
|
1731
1631
|
selector: "cadmus-item-editor",
|
|
1732
1632
|
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\">◆</span>\r\n {{ 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 >⬤</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",
|
|
1633
|
+
template: "<mat-card appearance=\"outlined\">\n <mat-card-content>\n <div>\n <cadmus-current-item-bar />\n </div>\n @if (busy()) {\n <mat-progress-bar mode=\"indeterminate\" />\n }\n\n <!-- item content -->\n <mat-tab-group [selectedIndex]=\"id() ? 1 : 0\">\n <!-- metadata -->\n <mat-tab label=\"Metadata\">\n <form [formRoot]=\"metadata\">\n <div class=\"form-row\">\n <!-- title -->\n <mat-form-field class=\"flex-field\">\n <mat-label>title</mat-label>\n <input matInput type=\"text\" id=\"title\" [formField]=\"metadata.title\" />\n @if (\n metadata.title().getError(\"required\") && (metadata.title().touched() || metadata.title().dirty())\n ) {\n <mat-error>enter title</mat-error>\n }\n @if (\n metadata.title().getError(\"maxLength\") && (metadata.title().touched() || metadata.title().dirty())\n ) {\n <mat-error>title too long</mat-error>\n }\n </mat-form-field>\n\n @if (hasMetadataBuilders()) {\n <!-- auto title -->\n <button\n type=\"button\"\n mat-icon-button\n [disabled]=\"busy()\"\n (click)=\"generateTitle()\"\n >\n <mat-icon matTooltip=\"Generate title\">auto_awesome</mat-icon>\n </button>\n }\n\n <!-- sortKey -->\n <mat-form-field class=\"flex-field\">\n <mat-label>sort key</mat-label>\n <input\n matInput\n type=\"text\"\n id=\"sortKey\"\n [formField]=\"metadata.sortKey\"\n />\n @if (\n metadata.sortKey().getError(\"required\") &&\n (metadata.sortKey().touched() || metadata.sortKey().dirty())\n ) {\n <mat-error>enter sort key</mat-error>\n }\n @if (\n metadata.sortKey().getError(\"maxLength\") &&\n (metadata.sortKey().touched() || metadata.sortKey().dirty())\n ) {\n <mat-error>sort key too long</mat-error>\n }\n </mat-form-field>\n </div>\n\n <!-- description -->\n <div class=\"flex-row\">\n <mat-form-field class=\"item\">\n <mat-label>description</mat-label>\n <textarea\n rows=\"2\"\n matInput\n id=\"description\"\n [formField]=\"metadata.description\"\n ></textarea>\n @if (\n metadata.description().getError(\"required\") &&\n (metadata.description().touched() || metadata.description().dirty())\n ) {\n <mat-error>enter description</mat-error>\n }\n @if (\n metadata.description().getError(\"maxLength\") &&\n (metadata.description().touched() || metadata.description().dirty())\n ) {\n <mat-error>description too long</mat-error>\n }\n </mat-form-field>\n\n @if (hasMetadataBuilders()) {\n <!-- auto description -->\n <button\n class=\"item fit\"\n type=\"button\"\n mat-icon-button\n [disabled]=\"busy()\"\n (click)=\"generateDescription()\"\n >\n <mat-icon matTooltip=\"Generate description\"\n >auto_awesome</mat-icon\n >\n </button>\n }\n </div>\n\n <!-- facet -->\n <div class=\"form-row\">\n <mat-form-field>\n <mat-label>facet</mat-label>\n <mat-select [formField]=\"metadata.facet\">\n @for (f of facets(); track f.id) {\n <mat-option [value]=\"f.id\">\n {{ f.label }}\n </mat-option>\n }\n </mat-select>\n <mat-error>please select a facet</mat-error>\n </mat-form-field>\n\n <!-- group -->\n <mat-form-field>\n <mat-label>group ID</mat-label>\n <input matInput [formField]=\"metadata.group\" />\n @if (\n metadata.group().getError(\"maxLength\") && (metadata.group().dirty() || metadata.group().touched())\n ) {\n <mat-error>too long</mat-error>\n }\n </mat-form-field>\n </div>\n\n <!-- flags -->\n <fieldset>\n <legend>flags</legend>\n <!-- read-only admin flags for non-admin users -->\n @if (adminFlagDefs().length) {\n <div class=\"admin-flags\">\n @for (def of adminFlagDefs(); track def.id) {\n <span class=\"admin-flag\">\n <span [style.color]=\"'#' + def.colorKey\">◆</span>\n {{ def.label }}\n </span>\n }\n </div>\n }\n <!-- editable flags -->\n @if (flagSetFlags().length) {\n <cadmus-ui-flag-set\n [hideToolbar]=\"true\"\n [flags]=\"flagSetFlags()\"\n [checkedIds]=\"checkedFlagIds()\"\n (checkedIdsChange)=\"onFlagCheckedIdsChange($event)\"\n />\n }\n </fieldset>\n <br />\n\n <!-- action buttons -->\n @if (userLevel() > 1) {\n <div class=\"form-row\">\n <button\n type=\"button\"\n mat-flat-button\n class=\"mat-warn\"\n (click)=\"onGenerateItems()\"\n >\n <mat-icon>copy_all</mat-icon> generate\n </button>\n <button\n type=\"submit\"\n mat-flat-button\n class=\"mat-primary\"\n [disabled]=\"busy()\"\n matTooltip=\"Save metadata\"\n >\n <mat-icon>save</mat-icon> save\n </button>\n </div>\n }\n </form>\n </mat-tab>\n\n <!-- parts -->\n @if (id()) {\n <mat-tab label=\"Parts\">\n <div class=\"new-part\">\n <div class=\"form-row\">\n <mat-form-field>\n <mat-label>part</mat-label>\n <mat-select [formField]=\"newPart.newPartType\">\n @for (\n p of newPartDefinitions();\n track p.typeId + \":\" + (p.roleId || \"\")\n ) {\n <mat-option [value]=\"p\">\n <span\n [style.color]=\"'#' + p.colorKey\"\n class=\"new-part-icon\"\n >⬤</span\n >\n {{ getPartIdName(p.typeId, p.roleId) }}\n </mat-option>\n }\n </mat-select>\n <mat-error>part type required</mat-error>\n </mat-form-field>\n <button\n mat-flat-button\n class=\"mat-primary\"\n type=\"button\"\n [disabled]=\"userLevel() < 2 || busy() || !newPart().valid()\"\n (click)=\"addPart()\"\n matTooltip=\"Add a new part of the selected type\"\n >\n <mat-icon>add_circle</mat-icon>\n part\n </button>\n </div>\n </div>\n <mat-divider></mat-divider>\n @for (group of partGroups(); track group.key) {\n <mat-expansion-panel expanded=\"true\" class=\"group-header\">\n <mat-expansion-panel-header>\n <mat-panel-title\n ><strong>{{ group.label }}</strong></mat-panel-title\n >\n <mat-panel-description>{{\n group.parts.length\n }}</mat-panel-description>\n </mat-expansion-panel-header>\n <table class=\"parts-table\">\n <thead>\n <tr>\n <th></th>\n <th>type</th>\n <th>role</th>\n <th class=\"noif-lt-xs\">modified</th>\n <th class=\"noif-lt-xs\">user</th>\n </tr>\n </thead>\n <tbody>\n @for (\n part of group.parts;\n track part.typeId + \":\" + (part.roleId || \"\")\n ) {\n <tr>\n <!-- edit -->\n <td class=\"fit-width\">\n <button\n mat-icon-button\n type=\"button\"\n [disabled]=\"busy()\"\n (click)=\"editPart(part)\"\n matTooltip=\"Edit this part\"\n >\n <mat-icon class=\"mat-primary\">create</mat-icon>\n </button>\n <!-- delete -->\n @if (\n user()?.roles?.length &&\n (user()?.roles?.includes(\"admin\") ||\n user()?.roles?.includes(\"editor\") ||\n user()?.roles?.includes(\"operator\"))\n ) {\n <button\n mat-icon-button\n type=\"button\"\n [disabled]=\"userLevel() < 2 || busy()\"\n (click)=\"deletePart(part)\"\n matTooltip=\"Delete this part\"\n >\n <mat-icon class=\"mat-warn\">delete</mat-icon>\n </button>\n }\n <!-- copy ID -->\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Copy this part ID\"\n [cdkCopyToClipboard]=\"part.id\"\n >\n <mat-icon>assignment</mat-icon>\n </button>\n <!-- copy into item -->\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Copy part into another item\"\n (click)=\"onCopyPart(part)\"\n >\n <mat-icon>open_in_new</mat-icon>\n </button>\n <!-- preview -->\n @if (\n part | hasPreview: previewJKeys() : previewFKeys()\n ) {\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Preview this part\"\n (click)=\"previewPart(part)\"\n >\n <mat-icon>preview</mat-icon>\n </button>\n }\n </td>\n <td>\n <cadmus-part-badge\n [partTypeIds]=\"part\"\n [facetDefinition]=\"facet()\"\n [badgeType]=\"1\"\n [typeThesaurus]=\"typeThesaurus()\"\n />\n </td>\n <td>\n <cadmus-part-badge\n [partTypeIds]=\"part\"\n [facetDefinition]=\"facet()\"\n [badgeType]=\"2\"\n [typeThesaurus]=\"typeThesaurus()\"\n />\n </td>\n <td class=\"noif-lt-xs\">\n {{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\n </td>\n <td class=\"noif-lt-xs\">{{ part.userId }}</td>\n </tr>\n }\n </tbody>\n </table>\n </mat-expansion-panel>\n }\n <cadmus-missing-parts\n [facetDefinition]=\"facet()\"\n [partDefinitions]=\"\n $safeNavigationMigration(facet()?.partDefinitions)\n \"\n [parts]=\"parts()\"\n [typeThesaurus]=\"typeThesaurus()\"\n (addRequest)=\"addPart($event)\"\n />\n </mat-tab>\n }\n\n <!-- layers -->\n @if (id()) {\n <mat-tab label=\"Layers\">\n <table id=\"layers\">\n <thead>\n <th aria-label=\"actions\"></th>\n <th>type</th>\n <th>role</th>\n <th>frr.</th>\n <th>last modified</th>\n </thead>\n <tbody>\n @for (\n part of layerPartInfos();\n track part.typeId + \":\" + (part.roleId || \"\")\n ) {\n <tr>\n <td class=\"fit-width\">\n @if (!part.isAbsent) {\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Edit this layer part\"\n (click)=\"editPart(part)\"\n >\n <mat-icon class=\"mat-primary\">edit</mat-icon>\n </button>\n }\n @if (part.isAbsent) {\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Add this layer part\"\n [disabled]=\"userLevel() < 2\"\n (click)=\"addLayerPart(part)\"\n >\n <mat-icon class=\"mat-primary\">add_circle</mat-icon>\n </button>\n }\n @if (!part.isAbsent) {\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Delete this layer part\"\n [disabled]=\"userLevel() < 2\"\n (click)=\"deletePart(part)\"\n >\n <mat-icon class=\"mat-warn\">delete</mat-icon>\n </button>\n }\n @if (!part.isAbsent) {\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Copy this part ID\"\n [cdkCopyToClipboard]=\"part.id\"\n >\n <mat-icon>assignment</mat-icon>\n </button>\n }\n </td>\n <td>\n <cadmus-part-badge\n [partTypeIds]=\"part\"\n [facetDefinition]=\"facet()\"\n [badgeType]=\"1\"\n [typeThesaurus]=\"typeThesaurus()\"\n />\n </td>\n <td>\n <cadmus-part-badge\n [partTypeIds]=\"part\"\n [facetDefinition]=\"facet()\"\n [badgeType]=\"2\"\n [typeThesaurus]=\"typeThesaurus()\"\n />\n </td>\n <td\n [class.count-n]=\"part.fragmentCount\"\n [class.count-z]=\"!part.fragmentCount\"\n >\n {{ part.fragmentCount }}\n </td>\n <td>\n @if (!part.isAbsent) {\n <span>\n {{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\n </span>\n }\n </td>\n </tr>\n }\n </tbody>\n </table>\n </mat-tab>\n }\n\n <!-- thesaurus scopes -->\n @if (parts().length) {\n <mat-tab label=\"Th-Scopes\">\n <cadmus-parts-scope-editor\n [parts]=\"parts()\"\n [readonly]=\"userLevel() < 2 || busy() ? true : false\"\n (setScopeRequest)=\"setPartsScope($event)\"\n />\n </mat-tab>\n }\n </mat-tab-group>\n </mat-card-content>\n</mat-card>\n",
|
|
1734
1634
|
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
1635
|
dependencies: [
|
|
1736
1636
|
{
|
|
@@ -1825,55 +1725,18 @@ var ItemEditorComponent = class ItemEditorComponent {
|
|
|
1825
1725
|
],
|
|
1826
1726
|
exportAs: ["matTab"]
|
|
1827
1727
|
},
|
|
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
1728
|
{
|
|
1843
1729
|
kind: "directive",
|
|
1844
|
-
type:
|
|
1845
|
-
selector: "[
|
|
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"]
|
|
1730
|
+
type: FormField,
|
|
1731
|
+
selector: "[formField]",
|
|
1732
|
+
inputs: ["formField"],
|
|
1733
|
+
exportAs: ["formField"]
|
|
1869
1734
|
},
|
|
1870
1735
|
{
|
|
1871
1736
|
kind: "directive",
|
|
1872
|
-
type:
|
|
1873
|
-
selector: "[
|
|
1874
|
-
inputs: ["
|
|
1875
|
-
outputs: ["ngSubmit"],
|
|
1876
|
-
exportAs: ["ngForm"]
|
|
1737
|
+
type: FormRoot,
|
|
1738
|
+
selector: "form[formRoot]",
|
|
1739
|
+
inputs: ["formRoot"]
|
|
1877
1740
|
},
|
|
1878
1741
|
{
|
|
1879
1742
|
kind: "component",
|
|
@@ -2106,7 +1969,8 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2106
1969
|
MatProgressBar,
|
|
2107
1970
|
MatTabGroup,
|
|
2108
1971
|
MatTab,
|
|
2109
|
-
|
|
1972
|
+
FormField,
|
|
1973
|
+
FormRoot,
|
|
2110
1974
|
MatFormField,
|
|
2111
1975
|
MatLabel,
|
|
2112
1976
|
MatInput,
|
|
@@ -2129,7 +1993,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2129
1993
|
CurrentItemBarComponent,
|
|
2130
1994
|
FlagSetComponent
|
|
2131
1995
|
],
|
|
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\">◆</span>\r\n {{ 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 >⬤</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",
|
|
1996
|
+
template: "<mat-card appearance=\"outlined\">\n <mat-card-content>\n <div>\n <cadmus-current-item-bar />\n </div>\n @if (busy()) {\n <mat-progress-bar mode=\"indeterminate\" />\n }\n\n <!-- item content -->\n <mat-tab-group [selectedIndex]=\"id() ? 1 : 0\">\n <!-- metadata -->\n <mat-tab label=\"Metadata\">\n <form [formRoot]=\"metadata\">\n <div class=\"form-row\">\n <!-- title -->\n <mat-form-field class=\"flex-field\">\n <mat-label>title</mat-label>\n <input matInput type=\"text\" id=\"title\" [formField]=\"metadata.title\" />\n @if (\n metadata.title().getError(\"required\") && (metadata.title().touched() || metadata.title().dirty())\n ) {\n <mat-error>enter title</mat-error>\n }\n @if (\n metadata.title().getError(\"maxLength\") && (metadata.title().touched() || metadata.title().dirty())\n ) {\n <mat-error>title too long</mat-error>\n }\n </mat-form-field>\n\n @if (hasMetadataBuilders()) {\n <!-- auto title -->\n <button\n type=\"button\"\n mat-icon-button\n [disabled]=\"busy()\"\n (click)=\"generateTitle()\"\n >\n <mat-icon matTooltip=\"Generate title\">auto_awesome</mat-icon>\n </button>\n }\n\n <!-- sortKey -->\n <mat-form-field class=\"flex-field\">\n <mat-label>sort key</mat-label>\n <input\n matInput\n type=\"text\"\n id=\"sortKey\"\n [formField]=\"metadata.sortKey\"\n />\n @if (\n metadata.sortKey().getError(\"required\") &&\n (metadata.sortKey().touched() || metadata.sortKey().dirty())\n ) {\n <mat-error>enter sort key</mat-error>\n }\n @if (\n metadata.sortKey().getError(\"maxLength\") &&\n (metadata.sortKey().touched() || metadata.sortKey().dirty())\n ) {\n <mat-error>sort key too long</mat-error>\n }\n </mat-form-field>\n </div>\n\n <!-- description -->\n <div class=\"flex-row\">\n <mat-form-field class=\"item\">\n <mat-label>description</mat-label>\n <textarea\n rows=\"2\"\n matInput\n id=\"description\"\n [formField]=\"metadata.description\"\n ></textarea>\n @if (\n metadata.description().getError(\"required\") &&\n (metadata.description().touched() || metadata.description().dirty())\n ) {\n <mat-error>enter description</mat-error>\n }\n @if (\n metadata.description().getError(\"maxLength\") &&\n (metadata.description().touched() || metadata.description().dirty())\n ) {\n <mat-error>description too long</mat-error>\n }\n </mat-form-field>\n\n @if (hasMetadataBuilders()) {\n <!-- auto description -->\n <button\n class=\"item fit\"\n type=\"button\"\n mat-icon-button\n [disabled]=\"busy()\"\n (click)=\"generateDescription()\"\n >\n <mat-icon matTooltip=\"Generate description\"\n >auto_awesome</mat-icon\n >\n </button>\n }\n </div>\n\n <!-- facet -->\n <div class=\"form-row\">\n <mat-form-field>\n <mat-label>facet</mat-label>\n <mat-select [formField]=\"metadata.facet\">\n @for (f of facets(); track f.id) {\n <mat-option [value]=\"f.id\">\n {{ f.label }}\n </mat-option>\n }\n </mat-select>\n <mat-error>please select a facet</mat-error>\n </mat-form-field>\n\n <!-- group -->\n <mat-form-field>\n <mat-label>group ID</mat-label>\n <input matInput [formField]=\"metadata.group\" />\n @if (\n metadata.group().getError(\"maxLength\") && (metadata.group().dirty() || metadata.group().touched())\n ) {\n <mat-error>too long</mat-error>\n }\n </mat-form-field>\n </div>\n\n <!-- flags -->\n <fieldset>\n <legend>flags</legend>\n <!-- read-only admin flags for non-admin users -->\n @if (adminFlagDefs().length) {\n <div class=\"admin-flags\">\n @for (def of adminFlagDefs(); track def.id) {\n <span class=\"admin-flag\">\n <span [style.color]=\"'#' + def.colorKey\">◆</span>\n {{ def.label }}\n </span>\n }\n </div>\n }\n <!-- editable flags -->\n @if (flagSetFlags().length) {\n <cadmus-ui-flag-set\n [hideToolbar]=\"true\"\n [flags]=\"flagSetFlags()\"\n [checkedIds]=\"checkedFlagIds()\"\n (checkedIdsChange)=\"onFlagCheckedIdsChange($event)\"\n />\n }\n </fieldset>\n <br />\n\n <!-- action buttons -->\n @if (userLevel() > 1) {\n <div class=\"form-row\">\n <button\n type=\"button\"\n mat-flat-button\n class=\"mat-warn\"\n (click)=\"onGenerateItems()\"\n >\n <mat-icon>copy_all</mat-icon> generate\n </button>\n <button\n type=\"submit\"\n mat-flat-button\n class=\"mat-primary\"\n [disabled]=\"busy()\"\n matTooltip=\"Save metadata\"\n >\n <mat-icon>save</mat-icon> save\n </button>\n </div>\n }\n </form>\n </mat-tab>\n\n <!-- parts -->\n @if (id()) {\n <mat-tab label=\"Parts\">\n <div class=\"new-part\">\n <div class=\"form-row\">\n <mat-form-field>\n <mat-label>part</mat-label>\n <mat-select [formField]=\"newPart.newPartType\">\n @for (\n p of newPartDefinitions();\n track p.typeId + \":\" + (p.roleId || \"\")\n ) {\n <mat-option [value]=\"p\">\n <span\n [style.color]=\"'#' + p.colorKey\"\n class=\"new-part-icon\"\n >⬤</span\n >\n {{ getPartIdName(p.typeId, p.roleId) }}\n </mat-option>\n }\n </mat-select>\n <mat-error>part type required</mat-error>\n </mat-form-field>\n <button\n mat-flat-button\n class=\"mat-primary\"\n type=\"button\"\n [disabled]=\"userLevel() < 2 || busy() || !newPart().valid()\"\n (click)=\"addPart()\"\n matTooltip=\"Add a new part of the selected type\"\n >\n <mat-icon>add_circle</mat-icon>\n part\n </button>\n </div>\n </div>\n <mat-divider></mat-divider>\n @for (group of partGroups(); track group.key) {\n <mat-expansion-panel expanded=\"true\" class=\"group-header\">\n <mat-expansion-panel-header>\n <mat-panel-title\n ><strong>{{ group.label }}</strong></mat-panel-title\n >\n <mat-panel-description>{{\n group.parts.length\n }}</mat-panel-description>\n </mat-expansion-panel-header>\n <table class=\"parts-table\">\n <thead>\n <tr>\n <th></th>\n <th>type</th>\n <th>role</th>\n <th class=\"noif-lt-xs\">modified</th>\n <th class=\"noif-lt-xs\">user</th>\n </tr>\n </thead>\n <tbody>\n @for (\n part of group.parts;\n track part.typeId + \":\" + (part.roleId || \"\")\n ) {\n <tr>\n <!-- edit -->\n <td class=\"fit-width\">\n <button\n mat-icon-button\n type=\"button\"\n [disabled]=\"busy()\"\n (click)=\"editPart(part)\"\n matTooltip=\"Edit this part\"\n >\n <mat-icon class=\"mat-primary\">create</mat-icon>\n </button>\n <!-- delete -->\n @if (\n user()?.roles?.length &&\n (user()?.roles?.includes(\"admin\") ||\n user()?.roles?.includes(\"editor\") ||\n user()?.roles?.includes(\"operator\"))\n ) {\n <button\n mat-icon-button\n type=\"button\"\n [disabled]=\"userLevel() < 2 || busy()\"\n (click)=\"deletePart(part)\"\n matTooltip=\"Delete this part\"\n >\n <mat-icon class=\"mat-warn\">delete</mat-icon>\n </button>\n }\n <!-- copy ID -->\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Copy this part ID\"\n [cdkCopyToClipboard]=\"part.id\"\n >\n <mat-icon>assignment</mat-icon>\n </button>\n <!-- copy into item -->\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Copy part into another item\"\n (click)=\"onCopyPart(part)\"\n >\n <mat-icon>open_in_new</mat-icon>\n </button>\n <!-- preview -->\n @if (\n part | hasPreview: previewJKeys() : previewFKeys()\n ) {\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Preview this part\"\n (click)=\"previewPart(part)\"\n >\n <mat-icon>preview</mat-icon>\n </button>\n }\n </td>\n <td>\n <cadmus-part-badge\n [partTypeIds]=\"part\"\n [facetDefinition]=\"facet()\"\n [badgeType]=\"1\"\n [typeThesaurus]=\"typeThesaurus()\"\n />\n </td>\n <td>\n <cadmus-part-badge\n [partTypeIds]=\"part\"\n [facetDefinition]=\"facet()\"\n [badgeType]=\"2\"\n [typeThesaurus]=\"typeThesaurus()\"\n />\n </td>\n <td class=\"noif-lt-xs\">\n {{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\n </td>\n <td class=\"noif-lt-xs\">{{ part.userId }}</td>\n </tr>\n }\n </tbody>\n </table>\n </mat-expansion-panel>\n }\n <cadmus-missing-parts\n [facetDefinition]=\"facet()\"\n [partDefinitions]=\"\n $safeNavigationMigration(facet()?.partDefinitions)\n \"\n [parts]=\"parts()\"\n [typeThesaurus]=\"typeThesaurus()\"\n (addRequest)=\"addPart($event)\"\n />\n </mat-tab>\n }\n\n <!-- layers -->\n @if (id()) {\n <mat-tab label=\"Layers\">\n <table id=\"layers\">\n <thead>\n <th aria-label=\"actions\"></th>\n <th>type</th>\n <th>role</th>\n <th>frr.</th>\n <th>last modified</th>\n </thead>\n <tbody>\n @for (\n part of layerPartInfos();\n track part.typeId + \":\" + (part.roleId || \"\")\n ) {\n <tr>\n <td class=\"fit-width\">\n @if (!part.isAbsent) {\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Edit this layer part\"\n (click)=\"editPart(part)\"\n >\n <mat-icon class=\"mat-primary\">edit</mat-icon>\n </button>\n }\n @if (part.isAbsent) {\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Add this layer part\"\n [disabled]=\"userLevel() < 2\"\n (click)=\"addLayerPart(part)\"\n >\n <mat-icon class=\"mat-primary\">add_circle</mat-icon>\n </button>\n }\n @if (!part.isAbsent) {\n <button\n type=\"button\"\n mat-icon-button\n matTooltip=\"Delete this layer part\"\n [disabled]=\"userLevel() < 2\"\n (click)=\"deletePart(part)\"\n >\n <mat-icon class=\"mat-warn\">delete</mat-icon>\n </button>\n }\n @if (!part.isAbsent) {\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Copy this part ID\"\n [cdkCopyToClipboard]=\"part.id\"\n >\n <mat-icon>assignment</mat-icon>\n </button>\n }\n </td>\n <td>\n <cadmus-part-badge\n [partTypeIds]=\"part\"\n [facetDefinition]=\"facet()\"\n [badgeType]=\"1\"\n [typeThesaurus]=\"typeThesaurus()\"\n />\n </td>\n <td>\n <cadmus-part-badge\n [partTypeIds]=\"part\"\n [facetDefinition]=\"facet()\"\n [badgeType]=\"2\"\n [typeThesaurus]=\"typeThesaurus()\"\n />\n </td>\n <td\n [class.count-n]=\"part.fragmentCount\"\n [class.count-z]=\"!part.fragmentCount\"\n >\n {{ part.fragmentCount }}\n </td>\n <td>\n @if (!part.isAbsent) {\n <span>\n {{ part.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}\n </span>\n }\n </td>\n </tr>\n }\n </tbody>\n </table>\n </mat-tab>\n }\n\n <!-- thesaurus scopes -->\n @if (parts().length) {\n <mat-tab label=\"Th-Scopes\">\n <cadmus-parts-scope-editor\n [parts]=\"parts()\"\n [readonly]=\"userLevel() < 2 || busy() ? true : false\"\n (setScopeRequest)=\"setPartsScope($event)\"\n />\n </mat-tab>\n }\n </mat-tab-group>\n </mat-card-content>\n</mat-card>\n",
|
|
2133
1997
|
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
1998
|
}]
|
|
2135
1999
|
}],
|
|
@@ -2139,16 +2003,15 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2139
2003
|
{ type: i3.Router },
|
|
2140
2004
|
{ type: i3.ActivatedRoute },
|
|
2141
2005
|
{ type: i4.MatSnackBar },
|
|
2142
|
-
{ type: i1$
|
|
2006
|
+
{ type: i1$1.AppRepository },
|
|
2143
2007
|
{ type: EditedItemRepository },
|
|
2144
|
-
{ type: i2$
|
|
2008
|
+
{ type: i2$2.ItemService },
|
|
2145
2009
|
{ type: i8.LibraryRouteService },
|
|
2146
|
-
{ type:
|
|
2010
|
+
{ type: i2$1.DialogService },
|
|
2147
2011
|
{ type: i10.AuthJwtService },
|
|
2148
|
-
{ type: i2$
|
|
2149
|
-
{ type: i2$
|
|
2150
|
-
{ type:
|
|
2151
|
-
{ type: i1$1.FormBuilder }
|
|
2012
|
+
{ type: i2$2.UserLevelService },
|
|
2013
|
+
{ type: i2$2.MessagingService },
|
|
2014
|
+
{ type: i4$1.EnvService }
|
|
2152
2015
|
]
|
|
2153
2016
|
});
|
|
2154
2017
|
export { CurrentItemBarComponent, CurrentLayerPartBarComponent, EditedItemRepository, ItemEditorComponent, ItemGenerateDialogComponent, ItemLookupDialogComponent };
|