@visns-studio/visns-components 5.15.33 → 5.15.34

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/package.json CHANGED
@@ -94,7 +94,7 @@
94
94
  "react-dom": "^17.0.0 || ^18.0.0"
95
95
  },
96
96
  "name": "@visns-studio/visns-components",
97
- "version": "5.15.33",
97
+ "version": "5.15.34",
98
98
  "description": "Various packages to assist in the development of our Custom Applications.",
99
99
  "main": "src/index.js",
100
100
  "files": [
@@ -1734,29 +1734,56 @@ function Form({
1734
1734
  return acc;
1735
1735
  }, {});
1736
1736
 
1737
- const saveAnotherUrl = `${
1738
- saveAnother.url
1739
- }/${formData[saveAnother.dataKey]}`;
1740
- const resSaveAnother =
1741
- await CustomFetch(
1742
- saveAnotherUrl,
1743
- saveAnother.method,
1744
- processedData
1745
- );
1746
-
1747
- if (resSaveAnother.data.error === '') {
1748
- toast.success(saveAnother.message);
1737
+ // In bulk edit mode, call saveAnother for each row in the group
1738
+ if (bulkEditMode && bulkEditGroupData?.groupRowIds?.length) {
1739
+ let hasError = false;
1740
+ for (const rowId of bulkEditGroupData.groupRowIds) {
1741
+ const saveAnotherUrl = `${saveAnother.url}/${rowId}`;
1742
+ const resSaveAnother =
1743
+ await CustomFetch(
1744
+ saveAnotherUrl,
1745
+ saveAnother.method,
1746
+ processedData
1747
+ );
1748
+ if (resSaveAnother.data.error !== '') {
1749
+ hasError = true;
1750
+ }
1751
+ }
1752
+ if (!hasError) {
1753
+ toast.success(saveAnother.message);
1754
+ } else {
1755
+ saveAnotherFailed = true;
1756
+ }
1749
1757
  if (fetchTable) {
1750
1758
  const createdItem =
1751
1759
  res.data.data || res.data;
1752
1760
  fetchTable(createdItem);
1753
1761
  }
1754
1762
  } else {
1755
- saveAnotherFailed = true;
1756
- if (fetchTable) {
1757
- const createdItem =
1758
- res.data.data || res.data;
1759
- fetchTable(createdItem);
1763
+ const saveAnotherUrl = `${
1764
+ saveAnother.url
1765
+ }/${formData[saveAnother.dataKey]}`;
1766
+ const resSaveAnother =
1767
+ await CustomFetch(
1768
+ saveAnotherUrl,
1769
+ saveAnother.method,
1770
+ processedData
1771
+ );
1772
+
1773
+ if (resSaveAnother.data.error === '') {
1774
+ toast.success(saveAnother.message);
1775
+ if (fetchTable) {
1776
+ const createdItem =
1777
+ res.data.data || res.data;
1778
+ fetchTable(createdItem);
1779
+ }
1780
+ } else {
1781
+ saveAnotherFailed = true;
1782
+ if (fetchTable) {
1783
+ const createdItem =
1784
+ res.data.data || res.data;
1785
+ fetchTable(createdItem);
1786
+ }
1760
1787
  }
1761
1788
  }
1762
1789
  } else {
@@ -2204,6 +2231,24 @@ function Form({
2204
2231
 
2205
2232
  useEffect(() => {
2206
2233
  formSettings.fields.forEach((field) => {
2234
+ // showIfEmpty: only show field when its own value is empty/null/undefined/[]
2235
+ if (field.showIfEmpty) {
2236
+ const val = formData[field.id];
2237
+ const isEmpty =
2238
+ val === undefined ||
2239
+ val === null ||
2240
+ val === '' ||
2241
+ (Array.isArray(val) && val.length === 0);
2242
+ field.hide = !isEmpty;
2243
+
2244
+ if (updateForm) {
2245
+ updateForm((prevState) => ({
2246
+ ...prevState,
2247
+ fields: [...formSettings.fields],
2248
+ }));
2249
+ }
2250
+ }
2251
+
2207
2252
  const showConditions = field.show || [];
2208
2253
 
2209
2254
  showConditions.forEach((showObject) => {