jupiter-dynamic-forms 1.17.4 → 1.17.5

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
@@ -1702,7 +1702,8 @@ const field$1 = {
1702
1702
  urlPlaceholder: "https://example.com",
1703
1703
  phonePlaceholder: "+1 (555) 000-0000",
1704
1704
  enterValue: "Enter value",
1705
- enterDetailedInformation: "Enter detailed information..."
1705
+ enterDetailedInformation: "Enter detailed information...",
1706
+ scale: "Scale"
1706
1707
  };
1707
1708
  const admin$1 = {
1708
1709
  title: "Configure Roles",
@@ -1855,7 +1856,8 @@ const field = {
1855
1856
  urlPlaceholder: "https://voorbeeld.nl",
1856
1857
  phonePlaceholder: "+31 (0)20 123 4567",
1857
1858
  enterValue: "Voer waarde in",
1858
- enterDetailedInformation: "Voer gedetailleerde informatie in..."
1859
+ enterDetailedInformation: "Voer gedetailleerde informatie in...",
1860
+ scale: "Schaal"
1859
1861
  };
1860
1862
  const admin = {
1861
1863
  title: "Rollen configureren",
@@ -3320,7 +3322,9 @@ let JupiterFormField = class extends LitElement {
3320
3322
  console.log(`🏷️ [FormField] unit-change event dispatched`);
3321
3323
  }
3322
3324
  _handleDecimalsChange(event) {
3323
- const value = event.target.value.trim();
3325
+ const raw = event.target.value.trim();
3326
+ const num = parseFloat(raw);
3327
+ const value = raw && !isNaN(num) ? String(Math.abs(num)) : raw === "" ? "" : raw;
3324
3328
  this.decimals = value || void 0;
3325
3329
  this.dispatchEvent(new CustomEvent("decimals-change", {
3326
3330
  detail: { conceptId: this.conceptId, columnId: this.columnId, decimals: this.decimals },
@@ -3678,9 +3682,10 @@ let JupiterFormField = class extends LitElement {
3678
3682
 
3679
3683
  ${this._isMonetaryType() ? html`
3680
3684
  <div class="period-controls">
3681
- <label>Decimals:</label>
3685
+ <label>${I18n.t("field.scale")}:</label>
3682
3686
  <input
3683
3687
  type="number"
3688
+ min="0"
3684
3689
  class="typed-member-input"
3685
3690
  placeholder="Leave blank for INF"
3686
3691
  .value="${this.decimals ?? (this.globalDecimals !== "INF" ? this.globalDecimals : "")}"
@@ -8167,6 +8172,7 @@ let JupiterDynamicForm = class extends LitElement {
8167
8172
  this._unitData = {};
8168
8173
  this._preservedUnitData = {};
8169
8174
  this._decimalsData = {};
8175
+ this._effectiveMasterData = void 0;
8170
8176
  this._typedMemberData = {};
8171
8177
  this._preservedTypedMemberData = {};
8172
8178
  this._repeatCounts = {};
@@ -8253,6 +8259,9 @@ let JupiterDynamicForm = class extends LitElement {
8253
8259
  }
8254
8260
  }
8255
8261
  updated(changedProperties) {
8262
+ if (changedProperties.has("decimals") || changedProperties.has("masterData")) {
8263
+ this._computeEffectiveMasterData();
8264
+ }
8256
8265
  if (changedProperties.has("language")) {
8257
8266
  I18n.setLanguage(this.language);
8258
8267
  }
@@ -9077,6 +9086,20 @@ let JupiterDynamicForm = class extends LitElement {
9077
9086
  this._dirty = true;
9078
9087
  this.requestUpdate();
9079
9088
  }
9089
+ _computeEffectiveMasterData() {
9090
+ const ROUNDING_CONCEPT = "rj-i_DocumentIntendedRoundingLevel";
9091
+ if (this.decimals !== "INF") {
9092
+ const parsed = parseFloat(this.decimals);
9093
+ if (!isNaN(parsed)) {
9094
+ this._effectiveMasterData = {
9095
+ ...this.masterData || {},
9096
+ [ROUNDING_CONCEPT]: String(-parsed)
9097
+ };
9098
+ return;
9099
+ }
9100
+ }
9101
+ this._effectiveMasterData = this.masterData ? { ...this.masterData } : void 0;
9102
+ }
9080
9103
  _storeDecimals(conceptId, columnId, decimals) {
9081
9104
  const updated = { ...this._decimalsData };
9082
9105
  if (!updated[conceptId])
@@ -10505,7 +10528,8 @@ let JupiterDynamicForm = class extends LitElement {
10505
10528
  const fieldDecimals = (_d = this._decimalsData[concept.id]) == null ? void 0 : _d[columnId];
10506
10529
  const decimalsValue = fieldDecimals || (this.decimals !== "INF" ? this.decimals : void 0);
10507
10530
  if (isMonetary && decimalsValue) {
10508
- entry.decimals = decimalsValue;
10531
+ const parsed = parseFloat(decimalsValue);
10532
+ entry.decimals = isNaN(parsed) ? decimalsValue : String(-Math.abs(parsed));
10509
10533
  }
10510
10534
  if ((_e = column2 == null ? void 0 : column2.dimensionData) == null ? void 0 : _e.memberLabel) {
10511
10535
  entry.dimension = column2.dimensionData.memberLabel;
@@ -10645,12 +10669,12 @@ let JupiterDynamicForm = class extends LitElement {
10645
10669
  }
10646
10670
  if (concept.fields && concept.fields.length > 0) {
10647
10671
  concept.fields.forEach((field2) => {
10648
- var _a, _b, _c, _d, _e, _f, _g;
10672
+ var _a, _b, _c, _d, _e, _f, _g, _h;
10649
10673
  const conceptData = this._formData[concept.id];
10650
10674
  let fieldValue = conceptData == null ? void 0 : conceptData[field2.columnId];
10651
- if ((fieldValue === void 0 || fieldValue === null || fieldValue === "") && this.masterData) {
10675
+ if ((fieldValue === void 0 || fieldValue === null || fieldValue === "") && this._effectiveMasterData) {
10652
10676
  const baseConceptId = field2.conceptId || concept.id.split("__").slice(0, -1).join("__") || concept.id;
10653
- const masterValue = this.masterData[baseConceptId];
10677
+ const masterValue = (_a = this._effectiveMasterData) == null ? void 0 : _a[baseConceptId];
10654
10678
  if (masterValue !== void 0 && masterValue !== null && masterValue !== "") {
10655
10679
  fieldValue = masterValue;
10656
10680
  console.warn(` 📦 [Submission] Using masterData for: ${baseConceptId} [${field2.columnId}] = ${JSON.stringify(fieldValue)}`);
@@ -10658,7 +10682,7 @@ let JupiterDynamicForm = class extends LitElement {
10658
10682
  }
10659
10683
  if (fieldValue !== void 0 && fieldValue !== null && fieldValue !== "") {
10660
10684
  const column2 = this._findColumnByIdInSection(field2.columnId, section2);
10661
- const fieldPeriodData = (_a = this._periodData[concept.id]) == null ? void 0 : _a[field2.columnId];
10685
+ const fieldPeriodData = (_b = this._periodData[concept.id]) == null ? void 0 : _b[field2.columnId];
10662
10686
  const submissionEntry = {
10663
10687
  conceptId: concept.id,
10664
10688
  draftInstanceId: concept.id,
@@ -10680,20 +10704,21 @@ let JupiterDynamicForm = class extends LitElement {
10680
10704
  submissionEntry.period.endDate = endDate;
10681
10705
  }
10682
10706
  console.log(`🔍 [Submission] Concept: ${concept.id}, Column: ${field2.columnId}, Field Period: ${fieldPeriodData ? JSON.stringify(fieldPeriodData) : "none"}, Column Period: ${(column2 == null ? void 0 : column2.periodStartDate) || "none"} - ${(column2 == null ? void 0 : column2.periodEndDate) || "none"}, Used Period: ${submissionEntry.period.type === "instant" ? submissionEntry.period.date : `${submissionEntry.period.startDate} - ${submissionEntry.period.endDate}`}`);
10683
- const fieldUnit = (_b = this._unitData[concept.id]) == null ? void 0 : _b[field2.columnId];
10707
+ const fieldUnit = (_c = this._unitData[concept.id]) == null ? void 0 : _c[field2.columnId];
10684
10708
  if (fieldUnit) {
10685
10709
  submissionEntry.unit = fieldUnit;
10686
10710
  console.log(`✅ [Submission] Adding unit to entry: ${fieldUnit} for ${concept.id}/${field2.columnId}`);
10687
10711
  } else {
10688
10712
  console.log(`⚠️ [Submission] No unit found in _unitData for ${concept.id}/${field2.columnId}. _unitData state:`, JSON.stringify(this._unitData, null, 2));
10689
10713
  }
10690
- const isMonetary = (_c = concept.type) == null ? void 0 : _c.toLowerCase().includes("monetary");
10691
- const fieldDecimals = (_d = this._decimalsData[concept.id]) == null ? void 0 : _d[field2.columnId];
10714
+ const isMonetary = (_d = concept.type) == null ? void 0 : _d.toLowerCase().includes("monetary");
10715
+ const fieldDecimals = (_e = this._decimalsData[concept.id]) == null ? void 0 : _e[field2.columnId];
10692
10716
  const decimalsValue = fieldDecimals || (this.decimals !== "INF" ? this.decimals : void 0);
10693
10717
  if (isMonetary && decimalsValue) {
10694
- submissionEntry.decimals = decimalsValue;
10718
+ const parsed = parseFloat(decimalsValue);
10719
+ submissionEntry.decimals = isNaN(parsed) ? decimalsValue : String(-Math.abs(parsed));
10695
10720
  }
10696
- if ((column2 == null ? void 0 : column2.type) === "dimension" && ((_e = column2.dimensionData) == null ? void 0 : _e.dimensionIdKey)) {
10721
+ if ((column2 == null ? void 0 : column2.type) === "dimension" && ((_f = column2.dimensionData) == null ? void 0 : _f.dimensionIdKey)) {
10697
10722
  submissionEntry.dimension = column2.dimensionData.dimensionIdKey;
10698
10723
  console.log(`🔍 [DynamicForm] Using dimension key from field's column (${field2.columnId}):`, column2.dimensionData.dimensionIdKey);
10699
10724
  } else {
@@ -10729,12 +10754,12 @@ let JupiterDynamicForm = class extends LitElement {
10729
10754
  console.log(`🔍 [DynamicForm] Column details:`, {
10730
10755
  id: column2.id,
10731
10756
  type: column2.type,
10732
- hasTypedMembers: (_f = column2.dimensionData) == null ? void 0 : _f.hasTypedMembers,
10757
+ hasTypedMembers: (_g = column2.dimensionData) == null ? void 0 : _g.hasTypedMembers,
10733
10758
  dimensionData: column2.dimensionData
10734
10759
  });
10735
10760
  }
10736
10761
  }
10737
- if (!submissionEntry.typedMembers && ((_g = field2.crossRoleTypedMembers) == null ? void 0 : _g.length)) {
10762
+ if (!submissionEntry.typedMembers && ((_h = field2.crossRoleTypedMembers) == null ? void 0 : _h.length)) {
10738
10763
  const crossRoleKey = `${concept.id}__${field2.columnId}`;
10739
10764
  const crossRoleValues = this._typedMemberData[crossRoleKey];
10740
10765
  if (crossRoleValues) {
@@ -11000,7 +11025,7 @@ let JupiterDynamicForm = class extends LitElement {
11000
11025
  if (value === void 0 && conceptIdWithSuffix !== fieldConceptId) {
11001
11026
  value = (_b = this._formData[fieldConceptId]) == null ? void 0 : _b[field2.columnId];
11002
11027
  }
11003
- const masterValue = (_c = this.masterData) == null ? void 0 : _c[fieldConceptId];
11028
+ const masterValue = (_c = this._effectiveMasterData) == null ? void 0 : _c[fieldConceptId];
11004
11029
  if ((value === null || value === void 0 || typeof value === "string" && value.trim() === "") && masterValue !== void 0) {
11005
11030
  value = masterValue;
11006
11031
  console.warn(` 📦 Using masterData value for: ${fieldConceptId} [${field2.columnId}] = ${JSON.stringify(value)}`);
@@ -11551,7 +11576,7 @@ let JupiterDynamicForm = class extends LitElement {
11551
11576
  .mode="${this.mode}"
11552
11577
  .showFactsOnly="${this._showFactsOnly}"
11553
11578
  .conceptMatchIds="${hasConceptSearch ? conceptMatchIds : void 0}"
11554
- .masterData="${this.masterData}"
11579
+ .masterData="${this._effectiveMasterData}"
11555
11580
  .periodStartDate="${this.periodStartDate}"
11556
11581
  .periodEndDate="${this.periodEndDate}"
11557
11582
  @field-change="${this._handleFieldChange}"
@@ -11694,7 +11719,7 @@ let JupiterDynamicForm = class extends LitElement {
11694
11719
  .mode="${this.mode}"
11695
11720
  .showFactsOnly="${this._showFactsOnly}"
11696
11721
  .conceptMatchIds="${hasConceptSearch ? conceptMatchIds : void 0}"
11697
- .masterData="${this.masterData}"
11722
+ .masterData="${this._effectiveMasterData}"
11698
11723
  .periodStartDate="${this.periodStartDate}"
11699
11724
  .periodEndDate="${this.periodEndDate}"
11700
11725
  @field-change="${this._handleFieldChange}"
@@ -12767,6 +12792,9 @@ __decorateClass([
12767
12792
  __decorateClass([
12768
12793
  r()
12769
12794
  ], JupiterDynamicForm.prototype, "_decimalsData", 2);
12795
+ __decorateClass([
12796
+ r()
12797
+ ], JupiterDynamicForm.prototype, "_effectiveMasterData", 2);
12770
12798
  __decorateClass([
12771
12799
  r()
12772
12800
  ], JupiterDynamicForm.prototype, "_typedMemberData", 2);