datastake-daf 0.6.753 → 0.6.754
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/dist/components/index.js +136 -124
- package/dist/pages/index.js +95 -138
- package/package.json +1 -1
- package/src/@daf/core/components/DynamicForm/index.jsx +46 -31
- package/src/@daf/pages/Summary/Activities/Restoration/helper.js +0 -89
- package/src/@daf/pages/Summary/Activities/Restoration/index.jsx +55 -34
package/dist/components/index.js
CHANGED
|
@@ -9436,29 +9436,24 @@ const processConditionalTableKeys = (tableKeys, item) => {
|
|
|
9436
9436
|
});
|
|
9437
9437
|
return processedKeys;
|
|
9438
9438
|
};
|
|
9439
|
-
const renderFieldData =
|
|
9440
|
-
let getApiBaseUrl = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : () => {};
|
|
9441
|
-
let getAppHeader = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : () => {};
|
|
9442
|
-
let app = arguments.length > 6 ? arguments[6] : undefined;
|
|
9443
|
-
let allValues = arguments.length > 7 ? arguments[7] : undefined;
|
|
9444
|
-
let formValues = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : {};
|
|
9439
|
+
const renderFieldData = (type, value, user, config, getApiBaseUrl = () => {}, getAppHeader = () => {}, app, allValues, formValues = {}) => {
|
|
9445
9440
|
switch (type) {
|
|
9446
9441
|
case 'year':
|
|
9447
9442
|
return value !== '-' ? renderDateFormatted(value, 'YYYY', 'en') : '-';
|
|
9448
9443
|
case 'date':
|
|
9449
9444
|
{
|
|
9450
|
-
const language = user
|
|
9445
|
+
const language = user?.language && user?.language === 'sp' ? 'es' : user?.language;
|
|
9451
9446
|
return value !== '-' ? renderDateFormatted(value, 'DD MMM YYYY', language || 'en') : '-';
|
|
9452
9447
|
}
|
|
9453
9448
|
case 'select':
|
|
9454
9449
|
{
|
|
9455
|
-
const options =
|
|
9450
|
+
const options = config?.options || [];
|
|
9456
9451
|
const option = findOptions(value, options);
|
|
9457
9452
|
return option;
|
|
9458
9453
|
}
|
|
9459
9454
|
case 'multiselect':
|
|
9460
9455
|
{
|
|
9461
|
-
const options =
|
|
9456
|
+
const options = config?.options || [];
|
|
9462
9457
|
const _val = typeof value === 'string' ? value.split(',').map(v => v.trim()) : value;
|
|
9463
9458
|
const option = findOptions(_val, options);
|
|
9464
9459
|
return option.join(', ');
|
|
@@ -9473,7 +9468,7 @@ const renderFieldData = function (type, value, user, config) {
|
|
|
9473
9468
|
formValues: formValues
|
|
9474
9469
|
});
|
|
9475
9470
|
case 'percentage':
|
|
9476
|
-
return value === '-' || value === null || value === undefined ? '-' :
|
|
9471
|
+
return value === '-' || value === null || value === undefined ? '-' : `${value} %`;
|
|
9477
9472
|
case 'geolocation':
|
|
9478
9473
|
{
|
|
9479
9474
|
const val = JSON.parse(value) || {};
|
|
@@ -9487,7 +9482,7 @@ const renderFieldData = function (type, value, user, config) {
|
|
|
9487
9482
|
case 'upload':
|
|
9488
9483
|
case 'videoUpload':
|
|
9489
9484
|
{
|
|
9490
|
-
const documentName = allValues
|
|
9485
|
+
const documentName = allValues?.map(item => item?.name).join(', ');
|
|
9491
9486
|
return documentName;
|
|
9492
9487
|
}
|
|
9493
9488
|
default:
|
|
@@ -9495,27 +9490,25 @@ const renderFieldData = function (type, value, user, config) {
|
|
|
9495
9490
|
}
|
|
9496
9491
|
};
|
|
9497
9492
|
|
|
9498
|
-
const renderValue =
|
|
9499
|
-
|
|
9500
|
-
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
9504
|
-
|
|
9505
|
-
|
|
9506
|
-
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
|
|
9510
|
-
if (!(config !== null && config !== void 0 && config.inputs)) return null;
|
|
9493
|
+
const renderValue = ({
|
|
9494
|
+
value,
|
|
9495
|
+
hasChildren,
|
|
9496
|
+
config,
|
|
9497
|
+
user,
|
|
9498
|
+
getApiBaseUrl = () => {},
|
|
9499
|
+
getAppHeader = () => {},
|
|
9500
|
+
app,
|
|
9501
|
+
allData = {}
|
|
9502
|
+
}) => {
|
|
9503
|
+
if (config?.type === 'groupInputs') {
|
|
9504
|
+
if (!config?.inputs) return null;
|
|
9511
9505
|
const inputKeys = Object.keys(config.inputs).sort((a, b) => {
|
|
9512
|
-
|
|
9513
|
-
const
|
|
9514
|
-
const positionB = ((_config$inputs$b = config.inputs[b]) === null || _config$inputs$b === void 0 ? void 0 : _config$inputs$b.position) || 0;
|
|
9506
|
+
const positionA = config.inputs[a]?.position || 0;
|
|
9507
|
+
const positionB = config.inputs[b]?.position || 0;
|
|
9515
9508
|
return positionA - positionB;
|
|
9516
9509
|
});
|
|
9517
9510
|
const values = inputKeys.map(inputKey => {
|
|
9518
|
-
let inputValue = value
|
|
9511
|
+
let inputValue = value?.[inputKey];
|
|
9519
9512
|
if (inputValue === null || inputValue === undefined || inputValue === '') {
|
|
9520
9513
|
return '';
|
|
9521
9514
|
} else if (typeof inputValue === 'object' && inputValue !== null) {
|
|
@@ -9556,8 +9549,8 @@ const renderValue = _ref => {
|
|
|
9556
9549
|
} else {
|
|
9557
9550
|
displayValue = String(value);
|
|
9558
9551
|
}
|
|
9559
|
-
const fieldType =
|
|
9560
|
-
let cssClass =
|
|
9552
|
+
const fieldType = config?.type || 'text';
|
|
9553
|
+
let cssClass = `tree-value ${fieldType}-type`;
|
|
9561
9554
|
if (displayValue === '-') {
|
|
9562
9555
|
cssClass += ' empty';
|
|
9563
9556
|
}
|
|
@@ -9567,21 +9560,19 @@ const renderValue = _ref => {
|
|
|
9567
9560
|
children: displayValue
|
|
9568
9561
|
});
|
|
9569
9562
|
};
|
|
9570
|
-
const determineHasChildren =
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
} = _ref2;
|
|
9576
|
-
if ((config === null || config === void 0 ? void 0 : config.type) === 'groupInputs') {
|
|
9563
|
+
const determineHasChildren = ({
|
|
9564
|
+
config,
|
|
9565
|
+
level
|
|
9566
|
+
}) => {
|
|
9567
|
+
if (config?.type === 'groupInputs') {
|
|
9577
9568
|
return false;
|
|
9578
9569
|
}
|
|
9579
|
-
if (
|
|
9570
|
+
if (config?.type === 'header' && config?.inputs && Object.keys(config.inputs).length > 0) {
|
|
9580
9571
|
return true;
|
|
9581
9572
|
}
|
|
9582
|
-
return
|
|
9573
|
+
return config?.inputs || config?.type === 'group' || config?.type === 'dataLinkGroup' || config?.type === 'section' || config?.type === 'ajaxSubGroup' ||
|
|
9583
9574
|
// Add this line
|
|
9584
|
-
|
|
9575
|
+
config?.type === 'dataLink' && config?.meta?.tableKeys || level === 0 && config && typeof config === 'object' && Object.keys(config).some(key => key !== 'id' && key !== 'label' && key !== 'position' && key !== 'subTitle' && typeof config[key] === 'object' && config[key] !== null);
|
|
9585
9576
|
};
|
|
9586
9577
|
|
|
9587
9578
|
const sortByPosition = (items, getConfig) => {
|
|
@@ -10070,37 +10061,42 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
|
|
|
10070
10061
|
}
|
|
10071
10062
|
};
|
|
10072
10063
|
|
|
10073
|
-
const handleDataLinkWithTableKeys =
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
|
|
10084
|
-
|
|
10085
|
-
|
|
10086
|
-
|
|
10087
|
-
|
|
10064
|
+
const handleDataLinkWithTableKeys = _ref => {
|
|
10065
|
+
var _inputConfig$meta, _inputConfig$meta3, _inputConfig$meta4, _inputConfig$meta5;
|
|
10066
|
+
let {
|
|
10067
|
+
inputConfig,
|
|
10068
|
+
inputKey,
|
|
10069
|
+
value,
|
|
10070
|
+
level,
|
|
10071
|
+
t,
|
|
10072
|
+
rootForm,
|
|
10073
|
+
allData,
|
|
10074
|
+
user,
|
|
10075
|
+
getApiBaseUrl = () => {},
|
|
10076
|
+
getAppHeader = () => {},
|
|
10077
|
+
app,
|
|
10078
|
+
TreeNodeComponent
|
|
10079
|
+
} = _ref;
|
|
10080
|
+
if ((inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type) !== 'dataLink' || !(inputConfig !== null && inputConfig !== void 0 && (_inputConfig$meta = inputConfig.meta) !== null && _inputConfig$meta !== void 0 && _inputConfig$meta.tableKeys)) {
|
|
10088
10081
|
return null;
|
|
10089
10082
|
}
|
|
10090
10083
|
const tableKeys = inputConfig.meta.tableKeys;
|
|
10091
|
-
const isAjaxModal = React.useMemo(() =>
|
|
10084
|
+
const isAjaxModal = React.useMemo(() => {
|
|
10085
|
+
var _inputConfig$meta2;
|
|
10086
|
+
return !!(inputConfig !== null && inputConfig !== void 0 && (_inputConfig$meta2 = inputConfig.meta) !== null && _inputConfig$meta2 !== void 0 && _inputConfig$meta2.namespace);
|
|
10087
|
+
}, [inputConfig]);
|
|
10092
10088
|
const ajaxModalValues = useAjaxModal$2({
|
|
10093
10089
|
name: inputKey,
|
|
10094
10090
|
user,
|
|
10095
|
-
namespace: inputConfig
|
|
10096
|
-
skipFetch: inputConfig
|
|
10091
|
+
namespace: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta3 = inputConfig.meta) === null || _inputConfig$meta3 === void 0 ? void 0 : _inputConfig$meta3.namespace,
|
|
10092
|
+
skipFetch: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta4 = inputConfig.meta) === null || _inputConfig$meta4 === void 0 ? void 0 : _inputConfig$meta4.skipFetch,
|
|
10097
10093
|
isAjaxModal,
|
|
10098
|
-
formScope: inputConfig
|
|
10094
|
+
formScope: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta5 = inputConfig.meta) === null || _inputConfig$meta5 === void 0 ? void 0 : _inputConfig$meta5.formScope,
|
|
10099
10095
|
APP: app,
|
|
10100
10096
|
apiBaseUrl: getApiBaseUrl(),
|
|
10101
10097
|
_getAppHeader: getAppHeader
|
|
10102
10098
|
});
|
|
10103
|
-
const dataLinkForm = ajaxModalValues
|
|
10099
|
+
const dataLinkForm = ajaxModalValues === null || ajaxModalValues === void 0 ? void 0 : ajaxModalValues.form;
|
|
10104
10100
|
const createInputsAndValues = item => {
|
|
10105
10101
|
const inputs = {};
|
|
10106
10102
|
const values = {};
|
|
@@ -10113,19 +10109,20 @@ const handleDataLinkWithTableKeys = ({
|
|
|
10113
10109
|
};
|
|
10114
10110
|
const isUploadFieldEmpty = (fieldKey, itemToCheck) => {
|
|
10115
10111
|
if (uploadTypeFields.includes(fieldKey)) {
|
|
10116
|
-
const itemValue = itemToCheck
|
|
10112
|
+
const itemValue = itemToCheck === null || itemToCheck === void 0 ? void 0 : itemToCheck[fieldKey];
|
|
10117
10113
|
return itemValue === undefined || itemValue === null || Array.isArray(itemValue) && itemValue.length === 0;
|
|
10118
10114
|
}
|
|
10119
10115
|
return false;
|
|
10120
10116
|
};
|
|
10121
10117
|
const processedTableKeys = processConditionalTableKeys(tableKeys, item);
|
|
10122
10118
|
processedTableKeys.filter(tableKey => tableKey !== 'datastakeId').filter(tableKey => !isUploadFieldEmpty(tableKey, item)).forEach(tableKey => {
|
|
10123
|
-
|
|
10119
|
+
var _dataLinkForm$identif;
|
|
10120
|
+
const formInputConfig = (dataLinkForm === null || dataLinkForm === void 0 ? void 0 : dataLinkForm[tableKey]) || (dataLinkForm === null || dataLinkForm === void 0 || (_dataLinkForm$identif = dataLinkForm['identification']) === null || _dataLinkForm$identif === void 0 ? void 0 : _dataLinkForm$identif[tableKey]);
|
|
10124
10121
|
if (formInputConfig) {
|
|
10125
|
-
|
|
10126
|
-
|
|
10122
|
+
var _item$linking, _formInputConfig$meta, _formInputConfig$tabl;
|
|
10123
|
+
inputs[tableKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
|
|
10127
10124
|
label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : formInputConfig.label || formInputConfig.tableLabel || tableKey
|
|
10128
|
-
};
|
|
10125
|
+
});
|
|
10129
10126
|
if (formInputConfig.label && typeof formInputConfig.label === 'object') {
|
|
10130
10127
|
const dynamicLabelKeys = Object.keys(formInputConfig.label);
|
|
10131
10128
|
let resolvedLabel = null;
|
|
@@ -10133,7 +10130,7 @@ const handleDataLinkWithTableKeys = ({
|
|
|
10133
10130
|
const parts = labelKey.split(' is ');
|
|
10134
10131
|
if (parts.length === 2) {
|
|
10135
10132
|
const [conditionKey, conditionValue] = parts;
|
|
10136
|
-
if (item
|
|
10133
|
+
if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
|
|
10137
10134
|
resolvedLabel = formInputConfig.label[labelKey];
|
|
10138
10135
|
break;
|
|
10139
10136
|
}
|
|
@@ -10141,16 +10138,17 @@ const handleDataLinkWithTableKeys = ({
|
|
|
10141
10138
|
}
|
|
10142
10139
|
inputs[tableKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey);
|
|
10143
10140
|
}
|
|
10144
|
-
values[tableKey] = item
|
|
10141
|
+
values[tableKey] = (item === null || item === void 0 || (_item$linking = item.linking) === null || _item$linking === void 0 || (_item$linking = _item$linking.SCL) === null || _item$linking === void 0 || (_item$linking = _item$linking[item === null || item === void 0 ? void 0 : item[tableKey]]) === null || _item$linking === void 0 ? void 0 : _item$linking.name) || item[formInputConfig === null || formInputConfig === void 0 || (_formInputConfig$meta = formInputConfig.meta) === null || _formInputConfig$meta === void 0 ? void 0 : _formInputConfig$meta.onNewSetValueKey] || (item === null || item === void 0 ? void 0 : item[formInputConfig === null || formInputConfig === void 0 || (_formInputConfig$tabl = formInputConfig.tableLabel) === null || _formInputConfig$tabl === void 0 ? void 0 : _formInputConfig$tabl.toLowerCase()]) || (item === null || item === void 0 ? void 0 : item[tableKey]);
|
|
10145
10142
|
} else {
|
|
10143
|
+
var _item$linking2;
|
|
10146
10144
|
inputs[tableKey] = {
|
|
10147
10145
|
label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey,
|
|
10148
|
-
type: inputConfig
|
|
10146
|
+
type: inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type
|
|
10149
10147
|
};
|
|
10150
|
-
values[tableKey] = item
|
|
10148
|
+
values[tableKey] = (item === null || item === void 0 || (_item$linking2 = item.linking) === null || _item$linking2 === void 0 || (_item$linking2 = _item$linking2.SCL) === null || _item$linking2 === void 0 || (_item$linking2 = _item$linking2[item === null || item === void 0 ? void 0 : item[tableKey]]) === null || _item$linking2 === void 0 ? void 0 : _item$linking2.name) || (item === null || item === void 0 ? void 0 : item[tableKey]);
|
|
10151
10149
|
}
|
|
10152
10150
|
});
|
|
10153
|
-
if (dataLinkForm
|
|
10151
|
+
if (dataLinkForm !== null && dataLinkForm !== void 0 && dataLinkForm.identification && typeof dataLinkForm.identification === 'object') {
|
|
10154
10152
|
Object.keys(dataLinkForm.identification).filter(fieldKey => {
|
|
10155
10153
|
if (uploadTypeFields.includes(fieldKey)) {
|
|
10156
10154
|
return !isUploadFieldEmpty(fieldKey, item);
|
|
@@ -10160,11 +10158,11 @@ const handleDataLinkWithTableKeys = ({
|
|
|
10160
10158
|
const formInputConfig = dataLinkForm.identification[fieldKey];
|
|
10161
10159
|
return formInputConfig && typeof formInputConfig === 'object' && !Array.isArray(formInputConfig);
|
|
10162
10160
|
}).forEach(fieldKey => {
|
|
10161
|
+
var _item$linking3, _formInputConfig$tabl2;
|
|
10163
10162
|
const formInputConfig = dataLinkForm.identification[fieldKey];
|
|
10164
|
-
inputs[fieldKey] = {
|
|
10165
|
-
...formInputConfig,
|
|
10163
|
+
inputs[fieldKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
|
|
10166
10164
|
label: uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : formInputConfig.label || formInputConfig.tableLabel || fieldKey
|
|
10167
|
-
};
|
|
10165
|
+
});
|
|
10168
10166
|
if (formInputConfig.label && typeof formInputConfig.label === 'object') {
|
|
10169
10167
|
const dynamicLabelKeys = Object.keys(formInputConfig.label);
|
|
10170
10168
|
let resolvedLabel = null;
|
|
@@ -10172,7 +10170,7 @@ const handleDataLinkWithTableKeys = ({
|
|
|
10172
10170
|
const parts = labelKey.split(' is ');
|
|
10173
10171
|
if (parts.length === 2) {
|
|
10174
10172
|
const [conditionKey, conditionValue] = parts;
|
|
10175
|
-
if (item
|
|
10173
|
+
if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
|
|
10176
10174
|
resolvedLabel = formInputConfig.label[labelKey];
|
|
10177
10175
|
break;
|
|
10178
10176
|
}
|
|
@@ -10180,7 +10178,7 @@ const handleDataLinkWithTableKeys = ({
|
|
|
10180
10178
|
}
|
|
10181
10179
|
inputs[fieldKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : fieldKey);
|
|
10182
10180
|
}
|
|
10183
|
-
values[fieldKey] = item
|
|
10181
|
+
values[fieldKey] = (item === null || item === void 0 || (_item$linking3 = item.linking) === null || _item$linking3 === void 0 || (_item$linking3 = _item$linking3.SCL) === null || _item$linking3 === void 0 || (_item$linking3 = _item$linking3[item === null || item === void 0 ? void 0 : item[fieldKey]]) === null || _item$linking3 === void 0 ? void 0 : _item$linking3.name) || (item === null || item === void 0 ? void 0 : item[formInputConfig === null || formInputConfig === void 0 || (_formInputConfig$tabl2 = formInputConfig.tableLabel) === null || _formInputConfig$tabl2 === void 0 ? void 0 : _formInputConfig$tabl2.toLowerCase()]) || (item === null || item === void 0 ? void 0 : item[fieldKey]);
|
|
10184
10182
|
});
|
|
10185
10183
|
}
|
|
10186
10184
|
return {
|
|
@@ -10190,7 +10188,7 @@ const handleDataLinkWithTableKeys = ({
|
|
|
10190
10188
|
};
|
|
10191
10189
|
if (Array.isArray(value)) {
|
|
10192
10190
|
return value.map((item, itemIndex) => {
|
|
10193
|
-
const datastakeIdValue = item
|
|
10191
|
+
const datastakeIdValue = item === null || item === void 0 ? void 0 : item.datastakeId;
|
|
10194
10192
|
const {
|
|
10195
10193
|
inputs,
|
|
10196
10194
|
values
|
|
@@ -10199,9 +10197,9 @@ const handleDataLinkWithTableKeys = ({
|
|
|
10199
10197
|
return null;
|
|
10200
10198
|
}
|
|
10201
10199
|
return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
|
|
10202
|
-
nodeKey: datastakeIdValue || t(
|
|
10200
|
+
nodeKey: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
|
|
10203
10201
|
config: {
|
|
10204
|
-
label: datastakeIdValue || t(
|
|
10202
|
+
label: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
|
|
10205
10203
|
type: 'custom-datalink',
|
|
10206
10204
|
inputs: inputs
|
|
10207
10205
|
},
|
|
@@ -10215,10 +10213,10 @@ const handleDataLinkWithTableKeys = ({
|
|
|
10215
10213
|
getApiBaseUrl: getApiBaseUrl,
|
|
10216
10214
|
getAppHeader: getAppHeader,
|
|
10217
10215
|
app: app
|
|
10218
|
-
},
|
|
10216
|
+
}, "".concat(inputKey, "-").concat(itemIndex));
|
|
10219
10217
|
});
|
|
10220
10218
|
} else {
|
|
10221
|
-
const datastakeIdValue = value
|
|
10219
|
+
const datastakeIdValue = value === null || value === void 0 ? void 0 : value.datastakeId;
|
|
10222
10220
|
const {
|
|
10223
10221
|
inputs,
|
|
10224
10222
|
values
|
|
@@ -10243,24 +10241,25 @@ const handleDataLinkWithTableKeys = ({
|
|
|
10243
10241
|
getApiBaseUrl: getApiBaseUrl,
|
|
10244
10242
|
getAppHeader: getAppHeader,
|
|
10245
10243
|
app: app
|
|
10246
|
-
},
|
|
10244
|
+
}, "".concat(inputKey, "-single"));
|
|
10247
10245
|
}
|
|
10248
10246
|
};
|
|
10249
10247
|
|
|
10250
|
-
const handleGroupChildren =
|
|
10251
|
-
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
|
|
10257
|
-
|
|
10258
|
-
|
|
10259
|
-
|
|
10260
|
-
|
|
10261
|
-
|
|
10262
|
-
|
|
10263
|
-
|
|
10248
|
+
const handleGroupChildren = _ref => {
|
|
10249
|
+
let {
|
|
10250
|
+
config,
|
|
10251
|
+
value,
|
|
10252
|
+
allData,
|
|
10253
|
+
level,
|
|
10254
|
+
t,
|
|
10255
|
+
rootForm,
|
|
10256
|
+
user,
|
|
10257
|
+
getApiBaseUrl = () => {},
|
|
10258
|
+
getAppHeader = () => {},
|
|
10259
|
+
app,
|
|
10260
|
+
TreeNodeComponent
|
|
10261
|
+
} = _ref;
|
|
10262
|
+
if (!(config !== null && config !== void 0 && config.inputs)) {
|
|
10264
10263
|
return null;
|
|
10265
10264
|
}
|
|
10266
10265
|
const inputKeys = Object.keys(config.inputs);
|
|
@@ -10273,7 +10272,7 @@ const handleGroupChildren = ({
|
|
|
10273
10272
|
if (value && typeof value === 'object' && value[inputKey]) {
|
|
10274
10273
|
inputValue = value[inputKey];
|
|
10275
10274
|
} else {
|
|
10276
|
-
inputValue = allData
|
|
10275
|
+
inputValue = allData === null || allData === void 0 ? void 0 : allData[inputKey];
|
|
10277
10276
|
}
|
|
10278
10277
|
return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
|
|
10279
10278
|
nodeKey: inputKey,
|
|
@@ -39899,43 +39898,56 @@ function DynamicForm(_ref) {
|
|
|
39899
39898
|
// setOriginalData({});
|
|
39900
39899
|
// setValues({});
|
|
39901
39900
|
// MainForm.resetFields();
|
|
39901
|
+
} else if (isCreate) {
|
|
39902
|
+
// Reset form when data is empty in create mode (e.g., when switching contexts)
|
|
39903
|
+
setOriginalData({});
|
|
39904
|
+
setValues({});
|
|
39905
|
+
MainForm.resetFields();
|
|
39902
39906
|
}
|
|
39903
|
-
}, [data]);
|
|
39907
|
+
}, [data, isCreate]);
|
|
39904
39908
|
|
|
39905
39909
|
// Initialize default values for hidden and disabled fields
|
|
39906
39910
|
React.useEffect(() => {
|
|
39907
39911
|
if (Object.keys(form).length > 0) {
|
|
39908
|
-
|
|
39909
|
-
|
|
39910
|
-
|
|
39911
|
-
|
|
39912
|
-
|
|
39913
|
-
|
|
39914
|
-
|
|
39915
|
-
|
|
39916
|
-
|
|
39917
|
-
|
|
39918
|
-
|
|
39919
|
-
|
|
39920
|
-
|
|
39921
|
-
|
|
39922
|
-
|
|
39923
|
-
|
|
39924
|
-
|
|
39925
|
-
|
|
39926
|
-
|
|
39927
|
-
|
|
39912
|
+
setValues(prevValues => {
|
|
39913
|
+
// Use data prop as base, or current values if data is empty
|
|
39914
|
+
const baseValues = Object.keys(data).length > 0 ? data : prevValues;
|
|
39915
|
+
const updatedValues = _objectSpread2({}, baseValues);
|
|
39916
|
+
let hasChanges = false;
|
|
39917
|
+
const isEditMode = data && (data.id || data._id);
|
|
39918
|
+
|
|
39919
|
+
// Process all form fields to set default values for hidden and disabled fields
|
|
39920
|
+
Object.keys(form).forEach(formKey => {
|
|
39921
|
+
Object.keys(form[formKey]).forEach(fieldKey => {
|
|
39922
|
+
var _field$meta, _field$meta2, _field$meta3, _field$meta4, _field$meta5, _field$meta6;
|
|
39923
|
+
const field = form[formKey][fieldKey];
|
|
39924
|
+
const fieldId = field.dataId || fieldKey;
|
|
39925
|
+
|
|
39926
|
+
// Check if field is disabled
|
|
39927
|
+
const isDisabled = field !== null && field !== void 0 && (_field$meta = field.meta) !== null && _field$meta !== void 0 && _field$meta.disableEdit && typeof (field === null || field === void 0 || (_field$meta2 = field.meta) === null || _field$meta2 === void 0 ? void 0 : _field$meta2.disableEdit) === 'object' ? isModal ? field.meta.disableEdit.create || field.meta.disableEdit.modal || (field === null || field === void 0 || (_field$meta3 = field.meta) === null || _field$meta3 === void 0 || (_field$meta3 = _field$meta3.disableEdit) === null || _field$meta3 === void 0 ? void 0 : _field$meta3.edit) && isEditMode : field.meta.disableEdit.create || field.meta.disableEdit.drawer || (field === null || field === void 0 || (_field$meta4 = field.meta) === null || _field$meta4 === void 0 || (_field$meta4 = _field$meta4.disableEdit) === null || _field$meta4 === void 0 ? void 0 : _field$meta4.edit) && isEditMode : field === null || field === void 0 || (_field$meta5 = field.meta) === null || _field$meta5 === void 0 ? void 0 : _field$meta5.disableEdit;
|
|
39928
|
+
|
|
39929
|
+
// Set default value for hidden fields or disabled fields with default values
|
|
39930
|
+
if ((field === null || field === void 0 || (_field$meta6 = field.meta) === null || _field$meta6 === void 0 ? void 0 : _field$meta6.defaultValue) !== undefined) {
|
|
39931
|
+
var _field$meta7, _field$meta8;
|
|
39932
|
+
// In create mode, always update disabled/hidden fields with default values when form config changes
|
|
39933
|
+
// This ensures context switching (Operation -> Restoration) updates the field correctly
|
|
39934
|
+
const shouldUpdate = !propHasValue(updatedValues[fieldId]) || isCreate && !isEditMode && ((field === null || field === void 0 || (_field$meta7 = field.meta) === null || _field$meta7 === void 0 ? void 0 : _field$meta7.hidden) === true || isDisabled);
|
|
39935
|
+
if (shouldUpdate && ((field === null || field === void 0 || (_field$meta8 = field.meta) === null || _field$meta8 === void 0 ? void 0 : _field$meta8.hidden) === true || isDisabled)) {
|
|
39936
|
+
updatedValues[fieldId] = field.meta.defaultValue;
|
|
39937
|
+
hasChanges = true;
|
|
39938
|
+
}
|
|
39928
39939
|
}
|
|
39929
|
-
}
|
|
39940
|
+
});
|
|
39930
39941
|
});
|
|
39942
|
+
if (hasChanges) {
|
|
39943
|
+
// Also set the values in the Ant Design form
|
|
39944
|
+
MainForm.setFieldsValue(updatedValues);
|
|
39945
|
+
return updatedValues;
|
|
39946
|
+
}
|
|
39947
|
+
return prevValues;
|
|
39931
39948
|
});
|
|
39932
|
-
if (hasChanges) {
|
|
39933
|
-
setValues(updatedValues);
|
|
39934
|
-
// Also set the values in the Ant Design form
|
|
39935
|
-
MainForm.setFieldsValue(updatedValues);
|
|
39936
|
-
}
|
|
39937
39949
|
}
|
|
39938
|
-
}, [form, data, isModal]);
|
|
39950
|
+
}, [form, data, isModal, isCreate]);
|
|
39939
39951
|
const setSelectedForm = id => {
|
|
39940
39952
|
setForms(Forms.map(form => {
|
|
39941
39953
|
id === form.id ? form.selected = true : form.selected = false;
|
package/dist/pages/index.js
CHANGED
|
@@ -29371,43 +29371,56 @@ function DynamicForm({
|
|
|
29371
29371
|
// setOriginalData({});
|
|
29372
29372
|
// setValues({});
|
|
29373
29373
|
// MainForm.resetFields();
|
|
29374
|
+
} else if (isCreate) {
|
|
29375
|
+
// Reset form when data is empty in create mode (e.g., when switching contexts)
|
|
29376
|
+
setOriginalData({});
|
|
29377
|
+
setValues({});
|
|
29378
|
+
MainForm.resetFields();
|
|
29374
29379
|
}
|
|
29375
|
-
}, [data]);
|
|
29380
|
+
}, [data, isCreate]);
|
|
29376
29381
|
|
|
29377
29382
|
// Initialize default values for hidden and disabled fields
|
|
29378
29383
|
React.useEffect(() => {
|
|
29379
29384
|
if (Object.keys(form).length > 0) {
|
|
29380
|
-
|
|
29381
|
-
|
|
29382
|
-
|
|
29383
|
-
|
|
29384
|
-
|
|
29385
|
-
|
|
29386
|
-
|
|
29387
|
-
|
|
29388
|
-
|
|
29389
|
-
|
|
29390
|
-
|
|
29391
|
-
|
|
29392
|
-
|
|
29393
|
-
|
|
29394
|
-
|
|
29395
|
-
|
|
29396
|
-
|
|
29397
|
-
|
|
29398
|
-
|
|
29399
|
-
|
|
29385
|
+
setValues(prevValues => {
|
|
29386
|
+
// Use data prop as base, or current values if data is empty
|
|
29387
|
+
const baseValues = Object.keys(data).length > 0 ? data : prevValues;
|
|
29388
|
+
const updatedValues = {
|
|
29389
|
+
...baseValues
|
|
29390
|
+
};
|
|
29391
|
+
let hasChanges = false;
|
|
29392
|
+
const isEditMode = data && (data.id || data._id);
|
|
29393
|
+
|
|
29394
|
+
// Process all form fields to set default values for hidden and disabled fields
|
|
29395
|
+
Object.keys(form).forEach(formKey => {
|
|
29396
|
+
Object.keys(form[formKey]).forEach(fieldKey => {
|
|
29397
|
+
const field = form[formKey][fieldKey];
|
|
29398
|
+
const fieldId = field.dataId || fieldKey;
|
|
29399
|
+
|
|
29400
|
+
// Check if field is disabled
|
|
29401
|
+
const isDisabled = field?.meta?.disableEdit && typeof field?.meta?.disableEdit === 'object' ? isModal ? field.meta.disableEdit.create || field.meta.disableEdit.modal || field?.meta?.disableEdit?.edit && isEditMode : field.meta.disableEdit.create || field.meta.disableEdit.drawer || field?.meta?.disableEdit?.edit && isEditMode : field?.meta?.disableEdit;
|
|
29402
|
+
|
|
29403
|
+
// Set default value for hidden fields or disabled fields with default values
|
|
29404
|
+
if (field?.meta?.defaultValue !== undefined) {
|
|
29405
|
+
// In create mode, always update disabled/hidden fields with default values when form config changes
|
|
29406
|
+
// This ensures context switching (Operation -> Restoration) updates the field correctly
|
|
29407
|
+
const shouldUpdate = !propHasValue(updatedValues[fieldId]) || isCreate && !isEditMode && (field?.meta?.hidden === true || isDisabled);
|
|
29408
|
+
if (shouldUpdate && (field?.meta?.hidden === true || isDisabled)) {
|
|
29409
|
+
updatedValues[fieldId] = field.meta.defaultValue;
|
|
29410
|
+
hasChanges = true;
|
|
29411
|
+
}
|
|
29400
29412
|
}
|
|
29401
|
-
}
|
|
29413
|
+
});
|
|
29402
29414
|
});
|
|
29415
|
+
if (hasChanges) {
|
|
29416
|
+
// Also set the values in the Ant Design form
|
|
29417
|
+
MainForm.setFieldsValue(updatedValues);
|
|
29418
|
+
return updatedValues;
|
|
29419
|
+
}
|
|
29420
|
+
return prevValues;
|
|
29403
29421
|
});
|
|
29404
|
-
if (hasChanges) {
|
|
29405
|
-
setValues(updatedValues);
|
|
29406
|
-
// Also set the values in the Ant Design form
|
|
29407
|
-
MainForm.setFieldsValue(updatedValues);
|
|
29408
|
-
}
|
|
29409
29422
|
}
|
|
29410
|
-
}, [form, data, isModal]);
|
|
29423
|
+
}, [form, data, isModal, isCreate]);
|
|
29411
29424
|
const setSelectedForm = id => {
|
|
29412
29425
|
setForms(Forms.map(form => {
|
|
29413
29426
|
id === form.id ? form.selected = true : form.selected = false;
|
|
@@ -40813,6 +40826,13 @@ const getKeyIndicatorsRowConfig = ({
|
|
|
40813
40826
|
})
|
|
40814
40827
|
}];
|
|
40815
40828
|
|
|
40829
|
+
// ============================================================================
|
|
40830
|
+
// REGION: Photo/Image Extraction
|
|
40831
|
+
// ============================================================================
|
|
40832
|
+
|
|
40833
|
+
/**
|
|
40834
|
+
* Normalize URL by removing trailing colon if present
|
|
40835
|
+
*/
|
|
40816
40836
|
const normalizeUrl = url => url?.endsWith(':') ? url.slice(0, -1) : url;
|
|
40817
40837
|
|
|
40818
40838
|
/**
|
|
@@ -40925,88 +40945,6 @@ const getGenderTooltipChildren = (item, isEmpty, genderDistributionData, t, rend
|
|
|
40925
40945
|
});
|
|
40926
40946
|
};
|
|
40927
40947
|
|
|
40928
|
-
// ============================================================================
|
|
40929
|
-
// REGION: Multiselect Options
|
|
40930
|
-
// ============================================================================
|
|
40931
|
-
|
|
40932
|
-
/**
|
|
40933
|
-
* Get filtered options for multiselect based on activityData.origin
|
|
40934
|
-
* Filters options based on whether origin contains 'kobo', 'straatos', or both
|
|
40935
|
-
*
|
|
40936
|
-
* @param {Object} activityData - Activity data object containing origin array
|
|
40937
|
-
* @param {React.Component} CustomIcon - CustomIcon component for rendering Monitor option avatar
|
|
40938
|
-
* @returns {Array} - Filtered array of option objects
|
|
40939
|
-
*/
|
|
40940
|
-
const getFilteredOptions = (activityData, CustomIcon) => {
|
|
40941
|
-
const allOptions = [{
|
|
40942
|
-
label: "Own Data",
|
|
40943
|
-
value: "own",
|
|
40944
|
-
avatar: /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
40945
|
-
children: "OWN"
|
|
40946
|
-
}),
|
|
40947
|
-
background: "#016C6E",
|
|
40948
|
-
color: "white"
|
|
40949
|
-
}, {
|
|
40950
|
-
label: "Monitor",
|
|
40951
|
-
value: "other",
|
|
40952
|
-
avatar: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
|
|
40953
|
-
name: "Search02",
|
|
40954
|
-
size: 14
|
|
40955
|
-
})
|
|
40956
|
-
}];
|
|
40957
|
-
if (!activityData?.origin || !Array.isArray(activityData.origin)) {
|
|
40958
|
-
return allOptions;
|
|
40959
|
-
}
|
|
40960
|
-
|
|
40961
|
-
// Extract origin names from the array
|
|
40962
|
-
const originNames = activityData.origin.map(item => item?.name?.toLowerCase()).filter(Boolean);
|
|
40963
|
-
const hasKobo = originNames.includes('kobo');
|
|
40964
|
-
const hasStraatos = originNames.includes('straatos');
|
|
40965
|
-
|
|
40966
|
-
// If contains kobo only, show only Monitor
|
|
40967
|
-
if (hasKobo && !hasStraatos) {
|
|
40968
|
-
return allOptions.filter(option => option.value === 'other');
|
|
40969
|
-
}
|
|
40970
|
-
|
|
40971
|
-
// If contains straatos only, show only Own Data
|
|
40972
|
-
if (hasStraatos && !hasKobo) {
|
|
40973
|
-
return allOptions.filter(option => option.value === 'own');
|
|
40974
|
-
}
|
|
40975
|
-
|
|
40976
|
-
// If contains both or neither, show both
|
|
40977
|
-
return allOptions;
|
|
40978
|
-
};
|
|
40979
|
-
|
|
40980
|
-
/**
|
|
40981
|
-
* Get default selected value for multiselect based on activityData.origin
|
|
40982
|
-
*
|
|
40983
|
-
* @param {Object} activityData - Activity data object containing origin array
|
|
40984
|
-
* @returns {Array} - Array of default selected values
|
|
40985
|
-
*/
|
|
40986
|
-
const getDefaultSelected = activityData => {
|
|
40987
|
-
if (!activityData?.origin || !Array.isArray(activityData.origin)) {
|
|
40988
|
-
return ['own'];
|
|
40989
|
-
}
|
|
40990
|
-
|
|
40991
|
-
// Extract origin names from the array
|
|
40992
|
-
const originNames = activityData.origin.map(item => item?.name?.toLowerCase()).filter(Boolean);
|
|
40993
|
-
const hasKobo = originNames.includes('kobo');
|
|
40994
|
-
const hasStraatos = originNames.includes('straatos');
|
|
40995
|
-
|
|
40996
|
-
// If contains kobo only, default to monitor (other)
|
|
40997
|
-
if (hasKobo && !hasStraatos) {
|
|
40998
|
-
return ['other'];
|
|
40999
|
-
}
|
|
41000
|
-
|
|
41001
|
-
// If contains straatos only, default to own
|
|
41002
|
-
if (hasStraatos && !hasKobo) {
|
|
41003
|
-
return ['own'];
|
|
41004
|
-
}
|
|
41005
|
-
|
|
41006
|
-
// If contains both or neither, default to own
|
|
41007
|
-
return ['own'];
|
|
41008
|
-
};
|
|
41009
|
-
|
|
41010
40948
|
// ============================================================================
|
|
41011
40949
|
// REGION: Activity Indicators
|
|
41012
40950
|
// ============================================================================
|
|
@@ -41344,12 +41282,6 @@ const RestorationActivitySummary = ({
|
|
|
41344
41282
|
|
|
41345
41283
|
// Activity Indicators Config - mapped from activityData
|
|
41346
41284
|
const activityIndicatorsConfig = React.useMemo(() => getActivityIndicatorsConfig(activityData, t), [activityData, t]);
|
|
41347
|
-
|
|
41348
|
-
// Filter options based on activityData.origin
|
|
41349
|
-
const filteredOptions = React.useMemo(() => getFilteredOptions(activityData, CustomIcon), [activityData]);
|
|
41350
|
-
|
|
41351
|
-
// Get default selected based on activityData.origin
|
|
41352
|
-
const defaultSelected = React.useMemo(() => getDefaultSelected(activityData), [activityData]);
|
|
41353
41285
|
return /*#__PURE__*/jsxRuntime.jsxs(DashboardLayout, {
|
|
41354
41286
|
header: /*#__PURE__*/jsxRuntime.jsx(DAFHeader, {
|
|
41355
41287
|
title: 'Restoration Activity Summary',
|
|
@@ -41359,25 +41291,7 @@ const RestorationActivitySummary = ({
|
|
|
41359
41291
|
actionButtons: actionButtons,
|
|
41360
41292
|
breadcrumbs: breadcrumbs,
|
|
41361
41293
|
goBackTo: goBackTo,
|
|
41362
|
-
loading: loading
|
|
41363
|
-
addedHeaderFirst: true,
|
|
41364
|
-
addedHeader: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
41365
|
-
style: {
|
|
41366
|
-
marginRight: 0
|
|
41367
|
-
},
|
|
41368
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Multiselect, {
|
|
41369
|
-
canUnselectLast: false,
|
|
41370
|
-
options: filteredOptions,
|
|
41371
|
-
isAvatarGroup: true,
|
|
41372
|
-
selectionType: "checkbox",
|
|
41373
|
-
onChange: selected => {
|
|
41374
|
-
console.log(selected);
|
|
41375
|
-
},
|
|
41376
|
-
dropDownWidth: 200,
|
|
41377
|
-
defaultSelected: defaultSelected,
|
|
41378
|
-
placeholder: "Select partners..."
|
|
41379
|
-
})
|
|
41380
|
-
})
|
|
41294
|
+
loading: loading
|
|
41381
41295
|
}),
|
|
41382
41296
|
children: [/*#__PURE__*/jsxRuntime.jsx("section", {
|
|
41383
41297
|
children: /*#__PURE__*/jsxRuntime.jsx(KeyIndicatorsWidget, {
|
|
@@ -41406,6 +41320,50 @@ const RestorationActivitySummary = ({
|
|
|
41406
41320
|
app: "straatos",
|
|
41407
41321
|
showSider: false,
|
|
41408
41322
|
user: null,
|
|
41323
|
+
data: [{
|
|
41324
|
+
_id: {},
|
|
41325
|
+
id: "7f2aaed4-4b2e-406c-8e0a-6659c5c8367b",
|
|
41326
|
+
color: "#6698E4",
|
|
41327
|
+
parent: {
|
|
41328
|
+
_id: {},
|
|
41329
|
+
createdAt: "2024-06-13T14:51:55.296Z",
|
|
41330
|
+
updatedAt: "2024-06-13T14:51:55.296Z",
|
|
41331
|
+
id: "a5340bf1-2c7d-413f-a2a5-ccd7dc8f7a7c",
|
|
41332
|
+
name: "New Mine",
|
|
41333
|
+
authorId: "4e6066e9-00d8-423a-94ec-c7c9d3432fec",
|
|
41334
|
+
collectId: "f8a2b6a9cc935ef3e5844427f49aade34e152eca",
|
|
41335
|
+
country: "AL",
|
|
41336
|
+
category: "mineSite",
|
|
41337
|
+
datastakeId: "LOC-00000000141",
|
|
41338
|
+
__v: 0
|
|
41339
|
+
},
|
|
41340
|
+
administrativeLevel1: "6839cb26-5af4-44a3-b136-a0f0a0bcecc6",
|
|
41341
|
+
administrativeLevel2: "f849835d-5640-4bee-ae98-9f1c810c1abe",
|
|
41342
|
+
// "name": "New Mine",
|
|
41343
|
+
country: "AL",
|
|
41344
|
+
category: "mineSite",
|
|
41345
|
+
authorId: "4e6066e9-00d8-423a-94ec-c7c9d3432fec",
|
|
41346
|
+
gps: {
|
|
41347
|
+
latitude: 7,
|
|
41348
|
+
longitude: 1
|
|
41349
|
+
},
|
|
41350
|
+
area: [[6, 5], [7, 1], [9, 2]],
|
|
41351
|
+
associatedSubjects: [{
|
|
41352
|
+
entity: "Event",
|
|
41353
|
+
_id: {},
|
|
41354
|
+
nature: ""
|
|
41355
|
+
}],
|
|
41356
|
+
published: false,
|
|
41357
|
+
version: 1,
|
|
41358
|
+
createdAt: "2024-06-13T14:51:55.296Z",
|
|
41359
|
+
updatedAt: "2024-06-13T14:51:55.296Z",
|
|
41360
|
+
name: "Name",
|
|
41361
|
+
type: "Loc Type",
|
|
41362
|
+
__v: 0,
|
|
41363
|
+
datastakeId: "LOC-00000000141"
|
|
41364
|
+
}]
|
|
41365
|
+
// tooltipAsText: true,
|
|
41366
|
+
,
|
|
41409
41367
|
primaryLink: true,
|
|
41410
41368
|
renderTooltip: () => {
|
|
41411
41369
|
return [{
|
|
@@ -41413,10 +41371,9 @@ const RestorationActivitySummary = ({
|
|
|
41413
41371
|
value: "Name"
|
|
41414
41372
|
}];
|
|
41415
41373
|
},
|
|
41374
|
+
center: [13, -15],
|
|
41416
41375
|
mapConfig: {
|
|
41417
|
-
maxZoom: 18
|
|
41418
|
-
zoom: 5,
|
|
41419
|
-
center: [14, -14]
|
|
41376
|
+
maxZoom: 18
|
|
41420
41377
|
},
|
|
41421
41378
|
type: 'territory',
|
|
41422
41379
|
link: true,
|
package/package.json
CHANGED
|
@@ -165,46 +165,61 @@ export default function DynamicForm({
|
|
|
165
165
|
// setOriginalData({});
|
|
166
166
|
// setValues({});
|
|
167
167
|
// MainForm.resetFields();
|
|
168
|
+
} else if (isCreate) {
|
|
169
|
+
// Reset form when data is empty in create mode (e.g., when switching contexts)
|
|
170
|
+
setOriginalData({});
|
|
171
|
+
setValues({});
|
|
172
|
+
MainForm.resetFields();
|
|
168
173
|
}
|
|
169
|
-
}, [data]);
|
|
174
|
+
}, [data, isCreate]);
|
|
170
175
|
|
|
171
176
|
// Initialize default values for hidden and disabled fields
|
|
172
177
|
useEffect(() => {
|
|
173
178
|
if (Object.keys(form).length > 0) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
179
|
+
setValues(prevValues => {
|
|
180
|
+
// Use data prop as base, or current values if data is empty
|
|
181
|
+
const baseValues = Object.keys(data).length > 0 ? data : prevValues;
|
|
182
|
+
const updatedValues = { ...baseValues };
|
|
183
|
+
let hasChanges = false;
|
|
184
|
+
const isEditMode = data && (data.id || data._id);
|
|
185
|
+
|
|
186
|
+
// Process all form fields to set default values for hidden and disabled fields
|
|
187
|
+
Object.keys(form).forEach(formKey => {
|
|
188
|
+
Object.keys(form[formKey]).forEach(fieldKey => {
|
|
189
|
+
const field = form[formKey][fieldKey];
|
|
190
|
+
const fieldId = field.dataId || fieldKey;
|
|
191
|
+
|
|
192
|
+
// Check if field is disabled
|
|
193
|
+
const isDisabled = (field?.meta?.disableEdit && typeof field?.meta?.disableEdit === 'object')
|
|
194
|
+
? isModal
|
|
195
|
+
? field.meta.disableEdit.create || field.meta.disableEdit.modal || (field?.meta?.disableEdit?.edit && isEditMode)
|
|
196
|
+
: field.meta.disableEdit.create || field.meta.disableEdit.drawer || (field?.meta?.disableEdit?.edit && isEditMode)
|
|
197
|
+
: field?.meta?.disableEdit;
|
|
198
|
+
|
|
199
|
+
// Set default value for hidden fields or disabled fields with default values
|
|
200
|
+
if (field?.meta?.defaultValue !== undefined) {
|
|
201
|
+
// In create mode, always update disabled/hidden fields with default values when form config changes
|
|
202
|
+
// This ensures context switching (Operation -> Restoration) updates the field correctly
|
|
203
|
+
const shouldUpdate = !propHasValue(updatedValues[fieldId]) ||
|
|
204
|
+
(isCreate && !isEditMode && (field?.meta?.hidden === true || isDisabled));
|
|
205
|
+
|
|
206
|
+
if (shouldUpdate && (field?.meta?.hidden === true || isDisabled)) {
|
|
207
|
+
updatedValues[fieldId] = field.meta.defaultValue;
|
|
208
|
+
hasChanges = true;
|
|
209
|
+
}
|
|
196
210
|
}
|
|
197
|
-
}
|
|
211
|
+
});
|
|
198
212
|
});
|
|
213
|
+
|
|
214
|
+
if (hasChanges) {
|
|
215
|
+
// Also set the values in the Ant Design form
|
|
216
|
+
MainForm.setFieldsValue(updatedValues);
|
|
217
|
+
return updatedValues;
|
|
218
|
+
}
|
|
219
|
+
return prevValues;
|
|
199
220
|
});
|
|
200
|
-
|
|
201
|
-
if (hasChanges) {
|
|
202
|
-
setValues(updatedValues);
|
|
203
|
-
// Also set the values in the Ant Design form
|
|
204
|
-
MainForm.setFieldsValue(updatedValues);
|
|
205
|
-
}
|
|
206
221
|
}
|
|
207
|
-
}, [form, data, isModal]);
|
|
222
|
+
}, [form, data, isModal, isCreate]);
|
|
208
223
|
|
|
209
224
|
const setSelectedForm = (id) => {
|
|
210
225
|
setForms(Forms.map(form => {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
// ============================================================================
|
|
4
2
|
// REGION: Photo/Image Extraction
|
|
5
3
|
// ============================================================================
|
|
@@ -122,93 +120,6 @@ export const getGenderTooltipChildren = (item, isEmpty, genderDistributionData,
|
|
|
122
120
|
});
|
|
123
121
|
};
|
|
124
122
|
|
|
125
|
-
// ============================================================================
|
|
126
|
-
// REGION: Multiselect Options
|
|
127
|
-
// ============================================================================
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Get filtered options for multiselect based on activityData.origin
|
|
131
|
-
* Filters options based on whether origin contains 'kobo', 'straatos', or both
|
|
132
|
-
*
|
|
133
|
-
* @param {Object} activityData - Activity data object containing origin array
|
|
134
|
-
* @param {React.Component} CustomIcon - CustomIcon component for rendering Monitor option avatar
|
|
135
|
-
* @returns {Array} - Filtered array of option objects
|
|
136
|
-
*/
|
|
137
|
-
export const getFilteredOptions = (activityData, CustomIcon) => {
|
|
138
|
-
const allOptions = [
|
|
139
|
-
{
|
|
140
|
-
label: "Own Data",
|
|
141
|
-
value: "own",
|
|
142
|
-
avatar: <span>OWN</span>,
|
|
143
|
-
background: "#016C6E",
|
|
144
|
-
color: "white",
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
label: "Monitor",
|
|
148
|
-
value: "other",
|
|
149
|
-
avatar: <CustomIcon name={"Search02"} size={14} />,
|
|
150
|
-
},
|
|
151
|
-
];
|
|
152
|
-
|
|
153
|
-
if (!activityData?.origin || !Array.isArray(activityData.origin)) {
|
|
154
|
-
return allOptions;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Extract origin names from the array
|
|
158
|
-
const originNames = activityData.origin
|
|
159
|
-
.map(item => item?.name?.toLowerCase())
|
|
160
|
-
.filter(Boolean);
|
|
161
|
-
|
|
162
|
-
const hasKobo = originNames.includes('kobo');
|
|
163
|
-
const hasStraatos = originNames.includes('straatos');
|
|
164
|
-
|
|
165
|
-
// If contains kobo only, show only Monitor
|
|
166
|
-
if (hasKobo && !hasStraatos) {
|
|
167
|
-
return allOptions.filter(option => option.value === 'other');
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// If contains straatos only, show only Own Data
|
|
171
|
-
if (hasStraatos && !hasKobo) {
|
|
172
|
-
return allOptions.filter(option => option.value === 'own');
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// If contains both or neither, show both
|
|
176
|
-
return allOptions;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Get default selected value for multiselect based on activityData.origin
|
|
181
|
-
*
|
|
182
|
-
* @param {Object} activityData - Activity data object containing origin array
|
|
183
|
-
* @returns {Array} - Array of default selected values
|
|
184
|
-
*/
|
|
185
|
-
export const getDefaultSelected = (activityData) => {
|
|
186
|
-
if (!activityData?.origin || !Array.isArray(activityData.origin)) {
|
|
187
|
-
return ['own'];
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Extract origin names from the array
|
|
191
|
-
const originNames = activityData.origin
|
|
192
|
-
.map(item => item?.name?.toLowerCase())
|
|
193
|
-
.filter(Boolean);
|
|
194
|
-
|
|
195
|
-
const hasKobo = originNames.includes('kobo');
|
|
196
|
-
const hasStraatos = originNames.includes('straatos');
|
|
197
|
-
|
|
198
|
-
// If contains kobo only, default to monitor (other)
|
|
199
|
-
if (hasKobo && !hasStraatos) {
|
|
200
|
-
return ['other'];
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// If contains straatos only, default to own
|
|
204
|
-
if (hasStraatos && !hasKobo) {
|
|
205
|
-
return ['own'];
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// If contains both or neither, default to own
|
|
209
|
-
return ['own'];
|
|
210
|
-
};
|
|
211
|
-
|
|
212
123
|
// ============================================================================
|
|
213
124
|
// REGION: Activity Indicators
|
|
214
125
|
// ============================================================================
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMemo, useCallback } from 'react';
|
|
2
|
-
import { DashboardLayout, Header, ImageCarousel, KeyIndicators, MineSiteMap, Widget, PieChart, ActivityIndicators
|
|
2
|
+
import { DashboardLayout, Header, ImageCarousel, KeyIndicators, MineSiteMap, Widget, PieChart, ActivityIndicators } from '../../../../../../src/index.js'
|
|
3
3
|
import { getKeyIndicatorsRowConfig } from './config';
|
|
4
|
-
import { getActivityImages, getGenderDistributionData, isGenderDistributionEmpty, calculateGenderPieData, getGenderTooltipChildren, getActivityIndicatorsConfig
|
|
4
|
+
import { getActivityImages, getGenderDistributionData, isGenderDistributionEmpty, calculateGenderPieData, getGenderTooltipChildren, getActivityIndicatorsConfig } from './helper';
|
|
5
5
|
import { renderTooltipJsx } from '../../../../../../src/utils';
|
|
6
6
|
import { useResizeContext } from '../../../../../../src/context';
|
|
7
7
|
|
|
@@ -24,18 +24,6 @@ const RestorationActivitySummary = ({ activityData, supportText, onDownload, dow
|
|
|
24
24
|
[activityData, t]
|
|
25
25
|
);
|
|
26
26
|
|
|
27
|
-
// Filter options based on activityData.origin
|
|
28
|
-
const filteredOptions = useMemo(() =>
|
|
29
|
-
getFilteredOptions(activityData, CustomIcon),
|
|
30
|
-
[activityData]
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
// Get default selected based on activityData.origin
|
|
34
|
-
const defaultSelected = useMemo(() =>
|
|
35
|
-
getDefaultSelected(activityData),
|
|
36
|
-
[activityData]
|
|
37
|
-
);
|
|
38
|
-
|
|
39
27
|
return (
|
|
40
28
|
<DashboardLayout
|
|
41
29
|
header={
|
|
@@ -48,24 +36,6 @@ const RestorationActivitySummary = ({ activityData, supportText, onDownload, dow
|
|
|
48
36
|
breadcrumbs={breadcrumbs}
|
|
49
37
|
goBackTo={goBackTo}
|
|
50
38
|
loading={loading}
|
|
51
|
-
addedHeaderFirst
|
|
52
|
-
addedHeader={
|
|
53
|
-
<div style={{ marginRight: 0 }}>
|
|
54
|
-
<Multiselect
|
|
55
|
-
canUnselectLast={false}
|
|
56
|
-
options={filteredOptions}
|
|
57
|
-
isAvatarGroup
|
|
58
|
-
selectionType="checkbox"
|
|
59
|
-
onChange={(selected) => {
|
|
60
|
-
console.log(selected);
|
|
61
|
-
}}
|
|
62
|
-
dropDownWidth={200}
|
|
63
|
-
defaultSelected={defaultSelected}
|
|
64
|
-
placeholder="Select partners..."
|
|
65
|
-
/>
|
|
66
|
-
</div>
|
|
67
|
-
|
|
68
|
-
}
|
|
69
39
|
/>
|
|
70
40
|
}
|
|
71
41
|
>
|
|
@@ -87,6 +57,57 @@ const RestorationActivitySummary = ({ activityData, supportText, onDownload, dow
|
|
|
87
57
|
app={"straatos"}
|
|
88
58
|
showSider={false}
|
|
89
59
|
user={null}
|
|
60
|
+
data={[
|
|
61
|
+
{
|
|
62
|
+
_id: {},
|
|
63
|
+
id: "7f2aaed4-4b2e-406c-8e0a-6659c5c8367b",
|
|
64
|
+
color: "#6698E4",
|
|
65
|
+
parent: {
|
|
66
|
+
_id: {},
|
|
67
|
+
createdAt: "2024-06-13T14:51:55.296Z",
|
|
68
|
+
updatedAt: "2024-06-13T14:51:55.296Z",
|
|
69
|
+
id: "a5340bf1-2c7d-413f-a2a5-ccd7dc8f7a7c",
|
|
70
|
+
name: "New Mine",
|
|
71
|
+
authorId: "4e6066e9-00d8-423a-94ec-c7c9d3432fec",
|
|
72
|
+
collectId: "f8a2b6a9cc935ef3e5844427f49aade34e152eca",
|
|
73
|
+
country: "AL",
|
|
74
|
+
category: "mineSite",
|
|
75
|
+
datastakeId: "LOC-00000000141",
|
|
76
|
+
__v: 0,
|
|
77
|
+
},
|
|
78
|
+
administrativeLevel1: "6839cb26-5af4-44a3-b136-a0f0a0bcecc6",
|
|
79
|
+
administrativeLevel2: "f849835d-5640-4bee-ae98-9f1c810c1abe",
|
|
80
|
+
// "name": "New Mine",
|
|
81
|
+
country: "AL",
|
|
82
|
+
category: "mineSite",
|
|
83
|
+
authorId: "4e6066e9-00d8-423a-94ec-c7c9d3432fec",
|
|
84
|
+
gps: {
|
|
85
|
+
latitude: 7,
|
|
86
|
+
longitude: 1,
|
|
87
|
+
},
|
|
88
|
+
area: [
|
|
89
|
+
[6, 5],
|
|
90
|
+
[7, 1],
|
|
91
|
+
[9, 2],
|
|
92
|
+
],
|
|
93
|
+
associatedSubjects: [
|
|
94
|
+
{
|
|
95
|
+
entity: "Event",
|
|
96
|
+
_id: {},
|
|
97
|
+
nature: "",
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
published: false,
|
|
101
|
+
version: 1,
|
|
102
|
+
createdAt: "2024-06-13T14:51:55.296Z",
|
|
103
|
+
updatedAt: "2024-06-13T14:51:55.296Z",
|
|
104
|
+
name: "Name",
|
|
105
|
+
type: "Loc Type",
|
|
106
|
+
__v: 0,
|
|
107
|
+
datastakeId: "LOC-00000000141",
|
|
108
|
+
},
|
|
109
|
+
]}
|
|
110
|
+
// tooltipAsText: true,
|
|
90
111
|
primaryLink={true}
|
|
91
112
|
renderTooltip={() => {
|
|
92
113
|
return [
|
|
@@ -96,8 +117,8 @@ const RestorationActivitySummary = ({ activityData, supportText, onDownload, dow
|
|
|
96
117
|
},
|
|
97
118
|
];
|
|
98
119
|
}}
|
|
99
|
-
|
|
100
|
-
mapConfig={{ maxZoom: 18
|
|
120
|
+
center={[13, -15]}
|
|
121
|
+
mapConfig={{ maxZoom: 18 }}
|
|
101
122
|
type={'territory'}
|
|
102
123
|
link={true}
|
|
103
124
|
onClickLink={() => { }}
|