@qbs-origin/origin-form 0.8.0 → 0.8.2

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.
@@ -2664,6 +2664,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
2664
2664
  }]
2665
2665
  }], ctorParameters: () => [{ type: TranslatePipe }] });
2666
2666
 
2667
+ class NotificationConfig {
2668
+ constructor() {
2669
+ this.enabled = false;
2670
+ this.titleTemplate = 'Status update: {statusName}';
2671
+ this.messageTemplate = 'Your application status has been updated to: {statusName}';
2672
+ }
2673
+ }
2674
+ class InheritedField {
2675
+ constructor() {
2676
+ this.id = '';
2677
+ this.fieldName = '';
2678
+ }
2679
+ }
2680
+ class ParentChildConfig {
2681
+ constructor() {
2682
+ this.parentApplicationUuid = null;
2683
+ this.inheritedFields = [];
2684
+ this.notificationConfig = new NotificationConfig();
2685
+ }
2686
+ }
2667
2687
  class FormModel {
2668
2688
  }
2669
2689
  class AppDataControl {
@@ -2689,7 +2709,7 @@ class AppDataStep {
2689
2709
  }
2690
2710
  }
2691
2711
  class AppDataFill {
2692
- constructor(appDataId = '', configurationId = '', currentStepId = '', statusId = '', language = '', flux = [], offerId = '', isSubmitted = false) {
2712
+ constructor(appDataId = '', configurationId = '', currentStepId = '', statusId = '', language = '', flux = [], offerId = '', isSubmitted = false, parentAppDataUuid = '') {
2693
2713
  this.metadata = {
2694
2714
  appDataId: appDataId || '',
2695
2715
  configurationId: configurationId || '',
@@ -2698,6 +2718,7 @@ class AppDataFill {
2698
2718
  language: language || '',
2699
2719
  offerId: offerId || '',
2700
2720
  isSubmitted: isSubmitted || false,
2721
+ parentAppDataUuid: parentAppDataUuid || '',
2701
2722
  };
2702
2723
  this.flux = flux || [];
2703
2724
  }
@@ -2710,6 +2731,7 @@ class AppData {
2710
2731
  this.initFlowValues = data.initFlowValues;
2711
2732
  this.withNextStep = data.withNextStep;
2712
2733
  this.blockPreviousStep = data.blockPreviousStep;
2734
+ this.parentAppDataUuid = data.parentAppDataUuid;
2713
2735
  if (!data.env) {
2714
2736
  this.env = 'Config';
2715
2737
  }
@@ -3109,6 +3131,7 @@ const initialFormulareState = {
3109
3131
  applicationTypeId: 0,
3110
3132
  columnMappings: [],
3111
3133
  },
3134
+ parentChildConfig: undefined,
3112
3135
  },
3113
3136
  selectedTab: 'Date generale',
3114
3137
  canGetFromProd: false,
@@ -3230,14 +3253,16 @@ var ApiMethodType;
3230
3253
  ApiMethodType[ApiMethodType["Validation"] = 2] = "Validation";
3231
3254
  })(ApiMethodType || (ApiMethodType = {}));
3232
3255
  class StatusModel {
3233
- constructor(id, denumire, ordine, final, isActive, actions) {
3256
+ constructor(id, denumire, ordine, final, isActive, actions, childApplicationUuids = []) {
3234
3257
  this.actions = [];
3258
+ this.childApplicationUuids = [];
3235
3259
  this.id = id;
3236
3260
  this.name = denumire;
3237
3261
  this.order = ordine;
3238
3262
  this.final = final;
3239
3263
  this.isActive = isActive;
3240
3264
  this.actions = actions;
3265
+ this.childApplicationUuids = childApplicationUuids || [];
3241
3266
  }
3242
3267
  }
3243
3268
  class StatusAction {
@@ -6483,6 +6508,22 @@ class ActionStepHandler {
6483
6508
  }
6484
6509
  return visibleSteps;
6485
6510
  }
6511
+ /**
6512
+ * Gets action steps that appear before the first visible step in the flux.
6513
+ * These need to be executed on form initialization.
6514
+ */
6515
+ getActionStepsBeforeFirstVisibleStep(allSteps) {
6516
+ const actionSteps = [];
6517
+ for (const step of allSteps) {
6518
+ if (this.isActionStep(step)) {
6519
+ actionSteps.push(step);
6520
+ }
6521
+ else {
6522
+ break;
6523
+ }
6524
+ }
6525
+ return actionSteps;
6526
+ }
6486
6527
  /**
6487
6528
  * Gets action steps that should be executed when moving to the next step
6488
6529
  */
@@ -7138,6 +7179,8 @@ class CollectorFormComponent {
7138
7179
  }
7139
7180
  if (this.appModel) {
7140
7181
  await this.initAsync();
7182
+ // Execute any action/status steps that appear before the first visible step
7183
+ await this.executeLeadingActionSteps();
7141
7184
  }
7142
7185
  }
7143
7186
  async ngOnChanges(changes) {
@@ -7176,6 +7219,8 @@ class CollectorFormComponent {
7176
7219
  }
7177
7220
  }
7178
7221
  await this.initAsync();
7222
+ // Execute any action/status steps that appear before the first visible step
7223
+ await this.executeLeadingActionSteps();
7179
7224
  }
