@processmaker/screen-builder 3.8.17 → 3.8.19

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.
@@ -51112,7 +51112,7 @@ const nre = {
51112
51112
  const l = this.loadVariables(r);
51113
51113
  Object.assign(t, l.variables || {});
51114
51114
  }
51115
- return Object.assign(t, this.extractCalculatedVariables()), Object.keys(t).filter((l) => !l.startsWith("_parent.")).sort();
51115
+ return Object.assign(t, this.extractCalculatedVariables()), Object.assign(t, this.extractWatcherVariables()), Object.keys(t).filter((l) => this.isValidVariableName(l)).sort();
51116
51116
  },
51117
51117
  filteredVariables() {
51118
51118
  if (!this.searchQuery)
@@ -51139,6 +51139,31 @@ const nre = {
51139
51139
  return this.isEnabled ? this.requiredVariables.filter(
51140
51140
  (t) => !this.selectedVariables.includes(t)
51141
51141
  ) : [];
51142
+ },
51143
+ /**
51144
+ * Check if all filtered variables are selected
51145
+ */
51146
+ allSelected() {
51147
+ return this.filteredVariables.length > 0 && this.filteredVariables.every((t) => this.selectedVariables.includes(t));
51148
+ },
51149
+ /**
51150
+ * Check if some (but not all) filtered variables are selected
51151
+ */
51152
+ someSelected() {
51153
+ const t = this.filteredVariables.filter((e) => this.selectedVariables.includes(e)).length;
51154
+ return t > 0 && t < this.filteredVariables.length;
51155
+ },
51156
+ /**
51157
+ * Source for computed properties to watch for changes
51158
+ */
51159
+ computedPropertiesSource() {
51160
+ return this.getComputedProperties() || [];
51161
+ },
51162
+ /**
51163
+ * Source for watchers to watch for changes
51164
+ */
51165
+ watchersSource() {
51166
+ return this.getWatchers() || [];
51142
51167
  }
51143
51168
  },
