@visns-studio/visns-components 3.7.8 → 3.7.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.
- package/components/crm/DataGrid.jsx +1186 -1061
- package/components/crm/Field.jsx +1 -0
- package/components/crm/Form.jsx +23 -16
- package/components/crm/auth/Profile.jsx +0 -1
- package/components/crm/generic/GenericDashboard.jsx +42 -0
- package/components/crm/generic/GenericDetail.jsx +141 -49
- package/components/crm/generic/GenericIndex.jsx +0 -3
- package/package.json +5 -1
|
@@ -179,7 +179,6 @@ const DataGrid = forwardRef(
|
|
|
179
179
|
},
|
|
180
180
|
[ajaxSetting, dataReload, dSearch]
|
|
181
181
|
);
|
|
182
|
-
const [dropdownData, setDropdownData] = useState({});
|
|
183
182
|
const [filterDataSource, setFilterDataSource] = useState([]);
|
|
184
183
|
const [filterValue, setFilterValue] = useState([]);
|
|
185
184
|
const [gridColumns, setGridColumns] = useState([]);
|
|
@@ -1052,24 +1051,6 @@ const DataGrid = forwardRef(
|
|
|
1052
1051
|
[]
|
|
1053
1052
|
);
|
|
1054
1053
|
|
|
1055
|
-
const getDropdownData = async (id, url, fields) => {
|
|
1056
|
-
try {
|
|
1057
|
-
// Check if the data for the given id already exists
|
|
1058
|
-
if (!dropdownData[id]) {
|
|
1059
|
-
const res = await CustomFetch(url, 'POST', {
|
|
1060
|
-
fields: fields,
|
|
1061
|
-
});
|
|
1062
|
-
|
|
1063
|
-
setDropdownData((prevState) => ({
|
|
1064
|
-
...prevState,
|
|
1065
|
-
[id]: res.data.data,
|
|
1066
|
-
}));
|
|
1067
|
-
}
|
|
1068
|
-
} catch (err) {
|
|
1069
|
-
console.error(err);
|
|
1070
|
-
}
|
|
1071
|
-
};
|
|
1072
|
-
|
|
1073
1054
|
const handleDropdownUpdate = async (id, url, method, value) => {
|
|
1074
1055
|
try {
|
|
1075
1056
|
const res = await CustomFetch(url, method, {
|
|
@@ -1092,1128 +1073,1271 @@ const DataGrid = forwardRef(
|
|
|
1092
1073
|
}
|
|
1093
1074
|
};
|
|
1094
1075
|
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1076
|
+
const getDropdownData = async (ids, url, fields) => {
|
|
1077
|
+
// Concatenate id array into a single string if it's an array
|
|
1078
|
+
const uniqueId = Array.isArray(ids) ? ids.join('') : ids;
|
|
1079
|
+
|
|
1080
|
+
// Return a promise that includes the concatenated uniqueId in the resolution
|
|
1081
|
+
return new Promise(async (resolve, reject) => {
|
|
1082
|
+
try {
|
|
1083
|
+
const res = await CustomFetch(url, 'POST', { fields });
|
|
1084
|
+
resolve({ [uniqueId]: res.data.data }); // Correctly use uniqueId as the key
|
|
1085
|
+
} catch (err) {
|
|
1086
|
+
console.error(err);
|
|
1087
|
+
reject(err); // Reject the promise if there's an error
|
|
1101
1088
|
}
|
|
1102
1089
|
});
|
|
1103
|
-
}
|
|
1090
|
+
};
|
|
1104
1091
|
|
|
1105
1092
|
useEffect(() => {
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
let fileUrl = null;
|
|
1112
|
-
let icons = [];
|
|
1113
|
-
let relationName;
|
|
1114
|
-
let selectedDataSource = null;
|
|
1115
|
-
let stage;
|
|
1116
|
-
let columnStyle;
|
|
1117
|
-
let value;
|
|
1118
|
-
|
|
1119
|
-
const commonProps = {
|
|
1120
|
-
header: column.label,
|
|
1121
|
-
defaultFlex: 1,
|
|
1122
|
-
link: column.link ?? {},
|
|
1123
|
-
minWidth: column.minWidth ?? undefined,
|
|
1124
|
-
maxWidth: column.maxWidth ?? undefined,
|
|
1125
|
-
textAlign: column.textAlign ?? undefined,
|
|
1126
|
-
textVerticalAlign:
|
|
1127
|
-
style && style.text_vertical_align
|
|
1128
|
-
? style.text_vertical_align
|
|
1129
|
-
: 'center',
|
|
1130
|
-
style: (cellProps) => {
|
|
1131
|
-
const { id, value } = cellProps;
|
|
1132
|
-
let columnStyle = {};
|
|
1133
|
-
|
|
1134
|
-
if (
|
|
1135
|
-
column.styleCondition &&
|
|
1136
|
-
column.styleCondition.key
|
|
1137
|
-
) {
|
|
1138
|
-
if (value) {
|
|
1139
|
-
columnStyle = {
|
|
1140
|
-
...(column.style ?? {}),
|
|
1141
|
-
margin: '0px',
|
|
1142
|
-
};
|
|
1143
|
-
}
|
|
1144
|
-
} else {
|
|
1145
|
-
columnStyle = {
|
|
1146
|
-
...(column.style ?? {}),
|
|
1147
|
-
margin: '0px',
|
|
1148
|
-
};
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
return columnStyle;
|
|
1152
|
-
},
|
|
1153
|
-
type: column.type,
|
|
1154
|
-
};
|
|
1093
|
+
const dropdownFetches = columns
|
|
1094
|
+
.filter((column) => column.type === 'dropdown')
|
|
1095
|
+
.map((column) =>
|
|
1096
|
+
getDropdownData(column.id, column.url, column.fields)
|
|
1097
|
+
);
|
|
1155
1098
|
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1099
|
+
Promise.all(dropdownFetches)
|
|
1100
|
+
.then((results) => {
|
|
1101
|
+
// Merge all resolved objects into a single object
|
|
1102
|
+
const dropdownData = results.reduce((acc, result) => {
|
|
1103
|
+
return { ...acc, ...result };
|
|
1104
|
+
}, {});
|
|
1105
|
+
|
|
1106
|
+
const renderColumn = (column) => {
|
|
1107
|
+
let childValue;
|
|
1108
|
+
let columnId;
|
|
1109
|
+
let date;
|
|
1110
|
+
let filterEditor = null;
|
|
1111
|
+
let filterEditorProps = null;
|
|
1112
|
+
let fileUrl = null;
|
|
1113
|
+
let icons = [];
|
|
1114
|
+
let relationName;
|
|
1115
|
+
let selectedDataSource = null;
|
|
1116
|
+
let stage;
|
|
1117
|
+
let columnStyle;
|
|
1118
|
+
let value;
|
|
1119
|
+
|
|
1120
|
+
const commonProps = {
|
|
1121
|
+
header: column.label,
|
|
1122
|
+
defaultFlex: 1,
|
|
1123
|
+
link: column.link ?? {},
|
|
1124
|
+
minWidth: column.minWidth ?? undefined,
|
|
1125
|
+
maxWidth: column.maxWidth ?? undefined,
|
|
1126
|
+
textAlign: column.textAlign ?? undefined,
|
|
1127
|
+
textVerticalAlign:
|
|
1128
|
+
style && style.text_vertical_align
|
|
1129
|
+
? style.text_vertical_align
|
|
1130
|
+
: 'center',
|
|
1131
|
+
style: (cellProps) => {
|
|
1132
|
+
const { id, value } = cellProps;
|
|
1133
|
+
let columnStyle = {};
|
|
1164
1134
|
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1135
|
+
if (
|
|
1136
|
+
column.styleCondition &&
|
|
1137
|
+
column.styleCondition.key
|
|
1138
|
+
) {
|
|
1139
|
+
if (value) {
|
|
1140
|
+
columnStyle = {
|
|
1141
|
+
...(column.style ?? {}),
|
|
1142
|
+
margin: '0px',
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
} else {
|
|
1146
|
+
columnStyle = {
|
|
1147
|
+
...(column.style ?? {}),
|
|
1148
|
+
margin: '0px',
|
|
1149
|
+
};
|
|
1180
1150
|
}
|
|
1181
|
-
|
|
1151
|
+
|
|
1152
|
+
return columnStyle;
|
|
1182
1153
|
},
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
break;
|
|
1186
|
-
}
|
|
1154
|
+
type: column.type,
|
|
1155
|
+
};
|
|
1187
1156
|
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1157
|
+
switch (column.type) {
|
|
1158
|
+
case 'relation':
|
|
1159
|
+
case 'relationArray':
|
|
1160
|
+
relationName = column.id.reduce(
|
|
1161
|
+
(acc, id) => acc + `${id}.`,
|
|
1162
|
+
''
|
|
1163
|
+
);
|
|
1164
|
+
relationName += column.nameFrom;
|
|
1165
|
+
|
|
1166
|
+
selectedDataSource = filterDataSource.reduce(
|
|
1167
|
+
(acc, fds) => {
|
|
1168
|
+
if (fds.id === relationName) {
|
|
1169
|
+
return fds.dataset;
|
|
1170
|
+
}
|
|
1171
|
+
return acc;
|
|
1172
|
+
},
|
|
1173
|
+
null
|
|
1174
|
+
);
|
|
1175
|
+
break;
|
|
1176
|
+
default:
|
|
1177
|
+
selectedDataSource = filterDataSource.reduce(
|
|
1178
|
+
(acc, fds) => {
|
|
1179
|
+
if (fds.id === column.id) {
|
|
1180
|
+
return fds.dataset;
|
|
1181
|
+
}
|
|
1182
|
+
return acc;
|
|
1183
|
+
},
|
|
1184
|
+
null
|
|
1185
|
+
);
|
|
1186
|
+
break;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
if (column.filter && column.filter.type) {
|
|
1190
|
+
switch (column.filter.type) {
|
|
1191
|
+
case 'date':
|
|
1192
|
+
filterEditor = DateFilter;
|
|
1193
|
+
filterEditorProps = (props, { index }) => {
|
|
1194
|
+
return {
|
|
1195
|
+
dateFormat: 'DD-MM-YYYY',
|
|
1196
|
+
placeholder: column.filter
|
|
1197
|
+
.placeholder
|
|
1198
|
+
? column.filter.placeholder
|
|
1199
|
+
: 'Select Date',
|
|
1200
|
+
};
|
|
1201
|
+
};
|
|
1202
|
+
break;
|
|
1203
|
+
case 'number':
|
|
1204
|
+
filterEditor = NumberFilter;
|
|
1205
|
+
break;
|
|
1206
|
+
case 'select':
|
|
1207
|
+
filterEditor = SelectFilter;
|
|
1208
|
+
filterEditorProps = {
|
|
1209
|
+
multiple:
|
|
1210
|
+
column.filter.operator === 'inlist',
|
|
1211
|
+
wrapMultiple:
|
|
1212
|
+
column.filter.operator !== 'inlist',
|
|
1213
|
+
placeholder: column.filter.placeholder
|
|
1214
|
+
? column.filter.placeholder
|
|
1215
|
+
: 'All Options',
|
|
1216
|
+
dataSource: selectedDataSource,
|
|
1217
|
+
};
|
|
1218
|
+
break;
|
|
1219
|
+
default:
|
|
1220
|
+
filterEditor = null;
|
|
1221
|
+
filterEditorProps = null;
|
|
1222
|
+
break;
|
|
1223
|
+
}
|
|
1224
|
+
} else {
|
|
1217
1225
|
filterEditor = null;
|
|
1218
1226
|
filterEditorProps = null;
|
|
1219
|
-
|
|
1220
|
-
}
|
|
1221
|
-
} else {
|
|
1222
|
-
filterEditor = null;
|
|
1223
|
-
filterEditorProps = null;
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1226
|
-
switch (column.type) {
|
|
1227
|
-
case 'address':
|
|
1228
|
-
return {
|
|
1229
|
-
...commonProps,
|
|
1230
|
-
name: `${column.type}.${column.id}`,
|
|
1231
|
-
filterEditor: filterEditor,
|
|
1232
|
-
filterEditorProps: filterEditorProps,
|
|
1233
|
-
render: ({ data }) => {
|
|
1234
|
-
const addressFields = [
|
|
1235
|
-
'address1',
|
|
1236
|
-
'address2',
|
|
1237
|
-
'suburb',
|
|
1238
|
-
'postcode',
|
|
1239
|
-
];
|
|
1227
|
+
}
|
|
1240
1228
|
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1229
|
+
switch (column.type) {
|
|
1230
|
+
case 'address':
|
|
1231
|
+
return {
|
|
1232
|
+
...commonProps,
|
|
1233
|
+
name: `${column.type}.${column.id}`,
|
|
1234
|
+
filterEditor: filterEditor,
|
|
1235
|
+
filterEditorProps: filterEditorProps,
|
|
1236
|
+
render: ({ data }) => {
|
|
1237
|
+
const addressFields = [
|
|
1238
|
+
'address1',
|
|
1239
|
+
'address2',
|
|
1240
|
+
'suburb',
|
|
1241
|
+
'postcode',
|
|
1242
|
+
];
|
|
1243
|
+
|
|
1244
|
+
const addressValue = addressFields
|
|
1245
|
+
.filter((field) => data[field])
|
|
1246
|
+
.map((field) => data[field])
|
|
1247
|
+
.join(' ');
|
|
1245
1248
|
|
|
1246
|
-
|
|
1247
|
-
|
|
1249
|
+
const stateValue =
|
|
1250
|
+
data.state?.name ||
|
|
1251
|
+
data.state ||
|
|
1252
|
+
'';
|
|
1248
1253
|
|
|
1249
|
-
|
|
1254
|
+
const value = `${addressValue} ${stateValue}`;
|
|
1250
1255
|
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
data
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1256
|
+
return <span>{value}</span>;
|
|
1257
|
+
},
|
|
1258
|
+
};
|
|
1259
|
+
case 'age':
|
|
1260
|
+
return {
|
|
1261
|
+
...commonProps,
|
|
1262
|
+
type: 'number',
|
|
1263
|
+
filterEditor: filterEditor,
|
|
1264
|
+
name: `${column.type}.${column.id}`,
|
|
1265
|
+
render: ({ data }) => {
|
|
1266
|
+
value = column.id.reduce((acc, id) => {
|
|
1267
|
+
if (acc === '') {
|
|
1268
|
+
return data[id];
|
|
1269
|
+
} else {
|
|
1270
|
+
return acc ? acc[id] : '';
|
|
1271
|
+
}
|
|
1272
|
+
}, '');
|
|
1273
|
+
|
|
1274
|
+
if (value !== '' && value !== null) {
|
|
1275
|
+
date = moment(value);
|
|
1276
|
+
|
|
1277
|
+
return (
|
|
1278
|
+
<span>
|
|
1279
|
+
{moment().diff(
|
|
1280
|
+
date,
|
|
1281
|
+
column.duration
|
|
1282
|
+
? column.duration
|
|
1283
|
+
: 'years'
|
|
1284
|
+
)}
|
|
1285
|
+
</span>
|
|
1286
|
+
);
|
|
1287
|
+
} else {
|
|
1288
|
+
return null;
|
|
1289
|
+
}
|
|
1290
|
+
},
|
|
1291
|
+
};
|
|
1292
|
+
case 'arrayCount':
|
|
1293
|
+
return {
|
|
1294
|
+
...commonProps,
|
|
1295
|
+
name: `${column.type}.${column.id}`,
|
|
1296
|
+
sortable: false,
|
|
1297
|
+
render: ({ data }) => {
|
|
1298
|
+
if (data && data[column.id]) {
|
|
1299
|
+
return data[column.id].length;
|
|
1300
|
+
} else {
|
|
1301
|
+
return null;
|
|
1302
|
+
}
|
|
1303
|
+
},
|
|
1304
|
+
};
|
|
1305
|
+
case 'boolean':
|
|
1306
|
+
return {
|
|
1307
|
+
...commonProps,
|
|
1308
|
+
name: `${column.type}.${column.id}`,
|
|
1309
|
+
sortable: false,
|
|
1310
|
+
render: ({ data }) => {
|
|
1311
|
+
if (data[column.id]) {
|
|
1312
|
+
return 'Yes';
|
|
1313
|
+
} else {
|
|
1314
|
+
return 'No';
|
|
1315
|
+
}
|
|
1316
|
+
},
|
|
1317
|
+
};
|
|
1318
|
+
case 'coding':
|
|
1319
|
+
return {
|
|
1320
|
+
...commonProps,
|
|
1321
|
+
name: `${column.type}.${column.id}`,
|
|
1322
|
+
sortable: false,
|
|
1323
|
+
render: ({ data }) => {
|
|
1324
|
+
if (data) {
|
|
1325
|
+
return handleCoding(column, data);
|
|
1326
|
+
} else {
|
|
1327
|
+
return null;
|
|
1328
|
+
}
|
|
1329
|
+
},
|
|
1330
|
+
};
|
|
1331
|
+
case 'colour':
|
|
1332
|
+
return {
|
|
1333
|
+
...commonProps,
|
|
1334
|
+
name: `${column.type}.${column.id}`,
|
|
1335
|
+
sortable: false,
|
|
1336
|
+
render: ({ data }) => {
|
|
1337
|
+
if (data && data[column.id]) {
|
|
1338
|
+
return (
|
|
1339
|
+
<div
|
|
1340
|
+
style={{
|
|
1341
|
+
width: '25px',
|
|
1342
|
+
height: '25px',
|
|
1343
|
+
borderRadius: '10px',
|
|
1344
|
+
overflow: 'hidden',
|
|
1345
|
+
}}
|
|
1346
|
+
>
|
|
1347
|
+
<div
|
|
1348
|
+
style={{
|
|
1349
|
+
background:
|
|
1350
|
+
data[
|
|
1351
|
+
column.id
|
|
1352
|
+
] +
|
|
1353
|
+
' none repeat scroll 0% 0%',
|
|
1354
|
+
height: '100%',
|
|
1355
|
+
width: '100%',
|
|
1356
|
+
cursor: 'pointer',
|
|
1357
|
+
position:
|
|
1358
|
+
'relative',
|
|
1359
|
+
outline:
|
|
1360
|
+
'currentcolor none medium',
|
|
1361
|
+
}}
|
|
1362
|
+
></div>
|
|
1363
|
+
</div>
|
|
1364
|
+
);
|
|
1365
|
+
} else {
|
|
1366
|
+
return null;
|
|
1367
|
+
}
|
|
1368
|
+
},
|
|
1369
|
+
};
|
|
1370
|
+
case 'created_by':
|
|
1371
|
+
return {
|
|
1372
|
+
...commonProps,
|
|
1373
|
+
name: `${column.type}.${column.id}`,
|
|
1374
|
+
sortable: false,
|
|
1375
|
+
render: ({ data }) => {
|
|
1376
|
+
if (
|
|
1377
|
+
data.audits[0] &&
|
|
1378
|
+
data.audits[0].user &&
|
|
1379
|
+
data.audits[0].user.name
|
|
1380
|
+
) {
|
|
1381
|
+
value = data.audits[0].user.name;
|
|
1374
1382
|
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1383
|
+
return <span>{value}</span>;
|
|
1384
|
+
} else {
|
|
1385
|
+
return null;
|
|
1386
|
+
}
|
|
1387
|
+
},
|
|
1388
|
+
};
|
|
1389
|
+
case 'currency':
|
|
1390
|
+
return {
|
|
1391
|
+
...commonProps,
|
|
1392
|
+
name: column.id,
|
|
1393
|
+
render: ({ data }) => {
|
|
1394
|
+
if (data) {
|
|
1395
|
+
data = numeral(
|
|
1396
|
+
data[column.id]
|
|
1397
|
+
).format('$0,0.00');
|
|
1398
|
+
|
|
1399
|
+
return <span>{data}</span>;
|
|
1400
|
+
} else {
|
|
1401
|
+
return null;
|
|
1402
|
+
}
|
|
1403
|
+
},
|
|
1404
|
+
};
|
|
1405
|
+
case 'date':
|
|
1406
|
+
return {
|
|
1407
|
+
...commonProps,
|
|
1408
|
+
name: column.id,
|
|
1409
|
+
filterEditor: filterEditor,
|
|
1410
|
+
filterEditorProps: filterEditorProps,
|
|
1411
|
+
render: ({ data }) => {
|
|
1412
|
+
if (
|
|
1413
|
+
data &&
|
|
1414
|
+
data[column.id] &&
|
|
1415
|
+
moment(data[column.id]).isValid() &&
|
|
1416
|
+
moment(data[column.id]).format(
|
|
1417
|
+
'YYYY-MM-DD'
|
|
1418
|
+
) !== '1970-01-01'
|
|
1419
|
+
) {
|
|
1420
|
+
const value = moment(
|
|
1421
|
+
data[column.id]
|
|
1422
|
+
).format(
|
|
1423
|
+
column.format || 'DD-MM-YYYY'
|
|
1424
|
+
);
|
|
1425
|
+
columnStyle = {};
|
|
1390
1426
|
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
'YYYY-MM-DD'
|
|
1410
|
-
) !== '1970-01-01'
|
|
1411
|
-
) {
|
|
1412
|
-
const value = moment(
|
|
1413
|
-
data[column.id]
|
|
1414
|
-
).format(column.format || 'DD-MM-YYYY');
|
|
1415
|
-
columnStyle = {};
|
|
1427
|
+
if (
|
|
1428
|
+
column.active &&
|
|
1429
|
+
column.active.id &&
|
|
1430
|
+
column.active.value ===
|
|
1431
|
+
'expired'
|
|
1432
|
+
) {
|
|
1433
|
+
if (
|
|
1434
|
+
data[column.active.id] &&
|
|
1435
|
+
moment(
|
|
1436
|
+
data[column.active.id]
|
|
1437
|
+
).isBefore(moment())
|
|
1438
|
+
) {
|
|
1439
|
+
columnStyle = {
|
|
1440
|
+
color: column.active
|
|
1441
|
+
.colour,
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1416
1445
|
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1446
|
+
return (
|
|
1447
|
+
<span style={columnStyle}>
|
|
1448
|
+
{value}
|
|
1449
|
+
</span>
|
|
1450
|
+
);
|
|
1451
|
+
} else {
|
|
1452
|
+
return null;
|
|
1453
|
+
}
|
|
1454
|
+
},
|
|
1455
|
+
};
|
|
1456
|
+
case 'daterange':
|
|
1457
|
+
return {
|
|
1458
|
+
...commonProps,
|
|
1459
|
+
name: `${column.id[0]}.${column.id[1]}.`,
|
|
1460
|
+
filterEditor: filterEditor,
|
|
1461
|
+
filterEditorProps: filterEditorProps,
|
|
1462
|
+
render: ({ data }) => {
|
|
1422
1463
|
if (
|
|
1423
|
-
data
|
|
1464
|
+
data &&
|
|
1465
|
+
data[column.id[0]] &&
|
|
1424
1466
|
moment(
|
|
1425
|
-
data[column.
|
|
1426
|
-
).
|
|
1467
|
+
data[column.id[0]]
|
|
1468
|
+
).isValid() &&
|
|
1469
|
+
moment(data[column.id[0]]).format(
|
|
1470
|
+
'YYYY-MM-DD'
|
|
1471
|
+
) !== '1970-01-01'
|
|
1427
1472
|
) {
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1473
|
+
value = moment(
|
|
1474
|
+
data[column.id[0]]
|
|
1475
|
+
).format(
|
|
1476
|
+
column.format || 'DD-MM-YYYY'
|
|
1477
|
+
);
|
|
1431
1478
|
}
|
|
1432
|
-
}
|
|
1433
1479
|
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
data &&
|
|
1451
|
-
data[column.id[0]] &&
|
|
1452
|
-
moment(data[column.id[0]]).isValid() &&
|
|
1453
|
-
moment(data[column.id[0]]).format(
|
|
1454
|
-
'YYYY-MM-DD'
|
|
1455
|
-
) !== '1970-01-01'
|
|
1456
|
-
) {
|
|
1457
|
-
value = moment(data[column.id[0]]).format(
|
|
1458
|
-
column.format || 'DD-MM-YYYY'
|
|
1459
|
-
);
|
|
1460
|
-
}
|
|
1480
|
+
if (
|
|
1481
|
+
data &&
|
|
1482
|
+
data[column.id[1]] &&
|
|
1483
|
+
moment(
|
|
1484
|
+
data[column.id[1]]
|
|
1485
|
+
).isValid() &&
|
|
1486
|
+
moment(data[column.id[1]]).format(
|
|
1487
|
+
'YYYY-MM-DD'
|
|
1488
|
+
) !== '1970-01-01'
|
|
1489
|
+
) {
|
|
1490
|
+
value += ` - ${moment(
|
|
1491
|
+
data[column.id[1]]
|
|
1492
|
+
).format(
|
|
1493
|
+
column.format || 'DD-MM-YYYY'
|
|
1494
|
+
)}`;
|
|
1495
|
+
}
|
|
1461
1496
|
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1497
|
+
return <span>{value}</span>;
|
|
1498
|
+
},
|
|
1499
|
+
};
|
|
1500
|
+
case 'datetime':
|
|
1501
|
+
return {
|
|
1502
|
+
...commonProps,
|
|
1503
|
+
name: column.id,
|
|
1504
|
+
filterEditor: filterEditor,
|
|
1505
|
+
filterEditorProps: filterEditorProps,
|
|
1506
|
+
render: ({ data }) => {
|
|
1507
|
+
if (
|
|
1508
|
+
data &&
|
|
1509
|
+
data[column.id] &&
|
|
1510
|
+
moment(data[column.id]).isValid() &&
|
|
1511
|
+
moment(data[column.id]).format(
|
|
1512
|
+
'YYYY-MM-DD'
|
|
1513
|
+
) !== '1970-01-01'
|
|
1514
|
+
) {
|
|
1515
|
+
data = moment(
|
|
1516
|
+
data[column.id]
|
|
1517
|
+
).format(
|
|
1518
|
+
column.format
|
|
1519
|
+
? column.format
|
|
1520
|
+
: 'DD-MM-YYYY hh:mm A'
|
|
1521
|
+
);
|
|
1474
1522
|
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
if (
|
|
1486
|
-
data &&
|
|
1487
|
-
data[column.id] &&
|
|
1488
|
-
moment(data[column.id]).isValid() &&
|
|
1489
|
-
moment(data[column.id]).format(
|
|
1490
|
-
'YYYY-MM-DD'
|
|
1491
|
-
) !== '1970-01-01'
|
|
1492
|
-
) {
|
|
1493
|
-
data = moment(data[column.id]).format(
|
|
1494
|
-
column.format
|
|
1495
|
-
? column.format
|
|
1496
|
-
: 'DD-MM-YYYY hh:mm A'
|
|
1497
|
-
);
|
|
1523
|
+
return <span>{data}</span>;
|
|
1524
|
+
} else {
|
|
1525
|
+
return null;
|
|
1526
|
+
}
|
|
1527
|
+
},
|
|
1528
|
+
};
|
|
1529
|
+
case 'dropdown':
|
|
1530
|
+
columnId = Array.isArray(column.id)
|
|
1531
|
+
? column.id.join('-')
|
|
1532
|
+
: column.id;
|
|
1498
1533
|
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
name={column.id}
|
|
1513
|
-
value={data[column.id]?.id || ''}
|
|
1514
|
-
style={{ padding: '7px' }}
|
|
1515
|
-
onChange={(e) => {
|
|
1516
|
-
e.preventDefault();
|
|
1534
|
+
return {
|
|
1535
|
+
...commonProps,
|
|
1536
|
+
name: columnId,
|
|
1537
|
+
render: ({ data }) => {
|
|
1538
|
+
return (
|
|
1539
|
+
<select
|
|
1540
|
+
name={column.id}
|
|
1541
|
+
value={
|
|
1542
|
+
data[column.id]?.id || ''
|
|
1543
|
+
}
|
|
1544
|
+
style={{ padding: '7px' }}
|
|
1545
|
+
onChange={(e) => {
|
|
1546
|
+
e.preventDefault();
|
|
1517
1547
|
|
|
1548
|
+
if (
|
|
1549
|
+
(column.update?.key,
|
|
1550
|
+
column.update?.url,
|
|
1551
|
+
column.update?.method)
|
|
1552
|
+
) {
|
|
1553
|
+
handleDropdownUpdate(
|
|
1554
|
+
column.update.key,
|
|
1555
|
+
`${column.update.url}/${data.id}`,
|
|
1556
|
+
column.update
|
|
1557
|
+
.method,
|
|
1558
|
+
e.target.value
|
|
1559
|
+
);
|
|
1560
|
+
}
|
|
1561
|
+
}}
|
|
1562
|
+
>
|
|
1563
|
+
<option value="">
|
|
1564
|
+
Select an Option
|
|
1565
|
+
</option>
|
|
1566
|
+
{dropdownData[column.id] &&
|
|
1567
|
+
dropdownData[column.id].length >
|
|
1568
|
+
0
|
|
1569
|
+
? dropdownData[
|
|
1570
|
+
column.id
|
|
1571
|
+
].map((option, index) => (
|
|
1572
|
+
<option
|
|
1573
|
+
value={option.id}
|
|
1574
|
+
key={index}
|
|
1575
|
+
>
|
|
1576
|
+
{option.label}
|
|
1577
|
+
</option>
|
|
1578
|
+
))
|
|
1579
|
+
: null}
|
|
1580
|
+
</select>
|
|
1581
|
+
);
|
|
1582
|
+
},
|
|
1583
|
+
};
|
|
1584
|
+
case 'file':
|
|
1585
|
+
return {
|
|
1586
|
+
...commonProps,
|
|
1587
|
+
name: column.id,
|
|
1588
|
+
sortable: false,
|
|
1589
|
+
render: ({ data }) => {
|
|
1590
|
+
if (data && data[column.id]) {
|
|
1591
|
+
// Check if the data is an array of files
|
|
1518
1592
|
if (
|
|
1519
|
-
(column.
|
|
1520
|
-
column.update?.url,
|
|
1521
|
-
column.update?.method)
|
|
1593
|
+
Array.isArray(data[column.id])
|
|
1522
1594
|
) {
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1595
|
+
// Return a span for each file in the array with added margin
|
|
1596
|
+
return data[column.id].map(
|
|
1597
|
+
(file, index) => (
|
|
1598
|
+
<span
|
|
1599
|
+
key={index} // Use index as a key; consider using unique ids if available
|
|
1600
|
+
onClick={(e) => {
|
|
1601
|
+
e.stopPropagation();
|
|
1602
|
+
e.preventDefault();
|
|
1603
|
+
handleDownload(
|
|
1604
|
+
file
|
|
1605
|
+
);
|
|
1606
|
+
}}
|
|
1607
|
+
style={{
|
|
1608
|
+
marginRight:
|
|
1609
|
+
'10px',
|
|
1610
|
+
display:
|
|
1611
|
+
'inline-block',
|
|
1612
|
+
}} // Added margin right and display style
|
|
1613
|
+
>
|
|
1614
|
+
<CloudDownload
|
|
1615
|
+
data-tooltip-id={`system-tooltip`}
|
|
1616
|
+
data-tooltip-content={`Download File ${file.file_name}`}
|
|
1617
|
+
strokeWidth={2}
|
|
1618
|
+
size={18}
|
|
1619
|
+
className="tdaction"
|
|
1620
|
+
/>
|
|
1621
|
+
</span>
|
|
1622
|
+
)
|
|
1623
|
+
);
|
|
1624
|
+
} else {
|
|
1625
|
+
// Return a single span for a single file with added margin
|
|
1626
|
+
return (
|
|
1627
|
+
<span
|
|
1628
|
+
onClick={(e) => {
|
|
1629
|
+
e.stopPropagation();
|
|
1630
|
+
e.preventDefault();
|
|
1631
|
+
handleDownload(
|
|
1632
|
+
data[column.id]
|
|
1633
|
+
);
|
|
1634
|
+
}}
|
|
1635
|
+
style={{
|
|
1636
|
+
marginRight: '10px',
|
|
1637
|
+
display:
|
|
1638
|
+
'inline-block',
|
|
1639
|
+
}} // Added margin right and display style for consistency
|
|
1640
|
+
>
|
|
1641
|
+
<CloudDownload
|
|
1642
|
+
data-tooltip-id="system-tooltip"
|
|
1643
|
+
data-tooltip-content={`Download File ${
|
|
1644
|
+
data[column.id]
|
|
1645
|
+
.file_name
|
|
1646
|
+
}`}
|
|
1647
|
+
strokeWidth={2}
|
|
1648
|
+
size={18}
|
|
1649
|
+
className="tdaction"
|
|
1650
|
+
/>
|
|
1651
|
+
</span>
|
|
1528
1652
|
);
|
|
1529
1653
|
}
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
sortable: false,
|
|
1557
|
-
render: ({ data }) => {
|
|
1558
|
-
if (data && data[column.id]) {
|
|
1559
|
-
// Check if the data is an array of files
|
|
1560
|
-
if (Array.isArray(data[column.id])) {
|
|
1561
|
-
// Return a span for each file in the array with added margin
|
|
1562
|
-
return data[column.id].map(
|
|
1563
|
-
(file, index) => (
|
|
1564
|
-
<span
|
|
1565
|
-
key={index} // Use index as a key; consider using unique ids if available
|
|
1566
|
-
onClick={(e) => {
|
|
1567
|
-
e.stopPropagation();
|
|
1568
|
-
e.preventDefault();
|
|
1569
|
-
handleDownload(file);
|
|
1570
|
-
}}
|
|
1571
|
-
style={{
|
|
1572
|
-
marginRight: '10px',
|
|
1573
|
-
display: 'inline-block',
|
|
1574
|
-
}} // Added margin right and display style
|
|
1575
|
-
>
|
|
1576
|
-
<CloudDownload
|
|
1577
|
-
data-tooltip-id={`system-tooltip`}
|
|
1578
|
-
data-tooltip-content={`Download File ${file.file_name}`}
|
|
1579
|
-
strokeWidth={2}
|
|
1580
|
-
size={18}
|
|
1581
|
-
className="tdaction"
|
|
1654
|
+
} else {
|
|
1655
|
+
return null;
|
|
1656
|
+
}
|
|
1657
|
+
},
|
|
1658
|
+
};
|
|
1659
|
+
case 'icons':
|
|
1660
|
+
return {
|
|
1661
|
+
...commonProps,
|
|
1662
|
+
name: column.id,
|
|
1663
|
+
sortable: false,
|
|
1664
|
+
render: ({ data }) => {
|
|
1665
|
+
icons = [];
|
|
1666
|
+
|
|
1667
|
+
if (
|
|
1668
|
+
column.icons &&
|
|
1669
|
+
column.icons.length > 0
|
|
1670
|
+
) {
|
|
1671
|
+
column.icons.forEach((icon) => {
|
|
1672
|
+
icons.push(
|
|
1673
|
+
<img
|
|
1674
|
+
src={icon.url}
|
|
1675
|
+
alt={icon.name}
|
|
1676
|
+
data-tooltip-id="system-tooltip"
|
|
1677
|
+
data-tooltip-content={
|
|
1678
|
+
icon.name
|
|
1679
|
+
}
|
|
1582
1680
|
/>
|
|
1583
|
-
|
|
1584
|
-
)
|
|
1585
|
-
|
|
1586
|
-
} else {
|
|
1587
|
-
// Return a single span for a single file with added margin
|
|
1588
|
-
return (
|
|
1589
|
-
<span
|
|
1590
|
-
onClick={(e) => {
|
|
1591
|
-
e.stopPropagation();
|
|
1592
|
-
e.preventDefault();
|
|
1593
|
-
handleDownload(
|
|
1594
|
-
data[column.id]
|
|
1595
|
-
);
|
|
1596
|
-
}}
|
|
1597
|
-
style={{
|
|
1598
|
-
marginRight: '10px',
|
|
1599
|
-
display: 'inline-block',
|
|
1600
|
-
}} // Added margin right and display style for consistency
|
|
1601
|
-
>
|
|
1602
|
-
<CloudDownload
|
|
1603
|
-
data-tooltip-id="system-tooltip"
|
|
1604
|
-
data-tooltip-content={`Download File ${
|
|
1605
|
-
data[column.id]
|
|
1606
|
-
.file_name
|
|
1607
|
-
}`}
|
|
1608
|
-
strokeWidth={2}
|
|
1609
|
-
size={18}
|
|
1610
|
-
className="tdaction"
|
|
1611
|
-
/>
|
|
1612
|
-
</span>
|
|
1613
|
-
);
|
|
1614
|
-
}
|
|
1615
|
-
} else {
|
|
1616
|
-
return null;
|
|
1617
|
-
}
|
|
1618
|
-
},
|
|
1619
|
-
};
|
|
1620
|
-
case 'icons':
|
|
1621
|
-
return {
|
|
1622
|
-
...commonProps,
|
|
1623
|
-
name: column.id,
|
|
1624
|
-
sortable: false,
|
|
1625
|
-
render: ({ data }) => {
|
|
1626
|
-
icons = [];
|
|
1627
|
-
|
|
1628
|
-
if (column.icons && column.icons.length > 0) {
|
|
1629
|
-
column.icons.forEach((icon) => {
|
|
1630
|
-
icons.push(
|
|
1631
|
-
<img
|
|
1632
|
-
src={icon.url}
|
|
1633
|
-
alt={icon.name}
|
|
1634
|
-
data-tooltip-id="system-tooltip"
|
|
1635
|
-
data-tooltip-content={icon.name}
|
|
1636
|
-
/>
|
|
1637
|
-
);
|
|
1638
|
-
});
|
|
1639
|
-
}
|
|
1640
|
-
|
|
1641
|
-
if (data) {
|
|
1642
|
-
return <span>{icons}</span>;
|
|
1643
|
-
} else {
|
|
1644
|
-
return null;
|
|
1645
|
-
}
|
|
1646
|
-
},
|
|
1647
|
-
};
|
|
1648
|
-
case 'image':
|
|
1649
|
-
return {
|
|
1650
|
-
...commonProps,
|
|
1651
|
-
name: column.id,
|
|
1652
|
-
render: ({ data }) => {
|
|
1653
|
-
if (data && data[column.id]) {
|
|
1654
|
-
fileUrl =
|
|
1655
|
-
data[column.id][0]?.file_url ||
|
|
1656
|
-
data[column.id]?.file_url;
|
|
1657
|
-
|
|
1658
|
-
if (fileUrl) {
|
|
1659
|
-
return (
|
|
1660
|
-
<span>
|
|
1661
|
-
{parse(
|
|
1662
|
-
`<img width="150" src="${fileUrl}" />`
|
|
1663
|
-
)}
|
|
1664
|
-
</span>
|
|
1665
|
-
);
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
|
-
return null;
|
|
1670
|
-
},
|
|
1671
|
-
};
|
|
1672
|
-
case 'json':
|
|
1673
|
-
return {
|
|
1674
|
-
...commonProps,
|
|
1675
|
-
name: `${column.id}.${column.jsonData}`,
|
|
1676
|
-
render: ({ data }) => {
|
|
1677
|
-
if (
|
|
1678
|
-
data &&
|
|
1679
|
-
data[column.id] &&
|
|
1680
|
-
data[column.id][column.jsonData]
|
|
1681
|
-
) {
|
|
1682
|
-
data = data[column.id][column.jsonData];
|
|
1683
|
-
|
|
1684
|
-
return <span>{data}</span>;
|
|
1685
|
-
} else {
|
|
1686
|
-
return null;
|
|
1687
|
-
}
|
|
1688
|
-
},
|
|
1689
|
-
};
|
|
1690
|
-
case 'number':
|
|
1691
|
-
return {
|
|
1692
|
-
...commonProps,
|
|
1693
|
-
name: column.id,
|
|
1694
|
-
type: 'number',
|
|
1695
|
-
};
|
|
1696
|
-
case 'option':
|
|
1697
|
-
return {
|
|
1698
|
-
...commonProps,
|
|
1699
|
-
name: column.id,
|
|
1700
|
-
filterEditor: filterEditor,
|
|
1701
|
-
filterEditorProps: filterEditorProps,
|
|
1702
|
-
render: ({ data }) => {
|
|
1703
|
-
let newData;
|
|
1704
|
-
|
|
1705
|
-
if (
|
|
1706
|
-
data &&
|
|
1707
|
-
column.options &&
|
|
1708
|
-
column.options[data[column.id]]
|
|
1709
|
-
) {
|
|
1710
|
-
if (
|
|
1711
|
-
column.key &&
|
|
1712
|
-
data[column.key] > 0 &&
|
|
1713
|
-
column.options[
|
|
1714
|
-
data[column.id]
|
|
1715
|
-
].includes('#')
|
|
1716
|
-
) {
|
|
1717
|
-
newData = column.options[
|
|
1718
|
-
data[column.id]
|
|
1719
|
-
].replace(/#/g, data[column.key]);
|
|
1720
|
-
} else {
|
|
1721
|
-
newData =
|
|
1722
|
-
column.options[data[column.id]];
|
|
1723
|
-
}
|
|
1681
|
+
);
|
|
1682
|
+
});
|
|
1683
|
+
}
|
|
1724
1684
|
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
return null;
|
|
1728
|
-
}
|
|
1729
|
-
},
|
|
1730
|
-
};
|
|
1731
|
-
case 'placeholder':
|
|
1732
|
-
return {
|
|
1733
|
-
...commonProps,
|
|
1734
|
-
name: column.id,
|
|
1735
|
-
sortable: false,
|
|
1736
|
-
render: ({ data }) => {
|
|
1737
|
-
if (data) {
|
|
1738
|
-
return <span>{column.placeholder}</span>;
|
|
1739
|
-
} else {
|
|
1740
|
-
return null;
|
|
1741
|
-
}
|
|
1742
|
-
},
|
|
1743
|
-
};
|
|
1744
|
-
case 'relation':
|
|
1745
|
-
return {
|
|
1746
|
-
...commonProps,
|
|
1747
|
-
name: relationName,
|
|
1748
|
-
sortable: false,
|
|
1749
|
-
filterEditor: filterEditor,
|
|
1750
|
-
filterEditorProps: filterEditorProps,
|
|
1751
|
-
render: ({ data }) => {
|
|
1752
|
-
value = column.id.reduce((acc, id) => {
|
|
1753
|
-
if (acc === '') {
|
|
1754
|
-
return data[id];
|
|
1755
|
-
} else {
|
|
1756
|
-
if (acc && acc[id]) {
|
|
1757
|
-
return acc[id];
|
|
1685
|
+
if (data) {
|
|
1686
|
+
return <span>{icons}</span>;
|
|
1758
1687
|
} else {
|
|
1759
|
-
return
|
|
1688
|
+
return null;
|
|
1689
|
+
}
|
|
1690
|
+
},
|
|
1691
|
+
};
|
|
1692
|
+
case 'image':
|
|
1693
|
+
return {
|
|
1694
|
+
...commonProps,
|
|
1695
|
+
name: column.id,
|
|
1696
|
+
render: ({ data }) => {
|
|
1697
|
+
if (data && data[column.id]) {
|
|
1698
|
+
fileUrl =
|
|
1699
|
+
data[column.id][0]?.file_url ||
|
|
1700
|
+
data[column.id]?.file_url;
|
|
1701
|
+
|
|
1702
|
+
if (fileUrl) {
|
|
1703
|
+
return (
|
|
1704
|
+
<span>
|
|
1705
|
+
{parse(
|
|
1706
|
+
`<img width="150" src="${fileUrl}" />`
|
|
1707
|
+
)}
|
|
1708
|
+
</span>
|
|
1709
|
+
);
|
|
1710
|
+
}
|
|
1760
1711
|
}
|
|
1761
|
-
}
|
|
1762
|
-
}, '');
|
|
1763
|
-
|
|
1764
|
-
if (value) {
|
|
1765
|
-
if (Array.isArray(value)) {
|
|
1766
|
-
value = value[0];
|
|
1767
|
-
}
|
|
1768
1712
|
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1713
|
+
return null;
|
|
1714
|
+
},
|
|
1715
|
+
};
|
|
1716
|
+
case 'json':
|
|
1717
|
+
return {
|
|
1718
|
+
...commonProps,
|
|
1719
|
+
name: `${column.id}.${column.jsonData}`,
|
|
1720
|
+
render: ({ data }) => {
|
|
1774
1721
|
if (
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
)
|
|
1722
|
+
data &&
|
|
1723
|
+
data[column.id] &&
|
|
1724
|
+
data[column.id][column.jsonData]
|
|
1779
1725
|
) {
|
|
1780
|
-
|
|
1726
|
+
data =
|
|
1727
|
+
data[column.id][
|
|
1728
|
+
column.jsonData
|
|
1729
|
+
];
|
|
1730
|
+
|
|
1731
|
+
return <span>{data}</span>;
|
|
1732
|
+
} else {
|
|
1733
|
+
return null;
|
|
1781
1734
|
}
|
|
1782
|
-
}
|
|
1735
|
+
},
|
|
1736
|
+
};
|
|
1737
|
+
case 'number':
|
|
1738
|
+
return {
|
|
1739
|
+
...commonProps,
|
|
1740
|
+
name: column.id,
|
|
1741
|
+
type: 'number',
|
|
1742
|
+
};
|
|
1743
|
+
case 'option':
|
|
1744
|
+
return {
|
|
1745
|
+
...commonProps,
|
|
1746
|
+
name: column.id,
|
|
1747
|
+
filterEditor: filterEditor,
|
|
1748
|
+
filterEditorProps: filterEditorProps,
|
|
1749
|
+
render: ({ data }) => {
|
|
1750
|
+
let newData;
|
|
1783
1751
|
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1752
|
+
if (
|
|
1753
|
+
data &&
|
|
1754
|
+
column.options &&
|
|
1755
|
+
column.options[data[column.id]]
|
|
1756
|
+
) {
|
|
1757
|
+
if (
|
|
1758
|
+
column.key &&
|
|
1759
|
+
data[column.key] > 0 &&
|
|
1760
|
+
column.options[
|
|
1761
|
+
data[column.id]
|
|
1762
|
+
].includes('#')
|
|
1763
|
+
) {
|
|
1764
|
+
newData = column.options[
|
|
1765
|
+
data[column.id]
|
|
1766
|
+
].replace(
|
|
1767
|
+
/#/g,
|
|
1768
|
+
data[column.key]
|
|
1769
|
+
);
|
|
1770
|
+
} else {
|
|
1771
|
+
newData =
|
|
1772
|
+
column.options[
|
|
1773
|
+
data[column.id]
|
|
1774
|
+
];
|
|
1798
1775
|
}
|
|
1776
|
+
|
|
1777
|
+
return <span>{newData}</span>;
|
|
1778
|
+
} else {
|
|
1779
|
+
return null;
|
|
1780
|
+
}
|
|
1781
|
+
},
|
|
1782
|
+
};
|
|
1783
|
+
case 'placeholder':
|
|
1784
|
+
return {
|
|
1785
|
+
...commonProps,
|
|
1786
|
+
name: column.id,
|
|
1787
|
+
sortable: false,
|
|
1788
|
+
render: ({ data }) => {
|
|
1789
|
+
if (data) {
|
|
1790
|
+
return (
|
|
1791
|
+
<span>
|
|
1792
|
+
{column.placeholder}
|
|
1793
|
+
</span>
|
|
1794
|
+
);
|
|
1795
|
+
} else {
|
|
1796
|
+
return null;
|
|
1799
1797
|
}
|
|
1798
|
+
},
|
|
1799
|
+
};
|
|
1800
|
+
case 'relation':
|
|
1801
|
+
return {
|
|
1802
|
+
...commonProps,
|
|
1803
|
+
name: relationName,
|
|
1804
|
+
sortable: false,
|
|
1805
|
+
filterEditor: filterEditor,
|
|
1806
|
+
filterEditorProps: filterEditorProps,
|
|
1807
|
+
render: ({ data }) => {
|
|
1808
|
+
value = column.id.reduce((acc, id) => {
|
|
1809
|
+
if (acc === '') {
|
|
1810
|
+
return data[id];
|
|
1811
|
+
} else {
|
|
1812
|
+
if (acc && acc[id]) {
|
|
1813
|
+
return acc[id];
|
|
1814
|
+
} else {
|
|
1815
|
+
return '';
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
}, '');
|
|
1800
1819
|
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
}
|
|
1806
|
-
},
|
|
1807
|
-
};
|
|
1808
|
-
case 'relationArray':
|
|
1809
|
-
return {
|
|
1810
|
-
...commonProps,
|
|
1811
|
-
name: relationName,
|
|
1812
|
-
sortable: false,
|
|
1813
|
-
filterEditor: filterEditor,
|
|
1814
|
-
filterEditorProps: filterEditorProps,
|
|
1815
|
-
render: ({ data }) => {
|
|
1816
|
-
const relationValue = column.id.reduce(
|
|
1817
|
-
(acc, id) =>
|
|
1818
|
-
acc === ''
|
|
1819
|
-
? data[id]
|
|
1820
|
-
: acc && acc[id]
|
|
1821
|
-
? acc[id]
|
|
1822
|
-
: '',
|
|
1823
|
-
''
|
|
1824
|
-
);
|
|
1820
|
+
if (value) {
|
|
1821
|
+
if (Array.isArray(value)) {
|
|
1822
|
+
value = value[0];
|
|
1823
|
+
}
|
|
1825
1824
|
|
|
1826
|
-
if (
|
|
1827
|
-
relationValue &&
|
|
1828
|
-
Array.isArray(relationValue) &&
|
|
1829
|
-
relationValue.length > 0
|
|
1830
|
-
) {
|
|
1831
|
-
const nameProperties = Array.isArray(
|
|
1832
|
-
column.nameFrom
|
|
1833
|
-
)
|
|
1834
|
-
? column.nameFrom
|
|
1835
|
-
: [column.nameFrom];
|
|
1836
|
-
|
|
1837
|
-
const values = relationValue
|
|
1838
|
-
.map((rv) => {
|
|
1839
1825
|
if (
|
|
1840
|
-
column.
|
|
1841
|
-
Array.isArray(column.childId)
|
|
1826
|
+
Array.isArray(column.nameFrom)
|
|
1842
1827
|
) {
|
|
1843
|
-
|
|
1828
|
+
value = column.nameFrom
|
|
1829
|
+
.map((nf) => value[nf])
|
|
1830
|
+
.join(' ');
|
|
1831
|
+
} else {
|
|
1832
|
+
if (
|
|
1833
|
+
value &&
|
|
1834
|
+
value.hasOwnProperty(
|
|
1835
|
+
column.nameFrom
|
|
1836
|
+
)
|
|
1837
|
+
) {
|
|
1838
|
+
value =
|
|
1839
|
+
value[column.nameFrom];
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1844
1842
|
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1843
|
+
if (
|
|
1844
|
+
column.placeholder &&
|
|
1845
|
+
column.placeholder !== ''
|
|
1846
|
+
) {
|
|
1847
|
+
return (
|
|
1848
|
+
<span>
|
|
1849
|
+
{column.placeholder}
|
|
1850
|
+
</span>
|
|
1851
|
+
);
|
|
1852
|
+
} else {
|
|
1853
|
+
if (
|
|
1854
|
+
column.hasOwnProperty(
|
|
1855
|
+
'format'
|
|
1856
|
+
)
|
|
1857
|
+
) {
|
|
1858
|
+
if (column.format) {
|
|
1859
|
+
value =
|
|
1860
|
+
moment(
|
|
1861
|
+
value
|
|
1862
|
+
).format(
|
|
1863
|
+
'DD-MM-YYYY'
|
|
1864
|
+
);
|
|
1849
1865
|
}
|
|
1850
|
-
}
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
return <span>{value}</span>;
|
|
1869
|
+
}
|
|
1870
|
+
} else {
|
|
1871
|
+
return null;
|
|
1872
|
+
}
|
|
1873
|
+
},
|
|
1874
|
+
};
|
|
1875
|
+
case 'relationArray':
|
|
1876
|
+
return {
|
|
1877
|
+
...commonProps,
|
|
1878
|
+
name: relationName,
|
|
1879
|
+
sortable: false,
|
|
1880
|
+
filterEditor: filterEditor,
|
|
1881
|
+
filterEditorProps: filterEditorProps,
|
|
1882
|
+
render: ({ data }) => {
|
|
1883
|
+
const relationValue = column.id.reduce(
|
|
1884
|
+
(acc, id) =>
|
|
1885
|
+
acc === ''
|
|
1886
|
+
? data[id]
|
|
1887
|
+
: acc && acc[id]
|
|
1888
|
+
? acc[id]
|
|
1889
|
+
: '',
|
|
1890
|
+
''
|
|
1891
|
+
);
|
|
1851
1892
|
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1893
|
+
if (
|
|
1894
|
+
relationValue &&
|
|
1895
|
+
Array.isArray(relationValue) &&
|
|
1896
|
+
relationValue.length > 0
|
|
1897
|
+
) {
|
|
1898
|
+
const nameProperties =
|
|
1899
|
+
Array.isArray(column.nameFrom)
|
|
1900
|
+
? column.nameFrom
|
|
1901
|
+
: [column.nameFrom];
|
|
1902
|
+
|
|
1903
|
+
const values = relationValue
|
|
1904
|
+
.map((rv) => {
|
|
1905
|
+
if (
|
|
1906
|
+
column.childId &&
|
|
1907
|
+
Array.isArray(
|
|
1908
|
+
column.childId
|
|
1909
|
+
)
|
|
1910
|
+
) {
|
|
1911
|
+
childValue = rv;
|
|
1912
|
+
|
|
1913
|
+
column.childId.forEach(
|
|
1914
|
+
(a) => {
|
|
1915
|
+
if (
|
|
1857
1916
|
childValue[
|
|
1858
|
-
|
|
1917
|
+
a
|
|
1859
1918
|
]
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1919
|
+
) {
|
|
1920
|
+
childValue =
|
|
1921
|
+
childValue[
|
|
1922
|
+
a
|
|
1923
|
+
];
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
);
|
|
1927
|
+
|
|
1928
|
+
if (childValue) {
|
|
1929
|
+
const propertyValues =
|
|
1930
|
+
nameProperties
|
|
1931
|
+
.map(
|
|
1932
|
+
(
|
|
1933
|
+
prop
|
|
1934
|
+
) =>
|
|
1935
|
+
childValue[
|
|
1936
|
+
prop
|
|
1937
|
+
]
|
|
1938
|
+
)
|
|
1939
|
+
.filter(
|
|
1940
|
+
(
|
|
1941
|
+
value
|
|
1942
|
+
) =>
|
|
1943
|
+
value !==
|
|
1944
|
+
undefined &&
|
|
1945
|
+
value !==
|
|
1946
|
+
null
|
|
1947
|
+
);
|
|
1948
|
+
return propertyValues.join(
|
|
1949
|
+
' '
|
|
1867
1950
|
);
|
|
1868
|
-
|
|
1869
|
-
|
|
1951
|
+
}
|
|
1952
|
+
} else {
|
|
1953
|
+
const propertyValues =
|
|
1954
|
+
nameProperties
|
|
1955
|
+
.map(
|
|
1956
|
+
(prop) =>
|
|
1957
|
+
rv[prop]
|
|
1958
|
+
)
|
|
1959
|
+
.filter(
|
|
1960
|
+
(value) =>
|
|
1961
|
+
value !==
|
|
1962
|
+
undefined &&
|
|
1963
|
+
value !==
|
|
1964
|
+
null
|
|
1965
|
+
);
|
|
1966
|
+
return propertyValues.join(
|
|
1967
|
+
' '
|
|
1968
|
+
);
|
|
1969
|
+
}
|
|
1970
|
+
})
|
|
1971
|
+
.filter(
|
|
1972
|
+
(value) => value !== ''
|
|
1973
|
+
);
|
|
1974
|
+
|
|
1975
|
+
// if (values.length > 0) {
|
|
1976
|
+
let result = '';
|
|
1977
|
+
|
|
1978
|
+
if (
|
|
1979
|
+
column.relation?.id &&
|
|
1980
|
+
column.relation?.key
|
|
1981
|
+
) {
|
|
1982
|
+
const relationValue =
|
|
1983
|
+
column.relation.key.reduce(
|
|
1984
|
+
(acc, id) =>
|
|
1985
|
+
acc === ''
|
|
1986
|
+
? data[id]
|
|
1987
|
+
: acc && acc[id]
|
|
1988
|
+
? acc[id]
|
|
1989
|
+
: '',
|
|
1990
|
+
''
|
|
1870
1991
|
);
|
|
1992
|
+
|
|
1993
|
+
result = `${
|
|
1994
|
+
relationValue[
|
|
1995
|
+
column.relation.id
|
|
1996
|
+
]
|
|
1997
|
+
}<br />`;
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
if (
|
|
2001
|
+
column.where &&
|
|
2002
|
+
column.where.id &&
|
|
2003
|
+
column.where.value
|
|
2004
|
+
) {
|
|
2005
|
+
if (
|
|
2006
|
+
data[column.where.id] ===
|
|
2007
|
+
column.where.value
|
|
2008
|
+
) {
|
|
2009
|
+
result +=
|
|
2010
|
+
values.join('<br />');
|
|
1871
2011
|
}
|
|
1872
2012
|
} else {
|
|
1873
|
-
|
|
1874
|
-
nameProperties
|
|
1875
|
-
.map((prop) => rv[prop])
|
|
1876
|
-
.filter(
|
|
1877
|
-
(value) =>
|
|
1878
|
-
value !==
|
|
1879
|
-
undefined &&
|
|
1880
|
-
value !== null
|
|
1881
|
-
);
|
|
1882
|
-
return propertyValues.join(' ');
|
|
2013
|
+
result += values.join('<br />');
|
|
1883
2014
|
}
|
|
1884
|
-
})
|
|
1885
|
-
.filter((value) => value !== '');
|
|
1886
2015
|
|
|
1887
|
-
|
|
1888
|
-
|
|
2016
|
+
return <span>{parse(result)}</span>;
|
|
2017
|
+
// }
|
|
2018
|
+
} else {
|
|
2019
|
+
let result = '';
|
|
1889
2020
|
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
2021
|
+
if (
|
|
2022
|
+
column.relation?.id &&
|
|
2023
|
+
column.relation?.key
|
|
2024
|
+
) {
|
|
2025
|
+
const relationValue =
|
|
2026
|
+
column.relation.key.reduce(
|
|
2027
|
+
(acc, id) =>
|
|
2028
|
+
acc === ''
|
|
2029
|
+
? data[id]
|
|
2030
|
+
: acc && acc[id]
|
|
2031
|
+
? acc[id]
|
|
2032
|
+
: '',
|
|
2033
|
+
''
|
|
2034
|
+
);
|
|
1904
2035
|
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
2036
|
+
result =
|
|
2037
|
+
relationValue &&
|
|
2038
|
+
relationValue[
|
|
2039
|
+
column.relation.id
|
|
2040
|
+
]
|
|
2041
|
+
? relationValue[
|
|
2042
|
+
column.relation.id
|
|
2043
|
+
]
|
|
2044
|
+
: '';
|
|
2045
|
+
}
|
|
1909
2046
|
|
|
1910
|
-
|
|
1911
|
-
column.where &&
|
|
1912
|
-
column.where.id &&
|
|
1913
|
-
column.where.value
|
|
1914
|
-
) {
|
|
1915
|
-
if (
|
|
1916
|
-
data[column.where.id] ===
|
|
1917
|
-
column.where.value
|
|
1918
|
-
) {
|
|
1919
|
-
result += values.join('<br />');
|
|
2047
|
+
return <span>{parse(result)}</span>;
|
|
1920
2048
|
}
|
|
1921
|
-
} else {
|
|
1922
|
-
result += values.join('<br />');
|
|
1923
|
-
}
|
|
1924
|
-
|
|
1925
|
-
return <span>{parse(result)}</span>;
|
|
1926
|
-
// }
|
|
1927
|
-
} else {
|
|
1928
|
-
let result = '';
|
|
1929
2049
|
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
2050
|
+
return null;
|
|
2051
|
+
},
|
|
2052
|
+
};
|
|
2053
|
+
case 'richtext':
|
|
2054
|
+
return {
|
|
2055
|
+
...commonProps,
|
|
2056
|
+
name: column.id,
|
|
2057
|
+
render: ({ data }) => {
|
|
2058
|
+
if (data && data[column.id]) {
|
|
2059
|
+
return (
|
|
2060
|
+
<span>
|
|
2061
|
+
{parse(data[column.id])}
|
|
2062
|
+
</span>
|
|
1943
2063
|
);
|
|
2064
|
+
} else {
|
|
2065
|
+
return null;
|
|
2066
|
+
}
|
|
2067
|
+
},
|
|
2068
|
+
};
|
|
2069
|
+
case 'stage':
|
|
2070
|
+
return {
|
|
2071
|
+
...commonProps,
|
|
2072
|
+
name: column.id,
|
|
2073
|
+
sortable: false,
|
|
2074
|
+
render: ({ data }) => {
|
|
2075
|
+
stage = '';
|
|
2076
|
+
|
|
2077
|
+
column.keyIds.forEach((a, b) => {
|
|
2078
|
+
if (data[a] === 1) {
|
|
2079
|
+
stage = column.valueIds[b];
|
|
2080
|
+
}
|
|
2081
|
+
});
|
|
1944
2082
|
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
);
|
|
1969
|
-
} else {
|
|
1970
|
-
return null;
|
|
1971
|
-
}
|
|
1972
|
-
},
|
|
1973
|
-
};
|
|
1974
|
-
case 'stage':
|
|
1975
|
-
return {
|
|
1976
|
-
...commonProps,
|
|
1977
|
-
name: column.id,
|
|
1978
|
-
sortable: false,
|
|
1979
|
-
render: ({ data }) => {
|
|
1980
|
-
stage = '';
|
|
1981
|
-
|
|
1982
|
-
column.keyIds.forEach((a, b) => {
|
|
1983
|
-
if (data[a] === 1) {
|
|
1984
|
-
stage = column.valueIds[b];
|
|
1985
|
-
}
|
|
1986
|
-
});
|
|
1987
|
-
|
|
1988
|
-
return <span>{stage}</span>;
|
|
1989
|
-
},
|
|
1990
|
-
};
|
|
1991
|
-
case 'time':
|
|
1992
|
-
return {
|
|
1993
|
-
...commonProps,
|
|
1994
|
-
name: column.id,
|
|
1995
|
-
render: ({ data }) => {
|
|
1996
|
-
if (
|
|
1997
|
-
data &&
|
|
1998
|
-
data[column.id] &&
|
|
1999
|
-
moment(data[column.id]).isValid() &&
|
|
2000
|
-
moment(data[column.id]).format(
|
|
2001
|
-
'YYYY-MM-DD'
|
|
2002
|
-
) !== '1970-01-01'
|
|
2003
|
-
) {
|
|
2004
|
-
data = moment(data[column.id]).format(
|
|
2005
|
-
column.format
|
|
2006
|
-
? column.format
|
|
2007
|
-
: 'hh:mm A'
|
|
2008
|
-
);
|
|
2083
|
+
return <span>{stage}</span>;
|
|
2084
|
+
},
|
|
2085
|
+
};
|
|
2086
|
+
case 'time':
|
|
2087
|
+
return {
|
|
2088
|
+
...commonProps,
|
|
2089
|
+
name: column.id,
|
|
2090
|
+
render: ({ data }) => {
|
|
2091
|
+
if (
|
|
2092
|
+
data &&
|
|
2093
|
+
data[column.id] &&
|
|
2094
|
+
moment(data[column.id]).isValid() &&
|
|
2095
|
+
moment(data[column.id]).format(
|
|
2096
|
+
'YYYY-MM-DD'
|
|
2097
|
+
) !== '1970-01-01'
|
|
2098
|
+
) {
|
|
2099
|
+
data = moment(
|
|
2100
|
+
data[column.id]
|
|
2101
|
+
).format(
|
|
2102
|
+
column.format
|
|
2103
|
+
? column.format
|
|
2104
|
+
: 'hh:mm A'
|
|
2105
|
+
);
|
|
2009
2106
|
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2107
|
+
return <span>{data}</span>;
|
|
2108
|
+
} else {
|
|
2109
|
+
return null;
|
|
2110
|
+
}
|
|
2111
|
+
},
|
|
2112
|
+
};
|
|
2113
|
+
case 'timer':
|
|
2114
|
+
return {
|
|
2115
|
+
...commonProps,
|
|
2116
|
+
name: column.id,
|
|
2117
|
+
render: ({ data }) => {
|
|
2118
|
+
if (
|
|
2119
|
+
data &&
|
|
2120
|
+
data[column.id] &&
|
|
2121
|
+
moment(data[column.id]).isValid() &&
|
|
2122
|
+
moment(data[column.id]).format(
|
|
2123
|
+
'YYYY-MM-DD'
|
|
2124
|
+
) !== '1970-01-01'
|
|
2125
|
+
) {
|
|
2126
|
+
data = moment(
|
|
2127
|
+
data[column.id]
|
|
2128
|
+
).format(
|
|
2129
|
+
column.format
|
|
2130
|
+
? column.format
|
|
2131
|
+
: 'DD-MM-YYYY hh:mm A'
|
|
2132
|
+
);
|
|
2034
2133
|
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2134
|
+
return <span>{data}</span>;
|
|
2135
|
+
} else {
|
|
2136
|
+
let shouldRenderButton = false;
|
|
2038
2137
|
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
const
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
req.
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2138
|
+
if (
|
|
2139
|
+
!column.hasOwnProperty(
|
|
2140
|
+
'require'
|
|
2141
|
+
) ||
|
|
2142
|
+
column.require.length === 0
|
|
2143
|
+
) {
|
|
2144
|
+
shouldRenderButton = true;
|
|
2145
|
+
} else {
|
|
2146
|
+
for (const req of column.require) {
|
|
2147
|
+
if (
|
|
2148
|
+
req.hasOwnProperty('id')
|
|
2149
|
+
) {
|
|
2150
|
+
const hasValue =
|
|
2151
|
+
req.hasOwnProperty(
|
|
2152
|
+
'value'
|
|
2153
|
+
);
|
|
2154
|
+
if (
|
|
2155
|
+
(hasValue &&
|
|
2156
|
+
data[req.id] ===
|
|
2157
|
+
req.value) ||
|
|
2158
|
+
(!hasValue &&
|
|
2159
|
+
data[req.id])
|
|
2160
|
+
) {
|
|
2161
|
+
shouldRenderButton = true;
|
|
2162
|
+
} else {
|
|
2163
|
+
shouldRenderButton = false;
|
|
2164
|
+
break;
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2059
2167
|
}
|
|
2060
2168
|
}
|
|
2061
|
-
}
|
|
2062
|
-
}
|
|
2063
2169
|
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2170
|
+
if (shouldRenderButton) {
|
|
2171
|
+
return (
|
|
2172
|
+
<button
|
|
2173
|
+
className="btn"
|
|
2174
|
+
style={{
|
|
2175
|
+
padding:
|
|
2176
|
+
'0.2em 1em 0.05em 1em',
|
|
2177
|
+
}}
|
|
2178
|
+
onClick={(e) => {
|
|
2179
|
+
e.stopPropagation();
|
|
2180
|
+
e.preventDefault();
|
|
2181
|
+
|
|
2182
|
+
// Check if every required field in column.validate exists and is truthy in data
|
|
2183
|
+
const isValid =
|
|
2184
|
+
column.validate?.every(
|
|
2185
|
+
(v) =>
|
|
2186
|
+
data[v]
|
|
2187
|
+
) ?? true;
|
|
2188
|
+
|
|
2189
|
+
if (isValid) {
|
|
2190
|
+
handleTimer(
|
|
2191
|
+
data[
|
|
2192
|
+
form
|
|
2193
|
+
.primaryKey
|
|
2194
|
+
],
|
|
2195
|
+
column.id
|
|
2196
|
+
);
|
|
2197
|
+
} else {
|
|
2198
|
+
toast.error(
|
|
2199
|
+
'Please complete the required fields before starting the timer.'
|
|
2200
|
+
);
|
|
2201
|
+
}
|
|
2202
|
+
}}
|
|
2203
|
+
>
|
|
2204
|
+
<Alarm
|
|
2205
|
+
data-tooltip-id="system-tooltip"
|
|
2206
|
+
data-tooltip-content={`${column.label} Timer`}
|
|
2207
|
+
strokeWidth={2}
|
|
2208
|
+
size={18}
|
|
2209
|
+
className="tdaction"
|
|
2210
|
+
/>
|
|
2211
|
+
</button>
|
|
2212
|
+
);
|
|
2213
|
+
}
|
|
2075
2214
|
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
}
|
|
2215
|
+
return null;
|
|
2216
|
+
}
|
|
2217
|
+
},
|
|
2218
|
+
};
|
|
2219
|
+
case 'url':
|
|
2220
|
+
return {
|
|
2221
|
+
...commonProps,
|
|
2222
|
+
name: column.id,
|
|
2223
|
+
render: ({ data }) => {
|
|
2224
|
+
if (data && data[column.id]) {
|
|
2225
|
+
return (
|
|
2226
|
+
<span>
|
|
2227
|
+
<a
|
|
2228
|
+
href={data[column.id]}
|
|
2229
|
+
target="_blank"
|
|
2230
|
+
>
|
|
2231
|
+
Link
|
|
2232
|
+
</a>
|
|
2233
|
+
</span>
|
|
2234
|
+
);
|
|
2235
|
+
} else {
|
|
2236
|
+
return null;
|
|
2237
|
+
}
|
|
2238
|
+
},
|
|
2239
|
+
};
|
|
2240
|
+
default:
|
|
2241
|
+
columnId = Array.isArray(column.id)
|
|
2242
|
+
? column.id.join('-')
|
|
2243
|
+
: column.id;
|
|
2106
2244
|
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2245
|
+
return {
|
|
2246
|
+
...commonProps,
|
|
2247
|
+
name: columnId,
|
|
2248
|
+
filterEditor: filterEditor,
|
|
2249
|
+
filterEditorProps: filterEditorProps,
|
|
2250
|
+
render: ({ data }) => {
|
|
2251
|
+
if (
|
|
2252
|
+
data &&
|
|
2253
|
+
data[column.id] &&
|
|
2254
|
+
data[column.id] !== ''
|
|
2255
|
+
) {
|
|
2256
|
+
return (
|
|
2257
|
+
<span>
|
|
2258
|
+
{parse(
|
|
2259
|
+
String(data[column.id])
|
|
2260
|
+
)}
|
|
2261
|
+
</span>
|
|
2262
|
+
);
|
|
2263
|
+
} else {
|
|
2264
|
+
return null;
|
|
2265
|
+
}
|
|
2266
|
+
},
|
|
2267
|
+
};
|
|
2268
|
+
}
|
|
2269
|
+
};
|
|
2270
|
+
|
|
2271
|
+
const newColumns = columns.map(renderColumn);
|
|
2272
|
+
|
|
2273
|
+
if (settings.length > 0) {
|
|
2274
|
+
newColumns.push({
|
|
2275
|
+
name: 'setting',
|
|
2276
|
+
header: 'Action',
|
|
2277
|
+
defaultWidth: 100,
|
|
2278
|
+
textAlign: 'center',
|
|
2279
|
+
textVerticalAlign:
|
|
2280
|
+
style && style.text_vertical_align
|
|
2281
|
+
? style.text_vertical_align
|
|
2282
|
+
: 'center',
|
|
2115
2283
|
render: ({ data }) => {
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
Link
|
|
2124
|
-
</a>
|
|
2125
|
-
</span>
|
|
2126
|
-
);
|
|
2127
|
-
} else {
|
|
2128
|
-
return null;
|
|
2129
|
-
}
|
|
2284
|
+
return (
|
|
2285
|
+
<div className="tdactions">
|
|
2286
|
+
{settings.map((setting) =>
|
|
2287
|
+
renderSetting(setting, data)
|
|
2288
|
+
)}
|
|
2289
|
+
</div>
|
|
2290
|
+
);
|
|
2130
2291
|
},
|
|
2131
|
-
};
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2292
|
+
});
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
setGridColumns(newColumns);
|
|
2296
|
+
|
|
2297
|
+
const newFilterValue = columns
|
|
2298
|
+
.filter((column) => column.filter && column.filter.type) // Only consider columns with a filter type
|
|
2299
|
+
.map((column) => {
|
|
2300
|
+
// Map these filtered columns to a new object array
|
|
2301
|
+
let filterName = '';
|
|
2302
|
+
if (Array.isArray(column.id)) {
|
|
2303
|
+
filterName = column.id.reduce(
|
|
2304
|
+
(acc, id) => acc + `${id}.`,
|
|
2305
|
+
''
|
|
2306
|
+
);
|
|
2307
|
+
} else {
|
|
2308
|
+
if (column.type === 'address') {
|
|
2309
|
+
filterName = `address.${column.id}`;
|
|
2149
2310
|
} else {
|
|
2150
|
-
|
|
2311
|
+
filterName = column.id;
|
|
2151
2312
|
}
|
|
2152
|
-
}
|
|
2153
|
-
};
|
|
2154
|
-
}
|
|
2155
|
-
};
|
|
2156
|
-
|
|
2157
|
-
const newColumns = columns.map(renderColumn);
|
|
2158
|
-
|
|
2159
|
-
if (settings.length > 0) {
|
|
2160
|
-
newColumns.push({
|
|
2161
|
-
name: 'setting',
|
|
2162
|
-
header: 'Action',
|
|
2163
|
-
defaultWidth: 100,
|
|
2164
|
-
textAlign: 'center',
|
|
2165
|
-
textVerticalAlign:
|
|
2166
|
-
style && style.text_vertical_align
|
|
2167
|
-
? style.text_vertical_align
|
|
2168
|
-
: 'center',
|
|
2169
|
-
render: ({ data }) => {
|
|
2170
|
-
return (
|
|
2171
|
-
<div className="tdactions">
|
|
2172
|
-
{settings.map((setting) =>
|
|
2173
|
-
renderSetting(setting, data)
|
|
2174
|
-
)}
|
|
2175
|
-
</div>
|
|
2176
|
-
);
|
|
2177
|
-
},
|
|
2178
|
-
});
|
|
2179
|
-
}
|
|
2313
|
+
}
|
|
2180
2314
|
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
.filter((column) => column.filter && column.filter.type) // Only consider columns with a filter type
|
|
2185
|
-
.map((column) => {
|
|
2186
|
-
// Map these filtered columns to a new object array
|
|
2187
|
-
let filterName = '';
|
|
2188
|
-
if (Array.isArray(column.id)) {
|
|
2189
|
-
filterName = column.id.reduce(
|
|
2190
|
-
(acc, id) => acc + `${id}.`,
|
|
2191
|
-
''
|
|
2192
|
-
);
|
|
2193
|
-
} else {
|
|
2194
|
-
if (column.type === 'address') {
|
|
2195
|
-
filterName = `address.${column.id}`;
|
|
2196
|
-
} else {
|
|
2197
|
-
filterName = column.id;
|
|
2198
|
-
}
|
|
2199
|
-
}
|
|
2315
|
+
if (column.nameFrom) {
|
|
2316
|
+
filterName += column.nameFrom;
|
|
2317
|
+
}
|
|
2200
2318
|
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2319
|
+
return {
|
|
2320
|
+
key: column.filter.key
|
|
2321
|
+
? column.filter.key
|
|
2322
|
+
: null,
|
|
2323
|
+
name: filterName,
|
|
2324
|
+
operator: column.filter.operator,
|
|
2325
|
+
type: column.filter.type,
|
|
2326
|
+
value: column.filter.value
|
|
2327
|
+
? column.filter.value
|
|
2328
|
+
: '',
|
|
2329
|
+
reset: column.filter.reset
|
|
2330
|
+
? column.filter.reset
|
|
2331
|
+
: [],
|
|
2332
|
+
};
|
|
2333
|
+
});
|
|
2204
2334
|
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
value: column.filter.value ? column.filter.value : '',
|
|
2211
|
-
reset: column.filter.reset ? column.filter.reset : [],
|
|
2212
|
-
};
|
|
2335
|
+
setFilterValue(newFilterValue);
|
|
2336
|
+
setSelected([]);
|
|
2337
|
+
})
|
|
2338
|
+
.catch((error) => {
|
|
2339
|
+
console.error('Error in fetching dropdown data: ', error);
|
|
2213
2340
|
});
|
|
2214
|
-
|
|
2215
|
-
setFilterValue(newFilterValue);
|
|
2216
|
-
setSelected([]);
|
|
2217
2341
|
}, [columns, filterDataSource]);
|
|
2218
2342
|
|
|
2219
2343
|
useEffect(() => {
|
|
@@ -2420,6 +2544,7 @@ const DataGrid = forwardRef(
|
|
|
2420
2544
|
formSettings={formData}
|
|
2421
2545
|
formType={formType}
|
|
2422
2546
|
mapbox={mapbox}
|
|
2547
|
+
paramValue={paramValue}
|
|
2423
2548
|
style={style}
|
|
2424
2549
|
updateForm={setFormData}
|
|
2425
2550
|
/>
|