jupiter-dynamic-forms 1.16.1 → 1.16.3

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.mjs CHANGED
@@ -1501,6 +1501,7 @@ const form$1 = {
1501
1501
  submit: "Validate",
1502
1502
  save: "Save",
1503
1503
  saveDraft: "Save Draft",
1504
+ savingDraft: "Saving draft",
1504
1505
  errors: "Errors",
1505
1506
  modified: "Modified",
1506
1507
  valid: "Valid",
@@ -1646,6 +1647,7 @@ const form = {
1646
1647
  submit: "Valideren",
1647
1648
  save: "Opslaan",
1648
1649
  saveDraft: "Concept opslaan",
1650
+ savingDraft: "Concept opslaan...",
1649
1651
  errors: "Fouten",
1650
1652
  modified: "Gewijzigd",
1651
1653
  valid: "Geldig",
@@ -2022,11 +2024,12 @@ class DraftStorageService {
2022
2024
  /**
2023
2025
  * Create metadata snapshot from current form state
2024
2026
  */
2025
- createMetadataSnapshot(periodStartDate, periodEndDate, language, selectedRoleIds, allSections, typedMemberData, periodPreferences, periodData, unitData) {
2027
+ createMetadataSnapshot(periodStartDate, periodEndDate, language, selectedRoleIds, allSections, typedMemberData, periodPreferences, periodData, unitData, reportingLanguage = "en") {
2026
2028
  return {
2027
2029
  periodStartDate,
2028
2030
  periodEndDate,
2029
2031
  language,
2032
+ reportingLanguage,
2030
2033
  selectedRoleIds,
2031
2034
  // Store enhanced structure (with roleURI and order) or legacy string array
2032
2035
  customColumns: this.extractCustomColumns(allSections),
@@ -7168,10 +7171,12 @@ let JupiterDynamicForm = class extends LitElement {
7168
7171
  this.periodStartDate = "2025-01-01";
7169
7172
  this.periodEndDate = "2025-12-31";
7170
7173
  this.language = "en";
7174
+ this.reportingLanguage = "en";
7171
7175
  this.display = "accordion";
7172
7176
  this.mode = "inputForm";
7173
7177
  this.roleFilterAxes = [];
7174
7178
  this.showLastValidationResultBtn = false;
7179
+ this.isDraftSaving = false;
7175
7180
  this.defaultUnits = [];
7176
7181
  this._formData = {};
7177
7182
  this._draftLoaded = false;
@@ -7207,6 +7212,9 @@ let JupiterDynamicForm = class extends LitElement {
7207
7212
  this._validationStatus = "idle";
7208
7213
  this._skipDraftLoading = false;
7209
7214
  this._skipPeriodPreferencesRestore = false;
7215
+ this._autoSaveTimer = null;
7216
+ this._lastAutoSaveSnapshot = "";
7217
+ this._lastSavedDraftSnapshot = "";
7210
7218
  }
7211
7219
  connectedCallback() {
7212
7220
  super.connectedCallback();
@@ -7233,8 +7241,29 @@ let JupiterDynamicForm = class extends LitElement {
7233
7241
  this.requestUpdate();
7234
7242
  }
7235
7243
  });
7244
+ this._autoSaveTimer = setInterval(() => {
7245
+ const currentSnapshot = JSON.stringify(this._formData);
7246
+ if (this._lastAutoSaveSnapshot === "") {
7247
+ this._lastAutoSaveSnapshot = currentSnapshot;
7248
+ console.log("ℹ️ [Auto Save] Baseline initialized; no draft save emitted.");
7249
+ return;
7250
+ }
7251
+ if (currentSnapshot !== this._lastAutoSaveSnapshot) {
7252
+ this._lastAutoSaveSnapshot = currentSnapshot;
7253
+ this._handleSaveDraft("auto");
7254
+ } else {
7255
+ console.log("ℹ️ [Auto Save] No form state change detected; skipping draft save emit.");
7256
+ }
7257
+ }, 3e4);
7236
7258
  this._initializeForm();
7237
7259
  }
7260
+ disconnectedCallback() {
7261
+ super.disconnectedCallback();
7262
+ if (this._autoSaveTimer !== null) {
7263
+ clearInterval(this._autoSaveTimer);
7264
+ this._autoSaveTimer = null;
7265
+ }
7266
+ }
7238
7267
  updated(changedProperties) {
7239
7268
  if (changedProperties.has("language")) {
7240
7269
  I18n.setLanguage(this.language);
@@ -7879,7 +7908,8 @@ let JupiterDynamicForm = class extends LitElement {
7879
7908
  this._typedMemberData,
7880
7909
  this._periodPreferences,
7881
7910
  this._periodData,
7882
- this._unitData
7911
+ this._unitData,
7912
+ this.reportingLanguage
7883
7913
  );
7884
7914
  this._draftStorageService.saveDraft(currentFormData, currentMetadata);
7885
7915
  console.log("✅ Current form data saved to draft storage with NEW preferences");
@@ -8644,7 +8674,8 @@ let JupiterDynamicForm = class extends LitElement {
8644
8674
  data: this._formData,
8645
8675
  submissionData,
8646
8676
  valid: this._valid,
8647
- errors: this._errors
8677
+ errors: this._errors,
8678
+ reportingLanguage: this.reportingLanguage
8648
8679
  },
8649
8680
  bubbles: true
8650
8681
  }));
@@ -8653,7 +8684,7 @@ let JupiterDynamicForm = class extends LitElement {
8653
8684
  this._submitDisabled = false;
8654
8685
  }, 1e3);
8655
8686
  }
8656
- _handleSaveDraft() {
8687
+ _handleSaveDraft(source = "manual") {
8657
8688
  console.log(`🔵 [Save Draft] Checking for errors...`);
8658
8689
  console.log(`🔵 [Save Draft] _xbrlFormErrors.length: ${this._xbrlFormErrors.length}`);
8659
8690
  console.log(`🔵 [Save Draft] _xbrlFormErrors:`, this._xbrlFormErrors);
@@ -8683,8 +8714,18 @@ let JupiterDynamicForm = class extends LitElement {
8683
8714
  this._typedMemberData,
8684
8715
  this._periodPreferences,
8685
8716
  this._periodData,
8686
- this._unitData
8717
+ this._unitData,
8718
+ this.reportingLanguage
8687
8719
  );
8720
+ const draftPayloadSnapshot = JSON.stringify({
8721
+ draftData,
8722
+ metadata
8723
+ });
8724
+ if (draftPayloadSnapshot === this._lastSavedDraftSnapshot) {
8725
+ console.log(`ℹ️ [Save Draft] No draft content change detected (${source}); skipping event emit.`);
8726
+ return;
8727
+ }
8728
+ this._lastSavedDraftSnapshot = draftPayloadSnapshot;
8688
8729
  const saved = this._draftStorageService.saveDraft(draftData, metadata);
8689
8730
  console.log("💾 [Save Draft] Metadata saved with enhanced selectedRoleIds:", metadata.selectedRoleIds);
8690
8731
  this.dynaformsFacts = draftData;
@@ -8699,7 +8740,9 @@ let JupiterDynamicForm = class extends LitElement {
8699
8740
  errors: this._errors,
8700
8741
  // JSON data ready for external database storage
8701
8742
  dynaformsFacts: draftData,
8702
- dynaformsMetadata: metadata
8743
+ dynaformsMetadata: metadata,
8744
+ reportingLanguage: this.reportingLanguage,
8745
+ source: source == "auto" ? "auto" : "manual"
8703
8746
  },
8704
8747
  bubbles: true,
8705
8748
  composed: true
@@ -10497,9 +10540,9 @@ let JupiterDynamicForm = class extends LitElement {
10497
10540
  <button
10498
10541
  class="btn-secondary"
10499
10542
  @click="${this._handleSaveDraft}"
10500
- ?disabled="${this.disabled || this.readonly}"
10543
+ ?disabled="${this.disabled || this.readonly || this.isDraftSaving}"
10501
10544
  >
10502
- ${I18n.t("form.saveDraft")}
10545
+ ${this.isDraftSaving ? I18n.t("form.savingDraft") : I18n.t("form.saveDraft")}
10503
10546
  </button>
10504
10547
  ` : ""}
10505
10548
 
@@ -10513,14 +10556,6 @@ let JupiterDynamicForm = class extends LitElement {
10513
10556
  >
10514
10557
  ${I18n.t("form.preview")}
10515
10558
  </button>
10516
-
10517
- <button
10518
- class="btn-cancel-validation"
10519
- @click="${() => this.dispatchEvent(new CustomEvent("validationCancel", { bubbles: true, composed: true }))}"
10520
- ?disabled="${this.disabled || this.readonly}"
10521
- >
10522
- ${I18n.t("form.cancelValidation")}
10523
- </button>
10524
10559
  ` : ""}
10525
10560
 
10526
10561
  ${this._validationStatus === "complete" || this.showLastValidationResultBtn ? html`
@@ -10779,15 +10814,6 @@ JupiterDynamicForm.styles = css`
10779
10814
  background: var(--jupiter-primary-color-dark, #1565c0);
10780
10815
  }
10781
10816
 
10782
- .btn-cancel-validation {
10783
- background: var(--jupiter-primary-color, #1976d2);
10784
- color: white;
10785
- }
10786
- .btn-cancel-validation:hover:not(:disabled) {
10787
- background: var(--jupiter-primary-color, #1976d2);
10788
- color: white;
10789
- }
10790
-
10791
10817
  .btn-last-results {
10792
10818
  background: var(--jupiter-primary-color, #1976d2);
10793
10819
  color: white;
@@ -11422,6 +11448,9 @@ __decorateClass([
11422
11448
  __decorateClass([
11423
11449
  n2({ type: String })
11424
11450
  ], JupiterDynamicForm.prototype, "language", 2);
11451
+ __decorateClass([
11452
+ n2({ type: String })
11453
+ ], JupiterDynamicForm.prototype, "reportingLanguage", 2);
11425
11454
  __decorateClass([
11426
11455
  n2({ type: String })
11427
11456
  ], JupiterDynamicForm.prototype, "display", 2);
@@ -11437,6 +11466,9 @@ __decorateClass([
11437
11466
  __decorateClass([
11438
11467
  n2({ type: Boolean, attribute: "show-last-validation-result-btn" })
11439
11468
  ], JupiterDynamicForm.prototype, "showLastValidationResultBtn", 2);
11469
+ __decorateClass([
11470
+ n2({ type: Boolean, attribute: "is-draft-saving" })
11471
+ ], JupiterDynamicForm.prototype, "isDraftSaving", 2);
11440
11472
  __decorateClass([
11441
11473
  n2({ type: Array })
11442
11474
  ], JupiterDynamicForm.prototype, "defaultUnits", 2);