@steedos-labs/content-compliance 0.0.37 → 0.0.39
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/index.js +1 -1
- package/lib/index.js +217 -8
- package/lib/index.js.map +1 -1
- package/lib/methods/approval_engine.js +304 -145
- package/lib/methods/approval_engine.js.map +1 -1
- package/lib/methods/consts.d.ts +21 -5
- package/lib/methods/consts.js +12 -1
- package/lib/methods/consts.js.map +1 -1
- package/lib/methods/material.d.ts +4 -4
- package/lib/methods/material.js +87 -50
- package/lib/methods/material.js.map +1 -1
- package/main/default/objects/pepsico_approval_process/fields/type.field.yml +17 -0
- package/main/default/objects/pepsico_material/buttons/pepsico_material_approve.button.yml +5 -0
- package/main/default/objects/pepsico_material/buttons/pepsico_material_reject.button.yml +5 -0
- package/main/default/objects/pepsico_material/buttons/pepsico_nullify_material.button.yml +5 -0
- package/main/default/objects/pepsico_material/buttons/pepsico_update_material.button.yml +5 -0
- package/main/default/objects/pepsico_material/buttons/pepsico_upload_supplement.button.yml +5 -0
- package/main/default/objects/pepsico_material/fields/download_from_onedrive.field.yml +5 -0
- package/main/default/objects/pepsico_material/fields/remove_share_link_from_onedrive.field.yml +5 -0
- package/main/default/objects/pepsico_material_approval/buttons/kids_approve.button.yml +6 -1
- package/main/default/objects/pepsico_material_approval/buttons/kids_reject.button.yml +6 -1
- package/main/default/objects/pepsico_material_approval/buttons/pepsico_approval.button.yml +5 -0
- package/main/default/objects/pepsico_material_approval/buttons/pepsico_confirm_online.button.yml +10 -5
- package/main/default/objects/pepsico_material_approval/buttons/pepsico_material_upload.button.yml +6 -1
- package/main/default/objects/pepsico_material_approval/buttons/pepsico_postpone_online.button.yml +6 -1
- package/main/default/objects/pepsico_material_approval/buttons/pepsico_submit.button.yml +5 -0
- package/main/default/objects/pepsico_material_approval/buttons/pepsico_terminate.button.yml +5 -0
- package/main/default/objects/pepsico_material_approval/fields/materials_download_from_onedrive_failed_count.field.yml +5 -0
- package/main/default/objects/pepsico_material_approval/fields/materials_download_from_onedrive_status.field.yml +14 -0
- package/main/default/objects/pepsico_material_approval/fields/materials_remove_share_link_from_onedrive_failed_count.field.yml +5 -0
- package/main/default/objects/pepsico_material_approval/fields/materials_remove_share_link_from_onedrive_status.field.yml +14 -0
- package/main/default/triggers/pepsico_material_approval_init.trigger.yml +23 -0
- package/package.json +1 -1
- package/main/default/objects/pepsico_knowledge_maintain/buttons/pepsico_knowledge_authorization.button.yml +0 -33
- package/main/default/objects/pepsico_knowledge_maintain/buttons/pepsico_knowledge_reject.button.yml +0 -38
- package/main/default/objects/pepsico_knowledge_maintain/buttons/pepsico_knowledge_submission.button.yml +0 -38
- package/main/default/objects/pepsico_knowledge_maintain/fields/approval_status.field.yml +0 -23
- package/main/default/objects/pepsico_knowledge_maintain/fields/approver.field.yml +0 -13
|
@@ -31,7 +31,7 @@ var getApproverStep = function (ctx, materialApproval) { return tslib_1.__awaite
|
|
|
31
31
|
case 0: return [4, getApproverStepRule(ctx)];
|
|
32
32
|
case 1:
|
|
33
33
|
rule = _a.sent();
|
|
34
|
-
|
|
34
|
+
console.log("[getApproverStep]", rule, (0, amis_formula_1.evaluate)(rule.name, materialApproval));
|
|
35
35
|
if ((0, amis_formula_1.evaluate)(rule.name, materialApproval)) {
|
|
36
36
|
return [2, consts_1.Step.personnel_review];
|
|
37
37
|
}
|
|
@@ -82,7 +82,7 @@ var getNextStep = function (ctx, materialApproval, action) { return tslib_1.__aw
|
|
|
82
82
|
return [3, 11];
|
|
83
83
|
case 10: return [3, 11];
|
|
84
84
|
case 11:
|
|
85
|
-
|
|
85
|
+
console.log('[getNextStep]', JSON.stringify({
|
|
86
86
|
action: action,
|
|
87
87
|
nextStep: nextStep
|
|
88
88
|
}));
|
|
@@ -94,39 +94,72 @@ var getNextApprovers = function (ctx, materialApproval, nextStep) {
|
|
|
94
94
|
var approves = [];
|
|
95
95
|
switch (nextStep) {
|
|
96
96
|
case consts_1.Step.draft:
|
|
97
|
-
approves = (0, lodash_1.concat)(approves,
|
|
97
|
+
approves = (0, lodash_1.concat)(approves, {
|
|
98
|
+
userIds: [materialApproval.owner],
|
|
99
|
+
type: consts_1.ProcessApprovalType.Others
|
|
100
|
+
});
|
|
98
101
|
break;
|
|
99
102
|
case consts_1.Step.ai_review:
|
|
100
|
-
approves = (0, lodash_1.concat)(approves,
|
|
103
|
+
approves = (0, lodash_1.concat)(approves, {
|
|
104
|
+
userIds: [process.env.PEPSICO_CONTENT_APPROVAL_AI_USERID],
|
|
105
|
+
type: consts_1.ProcessApprovalType.AI
|
|
106
|
+
});
|
|
101
107
|
break;
|
|
102
108
|
case consts_1.Step.departmental_review:
|
|
103
109
|
if (materialApproval.ns_approval_status != true) {
|
|
104
|
-
approves = (0, lodash_1.concat)(approves,
|
|
110
|
+
approves = (0, lodash_1.concat)(approves, {
|
|
111
|
+
userIds: materialApproval.ns_reviewer,
|
|
112
|
+
type: consts_1.ProcessApprovalType.NS
|
|
113
|
+
});
|
|
105
114
|
}
|
|
106
115
|
if (materialApproval.legal_approval_status != true) {
|
|
107
|
-
approves = (0, lodash_1.concat)(approves,
|
|
116
|
+
approves = (0, lodash_1.concat)(approves, {
|
|
117
|
+
userIds: materialApproval.legal_reviewer,
|
|
118
|
+
type: consts_1.ProcessApprovalType.Legal
|
|
119
|
+
});
|
|
108
120
|
}
|
|
109
121
|
if (materialApproval.sra_approval_status != true) {
|
|
110
|
-
approves = (0, lodash_1.concat)(approves,
|
|
122
|
+
approves = (0, lodash_1.concat)(approves, {
|
|
123
|
+
userIds: materialApproval.sra_reviewer,
|
|
124
|
+
type: consts_1.ProcessApprovalType.SRA
|
|
125
|
+
});
|
|
111
126
|
}
|
|
112
127
|
if (materialApproval.ca_approval_status != true) {
|
|
113
|
-
approves = (0, lodash_1.concat)(approves,
|
|
128
|
+
approves = (0, lodash_1.concat)(approves, {
|
|
129
|
+
userIds: materialApproval.ca_reviewer,
|
|
130
|
+
type: consts_1.ProcessApprovalType.CA
|
|
131
|
+
});
|
|
114
132
|
}
|
|
115
133
|
if (materialApproval.child_files == 'yes' && materialApproval.kids_approval_status != true) {
|
|
116
|
-
approves = (0, lodash_1.concat)(approves,
|
|
134
|
+
approves = (0, lodash_1.concat)(approves, {
|
|
135
|
+
userIds: [materialApproval.kids_reviewer],
|
|
136
|
+
type: consts_1.ProcessApprovalType.Kids
|
|
137
|
+
});
|
|
117
138
|
}
|
|
118
139
|
break;
|
|
119
140
|
case consts_1.Step.personnel_review:
|
|
120
|
-
approves = (0, lodash_1.concat)(approves,
|
|
141
|
+
approves = (0, lodash_1.concat)(approves, {
|
|
142
|
+
userIds: materialApproval.reviewer,
|
|
143
|
+
type: consts_1.ProcessApprovalType.guding
|
|
144
|
+
});
|
|
121
145
|
if (materialApproval.child_files == 'yes') {
|
|
122
|
-
approves = (0, lodash_1.concat)(approves,
|
|
146
|
+
approves = (0, lodash_1.concat)(approves, {
|
|
147
|
+
userIds: [materialApproval.kids_reviewer],
|
|
148
|
+
type: consts_1.ProcessApprovalType.Kids
|
|
149
|
+
});
|
|
123
150
|
}
|
|
124
151
|
break;
|
|
125
152
|
case consts_1.Step.submitter_revisions:
|
|
126
|
-
approves = (0, lodash_1.concat)(approves,
|
|
153
|
+
approves = (0, lodash_1.concat)(approves, {
|
|
154
|
+
userIds: [materialApproval.owner],
|
|
155
|
+
type: consts_1.ProcessApprovalType.Others
|
|
156
|
+
});
|
|
127
157
|
break;
|
|
128
158
|
case consts_1.Step.awaiting_deployment:
|
|
129
|
-
approves = (0, lodash_1.concat)(approves,
|
|
159
|
+
approves = (0, lodash_1.concat)(approves, {
|
|
160
|
+
userIds: [materialApproval.owner],
|
|
161
|
+
type: consts_1.ProcessApprovalType.Others
|
|
162
|
+
});
|
|
130
163
|
break;
|
|
131
164
|
default:
|
|
132
165
|
break;
|
|
@@ -206,8 +239,8 @@ var sendNotifications = function (ctx, materialApproval, nextApprovers) { return
|
|
|
206
239
|
var updateUserStepStatus = function (ctx, materialApproval, _a) {
|
|
207
240
|
var approvalStatus = _a.approvalStatus;
|
|
208
241
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
209
|
-
var user, process, process_1, process_1_1, item,
|
|
210
|
-
var
|
|
242
|
+
var user, process, process_1, process_1_1, item, processOthers, processOthers_1, processOthers_1_1, item_1, e_2_1, e_3_1;
|
|
243
|
+
var e_3, _b, e_2, _c;
|
|
211
244
|
return tslib_1.__generator(this, function (_d) {
|
|
212
245
|
switch (_d.label) {
|
|
213
246
|
case 0:
|
|
@@ -227,11 +260,11 @@ var updateUserStepStatus = function (ctx, materialApproval, _a) {
|
|
|
227
260
|
process = _d.sent();
|
|
228
261
|
_d.label = 2;
|
|
229
262
|
case 2:
|
|
230
|
-
_d.trys.push([2,
|
|
263
|
+
_d.trys.push([2, 15, 16, 17]);
|
|
231
264
|
process_1 = tslib_1.__values(process), process_1_1 = process_1.next();
|
|
232
265
|
_d.label = 3;
|
|
233
266
|
case 3:
|
|
234
|
-
if (!!process_1_1.done) return [3,
|
|
267
|
+
if (!!process_1_1.done) return [3, 14];
|
|
235
268
|
item = process_1_1.value;
|
|
236
269
|
return [4, ctx.getObject("pepsico_approval_process").update(item._id, {
|
|
237
270
|
submitted: new Date(),
|
|
@@ -241,65 +274,64 @@ var updateUserStepStatus = function (ctx, materialApproval, _a) {
|
|
|
241
274
|
})];
|
|
242
275
|
case 4:
|
|
243
276
|
_d.sent();
|
|
244
|
-
|
|
277
|
+
return [4, ctx.getObject("pepsico_approval_process").find({
|
|
278
|
+
filters: [
|
|
279
|
+
["owner", "!=", user.userId],
|
|
280
|
+
["pepsico_material_approval", "=", materialApproval._id],
|
|
281
|
+
["current_step", "=", materialApproval.current_step],
|
|
282
|
+
["space", "=", materialApproval.space],
|
|
283
|
+
["approved", "=", 'progess'],
|
|
284
|
+
["type", "=", item.type]
|
|
285
|
+
],
|
|
286
|
+
sort: "modified desc"
|
|
287
|
+
})];
|
|
245
288
|
case 5:
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
case 6:
|
|
289
|
+
processOthers = _d.sent();
|
|
290
|
+
_d.label = 6;
|
|
291
|
+
case 6:
|
|
292
|
+
_d.trys.push([6, 11, 12, 13]);
|
|
293
|
+
processOthers_1 = (e_2 = void 0, tslib_1.__values(processOthers)), processOthers_1_1 = processOthers_1.next();
|
|
294
|
+
_d.label = 7;
|
|
249
295
|
case 7:
|
|
296
|
+
if (!!processOthers_1_1.done) return [3, 10];
|
|
297
|
+
item_1 = processOthers_1_1.value;
|
|
298
|
+
return [4, ctx.getObject("pepsico_approval_process").update(item_1._id, {
|
|
299
|
+
modified: new Date(),
|
|
300
|
+
modified_by: user.userId,
|
|
301
|
+
approved: ''
|
|
302
|
+
})];
|
|
303
|
+
case 8:
|
|
304
|
+
_d.sent();
|
|
305
|
+
_d.label = 9;
|
|
306
|
+
case 9:
|
|
307
|
+
processOthers_1_1 = processOthers_1.next();
|
|
308
|
+
return [3, 7];
|
|
309
|
+
case 10: return [3, 13];
|
|
310
|
+
case 11:
|
|
250
311
|
e_2_1 = _d.sent();
|
|
251
312
|
e_2 = { error: e_2_1 };
|
|
252
|
-
return [3,
|
|
253
|
-
case
|
|
313
|
+
return [3, 13];
|
|
314
|
+
case 12:
|
|
254
315
|
try {
|
|
255
|
-
if (
|
|
316
|
+
if (processOthers_1_1 && !processOthers_1_1.done && (_c = processOthers_1.return)) _c.call(processOthers_1);
|
|
256
317
|
}
|
|
257
318
|
finally { if (e_2) throw e_2.error; }
|
|
258
319
|
return [7];
|
|
259
|
-
case 9: return [4, ctx.getObject("pepsico_approval_process").find({
|
|
260
|
-
filters: [
|
|
261
|
-
["owner", "!=", user.userId],
|
|
262
|
-
["pepsico_material_approval", "=", materialApproval._id],
|
|
263
|
-
["current_step", "=", materialApproval.current_step],
|
|
264
|
-
["space", "=", materialApproval.space],
|
|
265
|
-
["approved", "=", 'progess']
|
|
266
|
-
],
|
|
267
|
-
top: 1,
|
|
268
|
-
sort: "modified desc"
|
|
269
|
-
})];
|
|
270
|
-
case 10:
|
|
271
|
-
processOthers = _d.sent();
|
|
272
|
-
_d.label = 11;
|
|
273
|
-
case 11:
|
|
274
|
-
_d.trys.push([11, 16, 17, 18]);
|
|
275
|
-
processOthers_1 = tslib_1.__values(processOthers), processOthers_1_1 = processOthers_1.next();
|
|
276
|
-
_d.label = 12;
|
|
277
|
-
case 12:
|
|
278
|
-
if (!!processOthers_1_1.done) return [3, 15];
|
|
279
|
-
item = processOthers_1_1.value;
|
|
280
|
-
return [4, ctx.getObject("pepsico_approval_process").update(item._id, {
|
|
281
|
-
modified: new Date(),
|
|
282
|
-
modified_by: user.userId,
|
|
283
|
-
approved: ''
|
|
284
|
-
})];
|
|
285
320
|
case 13:
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
case 14:
|
|
289
|
-
|
|
290
|
-
return [3, 12];
|
|
291
|
-
case 15: return [3, 18];
|
|
292
|
-
case 16:
|
|
321
|
+
process_1_1 = process_1.next();
|
|
322
|
+
return [3, 3];
|
|
323
|
+
case 14: return [3, 17];
|
|
324
|
+
case 15:
|
|
293
325
|
e_3_1 = _d.sent();
|
|
294
326
|
e_3 = { error: e_3_1 };
|
|
295
|
-
return [3,
|
|
296
|
-
case
|
|
327
|
+
return [3, 17];
|
|
328
|
+
case 16:
|
|
297
329
|
try {
|
|
298
|
-
if (
|
|
330
|
+
if (process_1_1 && !process_1_1.done && (_b = process_1.return)) _b.call(process_1);
|
|
299
331
|
}
|
|
300
332
|
finally { if (e_3) throw e_3.error; }
|
|
301
333
|
return [7];
|
|
302
|
-
case
|
|
334
|
+
case 17: return [2];
|
|
303
335
|
}
|
|
304
336
|
});
|
|
305
337
|
});
|
|
@@ -310,7 +342,7 @@ var updateApproveFieldStatus = function (ctx, recordId, approveField, approveFie
|
|
|
310
342
|
switch (_b.label) {
|
|
311
343
|
case 0:
|
|
312
344
|
if (!approveField) return [3, 2];
|
|
313
|
-
|
|
345
|
+
console.log('[updateApproveFieldStatus]', JSON.stringify({ recordId: recordId, approveField: approveField, approveFieldValue: approveFieldValue }));
|
|
314
346
|
return [4, ctx.getObject('pepsico_material_approval').update(recordId, (_a = {},
|
|
315
347
|
_a[approveField] = approveFieldValue,
|
|
316
348
|
_a))];
|
|
@@ -324,12 +356,12 @@ var updateApproveFieldStatus = function (ctx, recordId, approveField, approveFie
|
|
|
324
356
|
var changeApprovalProcess = function (ctx, materialApproval, _a) {
|
|
325
357
|
var nextStep = _a.nextStep, nextApprovers = _a.nextApprovers, description = _a.description;
|
|
326
358
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
327
|
-
var user, count, now, sUsers, _b,
|
|
328
|
-
var e_4,
|
|
329
|
-
return tslib_1.__generator(this, function (
|
|
330
|
-
switch (
|
|
359
|
+
var user, count, now, sUsers, _b, nextApprovers_2, nextApprovers_2_1, nextApprover, _c, _d, userId, spaceUsers, e_4_1, e_5_1;
|
|
360
|
+
var e_5, _e, e_4, _f;
|
|
361
|
+
return tslib_1.__generator(this, function (_g) {
|
|
362
|
+
switch (_g.label) {
|
|
331
363
|
case 0:
|
|
332
|
-
|
|
364
|
+
console.log("[changeApprovalProcess]", nextStep, nextApprovers, description);
|
|
333
365
|
user = ctx.meta.user;
|
|
334
366
|
if (!(!materialApproval.current_step || materialApproval.current_step == consts_1.Step.draft)) return [3, 3];
|
|
335
367
|
return [4, ctx.getObject("pepsico_approval_process").count({
|
|
@@ -339,7 +371,7 @@ var changeApprovalProcess = function (ctx, materialApproval, _a) {
|
|
|
339
371
|
]
|
|
340
372
|
})];
|
|
341
373
|
case 1:
|
|
342
|
-
count =
|
|
374
|
+
count = _g.sent();
|
|
343
375
|
if (!(count == 0)) return [3, 3];
|
|
344
376
|
now = new Date();
|
|
345
377
|
return [4, ctx.getObject('pepsico_approval_process').insert({
|
|
@@ -357,38 +389,44 @@ var changeApprovalProcess = function (ctx, materialApproval, _a) {
|
|
|
357
389
|
approved: 'submit'
|
|
358
390
|
})];
|
|
359
391
|
case 2:
|
|
360
|
-
|
|
361
|
-
|
|
392
|
+
_g.sent();
|
|
393
|
+
_g.label = 3;
|
|
362
394
|
case 3:
|
|
363
395
|
sUsers = null;
|
|
364
|
-
if (!(nextApprovers && nextApprovers.length > 0)) return [3, 5];
|
|
365
|
-
return [4, ctx.getObject('space_users').find({ filters: [['user', '=', nextApprovers], ['space', '=', materialApproval.space]] })];
|
|
366
|
-
case 4:
|
|
367
|
-
sUsers = _d.sent();
|
|
368
|
-
_d.label = 5;
|
|
369
|
-
case 5:
|
|
370
396
|
_b = nextStep;
|
|
371
397
|
switch (_b) {
|
|
372
|
-
case consts_1.Step.draft: return [3,
|
|
373
|
-
case consts_1.Step.ai_review: return [3,
|
|
374
|
-
case consts_1.Step.departmental_review: return [3,
|
|
375
|
-
case consts_1.Step.personnel_review: return [3,
|
|
376
|
-
case consts_1.Step.submitter_revisions: return [3,
|
|
377
|
-
case consts_1.Step.awaiting_deployment: return [3,
|
|
378
|
-
case consts_1.Step.conclusion: return [3,
|
|
398
|
+
case consts_1.Step.draft: return [3, 4];
|
|
399
|
+
case consts_1.Step.ai_review: return [3, 4];
|
|
400
|
+
case consts_1.Step.departmental_review: return [3, 4];
|
|
401
|
+
case consts_1.Step.personnel_review: return [3, 4];
|
|
402
|
+
case consts_1.Step.submitter_revisions: return [3, 4];
|
|
403
|
+
case consts_1.Step.awaiting_deployment: return [3, 4];
|
|
404
|
+
case consts_1.Step.conclusion: return [3, 19];
|
|
379
405
|
}
|
|
380
|
-
return [3,
|
|
406
|
+
return [3, 21];
|
|
407
|
+
case 4:
|
|
408
|
+
_g.trys.push([4, 16, 17, 18]);
|
|
409
|
+
nextApprovers_2 = tslib_1.__values(nextApprovers), nextApprovers_2_1 = nextApprovers_2.next();
|
|
410
|
+
_g.label = 5;
|
|
411
|
+
case 5:
|
|
412
|
+
if (!!nextApprovers_2_1.done) return [3, 15];
|
|
413
|
+
nextApprover = nextApprovers_2_1.value;
|
|
414
|
+
_g.label = 6;
|
|
381
415
|
case 6:
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
416
|
+
_g.trys.push([6, 12, 13, 14]);
|
|
417
|
+
_c = (e_4 = void 0, tslib_1.__values(nextApprover.userIds)), _d = _c.next();
|
|
418
|
+
_g.label = 7;
|
|
385
419
|
case 7:
|
|
386
|
-
if (!!
|
|
387
|
-
|
|
420
|
+
if (!!_d.done) return [3, 11];
|
|
421
|
+
userId = _d.value;
|
|
422
|
+
return [4, ctx.getObject('space_users').directFind({ filters: [['user', '=', userId], ['space', '=', materialApproval.space]] })];
|
|
423
|
+
case 8:
|
|
424
|
+
spaceUsers = _g.sent();
|
|
388
425
|
return [4, ctx.getObject('pepsico_approval_process').insert({
|
|
389
426
|
pepsico_material_approval: materialApproval._id,
|
|
390
|
-
owner:
|
|
391
|
-
|
|
427
|
+
owner: userId,
|
|
428
|
+
type: nextApprover.type,
|
|
429
|
+
review_department: spaceUsers.length > 0 ? spaceUsers[0].organization : null,
|
|
392
430
|
current_step: nextStep,
|
|
393
431
|
approved: "progess",
|
|
394
432
|
space: materialApproval.space,
|
|
@@ -398,25 +436,39 @@ var changeApprovalProcess = function (ctx, materialApproval, _a) {
|
|
|
398
436
|
modified_by: user.userId,
|
|
399
437
|
name: description
|
|
400
438
|
})];
|
|
401
|
-
case 8:
|
|
402
|
-
_d.sent();
|
|
403
|
-
_d.label = 9;
|
|
404
439
|
case 9:
|
|
405
|
-
|
|
440
|
+
_g.sent();
|
|
441
|
+
_g.label = 10;
|
|
442
|
+
case 10:
|
|
443
|
+
_d = _c.next();
|
|
406
444
|
return [3, 7];
|
|
407
|
-
case
|
|
408
|
-
case 11:
|
|
409
|
-
e_4_1 = _d.sent();
|
|
410
|
-
e_4 = { error: e_4_1 };
|
|
411
|
-
return [3, 13];
|
|
445
|
+
case 11: return [3, 14];
|
|
412
446
|
case 12:
|
|
447
|
+
e_4_1 = _g.sent();
|
|
448
|
+
e_4 = { error: e_4_1 };
|
|
449
|
+
return [3, 14];
|
|
450
|
+
case 13:
|
|
413
451
|
try {
|
|
414
|
-
if (
|
|
452
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
415
453
|
}
|
|
416
454
|
finally { if (e_4) throw e_4.error; }
|
|
417
455
|
return [7];
|
|
418
|
-
case
|
|
419
|
-
|
|
456
|
+
case 14:
|
|
457
|
+
nextApprovers_2_1 = nextApprovers_2.next();
|
|
458
|
+
return [3, 5];
|
|
459
|
+
case 15: return [3, 18];
|
|
460
|
+
case 16:
|
|
461
|
+
e_5_1 = _g.sent();
|
|
462
|
+
e_5 = { error: e_5_1 };
|
|
463
|
+
return [3, 18];
|
|
464
|
+
case 17:
|
|
465
|
+
try {
|
|
466
|
+
if (nextApprovers_2_1 && !nextApprovers_2_1.done && (_e = nextApprovers_2.return)) _e.call(nextApprovers_2);
|
|
467
|
+
}
|
|
468
|
+
finally { if (e_5) throw e_5.error; }
|
|
469
|
+
return [7];
|
|
470
|
+
case 18: return [3, 22];
|
|
471
|
+
case 19: return [4, ctx.getObject('pepsico_approval_process').insert({
|
|
420
472
|
pepsico_material_approval: materialApproval._id,
|
|
421
473
|
current_step: consts_1.Step.conclusion,
|
|
422
474
|
space: materialApproval.space,
|
|
@@ -426,11 +478,11 @@ var changeApprovalProcess = function (ctx, materialApproval, _a) {
|
|
|
426
478
|
modified_by: user.userId,
|
|
427
479
|
name: description
|
|
428
480
|
})];
|
|
429
|
-
case
|
|
430
|
-
|
|
431
|
-
return [3,
|
|
432
|
-
case
|
|
433
|
-
case
|
|
481
|
+
case 20:
|
|
482
|
+
_g.sent();
|
|
483
|
+
return [3, 22];
|
|
484
|
+
case 21: return [3, 22];
|
|
485
|
+
case 22: return [2];
|
|
434
486
|
}
|
|
435
487
|
});
|
|
436
488
|
});
|
|
@@ -459,33 +511,38 @@ var setPersonView = function (ctx, materialApproval) { return tslib_1.__awaiter(
|
|
|
459
511
|
});
|
|
460
512
|
}); };
|
|
461
513
|
var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
462
|
-
var user, record, nextStep, nextApprovers, error_1;
|
|
463
|
-
|
|
464
|
-
|
|
514
|
+
var user, record, nextStep, nextApprovers, nextApproversUserIds_1, nextApprovers_3, nextApprovers_3_1, nextApprover, e_6_1, error_1;
|
|
515
|
+
var e_6, _a;
|
|
516
|
+
return tslib_1.__generator(this, function (_b) {
|
|
517
|
+
switch (_b.label) {
|
|
465
518
|
case 0:
|
|
466
|
-
|
|
519
|
+
_b.trys.push([0, 40, , 41]);
|
|
467
520
|
user = ctx.meta.user;
|
|
468
521
|
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
469
522
|
case 1:
|
|
470
|
-
record =
|
|
471
|
-
|
|
523
|
+
record = _b.sent();
|
|
524
|
+
console.log('[advanceApproval]', record.current_step, record.person_pending_approve, user.userId);
|
|
472
525
|
if (record.current_step != consts_1.Step.draft && !(0, lodash_1.includes)(record.person_pending_approve, user.userId)) {
|
|
473
526
|
return [2, {}];
|
|
474
527
|
}
|
|
475
528
|
return [4, canSubmit(record)];
|
|
476
529
|
case 2:
|
|
477
|
-
|
|
530
|
+
_b.sent();
|
|
478
531
|
return [4, getNextStep(ctx, record, currentStepApprovalStatus)];
|
|
479
532
|
case 3:
|
|
480
|
-
nextStep =
|
|
533
|
+
nextStep = _b.sent();
|
|
481
534
|
return [4, getNextApprovers(ctx, record, nextStep)];
|
|
482
535
|
case 4:
|
|
483
|
-
nextApprovers =
|
|
484
|
-
|
|
536
|
+
nextApprovers = _b.sent();
|
|
537
|
+
console.log("[advanceApproval] currentStepApprovalStatus:", currentStepApprovalStatus, " nextStep:", nextStep, " nextApprovers:", nextApprovers);
|
|
538
|
+
nextApproversUserIds_1 = [];
|
|
539
|
+
(0, lodash_1.map)(nextApprovers, function (item) {
|
|
540
|
+
nextApproversUserIds_1 = (0, lodash_1.concat)(nextApproversUserIds_1, item.userIds);
|
|
541
|
+
});
|
|
485
542
|
return [4, ctx.getObject('pepsico_material_approval').update(recordId, {
|
|
486
543
|
current_step: nextStep,
|
|
487
544
|
review_status: getReviewStatus(nextStep),
|
|
488
|
-
person_pending_approve:
|
|
545
|
+
person_pending_approve: nextApproversUserIds_1,
|
|
489
546
|
$push: {
|
|
490
547
|
person_approved: {
|
|
491
548
|
$each: record.person_pending_approve
|
|
@@ -493,53 +550,154 @@ var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { retu
|
|
|
493
550
|
}
|
|
494
551
|
})];
|
|
495
552
|
case 5:
|
|
496
|
-
|
|
553
|
+
_b.sent();
|
|
497
554
|
return [4, changeApprovalProcess(ctx, record, {
|
|
498
555
|
nextStep: nextStep,
|
|
499
556
|
nextApprovers: nextApprovers,
|
|
500
557
|
description: ""
|
|
501
558
|
})];
|
|
502
559
|
case 6:
|
|
503
|
-
|
|
560
|
+
_b.sent();
|
|
504
561
|
if (nextStep === consts_1.Step.ai_review) {
|
|
505
562
|
}
|
|
506
|
-
|
|
507
|
-
return [4, setPersonView(ctx, record)];
|
|
563
|
+
_b.label = 7;
|
|
508
564
|
case 7:
|
|
509
|
-
|
|
510
|
-
|
|
565
|
+
_b.trys.push([7, 28, 29, 30]);
|
|
566
|
+
nextApprovers_3 = tslib_1.__values(nextApprovers), nextApprovers_3_1 = nextApprovers_3.next();
|
|
567
|
+
_b.label = 8;
|
|
511
568
|
case 8:
|
|
512
|
-
if (
|
|
513
|
-
|
|
569
|
+
if (!!nextApprovers_3_1.done) return [3, 27];
|
|
570
|
+
nextApprover = nextApprovers_3_1.value;
|
|
571
|
+
if (!(nextApprover.type === consts_1.ProcessApprovalType.CA)) return [3, 11];
|
|
572
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
573
|
+
ca_approval_status: ''
|
|
574
|
+
})];
|
|
514
575
|
case 9:
|
|
515
|
-
|
|
516
|
-
|
|
576
|
+
_b.sent();
|
|
577
|
+
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['ca_approval_status', '=', false]], {
|
|
578
|
+
ca_approval_status: ''
|
|
579
|
+
})];
|
|
517
580
|
case 10:
|
|
518
|
-
|
|
519
|
-
|
|
581
|
+
_b.sent();
|
|
582
|
+
_b.label = 11;
|
|
520
583
|
case 11:
|
|
521
|
-
|
|
522
|
-
return [4,
|
|
584
|
+
if (!(nextApprover.type === consts_1.ProcessApprovalType.Legal)) return [3, 14];
|
|
585
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
586
|
+
legal_approval_status: ''
|
|
587
|
+
})];
|
|
523
588
|
case 12:
|
|
524
|
-
|
|
525
|
-
|
|
589
|
+
_b.sent();
|
|
590
|
+
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['legal_approval_status', '=', false]], {
|
|
591
|
+
legal_approval_status: ''
|
|
592
|
+
})];
|
|
526
593
|
case 13:
|
|
527
|
-
|
|
528
|
-
|
|
594
|
+
_b.sent();
|
|
595
|
+
_b.label = 14;
|
|
529
596
|
case 14:
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
597
|
+
if (!(nextApprover.type === consts_1.ProcessApprovalType.NS)) return [3, 17];
|
|
598
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
599
|
+
ns_approval_status: ''
|
|
600
|
+
})];
|
|
601
|
+
case 15:
|
|
602
|
+
_b.sent();
|
|
603
|
+
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['ns_approval_status', '=', false]], {
|
|
604
|
+
ns_approval_status: ''
|
|
605
|
+
})];
|
|
533
606
|
case 16:
|
|
534
|
-
|
|
535
|
-
|
|
607
|
+
_b.sent();
|
|
608
|
+
_b.label = 17;
|
|
536
609
|
case 17:
|
|
537
|
-
|
|
610
|
+
if (!(nextApprover.type === consts_1.ProcessApprovalType.SRA)) return [3, 20];
|
|
611
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
612
|
+
sra_approval_status: ''
|
|
613
|
+
})];
|
|
614
|
+
case 18:
|
|
615
|
+
_b.sent();
|
|
616
|
+
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['sra_approval_status', '=', false]], {
|
|
617
|
+
sra_approval_status: ''
|
|
618
|
+
})];
|
|
619
|
+
case 19:
|
|
620
|
+
_b.sent();
|
|
621
|
+
_b.label = 20;
|
|
622
|
+
case 20:
|
|
623
|
+
if (!(nextApprover.type === consts_1.ProcessApprovalType.guding)) return [3, 23];
|
|
624
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
625
|
+
approval_status: ''
|
|
626
|
+
})];
|
|
627
|
+
case 21:
|
|
628
|
+
_b.sent();
|
|
629
|
+
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['approval_status', '=', false]], {
|
|
630
|
+
approval_status: ''
|
|
631
|
+
})];
|
|
632
|
+
case 22:
|
|
633
|
+
_b.sent();
|
|
634
|
+
_b.label = 23;
|
|
635
|
+
case 23:
|
|
636
|
+
if (!(nextApprover.type === consts_1.ProcessApprovalType.Kids)) return [3, 26];
|
|
637
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
638
|
+
kids_approval_status: ''
|
|
639
|
+
})];
|
|
640
|
+
case 24:
|
|
641
|
+
_b.sent();
|
|
642
|
+
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['kids_approval_status', '=', false]], {
|
|
643
|
+
kids_approval_status: ''
|
|
644
|
+
})];
|
|
645
|
+
case 25:
|
|
646
|
+
_b.sent();
|
|
647
|
+
_b.label = 26;
|
|
648
|
+
case 26:
|
|
649
|
+
nextApprovers_3_1 = nextApprovers_3.next();
|
|
650
|
+
return [3, 8];
|
|
651
|
+
case 27: return [3, 30];
|
|
652
|
+
case 28:
|
|
653
|
+
e_6_1 = _b.sent();
|
|
654
|
+
e_6 = { error: e_6_1 };
|
|
655
|
+
return [3, 30];
|
|
656
|
+
case 29:
|
|
657
|
+
try {
|
|
658
|
+
if (nextApprovers_3_1 && !nextApprovers_3_1.done && (_a = nextApprovers_3.return)) _a.call(nextApprovers_3);
|
|
659
|
+
}
|
|
660
|
+
finally { if (e_6) throw e_6.error; }
|
|
661
|
+
return [7];
|
|
662
|
+
case 30:
|
|
663
|
+
if (!(nextStep === consts_1.Step.departmental_review || nextStep === consts_1.Step.personnel_review)) return [3, 32];
|
|
664
|
+
return [4, setPersonView(ctx, record)];
|
|
665
|
+
case 31:
|
|
666
|
+
_b.sent();
|
|
667
|
+
_b.label = 32;
|
|
668
|
+
case 32:
|
|
669
|
+
if (!(record.current_step === consts_1.Step.departmental_review || record.current_step === consts_1.Step.personnel_review)) return [3, 34];
|
|
670
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
671
|
+
materials_remove_share_link_from_onedrive_status: 'pending'
|
|
672
|
+
})];
|
|
673
|
+
case 33:
|
|
674
|
+
_b.sent();
|
|
675
|
+
_b.label = 34;
|
|
676
|
+
case 34:
|
|
677
|
+
if (!(nextStep === consts_1.Step.awaiting_deployment)) return [3, 36];
|
|
678
|
+
return [4, pendingDeployment(ctx, recordId)];
|
|
679
|
+
case 35:
|
|
680
|
+
_b.sent();
|
|
681
|
+
_b.label = 36;
|
|
682
|
+
case 36:
|
|
683
|
+
if (!(nextStep === consts_1.Step.awaiting_deployment)) return [3, 38];
|
|
684
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
685
|
+
materials_download_from_onedrive_status: 'pending'
|
|
686
|
+
})];
|
|
687
|
+
case 37:
|
|
688
|
+
_b.sent();
|
|
689
|
+
_b.label = 38;
|
|
690
|
+
case 38: return [4, sendNotifications(ctx, record, nextApproversUserIds_1)];
|
|
691
|
+
case 39:
|
|
692
|
+
_b.sent();
|
|
693
|
+
return [2, {}];
|
|
694
|
+
case 40:
|
|
695
|
+
error_1 = _b.sent();
|
|
538
696
|
return [2, {
|
|
539
697
|
msg: error_1.message,
|
|
540
698
|
status: 500
|
|
541
699
|
}];
|
|
542
|
-
case
|
|
700
|
+
case 41: return [2];
|
|
543
701
|
}
|
|
544
702
|
});
|
|
545
703
|
}); };
|
|
@@ -717,7 +875,7 @@ var rejectContent = function (ctx, recordId, _a) {
|
|
|
717
875
|
case 2:
|
|
718
876
|
approvalNew = _b.sent();
|
|
719
877
|
currentStepApprovalStatus = consts_1.ApprovalStatus.rejected;
|
|
720
|
-
return [4, updateUserStepStatus(ctx, approvalNew, { approvalStatus: consts_1.ApprovalStatus.
|
|
878
|
+
return [4, updateUserStepStatus(ctx, approvalNew, { approvalStatus: consts_1.ApprovalStatus.rejected })];
|
|
721
879
|
case 3:
|
|
722
880
|
_b.sent();
|
|
723
881
|
if (approvalNew.current_step === consts_1.Step.departmental_review) {
|
|
@@ -795,6 +953,7 @@ var submitContent = function (ctx, recordId, currentStepApprovalStatus) {
|
|
|
795
953
|
_a.sent();
|
|
796
954
|
_a.label = 4;
|
|
797
955
|
case 4:
|
|
956
|
+
console.log("[submitContent] \u6B65\u9AA4\u63D0\u4EA4\uFF0C\u53C2\u6570\u4E3A \u5BA1\u6279\u5355: ".concat(recordId, " \u5F53\u524D\u6B65\u9AA4: ").concat(approvalNew.current_step, " \u5BA1\u6279\u7ED3\u679C\u4E3A: ").concat(currentStepApprovalStatus));
|
|
798
957
|
if (!(approvalNew.current_step === consts_1.Step.ai_review && currentStepApprovalStatus === consts_1.ApprovalStatus.approved
|
|
799
958
|
&& approvalNew.materials_uploaded_to_onedrive_status != 'completed')) return [3, 9];
|
|
800
959
|
return [4, (0, material_1.getPendingUploadsToOneDriveMaterials)(ctx, recordId)];
|