datastake-daf 0.6.751 → 0.6.753

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.
@@ -9667,28 +9667,30 @@ const handleSectionChildren = _ref => {
9667
9667
  });
9668
9668
  };
9669
9669
 
9670
- const handleArrayChildren = ({
9671
- value,
9672
- config,
9673
- label,
9674
- level,
9675
- t,
9676
- rootForm,
9677
- allData,
9678
- user,
9679
- getApiBaseUrl = () => {},
9680
- getAppHeader = () => {},
9681
- app,
9682
- TreeNodeComponent
9683
- }) => {
9670
+ const handleArrayChildren = _ref => {
9671
+ let {
9672
+ value,
9673
+ config,
9674
+ label,
9675
+ level,
9676
+ t,
9677
+ rootForm,
9678
+ allData,
9679
+ user,
9680
+ getApiBaseUrl = () => {},
9681
+ getAppHeader = () => {},
9682
+ app,
9683
+ TreeNodeComponent
9684
+ } = _ref;
9684
9685
  if (!Array.isArray(value)) {
9685
9686
  return null;
9686
9687
  }
9687
9688
  return value.map((item, itemIndex) => /*#__PURE__*/jsxRuntime.jsx("div", {
9688
9689
  className: "array-item",
9689
9690
  children: Object.keys(config.inputs).sort((a, b) => {
9690
- const positionA = config.inputs[a]?.position || 0;
9691
- const positionB = config.inputs[b]?.position || 0;
9691
+ var _config$inputs$a, _config$inputs$b;
9692
+ const positionA = ((_config$inputs$a = config.inputs[a]) === null || _config$inputs$a === void 0 ? void 0 : _config$inputs$a.position) || 0;
9693
+ const positionB = ((_config$inputs$b = config.inputs[b]) === null || _config$inputs$b === void 0 ? void 0 : _config$inputs$b.position) || 0;
9692
9694
  return positionA - positionB;
9693
9695
  }).map(subInputKey => {
9694
9696
  const subInputConfig = config.inputs[subInputKey];
@@ -9706,9 +9708,9 @@ const handleArrayChildren = ({
9706
9708
  getApiBaseUrl: getApiBaseUrl,
9707
9709
  getAppHeader: getAppHeader,
9708
9710
  app: app
9709
- }, `${itemIndex}-${subInputKey}`);
9711
+ }, "".concat(itemIndex, "-").concat(subInputKey));
9710
9712
  })
9711
- }, `${itemIndex}`));
9713
+ }, "".concat(itemIndex)));
9712
9714
  };
9713
9715
 
9714
9716
  const noDafApps = ['tif', 'cukura']; //PACKAGE_CHANGE_LATER (remove sbg)
@@ -10068,42 +10070,37 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10068
10070
  }
10069
10071
  };
10070
10072
 
10071
- const handleDataLinkWithTableKeys = _ref => {
10072
- var _inputConfig$meta, _inputConfig$meta3, _inputConfig$meta4, _inputConfig$meta5;
10073
- let {
10074
- inputConfig,
10075
- inputKey,
10076
- value,
10077
- level,
10078
- t,
10079
- rootForm,
10080
- allData,
10081
- user,
10082
- getApiBaseUrl = () => {},
10083
- getAppHeader = () => {},
10084
- app,
10085
- TreeNodeComponent
10086
- } = _ref;
10087
- 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)) {
10073
+ const handleDataLinkWithTableKeys = ({
10074
+ inputConfig,
10075
+ inputKey,
10076
+ value,
10077
+ level,
10078
+ t,
10079
+ rootForm,
10080
+ allData,
10081
+ user,
10082
+ getApiBaseUrl = () => {},
10083
+ getAppHeader = () => {},
10084
+ app,
10085
+ TreeNodeComponent
10086
+ }) => {
10087
+ if (inputConfig?.type !== 'dataLink' || !inputConfig?.meta?.tableKeys) {
10088
10088
  return null;
10089
10089
  }
10090
10090
  const tableKeys = inputConfig.meta.tableKeys;
10091
- const isAjaxModal = React.useMemo(() => {
10092
- var _inputConfig$meta2;
10093
- return !!(inputConfig !== null && inputConfig !== void 0 && (_inputConfig$meta2 = inputConfig.meta) !== null && _inputConfig$meta2 !== void 0 && _inputConfig$meta2.namespace);
10094
- }, [inputConfig]);
10091
+ const isAjaxModal = React.useMemo(() => !!inputConfig?.meta?.namespace, [inputConfig]);
10095
10092
  const ajaxModalValues = useAjaxModal$2({
10096
10093
  name: inputKey,
10097
10094
  user,
10098
- namespace: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta3 = inputConfig.meta) === null || _inputConfig$meta3 === void 0 ? void 0 : _inputConfig$meta3.namespace,
10099
- skipFetch: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta4 = inputConfig.meta) === null || _inputConfig$meta4 === void 0 ? void 0 : _inputConfig$meta4.skipFetch,
10095
+ namespace: inputConfig?.meta?.namespace,
10096
+ skipFetch: inputConfig?.meta?.skipFetch,
10100
10097
  isAjaxModal,
10101
- formScope: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta5 = inputConfig.meta) === null || _inputConfig$meta5 === void 0 ? void 0 : _inputConfig$meta5.formScope,
10098
+ formScope: inputConfig?.meta?.formScope,
10102
10099
  APP: app,
10103
10100
  apiBaseUrl: getApiBaseUrl(),
10104
10101
  _getAppHeader: getAppHeader
10105
10102
  });
