vcomply-workflow-engine 7.2.0 → 7.2.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.
@@ -32662,6 +32662,29 @@ class WorkflowComplianceComponent {
32662
32662
  });
32663
32663
  return data;
32664
32664
  }
32665
+ normalizeResponsibilityCenterIdList(raw) {
32666
+ if (raw === undefined || raw === null || raw === '') {
32667
+ return [];
32668
+ }
32669
+ if (Array.isArray(raw)) {
32670
+ return raw.filter((x) => x !== '' && x != null);
32671
+ }
32672
+ return [raw];
32673
+ }
32674
+ setRcListFromWorkflowIdentifiers(list, ids) {
32675
+ if (!ids?.length || !list?.length) {
32676
+ return [];
32677
+ }
32678
+ const keys = ['item_id', 'rcid', 'rc_id', 'pid', 'rc_pid'];
32679
+ const data = [];
32680
+ ids.forEach((id) => {
32681
+ const index = list.findIndex((row) => keys.some((k) => row[k] != null && row[k] == id));
32682
+ if (index !== -1) {
32683
+ data.push(list[index]);
32684
+ }
32685
+ });
32686
+ return data;
32687
+ }
32665
32688
  returnIds(list, key) {
32666
32689
  return list
32667
32690
  ?.map((ele) => {
@@ -35173,6 +35196,10 @@ class WorkflowComplianceComponent {
35173
35196
  checkedMoreOptions.push('CHECKPOINTS_NEW');
35174
35197
  this.moreOptions.CHECKPOINTS_NEW = true;
35175
35198
  }
35199
+ if (this.responsibilityForm?.assessment?.assessment_id) {
35200
+ checkedMoreOptions.push('ASSESSMENT');
35201
+ this.moreOptions.ASSESSMENT = true;
35202
+ }
35176
35203
  //if custom fields are present in the responsibility form and custom fields are present in the custom fields list
35177
35204
  if (this.responsibilityForm.customFields?.length > 0 && this.customFields?.length > 0) {
35178
35205
  checkedMoreOptions.push('CUSTOM_FIELDS');
@@ -35555,12 +35582,11 @@ class WorkflowComplianceComponent {
35555
35582
  description: res?.notes,
35556
35583
  objective: res?.objective,
35557
35584
  rc: (() => {
35558
- const rcId = res.responsibilityCenter?.id;
35559
- // After normalisation RCs should always have item_id populated
35560
- const rcResult = this.setList(this.responsibilityCentersList, rcId ? [rcId] : [], 'item_id');
35561
- return rcResult;
35585
+ const idList = this.normalizeResponsibilityCenterIdList(res?.responsibilityCenter?.id);
35586
+ return this.setRcListFromWorkflowIdentifiers(this.responsibilityCentersList, idList);
35562
35587
  })(),
35563
- responsibilityCenterType: res.responsibilityCenter?.type === 'all' ? 1 : 0,
35588
+ // Align with ResponsibilityService.buildResponsibilityPayload: form 1 -> 'any', 0 -> 'all'
35589
+ responsibilityCenterType: res?.responsibilityCenter?.type === 'all' ? 0 : 1,
35564
35590
  category: res?.program_cat_ids?.length
35565
35591
  ? res?.category_ids_array.filter((ele) => !res.program_cat_ids?.includes(ele))
35566
35592
  : res?.category_ids_array,
@@ -35611,6 +35637,11 @@ class WorkflowComplianceComponent {
35611
35637
  riskClass: res?.riskClass,
35612
35638
  selectedGRCObjects: res?.meta?.linkedEntities?.grcObjects ?? [],
35613
35639
  customFields: this.populateCustomFields(res) ?? [],
35640
+ assessment: {
35641
+ category_id: '',
35642
+ assessment_id: '',
35643
+ },
35644
+ new_checkpoints: {},
35614
35645
  };
35615
35646
  this.customFields = this.customFields?.filter((ele) => !res?.customField?.some((field) => field.id === ele.id));
35616
35647
  const GRC_OBJECTS = res?.meta?.linkedEntities?.grcObjects ?? [];
@@ -35619,6 +35650,7 @@ class WorkflowComplianceComponent {
35619
35650
  }
35620
35651
  this.populateFrequencyDetails(res.frequency);
35621
35652
  this.populateProgramDetails(res);
35653
+ this.populateLinkedAssessmentFromMeta(res);
35622
35654
  this.getEditMoreOptions(res);
35623
35655
  this.populateformatDetails(res);
35624
35656
  }
@@ -35661,33 +35693,61 @@ class WorkflowComplianceComponent {
35661
35693
  this.onItemsSelectedChange(this.selectedPrograms);
35662
35694
  }
35663
35695
  }
35696
+ populateLinkedAssessmentFromMeta(res) {
35697
+ const linkedAssessment = res?.meta?.linkedEntities?.assessment;
35698
+ if (!linkedAssessment || typeof linkedAssessment !== 'object') {
35699
+ return;
35700
+ }
35701
+ const assessmentId = String(linkedAssessment.aid ?? '').trim();
35702
+ if (!assessmentId) {
35703
+ return;
35704
+ }
35705
+ this.responsibilityService.getAssessmentDetailsByID(assessmentId).subscribe({
35706
+ next: (assessmentRes) => {
35707
+ if (!assessmentRes?.length) {
35708
+ return;
35709
+ }
35710
+ const categoryId = linkedAssessment.category_id ?? assessmentRes[0]?.category?.[0]?._id;
35711
+ if (!categoryId) {
35712
+ return;
35713
+ }
35714
+ this.setAssessmentData(assessmentRes, {
35715
+ assessment_id: assessmentId,
35716
+ category_id: categoryId,
35717
+ }, 'assessment');
35718
+ this.getEditMoreOptions(res);
35719
+ },
35720
+ error: () => {
35721
+ return;
35722
+ },
35723
+ });
35724
+ }
35664
35725
  populateFrequencyDetails(frequency) {
35665
- const getPattern = this.frequencyService.createFrequencyPattern(frequency);
35726
+ const pattern = this.frequencyService.createFrequencyPattern(frequency);
35666
35727
  const lifecycleDetails = this.frequencyService.getLifecyclePattern(frequency);
35667
- frequency.pattern = getPattern;
35728
+ frequency.pattern = pattern;
35668
35729
  frequency.lifecycle_details = lifecycleDetails.pattern;
35669
35730
  frequency.start_of_day_utc = lifecycleDetails.startFrom;
35670
35731
  if (this.responsibilityDetails?.onCompletionResponsibility) {
35671
35732
  this.responsibilityDetails.onCompletionResponsibility = {
35672
35733
  ...this.responsibilityDetails?.onCompletionResponsibility,
35673
- ...frequency.onComplete
35734
+ ...frequency.onComplete,
35674
35735
  };
35675
35736
  }
35676
35737
  this.frequencyDataPopulation(frequency);
35677
35738
  this.getFrequencyPlaceholder(frequency);
35678
35739
  }
35679
35740
  mapLinkedPrograms(programs) {
35680
- // Build a lookup for fast id → object mapping
35681
35741
  const programById = new Map();
35682
- for (const program of programs.data) {
35742
+ (programs?.data ?? []).forEach((program) => {
35683
35743
  programById.set(program.id, program);
35684
- }
35685
- // Map each linked ID group to full program objects
35744
+ });
35686
35745
  const mapped = {};
35687
- for (const originId in programs.linked) {
35688
- mapped[originId] = programs.linked[originId]
35689
- .map(id => programById.get(id))
35690
- .filter(Boolean); // remove undefined if id not found
35746
+ const linked = programs?.linked ?? {};
35747
+ for (const originId in linked) {
35748
+ mapped[originId] = (linked[originId] ?? [])
35749
+ .map((id) => programById.get(id))
35750
+ .filter(Boolean);
35691
35751
  }
35692
35752
  return mapped;
35693
35753
  }