@myrmidon/cadmus-item-editor 0.0.13 → 0.3.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.
- package/README.md +24 -24
- package/esm2020/lib/cadmus-item-editor.module.mjs +83 -0
- package/esm2020/lib/item-editor/item-editor.component.mjs +353 -0
- package/esm2020/lib/missing-parts/missing-parts.component.mjs +71 -0
- package/esm2020/lib/parts-scope-editor/parts-scope-editor.component.mjs +118 -0
- package/esm2020/myrmidon-cadmus-item-editor.mjs +5 -0
- package/esm2020/public-api.mjs +6 -0
- package/fesm2015/myrmidon-cadmus-item-editor.mjs +607 -0
- package/fesm2015/myrmidon-cadmus-item-editor.mjs.map +1 -0
- package/fesm2020/myrmidon-cadmus-item-editor.mjs +604 -0
- package/fesm2020/myrmidon-cadmus-item-editor.mjs.map +1 -0
- package/lib/cadmus-item-editor.module.d.ts +19 -0
- package/lib/item-editor/item-editor.component.d.ts +20 -17
- package/lib/missing-parts/missing-parts.component.d.ts +12 -9
- package/lib/parts-scope-editor/parts-scope-editor.component.d.ts +8 -5
- package/myrmidon-cadmus-item-editor.d.ts +1 -2
- package/package.json +27 -15
- package/bundles/myrmidon-cadmus-item-editor.umd.js +0 -929
- package/bundles/myrmidon-cadmus-item-editor.umd.js.map +0 -1
- package/bundles/myrmidon-cadmus-item-editor.umd.min.js +0 -16
- package/bundles/myrmidon-cadmus-item-editor.umd.min.js.map +0 -1
- package/esm2015/lib/cadmus-item-editor.module.js +0 -45
- package/esm2015/lib/item-editor/item-editor.component.js +0 -337
- package/esm2015/lib/missing-parts/missing-parts.component.js +0 -62
- package/esm2015/lib/parts-scope-editor/parts-scope-editor.component.js +0 -115
- package/esm2015/myrmidon-cadmus-item-editor.js +0 -7
- package/esm2015/public-api.js +0 -6
- package/fesm2015/myrmidon-cadmus-item-editor.js +0 -554
- package/fesm2015/myrmidon-cadmus-item-editor.js.map +0 -1
- package/myrmidon-cadmus-item-editor.metadata.json +0 -1
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { EventEmitter, Component, Input, Output, NgModule } from '@angular/core';
|
|
3
|
+
import * as i7 from '@angular/forms';
|
|
4
|
+
import { Validators, ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
5
|
+
import * as i1$1 from '@angular/router';
|
|
6
|
+
import { RouterModule } from '@angular/router';
|
|
7
|
+
import * as i2$2 from '@angular/material/snack-bar';
|
|
8
|
+
import * as i3$2 from '@myrmidon/cadmus-state';
|
|
9
|
+
import { CadmusStateModule } from '@myrmidon/cadmus-state';
|
|
10
|
+
import * as i4 from '@myrmidon/cadmus-core';
|
|
11
|
+
import { CadmusCoreModule } from '@myrmidon/cadmus-core';
|
|
12
|
+
import * as i3$1 from '@myrmidon/ng-mat-tools';
|
|
13
|
+
import { NgMatToolsModule } from '@myrmidon/ng-mat-tools';
|
|
14
|
+
import * as i2$1 from '@myrmidon/cadmus-api';
|
|
15
|
+
import { CadmusApiModule } from '@myrmidon/cadmus-api';
|
|
16
|
+
import * as i8 from '@angular/material/card';
|
|
17
|
+
import * as i9$1 from '@angular/material/progress-bar';
|
|
18
|
+
import * as i10 from '@angular/material/tabs';
|
|
19
|
+
import * as i6 from '@angular/material/form-field';
|
|
20
|
+
import * as i12 from '@angular/material/select';
|
|
21
|
+
import * as i13 from '@angular/material/core';
|
|
22
|
+
import * as i5$1 from '@angular/material/checkbox';
|
|
23
|
+
import * as i2 from '@angular/material/button';
|
|
24
|
+
import * as i1 from '@angular/material/icon';
|
|
25
|
+
import * as i17 from '@angular/material/divider';
|
|
26
|
+
import * as i18 from '@angular/material/expansion';
|
|
27
|
+
import * as i3 from '@myrmidon/cadmus-ui';
|
|
28
|
+
import { CustomValidators, CadmusUiModule } from '@myrmidon/cadmus-ui';
|
|
29
|
+
import * as i22 from '@angular/common';
|
|
30
|
+
import { CommonModule } from '@angular/common';
|
|
31
|
+
import * as i5 from '@angular/material/tooltip';
|
|
32
|
+
import * as i9 from '@angular/material/input';
|
|
33
|
+
import * as i11 from 'ngx-moment';
|
|
34
|
+
import { MomentModule } from 'ngx-moment';
|
|
35
|
+
import * as i24 from '@angular/cdk/clipboard';
|
|
36
|
+
import { ClipboardModule } from '@angular/cdk/clipboard';
|
|
37
|
+
import * as i26 from '@angular/flex-layout/extended';
|
|
38
|
+
import { CadmusMaterialModule } from '@myrmidon/cadmus-material';
|
|
39
|
+
import { NgToolsModule } from '@myrmidon/ng-tools';
|
|
40
|
+
|
|
41
|
+
class MissingPartsComponent {
|
|
42
|
+
constructor() {
|
|
43
|
+
this.missingDefinitions = [];
|
|
44
|
+
this.addRequest = new EventEmitter();
|
|
45
|
+
}
|
|
46
|
+
get partDefinitions() {
|
|
47
|
+
return this._partDefinitions;
|
|
48
|
+
}
|
|
49
|
+
set partDefinitions(value) {
|
|
50
|
+
this._partDefinitions = value;
|
|
51
|
+
this.updateMissing();
|
|
52
|
+
}
|
|
53
|
+
get parts() {
|
|
54
|
+
return this._parts;
|
|
55
|
+
}
|
|
56
|
+
set parts(value) {
|
|
57
|
+
this._parts = value;
|
|
58
|
+
this.updateMissing();
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The types thesaurus.
|
|
62
|
+
*/
|
|
63
|
+
get typeThesaurus() {
|
|
64
|
+
return this._typeThesaurus;
|
|
65
|
+
}
|
|
66
|
+
set typeThesaurus(value) {
|
|
67
|
+
this._typeThesaurus = value;
|
|
68
|
+
this.updateMissing();
|
|
69
|
+
}
|
|
70
|
+
ngOnInit() { }
|
|
71
|
+
isPartPresent(typeId, roleId) {
|
|
72
|
+
if (!this._partDefinitions) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return this._partDefinitions.some((d) => d.typeId === typeId && d.roleId === roleId);
|
|
76
|
+
}
|
|
77
|
+
updateMissing() {
|
|
78
|
+
this.missingDefinitions.length = 0;
|
|
79
|
+
if (!this._partDefinitions) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
for (let i = 0; i < this._partDefinitions.length; i++) {
|
|
83
|
+
const def = this._partDefinitions[i];
|
|
84
|
+
if (!this.isPartPresent(def.typeId, def.roleId)) {
|
|
85
|
+
this.missingDefinitions.push(def);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
MissingPartsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: MissingPartsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
91
|
+
MissingPartsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.2", type: MissingPartsComponent, selector: "cadmus-missing-parts", inputs: { partDefinitions: "partDefinitions", parts: "parts", typeThesaurus: "typeThesaurus" }, outputs: { addRequest: "addRequest" }, ngImport: i0, template: "<div *ngIf=\"missingDefinitions.length\">\r\n <h3><mat-icon color=\"warn\">warning</mat-icon> Missing Parts</h3>\r\n <table>\r\n <tbody>\r\n <tr *ngFor=\"let def of missingDefinitions\">\r\n <td>\r\n <button type=\"button\" mat-icon-button matTooltip=\"Add this part\">\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]=\"def\"\r\n [typeThesaurus]=\"typeThesaurus\"\r\n ></cadmus-part-badge>\r\n </td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n</div>\r\n", styles: [""], components: [{ type: i1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i3.PartBadgeComponent, selector: "cadmus-part-badge", inputs: ["badgeType", "typeThesaurus", "facetDefinition", "partTypeIds"] }], directives: [{ type: i22.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i22.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }] });
|
|
92
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: MissingPartsComponent, decorators: [{
|
|
93
|
+
type: Component,
|
|
94
|
+
args: [{ selector: 'cadmus-missing-parts', template: "<div *ngIf=\"missingDefinitions.length\">\r\n <h3><mat-icon color=\"warn\">warning</mat-icon> Missing Parts</h3>\r\n <table>\r\n <tbody>\r\n <tr *ngFor=\"let def of missingDefinitions\">\r\n <td>\r\n <button type=\"button\" mat-icon-button matTooltip=\"Add this part\">\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]=\"def\"\r\n [typeThesaurus]=\"typeThesaurus\"\r\n ></cadmus-part-badge>\r\n </td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n</div>\r\n", styles: [""] }]
|
|
95
|
+
}], ctorParameters: function () { return []; }, propDecorators: { partDefinitions: [{
|
|
96
|
+
type: Input
|
|
97
|
+
}], parts: [{
|
|
98
|
+
type: Input
|
|
99
|
+
}], typeThesaurus: [{
|
|
100
|
+
type: Input
|
|
101
|
+
}], addRequest: [{
|
|
102
|
+
type: Output
|
|
103
|
+
}] } });
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Parts thesaurus scope dumb editor component.
|
|
107
|
+
* This is used to set the thesaurus scope of multiple item's parts at once
|
|
108
|
+
* in the item editor.
|
|
109
|
+
*/
|
|
110
|
+
class PartsScopeEditorComponent {
|
|
111
|
+
constructor(_formBuilder, _facetService, _dialogService, _appQuery, _itemQuery) {
|
|
112
|
+
this._formBuilder = _formBuilder;
|
|
113
|
+
this._facetService = _facetService;
|
|
114
|
+
this._dialogService = _dialogService;
|
|
115
|
+
this._appQuery = _appQuery;
|
|
116
|
+
this._itemQuery = _itemQuery;
|
|
117
|
+
// events
|
|
118
|
+
this.setScopeRequest = new EventEmitter();
|
|
119
|
+
// form
|
|
120
|
+
this.checks = _formBuilder.array([], CustomValidators.minChecked(1));
|
|
121
|
+
this.scope = _formBuilder.control(null, [
|
|
122
|
+
Validators.maxLength(50),
|
|
123
|
+
Validators.pattern(/^[-a-zA-Z0-9_]+$/),
|
|
124
|
+
]);
|
|
125
|
+
this.form = _formBuilder.group({
|
|
126
|
+
checks: this.checks,
|
|
127
|
+
scope: this.scope,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
get parts() {
|
|
131
|
+
return this._parts;
|
|
132
|
+
}
|
|
133
|
+
set parts(value) {
|
|
134
|
+
this._parts = value;
|
|
135
|
+
this.updateForm();
|
|
136
|
+
}
|
|
137
|
+
ngOnInit() { }
|
|
138
|
+
updateForm() {
|
|
139
|
+
this.checks.clear();
|
|
140
|
+
if (!this._parts || this._parts.length === 0) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
for (let i = 0; i < this._parts.length; i++) {
|
|
144
|
+
this.checks.push(this._formBuilder.control(false));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
getPartColor(typeId, roleId) {
|
|
148
|
+
const state = this._itemQuery.getValue();
|
|
149
|
+
return this._facetService.getPartColor(typeId, roleId, state === null || state === void 0 ? void 0 : state.facet);
|
|
150
|
+
}
|
|
151
|
+
getTypeIdName(typeId) {
|
|
152
|
+
var _a;
|
|
153
|
+
const state = this._appQuery.getValue();
|
|
154
|
+
if (!state || !state.typeThesaurus) {
|
|
155
|
+
return typeId;
|
|
156
|
+
}
|
|
157
|
+
// strip :suffix if any
|
|
158
|
+
const i = typeId.lastIndexOf(':');
|
|
159
|
+
if (i > -1) {
|
|
160
|
+
typeId = typeId.substr(0, i);
|
|
161
|
+
}
|
|
162
|
+
const entry = (_a = state.typeThesaurus.entries) === null || _a === void 0 ? void 0 : _a.find((e) => e.id === typeId);
|
|
163
|
+
return entry ? entry.value : typeId;
|
|
164
|
+
}
|
|
165
|
+
getRoleIdName(roleId) {
|
|
166
|
+
if (!roleId || !roleId.startsWith('fr.')) {
|
|
167
|
+
return roleId;
|
|
168
|
+
}
|
|
169
|
+
return this.getTypeIdName(roleId);
|
|
170
|
+
}
|
|
171
|
+
submit() {
|
|
172
|
+
if (this.form.invalid || !this._parts) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const ids = [];
|
|
176
|
+
for (let i = 0; i < this.checks.length; i++) {
|
|
177
|
+
if (this.checks.controls[i].value === true) {
|
|
178
|
+
ids.push(this._parts[i].id);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
let msg = this.scope.value
|
|
182
|
+
? `Assign scope "${this.scope.value}" to ${ids.length} part`
|
|
183
|
+
: `Remove scope from ${ids.length} part`;
|
|
184
|
+
msg += ids.length > 1 ? 's?' : '?';
|
|
185
|
+
this._dialogService.confirm('Confirm Scopes', msg).subscribe((result) => {
|
|
186
|
+
if (!result) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
this.setScopeRequest.emit({
|
|
190
|
+
ids,
|
|
191
|
+
scope: this.scope.value,
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
PartsScopeEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: PartsScopeEditorComponent, deps: [{ token: i7.FormBuilder }, { token: i2$1.FacetService }, { token: i3$1.DialogService }, { token: i3$2.AppQuery }, { token: i3$2.EditItemQuery }], target: i0.ɵɵFactoryTarget.Component });
|
|
197
|
+
PartsScopeEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.2", type: PartsScopeEditorComponent, selector: "cadmus-parts-scope-editor", inputs: { parts: "parts", readonly: "readonly" }, outputs: { setScopeRequest: "setScopeRequest" }, ngImport: i0, template: "<form [formGroup]=\"form\" (submit)=\"submit()\">\r\n <table id=\"parts\">\r\n <thead>\r\n <tr>\r\n <th style=\"min-width: 32px;\"></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 <tr\r\n formArrayName=\"checks\"\r\n *ngFor=\"let ctl of checks.controls; let i = index\"\r\n >\r\n <td>\r\n \r\n <mat-checkbox [formControlName]=\"i\"></mat-checkbox>\r\n </td>\r\n <td>\r\n <span\r\n class=\"model-type\"\r\n [style.background-color]=\"\r\n getPartColor(parts[i].typeId, parts[i].roleId)\r\n \"\r\n >{{ getTypeIdName(parts[i].typeId) }}</span\r\n >\r\n </td>\r\n <td>{{ getRoleIdName(parts[i].roleId) }}</td>\r\n <td>{{ parts[i].thesaurusScope }}</td>\r\n <td>{{ parts[i].timeModified | amLocal | amTimeAgo }}</td>\r\n <td>{{ parts[i].userId }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n <div>\r\n <mat-form-field>\r\n <input matInput placeholder=\"scope\" formControlName=\"scope\" />\r\n <mat-error\r\n *ngIf=\"scope.hasError('maxLength') && (scope.dirty || scope.touched)\"\r\n >too long</mat-error\r\n >\r\n <mat-error\r\n *ngIf=\"scope.hasError('pattern') && (scope.dirty || scope.touched)\"\r\n >invalid scope</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n <button\r\n mat-raised-button\r\n color=\"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</form>\r\n", styles: ["th{font-weight:normal;color:silver;text-align:left}span.model-type{padding:4px;border-radius:6px}table#parts{border-collapse:separate;border-spacing:0 8px}\n"], components: [{ type: i5$1.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex", "aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { type: i6.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i7.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i7.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i7.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i22.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { type: i7.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i7.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i9.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i7.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i22.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.MatError, selector: "mat-error", inputs: ["id"] }, { type: i5.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }], pipes: { "amTimeAgo": i11.TimeAgoPipe, "amLocal": i11.LocalTimePipe } });
|
|
198
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: PartsScopeEditorComponent, decorators: [{
|
|
199
|
+
type: Component,
|
|
200
|
+
args: [{ selector: 'cadmus-parts-scope-editor', template: "<form [formGroup]=\"form\" (submit)=\"submit()\">\r\n <table id=\"parts\">\r\n <thead>\r\n <tr>\r\n <th style=\"min-width: 32px;\"></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 <tr\r\n formArrayName=\"checks\"\r\n *ngFor=\"let ctl of checks.controls; let i = index\"\r\n >\r\n <td>\r\n \r\n <mat-checkbox [formControlName]=\"i\"></mat-checkbox>\r\n </td>\r\n <td>\r\n <span\r\n class=\"model-type\"\r\n [style.background-color]=\"\r\n getPartColor(parts[i].typeId, parts[i].roleId)\r\n \"\r\n >{{ getTypeIdName(parts[i].typeId) }}</span\r\n >\r\n </td>\r\n <td>{{ getRoleIdName(parts[i].roleId) }}</td>\r\n <td>{{ parts[i].thesaurusScope }}</td>\r\n <td>{{ parts[i].timeModified | amLocal | amTimeAgo }}</td>\r\n <td>{{ parts[i].userId }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n <div>\r\n <mat-form-field>\r\n <input matInput placeholder=\"scope\" formControlName=\"scope\" />\r\n <mat-error\r\n *ngIf=\"scope.hasError('maxLength') && (scope.dirty || scope.touched)\"\r\n >too long</mat-error\r\n >\r\n <mat-error\r\n *ngIf=\"scope.hasError('pattern') && (scope.dirty || scope.touched)\"\r\n >invalid scope</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n <button\r\n mat-raised-button\r\n color=\"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</form>\r\n", styles: ["th{font-weight:normal;color:silver;text-align:left}span.model-type{padding:4px;border-radius:6px}table#parts{border-collapse:separate;border-spacing:0 8px}\n"] }]
|
|
201
|
+
}], ctorParameters: function () { return [{ type: i7.FormBuilder }, { type: i2$1.FacetService }, { type: i3$1.DialogService }, { type: i3$2.AppQuery }, { type: i3$2.EditItemQuery }]; }, propDecorators: { parts: [{
|
|
202
|
+
type: Input
|
|
203
|
+
}], readonly: [{
|
|
204
|
+
type: Input
|
|
205
|
+
}], setScopeRequest: [{
|
|
206
|
+
type: Output
|
|
207
|
+
}] } });
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Item editor. This can edit a new or existing item's metadata and parts.
|
|
211
|
+
*/
|
|
212
|
+
class ItemEditorComponent {
|
|
213
|
+
constructor(_router, _route, _snackbar, _appQuery, _query, _editItemService, _libraryRouteService, _dialogService, _authService, _formBuilder) {
|
|
214
|
+
this._router = _router;
|
|
215
|
+
this._route = _route;
|
|
216
|
+
this._snackbar = _snackbar;
|
|
217
|
+
this._appQuery = _appQuery;
|
|
218
|
+
this._query = _query;
|
|
219
|
+
this._editItemService = _editItemService;
|
|
220
|
+
this._libraryRouteService = _libraryRouteService;
|
|
221
|
+
this._dialogService = _dialogService;
|
|
222
|
+
this._authService = _authService;
|
|
223
|
+
this._formBuilder = _formBuilder;
|
|
224
|
+
this.id = this._route.snapshot.params.id;
|
|
225
|
+
this.flagDefinitions = [];
|
|
226
|
+
this.newPartDefinitions = [];
|
|
227
|
+
if (this.id === 'new') {
|
|
228
|
+
this.id = undefined;
|
|
229
|
+
}
|
|
230
|
+
// new part form
|
|
231
|
+
this.newPartType = _formBuilder.control(null, Validators.required);
|
|
232
|
+
this.newPart = _formBuilder.group({
|
|
233
|
+
newPartType: this.newPartType,
|
|
234
|
+
});
|
|
235
|
+
// item's metadata form
|
|
236
|
+
this.title = _formBuilder.control(null, [
|
|
237
|
+
Validators.required,
|
|
238
|
+
Validators.maxLength(500),
|
|
239
|
+
]);
|
|
240
|
+
this.sortKey = _formBuilder.control(null, [
|
|
241
|
+
Validators.required,
|
|
242
|
+
Validators.maxLength(500),
|
|
243
|
+
]);
|
|
244
|
+
this.sortKey.disable();
|
|
245
|
+
this.description = _formBuilder.control(null, [
|
|
246
|
+
Validators.required,
|
|
247
|
+
Validators.maxLength(1000),
|
|
248
|
+
]);
|
|
249
|
+
this.facet = _formBuilder.control(null, Validators.required);
|
|
250
|
+
this.group = _formBuilder.control(null, Validators.maxLength(100));
|
|
251
|
+
this.flags = _formBuilder.control(0);
|
|
252
|
+
this.flagChecks = _formBuilder.array([]);
|
|
253
|
+
this.metadata = _formBuilder.group({
|
|
254
|
+
title: this.title,
|
|
255
|
+
sortKey: this.sortKey,
|
|
256
|
+
description: this.description,
|
|
257
|
+
facet: this.facet,
|
|
258
|
+
group: this.group,
|
|
259
|
+
flagChecks: this.flagChecks,
|
|
260
|
+
});
|
|
261
|
+
this.userLevel = 0;
|
|
262
|
+
this.item$ = this._query.selectItem();
|
|
263
|
+
this.parts$ = this._query.selectParts();
|
|
264
|
+
this.partGroups$ = this._query.select((state) => state.partGroups);
|
|
265
|
+
this.layerPartInfos$ = this._query.select((state) => state.layerPartInfos);
|
|
266
|
+
this.facet$ = this._query.selectFacet();
|
|
267
|
+
this.facets$ = this._appQuery.selectFacets();
|
|
268
|
+
this.typeThesaurus$ = this._appQuery.selectTypeThesaurus();
|
|
269
|
+
this.loading$ = this._query.selectLoading();
|
|
270
|
+
this.saving$ = this._query.selectSaving();
|
|
271
|
+
this.deletingPart$ = this._query.selectDeletingPart();
|
|
272
|
+
this.error$ = this._query.selectError();
|
|
273
|
+
}
|
|
274
|
+
ngOnInit() {
|
|
275
|
+
this._authService.currentUser$.subscribe((user) => {
|
|
276
|
+
this.user = user || undefined;
|
|
277
|
+
this.userLevel = this._authService.getCurrentUserLevel();
|
|
278
|
+
});
|
|
279
|
+
// rebuild the flags controls array when flags definitions change
|
|
280
|
+
this._appQuery.selectFlags().subscribe((defs) => {
|
|
281
|
+
this.flagDefinitions = defs;
|
|
282
|
+
this.buildFlagsControls();
|
|
283
|
+
});
|
|
284
|
+
// when flags controls values change, update the flags value
|
|
285
|
+
this.flagChecks.valueChanges.subscribe((_) => {
|
|
286
|
+
this.flags.setValue(this.getFlagsValue());
|
|
287
|
+
});
|
|
288
|
+
// update the metadata form when item changes
|
|
289
|
+
this.item$.subscribe((item) => {
|
|
290
|
+
this.updateMetadataForm(item);
|
|
291
|
+
this.newPartDefinitions = this.getNewPartDefinitions();
|
|
292
|
+
});
|
|
293
|
+
// load the item (if any) and its lookup
|
|
294
|
+
this._editItemService.load(this.id);
|
|
295
|
+
}
|
|
296
|
+
canDeactivate() {
|
|
297
|
+
return !this.metadata.dirty;
|
|
298
|
+
}
|
|
299
|
+
getExistingPartTypeAndRoleIds() {
|
|
300
|
+
const groups = this._query.getValue().partGroups;
|
|
301
|
+
if (!groups) {
|
|
302
|
+
return [];
|
|
303
|
+
}
|
|
304
|
+
const results = [];
|
|
305
|
+
for (const group of groups) {
|
|
306
|
+
for (const part of group.parts) {
|
|
307
|
+
results.push({
|
|
308
|
+
typeId: part.typeId,
|
|
309
|
+
roleId: part.roleId,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return results;
|
|
314
|
+
}
|
|
315
|
+
getNewPartDefinitions() {
|
|
316
|
+
var _a;
|
|
317
|
+
const facet = this._query.getValue().facet;
|
|
318
|
+
if (!facet) {
|
|
319
|
+
return [];
|
|
320
|
+
}
|
|
321
|
+
const existingTypeRoleIds = this.getExistingPartTypeAndRoleIds();
|
|
322
|
+
const defs = [];
|
|
323
|
+
for (const def of facet.partDefinitions) {
|
|
324
|
+
// exclude layer parts, as these are in the layers tab
|
|
325
|
+
if ((_a = def.roleId) === null || _a === void 0 ? void 0 : _a.startsWith('fr.')) {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
// exclude parts present in the item
|
|
329
|
+
if (existingTypeRoleIds.find((tr) => {
|
|
330
|
+
return (tr.typeId === def.typeId &&
|
|
331
|
+
((!tr.roleId && !def.roleId) || tr.roleId === def.roleId));
|
|
332
|
+
})) {
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
defs.push(def);
|
|
336
|
+
}
|
|
337
|
+
// sort by sort key
|
|
338
|
+
defs.sort((a, b) => {
|
|
339
|
+
return a.sortKey.localeCompare(b.sortKey);
|
|
340
|
+
});
|
|
341
|
+
return defs;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Builds the array of flags controls according to the current flags
|
|
345
|
+
* definitions and the current flags value.
|
|
346
|
+
*/
|
|
347
|
+
buildFlagsControls() {
|
|
348
|
+
this.flagChecks.clear();
|
|
349
|
+
for (const def of this.flagDefinitions) {
|
|
350
|
+
const flagValue = def.id;
|
|
351
|
+
// tslint:disable-next-line: no-bitwise
|
|
352
|
+
const checked = (this.flags.value & flagValue) !== 0;
|
|
353
|
+
this.flagChecks.push(this._formBuilder.control(checked));
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Update the flags controls from the current flags value.
|
|
358
|
+
*/
|
|
359
|
+
updateFlagControls() {
|
|
360
|
+
if (!this.flagDefinitions) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
for (let i = 0; i < this.flagDefinitions.length; i++) {
|
|
364
|
+
const flagValue = this.flagDefinitions[i].id;
|
|
365
|
+
// tslint:disable-next-line: no-bitwise
|
|
366
|
+
const checked = (this.flags.value & flagValue) !== 0;
|
|
367
|
+
this.flagChecks.at(i).setValue(checked);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Get the flags value from the flags controls.
|
|
372
|
+
*/
|
|
373
|
+
getFlagsValue() {
|
|
374
|
+
let flagsValue = 0;
|
|
375
|
+
for (let i = 0; i < this.flagDefinitions.length; i++) {
|
|
376
|
+
const flagValue = this.flagDefinitions[i].id;
|
|
377
|
+
if (this.flagChecks.at(i).value) {
|
|
378
|
+
// tslint:disable-next-line: no-bitwise
|
|
379
|
+
flagsValue |= flagValue;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return flagsValue;
|
|
383
|
+
}
|
|
384
|
+
updateMetadataForm(item) {
|
|
385
|
+
if (!item) {
|
|
386
|
+
this.metadata.reset();
|
|
387
|
+
this.updateFlagControls();
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
this.title.setValue(item.title);
|
|
391
|
+
this.sortKey.setValue(item.sortKey);
|
|
392
|
+
this.description.setValue(item.description);
|
|
393
|
+
this.facet.setValue(item.facetId);
|
|
394
|
+
this.group.setValue(item.groupId);
|
|
395
|
+
this.flags.setValue(item.flags);
|
|
396
|
+
this.updateFlagControls();
|
|
397
|
+
this.metadata.markAsPristine();
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
getTypeIdName(typeId) {
|
|
401
|
+
var _a;
|
|
402
|
+
const state = this._appQuery.getValue();
|
|
403
|
+
if (!state || !state.typeThesaurus) {
|
|
404
|
+
return typeId;
|
|
405
|
+
}
|
|
406
|
+
// strip :suffix if any
|
|
407
|
+
const i = typeId.lastIndexOf(':');
|
|
408
|
+
if (i > -1) {
|
|
409
|
+
typeId = typeId.substr(0, i);
|
|
410
|
+
}
|
|
411
|
+
const entry = (_a = state.typeThesaurus.entries) === null || _a === void 0 ? void 0 : _a.find((e) => e.id === typeId);
|
|
412
|
+
return entry ? entry.value : typeId;
|
|
413
|
+
}
|
|
414
|
+
getRoleIdName(roleId) {
|
|
415
|
+
if (!roleId || !roleId.startsWith('fr.')) {
|
|
416
|
+
return roleId;
|
|
417
|
+
}
|
|
418
|
+
return this.getTypeIdName(roleId);
|
|
419
|
+
}
|
|
420
|
+
tryTrim(value) {
|
|
421
|
+
return value ? value.trim() : value;
|
|
422
|
+
}
|
|
423
|
+
save() {
|
|
424
|
+
if (!this.metadata.valid) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
const item = Object.assign({}, this._query.getValue().item);
|
|
428
|
+
if (!item) {
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
item.title = this.tryTrim(this.title.value);
|
|
432
|
+
item.sortKey = this.sortKey.value;
|
|
433
|
+
item.description = this.tryTrim(this.description.value);
|
|
434
|
+
item.facetId = this.tryTrim(this.facet.value);
|
|
435
|
+
item.groupId = this.tryTrim(this.group.value);
|
|
436
|
+
item.flags = this.flags.value;
|
|
437
|
+
// save and reload as edited if was new
|
|
438
|
+
this._editItemService.save(item).then((saved) => {
|
|
439
|
+
this.metadata.markAsPristine();
|
|
440
|
+
if (!item.id) {
|
|
441
|
+
this.id = saved.id;
|
|
442
|
+
this._router.navigate(['/items', saved.id]);
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
partExists(typeId, roleId) {
|
|
447
|
+
const groups = this._query.getValue().partGroups;
|
|
448
|
+
if (!groups) {
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
451
|
+
return groups.some((g) => {
|
|
452
|
+
return g.parts.some((p) => p.typeId === typeId && ((!p.roleId && !roleId) || p.roleId === roleId));
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
addPart(def) {
|
|
456
|
+
if (!def && !this.newPartType.valid) {
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
if (!this.id) {
|
|
460
|
+
this._snackbar.open('Please save the item before adding parts', 'OK', {
|
|
461
|
+
duration: 3000,
|
|
462
|
+
});
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
const typeId = def ? def.typeId : this.newPartType.value.typeId;
|
|
466
|
+
const roleId = def ? def.roleId : this.newPartType.value.roleId;
|
|
467
|
+
if (this.partExists(typeId, roleId)) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
const route = this._libraryRouteService.buildPartEditorRoute(this.id, 'new', typeId, roleId);
|
|
471
|
+
// navigate to the editor
|
|
472
|
+
this._router.navigate([route.route], route.rid
|
|
473
|
+
? {
|
|
474
|
+
queryParams: {
|
|
475
|
+
rid: route.rid,
|
|
476
|
+
},
|
|
477
|
+
}
|
|
478
|
+
: {});
|
|
479
|
+
}
|
|
480
|
+
editPart(part) {
|
|
481
|
+
// build the target route to the appropriate part editor
|
|
482
|
+
const route = this._libraryRouteService.buildPartEditorRoute(part.itemId, part.id, part.typeId, part.roleId);
|
|
483
|
+
// navigate to the editor
|
|
484
|
+
this._router.navigate([route.route], route.rid
|
|
485
|
+
? {
|
|
486
|
+
queryParams: {
|
|
487
|
+
rid: route.rid,
|
|
488
|
+
},
|
|
489
|
+
}
|
|
490
|
+
: {});
|
|
491
|
+
}
|
|
492
|
+
deletePart(part) {
|
|
493
|
+
this._dialogService
|
|
494
|
+
.confirm('Confirm Deletion', `Delete part "${part.typeId}"?`)
|
|
495
|
+
.subscribe((result) => {
|
|
496
|
+
if (!result) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
// delete
|
|
500
|
+
this._editItemService.deletePart(part.id).then((_) => {
|
|
501
|
+
// once deleted, refresh new-part definitions
|
|
502
|
+
this.newPartDefinitions = this.getNewPartDefinitions();
|
|
503
|
+
}, (error) => {
|
|
504
|
+
console.error(error);
|
|
505
|
+
this._snackbar.open('Error deleting part', 'OK');
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
addLayerPart(part) {
|
|
510
|
+
let name = this.getTypeIdName(part.typeId);
|
|
511
|
+
if (part.roleId) {
|
|
512
|
+
name += ' for ' + this.getRoleIdName(part.roleId);
|
|
513
|
+
}
|
|
514
|
+
this._dialogService
|
|
515
|
+
.confirm('Confirm Addition', `Add layer "${name}"?`)
|
|
516
|
+
.subscribe((result) => {
|
|
517
|
+
if (!result) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
this._editItemService.addNewLayerPart(part.itemId, part.typeId, part.roleId);
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
setPartsScope(request) {
|
|
524
|
+
this._editItemService.setPartThesaurusScope(request.ids, request.scope);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
ItemEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ItemEditorComponent, deps: [{ token: i1$1.Router }, { token: i1$1.ActivatedRoute }, { token: i2$2.MatSnackBar }, { token: i3$2.AppQuery }, { token: i3$2.EditItemQuery }, { token: i3$2.EditItemService }, { token: i4.LibraryRouteService }, { token: i3$1.DialogService }, { token: i2$1.AuthService }, { token: i7.FormBuilder }], target: i0.ɵɵFactoryTarget.Component });
|
|
528
|
+
ItemEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.2", type: ItemEditorComponent, selector: "cadmus-item-editor", ngImport: i0, template: "<mat-card>\r\n <mat-card-header>\r\n <mat-card-title>\r\n {{ (item$ | async)?.title || \"Item\" }}\r\n </mat-card-title>\r\n <mat-card-subtitle>\r\n {{ (item$ | async)?.description }}\r\n </mat-card-subtitle>\r\n </mat-card-header>\r\n <mat-card-content *ngIf=\"!id || (item$ | async) as item\">\r\n <p *ngIf=\"id\">\r\n ID:\r\n <input\r\n [cdkCopyToClipboard]=\"item.id\"\r\n type=\"text\"\r\n readonly=\"true\"\r\n spellcheck=\"false\"\r\n matTooltip=\"Click to copy\"\r\n [value]=\"item.id\"\r\n class=\"id\"\r\n />\r\n </p>\r\n <p *ngIf=\"id\">\r\n Last saved {{ item.timeModified | amLocal | amTimeAgo }} by\r\n {{ item.userId }} on\r\n {{ item.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}.<br />\r\n Created {{ item.timeCreated | amLocal | amTimeAgo }} by\r\n {{ item.creatorId }} on\r\n {{ item.timeCreated | date: \"yyyy-MM-dd HH:mm:ss\" }}.\r\n </p>\r\n <p *ngIf=\"error$ | async as error\">\r\n <mat-error>\r\n {{ error }}\r\n </mat-error>\r\n </p>\r\n\r\n <mat-progress-bar\r\n mode=\"indeterminate\"\r\n *ngIf=\"(loading$ | async) || (saving$ | async)\"\r\n ></mat-progress-bar>\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 <!-- title -->\r\n <div>\r\n <mat-form-field>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"title\"\r\n placeholder=\"title\"\r\n formControlName=\"title\"\r\n />\r\n <mat-error\r\n *ngIf=\"\r\n title.hasError('required') && (title.touched || title.dirty)\r\n \"\r\n >enter title</mat-error\r\n >\r\n <mat-error\r\n *ngIf=\"\r\n title.hasError('maxLength') && (title.touched || title.dirty)\r\n \"\r\n >\r\n title too long</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- sortKey -->\r\n <div>\r\n <mat-form-field>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"sortKey\"\r\n placeholder=\"sort key\"\r\n formControlName=\"sortKey\"\r\n />\r\n <mat-error\r\n *ngIf=\"\r\n sortKey.hasError('required') &&\r\n (sortKey.touched || sortKey.dirty)\r\n \"\r\n >enter sort key</mat-error\r\n >\r\n <mat-error\r\n *ngIf=\"\r\n sortKey.hasError('maxLength') &&\r\n (sortKey.touched || sortKey.dirty)\r\n \"\r\n >sort key too long</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- description -->\r\n <div>\r\n <mat-form-field class=\"full-width\">\r\n <textarea\r\n rows=\"2\"\r\n matInput\r\n id=\"description\"\r\n placeholder=\"description\"\r\n formControlName=\"description\"\r\n ></textarea>\r\n <mat-error\r\n *ngIf=\"\r\n description.hasError('required') &&\r\n (description.touched || description.dirty)\r\n \"\r\n >enter description</mat-error\r\n >\r\n <mat-error\r\n *ngIf=\"\r\n description.hasError('maxLength') &&\r\n (description.touched || description.dirty)\r\n \"\r\n >description too long</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- facet -->\r\n <div>\r\n <mat-form-field style=\"width: 400px\">\r\n <mat-select\r\n placeholder=\"facet\"\r\n formControlName=\"facet\"\r\n required=\"true\"\r\n >\r\n <mat-option *ngFor=\"let f of facets$ | async\" [value]=\"f.id\">\r\n {{ f.label }}\r\n </mat-option>\r\n </mat-select>\r\n <mat-error>please select a facet</mat-error>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- group -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput formControlName=\"group\" placeholder=\"group ID\" />\r\n <mat-error\r\n *ngIf=\"\r\n group.hasError('maxLength') && (group.dirty || group.touched)\r\n \"\r\n >too long</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- flags -->\r\n <div formArrayName=\"flagChecks\" *ngIf=\"flagDefinitions\">\r\n <mat-checkbox\r\n class=\"flag\"\r\n *ngFor=\"let c of flagChecks.controls; let i = index\"\r\n [formControlName]=\"i\"\r\n >\r\n <span [style.color]=\"'#' + flagDefinitions[i].colorKey\"\r\n >⬤</span\r\n >\r\n \r\n {{ flagDefinitions[i].label }}\r\n </mat-checkbox>\r\n </div>\r\n <br />\r\n\r\n <div>\r\n <button\r\n type=\"submit\"\r\n mat-raised-button\r\n color=\"primary\"\r\n [disabled]=\"\r\n userLevel < 2 || (saving$ | async) || (loading$ | async)\r\n \"\r\n matTooltip=\"Save metadata\"\r\n *ngIf=\"\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 >\r\n <mat-icon>save</mat-icon> save\r\n </button>\r\n </div>\r\n </form>\r\n </mat-tab>\r\n\r\n <!-- parts -->\r\n <mat-tab label=\"Parts\" *ngIf=\"id\">\r\n <div class=\"new-part\">\r\n <form [formGroup]=\"newPart\">\r\n <mat-form-field>\r\n <mat-select\r\n placeholder=\"part\"\r\n formControlName=\"newPartType\"\r\n required\r\n >\r\n <mat-option *ngFor=\"let p of newPartDefinitions\" [value]=\"p\">\r\n <span [style.color]=\"'#' + p.colorKey\" class=\"new-part-icon\"\r\n >⬤</span\r\n >\r\n {{ p.name }}\r\n <span *ngIf=\"p.roleId\" class=\"new-part-role\">{{\r\n p.roleId\r\n }}</span>\r\n </mat-option>\r\n </mat-select>\r\n <mat-error>part type required</mat-error>\r\n </mat-form-field>\r\n \r\n <button\r\n mat-stroked-button\r\n color=\"primary\"\r\n type=\"button\"\r\n [disabled]=\"userLevel < 2 || (loading$ | async) || !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 add part\r\n </button>\r\n </form>\r\n </div>\r\n\r\n <mat-divider></mat-divider>\r\n\r\n <mat-expansion-panel\r\n *ngFor=\"let group of partGroups$ | async\"\r\n [expanded]=\"true\"\r\n >\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\r\n <table>\r\n <thead>\r\n <tr>\r\n <th style=\"width: 124px\"></th>\r\n <th>type</th>\r\n <th>role</th>\r\n <th fxHide.xs>modified</th>\r\n <th fxHide.xs>user</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let part of group.parts\">\r\n <!-- edit -->\r\n <td>\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n color=\"primary\"\r\n matTooltip=\"Edit this part\"\r\n [disabled]=\"(loading$ | async) || (deletingPart$ | async)\"\r\n (click)=\"editPart(part)\"\r\n >\r\n <mat-icon>create</mat-icon>\r\n </button>\r\n <!-- delete -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Delete this part\"\r\n [disabled]=\"\r\n userLevel < 2 ||\r\n (loading$ | async) ||\r\n (deletingPart$ | async)\r\n \"\r\n (click)=\"deletePart(part)\"\r\n *ngIf=\"\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 >\r\n <mat-icon color=\"warn\">delete</mat-icon>\r\n </button>\r\n <!-- copy -->\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 </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet$ | async\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"typeThesaurus$ | async\"\r\n ></cadmus-part-badge>\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet$ | async\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"typeThesaurus$ | async\"\r\n ></cadmus-part-badge>\r\n </td>\r\n <td fxHide.xs>{{ part.timeModified | amLocal | amTimeAgo }}</td>\r\n <td fxHide.xs>{{ part.userId }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n </mat-expansion-panel>\r\n\r\n <cadmus-missing-parts\r\n [partDefinitions]=\"(facet$ | async)?.partDefinitions\"\r\n [parts]=\"parts$ | async\"\r\n [typeThesaurus]=\"typeThesaurus$ | async\"\r\n (addRequest)=\"addPart($event)\"\r\n ></cadmus-missing-parts>\r\n </mat-tab>\r\n\r\n <mat-tab label=\"Layers\" *ngIf=\"id\">\r\n <table *ngIf=\"layerPartInfos$ | async as parts\">\r\n <thead>\r\n <th></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 <tr *ngFor=\"let part of parts\">\r\n <td>\r\n <button\r\n *ngIf=\"!part.isAbsent\"\r\n type=\"button\"\r\n color=\"primary\"\r\n mat-icon-button\r\n matTooltip=\"Edit this layer part\"\r\n (click)=\"editPart(part)\"\r\n >\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n <button\r\n *ngIf=\"part.isAbsent\"\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"primary\"\r\n matTooltip=\"Add this layer part\"\r\n [disabled]=\"userLevel < 2\"\r\n (click)=\"addLayerPart(part)\"\r\n >\r\n <mat-icon>add_circle</mat-icon>\r\n </button>\r\n <button\r\n *ngIf=\"!part.isAbsent\"\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"warn\"\r\n matTooltip=\"Delete this layer part\"\r\n [disabled]=\"userLevel < 2\"\r\n (click)=\"deletePart(part)\"\r\n >\r\n <mat-icon>delete</mat-icon>\r\n </button>\r\n <button\r\n *ngIf=\"!part.isAbsent\"\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 </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet$ | async\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"typeThesaurus$ | async\"\r\n ></cadmus-part-badge>\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet$ | async\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"typeThesaurus$ | async\"\r\n ></cadmus-part-badge>\r\n </td>\r\n <td\r\n [ngClass]=\"{\r\n 'count-n': part.fragmentCount,\r\n 'count-z': !part.fragmentCount\r\n }\"\r\n >\r\n {{ part.fragmentCount }}\r\n </td>\r\n <td>\r\n <span *ngIf=\"!part.isAbsent\">\r\n {{ part.timeModified | amLocal | amTimeAgo }}\r\n </span>\r\n </td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n </mat-tab>\r\n\r\n <mat-tab\r\n label=\"Th-Scopes\"\r\n *ngIf=\"parts$ | async | sort: 'typeId' | sort: 'roleId' as parts\"\r\n >\r\n <cadmus-parts-scope-editor\r\n [parts]=\"parts\"\r\n [readonly]=\"userLevel < 2 || (saving$ | async) || (loading$ | async)\"\r\n (setScopeRequest)=\"setPartsScope($event)\"\r\n ></cadmus-parts-scope-editor>\r\n </mat-tab>\r\n </mat-tab-group>\r\n </mat-card-content>\r\n</mat-card>\r\n", styles: [".full-width{width:100%}th{font-weight:normal;color:silver}div.new-part{margin-left:32px}span.new-part-role{color:gray;margin-left:8px;vertical-align:middle}span.new-part-icon{margin:0 4px;vertical-align:middle}td.count-n{text-align:center;color:#03c03c}td.count-z{text-align:center;color:#f34f41}input.id{font-family:\"Courier New\",Courier,monospace;color:gray;min-width:22em}.flag{margin-left:10px}\n"], components: [{ type: i8.MatCard, selector: "mat-card", exportAs: ["matCard"] }, { type: i8.MatCardHeader, selector: "mat-card-header" }, { type: i9$1.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { type: i10.MatTabGroup, selector: "mat-tab-group", inputs: ["color", "disableRipple"], exportAs: ["matTabGroup"] }, { type: i10.MatTab, selector: "mat-tab", inputs: ["disabled", "label", "aria-label", "aria-labelledby"], exportAs: ["matTab"] }, { type: i6.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i12.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i13.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: i5$1.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex", "aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i17.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { type: i18.MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["disabled", "expanded", "hideToggle", "togglePosition"], outputs: ["opened", "closed", "expandedChange", "afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { type: i18.MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["tabIndex", "expandedHeight", "collapsedHeight"] }, { type: i3.PartBadgeComponent, selector: "cadmus-part-badge", inputs: ["badgeType", "typeThesaurus", "facetDefinition", "partTypeIds"] }, { type: MissingPartsComponent, selector: "cadmus-missing-parts", inputs: ["partDefinitions", "parts", "typeThesaurus"], outputs: ["addRequest"] }, { type: PartsScopeEditorComponent, selector: "cadmus-parts-scope-editor", inputs: ["parts", "readonly"], outputs: ["setScopeRequest"] }], directives: [{ type: i8.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { type: i8.MatCardSubtitle, selector: "mat-card-subtitle, [mat-card-subtitle], [matCardSubtitle]" }, { type: i22.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i8.MatCardContent, selector: "mat-card-content, [mat-card-content], [matCardContent]" }, { type: i5.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { type: i24.CdkCopyToClipboard, selector: "[cdkCopyToClipboard]", inputs: ["cdkCopyToClipboard", "cdkCopyToClipboardAttempts"], outputs: ["cdkCopyToClipboardCopied"] }, { type: i6.MatError, selector: "mat-error", inputs: ["id"] }, { type: i7.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i7.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i7.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i9.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i7.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i7.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i7.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i7.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i22.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { type: i18.MatExpansionPanelTitle, selector: "mat-panel-title" }, { type: i18.MatExpansionPanelDescription, selector: "mat-panel-description" }, { type: i26.DefaultShowHideDirective, selector: " [fxShow], [fxShow.print], [fxShow.xs], [fxShow.sm], [fxShow.md], [fxShow.lg], [fxShow.xl], [fxShow.lt-sm], [fxShow.lt-md], [fxShow.lt-lg], [fxShow.lt-xl], [fxShow.gt-xs], [fxShow.gt-sm], [fxShow.gt-md], [fxShow.gt-lg], [fxHide], [fxHide.print], [fxHide.xs], [fxHide.sm], [fxHide.md], [fxHide.lg], [fxHide.xl], [fxHide.lt-sm], [fxHide.lt-md], [fxHide.lt-lg], [fxHide.lt-xl], [fxHide.gt-xs], [fxHide.gt-sm], [fxHide.gt-md], [fxHide.gt-lg]", inputs: ["fxShow", "fxShow.print", "fxShow.xs", "fxShow.sm", "fxShow.md", "fxShow.lg", "fxShow.xl", "fxShow.lt-sm", "fxShow.lt-md", "fxShow.lt-lg", "fxShow.lt-xl", "fxShow.gt-xs", "fxShow.gt-sm", "fxShow.gt-md", "fxShow.gt-lg", "fxHide", "fxHide.print", "fxHide.xs", "fxHide.sm", "fxHide.md", "fxHide.lg", "fxHide.xl", "fxHide.lt-sm", "fxHide.lt-md", "fxHide.lt-lg", "fxHide.lt-xl", "fxHide.gt-xs", "fxHide.gt-sm", "fxHide.gt-md", "fxHide.gt-lg"] }, { type: i22.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i26.DefaultClassDirective, selector: " [ngClass], [ngClass.xs], [ngClass.sm], [ngClass.md], [ngClass.lg], [ngClass.xl], [ngClass.lt-sm], [ngClass.lt-md], [ngClass.lt-lg], [ngClass.lt-xl], [ngClass.gt-xs], [ngClass.gt-sm], [ngClass.gt-md], [ngClass.gt-lg]", inputs: ["ngClass", "ngClass.xs", "ngClass.sm", "ngClass.md", "ngClass.lg", "ngClass.xl", "ngClass.lt-sm", "ngClass.lt-md", "ngClass.lt-lg", "ngClass.lt-xl", "ngClass.gt-xs", "ngClass.gt-sm", "ngClass.gt-md", "ngClass.gt-lg"] }], pipes: { "async": i22.AsyncPipe, "amTimeAgo": i11.TimeAgoPipe, "amLocal": i11.LocalTimePipe, "date": i22.DatePipe, "sort": i4.SortPipe } });
|
|
529
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ItemEditorComponent, decorators: [{
|
|
530
|
+
type: Component,
|
|
531
|
+
args: [{ selector: 'cadmus-item-editor', template: "<mat-card>\r\n <mat-card-header>\r\n <mat-card-title>\r\n {{ (item$ | async)?.title || \"Item\" }}\r\n </mat-card-title>\r\n <mat-card-subtitle>\r\n {{ (item$ | async)?.description }}\r\n </mat-card-subtitle>\r\n </mat-card-header>\r\n <mat-card-content *ngIf=\"!id || (item$ | async) as item\">\r\n <p *ngIf=\"id\">\r\n ID:\r\n <input\r\n [cdkCopyToClipboard]=\"item.id\"\r\n type=\"text\"\r\n readonly=\"true\"\r\n spellcheck=\"false\"\r\n matTooltip=\"Click to copy\"\r\n [value]=\"item.id\"\r\n class=\"id\"\r\n />\r\n </p>\r\n <p *ngIf=\"id\">\r\n Last saved {{ item.timeModified | amLocal | amTimeAgo }} by\r\n {{ item.userId }} on\r\n {{ item.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}.<br />\r\n Created {{ item.timeCreated | amLocal | amTimeAgo }} by\r\n {{ item.creatorId }} on\r\n {{ item.timeCreated | date: \"yyyy-MM-dd HH:mm:ss\" }}.\r\n </p>\r\n <p *ngIf=\"error$ | async as error\">\r\n <mat-error>\r\n {{ error }}\r\n </mat-error>\r\n </p>\r\n\r\n <mat-progress-bar\r\n mode=\"indeterminate\"\r\n *ngIf=\"(loading$ | async) || (saving$ | async)\"\r\n ></mat-progress-bar>\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 <!-- title -->\r\n <div>\r\n <mat-form-field>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"title\"\r\n placeholder=\"title\"\r\n formControlName=\"title\"\r\n />\r\n <mat-error\r\n *ngIf=\"\r\n title.hasError('required') && (title.touched || title.dirty)\r\n \"\r\n >enter title</mat-error\r\n >\r\n <mat-error\r\n *ngIf=\"\r\n title.hasError('maxLength') && (title.touched || title.dirty)\r\n \"\r\n >\r\n title too long</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- sortKey -->\r\n <div>\r\n <mat-form-field>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"sortKey\"\r\n placeholder=\"sort key\"\r\n formControlName=\"sortKey\"\r\n />\r\n <mat-error\r\n *ngIf=\"\r\n sortKey.hasError('required') &&\r\n (sortKey.touched || sortKey.dirty)\r\n \"\r\n >enter sort key</mat-error\r\n >\r\n <mat-error\r\n *ngIf=\"\r\n sortKey.hasError('maxLength') &&\r\n (sortKey.touched || sortKey.dirty)\r\n \"\r\n >sort key too long</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- description -->\r\n <div>\r\n <mat-form-field class=\"full-width\">\r\n <textarea\r\n rows=\"2\"\r\n matInput\r\n id=\"description\"\r\n placeholder=\"description\"\r\n formControlName=\"description\"\r\n ></textarea>\r\n <mat-error\r\n *ngIf=\"\r\n description.hasError('required') &&\r\n (description.touched || description.dirty)\r\n \"\r\n >enter description</mat-error\r\n >\r\n <mat-error\r\n *ngIf=\"\r\n description.hasError('maxLength') &&\r\n (description.touched || description.dirty)\r\n \"\r\n >description too long</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- facet -->\r\n <div>\r\n <mat-form-field style=\"width: 400px\">\r\n <mat-select\r\n placeholder=\"facet\"\r\n formControlName=\"facet\"\r\n required=\"true\"\r\n >\r\n <mat-option *ngFor=\"let f of facets$ | async\" [value]=\"f.id\">\r\n {{ f.label }}\r\n </mat-option>\r\n </mat-select>\r\n <mat-error>please select a facet</mat-error>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- group -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput formControlName=\"group\" placeholder=\"group ID\" />\r\n <mat-error\r\n *ngIf=\"\r\n group.hasError('maxLength') && (group.dirty || group.touched)\r\n \"\r\n >too long</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- flags -->\r\n <div formArrayName=\"flagChecks\" *ngIf=\"flagDefinitions\">\r\n <mat-checkbox\r\n class=\"flag\"\r\n *ngFor=\"let c of flagChecks.controls; let i = index\"\r\n [formControlName]=\"i\"\r\n >\r\n <span [style.color]=\"'#' + flagDefinitions[i].colorKey\"\r\n >⬤</span\r\n >\r\n \r\n {{ flagDefinitions[i].label }}\r\n </mat-checkbox>\r\n </div>\r\n <br />\r\n\r\n <div>\r\n <button\r\n type=\"submit\"\r\n mat-raised-button\r\n color=\"primary\"\r\n [disabled]=\"\r\n userLevel < 2 || (saving$ | async) || (loading$ | async)\r\n \"\r\n matTooltip=\"Save metadata\"\r\n *ngIf=\"\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 >\r\n <mat-icon>save</mat-icon> save\r\n </button>\r\n </div>\r\n </form>\r\n </mat-tab>\r\n\r\n <!-- parts -->\r\n <mat-tab label=\"Parts\" *ngIf=\"id\">\r\n <div class=\"new-part\">\r\n <form [formGroup]=\"newPart\">\r\n <mat-form-field>\r\n <mat-select\r\n placeholder=\"part\"\r\n formControlName=\"newPartType\"\r\n required\r\n >\r\n <mat-option *ngFor=\"let p of newPartDefinitions\" [value]=\"p\">\r\n <span [style.color]=\"'#' + p.colorKey\" class=\"new-part-icon\"\r\n >⬤</span\r\n >\r\n {{ p.name }}\r\n <span *ngIf=\"p.roleId\" class=\"new-part-role\">{{\r\n p.roleId\r\n }}</span>\r\n </mat-option>\r\n </mat-select>\r\n <mat-error>part type required</mat-error>\r\n </mat-form-field>\r\n \r\n <button\r\n mat-stroked-button\r\n color=\"primary\"\r\n type=\"button\"\r\n [disabled]=\"userLevel < 2 || (loading$ | async) || !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 add part\r\n </button>\r\n </form>\r\n </div>\r\n\r\n <mat-divider></mat-divider>\r\n\r\n <mat-expansion-panel\r\n *ngFor=\"let group of partGroups$ | async\"\r\n [expanded]=\"true\"\r\n >\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\r\n <table>\r\n <thead>\r\n <tr>\r\n <th style=\"width: 124px\"></th>\r\n <th>type</th>\r\n <th>role</th>\r\n <th fxHide.xs>modified</th>\r\n <th fxHide.xs>user</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let part of group.parts\">\r\n <!-- edit -->\r\n <td>\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n color=\"primary\"\r\n matTooltip=\"Edit this part\"\r\n [disabled]=\"(loading$ | async) || (deletingPart$ | async)\"\r\n (click)=\"editPart(part)\"\r\n >\r\n <mat-icon>create</mat-icon>\r\n </button>\r\n <!-- delete -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Delete this part\"\r\n [disabled]=\"\r\n userLevel < 2 ||\r\n (loading$ | async) ||\r\n (deletingPart$ | async)\r\n \"\r\n (click)=\"deletePart(part)\"\r\n *ngIf=\"\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 >\r\n <mat-icon color=\"warn\">delete</mat-icon>\r\n </button>\r\n <!-- copy -->\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 </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet$ | async\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"typeThesaurus$ | async\"\r\n ></cadmus-part-badge>\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet$ | async\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"typeThesaurus$ | async\"\r\n ></cadmus-part-badge>\r\n </td>\r\n <td fxHide.xs>{{ part.timeModified | amLocal | amTimeAgo }}</td>\r\n <td fxHide.xs>{{ part.userId }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n </mat-expansion-panel>\r\n\r\n <cadmus-missing-parts\r\n [partDefinitions]=\"(facet$ | async)?.partDefinitions\"\r\n [parts]=\"parts$ | async\"\r\n [typeThesaurus]=\"typeThesaurus$ | async\"\r\n (addRequest)=\"addPart($event)\"\r\n ></cadmus-missing-parts>\r\n </mat-tab>\r\n\r\n <mat-tab label=\"Layers\" *ngIf=\"id\">\r\n <table *ngIf=\"layerPartInfos$ | async as parts\">\r\n <thead>\r\n <th></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 <tr *ngFor=\"let part of parts\">\r\n <td>\r\n <button\r\n *ngIf=\"!part.isAbsent\"\r\n type=\"button\"\r\n color=\"primary\"\r\n mat-icon-button\r\n matTooltip=\"Edit this layer part\"\r\n (click)=\"editPart(part)\"\r\n >\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n <button\r\n *ngIf=\"part.isAbsent\"\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"primary\"\r\n matTooltip=\"Add this layer part\"\r\n [disabled]=\"userLevel < 2\"\r\n (click)=\"addLayerPart(part)\"\r\n >\r\n <mat-icon>add_circle</mat-icon>\r\n </button>\r\n <button\r\n *ngIf=\"!part.isAbsent\"\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"warn\"\r\n matTooltip=\"Delete this layer part\"\r\n [disabled]=\"userLevel < 2\"\r\n (click)=\"deletePart(part)\"\r\n >\r\n <mat-icon>delete</mat-icon>\r\n </button>\r\n <button\r\n *ngIf=\"!part.isAbsent\"\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 </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet$ | async\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"typeThesaurus$ | async\"\r\n ></cadmus-part-badge>\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet$ | async\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"typeThesaurus$ | async\"\r\n ></cadmus-part-badge>\r\n </td>\r\n <td\r\n [ngClass]=\"{\r\n 'count-n': part.fragmentCount,\r\n 'count-z': !part.fragmentCount\r\n }\"\r\n >\r\n {{ part.fragmentCount }}\r\n </td>\r\n <td>\r\n <span *ngIf=\"!part.isAbsent\">\r\n {{ part.timeModified | amLocal | amTimeAgo }}\r\n </span>\r\n </td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n </mat-tab>\r\n\r\n <mat-tab\r\n label=\"Th-Scopes\"\r\n *ngIf=\"parts$ | async | sort: 'typeId' | sort: 'roleId' as parts\"\r\n >\r\n <cadmus-parts-scope-editor\r\n [parts]=\"parts\"\r\n [readonly]=\"userLevel < 2 || (saving$ | async) || (loading$ | async)\"\r\n (setScopeRequest)=\"setPartsScope($event)\"\r\n ></cadmus-parts-scope-editor>\r\n </mat-tab>\r\n </mat-tab-group>\r\n </mat-card-content>\r\n</mat-card>\r\n", styles: [".full-width{width:100%}th{font-weight:normal;color:silver}div.new-part{margin-left:32px}span.new-part-role{color:gray;margin-left:8px;vertical-align:middle}span.new-part-icon{margin:0 4px;vertical-align:middle}td.count-n{text-align:center;color:#03c03c}td.count-z{text-align:center;color:#f34f41}input.id{font-family:\"Courier New\",Courier,monospace;color:gray;min-width:22em}.flag{margin-left:10px}\n"] }]
|
|
532
|
+
}], ctorParameters: function () { return [{ type: i1$1.Router }, { type: i1$1.ActivatedRoute }, { type: i2$2.MatSnackBar }, { type: i3$2.AppQuery }, { type: i3$2.EditItemQuery }, { type: i3$2.EditItemService }, { type: i4.LibraryRouteService }, { type: i3$1.DialogService }, { type: i2$1.AuthService }, { type: i7.FormBuilder }]; } });
|
|
533
|
+
|
|
534
|
+
// https://github.com/ng-packagr/ng-packagr/issues/778
|
|
535
|
+
const RouterModuleForChild = RouterModule.forChild([
|
|
536
|
+
{ path: '', pathMatch: 'full', component: ItemEditorComponent },
|
|
537
|
+
]);
|
|
538
|
+
class CadmusItemEditorModule {
|
|
539
|
+
}
|
|
540
|
+
CadmusItemEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CadmusItemEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
541
|
+
CadmusItemEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CadmusItemEditorModule, declarations: [ItemEditorComponent,
|
|
542
|
+
MissingPartsComponent,
|
|
543
|
+
PartsScopeEditorComponent], imports: [CommonModule,
|
|
544
|
+
ReactiveFormsModule,
|
|
545
|
+
FormsModule, i1$1.RouterModule, ClipboardModule,
|
|
546
|
+
MomentModule,
|
|
547
|
+
// cadmus
|
|
548
|
+
CadmusCoreModule,
|
|
549
|
+
CadmusMaterialModule,
|
|
550
|
+
CadmusApiModule,
|
|
551
|
+
CadmusUiModule,
|
|
552
|
+
CadmusStateModule,
|
|
553
|
+
NgToolsModule,
|
|
554
|
+
NgMatToolsModule], exports: [ItemEditorComponent] });
|
|
555
|
+
CadmusItemEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CadmusItemEditorModule, imports: [[
|
|
556
|
+
CommonModule,
|
|
557
|
+
ReactiveFormsModule,
|
|
558
|
+
FormsModule,
|
|
559
|
+
RouterModuleForChild,
|
|
560
|
+
ClipboardModule,
|
|
561
|
+
MomentModule,
|
|
562
|
+
// cadmus
|
|
563
|
+
CadmusCoreModule,
|
|
564
|
+
CadmusMaterialModule,
|
|
565
|
+
CadmusApiModule,
|
|
566
|
+
CadmusUiModule,
|
|
567
|
+
CadmusStateModule,
|
|
568
|
+
NgToolsModule,
|
|
569
|
+
NgMatToolsModule
|
|
570
|
+
]] });
|
|
571
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CadmusItemEditorModule, decorators: [{
|
|
572
|
+
type: NgModule,
|
|
573
|
+
args: [{
|
|
574
|
+
imports: [
|
|
575
|
+
CommonModule,
|
|
576
|
+
ReactiveFormsModule,
|
|
577
|
+
FormsModule,
|
|
578
|
+
RouterModuleForChild,
|
|
579
|
+
ClipboardModule,
|
|
580
|
+
MomentModule,
|
|
581
|
+
// cadmus
|
|
582
|
+
CadmusCoreModule,
|
|
583
|
+
CadmusMaterialModule,
|
|
584
|
+
CadmusApiModule,
|
|
585
|
+
CadmusUiModule,
|
|
586
|
+
CadmusStateModule,
|
|
587
|
+
NgToolsModule,
|
|
588
|
+
NgMatToolsModule
|
|
589
|
+
],
|
|
590
|
+
declarations: [
|
|
591
|
+
ItemEditorComponent,
|
|
592
|
+
MissingPartsComponent,
|
|
593
|
+
PartsScopeEditorComponent,
|
|
594
|
+
],
|
|
595
|
+
exports: [ItemEditorComponent],
|
|
596
|
+
}]
|
|
597
|
+
}] });
|
|
598
|
+
|
|
599
|
+
/*
|
|
600
|
+
* Public API Surface of cadmus-item-editor
|
|
601
|
+
*/
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Generated bundle index. Do not edit.
|
|
605
|
+
*/
|
|
606
|
+
|
|
607
|
+
export { CadmusItemEditorModule, ItemEditorComponent, RouterModuleForChild };
|