@openinc/parse-server-opendash 4.12.0 → 4.14.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/dist/features/permissions/types/Permissions.d.ts +7 -10
- package/dist/features/permissions/types/Permissions.js +21 -15
- package/dist/functions/openinc-backfill-ticket-sort-keys.d.ts +18 -0
- package/dist/functions/openinc-backfill-ticket-sort-keys.js +52 -0
- package/dist/helper/ticketSortKeys.d.ts +37 -0
- package/dist/helper/ticketSortKeys.js +78 -0
- package/dist/hooks/Service_Equipment.js +8 -3
- package/dist/hooks/Service_Project.js +8 -3
- package/dist/hooks/Service_Schedule.js +22 -0
- package/dist/hooks/Service_Schedule_Template.js +25 -7
- package/dist/hooks/Service_Status.js +8 -3
- package/dist/hooks/Service_Ticket.js +170 -45
- package/dist/types/Service_Ticket.d.ts +9 -0
- package/dist/types/Service_Ticket.js +18 -0
- package/package.json +1 -1
- package/schema/Service_Ticket.json +12 -0
|
@@ -19,21 +19,18 @@ export declare namespace Permissions {
|
|
|
19
19
|
kanban_view = "maintenance:can-update-kanban-view"
|
|
20
20
|
}
|
|
21
21
|
enum SERVICE {
|
|
22
|
-
admin_access = "
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
admin_access = "openservice-core:can-access-admin",
|
|
23
|
+
masterdata_manage = "openservice-core:can-manage-masterdata",
|
|
24
|
+
tag_create = "openservice-core:can-create-tag",
|
|
25
|
+
ticket_access = "openservice-ticket:can-access-ticket-plugin",
|
|
26
|
+
ticket_create = "openservice-ticket:can-create-ticket",
|
|
27
|
+
ticket_delete = "openservice-ticket:can-delete-ticket",
|
|
28
28
|
schedule_access = "openservice-schedule:can-access-schedule-plugin",
|
|
29
29
|
schedule_create = "openservice-schedule:can-create-schedule",
|
|
30
30
|
schedule_delete = "openservice-schedule:can-delete-schedule",
|
|
31
31
|
execution_perform = "openservice-schedule:can-perform-execution",
|
|
32
32
|
template_manage = "openservice-schedule:can-manage-template",
|
|
33
|
-
|
|
34
|
-
formconfig_manage = "service:can-manage-formconfig",
|
|
35
|
-
tag_create = "service:can-create-tag",
|
|
36
|
-
analytics_view = "service:can-view-analytics"
|
|
33
|
+
analytics_view = "openservice-schedule:can-view-analytics"
|
|
37
34
|
}
|
|
38
35
|
enum CORE {
|
|
39
36
|
adminoverview = "opendash:can-access-admin-overview",
|
|
@@ -28,19 +28,32 @@ var Permissions;
|
|
|
28
28
|
// Update
|
|
29
29
|
MAINTENANCE["kanban_view"] = "maintenance:can-update-kanban-view";
|
|
30
30
|
})(MAINTENANCE = Permissions.MAINTENANCE || (Permissions.MAINTENANCE = {}));
|
|
31
|
+
// The prefix names the plugin that owns a key, and it is the i18n namespace
|
|
32
|
+
// the role admin resolves the label (`<key>.label`) in — each plugin ships
|
|
33
|
+
// the texts for its own keys. Must stay in sync with `SERVICE_PERMISSIONS`
|
|
34
|
+
// in `@opendash/plugin-openservice-core`.
|
|
31
35
|
let SERVICE;
|
|
32
36
|
(function (SERVICE) {
|
|
37
|
+
// openservice-core — shared by the ticket and the schedule plugin.
|
|
38
|
+
//
|
|
33
39
|
// Access to the shared service administration (`/admin/service/**`) —
|
|
34
40
|
// master data, contacts, service providers. Deliberately not tied to the
|
|
35
41
|
// schedule plugin: a tenant running only tickets administers the same
|
|
36
42
|
// contacts and companies.
|
|
37
|
-
SERVICE["admin_access"] = "
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
SERVICE["
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
SERVICE["admin_access"] = "openservice-core:can-access-admin";
|
|
44
|
+
SERVICE["masterdata_manage"] = "openservice-core:can-manage-masterdata";
|
|
45
|
+
// Narrow master-data capability: create a tag inline from a tag picker,
|
|
46
|
+
// without granting full master-data management.
|
|
47
|
+
SERVICE["tag_create"] = "openservice-core:can-create-tag";
|
|
48
|
+
// Ticket-Plugin
|
|
49
|
+
//
|
|
50
|
+
// No `read`, `edit` or `assign`: the ticket's ACL decides those per
|
|
51
|
+
// record. `create` has no record yet whose ACL could be asked. `delete`
|
|
52
|
+
// covers archiving, which is an update the ACL would grant to everybody
|
|
53
|
+
// assigned to the ticket.
|
|
54
|
+
SERVICE["ticket_access"] = "openservice-ticket:can-access-ticket-plugin";
|
|
55
|
+
SERVICE["ticket_create"] = "openservice-ticket:can-create-ticket";
|
|
56
|
+
SERVICE["ticket_delete"] = "openservice-ticket:can-delete-ticket";
|
|
44
57
|
// Schedule-Plugin
|
|
45
58
|
//
|
|
46
59
|
// No `read` or `edit` here on purpose: both are decided per record by the
|
|
@@ -54,14 +67,7 @@ var Permissions;
|
|
|
54
67
|
SERVICE["schedule_delete"] = "openservice-schedule:can-delete-schedule";
|
|
55
68
|
SERVICE["execution_perform"] = "openservice-schedule:can-perform-execution";
|
|
56
69
|
SERVICE["template_manage"] = "openservice-schedule:can-manage-template";
|
|
57
|
-
|
|
58
|
-
SERVICE["masterdata_manage"] = "service:can-manage-masterdata";
|
|
59
|
-
SERVICE["formconfig_manage"] = "service:can-manage-formconfig";
|
|
60
|
-
// Narrow master-data capability: create a tag inline from a tag picker,
|
|
61
|
-
// without granting full master-data management.
|
|
62
|
-
SERVICE["tag_create"] = "service:can-create-tag";
|
|
63
|
-
// Analytics / monitoring
|
|
64
|
-
SERVICE["analytics_view"] = "service:can-view-analytics";
|
|
70
|
+
SERVICE["analytics_view"] = "openservice-schedule:can-view-analytics";
|
|
65
71
|
})(SERVICE = Permissions.SERVICE || (Permissions.SERVICE = {}));
|
|
66
72
|
let CORE;
|
|
67
73
|
(function (CORE) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fills the sort shadow columns of one ticket — a Parse Dashboard script, run
|
|
3
|
+
* from "Run script on selected row" in the data browser.
|
|
4
|
+
*
|
|
5
|
+
* `statusOrder`, `projectSortKey` and `equipmentSortKey` are derived in
|
|
6
|
+
* `hooks/Service_Ticket.ts` when a ticket is saved, so every ticket written
|
|
7
|
+
* before those columns existed sorts as empty until it is touched once.
|
|
8
|
+
*
|
|
9
|
+
* All this does is re-save the row. The hook fills a missing key even when the
|
|
10
|
+
* pointer has not changed, so a plain save is the whole repair — and running it
|
|
11
|
+
* on a ticket that already has its keys changes nothing but `updatedAt`.
|
|
12
|
+
*
|
|
13
|
+
* Select the rows in the data browser (the whole page at a time works) and run
|
|
14
|
+
* it; it is safe to repeat.
|
|
15
|
+
*
|
|
16
|
+
* @param name The function name, derived from the file name.
|
|
17
|
+
*/
|
|
18
|
+
export declare function init(name: string): Promise<void>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.init = init;
|
|
7
|
+
const node_1 = __importDefault(require("parse/node"));
|
|
8
|
+
const index_js_1 = require("../types/index.js");
|
|
9
|
+
/**
|
|
10
|
+
* Fills the sort shadow columns of one ticket — a Parse Dashboard script, run
|
|
11
|
+
* from "Run script on selected row" in the data browser.
|
|
12
|
+
*
|
|
13
|
+
* `statusOrder`, `projectSortKey` and `equipmentSortKey` are derived in
|
|
14
|
+
* `hooks/Service_Ticket.ts` when a ticket is saved, so every ticket written
|
|
15
|
+
* before those columns existed sorts as empty until it is touched once.
|
|
16
|
+
*
|
|
17
|
+
* All this does is re-save the row. The hook fills a missing key even when the
|
|
18
|
+
* pointer has not changed, so a plain save is the whole repair — and running it
|
|
19
|
+
* on a ticket that already has its keys changes nothing but `updatedAt`.
|
|
20
|
+
*
|
|
21
|
+
* Select the rows in the data browser (the whole page at a time works) and run
|
|
22
|
+
* it; it is safe to repeat.
|
|
23
|
+
*
|
|
24
|
+
* @param name The function name, derived from the file name.
|
|
25
|
+
*/
|
|
26
|
+
async function init(name) {
|
|
27
|
+
node_1.default.Cloud.define(name, async function (request) {
|
|
28
|
+
const object = request.params.object;
|
|
29
|
+
// Thrown rather than returned: the dashboard surfaces a rejection as an
|
|
30
|
+
// error toast, while any resolved value reads as success.
|
|
31
|
+
if (!object) {
|
|
32
|
+
throw new node_1.default.Error(node_1.default.Error.INVALID_JSON, "No object was passed. Run this from the data browser on a selected row.");
|
|
33
|
+
}
|
|
34
|
+
if (object.className !== index_js_1.Service_Ticket.className) {
|
|
35
|
+
throw new node_1.default.Error(node_1.default.Error.INVALID_CLASS_NAME, `Expected a ${index_js_1.Service_Ticket.className} row, got ${object.className}.`);
|
|
36
|
+
}
|
|
37
|
+
await object.save(null, { useMasterKey: true });
|
|
38
|
+
return {
|
|
39
|
+
success: true,
|
|
40
|
+
id: object.id,
|
|
41
|
+
// Reported back so the dashboard shows what the row ended up with,
|
|
42
|
+
// rather than just "done". A ticket without a project legitimately has
|
|
43
|
+
// no project key.
|
|
44
|
+
statusOrder: object.get("statusOrder") ?? null,
|
|
45
|
+
projectSortKey: object.get("projectSortKey") ?? null,
|
|
46
|
+
equipmentSortKey: object.get("equipmentSortKey") ?? null,
|
|
47
|
+
};
|
|
48
|
+
}, {
|
|
49
|
+
// Parse Dashboard runs scripts with the master key.
|
|
50
|
+
requireMaster: true,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps the tickets' sort shadow columns in step when the referenced master
|
|
3
|
+
* data is renamed or reordered.
|
|
4
|
+
*
|
|
5
|
+
* `Service_Ticket`'s `beforeSave` derives `statusOrder`, `projectSortKey` and
|
|
6
|
+
* `equipmentSortKey` from the row a ticket points at — but only at the moment
|
|
7
|
+
* the ticket is saved. Renaming a project afterwards would leave every ticket
|
|
8
|
+
* sorting under the old name, so the owning class pushes the new value down
|
|
9
|
+
* from its own `afterSave`.
|
|
10
|
+
*
|
|
11
|
+
* Same shape as the tag closure reconciliation in `Service_Tag`: an invariant
|
|
12
|
+
* that has to hold for every write path, which only a backend trigger can
|
|
13
|
+
* guarantee.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Comparable form of a label — identical to the one in `hooks/Service_Ticket`.
|
|
17
|
+
*
|
|
18
|
+
* MongoDB compares strings byte by byte, so "Ökowerk" would sort behind
|
|
19
|
+
* "Zementwerk". Folding the diacritics puts it at "O", which is what German
|
|
20
|
+
* readers expect (DIN 5007-1).
|
|
21
|
+
*/
|
|
22
|
+
export declare function sortKeyOf(label: unknown): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Writes `value` into `targetField` on every ticket pointing at `row`.
|
|
25
|
+
*
|
|
26
|
+
* Narrowed to the row's own tenant where it has one: a referenced object can
|
|
27
|
+
* only be used by tickets of the same tenant, so there is no reason to scan
|
|
28
|
+
* — let alone touch — anybody else's data.
|
|
29
|
+
*/
|
|
30
|
+
export declare function pushSortKeyToTickets(pointerField: "status" | "project" | "equipment", targetField: "statusOrder" | "projectSortKey" | "equipmentSortKey", row: Parse.Object, value: number | string | undefined): Promise<number>;
|
|
31
|
+
/**
|
|
32
|
+
* Did the value a sort key is derived from change with this save?
|
|
33
|
+
*
|
|
34
|
+
* `original` is undefined on create, where the ticket's own `beforeSave` has
|
|
35
|
+
* already set the key — so a create needs no push and this returns false.
|
|
36
|
+
*/
|
|
37
|
+
export declare function derivedValueChanged(object: Parse.Object, original: Parse.Object | undefined, field: string): boolean;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.sortKeyOf = sortKeyOf;
|
|
7
|
+
exports.pushSortKeyToTickets = pushSortKeyToTickets;
|
|
8
|
+
exports.derivedValueChanged = derivedValueChanged;
|
|
9
|
+
const node_1 = __importDefault(require("parse/node"));
|
|
10
|
+
const index_js_1 = require("../types/index.js");
|
|
11
|
+
/**
|
|
12
|
+
* Keeps the tickets' sort shadow columns in step when the referenced master
|
|
13
|
+
* data is renamed or reordered.
|
|
14
|
+
*
|
|
15
|
+
* `Service_Ticket`'s `beforeSave` derives `statusOrder`, `projectSortKey` and
|
|
16
|
+
* `equipmentSortKey` from the row a ticket points at — but only at the moment
|
|
17
|
+
* the ticket is saved. Renaming a project afterwards would leave every ticket
|
|
18
|
+
* sorting under the old name, so the owning class pushes the new value down
|
|
19
|
+
* from its own `afterSave`.
|
|
20
|
+
*
|
|
21
|
+
* Same shape as the tag closure reconciliation in `Service_Tag`: an invariant
|
|
22
|
+
* that has to hold for every write path, which only a backend trigger can
|
|
23
|
+
* guarantee.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Comparable form of a label — identical to the one in `hooks/Service_Ticket`.
|
|
27
|
+
*
|
|
28
|
+
* MongoDB compares strings byte by byte, so "Ökowerk" would sort behind
|
|
29
|
+
* "Zementwerk". Folding the diacritics puts it at "O", which is what German
|
|
30
|
+
* readers expect (DIN 5007-1).
|
|
31
|
+
*/
|
|
32
|
+
function sortKeyOf(label) {
|
|
33
|
+
if (typeof label !== "string")
|
|
34
|
+
return undefined;
|
|
35
|
+
const trimmed = label.trim();
|
|
36
|
+
if (!trimmed)
|
|
37
|
+
return undefined;
|
|
38
|
+
return trimmed
|
|
39
|
+
.normalize("NFD")
|
|
40
|
+
.replace(/\p{Diacritic}/gu, "")
|
|
41
|
+
.replace(/ß/g, "ss")
|
|
42
|
+
.toLowerCase();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Writes `value` into `targetField` on every ticket pointing at `row`.
|
|
46
|
+
*
|
|
47
|
+
* Narrowed to the row's own tenant where it has one: a referenced object can
|
|
48
|
+
* only be used by tickets of the same tenant, so there is no reason to scan
|
|
49
|
+
* — let alone touch — anybody else's data.
|
|
50
|
+
*/
|
|
51
|
+
async function pushSortKeyToTickets(pointerField, targetField, row, value) {
|
|
52
|
+
const query = new node_1.default.Query(index_js_1.Service_Ticket).equalTo(pointerField, row);
|
|
53
|
+
const tenant = row.get("tenant");
|
|
54
|
+
if (tenant)
|
|
55
|
+
query.equalTo("tenant", tenant);
|
|
56
|
+
const affected = await query.findAll({ useMasterKey: true });
|
|
57
|
+
if (affected.length === 0)
|
|
58
|
+
return 0;
|
|
59
|
+
for (const ticket of affected) {
|
|
60
|
+
if (value === undefined)
|
|
61
|
+
ticket.unset(targetField);
|
|
62
|
+
else
|
|
63
|
+
ticket.set(targetField, value);
|
|
64
|
+
}
|
|
65
|
+
await node_1.default.Object.saveAll(affected, { useMasterKey: true });
|
|
66
|
+
return affected.length;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Did the value a sort key is derived from change with this save?
|
|
70
|
+
*
|
|
71
|
+
* `original` is undefined on create, where the ticket's own `beforeSave` has
|
|
72
|
+
* already set the key — so a create needs no push and this returns false.
|
|
73
|
+
*/
|
|
74
|
+
function derivedValueChanged(object, original, field) {
|
|
75
|
+
if (!original)
|
|
76
|
+
return false;
|
|
77
|
+
return object.get(field) !== original.get(field);
|
|
78
|
+
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.init = init;
|
|
7
7
|
const node_1 = __importDefault(require("parse/node"));
|
|
8
8
|
const index_js_1 = require("../features/schema/index.js");
|
|
9
|
+
const ticketSortKeys_js_1 = require("../helper/ticketSortKeys.js");
|
|
9
10
|
const index_js_2 = require("../types/index.js");
|
|
10
11
|
async function init() {
|
|
11
12
|
// Soft delete: tickets and meter readings point at equipment, so it is
|
|
@@ -18,9 +19,13 @@ async function init() {
|
|
|
18
19
|
await (0, index_js_1.defaultAclHandler)(request);
|
|
19
20
|
// TODO
|
|
20
21
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
// Tickets sort by `equipmentSortKey`, derived from this label when the ticket
|
|
23
|
+
// was saved. A rename therefore has to reach them, or they keep sorting under
|
|
24
|
+
// the old name until each one is touched by hand.
|
|
25
|
+
(0, index_js_1.afterSaveHook)(index_js_2.Service_Equipment, async ({ object, original }) => {
|
|
26
|
+
if (!(0, ticketSortKeys_js_1.derivedValueChanged)(object, original, "label"))
|
|
27
|
+
return;
|
|
28
|
+
await (0, ticketSortKeys_js_1.pushSortKeyToTickets)("equipment", "equipmentSortKey", object, (0, ticketSortKeys_js_1.sortKeyOf)(object.get("label")));
|
|
24
29
|
});
|
|
25
30
|
// Block deleting equipment that is still referenced where it matters:
|
|
26
31
|
// active tickets, and meter readings (whose `equipment` pointer is required,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.init = init;
|
|
4
4
|
const index_js_1 = require("../features/schema/index.js");
|
|
5
|
+
const ticketSortKeys_js_1 = require("../helper/ticketSortKeys.js");
|
|
5
6
|
const index_js_2 = require("../types/index.js");
|
|
6
7
|
async function init() {
|
|
7
8
|
// Soft delete: tickets point at their project and draw their number from its
|
|
@@ -14,8 +15,12 @@ async function init() {
|
|
|
14
15
|
await (0, index_js_1.defaultAclHandler)(request);
|
|
15
16
|
// TODO
|
|
16
17
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
// Tickets sort by `projectSortKey`, derived from this label when the ticket was
|
|
19
|
+
// saved. A rename therefore has to reach them, or they keep sorting under the
|
|
20
|
+
// old name until each one is touched by hand.
|
|
21
|
+
(0, index_js_1.afterSaveHook)(index_js_2.Service_Project, async ({ object, original }) => {
|
|
22
|
+
if (!(0, ticketSortKeys_js_1.derivedValueChanged)(object, original, "label"))
|
|
23
|
+
return;
|
|
24
|
+
await (0, ticketSortKeys_js_1.pushSortKeyToTickets)("project", "projectSortKey", object, (0, ticketSortKeys_js_1.sortKeyOf)(object.get("label")));
|
|
20
25
|
});
|
|
21
26
|
}
|
|
@@ -14,6 +14,28 @@ const index_js_4 = require("../types/index.js");
|
|
|
14
14
|
async function init() {
|
|
15
15
|
(0, index_js_1.beforeSaveHook)(index_js_4.Service_Schedule, async (request) => {
|
|
16
16
|
const { object, original, user } = request;
|
|
17
|
+
// Creating a plan is a capability: there is no record yet whose ACL could
|
|
18
|
+
// be asked, and the class-level `create` is open to everybody. The
|
|
19
|
+
// frontend hides its create button without it; this makes it hold for
|
|
20
|
+
// every other write path. A migration replays history, and master-key
|
|
21
|
+
// writes (alarm plans, the calendar sync) are the server's own.
|
|
22
|
+
//
|
|
23
|
+
// Passes `request`, not `request.user`: `defaultHandler` below refetches
|
|
24
|
+
// the user in place, which drops its session token (see the execution
|
|
25
|
+
// hook for the details).
|
|
26
|
+
if (!original && !(0, index_js_1.isMigrationMode)()) {
|
|
27
|
+
await (0, index_js_2.requirePermission)(request, Permissions_js_1.Permissions.SERVICE.schedule_create, "create a maintenance schedule");
|
|
28
|
+
}
|
|
29
|
+
// Archiving sets `deletedAt` — an update, which the plan's ACL grants to
|
|
30
|
+
// the creator and everybody assigned. The beforeDelete below only covers
|
|
31
|
+
// the hard delete, which no client uses; this is the path the frontend
|
|
32
|
+
// and the admin table take. Restoring is the same decision. Compared by
|
|
33
|
+
// presence, so a client resending the unchanged date is not refused.
|
|
34
|
+
if (original &&
|
|
35
|
+
!(0, index_js_1.isMigrationMode)() &&
|
|
36
|
+
!!object.get("deletedAt") !== !!original.get("deletedAt")) {
|
|
37
|
+
await (0, index_js_2.requirePermission)(request, Permissions_js_1.Permissions.SERVICE.schedule_delete, "archive a maintenance schedule");
|
|
38
|
+
}
|
|
17
39
|
await (0, index_js_1.defaultHandler)(request);
|
|
18
40
|
// The creator, recorded once and never rewritten: it is who the plan
|
|
19
41
|
// belongs to, and `defaultAclHandler` turns it into a read+write grant.
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.init = init;
|
|
4
|
-
const index_js_1 = require("../features/
|
|
4
|
+
const index_js_1 = require("../features/permissions/index.js");
|
|
5
|
+
const Permissions_js_1 = require("../features/permissions/types/Permissions.js");
|
|
6
|
+
const index_js_2 = require("../features/schema/index.js");
|
|
5
7
|
const assignmentAcl_js_1 = require("../features/openservice/serviceSchedules/assignmentAcl.js");
|
|
6
|
-
const
|
|
8
|
+
const index_js_3 = require("../types/index.js");
|
|
7
9
|
async function init() {
|
|
8
|
-
(0,
|
|
10
|
+
(0, index_js_2.beforeSaveHook)(index_js_3.Service_Schedule_Template, async (request) => {
|
|
9
11
|
const { object, original, user } = request;
|
|
10
|
-
|
|
12
|
+
// The template catalog is one capability — creating, editing and
|
|
13
|
+
// archiving alike, which is how the frontend gates it. The class-level
|
|
14
|
+
// permissions are open to everybody and the template's ACL would let its
|
|
15
|
+
// assigned roles change it. A migration replays history; master-key writes
|
|
16
|
+
// (the ACL sync in afterSave) are the server's own.
|
|
17
|
+
//
|
|
18
|
+
// Passes `request`, not `request.user`: `defaultHandler` below refetches
|
|
19
|
+
// the user in place, which drops its session token.
|
|
20
|
+
if (!(0, index_js_2.isMigrationMode)()) {
|
|
21
|
+
await (0, index_js_1.requirePermission)(request, Permissions_js_1.Permissions.SERVICE.template_manage, "change a maintenance template");
|
|
22
|
+
}
|
|
23
|
+
await (0, index_js_2.defaultHandler)(request);
|
|
11
24
|
// The creator, recorded once and never rewritten — a template stays visible
|
|
12
25
|
// to whoever built it, whatever happens to its assigned roles later.
|
|
13
26
|
if (!original && user && !object.get("user")) {
|
|
@@ -16,17 +29,22 @@ async function init() {
|
|
|
16
29
|
// A template is private like a plan: its creator, the roles it is assigned
|
|
17
30
|
// to, and administrators. Without `denyTenantUserRead` the whole tenant
|
|
18
31
|
// reads every template and assigning roles would mean nothing.
|
|
19
|
-
await (0,
|
|
32
|
+
await (0, index_js_2.defaultAclHandler)(request, {
|
|
20
33
|
allowCustomACL: true,
|
|
21
34
|
denyTenantUserRead: true,
|
|
22
35
|
});
|
|
23
36
|
});
|
|
24
|
-
(0,
|
|
37
|
+
(0, index_js_2.beforeDeleteHook)(index_js_3.Service_Schedule_Template, async (request) => {
|
|
38
|
+
if ((0, index_js_2.isMigrationMode)())
|
|
39
|
+
return;
|
|
40
|
+
await (0, index_js_1.requirePermission)(request, Permissions_js_1.Permissions.SERVICE.template_manage, "delete a maintenance template");
|
|
41
|
+
});
|
|
42
|
+
(0, index_js_2.afterSaveHook)(index_js_3.Service_Schedule_Template, async (request) => {
|
|
25
43
|
const { object, context } = request;
|
|
26
44
|
// The v1 → v2 migration writes the ACL this hook would derive itself; the
|
|
27
45
|
// sync would re-save the template under the master key without
|
|
28
46
|
// `skipChangelog`. See helper/migrationMode.ts.
|
|
29
|
-
if ((0,
|
|
47
|
+
if ((0, index_js_2.isMigrationMode)())
|
|
30
48
|
return;
|
|
31
49
|
// Our own ACL write — the assignments already match.
|
|
32
50
|
if (context?.[assignmentAcl_js_1.ASSIGNMENT_ACL_CONTEXT_FLAG])
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.init = init;
|
|
7
7
|
const node_1 = __importDefault(require("parse/node"));
|
|
8
8
|
const index_js_1 = require("../features/schema/index.js");
|
|
9
|
+
const ticketSortKeys_js_1 = require("../helper/ticketSortKeys.js");
|
|
9
10
|
const index_js_2 = require("../types/index.js");
|
|
10
11
|
async function init() {
|
|
11
12
|
// Soft delete: every ticket carries a required `status` pointer, so a status
|
|
@@ -18,9 +19,13 @@ async function init() {
|
|
|
18
19
|
await (0, index_js_1.defaultAclHandler)(request);
|
|
19
20
|
// TODO
|
|
20
21
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
// A ticket sorts by its status's workflow position, which it carries as
|
|
23
|
+
// `statusOrder`. Reordering the workflow has to reach the tickets, or the
|
|
24
|
+
// board keeps the old order until each one is touched by hand.
|
|
25
|
+
(0, index_js_1.afterSaveHook)(index_js_2.Service_Status, async ({ object, original }) => {
|
|
26
|
+
if (!(0, ticketSortKeys_js_1.derivedValueChanged)(object, original, "order"))
|
|
27
|
+
return;
|
|
28
|
+
await (0, ticketSortKeys_js_1.pushSortKeyToTickets)("status", "statusOrder", object, object.get("order"));
|
|
24
29
|
});
|
|
25
30
|
// A ticket's `status` is required — deleting a status still in use by active
|
|
26
31
|
// tickets would orphan that required pointer. Block it.
|
|
@@ -40,10 +40,12 @@ exports.init = init;
|
|
|
40
40
|
const node_1 = __importStar(require("parse/node"));
|
|
41
41
|
const i18next_1 = __importDefault(require("i18next"));
|
|
42
42
|
const index_js_1 = require("../features/schema/index.js");
|
|
43
|
+
const index_js_2 = require("../features/permissions/index.js");
|
|
44
|
+
const Permissions_js_1 = require("../features/permissions/types/Permissions.js");
|
|
43
45
|
const appLinks_js_1 = require("../helper/appLinks.js");
|
|
44
46
|
const pointerIds_js_1 = require("../helper/pointerIds.js");
|
|
45
47
|
const getUserLanguage_js_1 = require("../helper/getUserLanguage.js");
|
|
46
|
-
const
|
|
48
|
+
const index_js_3 = require("../types/index.js");
|
|
47
49
|
const ruleset_core_1 = require("@opendash/ruleset-core");
|
|
48
50
|
async function init() {
|
|
49
51
|
// Soft delete: a ticket is referenced by chat messages, meta entries,
|
|
@@ -51,10 +53,31 @@ async function init() {
|
|
|
51
53
|
// destroying. Archived rows are hidden from every client query here — see
|
|
52
54
|
// hideSoftDeleted() for the escape hatches (master key, an explicit
|
|
53
55
|
// constraint on `deleted`, and queries naming object ids).
|
|
54
|
-
(0, index_js_1.hideSoftDeleted)(
|
|
56
|
+
(0, index_js_1.hideSoftDeleted)(index_js_3.Service_Ticket, { field: "deleted" });
|
|
55
57
|
(0, index_js_1.beforeSaveHook)("OD3_Service_Ticket", async (request) => {
|
|
56
58
|
const { object, original, user } = request;
|
|
57
59
|
const isNew = object.isNew();
|
|
60
|
+
// Creating a ticket is a capability: there is no record yet whose ACL
|
|
61
|
+
// could be asked, and the class-level `create` is open to everybody. The
|
|
62
|
+
// frontend hides its create buttons without it; this is what makes it
|
|
63
|
+
// hold for every other write path. A migration replays history, and
|
|
64
|
+
// master-key writes (alarm tickets) are the server's own.
|
|
65
|
+
//
|
|
66
|
+
// Passes `request`, not `request.user`: `defaultHandler` below refetches
|
|
67
|
+
// the user in place, which drops its session token (see the execution
|
|
68
|
+
// hook for the details).
|
|
69
|
+
if (isNew && !(0, index_js_1.isMigrationMode)()) {
|
|
70
|
+
await (0, index_js_2.requirePermission)(request, Permissions_js_1.Permissions.SERVICE.ticket_create, "create a ticket");
|
|
71
|
+
}
|
|
72
|
+
// Archiving sets `deleted` — an update, which `setTicketACL` grants to the
|
|
73
|
+
// creator and everybody assigned. Retiring a ticket is a decision of its
|
|
74
|
+
// own, and restoring one is the same decision. Compared against
|
|
75
|
+
// `original`, so a client that resends the unchanged flag is not refused.
|
|
76
|
+
if (original &&
|
|
77
|
+
!(0, index_js_1.isMigrationMode)() &&
|
|
78
|
+
Boolean(object.get("deleted")) !== Boolean(original.get("deleted"))) {
|
|
79
|
+
await (0, index_js_2.requirePermission)(request, Permissions_js_1.Permissions.SERVICE.ticket_delete, "archive a ticket");
|
|
80
|
+
}
|
|
58
81
|
if (isNew && !object.get("createdBy") && user)
|
|
59
82
|
object.set("createdBy", user);
|
|
60
83
|
await (0, index_js_1.defaultHandler)(request);
|
|
@@ -66,7 +89,9 @@ async function init() {
|
|
|
66
89
|
// showing every ticket.
|
|
67
90
|
await (0, index_js_1.defaultAclHandler)(request, { allowCustomACL: true });
|
|
68
91
|
await setTicketACL(object);
|
|
69
|
-
await
|
|
92
|
+
const referenced = await loadReferencedRows(object);
|
|
93
|
+
assertSameTenantReferences(object, referenced);
|
|
94
|
+
applySortKeys(object, referenced);
|
|
70
95
|
// Assign a sequential ticket number on creation. Done here (backend) rather
|
|
71
96
|
// than in the frontend because every write path — the create form, the
|
|
72
97
|
// cross-plugin service, and the generic entity admin — funnels through this
|
|
@@ -82,11 +107,19 @@ async function init() {
|
|
|
82
107
|
await assignTicketNumber(object);
|
|
83
108
|
}
|
|
84
109
|
});
|
|
85
|
-
|
|
110
|
+
// A hard delete takes the ticket's chat, meta entries and notifications with
|
|
111
|
+
// it (see the cascade below) — at least the decision archiving is. Parse has
|
|
112
|
+
// no delete right of its own: the ACL's write grant covers delete as well.
|
|
113
|
+
(0, index_js_1.beforeDeleteHook)(index_js_3.Service_Ticket, async (request) => {
|
|
114
|
+
if ((0, index_js_1.isMigrationMode)())
|
|
115
|
+
return;
|
|
116
|
+
await (0, index_js_2.requirePermission)(request, Permissions_js_1.Permissions.SERVICE.ticket_delete, "delete a ticket");
|
|
117
|
+
});
|
|
118
|
+
(0, index_js_1.afterDeleteHook)(index_js_3.Service_Ticket, async ({ object }) => {
|
|
86
119
|
if (object.id)
|
|
87
120
|
await cleanupTicketRelations(object.id);
|
|
88
121
|
});
|
|
89
|
-
(0, index_js_1.afterSaveHook)(
|
|
122
|
+
(0, index_js_1.afterSaveHook)(index_js_3.Service_Ticket, async ({ object, original, user }) => {
|
|
90
123
|
// A bulk import would otherwise notify every assignee once per migrated
|
|
91
124
|
// ticket (~10k per tenant). See helper/migrationMode.ts.
|
|
92
125
|
if ((0, index_js_1.isMigrationMode)())
|
|
@@ -129,20 +162,20 @@ const RELATED_DELETE_LIMIT = 10000;
|
|
|
129
162
|
*/
|
|
130
163
|
async function cleanupTicketRelations(ticketId) {
|
|
131
164
|
const [metaEntries, chatMessages, notifications] = await Promise.all([
|
|
132
|
-
new node_1.default.Query(
|
|
133
|
-
.equalTo("entryClassName",
|
|
165
|
+
new node_1.default.Query(index_js_3.Meta_Entry)
|
|
166
|
+
.equalTo("entryClassName", index_js_3.Service_Ticket.className)
|
|
134
167
|
.equalTo("entryObjectId", ticketId)
|
|
135
168
|
.limit(RELATED_DELETE_LIMIT)
|
|
136
169
|
.find({ useMasterKey: true }),
|
|
137
170
|
// Chat context is stored as `contextToString(["service","ticket",id])`,
|
|
138
171
|
// i.e. a JSON.stringify of the tuple — match it exactly.
|
|
139
|
-
new node_1.default.Query(
|
|
172
|
+
new node_1.default.Query(index_js_3.Chat_Message)
|
|
140
173
|
.equalTo("context", JSON.stringify(["service", "ticket", ticketId]))
|
|
141
174
|
.limit(RELATED_DELETE_LIMIT)
|
|
142
175
|
.find({ useMasterKey: true }),
|
|
143
176
|
// `data` is a JSON Object column; Parse supports dot-notation into it. Query
|
|
144
177
|
// by class name (untyped) so the `data.ticketId` path key is accepted.
|
|
145
|
-
new node_1.default.Query(
|
|
178
|
+
new node_1.default.Query(index_js_3.Notification.className)
|
|
146
179
|
.equalTo("data.ticketId", ticketId)
|
|
147
180
|
.limit(RELATED_DELETE_LIMIT)
|
|
148
181
|
.find({ useMasterKey: true }),
|
|
@@ -207,33 +240,57 @@ const TENANT_SCOPED_POINTERS = ["status", "project", "equipment"];
|
|
|
207
240
|
/** Pointer-array fields whose entries must belong to the ticket's own tenant. */
|
|
208
241
|
const TENANT_SCOPED_POINTER_ARRAYS = ["tags", "assignedUsers"];
|
|
209
242
|
/**
|
|
210
|
-
*
|
|
243
|
+
* Shadow columns the ticket carries so the table can sort by a pointer.
|
|
211
244
|
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
245
|
+
* Parse sorts a pointer column by the stored reference, which is the object id —
|
|
246
|
+
* ordering by it looks random. Sorting by the referenced *label* needs the value
|
|
247
|
+
* on the ticket itself, so these three are kept in step here, where the
|
|
248
|
+
* referenced rows are being read anyway.
|
|
249
|
+
*/
|
|
250
|
+
const SORT_KEY_FIELDS = {
|
|
251
|
+
status: "statusOrder",
|
|
252
|
+
project: "projectSortKey",
|
|
253
|
+
equipment: "equipmentSortKey",
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Comparable form of a label.
|
|
219
257
|
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
258
|
+
* MongoDB compares strings byte by byte, so "Ökowerk" would sort behind
|
|
259
|
+
* "Zementwerk". Folding the diacritics puts it at "O", which is what German
|
|
260
|
+
* readers expect (DIN 5007-1), and lower-casing keeps the order independent of
|
|
261
|
+
* how someone capitalised the name.
|
|
262
|
+
*/
|
|
263
|
+
function sortKeyOf(label) {
|
|
264
|
+
if (typeof label !== "string")
|
|
265
|
+
return undefined;
|
|
266
|
+
const trimmed = label.trim();
|
|
267
|
+
if (!trimmed)
|
|
268
|
+
return undefined;
|
|
269
|
+
return trimmed
|
|
270
|
+
.normalize("NFD")
|
|
271
|
+
.replace(/\p{Diacritic}/gu, "")
|
|
272
|
+
.replace(/ß/g, "ss")
|
|
273
|
+
.toLowerCase();
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Reads the rows a ticket's dirty pointer fields refer to, one query per class.
|
|
222
277
|
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
* one extra query.
|
|
278
|
+
* Pointers arrive unfetched, so both the tenant check and the sort keys need a
|
|
279
|
+
* read — doing it once here is what keeps a save at a single extra query.
|
|
226
280
|
*/
|
|
227
|
-
async function
|
|
228
|
-
const tenantId = object.get("tenant")?.id;
|
|
229
|
-
if (!tenantId)
|
|
230
|
-
return; // nothing to compare against
|
|
281
|
+
async function loadReferencedRows(object) {
|
|
231
282
|
const suspects = [];
|
|
232
283
|
for (const field of TENANT_SCOPED_POINTERS) {
|
|
233
|
-
if (!object.dirty(field))
|
|
234
|
-
continue;
|
|
235
284
|
const value = object.get(field);
|
|
236
|
-
if (value)
|
|
285
|
+
if (!value)
|
|
286
|
+
continue;
|
|
287
|
+
// Also read a pointer whose sort key is missing, even when it has not
|
|
288
|
+
// changed: that is what lets a plain re-save fill in a ticket written
|
|
289
|
+
// before those columns existed, with no separate backfill path.
|
|
290
|
+
const keyMissing = field in SORT_KEY_FIELDS &&
|
|
291
|
+
object.get(SORT_KEY_FIELDS[field]) ==
|
|
292
|
+
null;
|
|
293
|
+
if (object.dirty(field) || keyMissing)
|
|
237
294
|
suspects.push(value);
|
|
238
295
|
}
|
|
239
296
|
for (const field of TENANT_SCOPED_POINTER_ARRAYS) {
|
|
@@ -243,11 +300,6 @@ async function assertSameTenantReferences(object) {
|
|
|
243
300
|
if (Array.isArray(value))
|
|
244
301
|
suspects.push(...value.filter(Boolean));
|
|
245
302
|
}
|
|
246
|
-
if (suspects.length === 0)
|
|
247
|
-
return;
|
|
248
|
-
// Pointers arrive unfetched, so the tenant has to be read from the database —
|
|
249
|
-
// one query per referenced class rather than `fetchAll` over a mixed list,
|
|
250
|
-
// which is both explicit and the only form that reads `tenant` back reliably.
|
|
251
303
|
const byClass = new Map();
|
|
252
304
|
for (const suspect of suspects) {
|
|
253
305
|
// A pointer that has not been saved yet has no id — nothing to look up.
|
|
@@ -257,20 +309,93 @@ async function assertSameTenantReferences(object) {
|
|
|
257
309
|
ids.add(suspect.id);
|
|
258
310
|
byClass.set(suspect.className, ids);
|
|
259
311
|
}
|
|
312
|
+
const rows = new Map();
|
|
260
313
|
for (const [className, ids] of byClass) {
|
|
261
|
-
const
|
|
314
|
+
const found = await new node_1.default.Query(className)
|
|
262
315
|
.containedIn("objectId", [...ids])
|
|
263
|
-
.
|
|
316
|
+
// `label` and `order` feed the sort keys below; `tenant` the guard.
|
|
317
|
+
.select("tenant", "label", "order")
|
|
264
318
|
.limit(ids.size)
|
|
265
319
|
.find({ useMasterKey: true });
|
|
266
|
-
for (const row of
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
320
|
+
for (const row of found)
|
|
321
|
+
rows.set(row.id, row);
|
|
322
|
+
}
|
|
323
|
+
return rows;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Rejects a ticket that references master data from another tenant.
|
|
327
|
+
*
|
|
328
|
+
* ACLs do not stop an `od-admin` at a tenant boundary, so every picker in the
|
|
329
|
+
* UI used to offer every tenant's statuses, projects, equipment and tags. The
|
|
330
|
+
* frontend now scopes those queries, but the UI is not the only write path —
|
|
331
|
+
* the generic entity admin and the REST API go straight through here — and a
|
|
332
|
+
* ticket pointing at a foreign status is silently broken: it is counted in
|
|
333
|
+
* neither tenant's board, and it blocks deletion of that status
|
|
334
|
+
* (`Service_Status`'s in-use guard does not filter by tenant either).
|
|
335
|
+
*
|
|
336
|
+
* `assignedRoles` is deliberately not checked: `_Role` has no tenant column at
|
|
337
|
+
* all — a role's tenant lives in its name — so there is nothing to compare.
|
|
338
|
+
*/
|
|
339
|
+
function assertSameTenantReferences(object, rows) {
|
|
340
|
+
const tenantId = object.get("tenant")?.id;
|
|
341
|
+
if (!tenantId)
|
|
342
|
+
return; // nothing to compare against
|
|
343
|
+
// Only the dirty references are judged — the loaded set is wider than that
|
|
344
|
+
// (see `loadReferencedRows`), and a ticket that already carries a bad
|
|
345
|
+
// reference has to stay saveable so it can be repaired.
|
|
346
|
+
const judged = [];
|
|
347
|
+
for (const field of TENANT_SCOPED_POINTERS) {
|
|
348
|
+
if (!object.dirty(field))
|
|
349
|
+
continue;
|
|
350
|
+
const value = object.get(field);
|
|
351
|
+
const row = value?.id ? rows.get(value.id) : undefined;
|
|
352
|
+
if (row)
|
|
353
|
+
judged.push(row);
|
|
354
|
+
}
|
|
355
|
+
for (const field of TENANT_SCOPED_POINTER_ARRAYS) {
|
|
356
|
+
if (!object.dirty(field))
|
|
357
|
+
continue;
|
|
358
|
+
const value = object.get(field);
|
|
359
|
+
for (const entry of value ?? []) {
|
|
360
|
+
const row = entry?.id ? rows.get(entry.id) : undefined;
|
|
361
|
+
if (row)
|
|
362
|
+
judged.push(row);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
for (const row of judged) {
|
|
366
|
+
const refTenantId = row.get("tenant")?.id;
|
|
367
|
+
// No tenant on the referenced row = shared/global master data, allowed.
|
|
368
|
+
if (!refTenantId || refTenantId === tenantId)
|
|
369
|
+
continue;
|
|
370
|
+
throw new node_1.default.Error(node_1.default.Error.VALIDATION_ERROR, `Cannot reference ${row.className} ${row.id} from tenant ` +
|
|
371
|
+
`${refTenantId} on a ticket of tenant ${tenantId}.`);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Keeps {@link SORT_KEY_FIELDS} in step with the pointers they shadow.
|
|
376
|
+
*
|
|
377
|
+
* Only dirty pointers are touched, so a save that changes the title leaves the
|
|
378
|
+
* keys alone. Clearing a pointer clears its key, which sorts the ticket with
|
|
379
|
+
* the other unassigned ones rather than leaving a stale name behind.
|
|
380
|
+
*/
|
|
381
|
+
function applySortKeys(object, rows) {
|
|
382
|
+
for (const [field, target] of Object.entries(SORT_KEY_FIELDS)) {
|
|
383
|
+
const pointer = object.get(field);
|
|
384
|
+
const keyMissing = pointer && object.get(target) == null;
|
|
385
|
+
if (!object.dirty(field) && !keyMissing)
|
|
386
|
+
continue;
|
|
387
|
+
const row = pointer?.id ? rows.get(pointer.id) : undefined;
|
|
388
|
+
if (!row) {
|
|
389
|
+
object.unset(target);
|
|
390
|
+
continue;
|
|
273
391
|
}
|
|
392
|
+
// Status sorts by its configured workflow position, not by its name: a
|
|
393
|
+
// board reads "Eingang, In Bearbeitung, Erledigt", never alphabetically.
|
|
394
|
+
const value = field === "status" ? row.get("order") : sortKeyOf(row.get("label"));
|
|
395
|
+
if (value === undefined || value === null)
|
|
396
|
+
object.unset(target);
|
|
397
|
+
else
|
|
398
|
+
object.set(target, value);
|
|
274
399
|
}
|
|
275
400
|
}
|
|
276
401
|
/**
|
|
@@ -388,7 +513,7 @@ async function notifyWatchers(ticket, notified, assignerName) {
|
|
|
388
513
|
async function loadWatcherRules(tenant) {
|
|
389
514
|
if (!tenant)
|
|
390
515
|
return [];
|
|
391
|
-
const config = await new node_1.default.Query(
|
|
516
|
+
const config = await new node_1.default.Query(index_js_3.Config)
|
|
392
517
|
.equalTo("key", ASSIGNMENT_NOTIFICATION_CONFIG_KEY)
|
|
393
518
|
.equalTo("tenant", tenant)
|
|
394
519
|
.first({ useMasterKey: true });
|
|
@@ -455,7 +580,7 @@ async function sendAssignmentNotification(user, ticket, options) {
|
|
|
455
580
|
await i18next_1.default.changeLanguage(await (0, getUserLanguage_js_1.getUserLanguage)(user));
|
|
456
581
|
const base = `openservice:ticket.assignment.${options.variant}`;
|
|
457
582
|
const ticketName = ticket.get("title");
|
|
458
|
-
await new
|
|
583
|
+
await new index_js_3.Notification({
|
|
459
584
|
title: i18next_1.default.t(`${base}.title`),
|
|
460
585
|
description: i18next_1.default.t(`${base}.description`, {
|
|
461
586
|
username: options.assignerName,
|
|
@@ -21,6 +21,7 @@ export interface Service_TicketAttributes {
|
|
|
21
21
|
downtime?: number | undefined;
|
|
22
22
|
dueDate?: Date | undefined;
|
|
23
23
|
equipment?: Service_Equipment | undefined;
|
|
24
|
+
equipmentSortKey?: string | undefined;
|
|
24
25
|
estimatedDuration?: number | undefined;
|
|
25
26
|
frequency?: number | undefined;
|
|
26
27
|
material?: TicketMaterial[] | undefined;
|
|
@@ -29,8 +30,10 @@ export interface Service_TicketAttributes {
|
|
|
29
30
|
parent?: Service_Ticket | undefined;
|
|
30
31
|
priority?: number | undefined;
|
|
31
32
|
project?: Service_Project | undefined;
|
|
33
|
+
projectSortKey?: string | undefined;
|
|
32
34
|
restriction?: number | undefined;
|
|
33
35
|
startDate?: Date | undefined;
|
|
36
|
+
statusOrder?: number | undefined;
|
|
34
37
|
status: Service_Status;
|
|
35
38
|
tags?: any[] | undefined;
|
|
36
39
|
tenant: Tenant;
|
|
@@ -79,6 +82,12 @@ export declare class Service_Ticket extends Parse.Object<Service_TicketAttribute
|
|
|
79
82
|
set project(value: Service_Project | undefined);
|
|
80
83
|
get restriction(): number | undefined;
|
|
81
84
|
set restriction(value: number | undefined);
|
|
85
|
+
get equipmentSortKey(): string | undefined;
|
|
86
|
+
set equipmentSortKey(value: string | undefined);
|
|
87
|
+
get projectSortKey(): string | undefined;
|
|
88
|
+
set projectSortKey(value: string | undefined);
|
|
89
|
+
get statusOrder(): number | undefined;
|
|
90
|
+
set statusOrder(value: number | undefined);
|
|
82
91
|
get startDate(): Date | undefined;
|
|
83
92
|
set startDate(value: Date | undefined);
|
|
84
93
|
get status(): Service_Status;
|
|
@@ -130,6 +130,24 @@ class Service_Ticket extends node_1.default.Object {
|
|
|
130
130
|
set restriction(value) {
|
|
131
131
|
super.set("restriction", value);
|
|
132
132
|
}
|
|
133
|
+
get equipmentSortKey() {
|
|
134
|
+
return super.get("equipmentSortKey");
|
|
135
|
+
}
|
|
136
|
+
set equipmentSortKey(value) {
|
|
137
|
+
super.set("equipmentSortKey", value);
|
|
138
|
+
}
|
|
139
|
+
get projectSortKey() {
|
|
140
|
+
return super.get("projectSortKey");
|
|
141
|
+
}
|
|
142
|
+
set projectSortKey(value) {
|
|
143
|
+
super.set("projectSortKey", value);
|
|
144
|
+
}
|
|
145
|
+
get statusOrder() {
|
|
146
|
+
return super.get("statusOrder");
|
|
147
|
+
}
|
|
148
|
+
set statusOrder(value) {
|
|
149
|
+
super.set("statusOrder", value);
|
|
150
|
+
}
|
|
133
151
|
get startDate() {
|
|
134
152
|
return super.get("startDate");
|
|
135
153
|
}
|
package/package.json
CHANGED
|
@@ -37,6 +37,10 @@
|
|
|
37
37
|
"type": "Pointer",
|
|
38
38
|
"targetClass": "{{PREFIX}}Service_Equipment"
|
|
39
39
|
},
|
|
40
|
+
"equipmentSortKey": {
|
|
41
|
+
"type": "String",
|
|
42
|
+
"required": false
|
|
43
|
+
},
|
|
40
44
|
"estimatedDuration": {
|
|
41
45
|
"type": "Number"
|
|
42
46
|
},
|
|
@@ -63,6 +67,10 @@
|
|
|
63
67
|
"type": "Pointer",
|
|
64
68
|
"targetClass": "{{PREFIX}}Service_Project"
|
|
65
69
|
},
|
|
70
|
+
"projectSortKey": {
|
|
71
|
+
"type": "String",
|
|
72
|
+
"required": false
|
|
73
|
+
},
|
|
66
74
|
"restriction": {
|
|
67
75
|
"type": "Number"
|
|
68
76
|
},
|
|
@@ -74,6 +82,10 @@
|
|
|
74
82
|
"targetClass": "{{PREFIX}}Service_Status",
|
|
75
83
|
"required": true
|
|
76
84
|
},
|
|
85
|
+
"statusOrder": {
|
|
86
|
+
"type": "Number",
|
|
87
|
+
"required": false
|
|
88
|
+
},
|
|
77
89
|
"tags": {
|
|
78
90
|
"type": "Array"
|
|
79
91
|
},
|