oa-componentbook 1.0.1-stage.434 → 1.0.1-stage.435
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/build/layout/EntityOverviewLayout/EntityOverviewLayout.js +135 -4
- package/build/layout/EntityOverviewLayout/reducer/entityOverviewLayoutReducer.js +18 -1
- package/build/widgets/oa-form-widget/FormWidget.js +2 -1
- package/build/widgets/oa-widget-user-management/UserManagementWidget.js +29 -5
- package/package.json +1 -1
|
@@ -58,7 +58,8 @@ function EntityOverviewLayout(_ref) {
|
|
|
58
58
|
profileData,
|
|
59
59
|
accordionData,
|
|
60
60
|
drawer,
|
|
61
|
-
modal
|
|
61
|
+
modal,
|
|
62
|
+
misc
|
|
62
63
|
} = state !== null && state !== void 0 ? state : {};
|
|
63
64
|
(0, _react.useEffect)(() => {
|
|
64
65
|
init();
|
|
@@ -121,8 +122,77 @@ function EntityOverviewLayout(_ref) {
|
|
|
121
122
|
placement: "bottomRight"
|
|
122
123
|
});
|
|
123
124
|
};
|
|
124
|
-
const handleCloseDrawer = () => {
|
|
125
|
-
|
|
125
|
+
const handleCloseDrawer = async () => {
|
|
126
|
+
// Preserve current profile data and accordion data when closing drawer
|
|
127
|
+
// to maintain selected enterprise and prevent data mismatch
|
|
128
|
+
const currentProfileData = state === null || state === void 0 ? void 0 : state.profileData;
|
|
129
|
+
const currentAccordionData = state === null || state === void 0 ? void 0 : state.accordionData;
|
|
130
|
+
const currentMisc = state === null || state === void 0 ? void 0 : state.misc; // Preserve misc to maintain enterpriseId
|
|
131
|
+
|
|
132
|
+
dispatch({
|
|
133
|
+
type: _entityOverviewLayoutReducer.actionTypes.SET_LOADING,
|
|
134
|
+
payload: true
|
|
135
|
+
});
|
|
136
|
+
if (getInitialData) {
|
|
137
|
+
const {
|
|
138
|
+
error,
|
|
139
|
+
data
|
|
140
|
+
} = await (getInitialData === null || getInitialData === void 0 ? void 0 : getInitialData(_objectSpread({}, currentMisc !== null && currentMisc !== void 0 ? currentMisc : {})));
|
|
141
|
+
if (error) {
|
|
142
|
+
showErrorNotification(error);
|
|
143
|
+
const dynamicConfig = (0, _staticConfigResolver.default)(config, {});
|
|
144
|
+
// Preserve profile data, accordion data, and misc to maintain sync
|
|
145
|
+
if (currentProfileData) {
|
|
146
|
+
dynamicConfig.profileData = currentProfileData;
|
|
147
|
+
}
|
|
148
|
+
if (currentAccordionData) {
|
|
149
|
+
dynamicConfig.accordionData = currentAccordionData;
|
|
150
|
+
}
|
|
151
|
+
if (currentMisc) {
|
|
152
|
+
dynamicConfig.misc = currentMisc; // Preserve misc with correct enterpriseId
|
|
153
|
+
}
|
|
154
|
+
dispatch({
|
|
155
|
+
type: _entityOverviewLayoutReducer.actionTypes.INIT,
|
|
156
|
+
payload: dynamicConfig
|
|
157
|
+
});
|
|
158
|
+
} else {
|
|
159
|
+
const dynamicConfig = (0, _staticConfigResolver.default)(config, data !== null && data !== void 0 ? data : {});
|
|
160
|
+
// Preserve profile data, accordion data, and misc to maintain sync
|
|
161
|
+
if (currentProfileData) {
|
|
162
|
+
dynamicConfig.profileData = currentProfileData;
|
|
163
|
+
}
|
|
164
|
+
if (currentAccordionData) {
|
|
165
|
+
dynamicConfig.accordionData = currentAccordionData;
|
|
166
|
+
}
|
|
167
|
+
if (currentMisc) {
|
|
168
|
+
dynamicConfig.misc = currentMisc; // Preserve misc with correct enterpriseId
|
|
169
|
+
}
|
|
170
|
+
dispatch({
|
|
171
|
+
type: _entityOverviewLayoutReducer.actionTypes.INIT,
|
|
172
|
+
payload: dynamicConfig
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
const dynamicConfig = (0, _staticConfigResolver.default)(config, {});
|
|
177
|
+
// Preserve profile data, accordion data, and misc to maintain sync
|
|
178
|
+
if (currentProfileData) {
|
|
179
|
+
dynamicConfig.profileData = currentProfileData;
|
|
180
|
+
}
|
|
181
|
+
if (currentAccordionData) {
|
|
182
|
+
dynamicConfig.accordionData = currentAccordionData;
|
|
183
|
+
}
|
|
184
|
+
if (currentMisc) {
|
|
185
|
+
dynamicConfig.misc = currentMisc; // Preserve misc with correct enterpriseId
|
|
186
|
+
}
|
|
187
|
+
dispatch({
|
|
188
|
+
type: _entityOverviewLayoutReducer.actionTypes.INIT,
|
|
189
|
+
payload: dynamicConfig
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
dispatch({
|
|
193
|
+
type: _entityOverviewLayoutReducer.actionTypes.SET_LOADING,
|
|
194
|
+
payload: false
|
|
195
|
+
});
|
|
126
196
|
dispatch({
|
|
127
197
|
type: _entityOverviewLayoutReducer.actionTypes.CLOSE_DRAWER
|
|
128
198
|
});
|
|
@@ -140,14 +210,73 @@ function EntityOverviewLayout(_ref) {
|
|
|
140
210
|
{
|
|
141
211
|
(config === null || config === void 0 ? void 0 : config.storageType) == "sessionStorage" && (config === null || config === void 0 ? void 0 : config.storageKey) && sessionStorage.setItem(config === null || config === void 0 ? void 0 : config.storageKey, JSON.stringify(selectedData));
|
|
142
212
|
}
|
|
213
|
+
// Always update 'selectedEnterprise' in sessionStorage to keep misc.enterpriseId in sync
|
|
214
|
+
if (selectedData) {
|
|
215
|
+
sessionStorage.setItem('selectedEnterprise', JSON.stringify(selectedData));
|
|
216
|
+
}
|
|
143
217
|
showSuccessNotification(config === null || config === void 0 ? void 0 : config.successMessage);
|
|
144
218
|
if (error) {
|
|
145
219
|
showErrorNotification(error);
|
|
146
220
|
} else {
|
|
221
|
+
// Update misc.enterpriseId to keep it in sync with selected enterprise
|
|
222
|
+
// Read from selectedData to match the sessionStorage structure
|
|
223
|
+
const enterpriseId = (selectedData === null || selectedData === void 0 ? void 0 : selectedData.value) || (selectedData === null || selectedData === void 0 ? void 0 : selectedData.enterpriseId) || (selectedData === null || selectedData === void 0 ? void 0 : selectedData.id) || selectedValue;
|
|
224
|
+
if (enterpriseId) {
|
|
225
|
+
dispatch({
|
|
226
|
+
type: _entityOverviewLayoutReducer.actionTypes.SET_MISC,
|
|
227
|
+
payload: _objectSpread(_objectSpread({}, state === null || state === void 0 ? void 0 : state.misc), {}, {
|
|
228
|
+
enterpriseId: enterpriseId,
|
|
229
|
+
enterpriseData: selectedData // Also update enterpriseData to match sessionStorage
|
|
230
|
+
})
|
|
231
|
+
});
|
|
232
|
+
}
|
|
147
233
|
dispatch({
|
|
148
234
|
type: _entityOverviewLayoutReducer.actionTypes.UPDATE_PROFILE_DATA,
|
|
149
235
|
payload: selectedItem
|
|
150
236
|
});
|
|
237
|
+
// Update accordion data if provided in the response
|
|
238
|
+
// Note: API returns 'accordianData' (typo) but we check for both
|
|
239
|
+
const accordionDataFromResponse = (data === null || data === void 0 ? void 0 : data.accordionData) || (data === null || data === void 0 ? void 0 : data.accordianData);
|
|
240
|
+
console.log('Checking accordion data from response:', accordionDataFromResponse);
|
|
241
|
+
|
|
242
|
+
// Check if accordionDataFromResponse is an object with data array, or if it's directly an array
|
|
243
|
+
if (accordionDataFromResponse) {
|
|
244
|
+
let accordionDataToUpdate;
|
|
245
|
+
if (Array.isArray(accordionDataFromResponse)) {
|
|
246
|
+
// If it's directly an array, use it as is
|
|
247
|
+
accordionDataToUpdate = accordionDataFromResponse;
|
|
248
|
+
} else if (accordionDataFromResponse.data && Array.isArray(accordionDataFromResponse.data)) {
|
|
249
|
+
// If it's an object with a data property containing the array, extract the data array
|
|
250
|
+
accordionDataToUpdate = accordionDataFromResponse.data;
|
|
251
|
+
}
|
|
252
|
+
if (accordionDataToUpdate) {
|
|
253
|
+
console.log('Dispatching UPDATE_ACCORDION_DATA with:', accordionDataToUpdate);
|
|
254
|
+
dispatch({
|
|
255
|
+
type: _entityOverviewLayoutReducer.actionTypes.UPDATE_ACCORDION_DATA,
|
|
256
|
+
payload: accordionDataToUpdate
|
|
257
|
+
});
|
|
258
|
+
} else {
|
|
259
|
+
console.log('Accordion data structure not recognized:', accordionDataFromResponse);
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
console.log('Accordion data not found. Checking refresh option...');
|
|
263
|
+
if (getInitialData && config !== null && config !== void 0 && config.refreshAccordionOnSwitch) {
|
|
264
|
+
var _state$misc2;
|
|
265
|
+
// Optionally refresh accordion data by calling getInitialData again
|
|
266
|
+
const {
|
|
267
|
+
error: refreshError,
|
|
268
|
+
data: refreshData
|
|
269
|
+
} = await (getInitialData === null || getInitialData === void 0 ? void 0 : getInitialData(_objectSpread(_objectSpread({}, (_state$misc2 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc2 !== void 0 ? _state$misc2 : {}), {}, {
|
|
270
|
+
selectedValue
|
|
271
|
+
})));
|
|
272
|
+
if (!refreshError && refreshData !== null && refreshData !== void 0 && refreshData.accordionData) {
|
|
273
|
+
dispatch({
|
|
274
|
+
type: _entityOverviewLayoutReducer.actionTypes.UPDATE_ACCORDION_DATA,
|
|
275
|
+
payload: refreshData.accordionData
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
151
280
|
}
|
|
152
281
|
}
|
|
153
282
|
};
|
|
@@ -255,7 +384,9 @@ function EntityOverviewLayout(_ref) {
|
|
|
255
384
|
customPageModal: modal,
|
|
256
385
|
addUserClick: addUserClick,
|
|
257
386
|
deleteUserClick: deleteUserClick,
|
|
258
|
-
editUserClick: editUserClick
|
|
387
|
+
editUserClick: editUserClick,
|
|
388
|
+
misc: misc,
|
|
389
|
+
drawer: drawer
|
|
259
390
|
}))))));
|
|
260
391
|
}
|
|
261
392
|
EntityOverviewLayout.propTypes = {};
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.initialState = exports.entityOverviewLayoutReducer = exports.actionTypes = void 0;
|
|
7
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
7
8
|
require("core-js/modules/es.symbol.description.js");
|
|
8
9
|
var _staticConfigResolver = require("../../GenricLayOut/resolver/staticConfigResolver");
|
|
9
10
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -19,7 +20,8 @@ const actionTypes = exports.actionTypes = {
|
|
|
19
20
|
SET_DRAWER: 'SET_DRAWER',
|
|
20
21
|
TOGGLE_DRAWER: 'TOGGLE_DRAWER',
|
|
21
22
|
CLOSE_DRAWER: 'CLOSE_DRAWER',
|
|
22
|
-
UPDATE_PROFILE_DATA: 'UPDATE_PROFILE_DATA'
|
|
23
|
+
UPDATE_PROFILE_DATA: 'UPDATE_PROFILE_DATA',
|
|
24
|
+
UPDATE_ACCORDION_DATA: 'UPDATE_ACCORDION_DATA'
|
|
23
25
|
};
|
|
24
26
|
const initialState = exports.initialState = {};
|
|
25
27
|
const entityOverviewLayoutReducer = (state, action) => {
|
|
@@ -38,6 +40,21 @@ const entityOverviewLayoutReducer = (state, action) => {
|
|
|
38
40
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
39
41
|
profileData: action.payload
|
|
40
42
|
});
|
|
43
|
+
case actionTypes.UPDATE_ACCORDION_DATA:
|
|
44
|
+
{
|
|
45
|
+
var _state$accordionData$, _state$accordionData;
|
|
46
|
+
console.log('Reducer: Updating accordion data with payload:', action.payload);
|
|
47
|
+
const newAccordionData = _objectSpread(_objectSpread({}, (state === null || state === void 0 ? void 0 : state.accordionData) || {}), {}, {
|
|
48
|
+
// Preserve all existing accordionData properties
|
|
49
|
+
visible: (_state$accordionData$ = state === null || state === void 0 || (_state$accordionData = state.accordionData) === null || _state$accordionData === void 0 ? void 0 : _state$accordionData.visible) !== null && _state$accordionData$ !== void 0 ? _state$accordionData$ : true,
|
|
50
|
+
// Preserve visible property, default to true
|
|
51
|
+
data: Array.isArray(action.payload) ? [...action.payload] : action.payload // Ensure new array reference
|
|
52
|
+
});
|
|
53
|
+
console.log('Reducer: New accordion data:', newAccordionData);
|
|
54
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
55
|
+
accordionData: newAccordionData
|
|
56
|
+
});
|
|
57
|
+
}
|
|
41
58
|
case actionTypes.SET_MISC:
|
|
42
59
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
43
60
|
misc: _objectSpread(_objectSpread({}, state.misc), action.payload)
|
|
@@ -452,7 +452,8 @@ function FormWidget(props) {
|
|
|
452
452
|
initialData: (item === null || item === void 0 ? void 0 : item.value) || [],
|
|
453
453
|
fields: item === null || item === void 0 ? void 0 : item.fields,
|
|
454
454
|
disabled: (item === null || item === void 0 ? void 0 : item.disabled) || false,
|
|
455
|
-
customPageModal: props === null || props === void 0 ? void 0 : props.customPageModal
|
|
455
|
+
customPageModal: props === null || props === void 0 ? void 0 : props.customPageModal,
|
|
456
|
+
misc: props === null || props === void 0 ? void 0 : props.misc
|
|
456
457
|
}, props)));
|
|
457
458
|
case "field":
|
|
458
459
|
return renderFieldWidget(item);
|
|
@@ -5,7 +5,7 @@ require("core-js/modules/es.weak-map.js");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default =
|
|
8
|
+
exports.default = _default;
|
|
9
9
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
10
10
|
require("core-js/modules/es.promise.js");
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -28,7 +28,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
28
28
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
29
29
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
30
30
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* eslint-disable */
|
|
31
|
-
function
|
|
31
|
+
function _default(_ref) {
|
|
32
|
+
var _drawer$data, _activeDrawerData$mis;
|
|
32
33
|
let {
|
|
33
34
|
form,
|
|
34
35
|
fieldName = "users",
|
|
@@ -39,7 +40,8 @@ function UserManagementWidget(_ref) {
|
|
|
39
40
|
addUserClick,
|
|
40
41
|
deleteUserClick,
|
|
41
42
|
editUserClick,
|
|
42
|
-
misc
|
|
43
|
+
misc,
|
|
44
|
+
drawer
|
|
43
45
|
} = _ref;
|
|
44
46
|
const finalFields = fields || [];
|
|
45
47
|
const [editingUserId, setEditingUserId] = (0, _react.useState)(null);
|
|
@@ -88,6 +90,28 @@ function UserManagementWidget(_ref) {
|
|
|
88
90
|
[fieldName]: defaultUsers
|
|
89
91
|
});
|
|
90
92
|
}, [initialData, fieldName, form]);
|
|
93
|
+
|
|
94
|
+
// Reset form state when drawer closes or opens to ensure fresh context
|
|
95
|
+
(0, _react.useEffect)(() => {
|
|
96
|
+
if (drawer && drawer.visible === false) {
|
|
97
|
+
// Reset adding/editing state when drawer closes
|
|
98
|
+
setAddingUser(false);
|
|
99
|
+
setEditingUserId(null);
|
|
100
|
+
setDeleteModalVisible(false);
|
|
101
|
+
setUserToDelete(null);
|
|
102
|
+
|
|
103
|
+
// Clear form fields
|
|
104
|
+
const clearData = {};
|
|
105
|
+
finalFields.forEach(field => {
|
|
106
|
+
clearData["".concat(fieldName, "_").concat(field.key)] = "";
|
|
107
|
+
});
|
|
108
|
+
form.setFieldsValue(clearData);
|
|
109
|
+
}
|
|
110
|
+
}, [drawer === null || drawer === void 0 ? void 0 : drawer.visible, form, fieldName, finalFields]);
|
|
111
|
+
|
|
112
|
+
// Access branchId dynamically from drawer data using active drawer key
|
|
113
|
+
const activeDrawerData = drawer === null || drawer === void 0 || (_drawer$data = drawer.data) === null || _drawer$data === void 0 ? void 0 : _drawer$data[drawer === null || drawer === void 0 ? void 0 : drawer.active];
|
|
114
|
+
const branchId = activeDrawerData === null || activeDrawerData === void 0 || (_activeDrawerData$mis = activeDrawerData.misc) === null || _activeDrawerData$mis === void 0 ? void 0 : _activeDrawerData$mis.branchId;
|
|
91
115
|
const handleEdit = user => {
|
|
92
116
|
setEditingUserId(user.id);
|
|
93
117
|
setAddingUser(false);
|
|
@@ -127,7 +151,7 @@ function UserManagementWidget(_ref) {
|
|
|
127
151
|
const {
|
|
128
152
|
error,
|
|
129
153
|
data
|
|
130
|
-
} = await editUserClick(editingUserId, userData);
|
|
154
|
+
} = await editUserClick(editingUserId, userData, misc);
|
|
131
155
|
if (error) {
|
|
132
156
|
showErrorNotification(error);
|
|
133
157
|
} else {
|
|
@@ -149,7 +173,7 @@ function UserManagementWidget(_ref) {
|
|
|
149
173
|
const {
|
|
150
174
|
error,
|
|
151
175
|
data
|
|
152
|
-
} = await addUserClick(userData, misc);
|
|
176
|
+
} = await addUserClick(userData, misc, branchId);
|
|
153
177
|
if (error) {
|
|
154
178
|
showErrorNotification(error);
|
|
155
179
|
} else {
|