@openinc/parse-server-opendash 3.6.0 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,22 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.saveTicketMeta = saveTicketMeta;
|
|
4
4
|
async function saveTicketMeta(ticket, value, fetchOptions) {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const currentMeta = ticket.get("meta") ?? {
|
|
6
|
+
fields: [],
|
|
7
|
+
};
|
|
8
8
|
if (value) {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const updatedMetaFields = currentMeta.fields ?? [];
|
|
10
|
+
const newMetaFields = [];
|
|
11
11
|
// overriding existing fields
|
|
12
12
|
for (const field of value.fields) {
|
|
13
|
-
const index =
|
|
13
|
+
const index = updatedMetaFields.findIndex((v) => v.name === field.name);
|
|
14
14
|
if (index === -1)
|
|
15
|
-
|
|
15
|
+
newMetaFields.push(field);
|
|
16
16
|
else
|
|
17
|
-
|
|
17
|
+
updatedMetaFields[index].value = field.value;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
ticket.set("meta",
|
|
19
|
+
currentMeta.fields = [...updatedMetaFields, ...newMetaFields];
|
|
20
|
+
ticket.set("meta", {
|
|
21
|
+
...currentMeta, // use all existing values
|
|
22
|
+
...value, // override with new values
|
|
23
|
+
fields: currentMeta.fields, // use the updated fields
|
|
24
|
+
});
|
|
21
25
|
}
|
|
22
26
|
return await ticket.save(null, fetchOptions);
|
|
23
27
|
}
|