@myrmidon/cadmus-item-editor 2.0.7 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +334 -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 +979 -979
- 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 -44
- 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 -124
- package/esm2020/lib/state/edited-item.repository.mjs +0 -332
- package/fesm2015/myrmidon-cadmus-item-editor.mjs +0 -1043
- package/fesm2015/myrmidon-cadmus-item-editor.mjs.map +0 -1
- package/fesm2020/myrmidon-cadmus-item-editor.mjs.map +0 -1
|
@@ -52,1000 +52,1000 @@ 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.
|
|
159
|
-
this._store.update((
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* @
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
.
|
|
231
|
-
.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
//
|
|
235
|
-
//
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
* @
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
.
|
|
275
|
-
.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
* @param
|
|
297
|
-
* @
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
.
|
|
320
|
-
.
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
* @param
|
|
342
|
-
* @
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
.
|
|
355
|
-
.
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
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
|
+
const facet = this.pickDefaultFacet(app.facets);
|
|
159
|
+
this._store.update(updateRequestStatus('edited-item', 'success'));
|
|
160
|
+
this._store.update((state) => ({
|
|
161
|
+
...state,
|
|
162
|
+
item: {
|
|
163
|
+
id: '',
|
|
164
|
+
title: '',
|
|
165
|
+
description: '',
|
|
166
|
+
facetId: facet?.id || '',
|
|
167
|
+
groupId: '',
|
|
168
|
+
sortKey: '',
|
|
169
|
+
flags: 0,
|
|
170
|
+
timeCreated: new Date(),
|
|
171
|
+
creatorId: '',
|
|
172
|
+
timeModified: new Date(),
|
|
173
|
+
userId: '',
|
|
174
|
+
},
|
|
175
|
+
parts: [],
|
|
176
|
+
partGroups: [],
|
|
177
|
+
layerPartInfos: layers,
|
|
178
|
+
facet: facet,
|
|
179
|
+
}));
|
|
180
|
+
this._store.update(setProp('newPartDefinitions', this.getNewPartDefinitions()));
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
// existing item
|
|
185
|
+
forkJoin({
|
|
186
|
+
item: this._itemService.getItem(itemId, true),
|
|
187
|
+
layers: this._itemService.getItemLayerInfo(itemId, true),
|
|
188
|
+
})
|
|
189
|
+
.pipe(take(1))
|
|
190
|
+
.subscribe({
|
|
191
|
+
next: (result) => {
|
|
192
|
+
this._store.update(updateRequestStatus('edited-item', 'success'));
|
|
193
|
+
const itemFacet = app.facets.find((f) => {
|
|
194
|
+
return f.id === result.item.facetId;
|
|
195
|
+
});
|
|
196
|
+
const facetParts = itemFacet ? itemFacet.partDefinitions : [];
|
|
197
|
+
this._store.update((state) => ({
|
|
198
|
+
...state,
|
|
199
|
+
item: result.item,
|
|
200
|
+
parts: result.item.parts || [],
|
|
201
|
+
partGroups: this._itemService.groupParts(result.item.parts || [], facetParts),
|
|
202
|
+
layerPartInfos: result.layers,
|
|
203
|
+
facet: itemFacet,
|
|
204
|
+
}));
|
|
205
|
+
this._store.update(setProp('newPartDefinitions', this.getNewPartDefinitions()));
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Ensure that the item with the specified ID is loaded.
|
|
212
|
+
*
|
|
213
|
+
* @param id The item ID.
|
|
214
|
+
*/
|
|
215
|
+
ensureItemLoaded(id) {
|
|
216
|
+
if (this.getItem()?.id === id) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
this.load(id);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Save the specified item in the backend and update this store.
|
|
223
|
+
*
|
|
224
|
+
* @param item The item.
|
|
225
|
+
* @returns Promise with saved item.
|
|
226
|
+
*/
|
|
227
|
+
save(item) {
|
|
228
|
+
return new Promise((resolve, reject) => {
|
|
229
|
+
this._itemService
|
|
230
|
+
.addItem(item)
|
|
231
|
+
.pipe(take(1))
|
|
232
|
+
.subscribe({
|
|
233
|
+
next: (saved) => {
|
|
234
|
+
// update the item and the selected facet from it;
|
|
235
|
+
// this is required when the item was new, and thus loaded
|
|
236
|
+
// with the default facet before saving it
|
|
237
|
+
const app = this._appRepository.getValue();
|
|
238
|
+
const itemFacet = app.facets.find((f) => {
|
|
239
|
+
return f.id === saved.facetId;
|
|
240
|
+
});
|
|
241
|
+
this._store.update((state) => ({
|
|
242
|
+
...state,
|
|
243
|
+
item: saved,
|
|
244
|
+
facet: itemFacet,
|
|
245
|
+
}));
|
|
246
|
+
// new-parts definitions
|
|
247
|
+
this._store.update(setProp('newPartDefinitions', this.getNewPartDefinitions()));
|
|
248
|
+
resolve(saved);
|
|
249
|
+
},
|
|
250
|
+
error: (error) => {
|
|
251
|
+
if (error) {
|
|
252
|
+
console.error(JSON.stringify(error));
|
|
253
|
+
}
|
|
254
|
+
reject({ message: 'Error saving item ' + item.id, error: error });
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Delete the specified part from this edited item.
|
|
261
|
+
*
|
|
262
|
+
* @param id The part's ID.
|
|
263
|
+
* @returns Promise with part ID.
|
|
264
|
+
*/
|
|
265
|
+
deletePart(id) {
|
|
266
|
+
return new Promise((resolve, reject) => {
|
|
267
|
+
const itemId = this._store.getValue().item?.id;
|
|
268
|
+
if (!itemId) {
|
|
269
|
+
reject({
|
|
270
|
+
message: 'Cannot delete part of unsaved item',
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
this._itemService
|
|
274
|
+
.deletePart(id)
|
|
275
|
+
.pipe(take(1))
|
|
276
|
+
.subscribe({
|
|
277
|
+
next: (_) => {
|
|
278
|
+
this.load(itemId);
|
|
279
|
+
resolve(id);
|
|
280
|
+
},
|
|
281
|
+
error: (error) => {
|
|
282
|
+
if (error) {
|
|
283
|
+
console.error(JSON.stringify(error));
|
|
284
|
+
}
|
|
285
|
+
reject({
|
|
286
|
+
message: "Error deleting item's part " + id,
|
|
287
|
+
error: error,
|
|
288
|
+
});
|
|
289
|
+
},
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Add a new layer part to this item.
|
|
295
|
+
*
|
|
296
|
+
* @param typeId The part type ID.
|
|
297
|
+
* @param roleId The part role ID.
|
|
298
|
+
* @returns Promise with new part.
|
|
299
|
+
*/
|
|
300
|
+
addNewLayerPart(typeId, roleId) {
|
|
301
|
+
return new Promise((resolve, reject) => {
|
|
302
|
+
const itemId = this._store.getValue().item?.id;
|
|
303
|
+
if (!itemId) {
|
|
304
|
+
reject({
|
|
305
|
+
message: 'Cannot add part to unsaved item',
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
const part = {
|
|
309
|
+
itemId: itemId,
|
|
310
|
+
typeId,
|
|
311
|
+
roleId,
|
|
312
|
+
id: '',
|
|
313
|
+
creatorId: '',
|
|
314
|
+
userId: '',
|
|
315
|
+
timeCreated: new Date(),
|
|
316
|
+
timeModified: new Date(),
|
|
317
|
+
};
|
|
318
|
+
this._itemService
|
|
319
|
+
.addPart(part)
|
|
320
|
+
.pipe(take(1))
|
|
321
|
+
.subscribe({
|
|
322
|
+
next: (part) => {
|
|
323
|
+
this.load(itemId);
|
|
324
|
+
resolve(part);
|
|
325
|
+
},
|
|
326
|
+
error: (error) => {
|
|
327
|
+
if (error) {
|
|
328
|
+
console.error(JSON.stringify(error));
|
|
329
|
+
}
|
|
330
|
+
reject({
|
|
331
|
+
message: 'Error adding new layer part for item ' + itemId,
|
|
332
|
+
error: error,
|
|
333
|
+
});
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Set the scope for the specified parts in this item.
|
|
340
|
+
*
|
|
341
|
+
* @param ids The part IDs.
|
|
342
|
+
* @param scope The scope to set.
|
|
343
|
+
* @returns Promise.
|
|
344
|
+
*/
|
|
345
|
+
setPartThesaurusScope(ids, scope) {
|
|
346
|
+
return new Promise((resolve, reject) => {
|
|
347
|
+
const itemId = this._store.getValue().item?.id;
|
|
348
|
+
if (!itemId) {
|
|
349
|
+
reject({
|
|
350
|
+
message: 'Cannot set scope for unsaved item',
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
this._itemService
|
|
354
|
+
.setPartThesaurusScope(ids, scope)
|
|
355
|
+
.pipe(take(1))
|
|
356
|
+
.subscribe({
|
|
357
|
+
next: (_) => {
|
|
358
|
+
this.load(itemId);
|
|
359
|
+
resolve(true);
|
|
360
|
+
},
|
|
361
|
+
error: (error) => {
|
|
362
|
+
if (error) {
|
|
363
|
+
console.error(JSON.stringify(error));
|
|
364
|
+
}
|
|
365
|
+
reject({
|
|
366
|
+
message: "Error setting item's part scope",
|
|
367
|
+
error: error,
|
|
368
|
+
});
|
|
369
|
+
},
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.3", ngImport: i0, type: EditedItemRepository, deps: [{ token: i1.AppRepository }, { token: i2.ItemService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
374
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.3", ngImport: i0, type: EditedItemRepository, providedIn: 'root' }); }
|
|
375
|
+
}
|
|
376
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.3", ngImport: i0, type: EditedItemRepository, decorators: [{
|
|
377
|
+
type: Injectable,
|
|
378
|
+
args: [{ providedIn: 'root' }]
|
|
378
379
|
}], ctorParameters: function () { return [{ type: i1.AppRepository }, { type: i2.ItemService }]; } });
|
|
379
380
|
|
|
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
|
|
381
|
+
class MissingPartsComponent {
|
|
382
|
+
get partDefinitions() {
|
|
383
|
+
return this._partDefinitions;
|
|
384
|
+
}
|
|
385
|
+
set partDefinitions(value) {
|
|
386
|
+
this._partDefinitions = value;
|
|
387
|
+
this.updateMissing();
|
|
388
|
+
}
|
|
389
|
+
get parts() {
|
|
390
|
+
return this._parts;
|
|
391
|
+
}
|
|
392
|
+
set parts(value) {
|
|
393
|
+
this._parts = value;
|
|
394
|
+
this.updateMissing();
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* The types thesaurus.
|
|
398
|
+
*/
|
|
399
|
+
get typeThesaurus() {
|
|
400
|
+
return this._typeThesaurus;
|
|
401
|
+
}
|
|
402
|
+
set typeThesaurus(value) {
|
|
403
|
+
this._typeThesaurus = value;
|
|
404
|
+
this.updateMissing();
|
|
405
|
+
}
|
|
406
|
+
constructor() {
|
|
407
|
+
this.missingDefinitions = [];
|
|
408
|
+
this.addRequest = new EventEmitter();
|
|
409
|
+
}
|
|
410
|
+
ngOnInit() { }
|
|
411
|
+
isPartPresent(typeId, roleId) {
|
|
412
|
+
if (!this._partDefinitions) {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
return this._partDefinitions.some((d) => d.typeId === typeId && d.roleId === roleId);
|
|
416
|
+
}
|
|
417
|
+
updateMissing() {
|
|
418
|
+
this.missingDefinitions.length = 0;
|
|
419
|
+
if (!this._partDefinitions) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
for (let i = 0; i < this._partDefinitions.length; i++) {
|
|
423
|
+
const def = this._partDefinitions[i];
|
|
424
|
+
if (!this.isPartPresent(def.typeId, def.roleId)) {
|
|
425
|
+
this.missingDefinitions.push(def);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.3", ngImport: i0, type: MissingPartsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
430
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.3", 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"] }] }); }
|
|
431
|
+
}
|
|
432
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.3", ngImport: i0, type: MissingPartsComponent, decorators: [{
|
|
433
|
+
type: Component,
|
|
434
|
+
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" }]
|
|
435
|
+
}], ctorParameters: function () { return []; }, propDecorators: { partDefinitions: [{
|
|
436
|
+
type: Input
|
|
437
|
+
}], parts: [{
|
|
438
|
+
type: Input
|
|
439
|
+
}], typeThesaurus: [{
|
|
440
|
+
type: Input
|
|
441
|
+
}], addRequest: [{
|
|
442
|
+
type: Output
|
|
442
443
|
}] } });
|
|
443
444
|
|
|
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
|
-
this.
|
|
459
|
-
|
|
460
|
-
this.
|
|
461
|
-
this.
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
this.
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
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
|
-
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
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
|
|
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
|
|
445
|
+
/**
|
|
446
|
+
* Parts thesaurus scope dumb editor component.
|
|
447
|
+
* This is used to set the thesaurus scope of multiple item's parts at once
|
|
448
|
+
* in the item editor.
|
|
449
|
+
*/
|
|
450
|
+
class PartsScopeEditorComponent {
|
|
451
|
+
get parts() {
|
|
452
|
+
return this._parts;
|
|
453
|
+
}
|
|
454
|
+
set parts(value) {
|
|
455
|
+
this._parts = value;
|
|
456
|
+
this.updateForm();
|
|
457
|
+
}
|
|
458
|
+
constructor(_formBuilder, _facetService, _dialogService, _appRepository, _colorService, _editedItemRepository) {
|
|
459
|
+
this._formBuilder = _formBuilder;
|
|
460
|
+
this._facetService = _facetService;
|
|
461
|
+
this._dialogService = _dialogService;
|
|
462
|
+
this._appRepository = _appRepository;
|
|
463
|
+
this._colorService = _colorService;
|
|
464
|
+
this._editedItemRepository = _editedItemRepository;
|
|
465
|
+
// events
|
|
466
|
+
this.setScopeRequest = new EventEmitter();
|
|
467
|
+
// form
|
|
468
|
+
this.checks = _formBuilder.array([], CustomValidators.minChecked(1));
|
|
469
|
+
this.scope = _formBuilder.control(null, [
|
|
470
|
+
Validators.maxLength(50),
|
|
471
|
+
Validators.pattern(/^[-a-zA-Z0-9_]+$/),
|
|
472
|
+
]);
|
|
473
|
+
this.form = _formBuilder.group({
|
|
474
|
+
checks: this.checks,
|
|
475
|
+
scope: this.scope,
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
ngOnInit() { }
|
|
479
|
+
updateForm() {
|
|
480
|
+
this.checks.clear();
|
|
481
|
+
if (!this._parts || this._parts.length === 0) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
for (let i = 0; i < this._parts.length; i++) {
|
|
485
|
+
this.checks.push(this._formBuilder.control(false));
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
getPartColor(typeId, roleId) {
|
|
489
|
+
const facet = this._editedItemRepository.getFacet();
|
|
490
|
+
return this._facetService.getPartColor(typeId, roleId, facet);
|
|
491
|
+
}
|
|
492
|
+
getContrastColor(typeId, roleId) {
|
|
493
|
+
const rgb = this.getPartColor(typeId, roleId);
|
|
494
|
+
return this._colorService.getContrastColor(rgb);
|
|
495
|
+
}
|
|
496
|
+
getTypeIdName(typeId) {
|
|
497
|
+
const state = this._appRepository.getValue();
|
|
498
|
+
if (!state || !state.typeThesaurus) {
|
|
499
|
+
return typeId;
|
|
500
|
+
}
|
|
501
|
+
// strip :suffix if any
|
|
502
|
+
const i = typeId.lastIndexOf(':');
|
|
503
|
+
if (i > -1) {
|
|
504
|
+
typeId = typeId.substring(0, i);
|
|
505
|
+
}
|
|
506
|
+
const entry = state.typeThesaurus.entries?.find((e) => e.id === typeId);
|
|
507
|
+
return entry ? entry.value : typeId;
|
|
508
|
+
}
|
|
509
|
+
getRoleIdName(roleId) {
|
|
510
|
+
if (!roleId || !roleId.startsWith('fr.')) {
|
|
511
|
+
return roleId;
|
|
512
|
+
}
|
|
513
|
+
return this.getTypeIdName(roleId);
|
|
514
|
+
}
|
|
515
|
+
submit() {
|
|
516
|
+
if (this.form.invalid || !this._parts) {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
const ids = [];
|
|
520
|
+
for (let i = 0; i < this.checks.length; i++) {
|
|
521
|
+
if (this.checks.controls[i].value === true) {
|
|
522
|
+
ids.push(this._parts[i].id);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
let msg = this.scope.value
|
|
526
|
+
? `Assign scope "${this.scope.value}" to ${ids.length} part`
|
|
527
|
+
: `Remove scope from ${ids.length} part`;
|
|
528
|
+
msg += ids.length > 1 ? 's?' : '?';
|
|
529
|
+
this._dialogService.confirm('Confirm Scopes', msg).subscribe((result) => {
|
|
530
|
+
if (!result) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
this.setScopeRequest.emit({
|
|
534
|
+
ids,
|
|
535
|
+
scope: this.scope.value,
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.3", 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 }); }
|
|
540
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.3", 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></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 class=\"fit-width\">\r\n <mat-checkbox [formControlName]=\"i\"></mat-checkbox>\r\n </td>\r\n <td>\r\n <span\r\n class=\"model-type\"\r\n [style.background-color]=\"\r\n getPartColor($any(parts)[i].typeId, $any(parts)[i].roleId)\r\n \"\r\n [style.color]=\"\r\n getContrastColor($any(parts)[i].typeId, $any(parts)[i].roleId)\r\n \"\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>\r\n {{ $any(parts)[i].timeModified | date : \"yyyy-MM-dd HH:mm:ss\" }}\r\n </td>\r\n <td>{{ $any(parts)[i].userId }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n <div class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>scope</mat-label>\r\n <input matInput formControlName=\"scope\" />\r\n <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 <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 </div>\r\n</form>\r\n", styles: ["th{font-weight:400;color:silver;text-align:left}td{padding:0 6px}td.fit-width{width:1px;white-space:nowrap}span.model-type{padding:4px;border-radius:6px}table#parts{border-collapse:separate;border-spacing:0 8px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}\n"], dependencies: [{ kind: "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" }] }); }
|
|
541
|
+
}
|
|
542
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.3", ngImport: i0, type: PartsScopeEditorComponent, decorators: [{
|
|
543
|
+
type: Component,
|
|
544
|
+
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></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 class=\"fit-width\">\r\n <mat-checkbox [formControlName]=\"i\"></mat-checkbox>\r\n </td>\r\n <td>\r\n <span\r\n class=\"model-type\"\r\n [style.background-color]=\"\r\n getPartColor($any(parts)[i].typeId, $any(parts)[i].roleId)\r\n \"\r\n [style.color]=\"\r\n getContrastColor($any(parts)[i].typeId, $any(parts)[i].roleId)\r\n \"\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>\r\n {{ $any(parts)[i].timeModified | date : \"yyyy-MM-dd HH:mm:ss\" }}\r\n </td>\r\n <td>{{ $any(parts)[i].userId }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n <div class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>scope</mat-label>\r\n <input matInput formControlName=\"scope\" />\r\n <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 <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 </div>\r\n</form>\r\n", styles: ["th{font-weight:400;color:silver;text-align:left}td{padding:0 6px}td.fit-width{width:1px;white-space:nowrap}span.model-type{padding:4px;border-radius:6px}table#parts{border-collapse:separate;border-spacing:0 8px}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}\n"] }]
|
|
545
|
+
}], ctorParameters: function () { return [{ type: i10.FormBuilder }, { type: i2.FacetService }, { type: i3$1.DialogService }, { type: i1.AppRepository }, { type: i5.ColorService }, { type: EditedItemRepository }]; }, propDecorators: { parts: [{
|
|
546
|
+
type: Input
|
|
547
|
+
}], readonly: [{
|
|
548
|
+
type: Input
|
|
549
|
+
}], setScopeRequest: [{
|
|
550
|
+
type: Output
|
|
550
551
|
}] } });
|
|
551
552
|
|
|
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
|
-
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
591
|
-
type: Pipe,
|
|
592
|
-
args: [{
|
|
593
|
-
name: 'hasPreview',
|
|
594
|
-
}]
|
|
553
|
+
/**
|
|
554
|
+
* A pipe used locally in the item editor to determine whether
|
|
555
|
+
* any of its parts can be previewed. To this end, this pipe requires
|
|
556
|
+
* the part plus the list of available renderers keys and flatteners
|
|
557
|
+
* keys. When the part is a base text, it is checked against flatteners
|
|
558
|
+
* and renderers; else, it is checked against renderers only.
|
|
559
|
+
* Ideally, a text part should have a flattener, while any other part
|
|
560
|
+
* should have a renderer. When there is no flattener, we fallback
|
|
561
|
+
* to the renderer if any.
|
|
562
|
+
*/
|
|
563
|
+
class HasPreviewPipe {
|
|
564
|
+
/**
|
|
565
|
+
* Transform the received part into a boolean value telling whether
|
|
566
|
+
* that part can be previewed or not.
|
|
567
|
+
*
|
|
568
|
+
* @param value The part.
|
|
569
|
+
* @param rKeys The list of available renderers keys.
|
|
570
|
+
* @param fKeys The list of available flatteners keys.
|
|
571
|
+
* @returns True if preview available; else false.
|
|
572
|
+
*/
|
|
573
|
+
transform(value, rKeys, fKeys) {
|
|
574
|
+
if (!value) {
|
|
575
|
+
return false;
|
|
576
|
+
}
|
|
577
|
+
// the preview key is equal to the typeId, optionally followed by
|
|
578
|
+
// | and the roleId when present (except when it's "base-text")
|
|
579
|
+
if (value.roleId === 'base-text') {
|
|
580
|
+
return fKeys?.find((k) => k === value.typeId) ||
|
|
581
|
+
rKeys?.find((k) => k === value.typeId)
|
|
582
|
+
? true
|
|
583
|
+
: false;
|
|
584
|
+
}
|
|
585
|
+
const key = value.roleId ? `${value.typeId}|${value.roleId}` : value.typeId;
|
|
586
|
+
return rKeys?.find((k) => k === key) ? true : false;
|
|
587
|
+
}
|
|
588
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.3", ngImport: i0, type: HasPreviewPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
589
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.0.3", ngImport: i0, type: HasPreviewPipe, name: "hasPreview" }); }
|
|
590
|
+
}
|
|
591
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.3", ngImport: i0, type: HasPreviewPipe, decorators: [{
|
|
592
|
+
type: Pipe,
|
|
593
|
+
args: [{
|
|
594
|
+
name: 'hasPreview',
|
|
595
|
+
}]
|
|
595
596
|
}] });
|
|
596
597
|
|
|
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
|
-
}
|
|
936
|
-
ItemEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.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 });
|
|
937
|
-
ItemEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.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: 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"], 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" }] });
|
|
938
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
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"] }]
|
|
598
|
+
/**
|
|
599
|
+
* Item editor. This can edit a new or existing item's metadata and parts.
|
|
600
|
+
* The ID of the item being edited is extracted from the route. For a new item
|
|
601
|
+
* this is 'new', which here is stored as an empty string.
|
|
602
|
+
*/
|
|
603
|
+
class ItemEditorComponent {
|
|
604
|
+
constructor(_router, _route, _snackbar, _appRepository, _repository, _itemService, _itemListRepository, _libraryRouteService, _dialogService, _authService, _userLevelService, _formBuilder) {
|
|
605
|
+
this._router = _router;
|
|
606
|
+
this._route = _route;
|
|
607
|
+
this._snackbar = _snackbar;
|
|
608
|
+
this._appRepository = _appRepository;
|
|
609
|
+
this._repository = _repository;
|
|
610
|
+
this._itemService = _itemService;
|
|
611
|
+
this._itemListRepository = _itemListRepository;
|
|
612
|
+
this._libraryRouteService = _libraryRouteService;
|
|
613
|
+
this._dialogService = _dialogService;
|
|
614
|
+
this._authService = _authService;
|
|
615
|
+
this._userLevelService = _userLevelService;
|
|
616
|
+
this._formBuilder = _formBuilder;
|
|
617
|
+
this.id = this._route.snapshot.params['id'];
|
|
618
|
+
this.flagDefinitions = [];
|
|
619
|
+
if (this.id === 'new') {
|
|
620
|
+
this.id = undefined;
|
|
621
|
+
}
|
|
622
|
+
// new part form
|
|
623
|
+
this.newPartType = _formBuilder.control(null, Validators.required);
|
|
624
|
+
this.newPart = _formBuilder.group({
|
|
625
|
+
newPartType: this.newPartType,
|
|
626
|
+
});
|
|
627
|
+
// item's metadata form
|
|
628
|
+
this.title = _formBuilder.control(null, [
|
|
629
|
+
Validators.required,
|
|
630
|
+
Validators.maxLength(500),
|
|
631
|
+
]);
|
|
632
|
+
this.sortKey = _formBuilder.control(null, [
|
|
633
|
+
Validators.required,
|
|
634
|
+
Validators.maxLength(500),
|
|
635
|
+
]);
|
|
636
|
+
this.sortKey.disable();
|
|
637
|
+
this.description = _formBuilder.control(null, [
|
|
638
|
+
Validators.required,
|
|
639
|
+
Validators.maxLength(1000),
|
|
640
|
+
]);
|
|
641
|
+
this.facet = _formBuilder.control(null, Validators.required);
|
|
642
|
+
this.group = _formBuilder.control(null, Validators.maxLength(100));
|
|
643
|
+
this.flags = _formBuilder.control(0, { nonNullable: true });
|
|
644
|
+
this.flagChecks = _formBuilder.array([]);
|
|
645
|
+
this.metadata = _formBuilder.group({
|
|
646
|
+
title: this.title,
|
|
647
|
+
sortKey: this.sortKey,
|
|
648
|
+
description: this.description,
|
|
649
|
+
facet: this.facet,
|
|
650
|
+
group: this.group,
|
|
651
|
+
flagChecks: this.flagChecks,
|
|
652
|
+
});
|
|
653
|
+
this.userLevel = 0;
|
|
654
|
+
this.item$ = this._repository.item$;
|
|
655
|
+
this.parts$ = this._repository.parts$;
|
|
656
|
+
this.partGroups$ = this._repository.partGroups$;
|
|
657
|
+
this.layerPartInfos$ = this._repository.layers$;
|
|
658
|
+
this.facet$ = this._repository.facet$;
|
|
659
|
+
this.newPartDefinitions$ = this._repository.newPartDefinitions$;
|
|
660
|
+
// app
|
|
661
|
+
this.facets$ = this._appRepository.facets$;
|
|
662
|
+
this.typeThesaurus$ = this._appRepository.typeThesaurus$;
|
|
663
|
+
this.previewJKeys$ = this._appRepository.previewJKeys$;
|
|
664
|
+
this.previewFKeys$ = this._appRepository.previewFKeys$;
|
|
665
|
+
}
|
|
666
|
+
ngOnInit() {
|
|
667
|
+
this._authService.currentUser$.subscribe((user) => {
|
|
668
|
+
this.user = user || undefined;
|
|
669
|
+
this.userLevel = this._userLevelService.getCurrentUserLevel();
|
|
670
|
+
});
|
|
671
|
+
// rebuild the flags controls array when flags definitions change
|
|
672
|
+
this._appRepository.flags$.subscribe((defs) => {
|
|
673
|
+
this.flagDefinitions = defs;
|
|
674
|
+
this.buildFlagsControls();
|
|
675
|
+
});
|
|
676
|
+
// when flags controls values change, update the flags value
|
|
677
|
+
this.flagChecks.valueChanges.subscribe((_) => {
|
|
678
|
+
if (!this._flagsFrozen) {
|
|
679
|
+
this.flags.setValue(this.getFlagsValue());
|
|
680
|
+
}
|
|
681
|
+
});
|
|
682
|
+
// update the metadata form when item changes (e.g. saved)
|
|
683
|
+
this.item$.subscribe((item) => {
|
|
684
|
+
this.updateMetadataForm(item);
|
|
685
|
+
});
|
|
686
|
+
// load the item (if any) and its lookup
|
|
687
|
+
this._repository.load(this.id);
|
|
688
|
+
}
|
|
689
|
+
canDeactivate() {
|
|
690
|
+
return !this.metadata.dirty;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Builds the array of flags controls according to the current flags
|
|
694
|
+
* definitions and the current flags value.
|
|
695
|
+
*/
|
|
696
|
+
buildFlagsControls() {
|
|
697
|
+
this._flagsFrozen = true;
|
|
698
|
+
this.flagChecks.clear();
|
|
699
|
+
for (const def of this.flagDefinitions) {
|
|
700
|
+
const flagValue = def.id;
|
|
701
|
+
// tslint:disable-next-line: no-bitwise
|
|
702
|
+
const checked = (this.flags.value & flagValue) !== 0;
|
|
703
|
+
this.flagChecks.push(this._formBuilder.control(checked));
|
|
704
|
+
}
|
|
705
|
+
this._flagsFrozen = false;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Update the flags controls from the current flags value.
|
|
709
|
+
*/
|
|
710
|
+
updateFlagControls() {
|
|
711
|
+
if (!this.flagDefinitions) {
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
this._flagsFrozen = true;
|
|
715
|
+
const value = this.flags.value;
|
|
716
|
+
for (let i = 0; i < this.flagDefinitions.length; i++) {
|
|
717
|
+
const flagValue = this.flagDefinitions[i].id;
|
|
718
|
+
// tslint:disable-next-line: no-bitwise
|
|
719
|
+
const checked = (value & flagValue) !== 0;
|
|
720
|
+
this.flagChecks.at(i).setValue(checked);
|
|
721
|
+
}
|
|
722
|
+
this._flagsFrozen = false;
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* Get the flags value from the flags controls.
|
|
726
|
+
*/
|
|
727
|
+
getFlagsValue() {
|
|
728
|
+
let flagsValue = 0;
|
|
729
|
+
for (let i = 0; i < this.flagDefinitions.length; i++) {
|
|
730
|
+
const flagValue = this.flagDefinitions[i].id;
|
|
731
|
+
if (this.flagChecks.at(i)?.value) {
|
|
732
|
+
// tslint:disable-next-line: no-bitwise
|
|
733
|
+
flagsValue |= flagValue;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
return flagsValue;
|
|
737
|
+
}
|
|
738
|
+
updateMetadataForm(item) {
|
|
739
|
+
if (!item) {
|
|
740
|
+
this.metadata.reset();
|
|
741
|
+
this.updateFlagControls();
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
this.title.setValue(item.title);
|
|
745
|
+
this.sortKey.setValue(item.sortKey);
|
|
746
|
+
this.description.setValue(item.description);
|
|
747
|
+
this.facet.setValue(item.facetId);
|
|
748
|
+
this.group.setValue(item.groupId);
|
|
749
|
+
this.flags.setValue(item.flags);
|
|
750
|
+
this.updateFlagControls();
|
|
751
|
+
this.metadata.markAsPristine();
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
getTypeIdName(typeId) {
|
|
755
|
+
const state = this._appRepository.getValue();
|
|
756
|
+
if (!state || !state.typeThesaurus) {
|
|
757
|
+
return typeId;
|
|
758
|
+
}
|
|
759
|
+
// strip :suffix if any
|
|
760
|
+
const i = typeId.lastIndexOf(':');
|
|
761
|
+
if (i > -1) {
|
|
762
|
+
typeId = typeId.substring(0, i);
|
|
763
|
+
}
|
|
764
|
+
const entry = state.typeThesaurus.entries?.find((e) => e.id === typeId);
|
|
765
|
+
return entry ? entry.value : typeId;
|
|
766
|
+
}
|
|
767
|
+
getRoleIdName(roleId) {
|
|
768
|
+
if (!roleId || !roleId.startsWith('fr.')) {
|
|
769
|
+
return roleId;
|
|
770
|
+
}
|
|
771
|
+
return this.getTypeIdName(roleId);
|
|
772
|
+
}
|
|
773
|
+
save() {
|
|
774
|
+
if (this.busy || !this.metadata.valid) {
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
// build item (its ID will be empty if new)
|
|
778
|
+
const item = { ...this._repository.getItem() };
|
|
779
|
+
if (!item) {
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
item.title = this.title.value?.trim();
|
|
783
|
+
item.sortKey = this.sortKey.value?.trim();
|
|
784
|
+
item.description = this.description.value?.trim();
|
|
785
|
+
item.facetId = this.facet.value?.trim() || undefined;
|
|
786
|
+
item.groupId = this.group.value?.trim() || undefined;
|
|
787
|
+
item.flags = this.flags.value;
|
|
788
|
+
// save: this will trigger a change in the store's item, reflected here
|
|
789
|
+
// by updating the metadata form
|
|
790
|
+
this.busy = true;
|
|
791
|
+
this._repository
|
|
792
|
+
.save(item)
|
|
793
|
+
.then((saved) => {
|
|
794
|
+
// once saved, a new item requires resetting the items list
|
|
795
|
+
if (!item.id) {
|
|
796
|
+
this._itemListRepository.clearCache();
|
|
797
|
+
this._itemListRepository.loadPage(1);
|
|
798
|
+
}
|
|
799
|
+
else {
|
|
800
|
+
// an existing item instead just requires updating the entity
|
|
801
|
+
// in the items list if present (e.g. flags might have been changed)
|
|
802
|
+
this._itemListRepository.updateEntity({
|
|
803
|
+
id: item.id,
|
|
804
|
+
title: item.title,
|
|
805
|
+
description: item.description,
|
|
806
|
+
facetId: item.facetId,
|
|
807
|
+
groupId: item.groupId,
|
|
808
|
+
sortKey: item.sortKey,
|
|
809
|
+
flags: item.flags,
|
|
810
|
+
timeCreated: item.timeCreated,
|
|
811
|
+
creatorId: item.creatorId,
|
|
812
|
+
timeModified: item.timeModified,
|
|
813
|
+
userId: item.userId,
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
// this.metadata.markAsPristine();
|
|
817
|
+
// reload to force change in page URL
|
|
818
|
+
if (!item.id) {
|
|
819
|
+
this.id = saved.id;
|
|
820
|
+
this._router.navigate(['/items', saved.id]);
|
|
821
|
+
}
|
|
822
|
+
})
|
|
823
|
+
.finally(() => {
|
|
824
|
+
this.busy = false;
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
partExists(typeId, roleId) {
|
|
828
|
+
const groups = this._repository.getPartGroups();
|
|
829
|
+
if (!groups) {
|
|
830
|
+
return false;
|
|
831
|
+
}
|
|
832
|
+
return groups.some((g) => {
|
|
833
|
+
return g.parts.some((p) => p.typeId === typeId && ((!p.roleId && !roleId) || p.roleId === roleId));
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
addPart(def) {
|
|
837
|
+
if (!def && !this.newPartType.valid) {
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
if (!this.id) {
|
|
841
|
+
this._snackbar.open('Please save the item before adding parts', 'OK', {
|
|
842
|
+
duration: 3000,
|
|
843
|
+
});
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
const typeId = def ? def.typeId : this.newPartType.value.typeId;
|
|
847
|
+
const roleId = def ? def.roleId : this.newPartType.value.roleId;
|
|
848
|
+
if (this.partExists(typeId, roleId)) {
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
const route = this._libraryRouteService.buildPartEditorRoute(this.id, 'new', typeId, roleId);
|
|
852
|
+
// navigate to the editor
|
|
853
|
+
this._router.navigate([route.route], route.rid
|
|
854
|
+
? {
|
|
855
|
+
queryParams: {
|
|
856
|
+
rid: route.rid,
|
|
857
|
+
},
|
|
858
|
+
}
|
|
859
|
+
: {});
|
|
860
|
+
}
|
|
861
|
+
editPart(part) {
|
|
862
|
+
// build the target route to the appropriate part editor
|
|
863
|
+
const route = this._libraryRouteService.buildPartEditorRoute(part.itemId, part.id, part.typeId, part.roleId);
|
|
864
|
+
// navigate to the editor
|
|
865
|
+
this._router.navigate([route.route], route.rid
|
|
866
|
+
? {
|
|
867
|
+
queryParams: {
|
|
868
|
+
rid: route.rid,
|
|
869
|
+
},
|
|
870
|
+
}
|
|
871
|
+
: {});
|
|
872
|
+
}
|
|
873
|
+
previewPart(part) {
|
|
874
|
+
if (part.roleId?.startsWith('fr.')) {
|
|
875
|
+
// layer parts redirect to base-text
|
|
876
|
+
this._itemService
|
|
877
|
+
.getBaseTextPart(part.itemId)
|
|
878
|
+
.pipe(take$1(1))
|
|
879
|
+
.subscribe((p) => {
|
|
880
|
+
this._router.navigate(['preview', part.itemId, p.part.id, 'text'], {
|
|
881
|
+
queryParams: { lid: part.roleId },
|
|
882
|
+
});
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
else if (part.roleId === 'base-text') {
|
|
886
|
+
this._router.navigate(['preview', part.itemId, part.id, 'text']);
|
|
887
|
+
}
|
|
888
|
+
else {
|
|
889
|
+
this._router.navigate(['preview', part.itemId, part.id]);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
deletePart(part) {
|
|
893
|
+
if (this.busy) {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
this._dialogService
|
|
897
|
+
.confirm('Confirm Deletion', `Delete part "${part.typeId}"?`)
|
|
898
|
+
.subscribe((result) => {
|
|
899
|
+
if (!result) {
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
// delete
|
|
903
|
+
this.busy = true;
|
|
904
|
+
this._repository.deletePart(part.id).then((_) => {
|
|
905
|
+
this.busy = false;
|
|
906
|
+
}, (error) => {
|
|
907
|
+
this.busy = false;
|
|
908
|
+
console.error(error);
|
|
909
|
+
this._snackbar.open('Error deleting part', 'OK');
|
|
910
|
+
});
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
addLayerPart(part) {
|
|
914
|
+
if (this.busy) {
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
let name = this.getTypeIdName(part.typeId);
|
|
918
|
+
if (part.roleId) {
|
|
919
|
+
name += ' for ' + this.getRoleIdName(part.roleId);
|
|
920
|
+
}
|
|
921
|
+
this.busy = true;
|
|
922
|
+
this._dialogService
|
|
923
|
+
.confirm('Confirm Addition', `Add layer "${name}"?`)
|
|
924
|
+
.subscribe((result) => {
|
|
925
|
+
if (!result) {
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
this._repository
|
|
929
|
+
.addNewLayerPart(part.typeId, part.roleId)
|
|
930
|
+
.finally(() => (this.busy = false));
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
setPartsScope(request) {
|
|
934
|
+
this._repository.setPartThesaurusScope(request.ids, request.scope);
|
|
935
|
+
}
|
|
936
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.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 }); }
|
|
937
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.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: 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" }] }); }
|
|
938
|
+
}
|
|
939
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.3", ngImport: i0, type: ItemEditorComponent, decorators: [{
|
|
940
|
+
type: Component,
|
|
941
|
+
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"] }]
|
|
941
942
|
}], 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 }]; } });
|
|
942
943
|
|
|
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
|
-
}
|
|
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
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
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
|
-
}]
|
|
944
|
+
// https://github.com/ng-packagr/ng-packagr/issues/778
|
|
945
|
+
const RouterModuleForChild = RouterModule.forChild([
|
|
946
|
+
{ path: '', pathMatch: 'full', component: ItemEditorComponent },
|
|
947
|
+
]);
|
|
948
|
+
class CadmusItemEditorModule {
|
|
949
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.3", ngImport: i0, type: CadmusItemEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
950
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.3", ngImport: i0, type: CadmusItemEditorModule, declarations: [ItemEditorComponent,
|
|
951
|
+
MissingPartsComponent,
|
|
952
|
+
PartsScopeEditorComponent,
|
|
953
|
+
HasPreviewPipe], imports: [CommonModule,
|
|
954
|
+
ReactiveFormsModule,
|
|
955
|
+
FormsModule, i1$1.RouterModule, ClipboardModule,
|
|
956
|
+
// material
|
|
957
|
+
MatButtonModule,
|
|
958
|
+
MatCheckboxModule,
|
|
959
|
+
MatCardModule,
|
|
960
|
+
MatDividerModule,
|
|
961
|
+
MatExpansionModule,
|
|
962
|
+
MatFormFieldModule,
|
|
963
|
+
MatIconModule,
|
|
964
|
+
MatInputModule,
|
|
965
|
+
MatProgressBarModule,
|
|
966
|
+
MatSelectModule,
|
|
967
|
+
MatTabsModule,
|
|
968
|
+
MatTooltipModule,
|
|
969
|
+
// cadmus
|
|
970
|
+
CadmusCoreModule,
|
|
971
|
+
CadmusApiModule,
|
|
972
|
+
CadmusUiModule,
|
|
973
|
+
CadmusStateModule,
|
|
974
|
+
NgToolsModule,
|
|
975
|
+
NgMatToolsModule], exports: [ItemEditorComponent] }); }
|
|
976
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.3", ngImport: i0, type: CadmusItemEditorModule, imports: [CommonModule,
|
|
977
|
+
ReactiveFormsModule,
|
|
978
|
+
FormsModule,
|
|
979
|
+
RouterModuleForChild,
|
|
980
|
+
ClipboardModule,
|
|
981
|
+
// material
|
|
982
|
+
MatButtonModule,
|
|
983
|
+
MatCheckboxModule,
|
|
984
|
+
MatCardModule,
|
|
985
|
+
MatDividerModule,
|
|
986
|
+
MatExpansionModule,
|
|
987
|
+
MatFormFieldModule,
|
|
988
|
+
MatIconModule,
|
|
989
|
+
MatInputModule,
|
|
990
|
+
MatProgressBarModule,
|
|
991
|
+
MatSelectModule,
|
|
992
|
+
MatTabsModule,
|
|
993
|
+
MatTooltipModule,
|
|
994
|
+
// cadmus
|
|
995
|
+
CadmusCoreModule,
|
|
996
|
+
CadmusApiModule,
|
|
997
|
+
CadmusUiModule,
|
|
998
|
+
CadmusStateModule,
|
|
999
|
+
NgToolsModule,
|
|
1000
|
+
NgMatToolsModule] }); }
|
|
1001
|
+
}
|
|
1002
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.3", ngImport: i0, type: CadmusItemEditorModule, decorators: [{
|
|
1003
|
+
type: NgModule,
|
|
1004
|
+
args: [{
|
|
1005
|
+
imports: [
|
|
1006
|
+
CommonModule,
|
|
1007
|
+
ReactiveFormsModule,
|
|
1008
|
+
FormsModule,
|
|
1009
|
+
RouterModuleForChild,
|
|
1010
|
+
ClipboardModule,
|
|
1011
|
+
// material
|
|
1012
|
+
MatButtonModule,
|
|
1013
|
+
MatCheckboxModule,
|
|
1014
|
+
MatCardModule,
|
|
1015
|
+
MatDividerModule,
|
|
1016
|
+
MatExpansionModule,
|
|
1017
|
+
MatFormFieldModule,
|
|
1018
|
+
MatIconModule,
|
|
1019
|
+
MatInputModule,
|
|
1020
|
+
MatProgressBarModule,
|
|
1021
|
+
MatSelectModule,
|
|
1022
|
+
MatTabsModule,
|
|
1023
|
+
MatTooltipModule,
|
|
1024
|
+
// cadmus
|
|
1025
|
+
CadmusCoreModule,
|
|
1026
|
+
CadmusApiModule,
|
|
1027
|
+
CadmusUiModule,
|
|
1028
|
+
CadmusStateModule,
|
|
1029
|
+
NgToolsModule,
|
|
1030
|
+
NgMatToolsModule,
|
|
1031
|
+
],
|
|
1032
|
+
declarations: [
|
|
1033
|
+
ItemEditorComponent,
|
|
1034
|
+
MissingPartsComponent,
|
|
1035
|
+
PartsScopeEditorComponent,
|
|
1036
|
+
HasPreviewPipe,
|
|
1037
|
+
],
|
|
1038
|
+
exports: [ItemEditorComponent],
|
|
1039
|
+
}]
|
|
1039
1040
|
}] });
|
|
1040
1041
|
|
|
1041
|
-
/*
|
|
1042
|
-
* Public API Surface of cadmus-item-editor
|
|
1042
|
+
/*
|
|
1043
|
+
* Public API Surface of cadmus-item-editor
|
|
1043
1044
|
*/
|
|
1044
1045
|
|
|
1045
|
-
/**
|
|
1046
|
-
* Generated bundle index. Do not edit.
|
|
1046
|
+
/**
|
|
1047
|
+
* Generated bundle index. Do not edit.
|
|
1047
1048
|
*/
|
|
1048
1049
|
|
|
1049
1050
|
export { CadmusItemEditorModule, EditedItemRepository, ItemEditorComponent, RouterModuleForChild };
|
|
1050
1051
|
//# sourceMappingURL=myrmidon-cadmus-item-editor.mjs.map
|
|
1051
|
-
//# sourceMappingURL=myrmidon-cadmus-item-editor.mjs.map
|