@visns-studio/visns-components 2.9.8 → 2.9.9
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.
|
@@ -295,6 +295,18 @@ const DataGrid = forwardRef(
|
|
|
295
295
|
const handleSettingClick = (s, d) => {
|
|
296
296
|
switch (s.id) {
|
|
297
297
|
case 'delete':
|
|
298
|
+
const getDataId = () => {
|
|
299
|
+
for (const item of ajaxSetting.where) {
|
|
300
|
+
if (
|
|
301
|
+
item.hasOwnProperty('urlParam') &&
|
|
302
|
+
item.urlParam === 'dataId'
|
|
303
|
+
) {
|
|
304
|
+
return item.value;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return 0;
|
|
308
|
+
};
|
|
309
|
+
|
|
298
310
|
confirmAlert({
|
|
299
311
|
title: 'Delete Item',
|
|
300
312
|
message:
|
|
@@ -310,11 +322,33 @@ const DataGrid = forwardRef(
|
|
|
310
322
|
buttons: [
|
|
311
323
|
{
|
|
312
324
|
label: 'Yes',
|
|
313
|
-
onClick: () =>
|
|
325
|
+
onClick: () => {
|
|
326
|
+
let deleteForm = {
|
|
327
|
+
url: '',
|
|
328
|
+
method: 'DELETE',
|
|
329
|
+
payload: {},
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
if (
|
|
333
|
+
form.hasOwnProperty('json') &&
|
|
334
|
+
form.json === true
|
|
335
|
+
) {
|
|
336
|
+
deleteForm.url = `${form.url}/jsonDelete`;
|
|
337
|
+
deleteForm.method = 'POST';
|
|
338
|
+
deleteForm.payload = {
|
|
339
|
+
id: d[form.primaryKey],
|
|
340
|
+
dataId: getDataId(),
|
|
341
|
+
};
|
|
342
|
+
} else {
|
|
343
|
+
deleteForm.url = `${form.url}/${
|
|
344
|
+
d[form.primaryKey]
|
|
345
|
+
}`;
|
|
346
|
+
}
|
|
347
|
+
|
|
314
348
|
CustomFetch(
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
349
|
+
deleteForm.url,
|
|
350
|
+
deleteForm.method,
|
|
351
|
+
deleteForm.payload,
|
|
318
352
|
(result) => {
|
|
319
353
|
if (result.error === '') {
|
|
320
354
|
const min = 0;
|
|
@@ -338,7 +372,8 @@ const DataGrid = forwardRef(
|
|
|
338
372
|
);
|
|
339
373
|
}
|
|
340
374
|
}
|
|
341
|
-
)
|
|
375
|
+
);
|
|
376
|
+
},
|
|
342
377
|
},
|
|
343
378
|
{
|
|
344
379
|
label: 'No',
|
|
@@ -2030,6 +2065,7 @@ const DataGrid = forwardRef(
|
|
|
2030
2065
|
closeOnDocumentClick={false}
|
|
2031
2066
|
>
|
|
2032
2067
|
<Form
|
|
2068
|
+
ajaxSetting={ajaxSetting}
|
|
2033
2069
|
closeModal={modalClose}
|
|
2034
2070
|
columnId={formId}
|
|
2035
2071
|
fetchTable={handleReload}
|
package/components/crm/Form.jsx
CHANGED
|
@@ -12,6 +12,7 @@ import Field from './Field';
|
|
|
12
12
|
import Table from './DataGrid';
|
|
13
13
|
|
|
14
14
|
function Form({
|
|
15
|
+
ajaxSetting,
|
|
15
16
|
closeModal,
|
|
16
17
|
columnId,
|
|
17
18
|
formType,
|
|
@@ -441,11 +442,30 @@ function Form({
|
|
|
441
442
|
} else {
|
|
442
443
|
switch (formType) {
|
|
443
444
|
case 'create':
|
|
444
|
-
|
|
445
|
+
if (
|
|
446
|
+
formSettings.hasOwnProperty('json') &&
|
|
447
|
+
formSettings.json === true
|
|
448
|
+
) {
|
|
449
|
+
url += '/jsonStore';
|
|
450
|
+
}
|
|
445
451
|
break;
|
|
446
452
|
case 'update':
|
|
447
453
|
case 'delete':
|
|
448
|
-
|
|
454
|
+
if (
|
|
455
|
+
formSettings.hasOwnProperty('json') &&
|
|
456
|
+
formSettings.json === true
|
|
457
|
+
) {
|
|
458
|
+
if (formType === 'update') {
|
|
459
|
+
url += `/jsonUpdate`;
|
|
460
|
+
} else {
|
|
461
|
+
url += `/jsonDelete/${
|
|
462
|
+
formData[formSettings.primaryKey]
|
|
463
|
+
}`;
|
|
464
|
+
}
|
|
465
|
+
} else {
|
|
466
|
+
url += `/${formData[formSettings.primaryKey]}`;
|
|
467
|
+
}
|
|
468
|
+
|
|
449
469
|
method = formType === 'update' ? 'PUT' : 'DELETE';
|
|
450
470
|
break;
|
|
451
471
|
}
|
|
@@ -578,11 +598,40 @@ function Form({
|
|
|
578
598
|
|
|
579
599
|
if (formType !== 'create' && columnId > 0) {
|
|
580
600
|
try {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
601
|
+
let urlSuffix,
|
|
602
|
+
method,
|
|
603
|
+
payload = {};
|
|
604
|
+
|
|
605
|
+
// Function to extract dataId from ajaxSetting
|
|
606
|
+
const getDataId = () => {
|
|
607
|
+
for (const item of ajaxSetting.where) {
|
|
608
|
+
if (
|
|
609
|
+
item.hasOwnProperty('urlParam') &&
|
|
610
|
+
item.urlParam === 'dataId'
|
|
611
|
+
) {
|
|
612
|
+
return item.value;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return 0;
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
if (
|
|
619
|
+
formSettings.hasOwnProperty('json') &&
|
|
620
|
+
formSettings.json === true
|
|
621
|
+
) {
|
|
622
|
+
let dataId = getDataId();
|
|
623
|
+
|
|
624
|
+
urlSuffix = '/jsonGet';
|
|
625
|
+
method = 'POST';
|
|
626
|
+
payload = { id: columnId, dataId };
|
|
627
|
+
} else {
|
|
628
|
+
urlSuffix = `/${columnId}`;
|
|
629
|
+
method = 'GET';
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
const url = `${formSettings.url}${urlSuffix}`;
|
|
633
|
+
const result = await CustomFetch(url, method, payload);
|
|
634
|
+
|
|
586
635
|
const data = result.hasOwnProperty('data')
|
|
587
636
|
? result.data
|
|
588
637
|
: result;
|
|
@@ -713,8 +713,7 @@ function GenericDetail({ setting, urlParam, userProfile }) {
|
|
|
713
713
|
case 'table':
|
|
714
714
|
if (
|
|
715
715
|
activeTabConfig.ajaxSetting &&
|
|
716
|
-
activeTabConfig.ajaxSetting.where
|
|
717
|
-
activeTabConfig.ajaxSetting.where.length > 0
|
|
716
|
+
activeTabConfig.ajaxSetting.where
|
|
718
717
|
) {
|
|
719
718
|
const updatedAjaxSetting = {
|
|
720
719
|
...activeTabConfig.ajaxSetting,
|
package/package.json
CHANGED