@dartech/arsenal-ui 1.3.80 → 1.3.81
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/index.js
CHANGED
@@ -70,11 +70,10 @@ import StepContent from '@mui/material/StepContent';
|
|
70
70
|
import StepConnector from '@mui/material/StepConnector';
|
71
71
|
import Select from '@mui/material/Select';
|
72
72
|
import InputLabel from '@mui/material/InputLabel';
|
73
|
-
import { toast } from 'react-toastify';
|
74
|
-
import axios from 'axios';
|
75
73
|
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
76
74
|
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
77
75
|
import classnames from 'classnames';
|
76
|
+
import { toast } from 'react-toastify';
|
78
77
|
import CssBaseline from '@mui/material/CssBaseline';
|
79
78
|
import MuiDrawer from '@mui/material/Drawer';
|
80
79
|
import MuiList from '@mui/material/List';
|
@@ -1659,6 +1658,7 @@ const propertiesArrayToObject = (properties, isGlobalParameter) => {
|
|
1659
1658
|
resultProperty['restrictedValues'] = property.restrictedValues;
|
1660
1659
|
}
|
1661
1660
|
if (propertyType === PropertyType.ENTITY_REFERENCE) {
|
1661
|
+
resultProperty['source'] = property.source;
|
1662
1662
|
resultProperty['definitionCode'] = property.definitionCode;
|
1663
1663
|
resultProperty['definitionVersion'] = property.definitionVersion;
|
1664
1664
|
resultProperty['labelPropertyCode'] = property.labelPropertyCode;
|
@@ -3287,7 +3287,6 @@ const EntityAdditionalFields = ({
|
|
3287
3287
|
}) => {
|
3288
3288
|
const {
|
3289
3289
|
control,
|
3290
|
-
setValue,
|
3291
3290
|
getValues,
|
3292
3291
|
trigger
|
3293
3292
|
} = useFormContext();
|
@@ -3302,7 +3301,8 @@ const EntityAdditionalFields = ({
|
|
3302
3301
|
});
|
3303
3302
|
const {
|
3304
3303
|
fields,
|
3305
|
-
append
|
3304
|
+
append,
|
3305
|
+
remove
|
3306
3306
|
} = useFieldArray({
|
3307
3307
|
control,
|
3308
3308
|
name: `${parentPropertyFieldName}.properties`
|
@@ -3422,6 +3422,7 @@ const EntityAdditionalFields = ({
|
|
3422
3422
|
children: jsx(CreatePropertiesList, {
|
3423
3423
|
hideAddButton: true,
|
3424
3424
|
entityPropFields: fields,
|
3425
|
+
parentRemove: remove,
|
3425
3426
|
parentFieldName: parentPropertyFieldName,
|
3426
3427
|
focusOnIndex: focusedProperty,
|
3427
3428
|
entityDefinition: _entityDefinition,
|
@@ -3645,131 +3646,6 @@ const StringValueField = ({
|
|
3645
3646
|
};
|
3646
3647
|
var StringValueField$1 = StringValueField;
|
3647
3648
|
|
3648
|
-
function useEntitiesService({
|
3649
|
-
baseURL
|
3650
|
-
}) {
|
3651
|
-
const entitiesInstance = axios.create({
|
3652
|
-
baseURL: baseURL
|
3653
|
-
});
|
3654
|
-
const getEntitiesByCodeAndVersion = ({
|
3655
|
-
definitionCode,
|
3656
|
-
definitionVersion
|
3657
|
-
}) => __awaiter(this, void 0, void 0, function* () {
|
3658
|
-
const response = yield entitiesInstance.get(`/entities/code/${definitionCode}/version/${definitionVersion}`);
|
3659
|
-
console.log(response);
|
3660
|
-
return response.data;
|
3661
|
-
});
|
3662
|
-
const getCustomerApplications = params => __awaiter(this, void 0, void 0, function* () {
|
3663
|
-
const response = yield entitiesInstance.get('/customer-application-instances', {
|
3664
|
-
params
|
3665
|
-
});
|
3666
|
-
return response.data['collection'];
|
3667
|
-
});
|
3668
|
-
const getProducts = params => __awaiter(this, void 0, void 0, function* () {
|
3669
|
-
const response = yield entitiesInstance.get('/products', {
|
3670
|
-
params
|
3671
|
-
});
|
3672
|
-
return response.data['collection'];
|
3673
|
-
});
|
3674
|
-
const getPledgeInstances = params => __awaiter(this, void 0, void 0, function* () {
|
3675
|
-
const response = yield entitiesInstance.get('/pledge-instances', {
|
3676
|
-
params
|
3677
|
-
});
|
3678
|
-
return response.data['collection'];
|
3679
|
-
});
|
3680
|
-
return {
|
3681
|
-
getEntitiesByCodeAndVersion,
|
3682
|
-
getCustomerApplications,
|
3683
|
-
getProducts,
|
3684
|
-
getPledgeInstances
|
3685
|
-
};
|
3686
|
-
}
|
3687
|
-
|
3688
|
-
const EntityReferenceValueField = ({
|
3689
|
-
name,
|
3690
|
-
required: _required = false,
|
3691
|
-
definitionProperty,
|
3692
|
-
baseURL: _baseURL = 'https://dev-sl-api.dar-dev.zone/api/v1'
|
3693
|
-
}) => {
|
3694
|
-
const {
|
3695
|
-
control
|
3696
|
-
} = useFormContext();
|
3697
|
-
const {
|
3698
|
-
source,
|
3699
|
-
definitionCode,
|
3700
|
-
definitionVersion,
|
3701
|
-
valuePropertyCode,
|
3702
|
-
labelPropertyCode
|
3703
|
-
} = definitionProperty;
|
3704
|
-
const {
|
3705
|
-
getCustomerApplications,
|
3706
|
-
getEntitiesByCodeAndVersion,
|
3707
|
-
getPledgeInstances,
|
3708
|
-
getProducts
|
3709
|
-
} = useEntitiesService({
|
3710
|
-
baseURL: _baseURL
|
3711
|
-
});
|
3712
|
-
const [loading, setLoading] = useState(false);
|
3713
|
-
const [referredInstancesValues, setReferredInstancesValues] = useState([]);
|
3714
|
-
const scalendCallback = useMemo(() => {
|
3715
|
-
if (source === 'SCALEND') {
|
3716
|
-
switch (definitionCode) {
|
3717
|
-
case 'CUSTOMERS':
|
3718
|
-
return getCustomerApplications;
|
3719
|
-
case 'PLEDGES':
|
3720
|
-
return getPledgeInstances;
|
3721
|
-
case 'PRODUCTS':
|
3722
|
-
return getProducts;
|
3723
|
-
default:
|
3724
|
-
return null;
|
3725
|
-
}
|
3726
|
-
}
|
3727
|
-
return null;
|
3728
|
-
}, [definitionCode, source]);
|
3729
|
-
useEffect(() => {
|
3730
|
-
if (definitionCode && definitionVersion) {
|
3731
|
-
setLoading(true);
|
3732
|
-
if (source === 'ARSENAL') {
|
3733
|
-
getEntitiesByCodeAndVersion({
|
3734
|
-
definitionCode,
|
3735
|
-
definitionVersion
|
3736
|
-
}).then(instances => {
|
3737
|
-
const instanceValues = instances.map(instance => instance['data'][`${valuePropertyCode}`]);
|
3738
|
-
setReferredInstancesValues(instanceValues);
|
3739
|
-
}).catch(error => {
|
3740
|
-
setReferredInstancesValues([]);
|
3741
|
-
toast.error(error);
|
3742
|
-
}).finally(() => {
|
3743
|
-
setLoading(false);
|
3744
|
-
});
|
3745
|
-
} else if (source === 'SCALEND') {
|
3746
|
-
scalendCallback().then(instances => {
|
3747
|
-
const instanceValues = instances.map(instance => instance.id);
|
3748
|
-
setReferredInstancesValues(instanceValues);
|
3749
|
-
}).catch(error => {
|
3750
|
-
setReferredInstancesValues([]);
|
3751
|
-
toast.error(error);
|
3752
|
-
}).finally(() => {
|
3753
|
-
setLoading(false);
|
3754
|
-
});
|
3755
|
-
}
|
3756
|
-
}
|
3757
|
-
}, [definitionCode, definitionVersion, valuePropertyCode, source, labelPropertyCode, scalendCallback]);
|
3758
|
-
return jsx(Grid, {
|
3759
|
-
children: jsx(ControlAutocomplete, {
|
3760
|
-
required: _required,
|
3761
|
-
control: control,
|
3762
|
-
name: source === 'SCALEND' ? name : `${name}.${labelPropertyCode}`,
|
3763
|
-
label: labelPropertyCode,
|
3764
|
-
labelKey: labelPropertyCode,
|
3765
|
-
valueKey: valuePropertyCode,
|
3766
|
-
loading: loading,
|
3767
|
-
options: referredInstancesValues
|
3768
|
-
})
|
3769
|
-
});
|
3770
|
-
};
|
3771
|
-
var EntityReferenceValueField$1 = EntityReferenceValueField;
|
3772
|
-
|
3773
3649
|
const PropertyWidget = ({
|
3774
3650
|
property,
|
3775
3651
|
name,
|
@@ -3858,13 +3734,9 @@ const PropertyWidget = ({
|
|
3858
3734
|
restrictedValues: property.restrictedValues
|
3859
3735
|
});
|
3860
3736
|
case PropertyType.ENTITY_REFERENCE:
|
3861
|
-
return jsx(
|
3862
|
-
// required
|
3863
|
-
, {
|
3864
|
-
// required
|
3737
|
+
return jsx(StringValueField$1, {
|
3865
3738
|
name: name,
|
3866
|
-
|
3867
|
-
baseURL: baseURL
|
3739
|
+
label: label
|
3868
3740
|
});
|
3869
3741
|
case PropertyType.ANY:
|
3870
3742
|
return jsx(ControlAceEditor, {
|
@@ -5036,7 +4908,8 @@ const CreatePropertiesList = ({
|
|
5036
4908
|
entityDefinition: _entityDefinition = false,
|
5037
4909
|
globalParameter: _globalParameter = false,
|
5038
4910
|
customPropertyFields: _customPropertyFields = [],
|
5039
|
-
entityPropFields
|
4911
|
+
entityPropFields,
|
4912
|
+
parentRemove
|
5040
4913
|
}) => {
|
5041
4914
|
const fieldName = useMemo(() => parentFieldName ? `${parentFieldName}.properties` : `properties`, [parentFieldName]);
|
5042
4915
|
const {
|
@@ -5080,9 +4953,16 @@ const CreatePropertiesList = ({
|
|
5080
4953
|
append(defaultPropertyValues);
|
5081
4954
|
clearErrors(fieldName);
|
5082
4955
|
}, [append, fieldName, clearErrors]);
|
4956
|
+
const removeFields = useMemo(() => {
|
4957
|
+
if (entityPropFields) {
|
4958
|
+
return parentRemove;
|
4959
|
+
} else {
|
4960
|
+
return remove;
|
4961
|
+
}
|
4962
|
+
}, [entityPropFields, remove, parentRemove]);
|
5083
4963
|
const handleRemoveParameter = useCallback(index => {
|
5084
|
-
|
5085
|
-
}, [
|
4964
|
+
removeFields(index);
|
4965
|
+
}, [removeFields]);
|
5086
4966
|
const propFields = useMemo(() => {
|
5087
4967
|
if (entityPropFields) {
|
5088
4968
|
return entityPropFields;
|
package/package.json
CHANGED
@@ -11,6 +11,7 @@ type Props = {
|
|
11
11
|
entityPropFields?: Array<object & {
|
12
12
|
id: string;
|
13
13
|
}>;
|
14
|
+
parentRemove?: (index?: number | number[]) => void;
|
14
15
|
};
|
15
|
-
export declare const CreatePropertiesList: ({ parentFieldName, hideAddButton, focusOnIndex, required, entityDefinition, globalParameter, customPropertyFields, entityPropFields, }: Props) => JSX.Element;
|
16
|
+
export declare const CreatePropertiesList: ({ parentFieldName, hideAddButton, focusOnIndex, required, entityDefinition, globalParameter, customPropertyFields, entityPropFields, parentRemove, }: Props) => JSX.Element;
|
16
17
|
export default CreatePropertiesList;
|