@visns-studio/visns-components 4.9.11 → 4.10.0
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
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
76
76
|
},
|
|
77
77
|
"name": "@visns-studio/visns-components",
|
|
78
|
-
"version": "4.
|
|
78
|
+
"version": "4.10.0",
|
|
79
79
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
80
80
|
"main": "src/index.js",
|
|
81
81
|
"files": [
|
|
@@ -204,7 +204,7 @@ function Form({
|
|
|
204
204
|
}
|
|
205
205
|
};
|
|
206
206
|
|
|
207
|
-
const handleChangeSelect = (inputValue, action, id) => {
|
|
207
|
+
const handleChangeSelect = async (inputValue, action, id) => {
|
|
208
208
|
const updateFormData = (update) => {
|
|
209
209
|
setFormData((prevState) => ({
|
|
210
210
|
...prevState,
|
|
@@ -212,59 +212,82 @@ function Form({
|
|
|
212
212
|
}));
|
|
213
213
|
};
|
|
214
214
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
const handleSelectOption = () => {
|
|
216
|
+
updateFormData({ [id]: inputValue });
|
|
217
|
+
|
|
218
|
+
// Update any matching form data properties
|
|
219
|
+
Object.keys(inputValue).forEach((key) => {
|
|
220
|
+
if (formData.hasOwnProperty(key)) {
|
|
221
|
+
updateFormData({ [key]: inputValue[key] });
|
|
222
|
+
}
|
|
223
|
+
});
|
|
218
224
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
225
|
+
formSettings.fields.forEach((field) => {
|
|
226
|
+
if (field.id === id && field.trigger) {
|
|
227
|
+
switch (field.trigger.type) {
|
|
228
|
+
case 'addDays':
|
|
229
|
+
handleAddDaysTrigger(inputValue, field);
|
|
230
|
+
break;
|
|
231
|
+
case 'setContent':
|
|
232
|
+
handleSetContentTrigger(inputValue, field);
|
|
233
|
+
break;
|
|
222
234
|
}
|
|
223
|
-
}
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
};
|
|
224
238
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
case 'addDays':
|
|
229
|
-
let newDate = moment();
|
|
230
|
-
let add = false;
|
|
239
|
+
const handleAddDaysTrigger = (inputValue, field) => {
|
|
240
|
+
let newDate = moment();
|
|
241
|
+
let add = false;
|
|
231
242
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
);
|
|
240
|
-
add = true;
|
|
241
|
-
}
|
|
243
|
+
if (
|
|
244
|
+
inputValue.no_of_days &&
|
|
245
|
+
parseFloat(inputValue.no_of_days) > 0
|
|
246
|
+
) {
|
|
247
|
+
newDate.add(parseFloat(inputValue.no_of_days), 'days');
|
|
248
|
+
add = true;
|
|
249
|
+
}
|
|
242
250
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
);
|
|
251
|
-
add = true;
|
|
252
|
-
}
|
|
251
|
+
if (
|
|
252
|
+
inputValue.no_of_hours &&
|
|
253
|
+
parseFloat(inputValue.no_of_hours) > 0
|
|
254
|
+
) {
|
|
255
|
+
newDate.add(parseFloat(inputValue.no_of_hours), 'hours');
|
|
256
|
+
add = true;
|
|
257
|
+
}
|
|
253
258
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
259
|
+
if (add) {
|
|
260
|
+
updateFormData({
|
|
261
|
+
[field.trigger.id]: newDate.toDate(),
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const handleSetContentTrigger = async (inputValue, field) => {
|
|
267
|
+
let contentValue = inputValue[field.trigger.key];
|
|
268
|
+
|
|
269
|
+
if (field.trigger.url && field.trigger.payload) {
|
|
270
|
+
const res = await CustomFetch(field.trigger.url, 'POST', {
|
|
271
|
+
[field.trigger.payload.key.id]:
|
|
272
|
+
inputValue[field.trigger.payload.value.id],
|
|
273
|
+
[field.trigger.payload.key.content]:
|
|
274
|
+
inputValue[field.trigger.payload.value.content],
|
|
267
275
|
});
|
|
276
|
+
|
|
277
|
+
if (res.data.content) {
|
|
278
|
+
contentValue = res.data.content;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
updateFormData({
|
|
283
|
+
[field.trigger.id]: contentValue,
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
// Switch cases to handle different actions
|
|
288
|
+
switch (action.action) {
|
|
289
|
+
case 'select-option':
|
|
290
|
+
handleSelectOption();
|
|
268
291
|
break;
|
|
269
292
|
case 'clear':
|
|
270
293
|
updateFormData({ [id]: '' });
|
|
@@ -27,6 +27,7 @@ import CustomFetch from '../Fetch';
|
|
|
27
27
|
import Form from '../Form';
|
|
28
28
|
import GenericDynamic from './GenericDynamic';
|
|
29
29
|
import QrCode from '../QrCode';
|
|
30
|
+
import SortableList from '../sorting/List';
|
|
30
31
|
import Table from '../DataGrid';
|
|
31
32
|
import TableFilter from '../TableFilter';
|
|
32
33
|
|
|
@@ -401,14 +402,14 @@ function GenericDetail({
|
|
|
401
402
|
return renderLatestNotes();
|
|
402
403
|
case 'options':
|
|
403
404
|
return renderOptions();
|
|
404
|
-
case 'richtext':
|
|
405
|
-
return renderRichText();
|
|
406
|
-
case 'total':
|
|
407
|
-
return renderTotal();
|
|
408
405
|
case 'password':
|
|
409
406
|
return renderPassword();
|
|
410
407
|
case 'relation':
|
|
411
408
|
return renderRelation();
|
|
409
|
+
case 'richtext':
|
|
410
|
+
return renderRichText();
|
|
411
|
+
case 'total':
|
|
412
|
+
return renderTotal();
|
|
412
413
|
default:
|
|
413
414
|
return size === 'full' && truncatedValue
|
|
414
415
|
? parse(`<br /><p>${truncatedValue}</p>`)
|
|
@@ -952,6 +953,7 @@ function GenericDetail({
|
|
|
952
953
|
)
|
|
953
954
|
)}
|
|
954
955
|
</div>
|
|
956
|
+
|
|
955
957
|
{activeTabConfig.form && (
|
|
956
958
|
<div className={styles.polActions}>
|
|
957
959
|
<button
|
|
@@ -1610,9 +1610,9 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
|
|
|
1610
1610
|
dataField.type ===
|
|
1611
1611
|
'table_text'
|
|
1612
1612
|
) {
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1613
|
+
excludedKeywords.push(
|
|
1614
|
+
'checkbox'
|
|
1615
|
+
);
|
|
1616
1616
|
}
|
|
1617
1617
|
return !excludedKeywords.some(
|
|
1618
1618
|
(
|