@visns-studio/visns-components 5.4.13 → 5.4.15

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
@@ -81,7 +81,7 @@
81
81
  "react-dom": "^17.0.0 || ^18.0.0"
82
82
  },
83
83
  "name": "@visns-studio/visns-components",
84
- "version": "5.4.13",
84
+ "version": "5.4.15",
85
85
  "description": "Various packages to assist in the development of our Custom Applications.",
86
86
  "main": "src/index.js",
87
87
  "files": [
@@ -15,6 +15,44 @@ function Breadcrumb({ data, page }) {
15
15
  : data[keys];
16
16
  };
17
17
 
18
+ // Function to evaluate condition for displaying image
19
+ const evaluateCondition = (condition) => {
20
+ if (!condition || !Array.isArray(condition) || condition.length === 0) {
21
+ return false;
22
+ }
23
+
24
+ return condition.every((cond) => {
25
+ if (!cond.id || !cond.value || !cond.operator || !data[cond.id]) {
26
+ return false;
27
+ }
28
+
29
+ const fieldValue = data[cond.id];
30
+ const condValue = cond.value;
31
+
32
+ switch (cond.operator) {
33
+ case 'eq': // equals
34
+ return fieldValue === condValue;
35
+ case 'neq': // not equals
36
+ return fieldValue !== condValue;
37
+ case 'gt': // greater than
38
+ return parseFloat(fieldValue) > parseFloat(condValue);
39
+ case 'gte': // greater than or equal
40
+ return parseFloat(fieldValue) >= parseFloat(condValue);
41
+ case 'lt': // less than
42
+ return parseFloat(fieldValue) < parseFloat(condValue);
43
+ case 'lte': // less than or equal
44
+ return parseFloat(fieldValue) <= parseFloat(condValue);
45
+ default:
46
+ return false;
47
+ }
48
+ });
49
+ };
50
+
51
+ // Check if image should be displayed based on condition
52
+ const shouldDisplayImage = page?.image?.condition
53
+ ? evaluateCondition(page.image.condition)
54
+ : false;
55
+
18
56
  // Get the nested data for parent title key if it exists
19
57
  const nestedData =
20
58
  data && page.parentTitleKey
@@ -102,6 +140,21 @@ function Breadcrumb({ data, page }) {
102
140
  )}
103
141
  </>
104
142
  )}
143
+
144
+ {/* Display image if condition is met */}
145
+ {shouldDisplayImage && page?.image?.url && (
146
+ <img
147
+ src={page.image.url}
148
+ alt="Verification Badge"
149
+ style={{
150
+ marginLeft: '12px',
151
+ height: '30px',
152
+ width: 'auto',
153
+ verticalAlign: 'middle',
154
+ filter: 'drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2))',
155
+ }}
156
+ />
157
+ )}
105
158
  </h1>
106
159
  );
107
160
  }
@@ -2226,19 +2226,41 @@ function GenericDetail({
2226
2226
  </div>
2227
2227
  )}
2228
2228
 
2229
- {activeTabConfig.functions
2230
- ?.checkboxDelete && (
2229
+ {(activeTabConfig.functions
2230
+ ?.checkboxDelete ||
2231
+ activeTabConfig.customAction) && (
2231
2232
  <div className={styles.polActions}>
2232
- <button
2233
- className={styles.btn}
2234
- onClick={
2235
- handleCheckboxDelete
2236
- }
2237
- >
2238
- {activeTabConfig.functions
2239
- .checkboxDelete.label ||
2240
- 'Delete'}
2241
- </button>
2233
+ {activeTabConfig.functions
2234
+ ?.checkboxDelete && (
2235
+ <button
2236
+ className={styles.btn}
2237
+ onClick={
2238
+ handleCheckboxDelete
2239
+ }
2240
+ >
2241
+ {activeTabConfig
2242
+ .functions
2243
+ .checkboxDelete
2244
+ .label || 'Delete'}
2245
+ </button>
2246
+ )}
2247
+
2248
+ {activeTabConfig.customAction && (
2249
+ <button
2250
+ className={styles.btn}
2251
+ onClick={() =>
2252
+ handleCustomAction(
2253
+ activeTabConfig.customAction
2254
+ )
2255
+ }
2256
+ >
2257
+ {
2258
+ activeTabConfig
2259
+ .customAction
2260
+ .label
2261
+ }
2262
+ </button>
2263
+ )}
2242
2264
  </div>
2243
2265
  )}
2244
2266
  </>