10106
- const dataLinkForm = ajaxModalValues === null || ajaxModalValues === void 0 ? void 0 : ajaxModalValues.form;
10103
+ const dataLinkForm = ajaxModalValues?.form;
10107
10104
  const createInputsAndValues = item => {
10108
10105
  const inputs = {};
10109
10106
  const values = {};
@@ -10116,20 +10113,19 @@ const handleDataLinkWithTableKeys = _ref => {
10116
10113
  };
10117
10114
  const isUploadFieldEmpty = (fieldKey, itemToCheck) => {
10118
10115
  if (uploadTypeFields.includes(fieldKey)) {
10119
- const itemValue = itemToCheck === null || itemToCheck === void 0 ? void 0 : itemToCheck[fieldKey];
10116
+ const itemValue = itemToCheck?.[fieldKey];
10120
10117
  return itemValue === undefined || itemValue === null || Array.isArray(itemValue) && itemValue.length === 0;
10121
10118
  }
10122
10119
  return false;
10123
10120
  };
10124
10121
  const processedTableKeys = processConditionalTableKeys(tableKeys, item);
10125
10122
  processedTableKeys.filter(tableKey => tableKey !== 'datastakeId').filter(tableKey => !isUploadFieldEmpty(tableKey, item)).forEach(tableKey => {
10126
- var _dataLinkForm$identif;
10127
- 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]);
10123
+ const formInputConfig = dataLinkForm?.[tableKey] || dataLinkForm?.['identification']?.[tableKey];
10128
10124
  if (formInputConfig) {
10129
- var _item$linking, _formInputConfig$meta, _formInputConfig$tabl;
10130
- inputs[tableKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10125
+ inputs[tableKey] = {
10126
+ ...formInputConfig,
10131
10127
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : formInputConfig.label || formInputConfig.tableLabel || tableKey
10132
- });
10128
+ };
10133
10129
  if (formInputConfig.label && typeof formInputConfig.label === 'object') {
10134
10130
  const dynamicLabelKeys = Object.keys(formInputConfig.label);
10135
10131
  let resolvedLabel = null;
@@ -10137,7 +10133,7 @@ const handleDataLinkWithTableKeys = _ref => {
10137
10133
  const parts = labelKey.split(' is ');
10138
10134
  if (parts.length === 2) {
10139
10135
  const [conditionKey, conditionValue] = parts;
10140
- if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
10136
+ if (item?.[conditionKey] === conditionValue) {
10141
10137
  resolvedLabel = formInputConfig.label[labelKey];
10142
10138
  break;
10143
10139
  }
@@ -10145,17 +10141,16 @@ const handleDataLinkWithTableKeys = _ref => {
10145
10141
  }
10146
10142
  inputs[tableKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey);
10147
10143
  }
10148
- 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]);
10144
+ values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item[formInputConfig?.meta?.onNewSetValueKey] || item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[tableKey];
10149
10145
  } else {
10150
- var _item$linking2;
10151
10146
  inputs[tableKey] = {
10152
10147
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey,
10153
- type: inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type
10148
+ type: inputConfig?.type
10154
10149
  };
10155
- 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]);
10150
+ values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item?.[tableKey];
10156
10151
  }
10157
10152
  });
