@visns-studio/visns-components 5.10.4 → 5.10.6

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
@@ -87,7 +87,7 @@
87
87
  "react-dom": "^17.0.0 || ^18.0.0"
88
88
  },
89
89
  "name": "@visns-studio/visns-components",
90
- "version": "5.10.4",
90
+ "version": "5.10.6",
91
91
  "description": "Various packages to assist in the development of our Custom Applications.",
92
92
  "main": "src/index.js",
93
93
  "files": [
@@ -3027,11 +3027,18 @@ const DataGrid = forwardRef(
3027
3027
  <>
3028
3028
  {/* Top container with search, action buttons, and auto-refresh */}
3029
3029
  {/* Only show top container if there are controls to display */}
3030
- {(!form.searchDisable ||
3031
- !form.createDisable ||
3032
- (!shouldRelocateAutoRefresh() &&
3033
- ajaxSetting &&
3034
- ajaxSetting.autoRefresh !== undefined)) && (
3030
+ {(() => {
3031
+ const hasSearchOrCreate = !form.searchDisable || !form.createDisable;
3032
+ const hasAutoRefresh = !shouldRelocateAutoRefresh() && ajaxSetting && ajaxSetting.autoRefresh !== undefined;
3033
+
3034
+ // If DataGridSearch would return null (both search and create disabled),
3035
+ // only show container if there are other controls besides auto-refresh
3036
+ if (form.searchDisable === true && form.createDisable === true) {
3037
+ return false; // Hide AutoRefreshControls when it would be the only control
3038
+ }
3039
+
3040
+ return hasSearchOrCreate || hasAutoRefresh;
3041
+ })() && (
3035
3042
  <div className={styles.dataGridTopContainer}>
3036
3043
  <div className={styles.dataGridTopLeftContainer}>
3037
3044
  <DataGridSearch
@@ -819,11 +819,12 @@ function Form({
819
819
  : null;
820
820
 
821
821
  // Check if formData[item.id] is null, undefined, or an empty string AND there's no auto value
822
- if (!formData[item.id] && !autoValue) {
822
+ // Note: 0 is considered a valid value for dropdowns/options
823
+ if ((formData[item.id] === null || formData[item.id] === undefined || formData[item.id] === '') && !autoValue) {
823
824
  // Check for required_check dependency
824
825
  if (
825
826
  item.required_check &&
826
- !formData[item.required_check]
827
+ (formData[item.required_check] === null || formData[item.required_check] === undefined || formData[item.required_check] === '')
827
828
  ) {
828
829
  validation += `${item.label} is a required field.<br/>`;
829
830
  _inputClass[item.id] = styles.inputError;
@@ -837,7 +838,7 @@ function Form({
837
838
  } else if (
838
839
  item.required_rely &&
839
840
  formData[item.required_rely] &&
840
- !formData[item.id]
841
+ (formData[item.id] === null || formData[item.id] === undefined || formData[item.id] === '')
841
842
  ) {
842
843
  // Check if the dependent required field is empty when it should be filled
843
844
  validation += `${item.label} is a required field.<br/>`;
@@ -1740,10 +1740,43 @@ function GenericIndex({
1740
1740
 
1741
1741
  const date = moment().format('YYYYMMDD');
1742
1742
 
1743
+ // Process the export payload
1744
+ let payload = {};
1745
+ if (config.export.payload) {
1746
+ payload = { ...config.export.payload };
1747
+
1748
+ // Process special values in the payload
1749
+ Object.keys(payload).forEach(key => {
1750
+ if (payload[key] === 'currentActive()') {
1751
+ // Get the current active filter value
1752
+ const activeFilter = subnav?.find(filter => {
1753
+ if (filter.isParent) {
1754
+ return filter.children && filter.children.some(child => child.show);
1755
+ }
1756
+ return filter.show === true;
1757
+ });
1758
+
1759
+ if (activeFilter) {
1760
+ if (activeFilter.isParent && activeFilter.children && activeFilter.children.length > 0) {
1761
+ // If it's a parent filter, get the active child's value
1762
+ const activeChild = activeFilter.children.find(child => child.show);
1763
+ payload[key] = activeChild ? activeChild.value || activeChild.id : '';
1764
+ } else {
1765
+ // For non-parent filters, use the filter's value or id
1766
+ payload[key] = activeFilter.value || activeFilter.id;
1767
+ }
1768
+ } else {
1769
+ // If no active filter is found, set to empty string
1770
+ payload[key] = '';
1771
+ }
1772
+ }
1773
+ });
1774
+ }
1775
+
1743
1776
  const res = await Download(
1744
1777
  config.export.url,
1745
1778
  config.export.method,
1746
- {}
1779
+ payload
1747
1780
  );
1748
1781
 
1749
1782
  if (res.data.error) {