@dartech/arsenal-ui 1.3.71 → 1.3.73
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
@@ -3286,17 +3286,24 @@ const EntityAdditionalFields = ({
|
|
3286
3286
|
control,
|
3287
3287
|
name: `${parentPropertyFieldName}.name`
|
3288
3288
|
});
|
3289
|
+
const {
|
3290
|
+
fields,
|
3291
|
+
append
|
3292
|
+
} = useFieldArray({
|
3293
|
+
control,
|
3294
|
+
name: `${parentPropertyFieldName}.properties`
|
3295
|
+
});
|
3289
3296
|
const parametersModal = useToggle();
|
3290
3297
|
const [focusedProperty, setFocusedProperty] = useState(0);
|
3291
3298
|
const handleAddParameter = useCallback(() => {
|
3292
|
-
if (
|
3293
|
-
|
3294
|
-
|
3299
|
+
if (fields.length > 0) {
|
3300
|
+
append(defaultPropertyValues$1);
|
3301
|
+
const propertyIndex = fields.length;
|
3295
3302
|
setFocusedProperty(propertyIndex);
|
3296
3303
|
} else {
|
3297
|
-
|
3304
|
+
append(defaultPropertyValues$1);
|
3298
3305
|
}
|
3299
|
-
}, [
|
3306
|
+
}, [fields, append]);
|
3300
3307
|
const handleStepperClick = index => setFocusedProperty(index);
|
3301
3308
|
const handleSubmitClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
3302
3309
|
const isValid = yield trigger(`${parentPropertyFieldName}.properties`);
|
@@ -3400,6 +3407,7 @@ const EntityAdditionalFields = ({
|
|
3400
3407
|
}, {
|
3401
3408
|
children: jsx(CreatePropertiesList, {
|
3402
3409
|
hideAddButton: true,
|
3410
|
+
entityPropFields: fields,
|
3403
3411
|
parentFieldName: parentPropertyFieldName,
|
3404
3412
|
focusOnIndex: focusedProperty,
|
3405
3413
|
entityDefinition: _entityDefinition,
|
@@ -3421,83 +3429,6 @@ const EntityAdditionalFields = ({
|
|
3421
3429
|
};
|
3422
3430
|
var EntityAdditionalFields$1 = EntityAdditionalFields;
|
3423
3431
|
|
3424
|
-
const sources = [{
|
3425
|
-
label: 'Arsenal',
|
3426
|
-
value: 'ARSENAL'
|
3427
|
-
}, {
|
3428
|
-
label: 'Scalend',
|
3429
|
-
value: 'SCALEND'
|
3430
|
-
}];
|
3431
|
-
const modules = [{
|
3432
|
-
label: 'Customers',
|
3433
|
-
value: 'CUSTOMERS'
|
3434
|
-
}, {
|
3435
|
-
label: 'Products',
|
3436
|
-
value: 'PRODUCTS'
|
3437
|
-
}, {
|
3438
|
-
label: 'Pledges',
|
3439
|
-
value: 'PLEDGES'
|
3440
|
-
}];
|
3441
|
-
const EntityReferencePropertyFields = ({
|
3442
|
-
propertyFieldName
|
3443
|
-
}) => {
|
3444
|
-
const {
|
3445
|
-
control
|
3446
|
-
} = useFormContext();
|
3447
|
-
const source = useWatch({
|
3448
|
-
control,
|
3449
|
-
name: `${propertyFieldName}.source`
|
3450
|
-
});
|
3451
|
-
return jsxs(Fragment, {
|
3452
|
-
children: [jsx(Grid, {
|
3453
|
-
children: jsx(ControlSelect, {
|
3454
|
-
required: true,
|
3455
|
-
control: control,
|
3456
|
-
name: `${propertyFieldName}.source`,
|
3457
|
-
label: "Source",
|
3458
|
-
options: sources
|
3459
|
-
})
|
3460
|
-
}), source && jsx(Grid, {
|
3461
|
-
children: source === 'ARSENAL' ? jsx(ControlInput, {
|
3462
|
-
required: true,
|
3463
|
-
control: control,
|
3464
|
-
name: `${propertyFieldName}.definitionCode`,
|
3465
|
-
label: "Definition Code"
|
3466
|
-
}) : jsx(ControlSelect, {
|
3467
|
-
required: true,
|
3468
|
-
control: control,
|
3469
|
-
name: `${propertyFieldName}.definitionCode`,
|
3470
|
-
label: "Definition Code",
|
3471
|
-
valueKey: "value",
|
3472
|
-
options: modules
|
3473
|
-
})
|
3474
|
-
}), jsx(Grid, {
|
3475
|
-
children: jsx(ControlInput, {
|
3476
|
-
required: true,
|
3477
|
-
control: control,
|
3478
|
-
name: `${propertyFieldName}.definitionVersion`,
|
3479
|
-
label: "Definition Version",
|
3480
|
-
defaultValue: 1
|
3481
|
-
})
|
3482
|
-
}), jsx(Grid, {
|
3483
|
-
children: jsx(ControlInput, {
|
3484
|
-
required: true,
|
3485
|
-
control: control,
|
3486
|
-
name: `${propertyFieldName}.labelPropertyCode`,
|
3487
|
-
label: "Label Property Code"
|
3488
|
-
})
|
3489
|
-
}), jsx(Grid, {
|
3490
|
-
children: jsx(ControlInput, {
|
3491
|
-
required: true,
|
3492
|
-
control: control,
|
3493
|
-
name: `${propertyFieldName}.valuePropertyCode`,
|
3494
|
-
label: "Value Property Code"
|
3495
|
-
})
|
3496
|
-
})]
|
3497
|
-
});
|
3498
|
-
};
|
3499
|
-
var EntityReferencePropertyFields$1 = EntityReferencePropertyFields;
|
3500
|
-
|
3501
3432
|
const StringPropertyFields = ({
|
3502
3433
|
propertyFieldName
|
3503
3434
|
}) => {
|
@@ -3624,7 +3555,8 @@ const PropertyAdditionalFields = ({
|
|
3624
3555
|
defaultValue: DATE_TIME_DEFAULT_FORMAT
|
3625
3556
|
});
|
3626
3557
|
case PropertyType.ENTITY_REFERENCE:
|
3627
|
-
return
|
3558
|
+
// return <EntityReferencePropertyFields propertyFieldName={propertyFieldName} />;
|
3559
|
+
return jsx(StringPropertyFields$1, {
|
3628
3560
|
propertyFieldName: propertyFieldName
|
3629
3561
|
});
|
3630
3562
|
case PropertyType.ENTITY:
|
@@ -5127,14 +5059,23 @@ const CreatePropertiesList = ({
|
|
5127
5059
|
required,
|
5128
5060
|
entityDefinition: _entityDefinition = false,
|
5129
5061
|
globalParameter: _globalParameter = false,
|
5130
|
-
customPropertyFields: _customPropertyFields = []
|
5062
|
+
customPropertyFields: _customPropertyFields = [],
|
5063
|
+
entityPropFields
|
5131
5064
|
}) => {
|
5132
5065
|
const fieldName = useMemo(() => parentFieldName ? `${parentFieldName}.properties` : `properties`, [parentFieldName]);
|
5133
5066
|
const {
|
5134
|
-
setValue,
|
5135
5067
|
clearErrors,
|
5136
|
-
control
|
5068
|
+
control,
|
5069
|
+
watch
|
5137
5070
|
} = useFormContext();
|
5071
|
+
const {
|
5072
|
+
fields,
|
5073
|
+
append,
|
5074
|
+
remove
|
5075
|
+
} = useFieldArray({
|
5076
|
+
control,
|
5077
|
+
name: fieldName
|
5078
|
+
});
|
5138
5079
|
const {
|
5139
5080
|
fieldState: {
|
5140
5081
|
error
|
@@ -5160,16 +5101,19 @@ const CreatePropertiesList = ({
|
|
5160
5101
|
}
|
5161
5102
|
}, [focusOnIndex, refs]);
|
5162
5103
|
const handleAddParameter = useCallback(() => {
|
5163
|
-
|
5164
|
-
setValue(`${fieldName}.${properties.length}`, defaultPropertyValues);
|
5165
|
-
} else {
|
5166
|
-
setValue(fieldName, [defaultPropertyValues]);
|
5167
|
-
}
|
5104
|
+
append(defaultPropertyValues);
|
5168
5105
|
clearErrors(fieldName);
|
5169
|
-
}, [
|
5106
|
+
}, [append, fieldName, clearErrors]);
|
5170
5107
|
const handleRemoveParameter = useCallback(index => {
|
5171
|
-
|
5172
|
-
}, [
|
5108
|
+
remove(index);
|
5109
|
+
}, [remove]);
|
5110
|
+
const propFields = useMemo(() => {
|
5111
|
+
if (entityPropFields) {
|
5112
|
+
return entityPropFields;
|
5113
|
+
} else {
|
5114
|
+
return fields;
|
5115
|
+
}
|
5116
|
+
}, [entityPropFields, fields]);
|
5173
5117
|
return jsxs(Fragment, {
|
5174
5118
|
children: [error && error.message && jsx(Grid, Object.assign({
|
5175
5119
|
sm: 12
|
@@ -5179,7 +5123,7 @@ const CreatePropertiesList = ({
|
|
5179
5123
|
}, {
|
5180
5124
|
children: error.message
|
5181
5125
|
}))
|
5182
|
-
})), Array.isArray(properties) &&
|
5126
|
+
})), Array.isArray(properties) && propFields.map((item, index) => jsx(Grid, Object.assign({
|
5183
5127
|
sm: 12,
|
5184
5128
|
ref: ref => refs.current[index] = ref
|
5185
5129
|
}, {
|
@@ -5196,7 +5140,7 @@ const CreatePropertiesList = ({
|
|
5196
5140
|
wordBreak: 'break-word'
|
5197
5141
|
}
|
5198
5142
|
}, {
|
5199
|
-
children:
|
5143
|
+
children: watch(`${fieldName}.${index}.name`) || `Property ${index + 1}`
|
5200
5144
|
}))
|
5201
5145
|
})), jsx(AccordionDetails, {
|
5202
5146
|
children: jsx(CreatePropertyFormFields, {
|
@@ -5216,7 +5160,7 @@ const CreatePropertiesList = ({
|
|
5216
5160
|
}))
|
5217
5161
|
})]
|
5218
5162
|
}))
|
5219
|
-
}),
|
5163
|
+
}), item.id)), !hideAddButton && jsx(Grid, Object.assign({
|
5220
5164
|
xs: 12
|
5221
5165
|
}, {
|
5222
5166
|
children: jsx(Button, Object.assign({
|
package/package.json
CHANGED
@@ -8,6 +8,9 @@ type Props = {
|
|
8
8
|
entityDefinition?: boolean;
|
9
9
|
globalParameter?: boolean;
|
10
10
|
customPropertyFields?: CustomPropertyFieldProps[];
|
11
|
+
entityPropFields?: Array<object & {
|
12
|
+
id: string;
|
13
|
+
}>;
|
11
14
|
};
|
12
|
-
export declare const CreatePropertiesList: ({ parentFieldName, hideAddButton, focusOnIndex, required, entityDefinition, globalParameter, customPropertyFields, }: Props) => JSX.Element;
|
15
|
+
export declare const CreatePropertiesList: ({ parentFieldName, hideAddButton, focusOnIndex, required, entityDefinition, globalParameter, customPropertyFields, entityPropFields, }: Props) => JSX.Element;
|
13
16
|
export default CreatePropertiesList;
|