oa-componentbook 1.0.1-stage.445 → 1.0.1-stage.446
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/components/oa-component-progress-bar/CustomProgressBar.js +8 -4
- package/build/components/oa-component-table-with-search-and-filter/TableWithSearchAndFilter.js +63 -59
- package/build/components/oa-component-textarea/CustomTextArea.js +95 -8
- package/build/components/oa-component-textarea/constants.js +39 -0
- package/build/components/oa-component-textarea/styles.js +12 -3
- package/build/layout/EntityOverviewLayout/EntityOverviewLayout.js +145 -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 +61 -8
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
18
|
* @param {number} totalStep - The total number of steps in the progress.
|
|
19
19
|
* @param {string} headingColor - The color used for the step text heading.
|
|
20
20
|
* @param {string} barColor - The color used for the progress bar.
|
|
21
|
+
* @param {boolean} showStepText - Whether to display the step text (Step X out of Y).
|
|
21
22
|
*
|
|
22
23
|
* @returns {React.ReactElement} A component displaying the current progress.
|
|
23
24
|
*/
|
|
@@ -26,9 +27,10 @@ function ProgressBar(_ref) {
|
|
|
26
27
|
currentStep,
|
|
27
28
|
totalStep,
|
|
28
29
|
headingColor,
|
|
29
|
-
barColor
|
|
30
|
+
barColor,
|
|
31
|
+
showStepText
|
|
30
32
|
} = _ref;
|
|
31
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
33
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, showStepText && /*#__PURE__*/_react.default.createElement("div", {
|
|
32
34
|
className: "margin-bottom-8"
|
|
33
35
|
}, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
34
36
|
color: headingColor,
|
|
@@ -57,12 +59,14 @@ ProgressBar.propTypes = {
|
|
|
57
59
|
currentStep: _propTypes.default.number,
|
|
58
60
|
totalStep: _propTypes.default.number,
|
|
59
61
|
headingColor: _propTypes.default.string,
|
|
60
|
-
barColor: _propTypes.default.string
|
|
62
|
+
barColor: _propTypes.default.string,
|
|
63
|
+
showStepText: _propTypes.default.bool
|
|
61
64
|
};
|
|
62
65
|
ProgressBar.defaultProps = {
|
|
63
66
|
currentStep: 1,
|
|
64
67
|
totalStep: 1,
|
|
65
68
|
headingColor: 'positive',
|
|
66
|
-
barColor: 'positive'
|
|
69
|
+
barColor: 'positive',
|
|
70
|
+
showStepText: true
|
|
67
71
|
};
|
|
68
72
|
var _default = exports.default = ProgressBar;
|
package/build/components/oa-component-table-with-search-and-filter/TableWithSearchAndFilter.js
CHANGED
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
});
|
|
9
9
|
exports.default = void 0;
|
|
10
10
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
11
|
+
require("core-js/modules/es.json.stringify.js");
|
|
11
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
13
|
var _Search = _interopRequireDefault(require("@material-ui/icons/Search"));
|
|
13
14
|
var _FilterList = _interopRequireDefault(require("@material-ui/icons/FilterList"));
|
|
@@ -115,7 +116,6 @@ function TableWithSearchAndFilter(_ref) {
|
|
|
115
116
|
// Filter drawer state
|
|
116
117
|
const [isFilterDrawerVisible, setIsFilterDrawerVisible] = (0, _react.useState)(false);
|
|
117
118
|
const [filterValues, setFilterValues] = (0, _react.useState)({});
|
|
118
|
-
const [areAllRequiredFieldsFilled, setAreAllRequiredFieldsFilled] = (0, _react.useState)(true);
|
|
119
119
|
|
|
120
120
|
// Search handlers
|
|
121
121
|
const handleSearchChange = e => {
|
|
@@ -133,47 +133,6 @@ function TableWithSearchAndFilter(_ref) {
|
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
-
// Memoized required keys calculation for better performance
|
|
137
|
-
const requiredKeys = (0, _react.useMemo)(() => {
|
|
138
|
-
const keys = [];
|
|
139
|
-
filterConfig.forEach(filter => {
|
|
140
|
-
const {
|
|
141
|
-
type,
|
|
142
|
-
key,
|
|
143
|
-
required,
|
|
144
|
-
fields = []
|
|
145
|
-
} = filter;
|
|
146
|
-
if (required) {
|
|
147
|
-
if (type === 'dateRange' || type === 'group') {
|
|
148
|
-
fields.forEach(field => {
|
|
149
|
-
keys.push(field.key);
|
|
150
|
-
});
|
|
151
|
-
} else {
|
|
152
|
-
keys.push(key);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
return keys;
|
|
157
|
-
}, [filterConfig]);
|
|
158
|
-
|
|
159
|
-
// Helper function to validate if all required fields are filled
|
|
160
|
-
const validateRequiredFields = (filters, keys) => {
|
|
161
|
-
if (keys.length === 0) return true;
|
|
162
|
-
return keys.every(requiredKey => {
|
|
163
|
-
const val = filters[requiredKey];
|
|
164
|
-
if (val === undefined || val === null || val === '') {
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
if (Array.isArray(val)) {
|
|
168
|
-
return val.length > 0;
|
|
169
|
-
}
|
|
170
|
-
if (typeof val === 'object' && !(val instanceof Date)) {
|
|
171
|
-
return Object.keys(val).length > 0;
|
|
172
|
-
}
|
|
173
|
-
return true;
|
|
174
|
-
});
|
|
175
|
-
};
|
|
176
|
-
|
|
177
136
|
// Filter handlers
|
|
178
137
|
const handleOpenFilterDrawer = () => setIsFilterDrawerVisible(true);
|
|
179
138
|
const handleCloseFilterDrawer = () => setIsFilterDrawerVisible(false);
|
|
@@ -184,15 +143,8 @@ function TableWithSearchAndFilter(_ref) {
|
|
|
184
143
|
const updatedFilters = _objectSpread(_objectSpread({}, filterValues), {}, {
|
|
185
144
|
[key]: normalizedValue
|
|
186
145
|
});
|
|
187
|
-
|
|
188
|
-
// Update filter values
|
|
189
146
|
setFilterValues(updatedFilters);
|
|
190
147
|
|
|
191
|
-
// Immediately update validation state to ensure button state is always correct
|
|
192
|
-
// This avoids React production optimization issues with dependency tracking
|
|
193
|
-
const isValid = validateRequiredFields(updatedFilters, requiredKeys);
|
|
194
|
-
setAreAllRequiredFieldsFilled(isValid);
|
|
195
|
-
|
|
196
148
|
// Call onChange callback if provided for real-time filter changes
|
|
197
149
|
if (onFilterChange) {
|
|
198
150
|
onFilterChange(key, normalizedValue, updatedFilters, action);
|
|
@@ -206,21 +158,73 @@ function TableWithSearchAndFilter(_ref) {
|
|
|
206
158
|
};
|
|
207
159
|
const handleClearFilters = () => {
|
|
208
160
|
setFilterValues({});
|
|
209
|
-
// Update validation state immediately
|
|
210
|
-
const isValid = validateRequiredFields({}, requiredKeys);
|
|
211
|
-
setAreAllRequiredFieldsFilled(isValid);
|
|
212
161
|
if (onFiltersClear) {
|
|
213
162
|
onFiltersClear();
|
|
214
163
|
}
|
|
215
164
|
};
|
|
216
165
|
|
|
217
|
-
//
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
166
|
+
// Memoized required keys calculation for better performance
|
|
167
|
+
const requiredKeys = (0, _react.useMemo)(() => {
|
|
168
|
+
const keys = [];
|
|
169
|
+
filterConfig.forEach(filter => {
|
|
170
|
+
const {
|
|
171
|
+
type,
|
|
172
|
+
key,
|
|
173
|
+
required,
|
|
174
|
+
fields = []
|
|
175
|
+
} = filter;
|
|
176
|
+
if (required) {
|
|
177
|
+
if (type === 'dateRange' || type === 'group') {
|
|
178
|
+
fields.forEach(field => {
|
|
179
|
+
keys.push(field.key);
|
|
180
|
+
});
|
|
181
|
+
} else {
|
|
182
|
+
keys.push(key);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
return keys;
|
|
187
|
+
}, [filterConfig]);
|
|
188
|
+
|
|
189
|
+
// Create a stable string representation of filterValues for required keys
|
|
190
|
+
// This ensures reliable dependency tracking in production builds
|
|
191
|
+
const requiredFieldsSignature = (0, _react.useMemo)(() => requiredKeys.map(key => {
|
|
192
|
+
const value = filterValues[key];
|
|
193
|
+
// Create a stable string representation that changes when value changes
|
|
194
|
+
if (value === undefined || value === null) return "".concat(key, ":null");
|
|
195
|
+
if (value instanceof Date) return "".concat(key, ":").concat(value.getTime());
|
|
196
|
+
return "".concat(key, ":").concat(JSON.stringify(value));
|
|
197
|
+
}).join('|'), [requiredKeys, filterValues]);
|
|
198
|
+
|
|
199
|
+
// Memoized check if all required fields are filled
|
|
200
|
+
const areAllRequiredFieldsFilled = (0, _react.useMemo)(() => {
|
|
201
|
+
// If no required fields, button should be enabled
|
|
202
|
+
if (requiredKeys.length === 0) {
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Check each required field has a valid value
|
|
207
|
+
return requiredKeys.every(requiredKey => {
|
|
208
|
+
const value = filterValues[requiredKey];
|
|
209
|
+
|
|
210
|
+
// Check if value exists and is not empty/null/undefined
|
|
211
|
+
// Also handle edge cases: empty arrays, empty objects, etc.
|
|
212
|
+
if (value === undefined || value === null || value === '') {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Handle arrays
|
|
217
|
+
if (Array.isArray(value)) {
|
|
218
|
+
return value.length > 0;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Handle objects (but allow Date objects and other valid objects)
|
|
222
|
+
if (typeof value === 'object' && !(value instanceof Date)) {
|
|
223
|
+
return Object.keys(value).length > 0;
|
|
224
|
+
}
|
|
225
|
+
return true;
|
|
226
|
+
});
|
|
227
|
+
}, [requiredKeys, requiredFieldsSignature, filterValues]);
|
|
224
228
|
|
|
225
229
|
// Helper function to determine notFoundContent message
|
|
226
230
|
const getNotFoundContent = (isApiCallInProgress, query) => {
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.object.assign.js");
|
|
4
|
+
require("core-js/modules/es.weak-map.js");
|
|
5
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
4
6
|
Object.defineProperty(exports, "__esModule", {
|
|
5
7
|
value: true
|
|
6
8
|
});
|
|
7
9
|
exports.default = void 0;
|
|
10
|
+
require("core-js/modules/es.string.trim.js");
|
|
8
11
|
var _react = _interopRequireDefault(require("react"));
|
|
9
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
13
|
var _antd = require("antd");
|
|
11
|
-
var
|
|
14
|
+
var _SendRounded = _interopRequireDefault(require("@material-ui/icons/SendRounded"));
|
|
15
|
+
var _styles = _interopRequireWildcard(require("./styles"));
|
|
12
16
|
var _ColorVariablesMap = _interopRequireDefault(require("../../global-css/ColorVariablesMap"));
|
|
13
|
-
|
|
17
|
+
var _MaterialIcon = _interopRequireDefault(require("../oa-component-icons/MaterialIcon"));
|
|
18
|
+
var _constants = require("./constants");
|
|
19
|
+
const _excluded = ["rows", "placeholder", "maxLength", "className", "variant"],
|
|
20
|
+
_excluded2 = ["minRows", "maxRows", "sendIconConfig", "onSend", "value", "onChange", "disabled"];
|
|
21
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
22
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
24
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
16
25
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
@@ -19,19 +28,25 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
19
28
|
* A custom text area component.
|
|
20
29
|
*
|
|
21
30
|
* The component includes the following properties:
|
|
22
|
-
* - `rows`: The number of rows for the text area.
|
|
31
|
+
* - `rows`: The number of rows for the text area (used for default variant).
|
|
23
32
|
* - `placeholder`: The placeholder text for the text area.
|
|
24
33
|
* - `maxLength`: The maximum length of the input value.
|
|
25
34
|
* - `className`: Additional CSS class to apply to the text area.
|
|
35
|
+
* - `variant`: 'default' or 'gradient' - determines the styling variant.
|
|
36
|
+
* - `minRows`: Initial line height for gradient variant (default: 1).
|
|
37
|
+
* - `maxRows`: Maximum rows before scrolling starts for gradient variant (default: null for unlimited).
|
|
38
|
+
* - `sendIconConfig`: Object with `show` (boolean, default: false) and `disabled` (boolean, default: false) for gradient variant only.
|
|
39
|
+
* - `onSend`: Callback function called when send icon is clicked (gradient variant only).
|
|
26
40
|
* - `antDesignProps`: Any other props to pass to the antd Input.TextArea component.
|
|
27
41
|
*
|
|
28
42
|
* The component will apply the following styles:
|
|
29
43
|
* - A dark grey background when the component is disabled.
|
|
30
44
|
* - A dark grey text color when the component is disabled.
|
|
31
45
|
* - A custom style class of `custom-textarea` to the outer element.
|
|
46
|
+
* - Gradient border and auto-growing height for gradient variant.
|
|
32
47
|
*
|
|
33
48
|
* The component will also apply the following props to the antd Input.TextArea component:
|
|
34
|
-
* - `rows`
|
|
49
|
+
* - `rows` (for default variant) or `minRows`/`maxRows` (for gradient variant)
|
|
35
50
|
* - `placeholder`
|
|
36
51
|
* - `maxLength`
|
|
37
52
|
* - `className` (appended to the outer element)
|
|
@@ -42,9 +57,79 @@ function CustomTextArea(_ref) {
|
|
|
42
57
|
rows,
|
|
43
58
|
placeholder,
|
|
44
59
|
maxLength,
|
|
45
|
-
className
|
|
60
|
+
className,
|
|
61
|
+
variant = 'default'
|
|
46
62
|
} = _ref,
|
|
47
63
|
antDesignProps = _objectWithoutProperties(_ref, _excluded);
|
|
64
|
+
// Render gradient variant
|
|
65
|
+
if (variant === 'gradient') {
|
|
66
|
+
// Extract gradient-specific props from antDesignProps
|
|
67
|
+
const _ref2 = antDesignProps || {},
|
|
68
|
+
{
|
|
69
|
+
minRows = _constants.DEFAULT_MIN_ROWS,
|
|
70
|
+
maxRows = _constants.DEFAULT_MAX_ROWS,
|
|
71
|
+
sendIconConfig = _constants.DEFAULT_SEND_ICON_CONFIG,
|
|
72
|
+
onSend,
|
|
73
|
+
value,
|
|
74
|
+
onChange,
|
|
75
|
+
disabled
|
|
76
|
+
} = _ref2,
|
|
77
|
+
restAntDesignProps = _objectWithoutProperties(_ref2, _excluded2);
|
|
78
|
+
|
|
79
|
+
// Handle send icon click - gradient variant only
|
|
80
|
+
// Use value prop directly - no internal state management
|
|
81
|
+
const handleSendClick = () => {
|
|
82
|
+
const currentValue = value || '';
|
|
83
|
+
// Only allow click if textarea is enabled, icon config is not disabled, and has content
|
|
84
|
+
if (onSend && !disabled && !sendIconConfig.disabled && currentValue.trim()) {
|
|
85
|
+
onSend(currentValue);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// Determine if send icon should be enabled - gradient variant only
|
|
90
|
+
// Icon is enabled if: textarea is enabled AND config says it's not disabled AND there's content
|
|
91
|
+
// Use value prop directly - no internal state
|
|
92
|
+
const currentValue = value || '';
|
|
93
|
+
const isSendEnabled = !disabled && !sendIconConfig.disabled && currentValue.trim().length > 0;
|
|
94
|
+
|
|
95
|
+
// Determine if icon should be shown - only for gradient variant
|
|
96
|
+
// Hidden by default, only show when explicitly requested via sendIconConfig.show
|
|
97
|
+
const shouldShowIcon = sendIconConfig.show;
|
|
98
|
+
return /*#__PURE__*/_react.default.createElement(_antd.ConfigProvider, {
|
|
99
|
+
theme: {
|
|
100
|
+
token: {
|
|
101
|
+
colorBgContainerDisabled: _ColorVariablesMap.default['--color-divider'],
|
|
102
|
+
colorTextDisabled: _ColorVariablesMap.default['--color-secondary-content']
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, /*#__PURE__*/_react.default.createElement(_styles.TextAreaWrapper, {
|
|
106
|
+
className: className,
|
|
107
|
+
$disabled: disabled
|
|
108
|
+
}, /*#__PURE__*/_react.default.createElement(_styles.default, _extends({
|
|
109
|
+
placeholder: placeholder,
|
|
110
|
+
maxLength: maxLength,
|
|
111
|
+
className: "custom-textarea-gradient",
|
|
112
|
+
value: value,
|
|
113
|
+
onChange: onChange,
|
|
114
|
+
disabled: disabled,
|
|
115
|
+
autoSize: maxRows ? {
|
|
116
|
+
minRows,
|
|
117
|
+
maxRows
|
|
118
|
+
} : {
|
|
119
|
+
minRows
|
|
120
|
+
}
|
|
121
|
+
}, restAntDesignProps)), shouldShowIcon && /*#__PURE__*/_react.default.createElement(_styles.SendIconWrapper, {
|
|
122
|
+
className: disabled || sendIconConfig.disabled || !isSendEnabled ? 'icon-disabled' : 'icon-enabled'
|
|
123
|
+
}, /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
|
|
124
|
+
icon: _SendRounded.default,
|
|
125
|
+
size: 24,
|
|
126
|
+
color: isSendEnabled ? 'primary' : 'placeholder-text',
|
|
127
|
+
onClick: handleSendClick
|
|
128
|
+
}))));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Render default variant (existing behavior - completely unchanged)
|
|
132
|
+
// All props including value, onChange pass through naturally via antDesignProps
|
|
48
133
|
return /*#__PURE__*/_react.default.createElement(_antd.ConfigProvider, {
|
|
49
134
|
theme: {
|
|
50
135
|
token: {
|
|
@@ -63,12 +148,14 @@ CustomTextArea.propTypes = {
|
|
|
63
148
|
rows: _propTypes.default.number,
|
|
64
149
|
placeholder: _propTypes.default.string,
|
|
65
150
|
maxLength: _propTypes.default.number,
|
|
66
|
-
className: _propTypes.default.string
|
|
151
|
+
className: _propTypes.default.string,
|
|
152
|
+
variant: _propTypes.default.oneOf(['default', 'gradient'])
|
|
67
153
|
};
|
|
68
154
|
CustomTextArea.defaultProps = {
|
|
69
|
-
rows:
|
|
155
|
+
rows: _constants.DEFAULT_ROWS,
|
|
70
156
|
placeholder: null,
|
|
71
157
|
maxLength: 5000,
|
|
72
|
-
className: ''
|
|
158
|
+
className: '',
|
|
159
|
+
variant: 'default'
|
|
73
160
|
};
|
|
74
161
|
var _default = exports.default = CustomTextArea;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TEXTAREA_SHADOW = exports.TEXTAREA_BORDER_RADIUS = exports.SEND_ICON_SIZE = exports.GRADIENT_BORDER_COLORS = exports.DEFAULT_SEND_ICON_CONFIG = exports.DEFAULT_ROWS = exports.DEFAULT_MIN_ROWS = exports.DEFAULT_MAX_ROWS = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Constants for CustomTextArea component
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Default values for textarea configuration
|
|
12
|
+
const DEFAULT_MIN_ROWS = exports.DEFAULT_MIN_ROWS = 1;
|
|
13
|
+
const DEFAULT_MAX_ROWS = exports.DEFAULT_MAX_ROWS = null; // null means unlimited growth
|
|
14
|
+
const DEFAULT_ROWS = exports.DEFAULT_ROWS = 2;
|
|
15
|
+
|
|
16
|
+
// Gradient border colors
|
|
17
|
+
const GRADIENT_BORDER_COLORS = exports.GRADIENT_BORDER_COLORS = {
|
|
18
|
+
top: '#0098FF',
|
|
19
|
+
// Blue
|
|
20
|
+
middle: '#9A6CFF',
|
|
21
|
+
// Purple
|
|
22
|
+
bottom: '#FB6252' // Coral/Orange-Red
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Shadow styles
|
|
26
|
+
const TEXTAREA_SHADOW = exports.TEXTAREA_SHADOW = '0px 2px 10px rgba(0, 0, 0, 0.14)';
|
|
27
|
+
|
|
28
|
+
// Border radius
|
|
29
|
+
const TEXTAREA_BORDER_RADIUS = exports.TEXTAREA_BORDER_RADIUS = '12px';
|
|
30
|
+
|
|
31
|
+
// Icon sizes
|
|
32
|
+
const SEND_ICON_SIZE = exports.SEND_ICON_SIZE = 24;
|
|
33
|
+
|
|
34
|
+
// Default send icon configuration
|
|
35
|
+
const DEFAULT_SEND_ICON_CONFIG = exports.DEFAULT_SEND_ICON_CONFIG = {
|
|
36
|
+
show: false,
|
|
37
|
+
// Hidden by default - only show when explicitly requested
|
|
38
|
+
disabled: false
|
|
39
|
+
};
|
|
@@ -3,14 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.TextAreaWrapper = exports.SendIconWrapper = void 0;
|
|
7
7
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
8
|
var _antd = require("antd");
|
|
9
|
-
var
|
|
9
|
+
var _constants = require("./constants");
|
|
10
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
10
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
12
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
12
13
|
const {
|
|
13
14
|
TextArea: AntdTextArea
|
|
14
15
|
} = _antd.Input;
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
// Default textarea styles (existing)
|
|
18
|
+
const StyledTextArea = (0, _styledComponents.default)(AntdTextArea)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &.custom-textarea {\n padding: 16px;\n resize: none;\n border-radius: 4px;\n max-height: 92px;\n border: 1px solid var(--color-placeholder-text);\n }\n &.custom-textarea:hover {\n border: 1px solid var(--color-primary);\n }\n &.custom-textarea:focus-within {\n box-shadow: 0px 0px 4px 0px rgba(1, 79, 197, 0.90);\n }\n\n /* Gradient variant styles */\n &.custom-textarea-gradient {\n padding: 16px 48px 16px 16px;\n resize: none;\n border-radius: calc(", " - 2px);\n border: none;\n background: var(--color-primary-background);\n font-size: 16px;\n line-height: 24px;\n color: var(--color-primary-content);\n min-height: auto !important;\n box-shadow: none;\n width: 100%;\n }\n\n &.custom-textarea-gradient::placeholder {\n color: var(--color-secondary-content);\n }\n\n &.custom-textarea-gradient:hover {\n box-shadow: none;\n }\n\n &.custom-textarea-gradient:focus {\n outline: none;\n box-shadow: none;\n }\n\n &.custom-textarea-gradient:focus-within {\n box-shadow: none;\n }\n"])), _constants.TEXTAREA_BORDER_RADIUS);
|
|
19
|
+
|
|
20
|
+
// Wrapper for gradient variant with gradient border
|
|
21
|
+
const TextAreaWrapper = exports.TextAreaWrapper = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n display: block;\n width: 100%;\n border-radius: ", ";\n padding: 2px;\n background: ", ";\n box-shadow: ", ";\n opacity: ", ";\n"])), _constants.TEXTAREA_BORDER_RADIUS, props => props.$disabled ? 'var(--color-divider)' : "linear-gradient(\n 135deg,\n ".concat(_constants.GRADIENT_BORDER_COLORS.top, " 0%,\n ").concat(_constants.GRADIENT_BORDER_COLORS.middle, " 50%,\n ").concat(_constants.GRADIENT_BORDER_COLORS.bottom, " 100%\n )"), props => props.$disabled ? 'none' : _constants.TEXTAREA_SHADOW, props => props.$disabled ? 0.6 : 1);
|
|
22
|
+
|
|
23
|
+
// Send icon wrapper positioned absolutely
|
|
24
|
+
const SendIconWrapper = exports.SendIconWrapper = _styledComponents.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: absolute;\n top: 18px;\n right: 18px;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10;\n pointer-events: none;\n\n button,\n svg {\n pointer-events: auto;\n }\n\n /* Icon disabled state */\n &.icon-disabled {\n opacity: 0.5;\n \n button,\n svg {\n cursor: not-allowed;\n }\n }\n\n /* Icon enabled state */\n &.icon-enabled {\n opacity: 1;\n \n button,\n svg {\n cursor: pointer;\n }\n }\n"])));
|
|
16
25
|
var _default = exports.default = StyledTextArea;
|
|
@@ -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,90 @@ function EntityOverviewLayout(_ref) {
|
|
|
121
122
|
placement: "bottomRight"
|
|
122
123
|
});
|
|
123
124
|
};
|
|
124
|
-
const handleCloseDrawer = () => {
|
|
125
|
-
|
|
125
|
+
const handleCloseDrawer = async () => {
|
|
126
|
+
var _state$misc2, _state$misc3, _state$misc4;
|
|
127
|
+
// Get selected enterprise from session storage to ensure profile data reflects correct enterprise
|
|
128
|
+
const selectedEnterpriseFromStorage = JSON.parse(sessionStorage.getItem('selectedEnterprise') || 'null');
|
|
129
|
+
const enterpriseIdFromStorage = (selectedEnterpriseFromStorage === null || selectedEnterpriseFromStorage === void 0 ? void 0 : selectedEnterpriseFromStorage.value) || (selectedEnterpriseFromStorage === null || selectedEnterpriseFromStorage === void 0 ? void 0 : selectedEnterpriseFromStorage.enterpriseId) || (selectedEnterpriseFromStorage === null || selectedEnterpriseFromStorage === void 0 ? void 0 : selectedEnterpriseFromStorage.id);
|
|
130
|
+
|
|
131
|
+
// Update misc with enterpriseId from session storage
|
|
132
|
+
const currentMisc = _objectSpread(_objectSpread({}, (_state$misc2 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc2 !== void 0 ? _state$misc2 : {}), {}, {
|
|
133
|
+
enterpriseId: enterpriseIdFromStorage || (state === null || state === void 0 || (_state$misc3 = state.misc) === null || _state$misc3 === void 0 ? void 0 : _state$misc3.enterpriseId),
|
|
134
|
+
enterpriseData: selectedEnterpriseFromStorage || (state === null || state === void 0 || (_state$misc4 = state.misc) === null || _state$misc4 === void 0 ? void 0 : _state$misc4.enterpriseData)
|
|
135
|
+
});
|
|
136
|
+
dispatch({
|
|
137
|
+
type: _entityOverviewLayoutReducer.actionTypes.SET_LOADING,
|
|
138
|
+
payload: true
|
|
139
|
+
});
|
|
140
|
+
if (getInitialData) {
|
|
141
|
+
const {
|
|
142
|
+
error,
|
|
143
|
+
data
|
|
144
|
+
} = await (getInitialData === null || getInitialData === void 0 ? void 0 : getInitialData(_objectSpread({}, currentMisc)));
|
|
145
|
+
if (error) {
|
|
146
|
+
showErrorNotification(error);
|
|
147
|
+
const dynamicConfig = (0, _staticConfigResolver.default)(config, {});
|
|
148
|
+
// Update misc with enterpriseId from session storage
|
|
149
|
+
if (currentMisc) {
|
|
150
|
+
dynamicConfig.misc = currentMisc;
|
|
151
|
+
}
|
|
152
|
+
// Don't preserve profile data - let it be re-rendered from config with correct enterprise
|
|
153
|
+
// Don't preserve accordion data - use fresh data from API (or empty if error)
|
|
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
|
+
// Update misc with enterpriseId from session storage
|
|
161
|
+
if (currentMisc) {
|
|
162
|
+
dynamicConfig.misc = currentMisc;
|
|
163
|
+
}
|
|
164
|
+
// Use fresh profile data from API response to reflect correct enterprise
|
|
165
|
+
if (data !== null && data !== void 0 && data.data) {
|
|
166
|
+
dispatch({
|
|
167
|
+
type: _entityOverviewLayoutReducer.actionTypes.UPDATE_PROFILE_DATA,
|
|
168
|
+
payload: data.data
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
// Use fresh accordion data from API response (includes newly added users)
|
|
172
|
+
// Check for both 'accordionData' and 'accordianData' (typo in API response)
|
|
173
|
+
const freshAccordionData = (data === null || data === void 0 ? void 0 : data.accordionData) || (data === null || data === void 0 ? void 0 : data.accordianData);
|
|
174
|
+
if (freshAccordionData) {
|
|
175
|
+
let accordionDataToUpdate;
|
|
176
|
+
if (Array.isArray(freshAccordionData)) {
|
|
177
|
+
accordionDataToUpdate = freshAccordionData;
|
|
178
|
+
} else if (freshAccordionData.data && Array.isArray(freshAccordionData.data)) {
|
|
179
|
+
accordionDataToUpdate = freshAccordionData.data;
|
|
180
|
+
} else {
|
|
181
|
+
accordionDataToUpdate = freshAccordionData;
|
|
182
|
+
}
|
|
183
|
+
// Update accordion data with fresh data from API
|
|
184
|
+
dispatch({
|
|
185
|
+
type: _entityOverviewLayoutReducer.actionTypes.UPDATE_ACCORDION_DATA,
|
|
186
|
+
payload: accordionDataToUpdate
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
dispatch({
|
|
190
|
+
type: _entityOverviewLayoutReducer.actionTypes.INIT,
|
|
191
|
+
payload: dynamicConfig
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
} else {
|
|
195
|
+
const dynamicConfig = (0, _staticConfigResolver.default)(config, {});
|
|
196
|
+
// Update misc with enterpriseId from session storage
|
|
197
|
+
if (currentMisc) {
|
|
198
|
+
dynamicConfig.misc = currentMisc;
|
|
199
|
+
}
|
|
200
|
+
dispatch({
|
|
201
|
+
type: _entityOverviewLayoutReducer.actionTypes.INIT,
|
|
202
|
+
payload: dynamicConfig
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
dispatch({
|
|
206
|
+
type: _entityOverviewLayoutReducer.actionTypes.SET_LOADING,
|
|
207
|
+
payload: false
|
|
208
|
+
});
|
|
126
209
|
dispatch({
|
|
127
210
|
type: _entityOverviewLayoutReducer.actionTypes.CLOSE_DRAWER
|
|
128
211
|
});
|
|
@@ -140,14 +223,70 @@ function EntityOverviewLayout(_ref) {
|
|
|
140
223
|
{
|
|
141
224
|
(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
225
|
}
|
|
226
|
+
// Always update 'selectedEnterprise' in sessionStorage to keep misc.enterpriseId in sync
|
|
227
|
+
if (selectedData) {
|
|
228
|
+
sessionStorage.setItem('selectedEnterprise', JSON.stringify(selectedData));
|
|
229
|
+
}
|
|
143
230
|
showSuccessNotification(config === null || config === void 0 ? void 0 : config.successMessage);
|
|
144
231
|
if (error) {
|
|
145
232
|
showErrorNotification(error);
|
|
146
233
|
} else {
|
|
234
|
+
// Update misc.enterpriseId to keep it in sync with selected enterprise
|
|
235
|
+
// Read from selectedData to match the sessionStorage structure
|
|
236
|
+
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;
|
|
237
|
+
if (enterpriseId) {
|
|
238
|
+
dispatch({
|
|
239
|
+
type: _entityOverviewLayoutReducer.actionTypes.SET_MISC,
|
|
240
|
+
payload: _objectSpread(_objectSpread({}, state === null || state === void 0 ? void 0 : state.misc), {}, {
|
|
241
|
+
enterpriseId: enterpriseId,
|
|
242
|
+
enterpriseData: selectedData // Also update enterpriseData to match sessionStorage
|
|
243
|
+
})
|
|
244
|
+
});
|
|
245
|
+
}
|
|
147
246
|
dispatch({
|
|
148
247
|
type: _entityOverviewLayoutReducer.actionTypes.UPDATE_PROFILE_DATA,
|
|
149
248
|
payload: selectedItem
|
|
150
249
|
});
|
|
250
|
+
// Update accordion data if provided in the response
|
|
251
|
+
// Note: API returns 'accordianData' (typo) but we check for both
|
|
252
|
+
const accordionDataFromResponse = (data === null || data === void 0 ? void 0 : data.accordionData) || (data === null || data === void 0 ? void 0 : data.accordianData);
|
|
253
|
+
|
|
254
|
+
// Check if accordionDataFromResponse is an object with data array, or if it's directly an array
|
|
255
|
+
if (accordionDataFromResponse) {
|
|
256
|
+
let accordionDataToUpdate;
|
|
257
|
+
if (Array.isArray(accordionDataFromResponse)) {
|
|
258
|
+
// If it's directly an array, use it as is
|
|
259
|
+
accordionDataToUpdate = accordionDataFromResponse;
|
|
260
|
+
} else if (accordionDataFromResponse.data && Array.isArray(accordionDataFromResponse.data)) {
|
|
261
|
+
// If it's an object with a data property containing the array, extract the data array
|
|
262
|
+
accordionDataToUpdate = accordionDataFromResponse.data;
|
|
263
|
+
}
|
|
264
|
+
if (accordionDataToUpdate) {
|
|
265
|
+
dispatch({
|
|
266
|
+
type: _entityOverviewLayoutReducer.actionTypes.UPDATE_ACCORDION_DATA,
|
|
267
|
+
payload: accordionDataToUpdate
|
|
268
|
+
});
|
|
269
|
+
} else {
|
|
270
|
+
console.log('Accordion data structure not recognized:', accordionDataFromResponse);
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
if (getInitialData && config !== null && config !== void 0 && config.refreshAccordionOnSwitch) {
|
|
274
|
+
var _state$misc5;
|
|
275
|
+
// Optionally refresh accordion data by calling getInitialData again
|
|
276
|
+
const {
|
|
277
|
+
error: refreshError,
|
|
278
|
+
data: refreshData
|
|
279
|
+
} = await (getInitialData === null || getInitialData === void 0 ? void 0 : getInitialData(_objectSpread(_objectSpread({}, (_state$misc5 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc5 !== void 0 ? _state$misc5 : {}), {}, {
|
|
280
|
+
selectedValue
|
|
281
|
+
})));
|
|
282
|
+
if (!refreshError && refreshData !== null && refreshData !== void 0 && refreshData.accordionData) {
|
|
283
|
+
dispatch({
|
|
284
|
+
type: _entityOverviewLayoutReducer.actionTypes.UPDATE_ACCORDION_DATA,
|
|
285
|
+
payload: refreshData.accordionData
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
151
290
|
}
|
|
152
291
|
}
|
|
153
292
|
};
|
|
@@ -255,7 +394,9 @@ function EntityOverviewLayout(_ref) {
|
|
|
255
394
|
customPageModal: modal,
|
|
256
395
|
addUserClick: addUserClick,
|
|
257
396
|
deleteUserClick: deleteUserClick,
|
|
258
|
-
editUserClick: editUserClick
|
|
397
|
+
editUserClick: editUserClick,
|
|
398
|
+
misc: misc,
|
|
399
|
+
drawer: drawer
|
|
259
400
|
}))))));
|
|
260
401
|
}
|
|
261
402
|
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,9 +5,12 @@ 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
|
+
require("core-js/modules/es.regexp.constructor.js");
|
|
12
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
13
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
11
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
15
|
var _antd = require("antd");
|
|
13
16
|
var _EditOutlined = _interopRequireDefault(require("@material-ui/icons/EditOutlined"));
|
|
@@ -28,7 +31,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
28
31
|
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
32
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
30
33
|
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
|
|
34
|
+
function _default(_ref) {
|
|
35
|
+
var _drawer$data, _activeDrawerData$mis;
|
|
32
36
|
let {
|
|
33
37
|
form,
|
|
34
38
|
fieldName = "users",
|
|
@@ -39,7 +43,8 @@ function UserManagementWidget(_ref) {
|
|
|
39
43
|
addUserClick,
|
|
40
44
|
deleteUserClick,
|
|
41
45
|
editUserClick,
|
|
42
|
-
misc
|
|
46
|
+
misc,
|
|
47
|
+
drawer
|
|
43
48
|
} = _ref;
|
|
44
49
|
const finalFields = fields || [];
|
|
45
50
|
const [editingUserId, setEditingUserId] = (0, _react.useState)(null);
|
|
@@ -88,6 +93,28 @@ function UserManagementWidget(_ref) {
|
|
|
88
93
|
[fieldName]: defaultUsers
|
|
89
94
|
});
|
|
90
95
|
}, [initialData, fieldName, form]);
|
|
96
|
+
|
|
97
|
+
// Reset form state when drawer closes or opens to ensure fresh context
|
|
98
|
+
(0, _react.useEffect)(() => {
|
|
99
|
+
if (drawer && drawer.visible === false) {
|
|
100
|
+
// Reset adding/editing state when drawer closes
|
|
101
|
+
setAddingUser(false);
|
|
102
|
+
setEditingUserId(null);
|
|
103
|
+
setDeleteModalVisible(false);
|
|
104
|
+
setUserToDelete(null);
|
|
105
|
+
|
|
106
|
+
// Clear form fields
|
|
107
|
+
const clearData = {};
|
|
108
|
+
finalFields.forEach(field => {
|
|
109
|
+
clearData["".concat(fieldName, "_").concat(field.key)] = "";
|
|
110
|
+
});
|
|
111
|
+
form.setFieldsValue(clearData);
|
|
112
|
+
}
|
|
113
|
+
}, [drawer === null || drawer === void 0 ? void 0 : drawer.visible, form, fieldName, finalFields]);
|
|
114
|
+
|
|
115
|
+
// Access branchId dynamically from drawer data using active drawer key
|
|
116
|
+
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];
|
|
117
|
+
const branchId = activeDrawerData === null || activeDrawerData === void 0 || (_activeDrawerData$mis = activeDrawerData.misc) === null || _activeDrawerData$mis === void 0 ? void 0 : _activeDrawerData$mis.branchId;
|
|
91
118
|
const handleEdit = user => {
|
|
92
119
|
setEditingUserId(user.id);
|
|
93
120
|
setAddingUser(false);
|
|
@@ -127,7 +154,7 @@ function UserManagementWidget(_ref) {
|
|
|
127
154
|
const {
|
|
128
155
|
error,
|
|
129
156
|
data
|
|
130
|
-
} = await editUserClick(editingUserId, userData);
|
|
157
|
+
} = await editUserClick(editingUserId, userData, misc);
|
|
131
158
|
if (error) {
|
|
132
159
|
showErrorNotification(error);
|
|
133
160
|
} else {
|
|
@@ -146,10 +173,13 @@ function UserManagementWidget(_ref) {
|
|
|
146
173
|
} else if (addingUser) {
|
|
147
174
|
// Add new user
|
|
148
175
|
if (addUserClick) {
|
|
176
|
+
console.log("userData", userData);
|
|
177
|
+
console.log("misc", misc);
|
|
178
|
+
console.log("branchId", branchId);
|
|
149
179
|
const {
|
|
150
180
|
error,
|
|
151
181
|
data
|
|
152
|
-
} = await addUserClick(userData, misc);
|
|
182
|
+
} = await addUserClick(userData, misc, branchId);
|
|
153
183
|
if (error) {
|
|
154
184
|
showErrorNotification(error);
|
|
155
185
|
} else {
|
|
@@ -215,15 +245,38 @@ function UserManagementWidget(_ref) {
|
|
|
215
245
|
};
|
|
216
246
|
const canDelete = users.length > 1;
|
|
217
247
|
const isEditing = editingUserId !== null || addingUser;
|
|
248
|
+
|
|
249
|
+
// Process rules to handle checkValidator structure (similar to FormWidget)
|
|
250
|
+
const processRules = rules => {
|
|
251
|
+
if (!rules || !Array.isArray(rules)) {
|
|
252
|
+
return rules;
|
|
253
|
+
}
|
|
254
|
+
return rules.map(r => {
|
|
255
|
+
// If rule has checkValidator, extract the nested rule object
|
|
256
|
+
if (r !== null && r !== void 0 && r.checkValidator && r !== null && r !== void 0 && r.rule) {
|
|
257
|
+
let processedRule = _objectSpread({}, r.rule);
|
|
258
|
+
|
|
259
|
+
// Handle pattern conversion if it's a string
|
|
260
|
+
if (processedRule.pattern && typeof processedRule.pattern === "string") {
|
|
261
|
+
processedRule.pattern = new RegExp(processedRule.pattern);
|
|
262
|
+
}
|
|
263
|
+
return processedRule;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Return rule as-is if it doesn't have checkValidator structure
|
|
267
|
+
return r;
|
|
268
|
+
});
|
|
269
|
+
};
|
|
218
270
|
const renderFormField = field => {
|
|
219
271
|
var _field$options;
|
|
220
272
|
const fieldNameWithPrefix = "".concat(fieldName, "_").concat(field.key);
|
|
273
|
+
const processedRules = processRules(field.rules);
|
|
221
274
|
switch (field.widget || field.type) {
|
|
222
275
|
case "input":
|
|
223
276
|
return /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
224
277
|
name: fieldNameWithPrefix,
|
|
225
278
|
label: field.label,
|
|
226
|
-
rules:
|
|
279
|
+
rules: processedRules,
|
|
227
280
|
style: {
|
|
228
281
|
marginBottom: 16
|
|
229
282
|
}
|
|
@@ -234,7 +287,7 @@ function UserManagementWidget(_ref) {
|
|
|
234
287
|
return /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
235
288
|
name: fieldNameWithPrefix,
|
|
236
289
|
label: field.label,
|
|
237
|
-
rules:
|
|
290
|
+
rules: processedRules,
|
|
238
291
|
style: {
|
|
239
292
|
marginBottom: 16
|
|
240
293
|
}
|
|
@@ -249,7 +302,7 @@ function UserManagementWidget(_ref) {
|
|
|
249
302
|
return /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
250
303
|
name: fieldNameWithPrefix,
|
|
251
304
|
label: field.label,
|
|
252
|
-
rules:
|
|
305
|
+
rules: processedRules,
|
|
253
306
|
style: {
|
|
254
307
|
marginBottom: 16
|
|
255
308
|
}
|