10158
- if (dataLinkForm !== null && dataLinkForm !== void 0 && dataLinkForm.identification && typeof dataLinkForm.identification === 'object') {
10153
+ if (dataLinkForm?.identification && typeof dataLinkForm.identification === 'object') {
10159
10154
  Object.keys(dataLinkForm.identification).filter(fieldKey => {
10160
10155
  if (uploadTypeFields.includes(fieldKey)) {
10161
10156
  return !isUploadFieldEmpty(fieldKey, item);
@@ -10165,11 +10160,11 @@ const handleDataLinkWithTableKeys = _ref => {
10165
10160
  const formInputConfig = dataLinkForm.identification[fieldKey];
10166
10161
  return formInputConfig && typeof formInputConfig === 'object' && !Array.isArray(formInputConfig);
10167
10162
  }).forEach(fieldKey => {
10168
- var _item$linking3, _formInputConfig$tabl2;
10169
10163
  const formInputConfig = dataLinkForm.identification[fieldKey];
10170
- inputs[fieldKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10164
+ inputs[fieldKey] = {
10165
+ ...formInputConfig,
10171
10166
  label: uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : formInputConfig.label || formInputConfig.tableLabel || fieldKey
10172
- });
10167
+ };
10173
10168
  if (formInputConfig.label && typeof formInputConfig.label === 'object') {
10174
10169
  const dynamicLabelKeys = Object.keys(formInputConfig.label);
10175
10170
  let resolvedLabel = null;
@@ -10177,7 +10172,7 @@ const handleDataLinkWithTableKeys = _ref => {
10177
10172
  const parts = labelKey.split(' is ');
10178
10173
  if (parts.length === 2) {
10179
10174
  const [conditionKey, conditionValue] = parts;
10180
- if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
10175
+ if (item?.[conditionKey] === conditionValue) {
10181
10176
  resolvedLabel = formInputConfig.label[labelKey];
10182
10177
  break;
10183
10178
  }
@@ -10185,7 +10180,7 @@ const handleDataLinkWithTableKeys = _ref => {
10185
10180
  }
10186
10181
  inputs[fieldKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : fieldKey);
10187
10182
  }
10188
- 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]);
10183
+ values[fieldKey] = item?.linking?.SCL?.[item?.[fieldKey]]?.name || item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[fieldKey];
10189
10184
  });
10190
10185
  }
10191
10186
  return {
@@ -10195,7 +10190,7 @@ const handleDataLinkWithTableKeys = _ref => {
10195
10190
  };
10196
10191
  if (Array.isArray(value)) {
10197
10192
  return value.map((item, itemIndex) => {
10198
- const datastakeIdValue = item === null || item === void 0 ? void 0 : item.datastakeId;
10193
+ const datastakeIdValue = item?.datastakeId;
10199
10194
  const {
10200
10195
  inputs,
10201
10196
  values
@@ -10204,9 +10199,9 @@ const handleDataLinkWithTableKeys = _ref => {
10204
10199
  return null;
10205
10200
  }
10206
10201
  return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
10207
- nodeKey: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10202
+ nodeKey: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10208
10203
  config: {
10209
- label: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10204
+ label: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10210
10205
  type: 'custom-datalink',
10211
10206
  inputs: inputs
10212
10207
  },
@@ -10220,10 +10215,10 @@ const handleDataLinkWithTableKeys = _ref => {
10220
10215
  getApiBaseUrl: getApiBaseUrl,
10221
10216
  getAppHeader: getAppHeader,
10222
10217
  app: app
10223
- }, "".concat(inputKey, "-").concat(itemIndex));
10218
+ }, `${inputKey}-${itemIndex}`);
10224
10219
  });
10225
10220
  } else {
10226
- const datastakeIdValue = value === null || value === void 0 ? void 0 : value.datastakeId;
10221
+ const datastakeIdValue = value?.datastakeId;
10227
10222
  const {
10228
10223
  inputs,
10229
10224
  values
@@ -10248,7 +10243,7 @@ const handleDataLinkWithTableKeys = _ref => {
10248
10243
  getApiBaseUrl: getApiBaseUrl,
10249
10244
  getAppHeader: getAppHeader,
10250
10245
  app: app
10251
- }, "".concat(inputKey, "-single"));
10246
+ }, `${inputKey}-single`);
10252
10247
  }
10253
10248
  };
10254
10249
 
@@ -39907,20 +39902,27 @@ function DynamicForm(_ref) {
39907
39902
  }
39908
39903
  }, [data]);
39909
39904
 
