dynamic-mui 1.0.71 → 1.0.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/build/asset-manifest.json +3 -3
- package/build/index.html +1 -1
- package/build/static/js/{main.c9bfd94c.js → main.9e08a04c.js} +3 -3
- package/build/static/js/{main.c9bfd94c.js.map → main.9e08a04c.js.map} +1 -1
- package/dist-modules/components/controls/Stepper/stepper.js +71 -105
- package/dist-modules/data/stepper.js +59 -118
- package/dist-modules/util/helper.js +46 -13
- package/docs/asset-manifest.json +2 -2
- package/docs/build/bundle.5a4707c5.js +184 -0
- package/docs/index.html +1 -1
- package/package.json +1 -1
- package/docs/build/bundle.8cf75d73.js +0 -184
- /package/build/static/js/{main.c9bfd94c.js.LICENSE.txt → main.9e08a04c.js.LICENSE.txt} +0 -0
- /package/docs/build/{bundle.8cf75d73.js.LICENSE.txt → bundle.5a4707c5.js.LICENSE.txt} +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _material = require("@mui/material");
|
|
@@ -13,43 +13,43 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
13
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
14
|
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 && {}.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; }
|
|
15
15
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } // eslint-disable-next-line import/no-cycle
|
|
16
|
+
// Initial State
|
|
16
17
|
const initialState = {
|
|
17
18
|
activeStep: 0,
|
|
18
19
|
stepperResponse: {},
|
|
19
20
|
MuiSteps: []
|
|
20
21
|
};
|
|
21
|
-
const response = {}; // Reintegrated response object
|
|
22
22
|
|
|
23
|
+
// Reducer Logic
|
|
23
24
|
const reducer = (state, action) => {
|
|
24
|
-
|
|
25
|
+
const {
|
|
26
|
+
type,
|
|
27
|
+
payload
|
|
28
|
+
} = action;
|
|
29
|
+
switch (type) {
|
|
25
30
|
case 'SET_STEPS':
|
|
26
31
|
return {
|
|
27
32
|
...state,
|
|
28
|
-
MuiSteps:
|
|
33
|
+
MuiSteps: payload.MuiSteps
|
|
29
34
|
};
|
|
30
35
|
case 'SET_STEP':
|
|
31
36
|
return {
|
|
32
37
|
...state,
|
|
33
|
-
activeStep:
|
|
34
|
-
};
|
|
35
|
-
case 'NEXT_STEP':
|
|
36
|
-
return {
|
|
37
|
-
...state,
|
|
38
|
-
activeStep: state.activeStep + 1
|
|
39
|
-
};
|
|
40
|
-
case 'PREVIOUS_STEP':
|
|
41
|
-
return {
|
|
42
|
-
...state,
|
|
43
|
-
activeStep: state.activeStep - 1
|
|
38
|
+
activeStep: payload.currentStep
|
|
44
39
|
};
|
|
45
40
|
case 'UPDATE_RESPONSE':
|
|
46
41
|
return {
|
|
47
42
|
...state,
|
|
48
43
|
stepperResponse: {
|
|
49
44
|
...state.stepperResponse,
|
|
50
|
-
[
|
|
45
|
+
[payload.id]: payload.value
|
|
51
46
|
}
|
|
52
47
|
};
|
|
48
|
+
case 'CHANGE_STEP':
|
|
49
|
+
return {
|
|
50
|
+
...state,
|
|
51
|
+
activeStep: state.activeStep + payload.stepChange
|
|
52
|
+
};
|
|
53
53
|
default:
|
|
54
54
|
return state;
|
|
55
55
|
}
|
|
@@ -62,37 +62,33 @@ function Stepper(_ref) {
|
|
|
62
62
|
currentStep,
|
|
63
63
|
patch
|
|
64
64
|
} = _ref;
|
|
65
|
-
const [state, dispatch] = (0, _react.useReducer)(reducer, initialState,
|
|
66
|
-
...init,
|
|
65
|
+
const [state, dispatch] = (0, _react.useReducer)(reducer, initialState, () => ({
|
|
67
66
|
activeStep: currentStep,
|
|
68
67
|
stepperResponse: patch,
|
|
69
|
-
MuiSteps:
|
|
68
|
+
MuiSteps: attributes.MuiSteps || []
|
|
70
69
|
}));
|
|
71
70
|
const {
|
|
72
71
|
activeStep,
|
|
73
72
|
stepperResponse,
|
|
74
73
|
MuiSteps
|
|
75
74
|
} = state;
|
|
76
|
-
(0, _react.useEffect)(() => {
|
|
77
|
-
response[attributes.id] = patch; // Update response on patch change
|
|
78
|
-
return () => {
|
|
79
|
-
response[attributes.id] = {}; // Cleanup response on component unmount
|
|
80
|
-
// eslint-disable-next-line no-console
|
|
81
|
-
// console.log('Component unmounted');
|
|
82
|
-
};
|
|
83
|
-
}, [patch, attributes.id]);
|
|
84
75
|
(0, _react.useEffect)(() => {
|
|
85
76
|
dispatch({
|
|
86
77
|
type: 'SET_STEP',
|
|
87
|
-
|
|
78
|
+
payload: {
|
|
79
|
+
currentStep
|
|
80
|
+
}
|
|
88
81
|
});
|
|
89
82
|
}, [currentStep]);
|
|
90
83
|
const handleStepChange = (0, _react.useCallback)((stepChange, isScreenChange, isLastStep) => {
|
|
91
84
|
dispatch({
|
|
92
|
-
type:
|
|
85
|
+
type: 'CHANGE_STEP',
|
|
86
|
+
payload: {
|
|
87
|
+
stepChange
|
|
88
|
+
}
|
|
93
89
|
});
|
|
94
|
-
const newStep = activeStep +
|
|
95
|
-
onStepUpdate?.(newStep, isScreenChange && stepChange
|
|
90
|
+
const newStep = activeStep + stepChange;
|
|
91
|
+
onStepUpdate?.(newStep, isScreenChange && stepChange > 0, isLastStep);
|
|
96
92
|
if (isLastStep) {
|
|
97
93
|
onChange?.({
|
|
98
94
|
id: attributes.id,
|
|
@@ -105,82 +101,45 @@ function Stepper(_ref) {
|
|
|
105
101
|
id,
|
|
106
102
|
value
|
|
107
103
|
} = _ref2;
|
|
108
|
-
response[attributes.id][id] = value;
|
|
109
104
|
dispatch({
|
|
110
105
|
type: 'UPDATE_RESPONSE',
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
payload: {
|
|
107
|
+
id,
|
|
108
|
+
value
|
|
109
|
+
}
|
|
113
110
|
});
|
|
114
111
|
onChange?.({
|
|
115
112
|
id,
|
|
116
113
|
value
|
|
117
114
|
});
|
|
118
|
-
// let updateUI = false;
|
|
119
|
-
// const newMuiSteps = MuiSteps.map((step) => {
|
|
120
|
-
// let newComponents = step.components || [];
|
|
121
|
-
// const fElement = newComponents?.find(
|
|
122
|
-
// (component) => component?.id === id || component?.props?.id === id,
|
|
123
|
-
// );
|
|
124
|
-
// if (fElement && fElement.onChangeUpdate) {
|
|
125
|
-
// fElement.onChangeUpdate.forEach(({ enableDisableConfig, patchId, replaceUiConfig }) => {
|
|
126
|
-
// if (enableDisableConfig) {
|
|
127
|
-
// let disableElement = newComponents.find(
|
|
128
|
-
// (k) => k.id === patchId || k?.props?.id === patchId,
|
|
129
|
-
// );
|
|
130
|
-
// if (disableElement && disableElement?.props?.MuiAttributes) {
|
|
131
|
-
// disableElement = {
|
|
132
|
-
// ...disableElement,
|
|
133
|
-
// props: {
|
|
134
|
-
// ...disableElement?.props,
|
|
135
|
-
// MuiAttributes: {
|
|
136
|
-
// ...disableElement?.props?.MuiAttributes,
|
|
137
|
-
// disabled: enableDisableConfig[value],
|
|
138
|
-
// },
|
|
139
|
-
// },
|
|
140
|
-
// };
|
|
141
|
-
// newComponents = newComponents.filter((k) => k?.props?.id !== patchId);
|
|
142
|
-
// newComponents.push(disableElement);
|
|
143
|
-
// updateUI = true;
|
|
144
|
-
// }
|
|
145
|
-
// }
|
|
146
|
-
// if (replaceUiConfig) {
|
|
147
|
-
// newComponents = newComponents.filter((k) => k?.props?.id !== patchId);
|
|
148
|
-
// newComponents.push(replaceUiConfig);
|
|
149
|
-
// updateUI = true;
|
|
150
|
-
// }
|
|
151
|
-
// });
|
|
152
|
-
// }
|
|
153
|
-
// return { ...step, components: newComponents };
|
|
154
|
-
// });
|
|
155
|
-
// if (updateUI) {
|
|
156
|
-
// dispatch({ type: 'SET_STEPS', MuiSteps: newMuiSteps });
|
|
157
|
-
// }
|
|
158
115
|
}, [onChange]);
|
|
159
|
-
const
|
|
160
|
-
let mandatoryIds = arguments.length >
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
mb: 2
|
|
164
|
-
}
|
|
165
|
-
}, /*#__PURE__*/_react.default.createElement(_material.Button, _extends({
|
|
166
|
-
variant: "contained",
|
|
167
|
-
onClick: () => handleStepChange('NEXT_STEP', isScreenChange, index === MuiSteps.length - 1),
|
|
168
|
-
disabled: mandatoryIds.some(id => !response[attributes.id][id]),
|
|
169
|
-
sx: {
|
|
170
|
-
mt: 1,
|
|
171
|
-
mr: 1
|
|
172
|
-
}
|
|
173
|
-
}, attributes.MuiButtonAttributes.next, index === MuiSteps.length - 1 && {
|
|
174
|
-
...attributes.MuiButtonAttributes.final
|
|
175
|
-
}), index === MuiSteps.length - 1 ? 'Finish' : 'Continue'), /*#__PURE__*/_react.default.createElement(_material.Button, _extends({
|
|
176
|
-
disabled: index === 0,
|
|
177
|
-
onClick: () => handleStepChange('PREVIOUS_STEP', isScreenChange, false),
|
|
178
|
-
sx: {
|
|
179
|
-
mt: 1,
|
|
180
|
-
mr: 1
|
|
181
|
-
}
|
|
182
|
-
}, attributes.MuiButtonAttributes.back), "Back"));
|
|
116
|
+
const isDisabled = function () {
|
|
117
|
+
let mandatoryIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
118
|
+
let optionalMandatoryIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
119
|
+
return mandatoryIds.some(id => !stepperResponse[id]) || optionalMandatoryIds.some(item => stepperResponse[item.key] === item.value && item.mandatoryIds.some(id => !stepperResponse[id]));
|
|
183
120
|
};
|
|
121
|
+
const renderButtons = (index, isScreenChange, mandatoryIds, optionalMandatoryIds) => /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
122
|
+
sx: {
|
|
123
|
+
mb: 2
|
|
124
|
+
}
|
|
125
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Button, _extends({
|
|
126
|
+
variant: "contained",
|
|
127
|
+
onClick: () => handleStepChange(1, isScreenChange, index === MuiSteps.length - 1),
|
|
128
|
+
disabled: isDisabled(mandatoryIds, optionalMandatoryIds),
|
|
129
|
+
sx: {
|
|
130
|
+
mt: 1,
|
|
131
|
+
mr: 1
|
|
132
|
+
}
|
|
133
|
+
}, attributes.MuiButtonAttributes.next, index === MuiSteps.length - 1 && {
|
|
134
|
+
...attributes.MuiButtonAttributes.final
|
|
135
|
+
}), index === MuiSteps.length - 1 ? 'Finish' : 'Continue'), /*#__PURE__*/_react.default.createElement(_material.Button, _extends({
|
|
136
|
+
disabled: index === 0,
|
|
137
|
+
onClick: () => handleStepChange(-1, isScreenChange, false),
|
|
138
|
+
sx: {
|
|
139
|
+
mt: 1,
|
|
140
|
+
mr: 1
|
|
141
|
+
}
|
|
142
|
+
}, attributes.MuiButtonAttributes.back), "Back"));
|
|
184
143
|
return /*#__PURE__*/_react.default.createElement(_material.Box, _extends({
|
|
185
144
|
sx: {
|
|
186
145
|
maxWidth: 400
|
|
@@ -196,9 +155,11 @@ function Stepper(_ref) {
|
|
|
196
155
|
}, "Last step")
|
|
197
156
|
}, attributes.MuiStepLabelAttributes), step.label), /*#__PURE__*/_react.default.createElement(_material.StepContent, attributes.MuiStepContentAttributes, step.components ? /*#__PURE__*/_react.default.createElement(_stepperComponents.default, {
|
|
198
157
|
onUpdate: handleUpdate,
|
|
199
|
-
components: (0, _helper.updatePatchData)(step.components, stepperResponse,
|
|
200
|
-
}) : /*#__PURE__*/_react.default.createElement(_material.Typography, null, step.description),
|
|
158
|
+
components: (0, _helper.updatePatchData)(step.components, stepperResponse, '', {}, step.enableDisableIds)
|
|
159
|
+
}) : /*#__PURE__*/_react.default.createElement(_material.Typography, null, step.description), renderButtons(index, step.isScreenChange, step.mandatoryIds, step.optionalMandatoryIds))))));
|
|
201
160
|
}
|
|
161
|
+
|
|
162
|
+
// PropTypes Definition
|
|
202
163
|
Stepper.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
203
164
|
attributes: _propTypes.default.shape({
|
|
204
165
|
id: _propTypes.default.string.isRequired,
|
|
@@ -206,7 +167,9 @@ Stepper.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
206
167
|
label: _propTypes.default.string.isRequired,
|
|
207
168
|
description: _propTypes.default.string,
|
|
208
169
|
isScreenChange: _propTypes.default.bool,
|
|
209
|
-
components: _propTypes.default.array
|
|
170
|
+
components: _propTypes.default.array,
|
|
171
|
+
mandatoryIds: _propTypes.default.array,
|
|
172
|
+
optionalMandatoryIds: _propTypes.default.array
|
|
210
173
|
})).isRequired,
|
|
211
174
|
MuiButtonAttributes: _propTypes.default.object,
|
|
212
175
|
MuiBoxAttributes: _propTypes.default.object,
|
|
@@ -220,10 +183,13 @@ Stepper.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
220
183
|
currentStep: _propTypes.default.number,
|
|
221
184
|
patch: _propTypes.default.object
|
|
222
185
|
} : {};
|
|
186
|
+
|
|
187
|
+
// Default Props
|
|
223
188
|
Stepper.defaultProps = {
|
|
224
189
|
attributes: {},
|
|
225
|
-
currentStep: 0,
|
|
226
|
-
patch: {},
|
|
227
190
|
onChange: () => {},
|
|
228
|
-
onStepUpdate: () => {}
|
|
229
|
-
|
|
191
|
+
onStepUpdate: () => {},
|
|
192
|
+
currentStep: 0,
|
|
193
|
+
patch: {}
|
|
194
|
+
};
|
|
195
|
+
var _default = exports.default = Stepper;
|
|
@@ -16,6 +16,21 @@ const mui = exports.mui = [{
|
|
|
16
16
|
label: 'Select Service Request',
|
|
17
17
|
mandatoryIds: ['servicetype'],
|
|
18
18
|
components: [{
|
|
19
|
+
id: 'servicetypeselect',
|
|
20
|
+
type: 'radio',
|
|
21
|
+
props: {
|
|
22
|
+
id: 'servicetypeselect',
|
|
23
|
+
value: 'Existing',
|
|
24
|
+
MuiAttributes: {},
|
|
25
|
+
MuiFLabelIcon: {},
|
|
26
|
+
MuiFLabel: '',
|
|
27
|
+
MuiFCLAttributes: {},
|
|
28
|
+
MuiFCLabels: ['Existing', 'New'],
|
|
29
|
+
MuiRGAttributes: {
|
|
30
|
+
row: true
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
19
34
|
type: 'select',
|
|
20
35
|
props: {
|
|
21
36
|
id: 'servicetype',
|
|
@@ -23,17 +38,8 @@ const mui = exports.mui = [{
|
|
|
23
38
|
required: true
|
|
24
39
|
},
|
|
25
40
|
options: [{
|
|
26
|
-
value: '
|
|
27
|
-
label: '
|
|
28
|
-
}, {
|
|
29
|
-
value: 'Align Meter',
|
|
30
|
-
label: 'Align Meter'
|
|
31
|
-
}, {
|
|
32
|
-
value: 'Before Meter Leaking',
|
|
33
|
-
label: 'Before Meter Leaking'
|
|
34
|
-
}, {
|
|
35
|
-
value: 'Billing Concerns',
|
|
36
|
-
label: 'Billing Concerns'
|
|
41
|
+
value: 'New Installation',
|
|
42
|
+
label: 'New Installation'
|
|
37
43
|
}, {
|
|
38
44
|
value: 'Change Classification',
|
|
39
45
|
label: 'Change Classification'
|
|
@@ -44,62 +50,14 @@ const mui = exports.mui = [{
|
|
|
44
50
|
value: 'Change Name',
|
|
45
51
|
label: 'Change Name'
|
|
46
52
|
}, {
|
|
47
|
-
value: '
|
|
48
|
-
label: '
|
|
49
|
-
}, {
|
|
50
|
-
value: 'Disconnection - Involuntary',
|
|
51
|
-
label: 'Disconnection - Involuntary'
|
|
52
|
-
}, {
|
|
53
|
-
value: 'Disconnection - Voluntary',
|
|
54
|
-
label: 'Disconnection - Voluntary'
|
|
55
|
-
}, {
|
|
56
|
-
value: 'Distribution Line Leaking',
|
|
57
|
-
label: 'Distribution Line Leaking'
|
|
58
|
-
}, {
|
|
59
|
-
value: 'Estimate Inner Plumbing',
|
|
60
|
-
label: 'Estimate Inner Plumbing'
|
|
61
|
-
}, {
|
|
62
|
-
value: 'Illegal Activity',
|
|
63
|
-
label: 'Illegal Activity'
|
|
64
|
-
}, {
|
|
65
|
-
value: 'Install Lockwing',
|
|
66
|
-
label: 'Install Lockwing'
|
|
67
|
-
}, {
|
|
68
|
-
value: 'Low Pressure/No Water',
|
|
69
|
-
label: 'Low Pressure/No Water'
|
|
70
|
-
}, {
|
|
71
|
-
value: 'Mainline Leaking',
|
|
72
|
-
label: 'Mainline Leaking'
|
|
73
|
-
}, {
|
|
74
|
-
value: 'Other Complaints',
|
|
75
|
-
label: 'Other Complaints'
|
|
76
|
-
}, {
|
|
77
|
-
value: 'Paid Before Disconnect',
|
|
78
|
-
label: 'Paid Before Disconnect'
|
|
79
|
-
}, {
|
|
80
|
-
value: 'Pull Out Meter',
|
|
81
|
-
label: 'Pull Out Meter'
|
|
53
|
+
value: 'Transfer Location',
|
|
54
|
+
label: 'Transfer Location'
|
|
82
55
|
}, {
|
|
83
56
|
value: 'Recheck Read',
|
|
84
57
|
label: 'Recheck Read'
|
|
85
58
|
}, {
|
|
86
|
-
value: '
|
|
87
|
-
label: '
|
|
88
|
-
}, {
|
|
89
|
-
value: 'Relocation - Change Zone',
|
|
90
|
-
label: 'Relocation - Change Zone'
|
|
91
|
-
}, {
|
|
92
|
-
value: 'Secondaryline Leaking',
|
|
93
|
-
label: 'Secondaryline Leaking'
|
|
94
|
-
}, {
|
|
95
|
-
value: 'Survey',
|
|
96
|
-
label: 'Survey'
|
|
97
|
-
}, {
|
|
98
|
-
value: 'Relocation',
|
|
99
|
-
label: 'Relocation'
|
|
100
|
-
}, {
|
|
101
|
-
value: 'Water Quality Concern',
|
|
102
|
-
label: 'Water Quality Concern'
|
|
59
|
+
value: 'Disconnection - Voluntary',
|
|
60
|
+
label: 'Disconnection - Voluntary'
|
|
103
61
|
}],
|
|
104
62
|
MuiBoxAttributes: {}
|
|
105
63
|
}
|
|
@@ -112,6 +70,9 @@ const mui = exports.mui = [{
|
|
|
112
70
|
type: 'select',
|
|
113
71
|
props: {
|
|
114
72
|
id: 'priority',
|
|
73
|
+
MuiAttributes: {
|
|
74
|
+
required: true
|
|
75
|
+
},
|
|
115
76
|
options: [{
|
|
116
77
|
value: 'Emergency',
|
|
117
78
|
label: 'Emergency'
|
|
@@ -163,33 +124,37 @@ const mui = exports.mui = [{
|
|
|
163
124
|
}]
|
|
164
125
|
}, {
|
|
165
126
|
label: 'Assign User',
|
|
166
|
-
mandatoryIds: ['
|
|
127
|
+
mandatoryIds: ['assigntouser'],
|
|
167
128
|
components: [{
|
|
168
129
|
type: 'select',
|
|
169
130
|
props: {
|
|
170
|
-
id: '
|
|
131
|
+
id: 'assigntouser',
|
|
171
132
|
MuiAttributes: {},
|
|
172
133
|
options: [{
|
|
173
|
-
value: '
|
|
174
|
-
label: '
|
|
175
|
-
}, {
|
|
176
|
-
value: 'gwdreader1',
|
|
177
|
-
label: 'gwdreader1'
|
|
134
|
+
value: 'Dinakaran',
|
|
135
|
+
label: 'Dinakaran'
|
|
178
136
|
}, {
|
|
179
|
-
value: '
|
|
180
|
-
label: '
|
|
181
|
-
}, {
|
|
182
|
-
value: 'gmrolandobill',
|
|
183
|
-
label: 'gmrolandobill'
|
|
184
|
-
}, {
|
|
185
|
-
value: 'mungGuiuan',
|
|
186
|
-
label: 'mungGuiuan'
|
|
137
|
+
value: 'Thiyagarajan',
|
|
138
|
+
label: 'Thiyagarajan'
|
|
187
139
|
}],
|
|
188
140
|
MuiBoxAttributes: {}
|
|
189
141
|
}
|
|
190
142
|
}]
|
|
191
143
|
}, {
|
|
192
144
|
label: 'Determine Cost',
|
|
145
|
+
optionalMandatoryIds: [{
|
|
146
|
+
key: 'determinecost',
|
|
147
|
+
value: 'Assign',
|
|
148
|
+
mandatoryIds: ['cost']
|
|
149
|
+
}],
|
|
150
|
+
enableDisableIds: [{
|
|
151
|
+
key: 'determinecost',
|
|
152
|
+
disableIds: ['cost'],
|
|
153
|
+
compareValues: {
|
|
154
|
+
Skip: true,
|
|
155
|
+
Assign: false
|
|
156
|
+
}
|
|
157
|
+
}],
|
|
193
158
|
components: [{
|
|
194
159
|
id: 'determinecost',
|
|
195
160
|
type: 'radio',
|
|
@@ -204,25 +169,29 @@ const mui = exports.mui = [{
|
|
|
204
169
|
MuiRGAttributes: {
|
|
205
170
|
row: true
|
|
206
171
|
}
|
|
172
|
+
},
|
|
173
|
+
enableDisableConfig: {
|
|
174
|
+
disableId: 'cost',
|
|
175
|
+
compareValue: {
|
|
176
|
+
Skip: true,
|
|
177
|
+
Assign: false
|
|
178
|
+
}
|
|
207
179
|
}
|
|
208
180
|
}, {
|
|
209
|
-
id: '
|
|
181
|
+
id: 'cost',
|
|
210
182
|
type: 'textfield',
|
|
211
183
|
props: {
|
|
212
|
-
id: '
|
|
213
|
-
MuiAttributes: {
|
|
214
|
-
type: 'number'
|
|
215
|
-
},
|
|
216
|
-
value: 0
|
|
184
|
+
id: 'cost',
|
|
185
|
+
MuiAttributes: {}
|
|
217
186
|
}
|
|
218
187
|
}]
|
|
219
188
|
}, {
|
|
220
189
|
label: 'Description',
|
|
221
190
|
components: [{
|
|
222
|
-
id: '
|
|
191
|
+
id: 'description',
|
|
223
192
|
type: 'textfield',
|
|
224
193
|
props: {
|
|
225
|
-
id: '
|
|
194
|
+
id: 'description',
|
|
226
195
|
MuiAttributes: {
|
|
227
196
|
multiline: true,
|
|
228
197
|
rows: 3
|
|
@@ -232,47 +201,19 @@ const mui = exports.mui = [{
|
|
|
232
201
|
}, {
|
|
233
202
|
label: 'Review'
|
|
234
203
|
}],
|
|
235
|
-
MuiStepAttributes: {
|
|
236
|
-
sx: {
|
|
237
|
-
'& .MuiStepLabel-root .Mui-completed': {
|
|
238
|
-
color: 'primary.dark'
|
|
239
|
-
},
|
|
240
|
-
'& .MuiStepLabel-label.Mui-completed.MuiStepLabel-alternativeLabel': {
|
|
241
|
-
color: 'grey.500'
|
|
242
|
-
},
|
|
243
|
-
'& .MuiStepLabel-root .Mui-active': {
|
|
244
|
-
color: 'primary.dark'
|
|
245
|
-
},
|
|
246
|
-
'& .MuiStepLabel-label.Mui-active.MuiStepLabel-alternativeLabel': {
|
|
247
|
-
color: 'common.white'
|
|
248
|
-
},
|
|
249
|
-
'& .MuiStepLabel-root .Mui-active .MuiStepIcon-text': {
|
|
250
|
-
fill: 'common.white'
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
},
|
|
204
|
+
MuiStepAttributes: {},
|
|
254
205
|
MuiStepLabelAttributes: {},
|
|
255
206
|
MuiStepContentAttributes: {},
|
|
256
207
|
MuiButtonAttributes: {
|
|
257
|
-
back: {
|
|
258
|
-
sx: {
|
|
259
|
-
color: 'primary.dark',
|
|
260
|
-
mt: 1
|
|
261
|
-
}
|
|
262
|
-
},
|
|
208
|
+
back: {},
|
|
263
209
|
next: {
|
|
264
210
|
sx: {
|
|
265
|
-
bgcolor: 'primary.dark'
|
|
266
|
-
mt: 1
|
|
211
|
+
bgcolor: 'primary.dark'
|
|
267
212
|
}
|
|
268
213
|
},
|
|
269
214
|
final: {
|
|
270
215
|
sx: {
|
|
271
|
-
bgcolor: 'success.light'
|
|
272
|
-
mt: 1,
|
|
273
|
-
'&:hover': {
|
|
274
|
-
bgcolor: 'success.dark'
|
|
275
|
-
}
|
|
216
|
+
bgcolor: 'success.light'
|
|
276
217
|
}
|
|
277
218
|
},
|
|
278
219
|
backLabel: '',
|
|
@@ -12,7 +12,6 @@ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
|
12
12
|
var _material = require("@mui/material");
|
|
13
13
|
var _xDatePickers = require("@mui/x-date-pickers");
|
|
14
14
|
var _react = _interopRequireDefault(require("react"));
|
|
15
|
-
var _utils = require("@mui/x-data-grid/utils/utils");
|
|
16
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
16
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
18
17
|
function generateLayout(data) {
|
|
@@ -85,29 +84,63 @@ function isEmptyCustom(value) {
|
|
|
85
84
|
}
|
|
86
85
|
const updatePatchData = function (fields, patch, guid) {
|
|
87
86
|
let response = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
87
|
+
let enableDisableIds = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
88
88
|
try {
|
|
89
|
+
// Update response with the patch for the provided GUID
|
|
89
90
|
response[guid] = patch;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
91
|
+
|
|
92
|
+
// Map and update fields with response data
|
|
93
|
+
const updatedFields = (0, _lodash.map)(fields, field => {
|
|
94
|
+
const newField = (0, _lodash.cloneDeep)(field);
|
|
95
95
|
const id = newField?.id || newField?.props?.id;
|
|
96
96
|
if (id && response[guid] && !isEmptyCustom(response[guid][id])) {
|
|
97
|
-
const defaultValue =
|
|
98
|
-
const isUndefined = response[guid][id] === undefined;
|
|
97
|
+
const defaultValue = ['switch', 'checkbox'].includes(newField?.type) ? false : '';
|
|
99
98
|
newField.props = {
|
|
100
99
|
...newField.props,
|
|
101
|
-
value:
|
|
100
|
+
value: response[guid][id] === undefined ? defaultValue : response[guid][id]
|
|
102
101
|
};
|
|
103
|
-
// newField.props.value = response[guid][id] || defaultValue;
|
|
104
102
|
}
|
|
105
103
|
return newField;
|
|
106
104
|
});
|
|
107
|
-
|
|
105
|
+
|
|
106
|
+
// Handle enable/disable logic
|
|
107
|
+
if (enableDisableIds.length > 0) {
|
|
108
|
+
enableDisableIds.forEach(_ref => {
|
|
109
|
+
let {
|
|
110
|
+
key,
|
|
111
|
+
disableIds,
|
|
112
|
+
compareValues = {}
|
|
113
|
+
} = _ref;
|
|
114
|
+
const controllingField = updatedFields.find(field => field?.id === key || field?.props?.id === key);
|
|
115
|
+
if (controllingField) {
|
|
116
|
+
const disabled = compareValues[controllingField?.props?.value];
|
|
117
|
+
disableIds.forEach(patchId => {
|
|
118
|
+
const targetFieldIndex = updatedFields.findIndex(field => field?.id === patchId || field?.props?.id === patchId);
|
|
119
|
+
if (targetFieldIndex !== -1) {
|
|
120
|
+
const tElement = updatedFields[targetFieldIndex];
|
|
121
|
+
const id = tElement?.id || tElement?.props?.id;
|
|
122
|
+
response[guid][id] = disabled ? '' : response[guid][id];
|
|
123
|
+
updatedFields[targetFieldIndex] = {
|
|
124
|
+
...updatedFields[targetFieldIndex],
|
|
125
|
+
props: {
|
|
126
|
+
...updatedFields[targetFieldIndex].props,
|
|
127
|
+
value: disabled ? '' : updatedFields[targetFieldIndex]?.props?.value,
|
|
128
|
+
MuiAttributes: {
|
|
129
|
+
...updatedFields[targetFieldIndex].props?.MuiAttributes,
|
|
130
|
+
disabled
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return updatedFields;
|
|
140
|
+
} catch (error) {
|
|
108
141
|
// eslint-disable-next-line no-console
|
|
109
|
-
console.
|
|
110
|
-
return fields;
|
|
142
|
+
console.error('Error updating patch data:', error);
|
|
143
|
+
return fields; // Return original fields on error
|
|
111
144
|
}
|
|
112
145
|
};
|
|
113
146
|
exports.updatePatchData = updatePatchData;
|
package/docs/asset-manifest.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
|
-
"main.js": "/DinakaranS/-dynamic-mui/build/bundle.
|
|
3
|
+
"main.js": "/DinakaranS/-dynamic-mui/build/bundle.5a4707c5.js",
|
|
4
4
|
"index.html": "/DinakaranS/-dynamic-mui/index.html"
|
|
5
5
|
},
|
|
6
6
|
"entrypoints": [
|
|
7
|
-
"build/bundle.
|
|
7
|
+
"build/bundle.5a4707c5.js"
|
|
8
8
|
]
|
|
9
9
|
}
|