@openinc/parse-server-opendash 4.20.0 → 4.21.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.
|
@@ -25,6 +25,7 @@ export declare namespace Permissions {
|
|
|
25
25
|
ticket_access = "openservice-ticket:can-access-ticket-plugin",
|
|
26
26
|
ticket_create = "openservice-ticket:can-create-ticket",
|
|
27
27
|
ticket_delete = "openservice-ticket:can-delete-ticket",
|
|
28
|
+
ticket_analytics_view = "openservice-ticket:can-view-analytics",
|
|
28
29
|
schedule_access = "openservice-schedule:can-access-schedule-plugin",
|
|
29
30
|
schedule_create = "openservice-schedule:can-create-schedule",
|
|
30
31
|
schedule_delete = "openservice-schedule:can-delete-schedule",
|
|
@@ -54,6 +54,11 @@ var Permissions;
|
|
|
54
54
|
SERVICE["ticket_access"] = "openservice-ticket:can-access-ticket-plugin";
|
|
55
55
|
SERVICE["ticket_create"] = "openservice-ticket:can-create-ticket";
|
|
56
56
|
SERVICE["ticket_delete"] = "openservice-ticket:can-delete-ticket";
|
|
57
|
+
// The ticket evaluations page. Its own key rather than the schedule
|
|
58
|
+
// plugin's `analytics_view`: a tenant may well want its shift leads to see
|
|
59
|
+
// ticket throughput without opening up maintenance compliance, and the two
|
|
60
|
+
// pages belong to two plugins that are deployed independently.
|
|
61
|
+
SERVICE["ticket_analytics_view"] = "openservice-ticket:can-view-analytics";
|
|
57
62
|
// Schedule-Plugin
|
|
58
63
|
//
|
|
59
64
|
// No `read` or `edit` here on purpose: both are decided per record by the
|
|
@@ -42,6 +42,7 @@ const i18next_1 = __importDefault(require("i18next"));
|
|
|
42
42
|
const index_js_1 = require("../features/schema/index.js");
|
|
43
43
|
const index_js_2 = require("../features/permissions/index.js");
|
|
44
44
|
const Permissions_js_1 = require("../features/permissions/types/Permissions.js");
|
|
45
|
+
const AlarmTicketTypes_js_1 = require("../features/openservice/alarms/ticket/AlarmTicketTypes.js");
|
|
45
46
|
const appLinks_js_1 = require("../helper/appLinks.js");
|
|
46
47
|
const pointerIds_js_1 = require("../helper/pointerIds.js");
|
|
47
48
|
const getUserLanguage_js_1 = require("../helper/getUserLanguage.js");
|
|
@@ -92,6 +93,7 @@ async function init() {
|
|
|
92
93
|
const referenced = await loadReferencedRows(object);
|
|
93
94
|
assertSameTenantReferences(object, referenced);
|
|
94
95
|
applySortKeys(object, referenced);
|
|
96
|
+
applyClosedAt(object, referenced);
|
|
95
97
|
// Assign a sequential ticket number on creation. Done here (backend) rather
|
|
96
98
|
// than in the frontend because every write path — the create form, the
|
|
97
99
|
// cross-plugin service, and the generic entity admin — funnels through this
|
|
@@ -320,8 +322,9 @@ async function loadReferencedRows(object) {
|
|
|
320
322
|
for (const [className, ids] of byClass) {
|
|
321
323
|
const found = await new node_1.default.Query(className)
|
|
322
324
|
.containedIn("objectId", [...ids])
|
|
323
|
-
// `label` and `order` feed the sort keys below
|
|
324
|
-
|
|
325
|
+
// `label` and `order` feed the sort keys below, `category` the
|
|
326
|
+
// closing date; `tenant` the guard.
|
|
327
|
+
.select("tenant", "label", "order", "category")
|
|
325
328
|
.limit(ids.size)
|
|
326
329
|
.find({ useMasterKey: true });
|
|
327
330
|
for (const row of found)
|
|
@@ -407,6 +410,57 @@ function applySortKeys(object, rows) {
|
|
|
407
410
|
object.set(target, value);
|
|
408
411
|
}
|
|
409
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* Stamps and clears `closedAt` from the ticket's status.
|
|
415
|
+
*
|
|
416
|
+
* **Why the server and not the form.** `closedAt` is the only record of when
|
|
417
|
+
* work finished, and every number built on it — throughput, how long a ticket
|
|
418
|
+
* sat open, what a month closed — is wrong if it is missing on some tickets and
|
|
419
|
+
* guessed on others. It was a plain date field nobody filled: the board moves a
|
|
420
|
+
* ticket to "Erledigt" by drag and drop, the detail page by a dropdown, the
|
|
421
|
+
* rules by an action, and none of them went near it. Doing it here covers every
|
|
422
|
+
* one of those paths plus the import and the REST API, which is the whole point
|
|
423
|
+
* of putting it in `beforeSave`.
|
|
424
|
+
*
|
|
425
|
+
* **The status decides, not the field.** A status counts as closing when its
|
|
426
|
+
* `category` is one of {@link DONE_STATUS_CATEGORIES} — the same list the alarm
|
|
427
|
+
* tickets and the frontend read, so "Erledigt", "Abgebrochen" and whatever a
|
|
428
|
+
* tenant calls them agree without anybody configuring it twice.
|
|
429
|
+
*
|
|
430
|
+
* Reopening clears the stamp. A ticket that goes back to "In Bearbeitung" is
|
|
431
|
+
* not closed, and leaving the old date would quietly count it as finished in
|
|
432
|
+
* every evaluation while it is being worked on again.
|
|
433
|
+
*
|
|
434
|
+
* **A value the caller sent wins.** `object.dirty("closedAt")` means somebody
|
|
435
|
+
* named a date in this same save — the migration replaying history, a correction
|
|
436
|
+
* in the admin table — and overwriting it with `now` would be this function
|
|
437
|
+
* deciding it knows better.
|
|
438
|
+
*/
|
|
439
|
+
function applyClosedAt(object, rows) {
|
|
440
|
+
// Nothing to react to: the status is unchanged. A ticket whose status stayed
|
|
441
|
+
// put keeps whatever stamp it has, including none.
|
|
442
|
+
if (!object.dirty("status"))
|
|
443
|
+
return;
|
|
444
|
+
// Explicitly set in this save — see the note above.
|
|
445
|
+
if (object.dirty("closedAt"))
|
|
446
|
+
return;
|
|
447
|
+
const status = object.get("status");
|
|
448
|
+
const row = status?.id ? rows.get(status.id) : undefined;
|
|
449
|
+
// The row is only missing when the pointer could not be read. Guessing either
|
|
450
|
+
// way would be worse than leaving the stamp as it is.
|
|
451
|
+
if (!row)
|
|
452
|
+
return;
|
|
453
|
+
const closing = AlarmTicketTypes_js_1.DONE_STATUS_CATEGORIES.includes(row.get("category"));
|
|
454
|
+
if (closing) {
|
|
455
|
+
// Already stamped: the ticket moved between two closing statuses
|
|
456
|
+
// ("Erledigt" → "Abgebrochen"). It closed when it first closed.
|
|
457
|
+
if (!object.get("closedAt"))
|
|
458
|
+
object.set("closedAt", new Date());
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
object.unset("closedAt");
|
|
462
|
+
}
|
|
463
|
+
}
|
|
410
464
|
/**
|
|
411
465
|
* Sets the ticket ACL from `createdBy`, `assignedUsers` and `assignedRoles` —
|
|
412
466
|
* each gets read/write. `assignedUsers`/`assignedRoles` are arrays of Parse
|