39910
- // Initialize default values for hidden fields
39905
+ // Initialize default values for hidden and disabled fields
39911
39906
  React.useEffect(() => {
39912
39907
  if (Object.keys(form).length > 0) {
39913
39908
  const updatedValues = _objectSpread2({}, values);
39914
39909
  let hasChanges = false;
39910
+ const isEditMode = data && (data.id || data._id);
39915
39911
 
39916
- // Process all form fields to set default values for hidden fields
39912
+ // Process all form fields to set default values for hidden and disabled fields
39917
39913
  Object.keys(form).forEach(formKey => {
39918
39914
  Object.keys(form[formKey]).forEach(fieldKey => {
39919
- var _field$meta, _field$meta2;
39915
+ var _field$meta, _field$meta2, _field$meta3, _field$meta4, _field$meta5, _field$meta6;
39920
39916
  const field = form[formKey][fieldKey];
39921
- if ((field === null || field === void 0 || (_field$meta = field.meta) === null || _field$meta === void 0 ? void 0 : _field$meta.hidden) === true && (field === null || field === void 0 || (_field$meta2 = field.meta) === null || _field$meta2 === void 0 ? void 0 : _field$meta2.defaultValue) !== undefined) {
39922
- const fieldId = field.dataId || fieldKey;
39923
- if (!propHasValue(updatedValues[fieldId])) {
39917
+ const fieldId = field.dataId || fieldKey;
39918
+
39919
+ // Check if field is disabled
39920
+ 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;
39921
+
39922
+ // Set default value for hidden fields or disabled fields with default values
39923
+ if ((field === null || field === void 0 || (_field$meta6 = field.meta) === null || _field$meta6 === void 0 ? void 0 : _field$meta6.defaultValue) !== undefined && !propHasValue(updatedValues[fieldId])) {
39924
+ var _field$meta7;
39925
+ if ((field === null || field === void 0 || (_field$meta7 = field.meta) === null || _field$meta7 === void 0 ? void 0 : _field$meta7.hidden) === true || isDisabled) {
39924
39926
  updatedValues[fieldId] = field.meta.defaultValue;
39925
39927
  hasChanges = true;
39926
39928
  }
@@ -39933,7 +39935,7 @@ function DynamicForm(_ref) {
39933
39935
  MainForm.setFieldsValue(updatedValues);
39934
39936
  }
39935
39937
  }
39936
- }, [form]);
39938
+ }, [form, data, isModal]);
39937
39939
  const setSelectedForm = id => {
39938
39940
  setForms(Forms.map(form => {
39939
39941
  id === form.id ? form.selected = true : form.selected = false;
@@ -39970,7 +39972,7 @@ function DynamicForm(_ref) {
39970
39972
  }).every(key => key);
39971
39973
  };
39972
39974
  const getData = (name, input, value, commentValue, path, disabledPath) => {
39973
- var _input$meta, _input$meta2, _input$meta3, _input$meta4, _input$meta5, _input$meta6, _input$meta7, _input$meta8, _input$meta9, _input$meta10, _input$meta11, _input$meta12;
39975
+ var _input$meta, _input$meta2, _input$meta3, _input$meta4, _input$meta5, _input$meta6, _input$meta7, _input$meta9, _input$meta10, _input$meta11, _input$meta12;
39974
39976
  const props = {
39975
39977
  // placeholder: input.labelHint ? input.labelHint : getInputLabel(input, values, true),
39976
39978
  placeholder: input.labelHint,
@@ -40007,11 +40009,16 @@ function DynamicForm(_ref) {
40007
40009
  }
40008
40010
  value = fileList;
40009
40011
  }
40010
- // Handle default values for hidden fields
40011
- if ((input === null || input === void 0 || (_input$meta7 = input.meta) === null || _input$meta7 === void 0 ? void 0 : _input$meta7.hidden) === true && (input === null || input === void 0 || (_input$meta8 = input.meta) === null || _input$meta8 === void 0 ? void 0 : _input$meta8.defaultValue) !== undefined && !propHasValue(value)) {
40012
- value = input.meta.defaultValue;
40013
- if (typeof path === 'string') {
40014
- dot__default["default"].str(path, value, values);
40012
+ // Handle default values for hidden fields and disabled fields
40013
+ if ((input === null || input === void 0 || (_input$meta7 = input.meta) === null || _input$meta7 === void 0 ? void 0 : _input$meta7.defaultValue) !== undefined && !propHasValue(value)) {
40014
+ var _input$meta8;
40015
+ const isFieldHidden = (input === null || input === void 0 || (_input$meta8 = input.meta) === null || _input$meta8 === void 0 ? void 0 : _input$meta8.hidden) === true;
40016
+ const isFieldDisabled = props.disabled || isDisabled;
40017
+ if (isFieldHidden || isFieldDisabled) {
40018
+ value = input.meta.defaultValue;
40019
+ if (typeof path === 'string') {
40020
+ dot__default["default"].str(path, value, values);
40021
+ }
40015
40022
  }
40016
40023
  }
40017
40024
  const config = {
@@ -29374,21 +29374,27 @@ function DynamicForm({
29374
29374
  }
29375
29375
  }, [data]);
29376
29376
 
29377
- // Initialize default values for hidden fields
29377
+ // Initialize default values for hidden and disabled fields
29378
29378
  React.useEffect(() => {
29379
29379
  if (Object.keys(form).length > 0) {
29380
29380
  const updatedValues = {
29381
29381
  ...values
29382
29382
  };
29383
29383
  let hasChanges = false;
29384
+ const isEditMode = data && (data.id || data._id);
29384
29385
 
29385
- // Process all form fields to set default values for hidden fields
29386
+ // Process all form fields to set default values for hidden and disabled fields
29386
29387
  Object.keys(form).forEach(formKey => {
29387
29388
  Object.keys(form[formKey]).forEach(fieldKey => {
29388
29389
  const field = form[formKey][fieldKey];
29389
- if (field?.meta?.hidden === true && field?.meta?.defaultValue !== undefined) {
29390
- const fieldId = field.dataId || fieldKey;
29391
- if (!propHasValue(updatedValues[fieldId])) {
29390
+ const fieldId = field.dataId || fieldKey;
29391
+
29392
+ // Check if field is disabled
29393
+ 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;
29394
+
29395
+ // Set default value for hidden fields or disabled fields with default values
29396
+ if (field?.meta?.defaultValue !== undefined && !propHasValue(updatedValues[fieldId])) {
29397
+ if (field?.meta?.hidden === true || isDisabled) {
29392
29398
  updatedValues[fieldId] = field.meta.defaultValue;
29393
29399
  hasChanges = true;
29394
29400
  }
@@ -29401,7 +29407,7 @@ function DynamicForm({
29401
29407
  MainForm.setFieldsValue(updatedValues);
29402
29408
  }
29403
29409
  }
29404
- }, [form]);
29410
+ }, [form, data, isModal]);
29405
29411
  const setSelectedForm = id => {
29406
29412
  setForms(Forms.map(form => {
29407
29413
  id === form.id ? form.selected = true : form.selected = false;
@@ -29474,11 +29480,15 @@ function DynamicForm({
29474
29480
  }
29475
29481
  value = fileList;
29476
29482
  }
29477
- // Handle default values for hidden fields
29478
- if (input?.meta?.hidden === true && input?.meta?.defaultValue !== undefined && !propHasValue(value)) {
29479
- value = input.meta.defaultValue;
29480
- if (typeof path === 'string') {
29481
- dot__default["default"].str(path, value, values);
29483
+ // Handle default values for hidden fields and disabled fields
29484
+ if (input?.meta?.defaultValue !== undefined && !propHasValue(value)) {
29485
+ const isFieldHidden = input?.meta?.hidden === true;
29486
+ const isFieldDisabled = props.disabled || isDisabled;
29487
+ if (isFieldHidden || isFieldDisabled) {
29488
+ value = input.meta.defaultValue;
29489
+ if (typeof path === 'string') {
29490
+ dot__default["default"].str(path, value, values);
29491
+ }
29482
29492
  }
29483
29493
  }
29484
29494
  const config = {
@@ -40803,13 +40813,6 @@ const getKeyIndicatorsRowConfig = ({
40803
40813
  })
40804
40814
  }];
40805
40815
 
40806
- // ============================================================================
40807
- // REGION: Photo/Image Extraction
40808
- // ============================================================================
40809
-
40810
- /**
40811
- * Normalize URL by removing trailing colon if present
40812
- */
40813
40816
  const normalizeUrl = url => url?.endsWith(':') ? url.slice(0, -1) : url;
40814
40817
 
40815
40818
  /**
@@ -40922,6 +40925,88 @@ const getGenderTooltipChildren = (item, isEmpty, genderDistributionData, t, rend
40922
40925
  });
40923
40926
  };
40924
40927
 
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
+
40925
41010
  // ============================================================================
40926
41011
  // REGION: Activity Indicators
40927
41012
  // ============================================================================
@@ -41259,6 +41344,12 @@ const RestorationActivitySummary = ({
41259
41344
 
41260
41345
  // Activity Indicators Config - mapped from activityData
41261
41346
  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]);
41262
41353
  return /*#__PURE__*/jsxRuntime.jsxs(DashboardLayout, {
41263
41354
  header: /*#__PURE__*/jsxRuntime.jsx(DAFHeader, {
41264
41355
  title: 'Restoration Activity Summary',
@@ -41268,7 +41359,25 @@ const RestorationActivitySummary = ({
41268
41359
  actionButtons: actionButtons,
41269
41360
  breadcrumbs: breadcrumbs,
41270
41361
  goBackTo: goBackTo,
41271
- loading: loading
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
+ })
41272
41381
  }),
41273
41382
  children: [/*#__PURE__*/jsxRuntime.jsx("section", {
41274
41383
  children: /*#__PURE__*/jsxRuntime.jsx(KeyIndicatorsWidget, {
@@ -41297,50 +41406,6 @@ const RestorationActivitySummary = ({
41297
41406
  app: "straatos",
41298
41407
  showSider: false,
41299
41408
  user: null,
41300
- data: [{
41301
- _id: {},
41302
- id: "7f2aaed4-4b2e-406c-8e0a-6659c5c8367b",
41303
- color: "#6698E4",
41304
- parent: {
41305
- _id: {},
41306
- createdAt: "2024-06-13T14:51:55.296Z",
41307
- updatedAt: "2024-06-13T14:51:55.296Z",
41308
- id: "a5340bf1-2c7d-413f-a2a5-ccd7dc8f7a7c",
41309
- name: "New Mine",
41310
- authorId: "4e6066e9-00d8-423a-94ec-c7c9d3432fec",
41311
- collectId: "f8a2b6a9cc935ef3e5844427f49aade34e152eca",
41312
- country: "AL",
41313
- category: "mineSite",
41314
- datastakeId: "LOC-00000000141",
41315
- __v: 0
41316
- },
41317
- administrativeLevel1: "6839cb26-5af4-44a3-b136-a0f0a0bcecc6",
41318
- administrativeLevel2: "f849835d-5640-4bee-ae98-9f1c810c1abe",
41319
- // "name": "New Mine",
41320
- country: "AL",
41321
- category: "mineSite",
41322
- authorId: "4e6066e9-00d8-423a-94ec-c7c9d3432fec",
41323
- gps: {
41324
- latitude: 7,
41325
- longitude: 1
41326
- },
41327
- area: [[6, 5], [7, 1], [9, 2]],
41328
- associatedSubjects: [{
41329
- entity: "Event",
41330
- _id: {},
41331
- nature: ""
41332
- }],
41333
- published: false,
41334
- version: 1,
41335
- createdAt: "2024-06-13T14:51:55.296Z",
41336
- updatedAt: "2024-06-13T14:51:55.296Z",
41337
- name: "Name",
41338
- type: "Loc Type",
41339
- __v: 0,
41340
- datastakeId: "LOC-00000000141"
41341
- }]
41342
- // tooltipAsText: true,
41343
- ,
41344
41409
  primaryLink: true,
41345
41410
  renderTooltip: () => {
41346
41411
  return [{
@@ -41348,9 +41413,10 @@ const RestorationActivitySummary = ({
41348
41413
  value: "Name"
41349
41414
  }];
41350
41415
  },
41351
- center: [13, -15],
41352
41416
  mapConfig: {
41353
- maxZoom: 18
41417
+ maxZoom: 18,
41418
+ zoom: 5,
41419
+ center: [14, -14]
41354
41420
  },
41355
41421
  type: 'territory',
41356
41422
  link: true,
@@ -0,0 +1,330 @@
1
+ /* Isolated Mapbox GL CSS - Scoped to prevent Leaflet conflicts */
2
+
3
+ /* Mapbox GL Core Styles - Scoped with .mapbox-gl-scope */
4
+ .mapbox-gl-scope .mapboxgl-map {
5
+ font: 12px/20px Helvetica Neue, Arial, Helvetica, sans-serif;
6
+ overflow: hidden;
7
+ position: relative;
8
+ -webkit-tap-highlight-color: rgb(0 0 0/0);
9
+ }
10
+
11
+ .mapbox-gl-scope .mapboxgl-canvas {
12
+ left: 0;
13
+ position: absolute;
14
+ top: 0;
15
+ }
16
+
17
+ .mapbox-gl-scope .mapboxgl-map:-webkit-full-screen {
18
+ height: 100%;
19
+ width: 100%;
20
+ }
21
+
22
+ .mapbox-gl-scope .mapboxgl-canary {
23
+ background-color: salmon;
24
+ }
25
+
26
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-interactive,
27
+ .mapbox-gl-scope .mapboxgl-ctrl-group button.mapboxgl-ctrl-compass {
28
+ cursor: grab;
29
+ -webkit-user-select: none;
30
+ user-select: none;
31
+ }
32
+
33
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-interactive.mapboxgl-track-pointer {
34
+ cursor: pointer;
35
+ }
36
+
37
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-interactive:active,
38
+ .mapbox-gl-scope .mapboxgl-ctrl-group button.mapboxgl-ctrl-compass:active {
39
+ cursor: grabbing;
40
+ }
41
+
42
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate,
43
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate .mapboxgl-canvas {
44
+ touch-action: pan-x pan-y;
45
+ }
46
+
47
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-drag-pan,
48
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-drag-pan .mapboxgl-canvas {
49
+ touch-action: pinch-zoom;
50
+ }
51
+
52
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan,
53
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan .mapboxgl-canvas {
54
+ touch-action: none;
55
+ }
56
+
57
+ /* Control positioning */
58
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom,
59
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-left,
60
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-right,
61
+ .mapbox-gl-scope .mapboxgl-ctrl-left,
62
+ .mapbox-gl-scope .mapboxgl-ctrl-right,
63
+ .mapbox-gl-scope .mapboxgl-ctrl-top,
64
+ .mapbox-gl-scope .mapboxgl-ctrl-top-left,
65
+ .mapbox-gl-scope .mapboxgl-ctrl-top-right {
66
+ pointer-events: none;
67
+ position: absolute;
68
+ z-index: 2;
69
+ }
70
+
71
+ .mapbox-gl-scope .mapboxgl-ctrl-top-left {
72
+ left: 0;
73
+ top: 0;
74
+ }
75
+
76
+ .mapbox-gl-scope .mapboxgl-ctrl-top {
77
+ left: 50%;
78
+ top: 0;
79
+ transform: translateX(-50%);
80
+ }
81
+
82
+ .mapbox-gl-scope .mapboxgl-ctrl-top-right {
83
+ right: 0;
84
+ top: 0;
85
+ }
86
+
87
+ .mapbox-gl-scope .mapboxgl-ctrl-right {
88
+ right: 0;
89
+ top: 50%;
90
+ transform: translateY(-50%);
91
+ }
92
+
93
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-right {
94
+ bottom: 0;
95
+ right: 0;
96
+ }
97
+
98
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom {
99
+ bottom: 0;
100
+ left: 50%;
101
+ transform: translateX(-50%);
102
+ }
103
+
104
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-left {
105
+ bottom: 0;
106
+ left: 0;
107
+ }
108
+
109
+ .mapbox-gl-scope .mapboxgl-ctrl-left {
110
+ left: 0;
111
+ top: 50%;
112
+ transform: translateY(-50%);
113
+ }
114
+
115
+ .mapbox-gl-scope .mapboxgl-ctrl {
116
+ clear: both;
117
+ pointer-events: auto;
118
+ transform: translate(0);
119
+ }
120
+
121
+ .mapbox-gl-scope .mapboxgl-ctrl-top-left .mapboxgl-ctrl {
122
+ float: left;
123
+ margin: 10px 0 0 10px;
124
+ }
125
+
126
+ .mapbox-gl-scope .mapboxgl-ctrl-top .mapboxgl-ctrl {
127
+ float: left;
128
+ margin: 10px 0;
129
+ }
130
+
131
+ .mapbox-gl-scope .mapboxgl-ctrl-top-right .mapboxgl-ctrl {
132
+ float: right;
133
+ margin: 10px 10px 0 0;
134
+ }
135
+
136
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-right .mapboxgl-ctrl,
137
+ .mapbox-gl-scope .mapboxgl-ctrl-right .mapboxgl-ctrl {
138
+ float: right;
139
+ margin: 0 10px 10px 0;
140
+ }
141
+
142
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom .mapboxgl-ctrl {
143
+ float: left;
144
+ margin: 10px 0;
145
+ }
146
+
147
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-left .mapboxgl-ctrl,
148
+ .mapbox-gl-scope .mapboxgl-ctrl-left .mapboxgl-ctrl {
149
+ float: left;
150
+ margin: 0 0 10px 10px;
151
+ }
152
+
153
+ /* Control group styling */
154
+ .mapbox-gl-scope .mapboxgl-ctrl-group {
155
+ background: #fff;
156
+ border-radius: 4px;
157
+ }
158
+
159
+ .mapbox-gl-scope .mapboxgl-ctrl-group:not(:empty) {
160
+ box-shadow: 0 0 0 2px #0000001a;
161
+ }
162
+
163
+ .mapbox-gl-scope .mapboxgl-ctrl-group button {
164
+ background-color: initial;
165
+ border: 0;
166
+ box-sizing: border-box;
167
+ cursor: pointer;
168
+ display: block;
169
+ height: 29px;
170
+ outline: none;
171
+ overflow: hidden;
172
+ padding: 0;
173
+ width: 29px;
174
+ }
175
+
176
+ .mapbox-gl-scope .mapboxgl-ctrl-group button+button {
177
+ border-top: 1px solid #ddd;
178
+ }
179
+
180
+ .mapbox-gl-scope .mapboxgl-ctrl button .mapboxgl-ctrl-icon {
181
+ background-position: 50%;
182
+ background-repeat: no-repeat;
183
+ display: block;
184
+ height: 100%;
185
+ width: 100%;
186
+ }
187
+
188
+ .mapbox-gl-scope .mapboxgl-ctrl-attrib-button:focus,
189
+ .mapbox-gl-scope .mapboxgl-ctrl-group button:focus {
190
+ box-shadow: 0 0 2px 2px #0096ff;
191
+ }
192
+
193
+ .mapbox-gl-scope .mapboxgl-ctrl button:disabled {
194
+ cursor: not-allowed;
195
+ }
196
+
197
+ .mapbox-gl-scope .mapboxgl-ctrl button:disabled .mapboxgl-ctrl-icon {
198
+ opacity: .25;
199
+ }
200
+
201
+ .mapbox-gl-scope .mapboxgl-ctrl-group button:first-child {
202
+ border-radius: 4px 4px 0 0;
203
+ }
204
+
205
+ .mapbox-gl-scope .mapboxgl-ctrl-group button:last-child {
206
+ border-radius: 0 0 4px 4px;
207
+ }
208
+
209
+ .mapbox-gl-scope .mapboxgl-ctrl-group button:only-child {
210
+ border-radius: inherit;
211
+ }
212
+
213
+ .mapbox-gl-scope .mapboxgl-ctrl button:not(:disabled):hover {
214
+ background-color: #0000000d;
215
+ }
216
+
217
+ /* Marker styles */
218
+ .mapbox-gl-scope .mapboxgl-marker {
219
+ position: absolute;
220
+ z-index: 1;
221
+ }
222
+
223
+ .mapbox-gl-scope .mapboxgl-marker svg {
224
+ display: block;
225
+ }
226
+
227
+ /* Popup styles */
228
+ .mapbox-gl-scope .mapboxgl-popup {
229
+ position: absolute;
230
+ text-align: center;
231
+ margin-bottom: 20px;
232
+ }
233
+
234
+ .mapbox-gl-scope .mapboxgl-popup-content-wrapper {
235
+ padding: 1px;
236
+ text-align: left;
237
+ border-radius: 12px;
238
+ }
239
+
240
+ .mapbox-gl-scope .mapboxgl-popup-content {
241
+ margin: 13px 24px 13px 20px;
242
+ line-height: 1.3;
243
+ font-size: 13px;
244
+ min-height: 1px;
245
+ }
246
+
247
+ .mapbox-gl-scope .mapboxgl-popup-content p {
248
+ margin: 17px 0;
249
+ }
250
+
251
+ .mapbox-gl-scope .mapboxgl-popup-tip-container {
252
+ width: 40px;
253
+ height: 20px;
254
+ position: absolute;
255
+ left: 50%;
256
+ margin-top: -1px;
257
+ margin-left: -20px;
258
+ overflow: hidden;
259
+ pointer-events: none;
260
+ }
261
+
262
+ .mapbox-gl-scope .mapboxgl-popup-tip {
263
+ width: 17px;
264
+ height: 17px;
265
+ padding: 1px;
266
+ margin: -10px auto 0;
267
+ pointer-events: auto;
268
+ -webkit-transform: rotate(45deg);
269
+ -moz-transform: rotate(45deg);
270
+ -ms-transform: rotate(45deg);
271
+ transform: rotate(45deg);
272
+ }
273
+
274
+ .mapbox-gl-scope .mapboxgl-popup-content-wrapper,
275
+ .mapbox-gl-scope .mapboxgl-popup-tip {
276
+ background: white;
277
+ color: #333;
278
+ box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4);
279
+ }
280
+
281
+ .mapbox-gl-scope .mapboxgl-popup-close-button {
282
+ position: absolute;
283
+ top: 0;
284
+ right: 0;
285
+ border: none;
286
+ text-align: center;
287
+ width: 24px;
288
+ height: 24px;
289
+ font: 16px/24px Tahoma, Verdana, sans-serif;
290
+ color: #757575;
291
+ text-decoration: none;
292
+ background: transparent;
293
+ }
294
+
295
+ .mapbox-gl-scope .mapboxgl-popup-close-button:hover,
296
+ .mapbox-gl-scope .mapboxgl-popup-close-button:focus {
297
+ color: #585858;
298
+ }
299
+
300
+ /* Attribution */
301
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution {
302
+ background: #fff;
303
+ background: rgba(255, 255, 255, 0.8);
304
+ margin: 0;
305
+ }
306
+
307
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution,
308
+ .mapbox-gl-scope .mapboxgl-ctrl-scale-line {
309
+ padding: 0 5px;
310
+ color: #333;
311
+ line-height: 1.4;
312
+ }
313
+
314
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution a {
315
+ text-decoration: none;
316
+ }
317
+
318
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution a:hover,
319
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution a:focus {
320
+ text-decoration: underline;
321
+ }
322
+
323
+ /* Hide attribution by default */
324
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution {
325
+ display: none !important;
326
+ }
327
+
328
+ .mapbox-gl-scope .mapboxgl-ctrl-logo {
329
+ display: none !important;
330
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.751",
3
+ "version": "0.6.753",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -168,19 +168,29 @@ export default function DynamicForm({
168
168
  }
169
169
  }, [data]);
170
170
 
171
- // Initialize default values for hidden fields
171
+ // Initialize default values for hidden and disabled fields
172
172
  useEffect(() => {
173
173
  if (Object.keys(form).length > 0) {
174
174
  const updatedValues = { ...values };
175
175
  let hasChanges = false;
176
+ const isEditMode = data && (data.id || data._id);
176
177
 
177
- // Process all form fields to set default values for hidden fields
178
+ // Process all form fields to set default values for hidden and disabled fields
178
179
  Object.keys(form).forEach(formKey => {
179
180
  Object.keys(form[formKey]).forEach(fieldKey => {
180
181
  const field = form[formKey][fieldKey];
181
- if (field?.meta?.hidden === true && field?.meta?.defaultValue !== undefined) {
182
- const fieldId = field.dataId || fieldKey;
183
- if (!propHasValue(updatedValues[fieldId])) {
182
+ const fieldId = field.dataId || fieldKey;
183
+
184
+ // Check if field is disabled
185
+ const isDisabled = (field?.meta?.disableEdit && typeof field?.meta?.disableEdit === 'object')
186
+ ? isModal
187
+ ? field.meta.disableEdit.create || field.meta.disableEdit.modal || (field?.meta?.disableEdit?.edit && isEditMode)
188
+ : field.meta.disableEdit.create || field.meta.disableEdit.drawer || (field?.meta?.disableEdit?.edit && isEditMode)
189
+ : field?.meta?.disableEdit;
190
+
191
+ // Set default value for hidden fields or disabled fields with default values
192
+ if (field?.meta?.defaultValue !== undefined && !propHasValue(updatedValues[fieldId])) {
193
+ if (field?.meta?.hidden === true || isDisabled) {
184
194
  updatedValues[fieldId] = field.meta.defaultValue;
185
195
  hasChanges = true;
186
196
  }
@@ -194,7 +204,7 @@ export default function DynamicForm({
194
204
  MainForm.setFieldsValue(updatedValues);
195
205
  }
196
206
  }
197
- }, [form]);
207
+ }, [form, data, isModal]);
198
208
 
199
209
  const setSelectedForm = (id) => {
200
210
  setForms(Forms.map(form => {
@@ -295,11 +305,16 @@ export default function DynamicForm({
295
305
  }
296
306
  value = fileList;
297
307
  }
298
- // Handle default values for hidden fields
299
- if (input?.meta?.hidden === true && input?.meta?.defaultValue !== undefined && !propHasValue(value)) {
300
- value = input.meta.defaultValue;
301
- if (typeof path === 'string') {
302
- dot.str(path, value, values);
308
+ // Handle default values for hidden fields and disabled fields
309
+ if (input?.meta?.defaultValue !== undefined && !propHasValue(value)) {
310
+ const isFieldHidden = input?.meta?.hidden === true;
311
+ const isFieldDisabled = props.disabled || isDisabled;
312
+
313
+ if (isFieldHidden || isFieldDisabled) {
314
+ value = input.meta.defaultValue;
315
+ if (typeof path === 'string') {
316
+ dot.str(path, value, values);
317
+ }
303
318
  }
304
319
  }
305
320
 
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  // ============================================================================
2
4
  // REGION: Photo/Image Extraction
3
5
  // ============================================================================
@@ -120,6 +122,93 @@ export const getGenderTooltipChildren = (item, isEmpty, genderDistributionData,
120
122
  });
121
123
  };
122
124
 
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
+
123
212
  // ============================================================================
124
213
  // REGION: Activity Indicators
125
214
  // ============================================================================
@@ -1,7 +1,7 @@
1
1
  import { useMemo, useCallback } from 'react';
2
- import { DashboardLayout, Header, ImageCarousel, KeyIndicators, MineSiteMap, Widget, PieChart, ActivityIndicators } from '../../../../../../src/index.js'
2
+ import { DashboardLayout, Header, ImageCarousel, KeyIndicators, MineSiteMap, Widget, PieChart, ActivityIndicators, Multiselect, CustomIcon } from '../../../../../../src/index.js'
3
3
  import { getKeyIndicatorsRowConfig } from './config';
4
- import { getActivityImages, getGenderDistributionData, isGenderDistributionEmpty, calculateGenderPieData, getGenderTooltipChildren, getActivityIndicatorsConfig } from './helper';
4
+ import { getActivityImages, getGenderDistributionData, isGenderDistributionEmpty, calculateGenderPieData, getGenderTooltipChildren, getActivityIndicatorsConfig, getFilteredOptions, getDefaultSelected } from './helper';
5
5
  import { renderTooltipJsx } from '../../../../../../src/utils';
6
6
  import { useResizeContext } from '../../../../../../src/context';
7
7
 
@@ -24,6 +24,18 @@ 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
+
27
39
  return (
28
40
  <DashboardLayout
29
41
  header={
@@ -36,6 +48,24 @@ const RestorationActivitySummary = ({ activityData, supportText, onDownload, dow
36
48
  breadcrumbs={breadcrumbs}
37
49
  goBackTo={goBackTo}
38
50
  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
+ }
39
69
  />
40
70
  }
41
71
  >
@@ -57,57 +87,6 @@ const RestorationActivitySummary = ({ activityData, supportText, onDownload, dow
57
87
  app={"straatos"}
58
88
  showSider={false}
59
89
  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,
111
90
  primaryLink={true}
112
91
  renderTooltip={() => {
113
92
  return [
@@ -117,8 +96,8 @@ const RestorationActivitySummary = ({ activityData, supportText, onDownload, dow
117
96
  },
118
97
  ];
119
98
  }}
120
- center={[13, -15]}
121
- mapConfig={{ maxZoom: 18 }}
99
+
100
+ mapConfig={{ maxZoom: 18, zoom: 5, center: [14, -14] }}
122
101
  type={'territory'}
123
102
  link={true}
124
103
  onClickLink={() => { }}