@myrmidon/cadmus-item-editor 2.0.6 → 5.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.
- package/esm2022/lib/cadmus-item-editor.module.mjs +128 -0
- package/esm2022/lib/has-preview.pipe.mjs +48 -0
- package/esm2022/lib/item-editor/item-editor.component.mjs +380 -0
- package/esm2022/lib/missing-parts/missing-parts.component.mjs +72 -0
- package/esm2022/lib/parts-scope-editor/parts-scope-editor.component.mjs +125 -0
- package/esm2022/lib/state/edited-item.repository.mjs +333 -0
- package/{esm2020 → esm2022}/myrmidon-cadmus-item-editor.mjs +4 -4
- package/{esm2020 → esm2022}/public-api.mjs +6 -6
- package/{fesm2020 → fesm2022}/myrmidon-cadmus-item-editor.mjs +981 -977
- package/fesm2022/myrmidon-cadmus-item-editor.mjs.map +1 -0
- package/index.d.ts +5 -5
- package/lib/cadmus-item-editor.module.d.ts +34 -34
- package/lib/has-preview.pipe.d.ts +27 -27
- package/lib/item-editor/item-editor.component.d.ts +88 -88
- package/lib/missing-parts/missing-parts.component.d.ts +25 -25
- package/lib/parts-scope-editor/parts-scope-editor.component.d.ts +44 -41
- package/lib/state/edited-item.repository.d.ts +102 -102
- package/package.json +8 -14
- package/public-api.d.ts +3 -3
- package/esm2020/lib/cadmus-item-editor.module.mjs +0 -127
- package/esm2020/lib/has-preview.pipe.mjs +0 -47
- package/esm2020/lib/item-editor/item-editor.component.mjs +0 -379
- package/esm2020/lib/missing-parts/missing-parts.component.mjs +0 -71
- package/esm2020/lib/parts-scope-editor/parts-scope-editor.component.mjs +0 -118
- package/esm2020/lib/state/edited-item.repository.mjs +0 -332
- package/fesm2015/myrmidon-cadmus-item-editor.mjs +0 -1038
- package/fesm2015/myrmidon-cadmus-item-editor.mjs.map +0 -1
- package/fesm2020/myrmidon-cadmus-item-editor.mjs.map +0 -1
|
@@ -25,7 +25,7 @@ import * as i12 from '@angular/cdk/clipboard';
|
|
|
25
25
|
import { ClipboardModule } from '@angular/cdk/clipboard';
|
|
26
26
|
import * as i13 from '@angular/material/button';
|
|
27
27
|
import { MatButtonModule } from '@angular/material/button';
|
|
28
|
-
import * as
|
|
28
|
+
import * as i9 from '@angular/material/checkbox';
|
|
29
29
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
30
30
|
import * as i15 from '@angular/material/card';
|
|
31
31
|
import { MatCardModule } from '@angular/material/card';
|
|
@@ -33,11 +33,11 @@ import * as i16 from '@angular/material/divider';
|
|
|
33
33
|
import { MatDividerModule } from '@angular/material/divider';
|
|
34
34
|
import * as i17 from '@angular/material/expansion';
|
|
35
35
|
import { MatExpansionModule } from '@angular/material/expansion';
|
|
36
|
-
import * as
|
|
36
|
+
import * as i10$1 from '@angular/material/form-field';
|
|
37
37
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
38
38
|
import * as i3 from '@angular/material/icon';
|
|
39
39
|
import { MatIconModule } from '@angular/material/icon';
|
|
40
|
-
import * as
|
|
40
|
+
import * as i11$1 from '@angular/material/input';
|
|
41
41
|
import { MatInputModule } from '@angular/material/input';
|
|
42
42
|
import * as i21 from '@angular/material/progress-bar';
|
|
43
43
|
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
@@ -52,995 +52,999 @@ import * as i5 from '@myrmidon/cadmus-ui';
|
|
|
52
52
|
import { CustomValidators, CadmusUiModule } from '@myrmidon/cadmus-ui';
|
|
53
53
|
import { NgToolsModule } from '@myrmidon/ng-tools';
|
|
54
54
|
|
|
55
|
-
/**
|
|
56
|
-
* Edited item ELF repository.
|
|
57
|
-
*/
|
|
58
|
-
class EditedItemRepository {
|
|
59
|
-
// public status$: Observable<StatusState>;
|
|
60
|
-
constructor(_appRepository, _itemService) {
|
|
61
|
-
this._appRepository = _appRepository;
|
|
62
|
-
this._itemService = _itemService;
|
|
63
|
-
this._store = createStore({ name: 'edited-item' }, withProps({
|
|
64
|
-
parts: [],
|
|
65
|
-
partGroups: [],
|
|
66
|
-
layerPartInfos: [],
|
|
67
|
-
newPartDefinitions: [],
|
|
68
|
-
}), withRequestsStatus());
|
|
69
|
-
this.item$ = this._store.pipe(select((state) => state.item));
|
|
70
|
-
this.parts$ = this._store.pipe(select((state) => state.parts));
|
|
71
|
-
this.partGroups$ = this._store.pipe(select((state) => state.partGroups));
|
|
72
|
-
this.layers$ = this._store.pipe(select((state) => state.layerPartInfos));
|
|
73
|
-
this.facet$ = this._store.pipe(select((state) => state.facet));
|
|
74
|
-
this.newPartDefinitions$ = this._store.pipe(select((state) => state.newPartDefinitions));
|
|
75
|
-
// this.status$ = this._store.pipe(selectRequestStatus('edited-item'));
|
|
76
|
-
}
|
|
77
|
-
getValue() {
|
|
78
|
-
return this._store.getValue();
|
|
79
|
-
}
|
|
80
|
-
getItem() {
|
|
81
|
-
return this._store.query((state) => state.item);
|
|
82
|
-
}
|
|
83
|
-
getFacet() {
|
|
84
|
-
return this._store.query((state) => state.facet);
|
|
85
|
-
}
|
|
86
|
-
getExistingPartTypeAndRoleIds() {
|
|
87
|
-
const groups = this.getPartGroups();
|
|
88
|
-
if (!groups) {
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
const results = [];
|
|
92
|
-
for (const group of groups) {
|
|
93
|
-
for (const part of group.parts) {
|
|
94
|
-
results.push({
|
|
95
|
-
typeId: part.typeId,
|
|
96
|
-
roleId: part.roleId,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return results;
|
|
101
|
-
}
|
|
102
|
-
getNewPartDefinitions() {
|
|
103
|
-
const facet = this.getFacet();
|
|
104
|
-
if (!facet) {
|
|
105
|
-
return [];
|
|
106
|
-
}
|
|
107
|
-
const existingTypeRoleIds = this.getExistingPartTypeAndRoleIds();
|
|
108
|
-
const defs = [];
|
|
109
|
-
for (const def of facet.partDefinitions) {
|
|
110
|
-
// exclude layer parts, as these are in the layers tab
|
|
111
|
-
if (def.roleId?.startsWith('fr.')) {
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
// exclude parts present in the item
|
|
115
|
-
if (existingTypeRoleIds.find((tr) => {
|
|
116
|
-
return (tr.typeId === def.typeId &&
|
|
117
|
-
((!tr.roleId && !def.roleId) || tr.roleId === def.roleId));
|
|
118
|
-
})) {
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
defs.push(def);
|
|
122
|
-
}
|
|
123
|
-
// sort by sort key
|
|
124
|
-
defs.sort((a, b) => {
|
|
125
|
-
return a.sortKey.localeCompare(b.sortKey);
|
|
126
|
-
});
|
|
127
|
-
return defs;
|
|
128
|
-
}
|
|
129
|
-
getPartGroups() {
|
|
130
|
-
return this._store.query((state) => state.partGroups);
|
|
131
|
-
}
|
|
132
|
-
pickDefaultFacet(facets) {
|
|
133
|
-
if (!facets.length) {
|
|
134
|
-
return undefined;
|
|
135
|
-
}
|
|
136
|
-
// if there is a facet with id="default", pick it
|
|
137
|
-
const defaultFacet = facets.find((f) => f.id === 'default');
|
|
138
|
-
if (defaultFacet) {
|
|
139
|
-
return defaultFacet;
|
|
140
|
-
}
|
|
141
|
-
// else just pick the first in the list
|
|
142
|
-
return facets[0];
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Load the specified item or a new item.
|
|
146
|
-
*
|
|
147
|
-
* @param itemId The item ID, or falsy for a new item.
|
|
148
|
-
*/
|
|
149
|
-
load(itemId) {
|
|
150
|
-
const app = this._appRepository.getValue();
|
|
151
|
-
this._store.update(updateRequestStatus('edited-item', 'pending'));
|
|
152
|
-
if (!itemId) {
|
|
153
|
-
// new item
|
|
154
|
-
this._itemService
|
|
155
|
-
.getItemLayerInfo('new', true)
|
|
156
|
-
.pipe(take(1))
|
|
157
|
-
.subscribe((layers) => {
|
|
158
|
-
this._store.update(updateRequestStatus('edited-item', 'success'));
|
|
159
|
-
this._store.update((state) => ({
|
|
160
|
-
...state,
|
|
161
|
-
item: {
|
|
162
|
-
id: '',
|
|
163
|
-
title: '',
|
|
164
|
-
description: '',
|
|
165
|
-
facetId: '',
|
|
166
|
-
groupId: '',
|
|
167
|
-
sortKey: '',
|
|
168
|
-
flags: 0,
|
|
169
|
-
timeCreated: new Date(),
|
|
170
|
-
creatorId: '',
|
|
171
|
-
timeModified: new Date(),
|
|
172
|
-
userId: '',
|
|
173
|
-
},
|
|
174
|
-
parts: [],
|
|
175
|
-
partGroups: [],
|
|
176
|
-
layerPartInfos: layers,
|
|
177
|
-
facet: this.pickDefaultFacet(app.facets),
|
|
178
|
-
}));
|
|
179
|
-
this._store.update(setProp('newPartDefinitions', this.getNewPartDefinitions()));
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
// existing item
|
|
184
|
-
forkJoin({
|
|
185
|
-
item: this._itemService.getItem(itemId, true),
|
|
186
|
-
layers: this._itemService.getItemLayerInfo(itemId, true),
|
|
187
|
-
})
|
|
188
|
-
.pipe(take(1))
|
|
189
|
-
.subscribe({
|
|
190
|
-
next: (result) => {
|
|
191
|
-
this._store.update(updateRequestStatus('edited-item', 'success'));
|
|
192
|
-
const itemFacet = app.facets.find((f) => {
|
|
193
|
-
return f.id === result.item.facetId;
|
|
194
|
-
});
|
|
195
|
-
const facetParts = itemFacet ? itemFacet.partDefinitions : [];
|
|
196
|
-
this._store.update((state) => ({
|
|
197
|
-
...state,
|
|
198
|
-
item: result.item,
|
|
199
|
-
parts: result.item.parts || [],
|
|
200
|
-
partGroups: this._itemService.groupParts(result.item.parts || [], facetParts),
|
|
201
|
-
layerPartInfos: result.layers,
|
|
202
|
-
facet: itemFacet,
|
|
203
|
-
}));
|
|
204
|
-
this._store.update(setProp('newPartDefinitions', this.getNewPartDefinitions()));
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Ensure that the item with the specified ID is loaded.
|
|
211
|
-
*
|
|
212
|
-
* @param id The item ID.
|
|
213
|
-
*/
|
|
214
|
-
ensureItemLoaded(id) {
|
|
215
|
-
if (this.getItem()?.id === id) {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
this.load(id);
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Save the specified item in the backend and update this store.
|
|
222
|
-
*
|
|
223
|
-
* @param item The item.
|
|
224
|
-
* @returns Promise with saved item.
|
|
225
|
-
*/
|
|
226
|
-
save(item) {
|
|
227
|
-
return new Promise((resolve, reject) => {
|
|
228
|
-
this._itemService
|
|
229
|
-
.addItem(item)
|
|
230
|
-
.pipe(take(1))
|
|
231
|
-
.subscribe({
|
|
232
|
-
next: (saved) => {
|
|
233
|
-
// update the item and the selected facet from it;
|
|
234
|
-
// this is required when the item was new, and thus loaded
|
|
235
|
-
// with the default facet before saving it
|
|
236
|
-
const app = this._appRepository.getValue();
|
|
237
|
-
const itemFacet = app.facets.find((f) => {
|
|
238
|
-
return f.id === saved.facetId;
|
|
239
|
-
});
|
|
240
|
-
this._store.update((state) => ({
|
|
241
|
-
...state,
|
|
242
|
-
item: saved,
|
|
243
|
-
facet: itemFacet,
|
|
244
|
-
}));
|
|
245
|
-
// new-parts definitions
|
|
246
|
-
this._store.update(setProp('newPartDefinitions', this.getNewPartDefinitions()));
|
|
247
|
-
resolve(saved);
|
|
248
|
-
},
|
|
249
|
-
error: (error) => {
|
|
250
|
-
if (error) {
|
|
251
|
-
console.error(JSON.stringify(error));
|
|
252
|
-
}
|
|
253
|
-
reject({ message: 'Error saving item ' + item.id, error: error });
|
|
254
|
-
},
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Delete the specified part from this edited item.
|
|
260
|
-
*
|
|
261
|
-
* @param id The part's ID.
|
|
262
|
-
* @returns Promise with part ID.
|
|
263
|
-
*/
|
|
264
|
-
deletePart(id) {
|
|
265
|
-
return new Promise((resolve, reject) => {
|
|
266
|
-
const itemId = this._store.getValue().item?.id;
|
|
267
|
-
if (!itemId) {
|
|
268
|
-
reject({
|
|
269
|
-
message: 'Cannot delete part of unsaved item',
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
this._itemService
|
|
273
|
-
.deletePart(id)
|
|
274
|
-
.pipe(take(1))
|
|
275
|
-
.subscribe({
|
|
276
|
-
next: (_) => {
|
|
277
|
-
this.load(itemId);
|
|
278
|
-
resolve(id);
|
|
279
|
-
},
|
|
280
|
-
error: (error) => {
|
|
281
|
-
if (error) {
|
|
282
|
-
console.error(JSON.stringify(error));
|
|
283
|
-
}
|
|
284
|
-
reject({
|
|
285
|
-
message: "Error deleting item's part " + id,
|
|
286
|
-
error: error,
|
|
287
|
-
});
|
|
288
|
-
},
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Add a new layer part to this item.
|
|
294
|
-
*
|
|
295
|
-
* @param typeId The part type ID.
|
|
296
|
-
* @param roleId The part role ID.
|
|
297
|
-
* @returns Promise with new part.
|
|
298
|
-
*/
|
|
299
|
-
addNewLayerPart(typeId, roleId) {
|
|
300
|
-
return new Promise((resolve, reject) => {
|
|
301
|
-
const itemId = this._store.getValue().item?.id;
|
|
302
|
-
if (!itemId) {
|
|
303
|
-
reject({
|
|
304
|
-
message: 'Cannot add part to unsaved item',
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
const part = {
|
|
308
|
-
itemId: itemId,
|
|
309
|
-
typeId,
|
|
310
|
-
roleId,
|
|
311
|
-
id: '',
|
|
312
|
-
creatorId: '',
|
|
313
|
-
userId: '',
|
|
314
|
-
timeCreated: new Date(),
|
|
315
|
-
timeModified: new Date(),
|
|
316
|
-
};
|
|
317
|
-
this._itemService
|
|
318
|
-
.addPart(part)
|
|
319
|
-
.pipe(take(1))
|
|
320
|
-
.subscribe({
|
|
321
|
-
next: (part) => {
|
|
322
|
-
this.load(itemId);
|
|
323
|
-
resolve(part);
|
|
324
|
-
},
|
|
325
|
-
error: (error) => {
|
|
326
|
-
if (error) {
|
|
327
|
-
console.error(JSON.stringify(error));
|
|
328
|
-
}
|
|
329
|
-
reject({
|
|
330
|
-
message: 'Error adding new layer part for item ' + itemId,
|
|
331
|
-
error: error,
|
|
332
|
-
});
|
|
333
|
-
},
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Set the scope for the specified parts in this item.
|
|
339
|
-
*
|
|
340
|
-
* @param ids The part IDs.
|
|
341
|
-
* @param scope The scope to set.
|
|
342
|
-
* @returns Promise.
|
|
343
|
-
*/
|
|
344
|
-
setPartThesaurusScope(ids, scope) {
|
|
345
|
-
return new Promise((resolve, reject) => {
|
|
346
|
-
const itemId = this._store.getValue().item?.id;
|
|
347
|
-
if (!itemId) {
|
|
348
|
-
reject({
|
|
349
|
-
message: 'Cannot set scope for unsaved item',
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
this._itemService
|
|
353
|
-
.setPartThesaurusScope(ids, scope)
|
|
354
|
-
.pipe(take(1))
|
|
355
|
-
.subscribe({
|
|
356
|
-
next: (_) => {
|
|
357
|
-
this.load(itemId);
|
|
358
|
-
resolve(true);
|
|
359
|
-
},
|
|
360
|
-
error: (error) => {
|
|
361
|
-
if (error) {
|
|
362
|
-
console.error(JSON.stringify(error));
|
|
363
|
-
}
|
|
364
|
-
reject({
|
|
365
|
-
message: "Error setting item's part scope",
|
|
366
|
-
error: error,
|
|
367
|
-
});
|
|
368
|
-
},
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
376
|
-
type: Injectable,
|
|
377
|
-
args: [{ providedIn: 'root' }]
|
|
55
|
+
/**
|
|
56
|
+
* Edited item ELF repository.
|
|
57
|
+
*/
|
|
58
|
+
class EditedItemRepository {
|
|
59
|
+
// public status$: Observable<StatusState>;
|
|
60
|
+
constructor(_appRepository, _itemService) {
|
|
61
|
+
this._appRepository = _appRepository;
|
|
62
|
+
this._itemService = _itemService;
|
|
63
|
+
this._store = createStore({ name: 'edited-item' }, withProps({
|
|
64
|
+
parts: [],
|
|
65
|
+
partGroups: [],
|
|
66
|
+
layerPartInfos: [],
|
|
67
|
+
newPartDefinitions: [],
|
|
68
|
+
}), withRequestsStatus());
|
|
69
|
+
this.item$ = this._store.pipe(select((state) => state.item));
|
|
70
|
+
this.parts$ = this._store.pipe(select((state) => state.parts));
|
|
71
|
+
this.partGroups$ = this._store.pipe(select((state) => state.partGroups));
|
|
72
|
+
this.layers$ = this._store.pipe(select((state) => state.layerPartInfos));
|
|
73
|
+
this.facet$ = this._store.pipe(select((state) => state.facet));
|
|
74
|
+
this.newPartDefinitions$ = this._store.pipe(select((state) => state.newPartDefinitions));
|
|
75
|
+
// this.status$ = this._store.pipe(selectRequestStatus('edited-item'));
|
|
76
|
+
}
|
|
77
|
+
getValue() {
|
|
78
|
+
return this._store.getValue();
|
|
79
|
+
}
|
|
80
|
+
getItem() {
|
|
81
|
+
return this._store.query((state) => state.item);
|
|
82
|
+
}
|
|
83
|
+
getFacet() {
|
|
84
|
+
return this._store.query((state) => state.facet);
|
|
85
|
+
}
|
|
86
|
+
getExistingPartTypeAndRoleIds() {
|
|
87
|
+
const groups = this.getPartGroups();
|
|
88
|
+
if (!groups) {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
const results = [];
|
|
92
|
+
for (const group of groups) {
|
|
93
|
+
for (const part of group.parts) {
|
|
94
|
+
results.push({
|
|
95
|
+
typeId: part.typeId,
|
|
96
|
+
roleId: part.roleId,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return results;
|
|
101
|
+
}
|
|
102
|
+
getNewPartDefinitions() {
|
|
103
|
+
const facet = this.getFacet();
|
|
104
|
+
if (!facet) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
const existingTypeRoleIds = this.getExistingPartTypeAndRoleIds();
|
|
108
|
+
const defs = [];
|
|
109
|
+
for (const def of facet.partDefinitions) {
|
|
110
|
+
// exclude layer parts, as these are in the layers tab
|
|
111
|
+
if (def.roleId?.startsWith('fr.')) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
// exclude parts present in the item
|
|
115
|
+
if (existingTypeRoleIds.find((tr) => {
|
|
116
|
+
return (tr.typeId === def.typeId &&
|
|
117
|
+
((!tr.roleId && !def.roleId) || tr.roleId === def.roleId));
|
|
118
|
+
})) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
defs.push(def);
|
|
122
|
+
}
|
|
123
|
+
// sort by sort key
|
|
124
|
+
defs.sort((a, b) => {
|
|
125
|
+
return a.sortKey.localeCompare(b.sortKey);
|
|
126
|
+
});
|
|
127
|
+
return defs;
|
|
128
|
+
}
|
|
129
|
+
getPartGroups() {
|
|
130
|
+
return this._store.query((state) => state.partGroups);
|
|
131
|
+
}
|
|
132
|
+
pickDefaultFacet(facets) {
|
|
133
|
+
if (!facets.length) {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
// if there is a facet with id="default", pick it
|
|
137
|
+
const defaultFacet = facets.find((f) => f.id === 'default');
|
|
138
|
+
if (defaultFacet) {
|
|
139
|
+
return defaultFacet;
|
|
140
|
+
}
|
|
141
|
+
// else just pick the first in the list
|
|
142
|
+
return facets[0];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Load the specified item or a new item.
|
|
146
|
+
*
|
|
147
|
+
* @param itemId The item ID, or falsy for a new item.
|
|
148
|
+
*/
|
|
149
|
+
load(itemId) {
|
|
150
|
+
const app = this._appRepository.getValue();
|
|
151
|
+
this._store.update(updateRequestStatus('edited-item', 'pending'));
|
|
152
|
+
if (!itemId) {
|
|
153
|
+
// new item
|
|
154
|
+
this._itemService
|
|
155
|
+
.getItemLayerInfo('new', true)
|
|
156
|
+
.pipe(take(1))
|
|
157
|
+
.subscribe((layers) => {
|
|
158
|
+
this._store.update(updateRequestStatus('edited-item', 'success'));
|
|
159
|
+
this._store.update((state) => ({
|
|
160
|
+
...state,
|
|
161
|
+
item: {
|
|
162
|
+
id: '',
|
|
163
|
+
title: '',
|
|
164
|
+
description: '',
|
|
165
|
+
facetId: '',
|
|
166
|
+
groupId: '',
|
|
167
|
+
sortKey: '',
|
|
168
|
+
flags: 0,
|
|
169
|
+
timeCreated: new Date(),
|
|
170
|
+
creatorId: '',
|
|
171
|
+
timeModified: new Date(),
|
|
172
|
+
userId: '',
|
|
173
|
+
},
|
|
174
|
+
parts: [],
|
|
175
|
+
partGroups: [],
|
|
176
|
+
layerPartInfos: layers,
|
|
177
|
+
facet: this.pickDefaultFacet(app.facets),
|
|
178
|
+
}));
|
|
179
|
+
this._store.update(setProp('newPartDefinitions', this.getNewPartDefinitions()));
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
// existing item
|
|
184
|
+
forkJoin({
|
|
185
|
+
item: this._itemService.getItem(itemId, true),
|
|
186
|
+
layers: this._itemService.getItemLayerInfo(itemId, true),
|
|
187
|
+
})
|
|
188
|
+
.pipe(take(1))
|
|
189
|
+
.subscribe({
|
|
190
|
+
next: (result) => {
|
|
191
|
+
this._store.update(updateRequestStatus('edited-item', 'success'));
|
|
192
|
+
const itemFacet = app.facets.find((f) => {
|
|
193
|
+
return f.id === result.item.facetId;
|
|
194
|
+
});
|
|
195
|
+
const facetParts = itemFacet ? itemFacet.partDefinitions : [];
|
|
196
|
+
this._store.update((state) => ({
|
|
197
|
+
...state,
|
|
198
|
+
item: result.item,
|
|
199
|
+
parts: result.item.parts || [],
|
|
200
|
+
partGroups: this._itemService.groupParts(result.item.parts || [], facetParts),
|
|
201
|
+
layerPartInfos: result.layers,
|
|
202
|
+
facet: itemFacet,
|
|
203
|
+
}));
|
|
204
|
+
this._store.update(setProp('newPartDefinitions', this.getNewPartDefinitions()));
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Ensure that the item with the specified ID is loaded.
|
|
211
|
+
*
|
|
212
|
+
* @param id The item ID.
|
|
213
|
+
*/
|
|
214
|
+
ensureItemLoaded(id) {
|
|
215
|
+
if (this.getItem()?.id === id) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
this.load(id);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Save the specified item in the backend and update this store.
|
|
222
|
+
*
|
|
223
|
+
* @param item The item.
|
|
224
|
+
* @returns Promise with saved item.
|
|
225
|
+
*/
|
|
226
|
+
save(item) {
|
|
227
|
+
return new Promise((resolve, reject) => {
|
|
228
|
+
this._itemService
|
|
229
|
+
.addItem(item)
|
|
230
|
+
.pipe(take(1))
|
|
231
|
+
.subscribe({
|
|
232
|
+
next: (saved) => {
|
|
233
|
+
// update the item and the selected facet from it;
|
|
234
|
+
// this is required when the item was new, and thus loaded
|
|
235
|
+
// with the default facet before saving it
|
|
236
|
+
const app = this._appRepository.getValue();
|
|
237
|
+
const itemFacet = app.facets.find((f) => {
|
|
238
|
+
return f.id === saved.facetId;
|
|
239
|
+
});
|
|
240
|
+
this._store.update((state) => ({
|
|
241
|
+
...state,
|
|
242
|
+
item: saved,
|
|
243
|
+
facet: itemFacet,
|
|
244
|
+
}));
|
|
245
|
+
// new-parts definitions
|
|
246
|
+
this._store.update(setProp('newPartDefinitions', this.getNewPartDefinitions()));
|
|
247
|
+
resolve(saved);
|
|
248
|
+
},
|
|
249
|
+
error: (error) => {
|
|
250
|
+
if (error) {
|
|
251
|
+
console.error(JSON.stringify(error));
|
|
252
|
+
}
|
|
253
|
+
reject({ message: 'Error saving item ' + item.id, error: error });
|
|
254
|
+
},
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Delete the specified part from this edited item.
|
|
260
|
+
*
|
|
261
|
+
* @param id The part's ID.
|
|
262
|
+
* @returns Promise with part ID.
|
|
263
|
+
*/
|
|
264
|
+
deletePart(id) {
|
|
265
|
+
return new Promise((resolve, reject) => {
|
|
266
|
+
const itemId = this._store.getValue().item?.id;
|
|
267
|
+
if (!itemId) {
|
|
268
|
+
reject({
|
|
269
|
+
message: 'Cannot delete part of unsaved item',
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
this._itemService
|
|
273
|
+
.deletePart(id)
|
|
274
|
+
.pipe(take(1))
|
|
275
|
+
.subscribe({
|
|
276
|
+
next: (_) => {
|
|
277
|
+
this.load(itemId);
|
|
278
|
+
resolve(id);
|
|
279
|
+
},
|
|
280
|
+
error: (error) => {
|
|
281
|
+
if (error) {
|
|
282
|
+
console.error(JSON.stringify(error));
|
|
283
|
+
}
|
|
284
|
+
reject({
|
|
285
|
+
message: "Error deleting item's part " + id,
|
|
286
|
+
error: error,
|
|
287
|
+
});
|
|
288
|
+
},
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Add a new layer part to this item.
|
|
294
|
+
*
|
|
295
|
+
* @param typeId The part type ID.
|
|
296
|
+
* @param roleId The part role ID.
|
|
297
|
+
* @returns Promise with new part.
|
|
298
|
+
*/
|
|
299
|
+
addNewLayerPart(typeId, roleId) {
|
|
300
|
+
return new Promise((resolve, reject) => {
|
|
301
|
+
const itemId = this._store.getValue().item?.id;
|
|
302
|
+
if (!itemId) {
|
|
303
|
+
reject({
|
|
304
|
+
message: 'Cannot add part to unsaved item',
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
const part = {
|
|
308
|
+
itemId: itemId,
|
|
309
|
+
typeId,
|
|
310
|
+
roleId,
|
|
311
|
+
id: '',
|
|
312
|
+
creatorId: '',
|
|
313
|
+
userId: '',
|
|
314
|
+
timeCreated: new Date(),
|
|
315
|
+
timeModified: new Date(),
|
|
316
|
+
};
|
|
317
|
+
this._itemService
|
|
318
|
+
.addPart(part)
|
|
319
|
+
.pipe(take(1))
|
|
320
|
+
.subscribe({
|
|
321
|
+
next: (part) => {
|
|
322
|
+
this.load(itemId);
|
|
323
|
+
resolve(part);
|
|
324
|
+
},
|
|
325
|
+
error: (error) => {
|
|
326
|
+
if (error) {
|
|
327
|
+
console.error(JSON.stringify(error));
|
|
328
|
+
}
|
|
329
|
+
reject({
|
|
330
|
+
message: 'Error adding new layer part for item ' + itemId,
|
|
331
|
+
error: error,
|
|
332
|
+
});
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Set the scope for the specified parts in this item.
|
|
339
|
+
*
|
|
340
|
+
* @param ids The part IDs.
|
|
341
|
+
* @param scope The scope to set.
|
|
342
|
+
* @returns Promise.
|
|
343
|
+
*/
|
|
344
|
+
setPartThesaurusScope(ids, scope) {
|
|
345
|
+
return new Promise((resolve, reject) => {
|
|
346
|
+
const itemId = this._store.getValue().item?.id;
|
|
347
|
+
if (!itemId) {
|
|
348
|
+
reject({
|
|
349
|
+
message: 'Cannot set scope for unsaved item',
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
this._itemService
|
|
353
|
+
.setPartThesaurusScope(ids, scope)
|
|
354
|
+
.pipe(take(1))
|
|
355
|
+
.subscribe({
|
|
356
|
+
next: (_) => {
|
|
357
|
+
this.load(itemId);
|
|
358
|
+
resolve(true);
|
|
359
|
+
},
|
|
360
|
+
error: (error) => {
|
|
361
|
+
if (error) {
|
|
362
|
+
console.error(JSON.stringify(error));
|
|
363
|
+
}
|
|
364
|
+
reject({
|
|
365
|
+
message: "Error setting item's part scope",
|
|
366
|
+
error: error,
|
|
367
|
+
});
|
|
368
|
+
},
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: EditedItemRepository, deps: [{ token: i1.AppRepository }, { token: i2.ItemService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
373
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: EditedItemRepository, providedIn: 'root' }); }
|
|
374
|
+
}
|
|
375
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: EditedItemRepository, decorators: [{
|
|
376
|
+
type: Injectable,
|
|
377
|
+
args: [{ providedIn: 'root' }]
|
|
378
378
|
}], ctorParameters: function () { return [{ type: i1.AppRepository }, { type: i2.ItemService }]; } });
|
|
379
379
|
|
|
380
|
-
class MissingPartsComponent {
|
|
381
|
-
|
|
382
|
-
this.
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
this.
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
this.
|
|
407
|
-
this.
|
|
408
|
-
}
|
|
409
|
-
ngOnInit() { }
|
|
410
|
-
isPartPresent(typeId, roleId) {
|
|
411
|
-
if (!this._partDefinitions) {
|
|
412
|
-
return false;
|
|
413
|
-
}
|
|
414
|
-
return this._partDefinitions.some((d) => d.typeId === typeId && d.roleId === roleId);
|
|
415
|
-
}
|
|
416
|
-
updateMissing() {
|
|
417
|
-
this.missingDefinitions.length = 0;
|
|
418
|
-
if (!this._partDefinitions) {
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
for (let i = 0; i < this._partDefinitions.length; i++) {
|
|
422
|
-
const def = this._partDefinitions[i];
|
|
423
|
-
if (!this.isPartPresent(def.typeId, def.roleId)) {
|
|
424
|
-
this.missingDefinitions.push(def);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
432
|
-
type: Component,
|
|
433
|
-
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]=\"$any(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" }]
|
|
434
|
-
}], ctorParameters: function () { return []; }, propDecorators: { partDefinitions: [{
|
|
435
|
-
type: Input
|
|
436
|
-
}], parts: [{
|
|
437
|
-
type: Input
|
|
438
|
-
}], typeThesaurus: [{
|
|
439
|
-
type: Input
|
|
440
|
-
}], addRequest: [{
|
|
441
|
-
type: Output
|
|
380
|
+
class MissingPartsComponent {
|
|
381
|
+
get partDefinitions() {
|
|
382
|
+
return this._partDefinitions;
|
|
383
|
+
}
|
|
384
|
+
set partDefinitions(value) {
|
|
385
|
+
this._partDefinitions = value;
|
|
386
|
+
this.updateMissing();
|
|
387
|
+
}
|
|
388
|
+
get parts() {
|
|
389
|
+
return this._parts;
|
|
390
|
+
}
|
|
391
|
+
set parts(value) {
|
|
392
|
+
this._parts = value;
|
|
393
|
+
this.updateMissing();
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* The types thesaurus.
|
|
397
|
+
*/
|
|
398
|
+
get typeThesaurus() {
|
|
399
|
+
return this._typeThesaurus;
|
|
400
|
+
}
|
|
401
|
+
set typeThesaurus(value) {
|
|
402
|
+
this._typeThesaurus = value;
|
|
403
|
+
this.updateMissing();
|
|
404
|
+
}
|
|
405
|
+
constructor() {
|
|
406
|
+
this.missingDefinitions = [];
|
|
407
|
+
this.addRequest = new EventEmitter();
|
|
408
|
+
}
|
|
409
|
+
ngOnInit() { }
|
|
410
|
+
isPartPresent(typeId, roleId) {
|
|
411
|
+
if (!this._partDefinitions) {
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
return this._partDefinitions.some((d) => d.typeId === typeId && d.roleId === roleId);
|
|
415
|
+
}
|
|
416
|
+
updateMissing() {
|
|
417
|
+
this.missingDefinitions.length = 0;
|
|
418
|
+
if (!this._partDefinitions) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
for (let i = 0; i < this._partDefinitions.length; i++) {
|
|
422
|
+
const def = this._partDefinitions[i];
|
|
423
|
+
if (!this.isPartPresent(def.typeId, def.roleId)) {
|
|
424
|
+
this.missingDefinitions.push(def);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: MissingPartsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
429
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.1", 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]=\"$any(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: [""], dependencies: [{ kind: "directive", type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i13.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i4.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "component", type: i5.PartBadgeComponent, selector: "cadmus-part-badge", inputs: ["badgeType", "typeThesaurus", "facetDefinition", "partTypeIds"] }] }); }
|
|
430
|
+
}
|
|
431
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: MissingPartsComponent, decorators: [{
|
|
432
|
+
type: Component,
|
|
433
|
+
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]=\"$any(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" }]
|
|
434
|
+
}], ctorParameters: function () { return []; }, propDecorators: { partDefinitions: [{
|
|
435
|
+
type: Input
|
|
436
|
+
}], parts: [{
|
|
437
|
+
type: Input
|
|
438
|
+
}], typeThesaurus: [{
|
|
439
|
+
type: Input
|
|
440
|
+
}], addRequest: [{
|
|
441
|
+
type: Output
|
|
442
442
|
}] } });
|
|
443
443
|
|
|
444
|
-
/**
|
|
445
|
-
* Parts thesaurus scope dumb editor component.
|
|
446
|
-
* This is used to set the thesaurus scope of multiple item's parts at once
|
|
447
|
-
* in the item editor.
|
|
448
|
-
*/
|
|
449
|
-
class PartsScopeEditorComponent {
|
|
450
|
-
|
|
451
|
-
this.
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
this.
|
|
455
|
-
this.
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
this.
|
|
460
|
-
this.
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
const
|
|
497
|
-
if (
|
|
498
|
-
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
let
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
}],
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}],
|
|
544
|
-
|
|
444
|
+
/**
|
|
445
|
+
* Parts thesaurus scope dumb editor component.
|
|
446
|
+
* This is used to set the thesaurus scope of multiple item's parts at once
|
|
447
|
+
* in the item editor.
|
|
448
|
+
*/
|
|
449
|
+
class PartsScopeEditorComponent {
|
|
450
|
+
get parts() {
|
|
451
|
+
return this._parts;
|
|
452
|
+
}
|
|
453
|
+
set parts(value) {
|
|
454
|
+
this._parts = value;
|
|
455
|
+
this.updateForm();
|
|
456
|
+
}
|
|
457
|
+
constructor(_formBuilder, _facetService, _dialogService, _appRepository, _colorService, _editedItemRepository) {
|
|
458
|
+
this._formBuilder = _formBuilder;
|
|
459
|
+
this._facetService = _facetService;
|
|
460
|
+
this._dialogService = _dialogService;
|
|
461
|
+
this._appRepository = _appRepository;
|
|
462
|
+
this._colorService = _colorService;
|
|
463
|
+
this._editedItemRepository = _editedItemRepository;
|
|
464
|
+
// events
|
|
465
|
+
this.setScopeRequest = new EventEmitter();
|
|
466
|
+
// form
|
|
467
|
+
this.checks = _formBuilder.array([], CustomValidators.minChecked(1));
|
|
468
|
+
this.scope = _formBuilder.control(null, [
|
|
469
|
+
Validators.maxLength(50),
|
|
470
|
+
Validators.pattern(/^[-a-zA-Z0-9_]+$/),
|
|
471
|
+
]);
|
|
472
|
+
this.form = _formBuilder.group({
|
|
473
|
+
checks: this.checks,
|
|
474
|
+
scope: this.scope,
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
ngOnInit() { }
|
|
478
|
+
updateForm() {
|
|
479
|
+
this.checks.clear();
|
|
480
|
+
if (!this._parts || this._parts.length === 0) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
for (let i = 0; i < this._parts.length; i++) {
|
|
484
|
+
this.checks.push(this._formBuilder.control(false));
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
getPartColor(typeId, roleId) {
|
|
488
|
+
const facet = this._editedItemRepository.getFacet();
|
|
489
|
+
return this._facetService.getPartColor(typeId, roleId, facet);
|
|
490
|
+
}
|
|
491
|
+
getContrastColor(typeId, roleId) {
|
|
492
|
+
const rgb = this.getPartColor(typeId, roleId);
|
|
493
|
+
return this._colorService.getContrastColor(rgb);
|
|
494
|
+
}
|
|
495
|
+
getTypeIdName(typeId) {
|
|
496
|
+
const state = this._appRepository.getValue();
|
|
497
|
+
if (!state || !state.typeThesaurus) {
|
|
498
|
+
return typeId;
|
|
499
|
+
}
|
|
500
|
+
// strip :suffix if any
|
|
501
|
+
const i = typeId.lastIndexOf(':');
|
|
502
|
+
if (i > -1) {
|
|
503
|
+
typeId = typeId.substring(0, i);
|
|
504
|
+
}
|
|
505
|
+
const entry = state.typeThesaurus.entries?.find((e) => e.id === typeId);
|
|
506
|
+
return entry ? entry.value : typeId;
|
|
507
|
+
}
|
|
508
|
+
getRoleIdName(roleId) {
|
|
509
|
+
if (!roleId || !roleId.startsWith('fr.')) {
|
|
510
|
+
return roleId;
|
|
511
|
+
}
|
|
512
|
+
return this.getTypeIdName(roleId);
|
|
513
|
+
}
|
|
514
|
+
submit() {
|
|
515
|
+
if (this.form.invalid || !this._parts) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
const ids = [];
|
|
519
|
+
for (let i = 0; i < this.checks.length; i++) {
|
|
520
|
+
if (this.checks.controls[i].value === true) {
|
|
521
|
+
ids.push(this._parts[i].id);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
let msg = this.scope.value
|
|
525
|
+
? `Assign scope "${this.scope.value}" to ${ids.length} part`
|
|
526
|
+
: `Remove scope from ${ids.length} part`;
|
|
527
|
+
msg += ids.length > 1 ? 's?' : '?';
|
|
528
|
+
this._dialogService.confirm('Confirm Scopes', msg).subscribe((result) => {
|
|
529
|
+
if (!result) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
this.setScopeRequest.emit({
|
|
533
|
+
ids,
|
|
534
|
+
scope: this.scope.value,
|
|
535
|
+
});
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: PartsScopeEditorComponent, deps: [{ token: i10.FormBuilder }, { token: i2.FacetService }, { token: i3$1.DialogService }, { token: i1.AppRepository }, { token: i5.ColorService }, { token: EditedItemRepository }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
539
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.1", 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]=\"getPartColor($any(parts)[i].typeId, $any(parts)[i].roleId)\"\r\n [style.color]=\"getContrastColor($any(parts)[i].typeId, $any(parts)[i].roleId)\"\r\n >{{ getTypeIdName($any(parts)[i].typeId) }}</span\r\n >\r\n </td>\r\n <td>{{ getRoleIdName($any(parts)[i].roleId) }}</td>\r\n <td>{{ $any(parts)[i].thesaurusScope }}</td>\r\n <td>{{ $any(parts)[i].timeModified | date: 'yyyy-MM-dd HH:mm:ss' }}</td>\r\n <td>{{ $any(parts)[i].userId }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n <div>\r\n <mat-form-field>\r\n <mat-label>scope</mat-label>\r\n <input matInput 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:400;color:silver;text-align:left}td{padding:0 6px}span.model-type{padding:4px;border-radius:6px}table#parts{border-collapse:separate;border-spacing:0 8px}\n"], dependencies: [{ kind: "directive", type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i10.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i10.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i10.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i10.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i10.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i10.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i10.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { kind: "component", type: i13.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i9.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex"], exportAs: ["matCheckbox"] }, { kind: "component", type: i10$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i10$1.MatLabel, selector: "mat-label" }, { kind: "directive", type: i10$1.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i11$1.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "directive", type: i4.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "pipe", type: i11.DatePipe, name: "date" }] }); }
|
|
540
|
+
}
|
|
541
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: PartsScopeEditorComponent, decorators: [{
|
|
542
|
+
type: Component,
|
|
543
|
+
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]=\"getPartColor($any(parts)[i].typeId, $any(parts)[i].roleId)\"\r\n [style.color]=\"getContrastColor($any(parts)[i].typeId, $any(parts)[i].roleId)\"\r\n >{{ getTypeIdName($any(parts)[i].typeId) }}</span\r\n >\r\n </td>\r\n <td>{{ getRoleIdName($any(parts)[i].roleId) }}</td>\r\n <td>{{ $any(parts)[i].thesaurusScope }}</td>\r\n <td>{{ $any(parts)[i].timeModified | date: 'yyyy-MM-dd HH:mm:ss' }}</td>\r\n <td>{{ $any(parts)[i].userId }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n <div>\r\n <mat-form-field>\r\n <mat-label>scope</mat-label>\r\n <input matInput 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:400;color:silver;text-align:left}td{padding:0 6px}span.model-type{padding:4px;border-radius:6px}table#parts{border-collapse:separate;border-spacing:0 8px}\n"] }]
|
|
544
|
+
}], ctorParameters: function () { return [{ type: i10.FormBuilder }, { type: i2.FacetService }, { type: i3$1.DialogService }, { type: i1.AppRepository }, { type: i5.ColorService }, { type: EditedItemRepository }]; }, propDecorators: { parts: [{
|
|
545
|
+
type: Input
|
|
546
|
+
}], readonly: [{
|
|
547
|
+
type: Input
|
|
548
|
+
}], setScopeRequest: [{
|
|
549
|
+
type: Output
|
|
545
550
|
}] } });
|
|
546
551
|
|
|
547
|
-
/**
|
|
548
|
-
* A pipe used locally in the item editor to determine whether
|
|
549
|
-
* any of its parts can be previewed. To this end, this pipe requires
|
|
550
|
-
* the part plus the list of available renderers keys and flatteners
|
|
551
|
-
* keys. When the part is a base text, it is checked against flatteners
|
|
552
|
-
* and renderers; else, it is checked against renderers only.
|
|
553
|
-
* Ideally, a text part should have a flattener, while any other part
|
|
554
|
-
* should have a renderer. When there is no flattener, we fallback
|
|
555
|
-
* to the renderer if any.
|
|
556
|
-
*/
|
|
557
|
-
class HasPreviewPipe {
|
|
558
|
-
/**
|
|
559
|
-
* Transform the received part into a boolean value telling whether
|
|
560
|
-
* that part can be previewed or not.
|
|
561
|
-
*
|
|
562
|
-
* @param value The part.
|
|
563
|
-
* @param rKeys The list of available renderers keys.
|
|
564
|
-
* @param fKeys The list of available flatteners keys.
|
|
565
|
-
* @returns True if preview available; else false.
|
|
566
|
-
*/
|
|
567
|
-
transform(value, rKeys, fKeys) {
|
|
568
|
-
if (!value) {
|
|
569
|
-
return false;
|
|
570
|
-
}
|
|
571
|
-
// the preview key is equal to the typeId, optionally followed by
|
|
572
|
-
// | and the roleId when present (except when it's "base-text")
|
|
573
|
-
if (value.roleId === 'base-text') {
|
|
574
|
-
return fKeys?.find((k) => k === value.typeId) ||
|
|
575
|
-
rKeys?.find((k) => k === value.typeId)
|
|
576
|
-
? true
|
|
577
|
-
: false;
|
|
578
|
-
}
|
|
579
|
-
const key = value.roleId ? `${value.typeId}|${value.roleId}` : value.typeId;
|
|
580
|
-
return rKeys?.find((k) => k === key) ? true : false;
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
586
|
-
type: Pipe,
|
|
587
|
-
args: [{
|
|
588
|
-
name: 'hasPreview',
|
|
589
|
-
}]
|
|
552
|
+
/**
|
|
553
|
+
* A pipe used locally in the item editor to determine whether
|
|
554
|
+
* any of its parts can be previewed. To this end, this pipe requires
|
|
555
|
+
* the part plus the list of available renderers keys and flatteners
|
|
556
|
+
* keys. When the part is a base text, it is checked against flatteners
|
|
557
|
+
* and renderers; else, it is checked against renderers only.
|
|
558
|
+
* Ideally, a text part should have a flattener, while any other part
|
|
559
|
+
* should have a renderer. When there is no flattener, we fallback
|
|
560
|
+
* to the renderer if any.
|
|
561
|
+
*/
|
|
562
|
+
class HasPreviewPipe {
|
|
563
|
+
/**
|
|
564
|
+
* Transform the received part into a boolean value telling whether
|
|
565
|
+
* that part can be previewed or not.
|
|
566
|
+
*
|
|
567
|
+
* @param value The part.
|
|
568
|
+
* @param rKeys The list of available renderers keys.
|
|
569
|
+
* @param fKeys The list of available flatteners keys.
|
|
570
|
+
* @returns True if preview available; else false.
|
|
571
|
+
*/
|
|
572
|
+
transform(value, rKeys, fKeys) {
|
|
573
|
+
if (!value) {
|
|
574
|
+
return false;
|
|
575
|
+
}
|
|
576
|
+
// the preview key is equal to the typeId, optionally followed by
|
|
577
|
+
// | and the roleId when present (except when it's "base-text")
|
|
578
|
+
if (value.roleId === 'base-text') {
|
|
579
|
+
return fKeys?.find((k) => k === value.typeId) ||
|
|
580
|
+
rKeys?.find((k) => k === value.typeId)
|
|
581
|
+
? true
|
|
582
|
+
: false;
|
|
583
|
+
}
|
|
584
|
+
const key = value.roleId ? `${value.typeId}|${value.roleId}` : value.typeId;
|
|
585
|
+
return rKeys?.find((k) => k === key) ? true : false;
|
|
586
|
+
}
|
|
587
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: HasPreviewPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
588
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.0.1", ngImport: i0, type: HasPreviewPipe, name: "hasPreview" }); }
|
|
589
|
+
}
|
|
590
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: HasPreviewPipe, decorators: [{
|
|
591
|
+
type: Pipe,
|
|
592
|
+
args: [{
|
|
593
|
+
name: 'hasPreview',
|
|
594
|
+
}]
|
|
590
595
|
}] });
|
|
591
596
|
|
|
592
|
-
/**
|
|
593
|
-
* Item editor. This can edit a new or existing item's metadata and parts.
|
|
594
|
-
* The ID of the item being edited is extracted from the route. For a new item
|
|
595
|
-
* this is 'new', which here is stored as an empty string.
|
|
596
|
-
*/
|
|
597
|
-
class ItemEditorComponent {
|
|
598
|
-
constructor(_router, _route, _snackbar, _appRepository, _repository, _itemService, _itemListRepository, _libraryRouteService, _dialogService, _authService, _userLevelService, _formBuilder) {
|
|
599
|
-
this._router = _router;
|
|
600
|
-
this._route = _route;
|
|
601
|
-
this._snackbar = _snackbar;
|
|
602
|
-
this._appRepository = _appRepository;
|
|
603
|
-
this._repository = _repository;
|
|
604
|
-
this._itemService = _itemService;
|
|
605
|
-
this._itemListRepository = _itemListRepository;
|
|
606
|
-
this._libraryRouteService = _libraryRouteService;
|
|
607
|
-
this._dialogService = _dialogService;
|
|
608
|
-
this._authService = _authService;
|
|
609
|
-
this._userLevelService = _userLevelService;
|
|
610
|
-
this._formBuilder = _formBuilder;
|
|
611
|
-
this.id = this._route.snapshot.params['id'];
|
|
612
|
-
this.flagDefinitions = [];
|
|
613
|
-
if (this.id === 'new') {
|
|
614
|
-
this.id = undefined;
|
|
615
|
-
}
|
|
616
|
-
// new part form
|
|
617
|
-
this.newPartType = _formBuilder.control(null, Validators.required);
|
|
618
|
-
this.newPart = _formBuilder.group({
|
|
619
|
-
newPartType: this.newPartType,
|
|
620
|
-
});
|
|
621
|
-
// item's metadata form
|
|
622
|
-
this.title = _formBuilder.control(null, [
|
|
623
|
-
Validators.required,
|
|
624
|
-
Validators.maxLength(500),
|
|
625
|
-
]);
|
|
626
|
-
this.sortKey = _formBuilder.control(null, [
|
|
627
|
-
Validators.required,
|
|
628
|
-
Validators.maxLength(500),
|
|
629
|
-
]);
|
|
630
|
-
this.sortKey.disable();
|
|
631
|
-
this.description = _formBuilder.control(null, [
|
|
632
|
-
Validators.required,
|
|
633
|
-
Validators.maxLength(1000),
|
|
634
|
-
]);
|
|
635
|
-
this.facet = _formBuilder.control(null, Validators.required);
|
|
636
|
-
this.group = _formBuilder.control(null, Validators.maxLength(100));
|
|
637
|
-
this.flags = _formBuilder.control(0, { nonNullable: true });
|
|
638
|
-
this.flagChecks = _formBuilder.array([]);
|
|
639
|
-
this.metadata = _formBuilder.group({
|
|
640
|
-
title: this.title,
|
|
641
|
-
sortKey: this.sortKey,
|
|
642
|
-
description: this.description,
|
|
643
|
-
facet: this.facet,
|
|
644
|
-
group: this.group,
|
|
645
|
-
flagChecks: this.flagChecks,
|
|
646
|
-
});
|
|
647
|
-
this.userLevel = 0;
|
|
648
|
-
this.item$ = this._repository.item$;
|
|
649
|
-
this.parts$ = this._repository.parts$;
|
|
650
|
-
this.partGroups$ = this._repository.partGroups$;
|
|
651
|
-
this.layerPartInfos$ = this._repository.layers$;
|
|
652
|
-
this.facet$ = this._repository.facet$;
|
|
653
|
-
this.newPartDefinitions$ = this._repository.newPartDefinitions$;
|
|
654
|
-
// app
|
|
655
|
-
this.facets$ = this._appRepository.facets$;
|
|
656
|
-
this.typeThesaurus$ = this._appRepository.typeThesaurus$;
|
|
657
|
-
this.previewJKeys$ = this._appRepository.previewJKeys$;
|
|
658
|
-
this.previewFKeys$ = this._appRepository.previewFKeys$;
|
|
659
|
-
}
|
|
660
|
-
ngOnInit() {
|
|
661
|
-
this._authService.currentUser$.subscribe((user) => {
|
|
662
|
-
this.user = user || undefined;
|
|
663
|
-
this.userLevel = this._userLevelService.getCurrentUserLevel();
|
|
664
|
-
});
|
|
665
|
-
// rebuild the flags controls array when flags definitions change
|
|
666
|
-
this._appRepository.flags$.subscribe((defs) => {
|
|
667
|
-
this.flagDefinitions = defs;
|
|
668
|
-
this.buildFlagsControls();
|
|
669
|
-
});
|
|
670
|
-
// when flags controls values change, update the flags value
|
|
671
|
-
this.flagChecks.valueChanges.subscribe((_) => {
|
|
672
|
-
if (!this._flagsFrozen) {
|
|
673
|
-
this.flags.setValue(this.getFlagsValue());
|
|
674
|
-
}
|
|
675
|
-
});
|
|
676
|
-
// update the metadata form when item changes (e.g. saved)
|
|
677
|
-
this.item$.subscribe((item) => {
|
|
678
|
-
this.updateMetadataForm(item);
|
|
679
|
-
});
|
|
680
|
-
// load the item (if any) and its lookup
|
|
681
|
-
this._repository.load(this.id);
|
|
682
|
-
}
|
|
683
|
-
canDeactivate() {
|
|
684
|
-
return !this.metadata.dirty;
|
|
685
|
-
}
|
|
686
|
-
/**
|
|
687
|
-
* Builds the array of flags controls according to the current flags
|
|
688
|
-
* definitions and the current flags value.
|
|
689
|
-
*/
|
|
690
|
-
buildFlagsControls() {
|
|
691
|
-
this._flagsFrozen = true;
|
|
692
|
-
this.flagChecks.clear();
|
|
693
|
-
for (const def of this.flagDefinitions) {
|
|
694
|
-
const flagValue = def.id;
|
|
695
|
-
// tslint:disable-next-line: no-bitwise
|
|
696
|
-
const checked = (this.flags.value & flagValue) !== 0;
|
|
697
|
-
this.flagChecks.push(this._formBuilder.control(checked));
|
|
698
|
-
}
|
|
699
|
-
this._flagsFrozen = false;
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Update the flags controls from the current flags value.
|
|
703
|
-
*/
|
|
704
|
-
updateFlagControls() {
|
|
705
|
-
if (!this.flagDefinitions) {
|
|
706
|
-
return;
|
|
707
|
-
}
|
|
708
|
-
this._flagsFrozen = true;
|
|
709
|
-
const value = this.flags.value;
|
|
710
|
-
for (let i = 0; i < this.flagDefinitions.length; i++) {
|
|
711
|
-
const flagValue = this.flagDefinitions[i].id;
|
|
712
|
-
// tslint:disable-next-line: no-bitwise
|
|
713
|
-
const checked = (value & flagValue) !== 0;
|
|
714
|
-
this.flagChecks.at(i).setValue(checked);
|
|
715
|
-
}
|
|
716
|
-
this._flagsFrozen = false;
|
|
717
|
-
}
|
|
718
|
-
/**
|
|
719
|
-
* Get the flags value from the flags controls.
|
|
720
|
-
*/
|
|
721
|
-
getFlagsValue() {
|
|
722
|
-
let flagsValue = 0;
|
|
723
|
-
for (let i = 0; i < this.flagDefinitions.length; i++) {
|
|
724
|
-
const flagValue = this.flagDefinitions[i].id;
|
|
725
|
-
if (this.flagChecks.at(i)?.value) {
|
|
726
|
-
// tslint:disable-next-line: no-bitwise
|
|
727
|
-
flagsValue |= flagValue;
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
return flagsValue;
|
|
731
|
-
}
|
|
732
|
-
updateMetadataForm(item) {
|
|
733
|
-
if (!item) {
|
|
734
|
-
this.metadata.reset();
|
|
735
|
-
this.updateFlagControls();
|
|
736
|
-
}
|
|
737
|
-
else {
|
|
738
|
-
this.title.setValue(item.title);
|
|
739
|
-
this.sortKey.setValue(item.sortKey);
|
|
740
|
-
this.description.setValue(item.description);
|
|
741
|
-
this.facet.setValue(item.facetId);
|
|
742
|
-
this.group.setValue(item.groupId);
|
|
743
|
-
this.flags.setValue(item.flags);
|
|
744
|
-
this.updateFlagControls();
|
|
745
|
-
this.metadata.markAsPristine();
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
getTypeIdName(typeId) {
|
|
749
|
-
const state = this._appRepository.getValue();
|
|
750
|
-
if (!state || !state.typeThesaurus) {
|
|
751
|
-
return typeId;
|
|
752
|
-
}
|
|
753
|
-
// strip :suffix if any
|
|
754
|
-
const i = typeId.lastIndexOf(':');
|
|
755
|
-
if (i > -1) {
|
|
756
|
-
typeId = typeId.substring(0, i);
|
|
757
|
-
}
|
|
758
|
-
const entry = state.typeThesaurus.entries?.find((e) => e.id === typeId);
|
|
759
|
-
return entry ? entry.value : typeId;
|
|
760
|
-
}
|
|
761
|
-
getRoleIdName(roleId) {
|
|
762
|
-
if (!roleId || !roleId.startsWith('fr.')) {
|
|
763
|
-
return roleId;
|
|
764
|
-
}
|
|
765
|
-
return this.getTypeIdName(roleId);
|
|
766
|
-
}
|
|
767
|
-
save() {
|
|
768
|
-
if (this.busy || !this.metadata.valid) {
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
// build item (its ID will be empty if new)
|
|
772
|
-
const item = { ...this._repository.getItem() };
|
|
773
|
-
if (!item) {
|
|
774
|
-
return;
|
|
775
|
-
}
|
|
776
|
-
item.title = this.title.value?.trim();
|
|
777
|
-
item.sortKey = this.sortKey.value?.trim();
|
|
778
|
-
item.description = this.description.value?.trim();
|
|
779
|
-
item.facetId = this.facet.value?.trim() || undefined;
|
|
780
|
-
item.groupId = this.group.value?.trim() || undefined;
|
|
781
|
-
item.flags = this.flags.value;
|
|
782
|
-
// save: this will trigger a change in the store's item, reflected here
|
|
783
|
-
// by updating the metadata form
|
|
784
|
-
this.busy = true;
|
|
785
|
-
this._repository
|
|
786
|
-
.save(item)
|
|
787
|
-
.then((saved) => {
|
|
788
|
-
// once saved, a new item requires resetting the items list
|
|
789
|
-
if (!item.id) {
|
|
790
|
-
this._itemListRepository.clearCache();
|
|
791
|
-
this._itemListRepository.loadPage(1);
|
|
792
|
-
}
|
|
793
|
-
else {
|
|
794
|
-
// an existing item instead just requires updating the entity
|
|
795
|
-
// in the items list if present (e.g. flags might have been changed)
|
|
796
|
-
this._itemListRepository.updateEntity({
|
|
797
|
-
id: item.id,
|
|
798
|
-
title: item.title,
|
|
799
|
-
description: item.description,
|
|
800
|
-
facetId: item.facetId,
|
|
801
|
-
groupId: item.groupId,
|
|
802
|
-
sortKey: item.sortKey,
|
|
803
|
-
flags: item.flags,
|
|
804
|
-
timeCreated: item.timeCreated,
|
|
805
|
-
creatorId: item.creatorId,
|
|
806
|
-
timeModified: item.timeModified,
|
|
807
|
-
userId: item.userId,
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
|
-
// this.metadata.markAsPristine();
|
|
811
|
-
// reload to force change in page URL
|
|
812
|
-
if (!item.id) {
|
|
813
|
-
this.id = saved.id;
|
|
814
|
-
this._router.navigate(['/items', saved.id]);
|
|
815
|
-
}
|
|
816
|
-
})
|
|
817
|
-
.finally(() => {
|
|
818
|
-
this.busy = false;
|
|
819
|
-
});
|
|
820
|
-
}
|
|
821
|
-
partExists(typeId, roleId) {
|
|
822
|
-
const groups = this._repository.getPartGroups();
|
|
823
|
-
if (!groups) {
|
|
824
|
-
return false;
|
|
825
|
-
}
|
|
826
|
-
return groups.some((g) => {
|
|
827
|
-
return g.parts.some((p) => p.typeId === typeId && ((!p.roleId && !roleId) || p.roleId === roleId));
|
|
828
|
-
});
|
|
829
|
-
}
|
|
830
|
-
addPart(def) {
|
|
831
|
-
if (!def && !this.newPartType.valid) {
|
|
832
|
-
return;
|
|
833
|
-
}
|
|
834
|
-
if (!this.id) {
|
|
835
|
-
this._snackbar.open('Please save the item before adding parts', 'OK', {
|
|
836
|
-
duration: 3000,
|
|
837
|
-
});
|
|
838
|
-
return;
|
|
839
|
-
}
|
|
840
|
-
const typeId = def ? def.typeId : this.newPartType.value.typeId;
|
|
841
|
-
const roleId = def ? def.roleId : this.newPartType.value.roleId;
|
|
842
|
-
if (this.partExists(typeId, roleId)) {
|
|
843
|
-
return;
|
|
844
|
-
}
|
|
845
|
-
const route = this._libraryRouteService.buildPartEditorRoute(this.id, 'new', typeId, roleId);
|
|
846
|
-
// navigate to the editor
|
|
847
|
-
this._router.navigate([route.route], route.rid
|
|
848
|
-
? {
|
|
849
|
-
queryParams: {
|
|
850
|
-
rid: route.rid,
|
|
851
|
-
},
|
|
852
|
-
}
|
|
853
|
-
: {});
|
|
854
|
-
}
|
|
855
|
-
editPart(part) {
|
|
856
|
-
// build the target route to the appropriate part editor
|
|
857
|
-
const route = this._libraryRouteService.buildPartEditorRoute(part.itemId, part.id, part.typeId, part.roleId);
|
|
858
|
-
// navigate to the editor
|
|
859
|
-
this._router.navigate([route.route], route.rid
|
|
860
|
-
? {
|
|
861
|
-
queryParams: {
|
|
862
|
-
rid: route.rid,
|
|
863
|
-
},
|
|
864
|
-
}
|
|
865
|
-
: {});
|
|
866
|
-
}
|
|
867
|
-
previewPart(part) {
|
|
868
|
-
if (part.roleId?.startsWith('fr.')) {
|
|
869
|
-
// layer parts redirect to base-text
|
|
870
|
-
this._itemService
|
|
871
|
-
.getBaseTextPart(part.itemId)
|
|
872
|
-
.pipe(take$1(1))
|
|
873
|
-
.subscribe((p) => {
|
|
874
|
-
this._router.navigate(['preview', part.itemId, p.part.id, 'text'], {
|
|
875
|
-
queryParams: { lid: part.roleId },
|
|
876
|
-
});
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
else if (part.roleId === 'base-text') {
|
|
880
|
-
this._router.navigate(['preview', part.itemId, part.id, 'text']);
|
|
881
|
-
}
|
|
882
|
-
else {
|
|
883
|
-
this._router.navigate(['preview', part.itemId, part.id]);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
deletePart(part) {
|
|
887
|
-
if (this.busy) {
|
|
888
|
-
return;
|
|
889
|
-
}
|
|
890
|
-
this._dialogService
|
|
891
|
-
.confirm('Confirm Deletion', `Delete part "${part.typeId}"?`)
|
|
892
|
-
.subscribe((result) => {
|
|
893
|
-
if (!result) {
|
|
894
|
-
return;
|
|
895
|
-
}
|
|
896
|
-
// delete
|
|
897
|
-
this.busy = true;
|
|
898
|
-
this._repository.deletePart(part.id).then((_) => {
|
|
899
|
-
this.busy = false;
|
|
900
|
-
}, (error) => {
|
|
901
|
-
this.busy = false;
|
|
902
|
-
console.error(error);
|
|
903
|
-
this._snackbar.open('Error deleting part', 'OK');
|
|
904
|
-
});
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
addLayerPart(part) {
|
|
908
|
-
if (this.busy) {
|
|
909
|
-
return;
|
|
910
|
-
}
|
|
911
|
-
let name = this.getTypeIdName(part.typeId);
|
|
912
|
-
if (part.roleId) {
|
|
913
|
-
name += ' for ' + this.getRoleIdName(part.roleId);
|
|
914
|
-
}
|
|
915
|
-
this.busy = true;
|
|
916
|
-
this._dialogService
|
|
917
|
-
.confirm('Confirm Addition', `Add layer "${name}"?`)
|
|
918
|
-
.subscribe((result) => {
|
|
919
|
-
if (!result) {
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
922
|
-
this._repository
|
|
923
|
-
.addNewLayerPart(part.typeId, part.roleId)
|
|
924
|
-
.finally(() => (this.busy = false));
|
|
925
|
-
});
|
|
926
|
-
}
|
|
927
|
-
setPartsScope(request) {
|
|
928
|
-
this._repository.setPartThesaurusScope(request.ids, request.scope);
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
ItemEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: ItemEditorComponent, deps: [{ token: i1$1.Router }, { token: i1$1.ActivatedRoute }, { token: i2$1.MatSnackBar }, { token: i1.AppRepository }, { token: EditedItemRepository }, { token: i2.ItemService }, { token: i6.ItemListRepository }, { token: i7.LibraryRouteService }, { token: i3$1.DialogService }, { token: i9$1.AuthJwtService }, { token: i2.UserLevelService }, { token: i10.FormBuilder }], target: i0.ɵɵFactoryTarget.Component });
|
|
932
|
-
ItemEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: ItemEditorComponent, selector: "cadmus-item-editor", ngImport: i0, template: "<mat-card appearance=\"outlined\">\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>\r\n <p *ngIf=\"id\">\r\n ID:\r\n <input\r\n [cdkCopyToClipboard]=\"(item$ | async)?.id || ''\"\r\n type=\"text\"\r\n readonly=\"true\"\r\n spellcheck=\"false\"\r\n matTooltip=\"Click to copy\"\r\n [value]=\"(item$ | async)?.id\"\r\n class=\"id\"\r\n />\r\n </p>\r\n <p *ngIf=\"item$ | async as item\">\r\n Last saved {{ item.timeModified | date : \"yyyy-MM-dd HH:mm:ss\" }} by\r\n {{ item.userId }}.<br />\r\n Created {{ item.timeCreated | date : \"yyyy-MM-dd HH:mm:ss\" }} by\r\n {{ item.creatorId }}.\r\n </p>\r\n\r\n <mat-progress-bar mode=\"indeterminate\" *ngIf=\"busy\"></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 <div class=\"form-row\">\r\n <!-- title -->\r\n <mat-form-field style=\"flex: 1 0 auto\">\r\n <mat-label>title</mat-label>\r\n <input matInput type=\"text\" id=\"title\" [formControl]=\"title\" />\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\r\n <!-- sortKey -->\r\n <mat-form-field style=\"flex: 1 0 auto\">\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 <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 <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 <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 class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>facet</mat-label>\r\n <mat-select [formControl]=\"facet\" required=\"true\">\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\r\n <!-- group -->\r\n <mat-form-field>\r\n <mat-label>group ID</mat-label>\r\n <input matInput [formControl]=\"group\" />\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 <fieldset>\r\n <legend>flags</legend>\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 </fieldset>\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]=\"userLevel < 2 || busy\"\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-label>part</mat-label>\r\n <mat-select [formControl]=\"newPartType\" required>\r\n <mat-option\r\n *ngFor=\"let p of newPartDefinitions$ | async\"\r\n [value]=\"p\"\r\n >\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 || 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 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 style=\"width: 100%\">\r\n <thead>\r\n <tr>\r\n <th style=\"width: 200px\"></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 <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 [disabled]=\"busy\"\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 [disabled]=\"userLevel < 2 || busy\"\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 <!-- preview -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Preview this part\"\r\n *ngIf=\"\r\n part\r\n | hasPreview\r\n : (previewJKeys$ | async)\r\n : (previewFKeys$ | async)\r\n \"\r\n (click)=\"previewPart(part)\"\r\n >\r\n <mat-icon>preview</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) || undefined\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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) || undefined\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\r\n ></cadmus-part-badge>\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 </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) || undefined\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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 id=\"layers\" *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) || undefined\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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) || undefined\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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 | date : \"yyyy-MM-dd HH:mm:ss\" }}\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 label=\"Th-Scopes\" *ngIf=\"parts$ | async as parts\">\r\n <!-- [parts]=\"parts | sort: 'typeId' | sort: 'roleId'\" -->\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 ></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:400;color:silver}#layers td{padding:0 6px}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}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}fieldset{border:1px solid silver;border-radius:6px;padding:6px;margin:8px 0}@media only screen and (max-width: 599px){.noif-lt-xs{display:none}}\n"], dependencies: [{ kind: "directive", type: i11.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i10.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i10.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i10.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i10.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i10.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i10.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i10.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i10.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i10.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { kind: "directive", type: i12.CdkCopyToClipboard, selector: "[cdkCopyToClipboard]", inputs: ["cdkCopyToClipboard", "cdkCopyToClipboardAttempts"], outputs: ["cdkCopyToClipboardCopied"] }, { kind: "component", type: i13.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i13.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i8.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex"], exportAs: ["matCheckbox"] }, { kind: "component", type: i15.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: i15.MatCardContent, selector: "mat-card-content" }, { kind: "component", type: i15.MatCardHeader, selector: "mat-card-header" }, { kind: "directive", type: i15.MatCardSubtitle, selector: "mat-card-subtitle, [mat-card-subtitle], [matCardSubtitle]" }, { kind: "directive", type: i15.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { kind: "component", type: i16.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "component", type: i17.MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["disabled", "expanded", "hideToggle", "togglePosition"], outputs: ["opened", "closed", "expandedChange", "afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { kind: "component", type: i17.MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["tabIndex", "expandedHeight", "collapsedHeight"] }, { kind: "directive", type: i17.MatExpansionPanelTitle, selector: "mat-panel-title" }, { kind: "directive", type: i17.MatExpansionPanelDescription, selector: "mat-panel-description" }, { kind: "component", type: i9.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i9.MatLabel, selector: "mat-label" }, { kind: "directive", type: i9.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i10$1.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i21.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "component", type: i22.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { kind: "component", type: i23.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "component", type: i24.MatTab, selector: "mat-tab", inputs: ["disabled"], exportAs: ["matTab"] }, { kind: "component", type: i24.MatTabGroup, selector: "mat-tab-group", inputs: ["color", "disableRipple", "fitInkBarToContent", "mat-stretch-tabs"], exportAs: ["matTabGroup"] }, { kind: "directive", type: i4.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "component", type: i5.PartBadgeComponent, selector: "cadmus-part-badge", inputs: ["badgeType", "typeThesaurus", "facetDefinition", "partTypeIds"] }, { kind: "component", type: MissingPartsComponent, selector: "cadmus-missing-parts", inputs: ["partDefinitions", "parts", "typeThesaurus"], outputs: ["addRequest"] }, { kind: "component", type: PartsScopeEditorComponent, selector: "cadmus-parts-scope-editor", inputs: ["parts", "readonly"], outputs: ["setScopeRequest"] }, { kind: "pipe", type: i11.AsyncPipe, name: "async" }, { kind: "pipe", type: i11.DatePipe, name: "date" }, { kind: "pipe", type: HasPreviewPipe, name: "hasPreview" }] });
|
|
933
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
934
|
-
type: Component,
|
|
935
|
-
args: [{ selector: 'cadmus-item-editor', template: "<mat-card appearance=\"outlined\">\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>\r\n <p *ngIf=\"id\">\r\n ID:\r\n <input\r\n [cdkCopyToClipboard]=\"(item$ | async)?.id || ''\"\r\n type=\"text\"\r\n readonly=\"true\"\r\n spellcheck=\"false\"\r\n matTooltip=\"Click to copy\"\r\n [value]=\"(item$ | async)?.id\"\r\n class=\"id\"\r\n />\r\n </p>\r\n <p *ngIf=\"item$ | async as item\">\r\n Last saved {{ item.timeModified | date : \"yyyy-MM-dd HH:mm:ss\" }} by\r\n {{ item.userId }}.<br />\r\n Created {{ item.timeCreated | date : \"yyyy-MM-dd HH:mm:ss\" }} by\r\n {{ item.creatorId }}.\r\n </p>\r\n\r\n <mat-progress-bar mode=\"indeterminate\" *ngIf=\"busy\"></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 <div class=\"form-row\">\r\n <!-- title -->\r\n <mat-form-field style=\"flex: 1 0 auto\">\r\n <mat-label>title</mat-label>\r\n <input matInput type=\"text\" id=\"title\" [formControl]=\"title\" />\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\r\n <!-- sortKey -->\r\n <mat-form-field style=\"flex: 1 0 auto\">\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 <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 <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 <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 class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>facet</mat-label>\r\n <mat-select [formControl]=\"facet\" required=\"true\">\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\r\n <!-- group -->\r\n <mat-form-field>\r\n <mat-label>group ID</mat-label>\r\n <input matInput [formControl]=\"group\" />\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 <fieldset>\r\n <legend>flags</legend>\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 </fieldset>\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]=\"userLevel < 2 || busy\"\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-label>part</mat-label>\r\n <mat-select [formControl]=\"newPartType\" required>\r\n <mat-option\r\n *ngFor=\"let p of newPartDefinitions$ | async\"\r\n [value]=\"p\"\r\n >\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 || 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 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 style=\"width: 100%\">\r\n <thead>\r\n <tr>\r\n <th style=\"width: 200px\"></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 <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 [disabled]=\"busy\"\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 [disabled]=\"userLevel < 2 || busy\"\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 <!-- preview -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Preview this part\"\r\n *ngIf=\"\r\n part\r\n | hasPreview\r\n : (previewJKeys$ | async)\r\n : (previewFKeys$ | async)\r\n \"\r\n (click)=\"previewPart(part)\"\r\n >\r\n <mat-icon>preview</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) || undefined\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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) || undefined\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\r\n ></cadmus-part-badge>\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 </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) || undefined\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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 id=\"layers\" *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) || undefined\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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) || undefined\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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 | date : \"yyyy-MM-dd HH:mm:ss\" }}\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 label=\"Th-Scopes\" *ngIf=\"parts$ | async as parts\">\r\n <!-- [parts]=\"parts | sort: 'typeId' | sort: 'roleId'\" -->\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 ></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:400;color:silver}#layers td{padding:0 6px}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}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}fieldset{border:1px solid silver;border-radius:6px;padding:6px;margin:8px 0}@media only screen and (max-width: 599px){.noif-lt-xs{display:none}}\n"] }]
|
|
597
|
+
/**
|
|
598
|
+
* Item editor. This can edit a new or existing item's metadata and parts.
|
|
599
|
+
* The ID of the item being edited is extracted from the route. For a new item
|
|
600
|
+
* this is 'new', which here is stored as an empty string.
|
|
601
|
+
*/
|
|
602
|
+
class ItemEditorComponent {
|
|
603
|
+
constructor(_router, _route, _snackbar, _appRepository, _repository, _itemService, _itemListRepository, _libraryRouteService, _dialogService, _authService, _userLevelService, _formBuilder) {
|
|
604
|
+
this._router = _router;
|
|
605
|
+
this._route = _route;
|
|
606
|
+
this._snackbar = _snackbar;
|
|
607
|
+
this._appRepository = _appRepository;
|
|
608
|
+
this._repository = _repository;
|
|
609
|
+
this._itemService = _itemService;
|
|
610
|
+
this._itemListRepository = _itemListRepository;
|
|
611
|
+
this._libraryRouteService = _libraryRouteService;
|
|
612
|
+
this._dialogService = _dialogService;
|
|
613
|
+
this._authService = _authService;
|
|
614
|
+
this._userLevelService = _userLevelService;
|
|
615
|
+
this._formBuilder = _formBuilder;
|
|
616
|
+
this.id = this._route.snapshot.params['id'];
|
|
617
|
+
this.flagDefinitions = [];
|
|
618
|
+
if (this.id === 'new') {
|
|
619
|
+
this.id = undefined;
|
|
620
|
+
}
|
|
621
|
+
// new part form
|
|
622
|
+
this.newPartType = _formBuilder.control(null, Validators.required);
|
|
623
|
+
this.newPart = _formBuilder.group({
|
|
624
|
+
newPartType: this.newPartType,
|
|
625
|
+
});
|
|
626
|
+
// item's metadata form
|
|
627
|
+
this.title = _formBuilder.control(null, [
|
|
628
|
+
Validators.required,
|
|
629
|
+
Validators.maxLength(500),
|
|
630
|
+
]);
|
|
631
|
+
this.sortKey = _formBuilder.control(null, [
|
|
632
|
+
Validators.required,
|
|
633
|
+
Validators.maxLength(500),
|
|
634
|
+
]);
|
|
635
|
+
this.sortKey.disable();
|
|
636
|
+
this.description = _formBuilder.control(null, [
|
|
637
|
+
Validators.required,
|
|
638
|
+
Validators.maxLength(1000),
|
|
639
|
+
]);
|
|
640
|
+
this.facet = _formBuilder.control(null, Validators.required);
|
|
641
|
+
this.group = _formBuilder.control(null, Validators.maxLength(100));
|
|
642
|
+
this.flags = _formBuilder.control(0, { nonNullable: true });
|
|
643
|
+
this.flagChecks = _formBuilder.array([]);
|
|
644
|
+
this.metadata = _formBuilder.group({
|
|
645
|
+
title: this.title,
|
|
646
|
+
sortKey: this.sortKey,
|
|
647
|
+
description: this.description,
|
|
648
|
+
facet: this.facet,
|
|
649
|
+
group: this.group,
|
|
650
|
+
flagChecks: this.flagChecks,
|
|
651
|
+
});
|
|
652
|
+
this.userLevel = 0;
|
|
653
|
+
this.item$ = this._repository.item$;
|
|
654
|
+
this.parts$ = this._repository.parts$;
|
|
655
|
+
this.partGroups$ = this._repository.partGroups$;
|
|
656
|
+
this.layerPartInfos$ = this._repository.layers$;
|
|
657
|
+
this.facet$ = this._repository.facet$;
|
|
658
|
+
this.newPartDefinitions$ = this._repository.newPartDefinitions$;
|
|
659
|
+
// app
|
|
660
|
+
this.facets$ = this._appRepository.facets$;
|
|
661
|
+
this.typeThesaurus$ = this._appRepository.typeThesaurus$;
|
|
662
|
+
this.previewJKeys$ = this._appRepository.previewJKeys$;
|
|
663
|
+
this.previewFKeys$ = this._appRepository.previewFKeys$;
|
|
664
|
+
}
|
|
665
|
+
ngOnInit() {
|
|
666
|
+
this._authService.currentUser$.subscribe((user) => {
|
|
667
|
+
this.user = user || undefined;
|
|
668
|
+
this.userLevel = this._userLevelService.getCurrentUserLevel();
|
|
669
|
+
});
|
|
670
|
+
// rebuild the flags controls array when flags definitions change
|
|
671
|
+
this._appRepository.flags$.subscribe((defs) => {
|
|
672
|
+
this.flagDefinitions = defs;
|
|
673
|
+
this.buildFlagsControls();
|
|
674
|
+
});
|
|
675
|
+
// when flags controls values change, update the flags value
|
|
676
|
+
this.flagChecks.valueChanges.subscribe((_) => {
|
|
677
|
+
if (!this._flagsFrozen) {
|
|
678
|
+
this.flags.setValue(this.getFlagsValue());
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
// update the metadata form when item changes (e.g. saved)
|
|
682
|
+
this.item$.subscribe((item) => {
|
|
683
|
+
this.updateMetadataForm(item);
|
|
684
|
+
});
|
|
685
|
+
// load the item (if any) and its lookup
|
|
686
|
+
this._repository.load(this.id);
|
|
687
|
+
}
|
|
688
|
+
canDeactivate() {
|
|
689
|
+
return !this.metadata.dirty;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Builds the array of flags controls according to the current flags
|
|
693
|
+
* definitions and the current flags value.
|
|
694
|
+
*/
|
|
695
|
+
buildFlagsControls() {
|
|
696
|
+
this._flagsFrozen = true;
|
|
697
|
+
this.flagChecks.clear();
|
|
698
|
+
for (const def of this.flagDefinitions) {
|
|
699
|
+
const flagValue = def.id;
|
|
700
|
+
// tslint:disable-next-line: no-bitwise
|
|
701
|
+
const checked = (this.flags.value & flagValue) !== 0;
|
|
702
|
+
this.flagChecks.push(this._formBuilder.control(checked));
|
|
703
|
+
}
|
|
704
|
+
this._flagsFrozen = false;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Update the flags controls from the current flags value.
|
|
708
|
+
*/
|
|
709
|
+
updateFlagControls() {
|
|
710
|
+
if (!this.flagDefinitions) {
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
this._flagsFrozen = true;
|
|
714
|
+
const value = this.flags.value;
|
|
715
|
+
for (let i = 0; i < this.flagDefinitions.length; i++) {
|
|
716
|
+
const flagValue = this.flagDefinitions[i].id;
|
|
717
|
+
// tslint:disable-next-line: no-bitwise
|
|
718
|
+
const checked = (value & flagValue) !== 0;
|
|
719
|
+
this.flagChecks.at(i).setValue(checked);
|
|
720
|
+
}
|
|
721
|
+
this._flagsFrozen = false;
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Get the flags value from the flags controls.
|
|
725
|
+
*/
|
|
726
|
+
getFlagsValue() {
|
|
727
|
+
let flagsValue = 0;
|
|
728
|
+
for (let i = 0; i < this.flagDefinitions.length; i++) {
|
|
729
|
+
const flagValue = this.flagDefinitions[i].id;
|
|
730
|
+
if (this.flagChecks.at(i)?.value) {
|
|
731
|
+
// tslint:disable-next-line: no-bitwise
|
|
732
|
+
flagsValue |= flagValue;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
return flagsValue;
|
|
736
|
+
}
|
|
737
|
+
updateMetadataForm(item) {
|
|
738
|
+
if (!item) {
|
|
739
|
+
this.metadata.reset();
|
|
740
|
+
this.updateFlagControls();
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
this.title.setValue(item.title);
|
|
744
|
+
this.sortKey.setValue(item.sortKey);
|
|
745
|
+
this.description.setValue(item.description);
|
|
746
|
+
this.facet.setValue(item.facetId);
|
|
747
|
+
this.group.setValue(item.groupId);
|
|
748
|
+
this.flags.setValue(item.flags);
|
|
749
|
+
this.updateFlagControls();
|
|
750
|
+
this.metadata.markAsPristine();
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
getTypeIdName(typeId) {
|
|
754
|
+
const state = this._appRepository.getValue();
|
|
755
|
+
if (!state || !state.typeThesaurus) {
|
|
756
|
+
return typeId;
|
|
757
|
+
}
|
|
758
|
+
// strip :suffix if any
|
|
759
|
+
const i = typeId.lastIndexOf(':');
|
|
760
|
+
if (i > -1) {
|
|
761
|
+
typeId = typeId.substring(0, i);
|
|
762
|
+
}
|
|
763
|
+
const entry = state.typeThesaurus.entries?.find((e) => e.id === typeId);
|
|
764
|
+
return entry ? entry.value : typeId;
|
|
765
|
+
}
|
|
766
|
+
getRoleIdName(roleId) {
|
|
767
|
+
if (!roleId || !roleId.startsWith('fr.')) {
|
|
768
|
+
return roleId;
|
|
769
|
+
}
|
|
770
|
+
return this.getTypeIdName(roleId);
|
|
771
|
+
}
|
|
772
|
+
save() {
|
|
773
|
+
if (this.busy || !this.metadata.valid) {
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
// build item (its ID will be empty if new)
|
|
777
|
+
const item = { ...this._repository.getItem() };
|
|
778
|
+
if (!item) {
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
item.title = this.title.value?.trim();
|
|
782
|
+
item.sortKey = this.sortKey.value?.trim();
|
|
783
|
+
item.description = this.description.value?.trim();
|
|
784
|
+
item.facetId = this.facet.value?.trim() || undefined;
|
|
785
|
+
item.groupId = this.group.value?.trim() || undefined;
|
|
786
|
+
item.flags = this.flags.value;
|
|
787
|
+
// save: this will trigger a change in the store's item, reflected here
|
|
788
|
+
// by updating the metadata form
|
|
789
|
+
this.busy = true;
|
|
790
|
+
this._repository
|
|
791
|
+
.save(item)
|
|
792
|
+
.then((saved) => {
|
|
793
|
+
// once saved, a new item requires resetting the items list
|
|
794
|
+
if (!item.id) {
|
|
795
|
+
this._itemListRepository.clearCache();
|
|
796
|
+
this._itemListRepository.loadPage(1);
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
// an existing item instead just requires updating the entity
|
|
800
|
+
// in the items list if present (e.g. flags might have been changed)
|
|
801
|
+
this._itemListRepository.updateEntity({
|
|
802
|
+
id: item.id,
|
|
803
|
+
title: item.title,
|
|
804
|
+
description: item.description,
|
|
805
|
+
facetId: item.facetId,
|
|
806
|
+
groupId: item.groupId,
|
|
807
|
+
sortKey: item.sortKey,
|
|
808
|
+
flags: item.flags,
|
|
809
|
+
timeCreated: item.timeCreated,
|
|
810
|
+
creatorId: item.creatorId,
|
|
811
|
+
timeModified: item.timeModified,
|
|
812
|
+
userId: item.userId,
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
// this.metadata.markAsPristine();
|
|
816
|
+
// reload to force change in page URL
|
|
817
|
+
if (!item.id) {
|
|
818
|
+
this.id = saved.id;
|
|
819
|
+
this._router.navigate(['/items', saved.id]);
|
|
820
|
+
}
|
|
821
|
+
})
|
|
822
|
+
.finally(() => {
|
|
823
|
+
this.busy = false;
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
partExists(typeId, roleId) {
|
|
827
|
+
const groups = this._repository.getPartGroups();
|
|
828
|
+
if (!groups) {
|
|
829
|
+
return false;
|
|
830
|
+
}
|
|
831
|
+
return groups.some((g) => {
|
|
832
|
+
return g.parts.some((p) => p.typeId === typeId && ((!p.roleId && !roleId) || p.roleId === roleId));
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
addPart(def) {
|
|
836
|
+
if (!def && !this.newPartType.valid) {
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
if (!this.id) {
|
|
840
|
+
this._snackbar.open('Please save the item before adding parts', 'OK', {
|
|
841
|
+
duration: 3000,
|
|
842
|
+
});
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
const typeId = def ? def.typeId : this.newPartType.value.typeId;
|
|
846
|
+
const roleId = def ? def.roleId : this.newPartType.value.roleId;
|
|
847
|
+
if (this.partExists(typeId, roleId)) {
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
const route = this._libraryRouteService.buildPartEditorRoute(this.id, 'new', typeId, roleId);
|
|
851
|
+
// navigate to the editor
|
|
852
|
+
this._router.navigate([route.route], route.rid
|
|
853
|
+
? {
|
|
854
|
+
queryParams: {
|
|
855
|
+
rid: route.rid,
|
|
856
|
+
},
|
|
857
|
+
}
|
|
858
|
+
: {});
|
|
859
|
+
}
|
|
860
|
+
editPart(part) {
|
|
861
|
+
// build the target route to the appropriate part editor
|
|
862
|
+
const route = this._libraryRouteService.buildPartEditorRoute(part.itemId, part.id, part.typeId, part.roleId);
|
|
863
|
+
// navigate to the editor
|
|
864
|
+
this._router.navigate([route.route], route.rid
|
|
865
|
+
? {
|
|
866
|
+
queryParams: {
|
|
867
|
+
rid: route.rid,
|
|
868
|
+
},
|
|
869
|
+
}
|
|
870
|
+
: {});
|
|
871
|
+
}
|
|
872
|
+
previewPart(part) {
|
|
873
|
+
if (part.roleId?.startsWith('fr.')) {
|
|
874
|
+
// layer parts redirect to base-text
|
|
875
|
+
this._itemService
|
|
876
|
+
.getBaseTextPart(part.itemId)
|
|
877
|
+
.pipe(take$1(1))
|
|
878
|
+
.subscribe((p) => {
|
|
879
|
+
this._router.navigate(['preview', part.itemId, p.part.id, 'text'], {
|
|
880
|
+
queryParams: { lid: part.roleId },
|
|
881
|
+
});
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
else if (part.roleId === 'base-text') {
|
|
885
|
+
this._router.navigate(['preview', part.itemId, part.id, 'text']);
|
|
886
|
+
}
|
|
887
|
+
else {
|
|
888
|
+
this._router.navigate(['preview', part.itemId, part.id]);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
deletePart(part) {
|
|
892
|
+
if (this.busy) {
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
this._dialogService
|
|
896
|
+
.confirm('Confirm Deletion', `Delete part "${part.typeId}"?`)
|
|
897
|
+
.subscribe((result) => {
|
|
898
|
+
if (!result) {
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
// delete
|
|
902
|
+
this.busy = true;
|
|
903
|
+
this._repository.deletePart(part.id).then((_) => {
|
|
904
|
+
this.busy = false;
|
|
905
|
+
}, (error) => {
|
|
906
|
+
this.busy = false;
|
|
907
|
+
console.error(error);
|
|
908
|
+
this._snackbar.open('Error deleting part', 'OK');
|
|
909
|
+
});
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
addLayerPart(part) {
|
|
913
|
+
if (this.busy) {
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
let name = this.getTypeIdName(part.typeId);
|
|
917
|
+
if (part.roleId) {
|
|
918
|
+
name += ' for ' + this.getRoleIdName(part.roleId);
|
|
919
|
+
}
|
|
920
|
+
this.busy = true;
|
|
921
|
+
this._dialogService
|
|
922
|
+
.confirm('Confirm Addition', `Add layer "${name}"?`)
|
|
923
|
+
.subscribe((result) => {
|
|
924
|
+
if (!result) {
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
this._repository
|
|
928
|
+
.addNewLayerPart(part.typeId, part.roleId)
|
|
929
|
+
.finally(() => (this.busy = false));
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
setPartsScope(request) {
|
|
933
|
+
this._repository.setPartThesaurusScope(request.ids, request.scope);
|
|
934
|
+
}
|
|
935
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: ItemEditorComponent, deps: [{ token: i1$1.Router }, { token: i1$1.ActivatedRoute }, { token: i2$1.MatSnackBar }, { token: i1.AppRepository }, { token: EditedItemRepository }, { token: i2.ItemService }, { token: i6.ItemListRepository }, { token: i7.LibraryRouteService }, { token: i3$1.DialogService }, { token: i9$1.AuthJwtService }, { token: i2.UserLevelService }, { token: i10.FormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
936
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.1", type: ItemEditorComponent, selector: "cadmus-item-editor", ngImport: i0, template: "<mat-card appearance=\"outlined\">\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>\r\n <p *ngIf=\"id\">\r\n ID:\r\n <input\r\n [cdkCopyToClipboard]=\"(item$ | async)?.id || ''\"\r\n type=\"text\"\r\n readonly=\"true\"\r\n spellcheck=\"false\"\r\n matTooltip=\"Click to copy\"\r\n [value]=\"(item$ | async)?.id\"\r\n class=\"id\"\r\n />\r\n </p>\r\n <p *ngIf=\"item$ | async as item\">\r\n Last saved {{ item.timeModified | date : \"yyyy-MM-dd HH:mm:ss\" }} by\r\n {{ item.userId }}.<br />\r\n Created {{ item.timeCreated | date : \"yyyy-MM-dd HH:mm:ss\" }} by\r\n {{ item.creatorId }}.\r\n </p>\r\n\r\n <mat-progress-bar mode=\"indeterminate\" *ngIf=\"busy\"></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 <div class=\"form-row\">\r\n <!-- title -->\r\n <mat-form-field style=\"flex: 1 0 auto\">\r\n <mat-label>title</mat-label>\r\n <input matInput type=\"text\" id=\"title\" [formControl]=\"title\" />\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\r\n <!-- sortKey -->\r\n <mat-form-field style=\"flex: 1 0 auto\">\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 <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 <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 <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 class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>facet</mat-label>\r\n <mat-select [formControl]=\"facet\" required=\"true\">\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\r\n <!-- group -->\r\n <mat-form-field>\r\n <mat-label>group ID</mat-label>\r\n <input matInput [formControl]=\"group\" />\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 <fieldset>\r\n <legend>flags</legend>\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 </fieldset>\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]=\"userLevel < 2 || busy\"\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-label>part</mat-label>\r\n <mat-select [formControl]=\"newPartType\" required>\r\n <mat-option\r\n *ngFor=\"let p of newPartDefinitions$ | async\"\r\n [value]=\"p\"\r\n >\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 || 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 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 style=\"width: 100%\">\r\n <thead>\r\n <tr>\r\n <th style=\"width: 200px\"></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 <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 [disabled]=\"busy\"\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 [disabled]=\"userLevel < 2 || busy\"\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 <!-- preview -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Preview this part\"\r\n *ngIf=\"\r\n part\r\n | hasPreview\r\n : (previewJKeys$ | async)\r\n : (previewFKeys$ | async)\r\n \"\r\n (click)=\"previewPart(part)\"\r\n >\r\n <mat-icon>preview</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) || undefined\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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) || undefined\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\r\n ></cadmus-part-badge>\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 </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) || undefined\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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 id=\"layers\" *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) || undefined\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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) || undefined\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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 | date : \"yyyy-MM-dd HH:mm:ss\" }}\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 label=\"Th-Scopes\" *ngIf=\"parts$ | async as parts\">\r\n <!-- [parts]=\"parts | sort: 'typeId' | sort: 'roleId'\" -->\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 ></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:400;color:silver}#layers td{padding:0 6px}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}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}fieldset{border:1px solid silver;border-radius:6px;padding:6px;margin:8px 0}@media only screen and (max-width: 599px){.noif-lt-xs{display:none}}\n"], dependencies: [{ kind: "directive", type: i11.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i10.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i10.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i10.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i10.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i10.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i10.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i10.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i10.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i10.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { kind: "directive", type: i12.CdkCopyToClipboard, selector: "[cdkCopyToClipboard]", inputs: ["cdkCopyToClipboard", "cdkCopyToClipboardAttempts"], outputs: ["cdkCopyToClipboardCopied"] }, { kind: "component", type: i13.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i13.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i9.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex"], exportAs: ["matCheckbox"] }, { kind: "component", type: i15.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: i15.MatCardContent, selector: "mat-card-content" }, { kind: "component", type: i15.MatCardHeader, selector: "mat-card-header" }, { kind: "directive", type: i15.MatCardSubtitle, selector: "mat-card-subtitle, [mat-card-subtitle], [matCardSubtitle]" }, { kind: "directive", type: i15.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { kind: "component", type: i16.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "component", type: i17.MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["disabled", "expanded", "hideToggle", "togglePosition"], outputs: ["opened", "closed", "expandedChange", "afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { kind: "component", type: i17.MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["tabIndex", "expandedHeight", "collapsedHeight"] }, { kind: "directive", type: i17.MatExpansionPanelTitle, selector: "mat-panel-title" }, { kind: "directive", type: i17.MatExpansionPanelDescription, selector: "mat-panel-description" }, { kind: "component", type: i10$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i10$1.MatLabel, selector: "mat-label" }, { kind: "directive", type: i10$1.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i11$1.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i21.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "component", type: i22.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator"], exportAs: ["matSelect"] }, { kind: "component", type: i23.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "component", type: i24.MatTab, selector: "mat-tab", inputs: ["disabled"], exportAs: ["matTab"] }, { kind: "component", type: i24.MatTabGroup, selector: "mat-tab-group", inputs: ["color", "disableRipple", "fitInkBarToContent", "mat-stretch-tabs"], exportAs: ["matTabGroup"] }, { kind: "directive", type: i4.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "component", type: i5.PartBadgeComponent, selector: "cadmus-part-badge", inputs: ["badgeType", "typeThesaurus", "facetDefinition", "partTypeIds"] }, { kind: "component", type: MissingPartsComponent, selector: "cadmus-missing-parts", inputs: ["partDefinitions", "parts", "typeThesaurus"], outputs: ["addRequest"] }, { kind: "component", type: PartsScopeEditorComponent, selector: "cadmus-parts-scope-editor", inputs: ["parts", "readonly"], outputs: ["setScopeRequest"] }, { kind: "pipe", type: i11.AsyncPipe, name: "async" }, { kind: "pipe", type: i11.DatePipe, name: "date" }, { kind: "pipe", type: HasPreviewPipe, name: "hasPreview" }] }); }
|
|
937
|
+
}
|
|
938
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: ItemEditorComponent, decorators: [{
|
|
939
|
+
type: Component,
|
|
940
|
+
args: [{ selector: 'cadmus-item-editor', template: "<mat-card appearance=\"outlined\">\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>\r\n <p *ngIf=\"id\">\r\n ID:\r\n <input\r\n [cdkCopyToClipboard]=\"(item$ | async)?.id || ''\"\r\n type=\"text\"\r\n readonly=\"true\"\r\n spellcheck=\"false\"\r\n matTooltip=\"Click to copy\"\r\n [value]=\"(item$ | async)?.id\"\r\n class=\"id\"\r\n />\r\n </p>\r\n <p *ngIf=\"item$ | async as item\">\r\n Last saved {{ item.timeModified | date : \"yyyy-MM-dd HH:mm:ss\" }} by\r\n {{ item.userId }}.<br />\r\n Created {{ item.timeCreated | date : \"yyyy-MM-dd HH:mm:ss\" }} by\r\n {{ item.creatorId }}.\r\n </p>\r\n\r\n <mat-progress-bar mode=\"indeterminate\" *ngIf=\"busy\"></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 <div class=\"form-row\">\r\n <!-- title -->\r\n <mat-form-field style=\"flex: 1 0 auto\">\r\n <mat-label>title</mat-label>\r\n <input matInput type=\"text\" id=\"title\" [formControl]=\"title\" />\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\r\n <!-- sortKey -->\r\n <mat-form-field style=\"flex: 1 0 auto\">\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 <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 <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 <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 class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>facet</mat-label>\r\n <mat-select [formControl]=\"facet\" required=\"true\">\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\r\n <!-- group -->\r\n <mat-form-field>\r\n <mat-label>group ID</mat-label>\r\n <input matInput [formControl]=\"group\" />\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 <fieldset>\r\n <legend>flags</legend>\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 </fieldset>\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]=\"userLevel < 2 || busy\"\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-label>part</mat-label>\r\n <mat-select [formControl]=\"newPartType\" required>\r\n <mat-option\r\n *ngFor=\"let p of newPartDefinitions$ | async\"\r\n [value]=\"p\"\r\n >\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 || 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 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 style=\"width: 100%\">\r\n <thead>\r\n <tr>\r\n <th style=\"width: 200px\"></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 <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 [disabled]=\"busy\"\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 [disabled]=\"userLevel < 2 || busy\"\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 <!-- preview -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Preview this part\"\r\n *ngIf=\"\r\n part\r\n | hasPreview\r\n : (previewJKeys$ | async)\r\n : (previewFKeys$ | async)\r\n \"\r\n (click)=\"previewPart(part)\"\r\n >\r\n <mat-icon>preview</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) || undefined\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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) || undefined\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\r\n ></cadmus-part-badge>\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 </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) || undefined\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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 id=\"layers\" *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) || undefined\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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) || undefined\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"(typeThesaurus$ | async) || undefined\"\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 | date : \"yyyy-MM-dd HH:mm:ss\" }}\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 label=\"Th-Scopes\" *ngIf=\"parts$ | async as parts\">\r\n <!-- [parts]=\"parts | sort: 'typeId' | sort: 'roleId'\" -->\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 ></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:400;color:silver}#layers td{padding:0 6px}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}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}fieldset{border:1px solid silver;border-radius:6px;padding:6px;margin:8px 0}@media only screen and (max-width: 599px){.noif-lt-xs{display:none}}\n"] }]
|
|
936
941
|
}], ctorParameters: function () { return [{ type: i1$1.Router }, { type: i1$1.ActivatedRoute }, { type: i2$1.MatSnackBar }, { type: i1.AppRepository }, { type: EditedItemRepository }, { type: i2.ItemService }, { type: i6.ItemListRepository }, { type: i7.LibraryRouteService }, { type: i3$1.DialogService }, { type: i9$1.AuthJwtService }, { type: i2.UserLevelService }, { type: i10.FormBuilder }]; } });
|
|
937
942
|
|
|
938
|
-
// https://github.com/ng-packagr/ng-packagr/issues/778
|
|
939
|
-
const RouterModuleForChild = RouterModule.forChild([
|
|
940
|
-
{ path: '', pathMatch: 'full', component: ItemEditorComponent },
|
|
941
|
-
]);
|
|
942
|
-
class CadmusItemEditorModule {
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
997
|
-
type: NgModule,
|
|
998
|
-
args: [{
|
|
999
|
-
imports: [
|
|
1000
|
-
CommonModule,
|
|
1001
|
-
ReactiveFormsModule,
|
|
1002
|
-
FormsModule,
|
|
1003
|
-
RouterModuleForChild,
|
|
1004
|
-
ClipboardModule,
|
|
1005
|
-
// material
|
|
1006
|
-
MatButtonModule,
|
|
1007
|
-
MatCheckboxModule,
|
|
1008
|
-
MatCardModule,
|
|
1009
|
-
MatDividerModule,
|
|
1010
|
-
MatExpansionModule,
|
|
1011
|
-
MatFormFieldModule,
|
|
1012
|
-
MatIconModule,
|
|
1013
|
-
MatInputModule,
|
|
1014
|
-
MatProgressBarModule,
|
|
1015
|
-
MatSelectModule,
|
|
1016
|
-
MatTabsModule,
|
|
1017
|
-
MatTooltipModule,
|
|
1018
|
-
// cadmus
|
|
1019
|
-
CadmusCoreModule,
|
|
1020
|
-
CadmusApiModule,
|
|
1021
|
-
CadmusUiModule,
|
|
1022
|
-
CadmusStateModule,
|
|
1023
|
-
NgToolsModule,
|
|
1024
|
-
NgMatToolsModule,
|
|
1025
|
-
],
|
|
1026
|
-
declarations: [
|
|
1027
|
-
ItemEditorComponent,
|
|
1028
|
-
MissingPartsComponent,
|
|
1029
|
-
PartsScopeEditorComponent,
|
|
1030
|
-
HasPreviewPipe,
|
|
1031
|
-
],
|
|
1032
|
-
exports: [ItemEditorComponent],
|
|
1033
|
-
}]
|
|
943
|
+
// https://github.com/ng-packagr/ng-packagr/issues/778
|
|
944
|
+
const RouterModuleForChild = RouterModule.forChild([
|
|
945
|
+
{ path: '', pathMatch: 'full', component: ItemEditorComponent },
|
|
946
|
+
]);
|
|
947
|
+
class CadmusItemEditorModule {
|
|
948
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: CadmusItemEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
949
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.1", ngImport: i0, type: CadmusItemEditorModule, declarations: [ItemEditorComponent,
|
|
950
|
+
MissingPartsComponent,
|
|
951
|
+
PartsScopeEditorComponent,
|
|
952
|
+
HasPreviewPipe], imports: [CommonModule,
|
|
953
|
+
ReactiveFormsModule,
|
|
954
|
+
FormsModule, i1$1.RouterModule, ClipboardModule,
|
|
955
|
+
// material
|
|
956
|
+
MatButtonModule,
|
|
957
|
+
MatCheckboxModule,
|
|
958
|
+
MatCardModule,
|
|
959
|
+
MatDividerModule,
|
|
960
|
+
MatExpansionModule,
|
|
961
|
+
MatFormFieldModule,
|
|
962
|
+
MatIconModule,
|
|
963
|
+
MatInputModule,
|
|
964
|
+
MatProgressBarModule,
|
|
965
|
+
MatSelectModule,
|
|
966
|
+
MatTabsModule,
|
|
967
|
+
MatTooltipModule,
|
|
968
|
+
// cadmus
|
|
969
|
+
CadmusCoreModule,
|
|
970
|
+
CadmusApiModule,
|
|
971
|
+
CadmusUiModule,
|
|
972
|
+
CadmusStateModule,
|
|
973
|
+
NgToolsModule,
|
|
974
|
+
NgMatToolsModule], exports: [ItemEditorComponent] }); }
|
|
975
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: CadmusItemEditorModule, imports: [CommonModule,
|
|
976
|
+
ReactiveFormsModule,
|
|
977
|
+
FormsModule,
|
|
978
|
+
RouterModuleForChild,
|
|
979
|
+
ClipboardModule,
|
|
980
|
+
// material
|
|
981
|
+
MatButtonModule,
|
|
982
|
+
MatCheckboxModule,
|
|
983
|
+
MatCardModule,
|
|
984
|
+
MatDividerModule,
|
|
985
|
+
MatExpansionModule,
|
|
986
|
+
MatFormFieldModule,
|
|
987
|
+
MatIconModule,
|
|
988
|
+
MatInputModule,
|
|
989
|
+
MatProgressBarModule,
|
|
990
|
+
MatSelectModule,
|
|
991
|
+
MatTabsModule,
|
|
992
|
+
MatTooltipModule,
|
|
993
|
+
// cadmus
|
|
994
|
+
CadmusCoreModule,
|
|
995
|
+
CadmusApiModule,
|
|
996
|
+
CadmusUiModule,
|
|
997
|
+
CadmusStateModule,
|
|
998
|
+
NgToolsModule,
|
|
999
|
+
NgMatToolsModule] }); }
|
|
1000
|
+
}
|
|
1001
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: CadmusItemEditorModule, decorators: [{
|
|
1002
|
+
type: NgModule,
|
|
1003
|
+
args: [{
|
|
1004
|
+
imports: [
|
|
1005
|
+
CommonModule,
|
|
1006
|
+
ReactiveFormsModule,
|
|
1007
|
+
FormsModule,
|
|
1008
|
+
RouterModuleForChild,
|
|
1009
|
+
ClipboardModule,
|
|
1010
|
+
// material
|
|
1011
|
+
MatButtonModule,
|
|
1012
|
+
MatCheckboxModule,
|
|
1013
|
+
MatCardModule,
|
|
1014
|
+
MatDividerModule,
|
|
1015
|
+
MatExpansionModule,
|
|
1016
|
+
MatFormFieldModule,
|
|
1017
|
+
MatIconModule,
|
|
1018
|
+
MatInputModule,
|
|
1019
|
+
MatProgressBarModule,
|
|
1020
|
+
MatSelectModule,
|
|
1021
|
+
MatTabsModule,
|
|
1022
|
+
MatTooltipModule,
|
|
1023
|
+
// cadmus
|
|
1024
|
+
CadmusCoreModule,
|
|
1025
|
+
CadmusApiModule,
|
|
1026
|
+
CadmusUiModule,
|
|
1027
|
+
CadmusStateModule,
|
|
1028
|
+
NgToolsModule,
|
|
1029
|
+
NgMatToolsModule,
|
|
1030
|
+
],
|
|
1031
|
+
declarations: [
|
|
1032
|
+
ItemEditorComponent,
|
|
1033
|
+
MissingPartsComponent,
|
|
1034
|
+
PartsScopeEditorComponent,
|
|
1035
|
+
HasPreviewPipe,
|
|
1036
|
+
],
|
|
1037
|
+
exports: [ItemEditorComponent],
|
|
1038
|
+
}]
|
|
1034
1039
|
}] });
|
|
1035
1040
|
|
|
1036
|
-
/*
|
|
1037
|
-
* Public API Surface of cadmus-item-editor
|
|
1041
|
+
/*
|
|
1042
|
+
* Public API Surface of cadmus-item-editor
|
|
1038
1043
|
*/
|
|
1039
1044
|
|
|
1040
|
-
/**
|
|
1041
|
-
* Generated bundle index. Do not edit.
|
|
1045
|
+
/**
|
|
1046
|
+
* Generated bundle index. Do not edit.
|
|
1042
1047
|
*/
|
|
1043
1048
|
|
|
1044
1049
|
export { CadmusItemEditorModule, EditedItemRepository, ItemEditorComponent, RouterModuleForChild };
|
|
1045
1050
|
//# sourceMappingURL=myrmidon-cadmus-item-editor.mjs.map
|
|
1046
|
-
//# sourceMappingURL=myrmidon-cadmus-item-editor.mjs.map
|