7180
7225
  catch (error) {
7181
7226
  }
@@ -7243,7 +7288,8 @@ class CollectorFormComponent {
7243
7288
  this.formlyPresentationFields = [];
7244
7289
  this.model = {};
7245
7290
  this.form = new FormGroup({});
7246
- if (this.fillData) {
7291
+ // Populate control IDs with values if fillData or initFlowValues exist
7292
+ if (this.fillData || this.initFlowValues) {
7247
7293
  this.populateControlIdsWithValueDictionary();
7248
7294
  }
7249
7295
  // Initialize model with default values if no fillData
@@ -7252,7 +7298,6 @@ class CollectorFormComponent {
7252
7298
  }
7253
7299
  else {
7254
7300
  this.populateModelWithFillData(this.fillData);
7255
- this.populateControlIdsWithValueDictionary();
7256
7301
  }
7257
7302
  this.form.patchValue(this.model);
7258
7303
  await this.buildFormlyConfigAsync();
@@ -7318,33 +7363,49 @@ class CollectorFormComponent {
7318
7363
  }
7319
7364
  populateControlIdsWithValueDictionary() {
7320
7365
  var currentLanguageId = this.getCurrentLanguageId();
7321
- const controlIdsWithValues = this.fillData.flux
7322
- .flatMap((step) => step.sections.flatMap((section) => section.controls
7323
- .filter((control) => control.controlId && control.fillValue)
7324
- .map((control) => ({
7325
- controlId: control.controlId,
7326
- fillValue: control.fillValue,
7327
- fillValueId: control.fillValueId,
7328
- }))))
7329
- .reduce((dictionary, { controlId, fillValue, fillValueId }) => {
7330
- if (fillValueId) {
7331
- for (const [key, dict] of this.dictionaryMap.entries()) {
7332
- const value = dict.values?.find((v) => v.id == fillValueId);
7333
- if (value) {
7334
- const translation = value.valueTranslations.find((t) => t.languageId == currentLanguageId);
7335
- if (translation) {
7336
- dictionary[controlId] = translation.value;
7337
- break;
7366
+ // Build dictionary from fillData.flux if available, otherwise start empty
7367
+ const controlIdsWithValues = this.fillData?.flux
7368
+ ? this.fillData.flux
7369
+ .flatMap((step) => step.sections.flatMap((section) => section.controls
7370
+ .filter((control) => control.controlId && control.fillValue)
7371
+ .map((control) => ({
7372
+ controlId: control.controlId,
7373
+ fillValue: control.fillValue,
7374
+ fillValueId: control.fillValueId,
7375
+ }))))
7376
+ .reduce((dictionary, { controlId, fillValue, fillValueId }) => {
7377
+ if (fillValueId) {
7378
+ for (const [key, dict] of this.dictionaryMap.entries()) {
7379
+ const value = dict.values?.find((v) => v.id == fillValueId);
7380
+ if (value) {
7381
+ const translation = value.valueTranslations.find((t) => t.languageId == currentLanguageId);
7382
+ if (translation) {
7383
+ dictionary[controlId] = translation.value;
7384
+ break;
7385
+ }
7338
7386
  }
7339
7387
  }
7340
7388
  }
7389
+ else {
7390
+ dictionary[controlId] = fillValue;
7391
+ }
7392
+ return dictionary;
7393
+ }, {})
7394
+ : {};
7395
+ // Get initFlowValues from fillData or from direct input (this.initFlowValues)
7396
+ let initFlowValues = this.fillData?.initFlowValues;
7397
+ // If not in fillData, try to parse from direct initFlowValues input
7398
+ if (!initFlowValues && this.initFlowValues) {
7399
+ try {
7400
+ initFlowValues =
7401
+ typeof this.initFlowValues === 'string'
7402
+ ? JSON.parse(this.initFlowValues)
7403
+ : this.initFlowValues;
7341
7404
  }
7342
- else {
7343
- dictionary[controlId] = fillValue;
7405
+ catch (e) {
7406
+ console.warn('Failed to parse initFlowValues:', e);
7344
7407
  }
7345
- return dictionary;
7346
- }, {});
7347
- const initFlowValues = this.fillData?.initFlowValues;
7408
+ }
7348
7409
  const addInitFlowValues = (node, pathParts) => {
7349
7410
  if (node === null || node === undefined) {
7350
7411
  if (pathParts.length > 0) {
@@ -7523,6 +7584,35 @@ class CollectorFormComponent {
7523
7584
  return false;
7524
7585
  }
7525
7586
  }
7587
+ async executeLeadingActionSteps() {
7588
+ if (!this.appDataUuid || !this.flux || this.flux.length === 0) {
7589
+ return;
7590
+ }
7591
+ const leadingActionSteps = this.actionStepHandler.getActionStepsBeforeFirstVisibleStep(this.flux);
7592
+ if (leadingActionSteps.length === 0) {
7593
+ return;
7594
+ }
7595
+ console.log(`🎬 Executing ${leadingActionSteps.length} leading action steps before first visible step`);
7596
+ this.isLoading = true;
7597
+ try {
7598
+ const result = await this.actionStepHandler.executeActionSteps(leadingActionSteps, this.appDataUuid, (step) => {
7599
+ const loadingMessage = Utils.findTranslationInfo('loadingMessageTranslations', step.translations, this.currentLanguageIso);
7600
+ this.loadingMessage = loadingMessage || null;
7601
+ });
7602
+ if (result.success) {
7603
+ console.log('✅ Leading action steps executed successfully');
7604
+ }
7605
+ else {
7606
+ console.error('❌ Leading action steps failed:', result.error);
7607
+ }
7608
+ }
7609
+ catch (error) {
7610
+ console.error('❌ Error executing leading action steps:', error);
7611
+ }
7612
+ finally {
7613
+ this.loadingMessage = null;
7614
+ }
7615
+ }
7526
7616
  onSelectedPageChanged(index) {
7527
7617
  if (this.formlyConfig[0].fieldGroup) {
7528
7618
  var selectedPage = this.formlyConfig[0].fieldGroup[index];
@@ -7587,8 +7677,15 @@ class CollectorFormComponent {
7587
7677
  }
7588
7678
  }
7589
7679
  else {
7590
- const val = this.findInApiCallsResponses(associatedControlId);
7591
- fg.defaultValue = val;
7680
+ // Check controlIdsWithValues for initFlowValues
7681
+ const initFlowValue = this.controlIdsWithValues?.[associatedControlId];
7682
+ if (initFlowValue !== undefined) {
7683
+ fg.defaultValue = initFlowValue;
7684
+ }
7685
+ else {
7686
+ const val = this.findInApiCallsResponses(associatedControlId);
7687
+ fg.defaultValue = val;
7688
+ }
7592
7689
  }
7593
7690
  }
7594
7691
  }
@@ -8714,6 +8811,11 @@ class CollectorFormComponent {
8714
8811
  }
8715
8812
  }
8716
8813
  }
8814
+ // Ensure type is set for presentation controls
8815
+ if (!formlyConfig.type) {
8816
+ formlyConfig.type = 'formly-paragraph';
8817
+ formlyConfig.className = 'component-text-field';
8818
+ }
8717
8819
  formlyConfig.id = control.identifier;
8718
8820
  formlyConfig.props['isDisplayMode'] = true;
8719
8821
  formlyConfig.props['collectionControlIdentifier'] =
@@ -9959,7 +10061,7 @@ class FormlyFieldStepperComponent extends FieldType {
9959
10061
  callback: () => this.checkIfFlowIsFinished(),
9960
10062
  });
9961
10063
  console.log('hasActionSteps', hasActionSteps);
9962
- if (hasActionSteps) {
10064
+ if (hasActionSteps && !this.isFlowFinished) {
9963
10065
  await this.updateAppData(true);
9964
10066
  }
9965
10067
  if (!this.isFlowFinished) {
@@ -10029,12 +10131,14 @@ class FormlyFieldStepperComponent extends FieldType {
10029
10131
  current: currentIdx,
10030
10132
  callback: () => this.checkIfFlowIsFinished(),
10031
10133
  });
10032
- if (hasActionSteps) {
10134
+ if (hasActionSteps && !this.isFlowFinished) {
10033
10135
  await this.updateAppData(true);
10034
10136
  }
10035
- this.stepper.next();
10036
- this.currentStepIndex = this.stepper.selectedIndex;
10037
- this.field?.props?.['onSelectedPageChanged'](this.stepper.selectedIndex);
10137
+ if (!this.isFlowFinished) {
10138
+ this.stepper.next();
10139
+ this.currentStepIndex = this.stepper.selectedIndex;
10140
+ this.field?.props?.['onSelectedPageChanged'](this.stepper.selectedIndex);
10141
+ }
10038
10142
  this.cdr.detectChanges();
10039
10143
  }
10040
10144
  checkIfFlowIsFinished() {