jupiter-dynamic-forms 1.16.1 → 1.16.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.
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",
@@ -7172,6 +7174,7 @@ let JupiterDynamicForm = class extends LitElement {
7172
7174
  this.mode = "inputForm";
7173
7175
  this.roleFilterAxes = [];
7174
7176
  this.showLastValidationResultBtn = false;
7177
+ this.isDraftSaving = false;
7175
7178
  this.defaultUnits = [];
7176
7179
  this._formData = {};
7177
7180
  this._draftLoaded = false;
@@ -7207,6 +7210,9 @@ let JupiterDynamicForm = class extends LitElement {
7207
7210
  this._validationStatus = "idle";
7208
7211
  this._skipDraftLoading = false;
7209
7212
  this._skipPeriodPreferencesRestore = false;
7213
+ this._autoSaveTimer = null;
7214
+ this._lastAutoSaveSnapshot = "";
7215
+ this._lastSavedDraftSnapshot = "";
7210
7216
  }
7211
7217
  connectedCallback() {
7212
7218
  super.connectedCallback();
@@ -7233,8 +7239,29 @@ let JupiterDynamicForm = class extends LitElement {
7233
7239
  this.requestUpdate();
7234
7240
  }
7235
7241
  });
7242
+ this._autoSaveTimer = setInterval(() => {
7243
+ const currentSnapshot = JSON.stringify(this._formData);
7244
+ if (this._lastAutoSaveSnapshot === "") {
7245
+ this._lastAutoSaveSnapshot = currentSnapshot;
7246
+ console.log("ℹ️ [Auto Save] Baseline initialized; no draft save emitted.");
7247
+ return;
7248
+ }
7249
+ if (currentSnapshot !== this._lastAutoSaveSnapshot) {
7250
+ this._lastAutoSaveSnapshot = currentSnapshot;
7251
+ this._handleSaveDraft("auto");
7252
+ } else {
7253
+ console.log("ℹ️ [Auto Save] No form state change detected; skipping draft save emit.");
7254
+ }
7255
+ }, 3e4);
7236
7256
  this._initializeForm();
7237
7257
  }
7258
+ disconnectedCallback() {
7259
+ super.disconnectedCallback();
7260
+ if (this._autoSaveTimer !== null) {
7261
+ clearInterval(this._autoSaveTimer);
7262
+ this._autoSaveTimer = null;
7263
+ }
7264
+ }
7238
7265
  updated(changedProperties) {
7239
7266
  if (changedProperties.has("language")) {
7240
7267
  I18n.setLanguage(this.language);
@@ -8653,7 +8680,7 @@ let JupiterDynamicForm = class extends LitElement {
8653
8680
  this._submitDisabled = false;
8654
8681
  }, 1e3);
8655
8682
  }
8656
- _handleSaveDraft() {
8683
+ _handleSaveDraft(source = "manual") {
8657
8684
  console.log(`🔵 [Save Draft] Checking for errors...`);
8658
8685
  console.log(`🔵 [Save Draft] _xbrlFormErrors.length: ${this._xbrlFormErrors.length}`);
8659
8686
  console.log(`🔵 [Save Draft] _xbrlFormErrors:`, this._xbrlFormErrors);
@@ -8685,6 +8712,15 @@ let JupiterDynamicForm = class extends LitElement {
8685
8712
  this._periodData,
8686
8713
  this._unitData
8687
8714
  );
8715
+ const draftPayloadSnapshot = JSON.stringify({
8716
+ draftData,
8717
+ metadata
8718
+ });
8719
+ if (draftPayloadSnapshot === this._lastSavedDraftSnapshot) {
8720
+ console.log(`ℹ️ [Save Draft] No draft content change detected (${source}); skipping event emit.`);
8721
+ return;
8722
+ }
8723
+ this._lastSavedDraftSnapshot = draftPayloadSnapshot;
8688
8724
  const saved = this._draftStorageService.saveDraft(draftData, metadata);
8689
8725
  console.log("💾 [Save Draft] Metadata saved with enhanced selectedRoleIds:", metadata.selectedRoleIds);
8690
8726
  this.dynaformsFacts = draftData;
@@ -8699,7 +8735,8 @@ let JupiterDynamicForm = class extends LitElement {
8699
8735
  errors: this._errors,
8700
8736
  // JSON data ready for external database storage
8701
8737
  dynaformsFacts: draftData,
8702
- dynaformsMetadata: metadata
8738
+ dynaformsMetadata: metadata,
8739
+ source: source == "auto" ? "auto" : "manual"
8703
8740
  },
8704
8741
  bubbles: true,
8705
8742
  composed: true
@@ -10497,9 +10534,9 @@ let JupiterDynamicForm = class extends LitElement {
10497
10534
  <button
10498
10535
  class="btn-secondary"
10499
10536
  @click="${this._handleSaveDraft}"
10500
- ?disabled="${this.disabled || this.readonly}"
10537
+ ?disabled="${this.disabled || this.readonly || this.isDraftSaving}"
10501
10538
  >
10502
- ${I18n.t("form.saveDraft")}
10539
+ ${this.isDraftSaving ? I18n.t("form.savingDraft") : I18n.t("form.saveDraft")}
10503
10540
  </button>
10504
10541
  ` : ""}
10505
10542
 
@@ -10513,14 +10550,6 @@ let JupiterDynamicForm = class extends LitElement {
10513
10550
  >
10514
10551
  ${I18n.t("form.preview")}
10515
10552
  </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
10553
  ` : ""}
10525
10554
 
10526
10555
  ${this._validationStatus === "complete" || this.showLastValidationResultBtn ? html`
@@ -10779,15 +10808,6 @@ JupiterDynamicForm.styles = css`
10779
10808
  background: var(--jupiter-primary-color-dark, #1565c0);
10780
10809
  }
10781
10810
 
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
10811
  .btn-last-results {
10792
10812
  background: var(--jupiter-primary-color, #1976d2);
10793
10813
  color: white;
@@ -11437,6 +11457,9 @@ __decorateClass([
11437
11457
  __decorateClass([
11438
11458
  n2({ type: Boolean, attribute: "show-last-validation-result-btn" })
11439
11459
  ], JupiterDynamicForm.prototype, "showLastValidationResultBtn", 2);
11460
+ __decorateClass([
11461
+ n2({ type: Boolean, attribute: "is-draft-saving" })
11462
+ ], JupiterDynamicForm.prototype, "isDraftSaving", 2);
11440
11463
  __decorateClass([
11441
11464
  n2({ type: Array })
11442
11465
  ], JupiterDynamicForm.prototype, "defaultUnits", 2);