@visns-studio/visns-components 5.14.21 → 5.14.22
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
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
90
90
|
},
|
|
91
91
|
"name": "@visns-studio/visns-components",
|
|
92
|
-
"version": "5.14.
|
|
92
|
+
"version": "5.14.22",
|
|
93
93
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
94
94
|
"main": "src/index.js",
|
|
95
95
|
"files": [
|
|
@@ -748,6 +748,11 @@ function GenericDetail({
|
|
|
748
748
|
res.data[action.copyToClipboard]
|
|
749
749
|
);
|
|
750
750
|
}
|
|
751
|
+
|
|
752
|
+
// Reload data if the action should refresh the view
|
|
753
|
+
if (action.reloadData !== false) {
|
|
754
|
+
setDataReload(prev => !prev);
|
|
755
|
+
}
|
|
751
756
|
} else {
|
|
752
757
|
toast.error(res.data.error);
|
|
753
758
|
}
|
|
@@ -757,6 +762,27 @@ function GenericDetail({
|
|
|
757
762
|
}
|
|
758
763
|
};
|
|
759
764
|
|
|
765
|
+
const getActionLabel = (action) => {
|
|
766
|
+
// If dynamicLabel is defined, use it to determine the label based on data
|
|
767
|
+
if (action.dynamicLabel) {
|
|
768
|
+
const { dataKey, values } = action.dynamicLabel;
|
|
769
|
+
const dataValue = getNestedValue(data, dataKey);
|
|
770
|
+
|
|
771
|
+
// Find matching value configuration
|
|
772
|
+
const matchedConfig = values.find(config => config.condition === dataValue);
|
|
773
|
+
if (matchedConfig) {
|
|
774
|
+
return matchedConfig.label;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
// Fallback to static label
|
|
779
|
+
return action.label;
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
const getNestedValue = (obj, path) => {
|
|
783
|
+
return path.split('.').reduce((current, key) => current?.[key], obj);
|
|
784
|
+
};
|
|
785
|
+
|
|
760
786
|
const handleCheckboxUpdate = async () => {
|
|
761
787
|
try {
|
|
762
788
|
if (currentConfigRef.current.functions.checkboxUpdate) {
|
|
@@ -2881,6 +2907,18 @@ function GenericDetail({
|
|
|
2881
2907
|
}
|
|
2882
2908
|
</button>
|
|
2883
2909
|
)}
|
|
2910
|
+
|
|
2911
|
+
{activeTabConfig.customActions && Array.isArray(activeTabConfig.customActions) && activeTabConfig.customActions.map((customAction, index) => (
|
|
2912
|
+
<button
|
|
2913
|
+
key={index}
|
|
2914
|
+
className={styles.btn}
|
|
2915
|
+
onClick={() =>
|
|
2916
|
+
handleCustomAction(customAction)
|
|
2917
|
+
}
|
|
2918
|
+
>
|
|
2919
|
+
{getActionLabel(customAction)}
|
|
2920
|
+
</button>
|
|
2921
|
+
))}
|
|
2884
2922
|
</div>
|
|
2885
2923
|
)}
|
|
2886
2924
|
</>
|
|
@@ -3150,7 +3188,8 @@ function GenericDetail({
|
|
|
3150
3188
|
|
|
3151
3189
|
{(activeTabConfig.functions
|
|
3152
3190
|
?.checkboxDelete ||
|
|
3153
|
-
activeTabConfig.customAction
|
|
3191
|
+
activeTabConfig.customAction ||
|
|
3192
|
+
(activeTabConfig.customActions && activeTabConfig.customActions.length > 0)) && (
|
|
3154
3193
|
<div className={styles.polActions}>
|
|
3155
3194
|
{activeTabConfig.functions
|
|
3156
3195
|
?.checkboxDelete && (
|
|
@@ -3183,6 +3222,18 @@ function GenericDetail({
|
|
|
3183
3222
|
}
|
|
3184
3223
|
</button>
|
|
3185
3224
|
)}
|
|
3225
|
+
|
|
3226
|
+
{activeTabConfig.customActions && Array.isArray(activeTabConfig.customActions) && activeTabConfig.customActions.map((customAction, index) => (
|
|
3227
|
+
<button
|
|
3228
|
+
key={index}
|
|
3229
|
+
className={styles.btn}
|
|
3230
|
+
onClick={() =>
|
|
3231
|
+
handleCustomAction(customAction)
|
|
3232
|
+
}
|
|
3233
|
+
>
|
|
3234
|
+
{getActionLabel(customAction)}
|
|
3235
|
+
</button>
|
|
3236
|
+
))}
|
|
3186
3237
|
</div>
|
|
3187
3238
|
)}
|
|
3188
3239
|
</>
|