51144
51169
  watch: {
@@ -51148,21 +51173,48 @@ const nre = {
51148
51173
  selectedVariables(t) {
51149
51174
  this.isEnabled ? (this.$emit("input", t), this.$emit("change", t)) : (this.$emit("input", []), this.$emit("change", []));
51150
51175
  },
51151
- isEnabled(t) {
51152
- t || (this.selectedVariables = [], this.$emit("input", []), this.$emit("change", []));
51176
+ isEnabled(t, e) {
51177
+ t && !e ? (this.selectedVariables = [...this.availableVariables], this.$emit("input", this.selectedVariables), this.$emit("change", this.selectedVariables)) : t || (this.selectedVariables = [], this.$emit("input", []), this.$emit("change", []));
51153
51178
  },
51154
51179
  "selectedControl.config.event"(t) {
51155
51180
  this.event = t;
51156
51181
  },
51157
- "builder.variablesTree"() {
51158
- this.$forceUpdate();
51182
+ formConfig: {
51183
+ handler() {
51184
+ this.$nextTick(() => {
51185
+ this.cleanupInvalidSelections();
51186
+ });
51187
+ },
51188
+ deep: !0,
51189
+ immediate: !0
51159
51190
  },
51160
- // Watch for computed properties changes in App.vue
51161
- "$root.computed"() {
51162
- this.$forceUpdate();
51191
+ // Watch for computed properties changes
51192
+ computedPropertiesSource: {
51193
+ handler() {
51194
+ this.$nextTick(() => {
51195
+ this.cleanupInvalidSelections();
51196
+ });
51197
+ },
51198
+ deep: !0
51199
+ },
51200
+ // Watch for watchers changes
51201
+ watchersSource: {
51202
+ handler() {
51203
+ this.$nextTick(() => {
51204
+ this.cleanupInvalidSelections();
51205
+ });
51206
+ },
51207
+ deep: !0
51163
51208
  }
51164
51209
  },
51165
51210
  methods: {
51211
+ /**
51212
+ * Remove selected variables that no longer exist in availableVariables
51213
+ */
51214
+ cleanupInvalidSelections() {
51215
+ const t = this.availableVariables, e = this.selectedVariables.filter((r) => t.includes(r));
51216
+ e.length !== this.selectedVariables.length && (this.selectedVariables = e, e.length === 0 && (this.isEnabled = !1));
51217
+ },
51166
51218
  /**
51167
51219
  * Load variables from the variables tree
51168
51220
  * Only includes root-level variables (no prefix, no dots in name)
@@ -51183,9 +51235,22 @@ const nre = {
51183
51235
  const t = new Set(this.filteredVariables);
51184
51236
  this.selectedVariables = this.selectedVariables.filter((e) => !t.has(e));
51185
51237
  },
51238
+ toggleSelectAll(t) {
51239
+ t ? this.selectAll() : this.deselectAll();
51240
+ },
51186
51241
  toggleSearch() {
51187
51242
  this.showSearch = !this.showSearch, this.showSearch || (this.searchQuery = "");
51188
51243
  },
51244
+ /**
51245
+ * Check if a variable name is valid
51246
+ * Uses same logic as dot_notation validation rule
51247
+ */
51248
+ isValidVariableName(t) {
51249
+ if (!t || typeof t != "string" || t.startsWith("_parent."))
51250
+ return !1;
51251
+ const e = /^[a-zA-Z][a-zA-Z0-9_]*$/;
51252
+ return t.split(".").every((i) => e.test(i));
51253
+ },
51189
51254
  /**
51190
51255
  * Extract calculated variables (computed properties) from the screen
51191
51256
  * Searches in multiple locations: App.vue, builder, or parent components
@@ -51200,23 +51265,51 @@ const nre = {
51200
51265
  * Get computed properties from various sources
51201
51266
  */
51202
51267
  getComputedProperties() {
51203
- var e, r, i, a, n, s, o, u;
51268
+ var e, r, i, a, n, s, o, u, l, c, d;
51204
51269
  if ((r = (e = this.$root) == null ? void 0 : e.$data) != null && r.computed)
51205
51270
  return this.$root.$data.computed;
51206
- if ((a = (i = this.builder) == null ? void 0 : i.screen) != null && a.computed)
51271
+ if ((n = (a = (i = this.$root) == null ? void 0 : i.$children) == null ? void 0 : a[0]) != null && n.computed && Array.isArray(this.$root.$children[0].computed))
51272
+ return this.$root.$children[0].computed;
51273
+ if ((o = (s = this.builder) == null ? void 0 : s.screen) != null && o.computed)
51207
51274
  return this.builder.screen.computed;
51208
- if ((n = this.builder) != null && n.computed)
51275
+ if ((u = this.builder) != null && u.computed)
51209
51276
  return this.builder.computed;
51210
- if ((o = (s = this.$root) == null ? void 0 : s.$parent) != null && o.computed)
51277
+ if ((c = (l = this.$root) == null ? void 0 : l.$parent) != null && c.computed)
51211
51278
  return this.$root.$parent.computed;
51212
51279
  let t = this.$parent;
51213
- for (let l = 0; l < 10 && t; l++) {
51214
- if ((u = t.$data) != null && u.computed)
51280
+ for (let f = 0; f < 10 && t; f++) {
51281
+ if ((d = t.$data) != null && d.computed)
51215
51282
  return t.$data.computed;
51216
51283
  t = t.$parent;
51217
51284
  }
51218
51285
  return [];
51219
51286
  },
51287
+ /**
51288
+ * Extract watcher output variables from the screen
51289
+ */
51290
+ extractWatcherVariables() {
51291
+ const t = {};
51292
+ return (this.getWatchers() || []).forEach((r) => {
51293
+ if (!r.byPass) {
51294
+ r.output_variable && (t[r.output_variable] = null);
51295
+ try {
51296
+ const i = typeof r.script_configuration == "string" ? JSON.parse(r.script_configuration) : r.script_configuration;
51297
+ ((i == null ? void 0 : i.dataMapping) || []).forEach((a) => {
51298
+ a.key && (t[a.key] = null);
51299
+ });
51300
+ } catch {
51301
+ console.error("Invalid JSON in script_configuration for watcher:", r.name);
51302
+ }
51303
+ }
51304
+ }), t;
51305
+ },
51306
+ /**
51307
+ * Get watchers from various sources
51308
+ */
51309
+ getWatchers() {
51310
+ var t, e, r, i, a, n, s, o, u;
51311
+ return ((e = (t = this.$root) == null ? void 0 : t.$data) == null ? void 0 : e.watchers) || ((a = (i = (r = this.$root) == null ? void 0 : r.$children) == null ? void 0 : i[0]) == null ? void 0 : a.watchers) || ((u = (o = (s = (n = this.$root) == null ? void 0 : n.$children) == null ? void 0 : s[0]) == null ? void 0 : o.$data) == null ? void 0 : u.watchers) || [];
51312
+ },
51220
51313
  /**
51221
51314
  * Extract variables from form config
51222
51315
  * Recursively searches through all pages and items
@@ -51350,7 +51443,7 @@ var sre = function() {
51350
51443
  var e = this, r = e._self._c;
51351
51444
  return e.event === "submit" ? r("div", { staticClass: "variables-to-submit-wrapper" }, [e.isEnabled && e.missingRequiredVariables.length > 0 ? r("b-alert", { staticClass: "warning-alert", attrs: { show: "", variant: "warning", "data-cy": "missing-required-warning" } }, [r("i", { staticClass: "fas fa-bolt warning-icon" }), r("span", { staticClass: "warning-text" }, [e._v(" " + e._s(e.$t("The following required fields are not included")) + ' "'), r("strong", [e._v(e._s(e.missingRequiredVariables.join('", "')))]), e._v('". ' + e._s(e.$t("This may cause validation errors during submission.")) + " ")])]) : e._e(), r("div", { staticClass: "variables-to-submit-card" }, [r("div", { staticClass: "header-section" }, [r("h6", { staticClass: "header-title" }, [e._v(e._s(e.$t("Submit Information")))]), r("b-form-checkbox", { staticClass: "toggle-switch", attrs: { switch: "", size: "lg", "data-cy": "variables-to-submit-toggle" }, model: { value: e.isEnabled, callback: function(i) {
51352
51445
  e.isEnabled = i;
51353
- }, expression: "isEnabled" } })], 1), r("div", { staticClass: "description-text" }, [r("p", [e._v(e._s(e.$t("Select variables to submit, otherwise all variables will be submitted by default.")))])]), e.isEnabled && e.availableVariables.length === 0 ? r("div", { staticClass: "alert alert-info" }, [r("small", [e._v(e._s(e.$t("No variables available. Variables will be available after you add form fields to your screen.")))])]) : e.isEnabled ? r("div", [r("div", { staticClass: "divider" }), r("div", { staticClass: "controls-section" }, [r("button", { staticClass: "select-all-button", attrs: { type: "button", disabled: e.filteredVariables.length === 0 || e.selectedVariables.length === e.filteredVariables.length, "data-cy": "variables-to-submit-select-all" }, on: { click: e.selectAll } }, [e._v(" " + e._s(e.$t("Select All")) + " ")]), r("button", { staticClass: "search-button", attrs: { type: "button", "data-cy": "variables-to-submit-search-toggle" }, on: { click: e.toggleSearch } }, [r("i", { staticClass: "fas fa-search" })])]), e.showSearch ? r("div", { staticClass: "search-container" }, [r("b-input-group", [r("b-form-input", { staticClass: "search-input", attrs: { placeholder: e.$t("Search variables..."), "data-cy": "variables-to-submit-search" }, model: { value: e.searchQuery, callback: function(i) {
51446
+ }, expression: "isEnabled" } })], 1), r("div", { staticClass: "description-text" }, [r("p", [e._v(e._s(e.$t("Select variables to submit, otherwise all variables will be submitted by default.")))])]), e.isEnabled && e.availableVariables.length === 0 ? r("div", { staticClass: "alert alert-info" }, [r("small", [e._v(e._s(e.$t("No variables available. Variables will be available after you add form fields to your screen.")))])]) : e.isEnabled ? r("div", [r("div", { staticClass: "divider" }), r("div", { staticClass: "controls-section" }, [r("b-form-checkbox", { staticClass: "select-all-checkbox", attrs: { checked: e.allSelected, indeterminate: e.someSelected, disabled: e.filteredVariables.length === 0, "data-cy": "variables-to-submit-select-all" }, on: { change: e.toggleSelectAll } }, [e._v(" " + e._s(e.$t("Select All")) + " ")]), r("button", { staticClass: "search-button", attrs: { type: "button", "data-cy": "variables-to-submit-search-toggle" }, on: { click: e.toggleSearch } }, [r("i", { staticClass: "fas fa-search" })])], 1), e.showSearch ? r("div", { staticClass: "search-container" }, [r("b-input-group", [r("b-form-input", { staticClass: "search-input", attrs: { placeholder: e.$t("Search variables..."), "data-cy": "variables-to-submit-search" }, model: { value: e.searchQuery, callback: function(i) {
51354
51447
  e.searchQuery = i;
51355
51448
  }, expression: "searchQuery" } }), r("b-input-group-append", [r("b-button", { staticClass: "clear-search-button", attrs: { disabled: !e.searchQuery, "data-cy": "variables-to-submit-clear-search", variant: "outline-secondary" }, on: { click: function(i) {
51356
51449
  e.searchQuery = "";
@@ -51365,7 +51458,7 @@ var sre = function() {
51365
51458
  ore,
51366
51459
  !1,
51367
51460
  null,
51368
- "7e10d798",
51461
+ "33a2f6e8",
51369
51462
  null,
51370
51463
  null
51371
51464
  );