awing-library 2.1.2-dev.7 → 2.1.2-dev.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +61 -42
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -111978,18 +111978,24 @@ const AutocompleteInput = fieldDefinition => {
|
|
|
111978
111978
|
multiple = true,
|
|
111979
111979
|
isDirectory = false,
|
|
111980
111980
|
onValidateCustom,
|
|
111981
|
-
disabled
|
|
111981
|
+
disabled,
|
|
111982
|
+
required = false
|
|
111982
111983
|
} = fieldDefinition,
|
|
111983
|
-
other = __rest$1(fieldDefinition, ["options", "value", "onChange", "readOnly", "error", "disableHelperText", "helperText", "disableClearable", "multiple", "isDirectory", "onValidateCustom", "disabled"]);
|
|
111984
|
+
other = __rest$1(fieldDefinition, ["options", "value", "onChange", "readOnly", "error", "disableHelperText", "helperText", "disableClearable", "multiple", "isDirectory", "onValidateCustom", "disabled", "required"]);
|
|
111985
|
+
console.log('fieldDefinition', fieldDefinition);
|
|
111984
111986
|
const onValidate = val => {
|
|
111985
|
-
if (
|
|
111986
|
-
|
|
111987
|
-
|
|
111988
|
-
|
|
111989
|
-
|
|
111990
|
-
|
|
111987
|
+
if (required) {
|
|
111988
|
+
if (!val) return false;
|
|
111989
|
+
if (onValidateCustom) {
|
|
111990
|
+
return onValidateCustom(val);
|
|
111991
|
+
}
|
|
111992
|
+
if (Array.isArray(val)) {
|
|
111993
|
+
return arrayIsNotEmptyValid(val);
|
|
111994
|
+
} else {
|
|
111995
|
+
return notNullValid(val);
|
|
111996
|
+
}
|
|
111991
111997
|
} else {
|
|
111992
|
-
return
|
|
111998
|
+
return true;
|
|
111993
111999
|
}
|
|
111994
112000
|
};
|
|
111995
112001
|
return jsxRuntimeExports.jsx(Autocomplete$2, Object.assign({
|
|
@@ -112019,6 +112025,7 @@ const AutocompleteInput = fieldDefinition => {
|
|
|
112019
112025
|
renderInput: params => jsxRuntimeExports.jsx(TextField$1, Object.assign({}, params, other, {
|
|
112020
112026
|
variant: "standard",
|
|
112021
112027
|
error: error,
|
|
112028
|
+
required: required,
|
|
112022
112029
|
helperText: !disableHelperText && error ? helperText !== null && helperText !== void 0 ? helperText : t('Common.InvalidData') : ''
|
|
112023
112030
|
}))
|
|
112024
112031
|
}, multiple && {
|
|
@@ -164819,8 +164826,7 @@ const Container$g = props => {
|
|
|
164819
164826
|
children: jsxRuntimeExports.jsx(DatePicker, Object.assign({
|
|
164820
164827
|
label: "Basic date picker"
|
|
164821
164828
|
}, rest, {
|
|
164822
|
-
onChange: handleChange
|
|
164823
|
-
defaultValue: dayjs()
|
|
164829
|
+
onChange: handleChange
|
|
164824
164830
|
}))
|
|
164825
164831
|
});
|
|
164826
164832
|
};
|
|
@@ -185091,9 +185097,32 @@ const Edit = () => {
|
|
|
185091
185097
|
roleTagOptions,
|
|
185092
185098
|
groupsTagOptions
|
|
185093
185099
|
} = useContextUser();
|
|
185100
|
+
//GetUserById to get user information
|
|
185101
|
+
useEffect(() => {
|
|
185102
|
+
if (services) {
|
|
185103
|
+
setLoadingUser(true);
|
|
185104
|
+
services.getUserById({
|
|
185105
|
+
id: Number(userId)
|
|
185106
|
+
}).then(data => {
|
|
185107
|
+
setUser(data);
|
|
185108
|
+
setUserRoleAuthens(lodashExports.map(lodashExports.get(data, 'roleAuthens', []), i => {
|
|
185109
|
+
var _a;
|
|
185110
|
+
return {
|
|
185111
|
+
id: i.id,
|
|
185112
|
+
roleId: i.roleId,
|
|
185113
|
+
roleName: (_a = i === null || i === void 0 ? void 0 : i.role) === null || _a === void 0 ? void 0 : _a.name
|
|
185114
|
+
};
|
|
185115
|
+
}));
|
|
185116
|
+
}).finally(() => {
|
|
185117
|
+
setLoadingUser(false);
|
|
185118
|
+
});
|
|
185119
|
+
}
|
|
185120
|
+
}, []);
|
|
185121
|
+
//handle confirm exit
|
|
185094
185122
|
const getUserRoles = () => {
|
|
185123
|
+
var _a;
|
|
185095
185124
|
const userRolesInput = [];
|
|
185096
|
-
const currentUserRoles = lodashExports.cloneDeep(lodashExports.get(user, 'roles',
|
|
185125
|
+
const currentUserRoles = lodashExports.cloneDeep(lodashExports.get(user, 'roles', (_a = user === null || user === void 0 ? void 0 : user.roleAuthens) === null || _a === void 0 ? void 0 : _a.map(i => i.roleId)));
|
|
185097
185126
|
// add more new items
|
|
185098
185127
|
lodashExports.each(currentUserRoles, i => {
|
|
185099
185128
|
if (!lodashExports.find(userRoleAuthens, j => j.roleId === i)) {
|
|
@@ -185114,6 +185143,7 @@ const Edit = () => {
|
|
|
185114
185143
|
});
|
|
185115
185144
|
return userRolesInput;
|
|
185116
185145
|
};
|
|
185146
|
+
//onUpdateUser function to update user information
|
|
185117
185147
|
const onUpdateUser = async () => {
|
|
185118
185148
|
if (!services) return;
|
|
185119
185149
|
setLoadingUpdateUser(true);
|
|
@@ -185133,25 +185163,16 @@ const Edit = () => {
|
|
|
185133
185163
|
setLoadingUpdateUser(false);
|
|
185134
185164
|
});
|
|
185135
185165
|
};
|
|
185136
|
-
|
|
185137
|
-
if (
|
|
185138
|
-
|
|
185139
|
-
|
|
185140
|
-
|
|
185141
|
-
|
|
185142
|
-
|
|
185143
|
-
|
|
185144
|
-
var _a;
|
|
185145
|
-
return {
|
|
185146
|
-
id: i.id,
|
|
185147
|
-
roleId: i.roleId,
|
|
185148
|
-
roleName: (_a = i === null || i === void 0 ? void 0 : i.role) === null || _a === void 0 ? void 0 : _a.name
|
|
185149
|
-
};
|
|
185150
|
-
}));
|
|
185151
|
-
}).finally(() => {
|
|
185152
|
-
setLoadingUser(false);
|
|
185166
|
+
const handleUpdate = useCallback((fieldsToUpdate, _formValid, key) => {
|
|
185167
|
+
if (!fieldsToUpdate || !Object.keys(fieldsToUpdate).length) return;
|
|
185168
|
+
setUser(prev => {
|
|
185169
|
+
if (!prev) return prev;
|
|
185170
|
+
return Object.assign(Object.assign({}, prev), {
|
|
185171
|
+
[key]: key !== 'roleAuthens' ? fieldsToUpdate[key] : fieldsToUpdate[key].map(i => ({
|
|
185172
|
+
roleId: i
|
|
185173
|
+
}))
|
|
185153
185174
|
});
|
|
185154
|
-
}
|
|
185175
|
+
});
|
|
185155
185176
|
}, []);
|
|
185156
185177
|
return jsxRuntimeExports.jsx(DrawerWrapper$1, {
|
|
185157
185178
|
title: t('User.TitleEdit'),
|
|
@@ -185170,11 +185191,12 @@ const Edit = () => {
|
|
|
185170
185191
|
required: true,
|
|
185171
185192
|
length: 200
|
|
185172
185193
|
}, {
|
|
185173
|
-
fieldName: '
|
|
185174
|
-
|
|
185194
|
+
fieldName: 'roleAuthens',
|
|
185195
|
+
multiple: true,
|
|
185175
185196
|
type: FIELD_TYPE.AUTOCOMPLETE,
|
|
185176
185197
|
label: t('User.Roles'),
|
|
185177
|
-
options: roleTagOptions
|
|
185198
|
+
options: roleTagOptions,
|
|
185199
|
+
required: false
|
|
185178
185200
|
},
|
|
185179
185201
|
//Todo: API getUserById does not return groups, so we need to handle it later
|
|
185180
185202
|
{
|
|
@@ -185182,7 +185204,8 @@ const Edit = () => {
|
|
|
185182
185204
|
multiple: true,
|
|
185183
185205
|
type: FIELD_TYPE.AUTOCOMPLETE,
|
|
185184
185206
|
label: t('User.Groups'),
|
|
185185
|
-
options: groupsTagOptions
|
|
185207
|
+
options: groupsTagOptions,
|
|
185208
|
+
required: false
|
|
185186
185209
|
}, {
|
|
185187
185210
|
fieldName: 'description',
|
|
185188
185211
|
type: FIELD_TYPE.TEXT_AREA,
|
|
@@ -185191,19 +185214,15 @@ const Edit = () => {
|
|
|
185191
185214
|
}],
|
|
185192
185215
|
oldValue: user ? {
|
|
185193
185216
|
name: user.name,
|
|
185194
|
-
|
|
185217
|
+
roleAuthens: (_a = user === null || user === void 0 ? void 0 : user.roleAuthens) === null || _a === void 0 ? void 0 : _a.map(i => i.roleId),
|
|
185195
185218
|
description: user.description,
|
|
185196
185219
|
groups: user.groups
|
|
185197
185220
|
} : undefined,
|
|
185198
|
-
onUpdate: (obj, formValid) => {
|
|
185199
|
-
var _a, _b;
|
|
185221
|
+
onUpdate: (obj, formValid, key) => {
|
|
185200
185222
|
if (!lodashExports.isEmpty(obj)) {
|
|
185201
|
-
obj
|
|
185202
|
-
roles: (_a = obj.roles) === null || _a === void 0 ? void 0 : _a.filter(role => role !== undefined),
|
|
185203
|
-
groups: (_b = obj.groups) === null || _b === void 0 ? void 0 : _b.filter(group => group !== undefined)
|
|
185204
|
-
}));
|
|
185223
|
+
handleUpdate(obj, formValid, key);
|
|
185205
185224
|
setConfirmExit(true);
|
|
185206
|
-
setReadyForSubmit(formValid);
|
|
185225
|
+
if (obj.name !== (user === null || user === void 0 ? void 0 : user.name)) setReadyForSubmit(formValid);
|
|
185207
185226
|
}
|
|
185208
185227
|
}
|
|
185209
185228
|
})
|