oa-componentbook 0.18.361 → 0.18.362
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.
|
@@ -54,7 +54,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
54
54
|
* @property {string} ['data-test'] Data test string to be applied to the outermost element.
|
|
55
55
|
*/
|
|
56
56
|
function ApprovalWidget(_ref) {
|
|
57
|
-
var _approvalForm$
|
|
57
|
+
var _approvalForm$disable5, _actionContent$label, _approvalForm$disable6, _approvalForm$disable7, _approvalForm$disable8, _approvalForm$disable9, _approvalForm$remarks2, _approvalForm$disable10;
|
|
58
58
|
let {
|
|
59
59
|
children,
|
|
60
60
|
description,
|
|
@@ -134,6 +134,92 @@ function ApprovalWidget(_ref) {
|
|
|
134
134
|
return "";
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Renders the approval radio group with validation
|
|
140
|
+
* @param {boolean} isRequired - Whether the field is required
|
|
141
|
+
* @returns {React.ReactNode} Radio group component
|
|
142
|
+
*/
|
|
143
|
+
const renderApprovalRadioGroup = function renderApprovalRadioGroup() {
|
|
144
|
+
var _approvalForm$disable, _approvalForm$disable2;
|
|
145
|
+
let isRequired = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
146
|
+
return /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
147
|
+
name: "isApproved-".concat(questionId),
|
|
148
|
+
className: "custom-radio-group",
|
|
149
|
+
initialValue: isApproved,
|
|
150
|
+
rules: isRequired ? [{
|
|
151
|
+
required: true,
|
|
152
|
+
message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
|
|
153
|
+
"data-test": "".concat(dataTest, "--is-approved-validation-message")
|
|
154
|
+
}, "Approval status needs to be selected.") : "Approval status needs to be selected."
|
|
155
|
+
}] : []
|
|
156
|
+
}, /*#__PURE__*/_react.default.createElement(_CustomRadio.default.Group, {
|
|
157
|
+
"data-test": dataTest ? "".concat(dataTest, "--is-approved-radio-group") : undefined,
|
|
158
|
+
onChange: onRadioChange,
|
|
159
|
+
value: isApproved
|
|
160
|
+
}, /*#__PURE__*/_react.default.createElement(_CustomRadio.default, {
|
|
161
|
+
"data-test": dataTest ? "".concat(dataTest, "--is-approved-radio-yes") : undefined,
|
|
162
|
+
disabled: (_approvalForm$disable = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable !== void 0 ? _approvalForm$disable : false,
|
|
163
|
+
label: "Mark as Approved",
|
|
164
|
+
value: 1
|
|
165
|
+
}), /*#__PURE__*/_react.default.createElement(_CustomRadio.default, {
|
|
166
|
+
"data-test": dataTest ? "".concat(dataTest, "--is-approved-radio-no") : undefined,
|
|
167
|
+
disabled: (_approvalForm$disable2 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable2 !== void 0 ? _approvalForm$disable2 : false,
|
|
168
|
+
label: "Mark as Pending",
|
|
169
|
+
value: 0
|
|
170
|
+
})));
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Renders the remarks textarea with validation
|
|
175
|
+
* @param {boolean} isRequired - Whether the field is required
|
|
176
|
+
* @returns {React.ReactNode} Remarks section component
|
|
177
|
+
*/
|
|
178
|
+
const renderRemarksSection = function renderRemarksSection() {
|
|
179
|
+
var _approvalForm$remarks, _approvalForm$disable3;
|
|
180
|
+
let isRequired = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
181
|
+
return isApproved === 0 && /*#__PURE__*/_react.default.createElement("section", null, /*#__PURE__*/_react.default.createElement("h5", {
|
|
182
|
+
className: "type-b2-400"
|
|
183
|
+
}, "Remarks"), /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
184
|
+
name: "remarks-".concat(questionId),
|
|
185
|
+
initialValue: (_approvalForm$remarks = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.remarks) !== null && _approvalForm$remarks !== void 0 ? _approvalForm$remarks : "",
|
|
186
|
+
rules: isRequired ? [{
|
|
187
|
+
required: true,
|
|
188
|
+
message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
|
|
189
|
+
"data-test": "".concat(dataTest, "--remarks-validation-message")
|
|
190
|
+
}, "Remarks cannot be empty.") : "Remarks cannot be empty."
|
|
191
|
+
}] : []
|
|
192
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Input.TextArea, {
|
|
193
|
+
"data-test": dataTest ? "".concat(dataTest, "--remarks") : undefined,
|
|
194
|
+
disabled: (_approvalForm$disable3 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable3 !== void 0 ? _approvalForm$disable3 : false
|
|
195
|
+
})));
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* BUSINESS LOGIC: Two different radio implementations exist for different approval scenarios
|
|
200
|
+
*
|
|
201
|
+
* "radio" - MANDATORY APPROVAL: Always requires user to select approval status
|
|
202
|
+
* - Used when approval decision is compulsory (e.g., critical business processes)
|
|
203
|
+
* - Both approval status AND remarks (if pending) are mandatory
|
|
204
|
+
* - Cannot proceed without making a selection
|
|
205
|
+
*
|
|
206
|
+
* "radioOptional" - OPTIONAL APPROVAL: Approval status depends on isMandatory flag
|
|
207
|
+
* - Used when approval might be optional based on business rules
|
|
208
|
+
* - If isMandatory=true: Same behavior as "radio" (mandatory)
|
|
209
|
+
* - If isMandatory=false: User can skip approval selection
|
|
210
|
+
* - Provides flexibility for different approval workflows
|
|
211
|
+
*
|
|
212
|
+
* This separation allows the same component to handle both strict and flexible approval processes
|
|
213
|
+
*
|
|
214
|
+
* Renders the approval section based on action render type
|
|
215
|
+
* @returns {React.ReactNode} Approval section component
|
|
216
|
+
*/
|
|
217
|
+
const renderApprovalSection = () => {
|
|
218
|
+
const isRadioType = actionRenderType === "radio" || actionRenderType === "radioOptional";
|
|
219
|
+
if (!isRadioType) return null;
|
|
220
|
+
const isRequired = actionRenderType === "radio" || isMandatory;
|
|
221
|
+
return /*#__PURE__*/_react.default.createElement("div", null, renderApprovalRadioGroup(isRequired), renderRemarksSection(isRequired));
|
|
222
|
+
};
|
|
137
223
|
return /*#__PURE__*/_react.default.createElement(_styles.StyledContainer, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
138
224
|
className: "row"
|
|
139
225
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -147,14 +233,14 @@ function ApprovalWidget(_ref) {
|
|
|
147
233
|
typography: "type-b2-400",
|
|
148
234
|
color: "primary-content"
|
|
149
235
|
}, description)), !isQuestionStyleWidget && ((multipleDocDetails === null || multipleDocDetails === void 0 ? void 0 : multipleDocDetails.length) > 0 ? multipleDocDetails.map(docDetails => {
|
|
150
|
-
var _approvalForm$
|
|
236
|
+
var _approvalForm$disable4;
|
|
151
237
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
152
238
|
className: "oaCustomerResponse"
|
|
153
239
|
}, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
154
240
|
typography: "type-b2-400",
|
|
155
241
|
color: "secondary-content"
|
|
156
242
|
}, docDetails.documentTitle, " \xA0"), /*#__PURE__*/_react.default.createElement(_UploadDownloadWidget.default, _extends({
|
|
157
|
-
disabled: (_approvalForm$
|
|
243
|
+
disabled: (_approvalForm$disable4 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable4 !== void 0 ? _approvalForm$disable4 : false,
|
|
158
244
|
"data-test": dataTest ? "".concat(dataTest, "--upload-download-widget") : undefined
|
|
159
245
|
}, docDetails, {
|
|
160
246
|
formName: isMandatory ? "file-".concat(questionId) : undefined
|
|
@@ -165,7 +251,7 @@ function ApprovalWidget(_ref) {
|
|
|
165
251
|
typography: "type-b2-400",
|
|
166
252
|
color: "secondary-content"
|
|
167
253
|
}, documentTitle, " \xA0"), /*#__PURE__*/_react.default.createElement(_UploadDownloadWidget.default, _extends({
|
|
168
|
-
disabled: (_approvalForm$
|
|
254
|
+
disabled: (_approvalForm$disable5 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable5 !== void 0 ? _approvalForm$disable5 : false,
|
|
169
255
|
"data-test": dataTest ? "".concat(dataTest, "--upload-download-widget") : undefined
|
|
170
256
|
}, docDetails, {
|
|
171
257
|
formName: isMandatory ? "file-".concat(questionId) : undefined
|
|
@@ -240,49 +326,8 @@ function ApprovalWidget(_ref) {
|
|
|
240
326
|
typography: "type-b2-400",
|
|
241
327
|
color: "secondary-content"
|
|
242
328
|
}, (_actionContent$label = actionContent === null || actionContent === void 0 ? void 0 : actionContent.label) !== null && _actionContent$label !== void 0 ? _actionContent$label : "-")), actionRenderType === "button" && /*#__PURE__*/_react.default.createElement(_CustomButton.default, _extends({
|
|
243
|
-
disabled: (_approvalForm$disable3 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable3 !== void 0 ? _approvalForm$disable3 : false
|
|
244
|
-
}, actionContent)), actionRenderType === "radio" &&
|
|
245
|
-
/*#__PURE__*/
|
|
246
|
-
//className="col-sm-12 col-md-4 col-lg-4"
|
|
247
|
-
_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
248
|
-
name: "isApproved-".concat(questionId),
|
|
249
|
-
className: "custom-radio-group",
|
|
250
|
-
initialValue: isApproved,
|
|
251
|
-
rules: [{
|
|
252
|
-
required: true,
|
|
253
|
-
message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
|
|
254
|
-
"data-test": "".concat(dataTest, "--is-approved-validation-message")
|
|
255
|
-
}, "Approval status needs to be selected.") : "Approval status needs to be selected."
|
|
256
|
-
}]
|
|
257
|
-
}, /*#__PURE__*/_react.default.createElement(_CustomRadio.default.Group, {
|
|
258
|
-
"data-test": dataTest ? "".concat(dataTest, "--is-approved-radio-group") : undefined,
|
|
259
|
-
onChange: onRadioChange,
|
|
260
|
-
value: isApproved
|
|
261
|
-
}, /*#__PURE__*/_react.default.createElement(_CustomRadio.default, {
|
|
262
|
-
"data-test": dataTest ? "".concat(dataTest, "--is-approved-radio-yes") : undefined,
|
|
263
|
-
disabled: (_approvalForm$disable4 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable4 !== void 0 ? _approvalForm$disable4 : false,
|
|
264
|
-
label: "Mark as Approved",
|
|
265
|
-
value: 1
|
|
266
|
-
}), /*#__PURE__*/_react.default.createElement(_CustomRadio.default, {
|
|
267
|
-
"data-test": dataTest ? "".concat(dataTest, "--is-approved-radio-no") : undefined,
|
|
268
|
-
disabled: (_approvalForm$disable5 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable5 !== void 0 ? _approvalForm$disable5 : false,
|
|
269
|
-
label: "Mark as Pending",
|
|
270
|
-
value: 0
|
|
271
|
-
}))), isApproved === 0 && /*#__PURE__*/_react.default.createElement("section", null, /*#__PURE__*/_react.default.createElement("h5", {
|
|
272
|
-
className: "type-b2-400"
|
|
273
|
-
}, "Remarks"), /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
274
|
-
name: "remarks-".concat(questionId),
|
|
275
|
-
initialValue: (_approvalForm$remarks = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.remarks) !== null && _approvalForm$remarks !== void 0 ? _approvalForm$remarks : "",
|
|
276
|
-
rules: [{
|
|
277
|
-
required: true,
|
|
278
|
-
message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
|
|
279
|
-
"data-test": "".concat(dataTest, "--remarks-validation-message")
|
|
280
|
-
}, "Remarks cannot be empty.") : "Remarks cannot be empty."
|
|
281
|
-
}]
|
|
282
|
-
}, /*#__PURE__*/_react.default.createElement(_antd.Input.TextArea, {
|
|
283
|
-
"data-test": dataTest ? "".concat(dataTest, "--remarks") : undefined,
|
|
284
329
|
disabled: (_approvalForm$disable6 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable6 !== void 0 ? _approvalForm$disable6 : false
|
|
285
|
-
})))
|
|
330
|
+
}, actionContent)), renderApprovalSection(), actionRenderType === "buttonWithForm" && /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
286
331
|
validateStatus: form.getFieldError("validateDocumentButton#".concat(questionId)) ? "error" : "",
|
|
287
332
|
help: /*#__PURE__*/_react.default.createElement("div", {
|
|
288
333
|
className: "errorForRtv"
|