@myrmidon/cadmus-item-editor 0.0.13 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -24
- package/esm2020/lib/cadmus-item-editor.module.mjs +83 -0
- package/esm2020/lib/item-editor/item-editor.component.mjs +353 -0
- package/esm2020/lib/missing-parts/missing-parts.component.mjs +71 -0
- package/esm2020/lib/parts-scope-editor/parts-scope-editor.component.mjs +118 -0
- package/esm2020/myrmidon-cadmus-item-editor.mjs +5 -0
- package/esm2020/public-api.mjs +6 -0
- package/fesm2015/myrmidon-cadmus-item-editor.mjs +607 -0
- package/fesm2015/myrmidon-cadmus-item-editor.mjs.map +1 -0
- package/fesm2020/myrmidon-cadmus-item-editor.mjs +604 -0
- package/fesm2020/myrmidon-cadmus-item-editor.mjs.map +1 -0
- package/lib/cadmus-item-editor.module.d.ts +19 -0
- package/lib/item-editor/item-editor.component.d.ts +20 -17
- package/lib/missing-parts/missing-parts.component.d.ts +12 -9
- package/lib/parts-scope-editor/parts-scope-editor.component.d.ts +8 -5
- package/myrmidon-cadmus-item-editor.d.ts +1 -2
- package/package.json +27 -15
- package/bundles/myrmidon-cadmus-item-editor.umd.js +0 -929
- package/bundles/myrmidon-cadmus-item-editor.umd.js.map +0 -1
- package/bundles/myrmidon-cadmus-item-editor.umd.min.js +0 -16
- package/bundles/myrmidon-cadmus-item-editor.umd.min.js.map +0 -1
- package/esm2015/lib/cadmus-item-editor.module.js +0 -45
- package/esm2015/lib/item-editor/item-editor.component.js +0 -337
- package/esm2015/lib/missing-parts/missing-parts.component.js +0 -62
- package/esm2015/lib/parts-scope-editor/parts-scope-editor.component.js +0 -115
- package/esm2015/myrmidon-cadmus-item-editor.js +0 -7
- package/esm2015/public-api.js +0 -6
- package/fesm2015/myrmidon-cadmus-item-editor.js +0 -554
- package/fesm2015/myrmidon-cadmus-item-editor.js.map +0 -1
- package/myrmidon-cadmus-item-editor.metadata.json +0 -1
|
@@ -1,929 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@myrmidon/cadmus-core'), require('@angular/forms'), require('@angular/router'), require('@angular/material/snack-bar'), require('@myrmidon/cadmus-ui'), require('@myrmidon/cadmus-state'), require('@myrmidon/cadmus-api'), require('@angular/common'), require('@angular/cdk/clipboard'), require('ngx-moment'), require('@myrmidon/cadmus-material')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@myrmidon/cadmus-item-editor', ['exports', '@angular/core', '@myrmidon/cadmus-core', '@angular/forms', '@angular/router', '@angular/material/snack-bar', '@myrmidon/cadmus-ui', '@myrmidon/cadmus-state', '@myrmidon/cadmus-api', '@angular/common', '@angular/cdk/clipboard', 'ngx-moment', '@myrmidon/cadmus-material'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.myrmidon = global.myrmidon || {}, global.myrmidon['cadmus-item-editor'] = {}), global.ng.core, global['@myrmidon/cadmus-core'], global.ng.forms, global.ng.router, global.ng.material.snackBar, global['@myrmidon/cadmus-ui'], global['@myrmidon/cadmus-state'], global['@myrmidon/cadmus-api'], global.ng.common, global.ng.cdk.clipboard, global['ngx-moment'], global['@myrmidon/cadmus-material']));
|
|
5
|
-
}(this, (function (exports, core, cadmusCore, forms, router, snackBar, cadmusUi, cadmusState, cadmusApi, common, clipboard, ngxMoment, cadmusMaterial) { 'use strict';
|
|
6
|
-
|
|
7
|
-
/*! *****************************************************************************
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
|
|
10
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
-
purpose with or without fee is hereby granted.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
***************************************************************************** */
|
|
21
|
-
/* global Reflect, Promise */
|
|
22
|
-
var extendStatics = function (d, b) {
|
|
23
|
-
extendStatics = Object.setPrototypeOf ||
|
|
24
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
25
|
-
function (d, b) { for (var p in b)
|
|
26
|
-
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
27
|
-
d[p] = b[p]; };
|
|
28
|
-
return extendStatics(d, b);
|
|
29
|
-
};
|
|
30
|
-
function __extends(d, b) {
|
|
31
|
-
extendStatics(d, b);
|
|
32
|
-
function __() { this.constructor = d; }
|
|
33
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
34
|
-
}
|
|
35
|
-
var __assign = function () {
|
|
36
|
-
__assign = Object.assign || function __assign(t) {
|
|
37
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
38
|
-
s = arguments[i];
|
|
39
|
-
for (var p in s)
|
|
40
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
41
|
-
t[p] = s[p];
|
|
42
|
-
}
|
|
43
|
-
return t;
|
|
44
|
-
};
|
|
45
|
-
return __assign.apply(this, arguments);
|
|
46
|
-
};
|
|
47
|
-
function __rest(s, e) {
|
|
48
|
-
var t = {};
|
|
49
|
-
for (var p in s)
|
|
50
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
-
t[p] = s[p];
|
|
52
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
-
t[p[i]] = s[p[i]];
|
|
56
|
-
}
|
|
57
|
-
return t;
|
|
58
|
-
}
|
|
59
|
-
function __decorate(decorators, target, key, desc) {
|
|
60
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
61
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
62
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
63
|
-
else
|
|
64
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
65
|
-
if (d = decorators[i])
|
|
66
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
67
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
68
|
-
}
|
|
69
|
-
function __param(paramIndex, decorator) {
|
|
70
|
-
return function (target, key) { decorator(target, key, paramIndex); };
|
|
71
|
-
}
|
|
72
|
-
function __metadata(metadataKey, metadataValue) {
|
|
73
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
74
|
-
return Reflect.metadata(metadataKey, metadataValue);
|
|
75
|
-
}
|
|
76
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
77
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
78
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
79
|
-
function fulfilled(value) { try {
|
|
80
|
-
step(generator.next(value));
|
|
81
|
-
}
|
|
82
|
-
catch (e) {
|
|
83
|
-
reject(e);
|
|
84
|
-
} }
|
|
85
|
-
function rejected(value) { try {
|
|
86
|
-
step(generator["throw"](value));
|
|
87
|
-
}
|
|
88
|
-
catch (e) {
|
|
89
|
-
reject(e);
|
|
90
|
-
} }
|
|
91
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
92
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
function __generator(thisArg, body) {
|
|
96
|
-
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
97
|
-
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
98
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
99
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
100
|
-
function step(op) {
|
|
101
|
-
if (f)
|
|
102
|
-
throw new TypeError("Generator is already executing.");
|
|
103
|
-
while (_)
|
|
104
|
-
try {
|
|
105
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
106
|
-
return t;
|
|
107
|
-
if (y = 0, t)
|
|
108
|
-
op = [op[0] & 2, t.value];
|
|
109
|
-
switch (op[0]) {
|
|
110
|
-
case 0:
|
|
111
|
-
case 1:
|
|
112
|
-
t = op;
|
|
113
|
-
break;
|
|
114
|
-
case 4:
|
|
115
|
-
_.label++;
|
|
116
|
-
return { value: op[1], done: false };
|
|
117
|
-
case 5:
|
|
118
|
-
_.label++;
|
|
119
|
-
y = op[1];
|
|
120
|
-
op = [0];
|
|
121
|
-
continue;
|
|
122
|
-
case 7:
|
|
123
|
-
op = _.ops.pop();
|
|
124
|
-
_.trys.pop();
|
|
125
|
-
continue;
|
|
126
|
-
default:
|
|
127
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
128
|
-
_ = 0;
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
132
|
-
_.label = op[1];
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
136
|
-
_.label = t[1];
|
|
137
|
-
t = op;
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
if (t && _.label < t[2]) {
|
|
141
|
-
_.label = t[2];
|
|
142
|
-
_.ops.push(op);
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
if (t[2])
|
|
146
|
-
_.ops.pop();
|
|
147
|
-
_.trys.pop();
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
op = body.call(thisArg, _);
|
|
151
|
-
}
|
|
152
|
-
catch (e) {
|
|
153
|
-
op = [6, e];
|
|
154
|
-
y = 0;
|
|
155
|
-
}
|
|
156
|
-
finally {
|
|
157
|
-
f = t = 0;
|
|
158
|
-
}
|
|
159
|
-
if (op[0] & 5)
|
|
160
|
-
throw op[1];
|
|
161
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
165
|
-
if (k2 === undefined)
|
|
166
|
-
k2 = k;
|
|
167
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
|
168
|
-
}) : (function (o, m, k, k2) {
|
|
169
|
-
if (k2 === undefined)
|
|
170
|
-
k2 = k;
|
|
171
|
-
o[k2] = m[k];
|
|
172
|
-
});
|
|
173
|
-
function __exportStar(m, o) {
|
|
174
|
-
for (var p in m)
|
|
175
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
176
|
-
__createBinding(o, m, p);
|
|
177
|
-
}
|
|
178
|
-
function __values(o) {
|
|
179
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
180
|
-
if (m)
|
|
181
|
-
return m.call(o);
|
|
182
|
-
if (o && typeof o.length === "number")
|
|
183
|
-
return {
|
|
184
|
-
next: function () {
|
|
185
|
-
if (o && i >= o.length)
|
|
186
|
-
o = void 0;
|
|
187
|
-
return { value: o && o[i++], done: !o };
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
191
|
-
}
|
|
192
|
-
function __read(o, n) {
|
|
193
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
194
|
-
if (!m)
|
|
195
|
-
return o;
|
|
196
|
-
var i = m.call(o), r, ar = [], e;
|
|
197
|
-
try {
|
|
198
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
199
|
-
ar.push(r.value);
|
|
200
|
-
}
|
|
201
|
-
catch (error) {
|
|
202
|
-
e = { error: error };
|
|
203
|
-
}
|
|
204
|
-
finally {
|
|
205
|
-
try {
|
|
206
|
-
if (r && !r.done && (m = i["return"]))
|
|
207
|
-
m.call(i);
|
|
208
|
-
}
|
|
209
|
-
finally {
|
|
210
|
-
if (e)
|
|
211
|
-
throw e.error;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
return ar;
|
|
215
|
-
}
|
|
216
|
-
function __spread() {
|
|
217
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
218
|
-
ar = ar.concat(__read(arguments[i]));
|
|
219
|
-
return ar;
|
|
220
|
-
}
|
|
221
|
-
function __spreadArrays() {
|
|
222
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
223
|
-
s += arguments[i].length;
|
|
224
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
225
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
226
|
-
r[k] = a[j];
|
|
227
|
-
return r;
|
|
228
|
-
}
|
|
229
|
-
;
|
|
230
|
-
function __await(v) {
|
|
231
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
232
|
-
}
|
|
233
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
234
|
-
if (!Symbol.asyncIterator)
|
|
235
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
236
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
237
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
238
|
-
function verb(n) { if (g[n])
|
|
239
|
-
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
240
|
-
function resume(n, v) { try {
|
|
241
|
-
step(g[n](v));
|
|
242
|
-
}
|
|
243
|
-
catch (e) {
|
|
244
|
-
settle(q[0][3], e);
|
|
245
|
-
} }
|
|
246
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
247
|
-
function fulfill(value) { resume("next", value); }
|
|
248
|
-
function reject(value) { resume("throw", value); }
|
|
249
|
-
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
250
|
-
resume(q[0][0], q[0][1]); }
|
|
251
|
-
}
|
|
252
|
-
function __asyncDelegator(o) {
|
|
253
|
-
var i, p;
|
|
254
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
255
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
256
|
-
}
|
|
257
|
-
function __asyncValues(o) {
|
|
258
|
-
if (!Symbol.asyncIterator)
|
|
259
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
260
|
-
var m = o[Symbol.asyncIterator], i;
|
|
261
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
262
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
263
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
264
|
-
}
|
|
265
|
-
function __makeTemplateObject(cooked, raw) {
|
|
266
|
-
if (Object.defineProperty) {
|
|
267
|
-
Object.defineProperty(cooked, "raw", { value: raw });
|
|
268
|
-
}
|
|
269
|
-
else {
|
|
270
|
-
cooked.raw = raw;
|
|
271
|
-
}
|
|
272
|
-
return cooked;
|
|
273
|
-
}
|
|
274
|
-
;
|
|
275
|
-
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
276
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
277
|
-
}) : function (o, v) {
|
|
278
|
-
o["default"] = v;
|
|
279
|
-
};
|
|
280
|
-
function __importStar(mod) {
|
|
281
|
-
if (mod && mod.__esModule)
|
|
282
|
-
return mod;
|
|
283
|
-
var result = {};
|
|
284
|
-
if (mod != null)
|
|
285
|
-
for (var k in mod)
|
|
286
|
-
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
287
|
-
__createBinding(result, mod, k);
|
|
288
|
-
__setModuleDefault(result, mod);
|
|
289
|
-
return result;
|
|
290
|
-
}
|
|
291
|
-
function __importDefault(mod) {
|
|
292
|
-
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
293
|
-
}
|
|
294
|
-
function __classPrivateFieldGet(receiver, privateMap) {
|
|
295
|
-
if (!privateMap.has(receiver)) {
|
|
296
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
297
|
-
}
|
|
298
|
-
return privateMap.get(receiver);
|
|
299
|
-
}
|
|
300
|
-
function __classPrivateFieldSet(receiver, privateMap, value) {
|
|
301
|
-
if (!privateMap.has(receiver)) {
|
|
302
|
-
throw new TypeError("attempted to set private field on non-instance");
|
|
303
|
-
}
|
|
304
|
-
privateMap.set(receiver, value);
|
|
305
|
-
return value;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Item editor. This can edit a new or existing item's metadata and parts.
|
|
310
|
-
*/
|
|
311
|
-
var ItemEditorComponent = /** @class */ (function () {
|
|
312
|
-
function ItemEditorComponent(_router, _route, _snackbar, _appQuery, _query, _editItemService, _libraryRouteService, _dialogService, _authService, _formBuilder) {
|
|
313
|
-
this._router = _router;
|
|
314
|
-
this._route = _route;
|
|
315
|
-
this._snackbar = _snackbar;
|
|
316
|
-
this._appQuery = _appQuery;
|
|
317
|
-
this._query = _query;
|
|
318
|
-
this._editItemService = _editItemService;
|
|
319
|
-
this._libraryRouteService = _libraryRouteService;
|
|
320
|
-
this._dialogService = _dialogService;
|
|
321
|
-
this._authService = _authService;
|
|
322
|
-
this._formBuilder = _formBuilder;
|
|
323
|
-
this.id = this._route.snapshot.params.id;
|
|
324
|
-
if (this.id === 'new') {
|
|
325
|
-
this.id = null;
|
|
326
|
-
}
|
|
327
|
-
// new part form
|
|
328
|
-
this.newPartType = _formBuilder.control(null, forms.Validators.required);
|
|
329
|
-
this.newPart = _formBuilder.group({
|
|
330
|
-
newPartType: this.newPartType,
|
|
331
|
-
});
|
|
332
|
-
// item's metadata form
|
|
333
|
-
this.title = _formBuilder.control(null, [
|
|
334
|
-
forms.Validators.required,
|
|
335
|
-
forms.Validators.maxLength(500),
|
|
336
|
-
]);
|
|
337
|
-
this.sortKey = _formBuilder.control(null, [
|
|
338
|
-
forms.Validators.required,
|
|
339
|
-
forms.Validators.maxLength(500),
|
|
340
|
-
]);
|
|
341
|
-
this.sortKey.disable();
|
|
342
|
-
this.description = _formBuilder.control(null, [
|
|
343
|
-
forms.Validators.required,
|
|
344
|
-
forms.Validators.maxLength(1000),
|
|
345
|
-
]);
|
|
346
|
-
this.facet = _formBuilder.control(null, forms.Validators.required);
|
|
347
|
-
this.group = _formBuilder.control(null, forms.Validators.maxLength(100));
|
|
348
|
-
this.flags = _formBuilder.control(0);
|
|
349
|
-
this.flagChecks = _formBuilder.array([]);
|
|
350
|
-
this.metadata = _formBuilder.group({
|
|
351
|
-
title: this.title,
|
|
352
|
-
sortKey: this.sortKey,
|
|
353
|
-
description: this.description,
|
|
354
|
-
facet: this.facet,
|
|
355
|
-
group: this.group,
|
|
356
|
-
flagChecks: this.flagChecks,
|
|
357
|
-
});
|
|
358
|
-
this.userLevel = 0;
|
|
359
|
-
}
|
|
360
|
-
ItemEditorComponent.prototype.ngOnInit = function () {
|
|
361
|
-
var _this = this;
|
|
362
|
-
this._authService.currentUser$.subscribe(function (user) {
|
|
363
|
-
_this.user = user;
|
|
364
|
-
_this.userLevel = _this._authService.getCurrentUserLevel();
|
|
365
|
-
});
|
|
366
|
-
this.item$ = this._query.selectItem();
|
|
367
|
-
this.parts$ = this._query.selectParts();
|
|
368
|
-
this.partGroups$ = this._query.select(function (state) { return state.partGroups; });
|
|
369
|
-
this.layerPartInfos$ = this._query.select(function (state) { return state.layerPartInfos; });
|
|
370
|
-
this.facet$ = this._query.selectFacet();
|
|
371
|
-
this.facets$ = this._appQuery.selectFacets();
|
|
372
|
-
// rebuild the flags controls array when flags definitions change
|
|
373
|
-
this._appQuery.selectFlags().subscribe(function (defs) {
|
|
374
|
-
_this.flagDefinitions = defs;
|
|
375
|
-
_this.buildFlagsControls();
|
|
376
|
-
});
|
|
377
|
-
this.typeThesaurus$ = this._appQuery.selectTypeThesaurus();
|
|
378
|
-
this.loading$ = this._query.selectLoading();
|
|
379
|
-
this.saving$ = this._query.selectSaving();
|
|
380
|
-
this.deletingPart$ = this._query.selectDeletingPart();
|
|
381
|
-
this.error$ = this._query.selectError();
|
|
382
|
-
// when flags controls values change, update the flags value
|
|
383
|
-
this.flagChecks.valueChanges.subscribe(function (_) {
|
|
384
|
-
_this.flags.setValue(_this.getFlagsValue());
|
|
385
|
-
});
|
|
386
|
-
// update the metadata form when item changes
|
|
387
|
-
this.item$.subscribe(function (item) {
|
|
388
|
-
_this.updateMetadataForm(item);
|
|
389
|
-
_this.newPartDefinitions = _this.getNewPartDefinitions();
|
|
390
|
-
});
|
|
391
|
-
// load the item (if any) and its lookup
|
|
392
|
-
this._editItemService.load(this.id);
|
|
393
|
-
};
|
|
394
|
-
ItemEditorComponent.prototype.canDeactivate = function () {
|
|
395
|
-
return !this.metadata.dirty;
|
|
396
|
-
};
|
|
397
|
-
ItemEditorComponent.prototype.getExistingPartTypeAndRoleIds = function () {
|
|
398
|
-
var e_1, _b, e_2, _c;
|
|
399
|
-
var groups = this._query.getValue().partGroups;
|
|
400
|
-
if (!groups) {
|
|
401
|
-
return [];
|
|
402
|
-
}
|
|
403
|
-
var results = [];
|
|
404
|
-
try {
|
|
405
|
-
for (var groups_1 = __values(groups), groups_1_1 = groups_1.next(); !groups_1_1.done; groups_1_1 = groups_1.next()) {
|
|
406
|
-
var group = groups_1_1.value;
|
|
407
|
-
try {
|
|
408
|
-
for (var _d = (e_2 = void 0, __values(group.parts)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
409
|
-
var part = _e.value;
|
|
410
|
-
results.push({
|
|
411
|
-
typeId: part.typeId,
|
|
412
|
-
roleId: part.roleId,
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
417
|
-
finally {
|
|
418
|
-
try {
|
|
419
|
-
if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
|
|
420
|
-
}
|
|
421
|
-
finally { if (e_2) throw e_2.error; }
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
426
|
-
finally {
|
|
427
|
-
try {
|
|
428
|
-
if (groups_1_1 && !groups_1_1.done && (_b = groups_1.return)) _b.call(groups_1);
|
|
429
|
-
}
|
|
430
|
-
finally { if (e_1) throw e_1.error; }
|
|
431
|
-
}
|
|
432
|
-
return results;
|
|
433
|
-
};
|
|
434
|
-
ItemEditorComponent.prototype.getNewPartDefinitions = function () {
|
|
435
|
-
var e_3, _b;
|
|
436
|
-
var _a;
|
|
437
|
-
var facet = this._query.getValue().facet;
|
|
438
|
-
if (!facet) {
|
|
439
|
-
return [];
|
|
440
|
-
}
|
|
441
|
-
var existingTypeRoleIds = this.getExistingPartTypeAndRoleIds();
|
|
442
|
-
var defs = [];
|
|
443
|
-
var _loop_1 = function (def) {
|
|
444
|
-
// exclude layer parts, as these are in the layers tab
|
|
445
|
-
if ((_a = def.roleId) === null || _a === void 0 ? void 0 : _a.startsWith('fr.')) {
|
|
446
|
-
return "continue";
|
|
447
|
-
}
|
|
448
|
-
// exclude parts present in the item
|
|
449
|
-
if (existingTypeRoleIds.find(function (tr) {
|
|
450
|
-
return (tr.typeId === def.typeId &&
|
|
451
|
-
((!tr.roleId && !def.roleId) || tr.roleId === def.roleId));
|
|
452
|
-
})) {
|
|
453
|
-
return "continue";
|
|
454
|
-
}
|
|
455
|
-
defs.push(def);
|
|
456
|
-
};
|
|
457
|
-
try {
|
|
458
|
-
for (var _c = __values(facet.partDefinitions), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
459
|
-
var def = _d.value;
|
|
460
|
-
_loop_1(def);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
464
|
-
finally {
|
|
465
|
-
try {
|
|
466
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
467
|
-
}
|
|
468
|
-
finally { if (e_3) throw e_3.error; }
|
|
469
|
-
}
|
|
470
|
-
// sort by sort key
|
|
471
|
-
defs.sort(function (a, b) {
|
|
472
|
-
return a.sortKey.localeCompare(b.sortKey);
|
|
473
|
-
});
|
|
474
|
-
return defs;
|
|
475
|
-
};
|
|
476
|
-
/**
|
|
477
|
-
* Builds the array of flags controls according to the current flags
|
|
478
|
-
* definitions and the current flags value.
|
|
479
|
-
*/
|
|
480
|
-
ItemEditorComponent.prototype.buildFlagsControls = function () {
|
|
481
|
-
var e_4, _b;
|
|
482
|
-
this.flagChecks.clear();
|
|
483
|
-
try {
|
|
484
|
-
for (var _c = __values(this.flagDefinitions), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
485
|
-
var def = _d.value;
|
|
486
|
-
var flagValue = def.id;
|
|
487
|
-
// tslint:disable-next-line: no-bitwise
|
|
488
|
-
var checked = (this.flags.value & flagValue) !== 0;
|
|
489
|
-
this.flagChecks.push(this._formBuilder.control(checked));
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
493
|
-
finally {
|
|
494
|
-
try {
|
|
495
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
496
|
-
}
|
|
497
|
-
finally { if (e_4) throw e_4.error; }
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
/**
|
|
501
|
-
* Update the flags controls from the current flags value.
|
|
502
|
-
*/
|
|
503
|
-
ItemEditorComponent.prototype.updateFlagControls = function () {
|
|
504
|
-
if (!this.flagDefinitions) {
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
for (var i = 0; i < this.flagDefinitions.length; i++) {
|
|
508
|
-
var flagValue = this.flagDefinitions[i].id;
|
|
509
|
-
// tslint:disable-next-line: no-bitwise
|
|
510
|
-
var checked = (this.flags.value & flagValue) !== 0;
|
|
511
|
-
this.flagChecks.at(i).setValue(checked);
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
/**
|
|
515
|
-
* Get the flags value from the flags controls.
|
|
516
|
-
*/
|
|
517
|
-
ItemEditorComponent.prototype.getFlagsValue = function () {
|
|
518
|
-
var flagsValue = 0;
|
|
519
|
-
for (var i = 0; i < this.flagDefinitions.length; i++) {
|
|
520
|
-
var flagValue = this.flagDefinitions[i].id;
|
|
521
|
-
if (this.flagChecks.at(i).value) {
|
|
522
|
-
// tslint:disable-next-line: no-bitwise
|
|
523
|
-
flagsValue |= flagValue;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
return flagsValue;
|
|
527
|
-
};
|
|
528
|
-
ItemEditorComponent.prototype.updateMetadataForm = function (item) {
|
|
529
|
-
if (!item) {
|
|
530
|
-
this.metadata.reset();
|
|
531
|
-
this.updateFlagControls();
|
|
532
|
-
}
|
|
533
|
-
else {
|
|
534
|
-
this.title.setValue(item.title);
|
|
535
|
-
this.sortKey.setValue(item.sortKey);
|
|
536
|
-
this.description.setValue(item.description);
|
|
537
|
-
this.facet.setValue(item.facetId);
|
|
538
|
-
this.group.setValue(item.groupId);
|
|
539
|
-
this.flags.setValue(item.flags);
|
|
540
|
-
this.updateFlagControls();
|
|
541
|
-
this.metadata.markAsPristine();
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
ItemEditorComponent.prototype.getTypeIdName = function (typeId) {
|
|
545
|
-
var state = this._appQuery.getValue();
|
|
546
|
-
if (!state || !state.typeThesaurus) {
|
|
547
|
-
return typeId;
|
|
548
|
-
}
|
|
549
|
-
// strip :suffix if any
|
|
550
|
-
var i = typeId.lastIndexOf(':');
|
|
551
|
-
if (i > -1) {
|
|
552
|
-
typeId = typeId.substr(0, i);
|
|
553
|
-
}
|
|
554
|
-
var entry = state.typeThesaurus.entries.find(function (e) { return e.id === typeId; });
|
|
555
|
-
return entry ? entry.value : typeId;
|
|
556
|
-
};
|
|
557
|
-
ItemEditorComponent.prototype.getRoleIdName = function (roleId) {
|
|
558
|
-
if (!roleId || !roleId.startsWith('fr.')) {
|
|
559
|
-
return roleId;
|
|
560
|
-
}
|
|
561
|
-
return this.getTypeIdName(roleId);
|
|
562
|
-
};
|
|
563
|
-
ItemEditorComponent.prototype.tryTrim = function (value) {
|
|
564
|
-
return value ? value.trim() : value;
|
|
565
|
-
};
|
|
566
|
-
ItemEditorComponent.prototype.save = function () {
|
|
567
|
-
var _this = this;
|
|
568
|
-
if (!this.metadata.valid) {
|
|
569
|
-
return;
|
|
570
|
-
}
|
|
571
|
-
var item = Object.assign({}, this._query.getValue().item);
|
|
572
|
-
item.title = this.tryTrim(this.title.value);
|
|
573
|
-
item.sortKey = this.sortKey.value;
|
|
574
|
-
item.description = this.tryTrim(this.description.value);
|
|
575
|
-
item.facetId = this.tryTrim(this.facet.value);
|
|
576
|
-
item.groupId = this.tryTrim(this.group.value);
|
|
577
|
-
item.flags = this.flags.value;
|
|
578
|
-
// save and reload as edited if was new
|
|
579
|
-
this._editItemService.save(item).then(function (saved) {
|
|
580
|
-
_this.metadata.markAsPristine();
|
|
581
|
-
if (!item.id) {
|
|
582
|
-
_this.id = saved.id;
|
|
583
|
-
_this._router.navigate(['/items', saved.id]);
|
|
584
|
-
}
|
|
585
|
-
});
|
|
586
|
-
};
|
|
587
|
-
ItemEditorComponent.prototype.partExists = function (typeId, roleId) {
|
|
588
|
-
var groups = this._query.getValue().partGroups;
|
|
589
|
-
return groups.some(function (g) {
|
|
590
|
-
return g.parts.some(function (p) { return p.typeId === typeId && ((!p.roleId && !roleId) || p.roleId === roleId); });
|
|
591
|
-
});
|
|
592
|
-
};
|
|
593
|
-
ItemEditorComponent.prototype.addPart = function (def) {
|
|
594
|
-
if (!def && !this.newPartType.valid) {
|
|
595
|
-
return;
|
|
596
|
-
}
|
|
597
|
-
if (!this.id) {
|
|
598
|
-
this._snackbar.open('Please save the item before adding parts', 'OK', {
|
|
599
|
-
duration: 3000,
|
|
600
|
-
});
|
|
601
|
-
return;
|
|
602
|
-
}
|
|
603
|
-
var typeId = def ? def.typeId : this.newPartType.value.typeId;
|
|
604
|
-
var roleId = def ? def.roleId : this.newPartType.value.roleId;
|
|
605
|
-
if (this.partExists(typeId, roleId)) {
|
|
606
|
-
return;
|
|
607
|
-
}
|
|
608
|
-
var route = this._libraryRouteService.buildPartEditorRoute(this.id, 'new', typeId, roleId);
|
|
609
|
-
// navigate to the editor
|
|
610
|
-
this._router.navigate([route.route], route.rid
|
|
611
|
-
? {
|
|
612
|
-
queryParams: {
|
|
613
|
-
rid: route.rid,
|
|
614
|
-
},
|
|
615
|
-
}
|
|
616
|
-
: {});
|
|
617
|
-
};
|
|
618
|
-
ItemEditorComponent.prototype.editPart = function (part) {
|
|
619
|
-
// build the target route to the appropriate part editor
|
|
620
|
-
var route = this._libraryRouteService.buildPartEditorRoute(part.itemId, part.id, part.typeId, part.roleId);
|
|
621
|
-
// navigate to the editor
|
|
622
|
-
this._router.navigate([route.route], route.rid
|
|
623
|
-
? {
|
|
624
|
-
queryParams: {
|
|
625
|
-
rid: route.rid,
|
|
626
|
-
},
|
|
627
|
-
}
|
|
628
|
-
: {});
|
|
629
|
-
};
|
|
630
|
-
ItemEditorComponent.prototype.deletePart = function (part) {
|
|
631
|
-
var _this = this;
|
|
632
|
-
this._dialogService
|
|
633
|
-
.confirm('Confirm Deletion', "Delete part \"" + part.typeId + "\"?")
|
|
634
|
-
.subscribe(function (result) {
|
|
635
|
-
if (!result) {
|
|
636
|
-
return;
|
|
637
|
-
}
|
|
638
|
-
// delete
|
|
639
|
-
_this._editItemService.deletePart(part.id).then(function (_) {
|
|
640
|
-
// once deleted, refresh new-part definitions
|
|
641
|
-
_this.newPartDefinitions = _this.getNewPartDefinitions();
|
|
642
|
-
}, function (error) {
|
|
643
|
-
console.error(error);
|
|
644
|
-
_this._snackbar.open('Error deleting part', 'OK');
|
|
645
|
-
});
|
|
646
|
-
});
|
|
647
|
-
};
|
|
648
|
-
ItemEditorComponent.prototype.addLayerPart = function (part) {
|
|
649
|
-
var _this = this;
|
|
650
|
-
var name = this.getTypeIdName(part.typeId);
|
|
651
|
-
if (part.roleId) {
|
|
652
|
-
name += ' for ' + this.getRoleIdName(part.roleId);
|
|
653
|
-
}
|
|
654
|
-
this._dialogService
|
|
655
|
-
.confirm('Confirm Addition', "Add layer \"" + name + "\"?")
|
|
656
|
-
.subscribe(function (result) {
|
|
657
|
-
if (!result) {
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
_this._editItemService.addNewLayerPart(part.itemId, part.typeId, part.roleId);
|
|
661
|
-
});
|
|
662
|
-
};
|
|
663
|
-
ItemEditorComponent.prototype.setPartsScope = function (request) {
|
|
664
|
-
this._editItemService.setPartThesaurusScope(request.ids, request.scope);
|
|
665
|
-
};
|
|
666
|
-
return ItemEditorComponent;
|
|
667
|
-
}());
|
|
668
|
-
ItemEditorComponent.decorators = [
|
|
669
|
-
{ type: core.Component, args: [{
|
|
670
|
-
selector: 'cadmus-item-editor',
|
|
671
|
-
template: "<mat-card>\r\n <mat-card-header>\r\n <mat-card-title>\r\n {{ (item$ | async)?.title || \"Item\" }}\r\n </mat-card-title>\r\n <mat-card-subtitle>\r\n {{ (item$ | async)?.description }}\r\n </mat-card-subtitle>\r\n </mat-card-header>\r\n <mat-card-content *ngIf=\"!id || (item$ | async) as item\">\r\n <p *ngIf=\"id\">\r\n ID:\r\n <input\r\n [cdkCopyToClipboard]=\"item.id\"\r\n type=\"text\"\r\n readonly=\"true\"\r\n spellcheck=\"false\"\r\n matTooltip=\"Click to copy\"\r\n [value]=\"item.id\"\r\n class=\"id\"\r\n />\r\n </p>\r\n <p *ngIf=\"id\">\r\n Last saved {{ item.timeModified | amLocal | amTimeAgo }} by\r\n {{ item.userId }} on\r\n {{ item.timeModified | date: \"yyyy-MM-dd HH:mm:ss\" }}.<br />\r\n Created {{ item.timeCreated | amLocal | amTimeAgo }} by\r\n {{ item.creatorId }} on\r\n {{ item.timeCreated | date: \"yyyy-MM-dd HH:mm:ss\" }}.\r\n </p>\r\n <p *ngIf=\"error$ | async as error\">\r\n <mat-error>\r\n {{ error }}\r\n </mat-error>\r\n </p>\r\n\r\n <mat-progress-bar\r\n mode=\"indeterminate\"\r\n *ngIf=\"(loading$ | async) || (saving$ | async)\"\r\n ></mat-progress-bar>\r\n\r\n <!-- item content -->\r\n <mat-tab-group [selectedIndex]=\"id ? 1 : 0\">\r\n <!-- metadata -->\r\n <mat-tab label=\"Metadata\">\r\n <form [formGroup]=\"metadata\" (ngSubmit)=\"save()\">\r\n <!-- title -->\r\n <div>\r\n <mat-form-field>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"title\"\r\n placeholder=\"title\"\r\n formControlName=\"title\"\r\n />\r\n <mat-error\r\n *ngIf=\"\r\n title.hasError('required') && (title.touched || title.dirty)\r\n \"\r\n >enter title</mat-error\r\n >\r\n <mat-error\r\n *ngIf=\"\r\n title.hasError('maxLength') && (title.touched || title.dirty)\r\n \"\r\n >\r\n title too long</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- sortKey -->\r\n <div>\r\n <mat-form-field>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"sortKey\"\r\n placeholder=\"sort key\"\r\n formControlName=\"sortKey\"\r\n />\r\n <mat-error\r\n *ngIf=\"\r\n sortKey.hasError('required') &&\r\n (sortKey.touched || sortKey.dirty)\r\n \"\r\n >enter sort key</mat-error\r\n >\r\n <mat-error\r\n *ngIf=\"\r\n sortKey.hasError('maxLength') &&\r\n (sortKey.touched || sortKey.dirty)\r\n \"\r\n >sort key too long</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- description -->\r\n <div>\r\n <mat-form-field class=\"full-width\">\r\n <textarea\r\n rows=\"2\"\r\n matInput\r\n id=\"description\"\r\n placeholder=\"description\"\r\n formControlName=\"description\"\r\n ></textarea>\r\n <mat-error\r\n *ngIf=\"\r\n description.hasError('required') &&\r\n (description.touched || description.dirty)\r\n \"\r\n >enter description</mat-error\r\n >\r\n <mat-error\r\n *ngIf=\"\r\n description.hasError('maxLength') &&\r\n (description.touched || description.dirty)\r\n \"\r\n >description too long</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- facet -->\r\n <div>\r\n <mat-form-field style=\"width: 400px\">\r\n <mat-select\r\n placeholder=\"facet\"\r\n formControlName=\"facet\"\r\n required=\"true\"\r\n >\r\n <mat-option *ngFor=\"let f of facets$ | async\" [value]=\"f.id\">\r\n {{ f.label }}\r\n </mat-option>\r\n </mat-select>\r\n <mat-error>please select a facet</mat-error>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- group -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput formControlName=\"group\" placeholder=\"group ID\" />\r\n <mat-error\r\n *ngIf=\"\r\n group.hasError('maxLength') && (group.dirty || group.touched)\r\n \"\r\n >too long</mat-error\r\n >\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- flags -->\r\n <div formArrayName=\"flagChecks\" *ngIf=\"flagDefinitions\">\r\n <mat-checkbox\r\n class=\"flag\"\r\n *ngFor=\"let c of flagChecks.controls; let i = index\"\r\n [formControlName]=\"i\"\r\n >\r\n <span [style.color]=\"'#' + flagDefinitions[i].colorKey\"\r\n >⬤</span\r\n >\r\n \r\n {{ flagDefinitions[i].label }}\r\n </mat-checkbox>\r\n </div>\r\n <br />\r\n\r\n <div>\r\n <button\r\n type=\"submit\"\r\n mat-raised-button\r\n color=\"primary\"\r\n [disabled]=\"\r\n userLevel < 2 || (saving$ | async) || (loading$ | async)\r\n \"\r\n matTooltip=\"Save metadata\"\r\n *ngIf=\"\r\n user.roles.includes('admin') ||\r\n user.roles.includes('editor') ||\r\n user.roles.includes('operator')\r\n \"\r\n >\r\n <mat-icon>save</mat-icon> save\r\n </button>\r\n </div>\r\n </form>\r\n </mat-tab>\r\n\r\n <!-- parts -->\r\n <mat-tab label=\"Parts\" *ngIf=\"id\">\r\n <div class=\"new-part\">\r\n <form [formGroup]=\"newPart\">\r\n <mat-form-field>\r\n <mat-select\r\n placeholder=\"part\"\r\n formControlName=\"newPartType\"\r\n required\r\n >\r\n <mat-option *ngFor=\"let p of newPartDefinitions\" [value]=\"p\">\r\n <span [style.color]=\"'#' + p.colorKey\" class=\"new-part-icon\"\r\n >⬤</span\r\n >\r\n {{ p.name }}\r\n <span *ngIf=\"p.roleId\" class=\"new-part-role\">{{\r\n p.roleId\r\n }}</span>\r\n </mat-option>\r\n </mat-select>\r\n <mat-error>part type required</mat-error>\r\n </mat-form-field>\r\n \r\n <button\r\n mat-stroked-button\r\n color=\"primary\"\r\n type=\"button\"\r\n [disabled]=\"userLevel < 2 || (loading$ | async) || !newPart.valid\"\r\n (click)=\"addPart()\"\r\n matTooltip=\"Add a new part of the selected type\"\r\n >\r\n <mat-icon>add_circle</mat-icon>\r\n add part\r\n </button>\r\n </form>\r\n </div>\r\n\r\n <mat-divider></mat-divider>\r\n\r\n <mat-expansion-panel\r\n *ngFor=\"let group of partGroups$ | async\"\r\n [expanded]=\"true\"\r\n >\r\n <mat-expansion-panel-header>\r\n <mat-panel-title\r\n ><strong>{{ group.label }}</strong></mat-panel-title\r\n >\r\n <mat-panel-description>{{\r\n group.parts.length\r\n }}</mat-panel-description>\r\n </mat-expansion-panel-header>\r\n\r\n <table>\r\n <thead>\r\n <tr>\r\n <th style=\"width: 124px\"></th>\r\n <th>type</th>\r\n <th>role</th>\r\n <th fxHide.xs>modified</th>\r\n <th fxHide.xs>user</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let part of group.parts\">\r\n <!-- edit -->\r\n <td>\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n color=\"primary\"\r\n matTooltip=\"Edit this part\"\r\n [disabled]=\"(loading$ | async) || (deletingPart$ | async)\"\r\n (click)=\"editPart(part)\"\r\n >\r\n <mat-icon>create</mat-icon>\r\n </button>\r\n <!-- delete -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Delete this part\"\r\n [disabled]=\"\r\n userLevel < 2 ||\r\n (loading$ | async) ||\r\n (deletingPart$ | async)\r\n \"\r\n (click)=\"deletePart(part)\"\r\n *ngIf=\"\r\n user.roles.includes('admin') ||\r\n user.roles.includes('editor') ||\r\n user.roles.includes('operator')\r\n \"\r\n >\r\n <mat-icon color=\"warn\">delete</mat-icon>\r\n </button>\r\n <!-- copy -->\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Copy this part ID\"\r\n [cdkCopyToClipboard]=\"part.id\"\r\n >\r\n <mat-icon>assignment</mat-icon>\r\n </button>\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet$ | async\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"typeThesaurus$ | async\"\r\n ></cadmus-part-badge>\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet$ | async\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"typeThesaurus$ | async\"\r\n ></cadmus-part-badge>\r\n </td>\r\n <td fxHide.xs>{{ part.timeModified | amLocal | amTimeAgo }}</td>\r\n <td fxHide.xs>{{ part.userId }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n </mat-expansion-panel>\r\n\r\n <cadmus-missing-parts\r\n [partDefinitions]=\"(facet$ | async)?.partDefinitions\"\r\n [parts]=\"parts$ | async\"\r\n [typeThesaurus]=\"typeThesaurus$ | async\"\r\n (addRequest)=\"addPart($event)\"\r\n ></cadmus-missing-parts>\r\n </mat-tab>\r\n\r\n <mat-tab label=\"Layers\" *ngIf=\"id\">\r\n <table *ngIf=\"layerPartInfos$ | async as parts\">\r\n <thead>\r\n <th></th>\r\n <th>type</th>\r\n <th>role</th>\r\n <th>frr.</th>\r\n <th>last modified</th>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let part of parts\">\r\n <td>\r\n <button\r\n *ngIf=\"!part.isAbsent\"\r\n type=\"button\"\r\n color=\"primary\"\r\n mat-icon-button\r\n matTooltip=\"Edit this layer part\"\r\n (click)=\"editPart(part)\"\r\n >\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n <button\r\n *ngIf=\"part.isAbsent\"\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"primary\"\r\n matTooltip=\"Add this layer part\"\r\n [disabled]=\"userLevel < 2\"\r\n (click)=\"addLayerPart(part)\"\r\n >\r\n <mat-icon>add_circle</mat-icon>\r\n </button>\r\n <button\r\n *ngIf=\"!part.isAbsent\"\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"warn\"\r\n matTooltip=\"Delete this layer part\"\r\n [disabled]=\"userLevel < 2\"\r\n (click)=\"deletePart(part)\"\r\n >\r\n <mat-icon>delete</mat-icon>\r\n </button>\r\n <button\r\n *ngIf=\"!part.isAbsent\"\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Copy this part ID\"\r\n [cdkCopyToClipboard]=\"part.id\"\r\n >\r\n <mat-icon>assignment</mat-icon>\r\n </button>\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet$ | async\"\r\n [badgeType]=\"1\"\r\n [typeThesaurus]=\"typeThesaurus$ | async\"\r\n ></cadmus-part-badge>\r\n </td>\r\n <td>\r\n <cadmus-part-badge\r\n [partTypeIds]=\"part\"\r\n [facetDefinition]=\"facet$ | async\"\r\n [badgeType]=\"2\"\r\n [typeThesaurus]=\"typeThesaurus$ | async\"\r\n ></cadmus-part-badge>\r\n </td>\r\n <td\r\n [ngClass]=\"{\r\n 'count-n': part.fragmentCount,\r\n 'count-z': !part.fragmentCount\r\n }\"\r\n >\r\n {{ part.fragmentCount }}\r\n </td>\r\n <td>\r\n <span *ngIf=\"!part.isAbsent\">\r\n {{ part.timeModified | amLocal | amTimeAgo }}\r\n </span>\r\n </td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n </mat-tab>\r\n\r\n <mat-tab\r\n label=\"Th-Scopes\"\r\n *ngIf=\"parts$ | async | sort: 'typeId' | sort: 'roleId' as parts\"\r\n >\r\n <cadmus-parts-scope-editor\r\n [parts]=\"parts\"\r\n [readonly]=\"userLevel < 2 || (saving$ | async) || (loading$ | async)\"\r\n (setScopeRequest)=\"setPartsScope($event)\"\r\n ></cadmus-parts-scope-editor>\r\n </mat-tab>\r\n </mat-tab-group>\r\n </mat-card-content>\r\n</mat-card>\r\n",
|
|
672
|
-
styles: [".full-width{width:100%}th{color:silver;font-weight:400}div.new-part{margin-left:32px}span.new-part-role{color:grey;margin-left:8px;vertical-align:middle}span.new-part-icon{margin:0 4px;vertical-align:middle}td.count-n{color:#03c03c;text-align:center}td.count-z{color:#f34f41;text-align:center}input.id{color:grey;font-family:Courier New,Courier,monospace;min-width:22em}.flag{margin-left:10px}"]
|
|
673
|
-
},] }
|
|
674
|
-
];
|
|
675
|
-
ItemEditorComponent.ctorParameters = function () { return [
|
|
676
|
-
{ type: router.Router },
|
|
677
|
-
{ type: router.ActivatedRoute },
|
|
678
|
-
{ type: snackBar.MatSnackBar },
|
|
679
|
-
{ type: cadmusState.AppQuery },
|
|
680
|
-
{ type: cadmusState.EditItemQuery },
|
|
681
|
-
{ type: cadmusState.EditItemService },
|
|
682
|
-
{ type: cadmusCore.LibraryRouteService },
|
|
683
|
-
{ type: cadmusUi.DialogService },
|
|
684
|
-
{ type: cadmusApi.AuthService },
|
|
685
|
-
{ type: forms.FormBuilder }
|
|
686
|
-
]; };
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
* Parts thesaurus scope dumb editor component.
|
|
690
|
-
* This is used to set the thesaurus scope of multiple item's parts at once
|
|
691
|
-
* in the item editor.
|
|
692
|
-
*/
|
|
693
|
-
var PartsScopeEditorComponent = /** @class */ (function () {
|
|
694
|
-
function PartsScopeEditorComponent(_formBuilder, _facetService, _dialogService, _appQuery, _itemQuery) {
|
|
695
|
-
this._formBuilder = _formBuilder;
|
|
696
|
-
this._facetService = _facetService;
|
|
697
|
-
this._dialogService = _dialogService;
|
|
698
|
-
this._appQuery = _appQuery;
|
|
699
|
-
this._itemQuery = _itemQuery;
|
|
700
|
-
// events
|
|
701
|
-
this.setScopeRequest = new core.EventEmitter();
|
|
702
|
-
// form
|
|
703
|
-
this.checks = _formBuilder.array([], cadmusUi.CustomValidators.minChecked(1));
|
|
704
|
-
this.scope = _formBuilder.control(null, [
|
|
705
|
-
forms.Validators.maxLength(50),
|
|
706
|
-
forms.Validators.pattern(/^[-a-zA-Z0-9_]+$/),
|
|
707
|
-
]);
|
|
708
|
-
this.form = _formBuilder.group({
|
|
709
|
-
checks: this.checks,
|
|
710
|
-
scope: this.scope,
|
|
711
|
-
});
|
|
712
|
-
}
|
|
713
|
-
Object.defineProperty(PartsScopeEditorComponent.prototype, "parts", {
|
|
714
|
-
get: function () {
|
|
715
|
-
return this._parts;
|
|
716
|
-
},
|
|
717
|
-
set: function (value) {
|
|
718
|
-
this._parts = value;
|
|
719
|
-
this.updateForm();
|
|
720
|
-
},
|
|
721
|
-
enumerable: false,
|
|
722
|
-
configurable: true
|
|
723
|
-
});
|
|
724
|
-
PartsScopeEditorComponent.prototype.ngOnInit = function () { };
|
|
725
|
-
PartsScopeEditorComponent.prototype.updateForm = function () {
|
|
726
|
-
this.checks.clear();
|
|
727
|
-
if (!this._parts || this._parts.length === 0) {
|
|
728
|
-
return;
|
|
729
|
-
}
|
|
730
|
-
for (var i = 0; i < this._parts.length; i++) {
|
|
731
|
-
this.checks.push(this._formBuilder.control(false));
|
|
732
|
-
}
|
|
733
|
-
};
|
|
734
|
-
PartsScopeEditorComponent.prototype.getPartColor = function (typeId, roleId) {
|
|
735
|
-
var state = this._itemQuery.getValue();
|
|
736
|
-
return this._facetService.getPartColor(typeId, roleId, state === null || state === void 0 ? void 0 : state.facet);
|
|
737
|
-
};
|
|
738
|
-
PartsScopeEditorComponent.prototype.getTypeIdName = function (typeId) {
|
|
739
|
-
var state = this._appQuery.getValue();
|
|
740
|
-
if (!state || !state.typeThesaurus) {
|
|
741
|
-
return typeId;
|
|
742
|
-
}
|
|
743
|
-
// strip :suffix if any
|
|
744
|
-
var i = typeId.lastIndexOf(':');
|
|
745
|
-
if (i > -1) {
|
|
746
|
-
typeId = typeId.substr(0, i);
|
|
747
|
-
}
|
|
748
|
-
var entry = state.typeThesaurus.entries.find(function (e) { return e.id === typeId; });
|
|
749
|
-
return entry ? entry.value : typeId;
|
|
750
|
-
};
|
|
751
|
-
PartsScopeEditorComponent.prototype.getRoleIdName = function (roleId) {
|
|
752
|
-
if (!roleId || !roleId.startsWith('fr.')) {
|
|
753
|
-
return roleId;
|
|
754
|
-
}
|
|
755
|
-
return this.getTypeIdName(roleId);
|
|
756
|
-
};
|
|
757
|
-
PartsScopeEditorComponent.prototype.submit = function () {
|
|
758
|
-
var _this = this;
|
|
759
|
-
if (this.form.invalid) {
|
|
760
|
-
return;
|
|
761
|
-
}
|
|
762
|
-
var ids = [];
|
|
763
|
-
for (var i = 0; i < this.checks.length; i++) {
|
|
764
|
-
if (this.checks.controls[i].value === true) {
|
|
765
|
-
ids.push(this._parts[i].id);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
var msg = this.scope.value
|
|
769
|
-
? "Assign scope \"" + this.scope.value + "\" to " + ids.length + " part"
|
|
770
|
-
: "Remove scope from " + ids.length + " part";
|
|
771
|
-
msg += ids.length > 1 ? 's?' : '?';
|
|
772
|
-
this._dialogService.confirm('Confirm Scopes', msg).subscribe(function (result) {
|
|
773
|
-
if (!result) {
|
|
774
|
-
return;
|
|
775
|
-
}
|
|
776
|
-
_this.setScopeRequest.emit({
|
|
777
|
-
ids: ids,
|
|
778
|
-
scope: _this.scope.value,
|
|
779
|
-
});
|
|
780
|
-
});
|
|
781
|
-
};
|
|
782
|
-
return PartsScopeEditorComponent;
|
|
783
|
-
}());
|
|
784
|
-
PartsScopeEditorComponent.decorators = [
|
|
785
|
-
{ type: core.Component, args: [{
|
|
786
|
-
selector: 'cadmus-parts-scope-editor',
|
|
787
|
-
template: "<form [formGroup]=\"form\" (submit)=\"submit()\">\n <table id=\"parts\">\n <thead>\n <tr>\n <th style=\"min-width: 32px;\"></th>\n <th>type</th>\n <th>role</th>\n <th>scope</th>\n <th>modified</th>\n <th>user</th>\n </tr>\n </thead>\n <tbody>\n <tr\n formArrayName=\"checks\"\n *ngFor=\"let ctl of checks.controls; let i = index\"\n >\n <td>\n \n <mat-checkbox [formControlName]=\"i\"></mat-checkbox>\n </td>\n <td>\n <span\n class=\"model-type\"\n [style.background-color]=\"\n getPartColor(parts[i].typeId, parts[i].roleId)\n \"\n >{{ getTypeIdName(parts[i].typeId) }}</span\n >\n </td>\n <td>{{ getRoleIdName(parts[i].roleId) }}</td>\n <td>{{ parts[i].thesaurusScope }}</td>\n <td>{{ parts[i].timeModified | amLocal | amTimeAgo }}</td>\n <td>{{ parts[i].userId }}</td>\n </tr>\n </tbody>\n </table>\n <div>\n <mat-form-field>\n <input matInput placeholder=\"scope\" formControlName=\"scope\" />\n <mat-error\n *ngIf=\"scope.hasError('maxLength') && (scope.dirty || scope.touched)\"\n >too long</mat-error\n >\n <mat-error\n *ngIf=\"scope.hasError('pattern') && (scope.dirty || scope.touched)\"\n >invalid scope</mat-error\n >\n </mat-form-field>\n </div>\n <button\n mat-raised-button\n color=\"primary\"\n type=\"submit\"\n [disabled]=\"form.invalid || readonly\"\n matTooltip=\"Assign the scope to the checked parts\"\n >\n assign\n </button>\n</form>\n",
|
|
788
|
-
styles: ["th{color:silver;font-weight:400;text-align:left}span.model-type{border-radius:6px;padding:4px}table#parts{border-collapse:initial;border-spacing:0 8px}"]
|
|
789
|
-
},] }
|
|
790
|
-
];
|
|
791
|
-
PartsScopeEditorComponent.ctorParameters = function () { return [
|
|
792
|
-
{ type: forms.FormBuilder },
|
|
793
|
-
{ type: cadmusApi.FacetService },
|
|
794
|
-
{ type: cadmusUi.DialogService },
|
|
795
|
-
{ type: cadmusState.AppQuery },
|
|
796
|
-
{ type: cadmusState.EditItemQuery }
|
|
797
|
-
]; };
|
|
798
|
-
PartsScopeEditorComponent.propDecorators = {
|
|
799
|
-
parts: [{ type: core.Input }],
|
|
800
|
-
readonly: [{ type: core.Input }],
|
|
801
|
-
setScopeRequest: [{ type: core.Output }]
|
|
802
|
-
};
|
|
803
|
-
|
|
804
|
-
var MissingPartsComponent = /** @class */ (function () {
|
|
805
|
-
function MissingPartsComponent() {
|
|
806
|
-
this.missingDefinitions = [];
|
|
807
|
-
this.addRequest = new core.EventEmitter();
|
|
808
|
-
}
|
|
809
|
-
Object.defineProperty(MissingPartsComponent.prototype, "partDefinitions", {
|
|
810
|
-
get: function () {
|
|
811
|
-
return this._partDefinitions;
|
|
812
|
-
},
|
|
813
|
-
set: function (value) {
|
|
814
|
-
this._partDefinitions = value;
|
|
815
|
-
this.updateMissing();
|
|
816
|
-
},
|
|
817
|
-
enumerable: false,
|
|
818
|
-
configurable: true
|
|
819
|
-
});
|
|
820
|
-
Object.defineProperty(MissingPartsComponent.prototype, "parts", {
|
|
821
|
-
get: function () {
|
|
822
|
-
return this._parts;
|
|
823
|
-
},
|
|
824
|
-
set: function (value) {
|
|
825
|
-
this._parts = value;
|
|
826
|
-
this.updateMissing();
|
|
827
|
-
},
|
|
828
|
-
enumerable: false,
|
|
829
|
-
configurable: true
|
|
830
|
-
});
|
|
831
|
-
Object.defineProperty(MissingPartsComponent.prototype, "typeThesaurus", {
|
|
832
|
-
/**
|
|
833
|
-
* The types thesaurus.
|
|
834
|
-
*/
|
|
835
|
-
get: function () {
|
|
836
|
-
return this._typeThesaurus;
|
|
837
|
-
},
|
|
838
|
-
set: function (value) {
|
|
839
|
-
this._typeThesaurus = value;
|
|
840
|
-
this.updateMissing();
|
|
841
|
-
},
|
|
842
|
-
enumerable: false,
|
|
843
|
-
configurable: true
|
|
844
|
-
});
|
|
845
|
-
MissingPartsComponent.prototype.ngOnInit = function () { };
|
|
846
|
-
MissingPartsComponent.prototype.isPartPresent = function (typeId, roleId) {
|
|
847
|
-
return this._partDefinitions.some(function (d) { return d.typeId === typeId && d.roleId === roleId; });
|
|
848
|
-
};
|
|
849
|
-
MissingPartsComponent.prototype.updateMissing = function () {
|
|
850
|
-
this.missingDefinitions.length = 0;
|
|
851
|
-
if (!this._partDefinitions) {
|
|
852
|
-
return;
|
|
853
|
-
}
|
|
854
|
-
for (var i = 0; i < this._partDefinitions.length; i++) {
|
|
855
|
-
var def = this._partDefinitions[i];
|
|
856
|
-
if (!this.isPartPresent(def.typeId, def.roleId)) {
|
|
857
|
-
this.missingDefinitions.push(def);
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
};
|
|
861
|
-
return MissingPartsComponent;
|
|
862
|
-
}());
|
|
863
|
-
MissingPartsComponent.decorators = [
|
|
864
|
-
{ type: core.Component, args: [{
|
|
865
|
-
selector: 'cadmus-missing-parts',
|
|
866
|
-
template: "<div *ngIf=\"missingDefinitions.length\">\r\n <h3><mat-icon color=\"warn\">warning</mat-icon> Missing Parts</h3>\r\n <table>\r\n <tbody>\r\n <tr *ngFor=\"let def of missingDefinitions\">\r\n <td>\r\n <button type=\"button\" mat-icon-button matTooltip=\"Add this part\">\r\n <mat-icon>add_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td matTooltip=\"def.description\">\r\n <cadmus-part-badge\r\n [partTypeIds]=\"def\"\r\n [facetDefinition]=\"def\"\r\n [typeThesaurus]=\"typeThesaurus\"\r\n ></cadmus-part-badge>\r\n </td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n</div>\r\n",
|
|
867
|
-
styles: [""]
|
|
868
|
-
},] }
|
|
869
|
-
];
|
|
870
|
-
MissingPartsComponent.ctorParameters = function () { return []; };
|
|
871
|
-
MissingPartsComponent.propDecorators = {
|
|
872
|
-
partDefinitions: [{ type: core.Input }],
|
|
873
|
-
parts: [{ type: core.Input }],
|
|
874
|
-
typeThesaurus: [{ type: core.Input }],
|
|
875
|
-
addRequest: [{ type: core.Output }]
|
|
876
|
-
};
|
|
877
|
-
|
|
878
|
-
// https://github.com/ng-packagr/ng-packagr/issues/778
|
|
879
|
-
var RouterModuleForChild = router.RouterModule.forChild([
|
|
880
|
-
{ path: '', pathMatch: 'full', component: ItemEditorComponent },
|
|
881
|
-
]);
|
|
882
|
-
var CadmusItemEditorModule = /** @class */ (function () {
|
|
883
|
-
function CadmusItemEditorModule() {
|
|
884
|
-
}
|
|
885
|
-
return CadmusItemEditorModule;
|
|
886
|
-
}());
|
|
887
|
-
CadmusItemEditorModule.decorators = [
|
|
888
|
-
{ type: core.NgModule, args: [{
|
|
889
|
-
imports: [
|
|
890
|
-
common.CommonModule,
|
|
891
|
-
forms.ReactiveFormsModule,
|
|
892
|
-
forms.FormsModule,
|
|
893
|
-
RouterModuleForChild,
|
|
894
|
-
clipboard.ClipboardModule,
|
|
895
|
-
ngxMoment.MomentModule,
|
|
896
|
-
// cadmus
|
|
897
|
-
cadmusCore.CadmusCoreModule,
|
|
898
|
-
cadmusMaterial.CadmusMaterialModule,
|
|
899
|
-
cadmusApi.CadmusApiModule,
|
|
900
|
-
cadmusUi.CadmusUiModule,
|
|
901
|
-
cadmusState.CadmusStateModule,
|
|
902
|
-
],
|
|
903
|
-
declarations: [
|
|
904
|
-
ItemEditorComponent,
|
|
905
|
-
MissingPartsComponent,
|
|
906
|
-
PartsScopeEditorComponent,
|
|
907
|
-
],
|
|
908
|
-
exports: [ItemEditorComponent],
|
|
909
|
-
},] }
|
|
910
|
-
];
|
|
911
|
-
|
|
912
|
-
/*
|
|
913
|
-
* Public API Surface of cadmus-item-editor
|
|
914
|
-
*/
|
|
915
|
-
|
|
916
|
-
/**
|
|
917
|
-
* Generated bundle index. Do not edit.
|
|
918
|
-
*/
|
|
919
|
-
|
|
920
|
-
exports.CadmusItemEditorModule = CadmusItemEditorModule;
|
|
921
|
-
exports.ItemEditorComponent = ItemEditorComponent;
|
|
922
|
-
exports.RouterModuleForChild = RouterModuleForChild;
|
|
923
|
-
exports.ɵa = MissingPartsComponent;
|
|
924
|
-
exports.ɵb = PartsScopeEditorComponent;
|
|
925
|
-
|
|
926
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
927
|
-
|
|
928
|
-
})));
|
|
929
|
-
//# sourceMappingURL=myrmidon-cadmus-item-editor.umd.js.map
|