oa-componentbook 1.0.1-stage.375 → 1.0.1-stage.376
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.
|
@@ -16,7 +16,7 @@ var _styles = require("./styles");
|
|
|
16
16
|
var _CustomRadio = _interopRequireDefault(require("../../components/oa-component-radio/CustomRadio"));
|
|
17
17
|
var _Typography = _interopRequireDefault(require("../../components/oa-component-typography/Typography"));
|
|
18
18
|
var _CustomButton = _interopRequireDefault(require("../../components/oa-component-button/CustomButton"));
|
|
19
|
-
const _excluded = ["children", "description", "docDetails", "approvalForm", "isMandatory", "hasDivider", "isQuestionStyleWidget", "questionId", "title", "viewOnClick", "data-test"];
|
|
19
|
+
const _excluded = ["children", "description", "docDetails", "approvalForm", "isMandatory", "hasDivider", "isQuestionStyleWidget", "questionId", "title", "viewOnClick", "data-test", "maxLength"];
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
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
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; }
|
|
@@ -59,9 +59,11 @@ function ApprovalWidget(_ref) {
|
|
|
59
59
|
questionId,
|
|
60
60
|
title,
|
|
61
61
|
viewOnClick,
|
|
62
|
-
|
|
62
|
+
"data-test": dataTest,
|
|
63
|
+
maxLength
|
|
63
64
|
} = _ref,
|
|
64
65
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
66
|
+
console.log(maxLength, "maxLength2");
|
|
65
67
|
const getInitialValue = isApproved => {
|
|
66
68
|
switch (isApproved) {
|
|
67
69
|
case true:
|
|
@@ -77,11 +79,11 @@ function ApprovalWidget(_ref) {
|
|
|
77
79
|
return /*#__PURE__*/_react.default.createElement(_styles.StyledContainer, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
78
80
|
className: "row"
|
|
79
81
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
80
|
-
className: approvalForm.hidden ?
|
|
82
|
+
className: approvalForm.hidden ? "col-sm-12 col-md-12 col-lg-12" : "col-sm-12 col-md-7 col-lg-7 gutter"
|
|
81
83
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
82
84
|
className: "row"
|
|
83
85
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
84
|
-
className: isQuestionStyleWidget ?
|
|
86
|
+
className: isQuestionStyleWidget ? "col-sm-12 col-md-12 col-lg-12" : "col-sm-12 col-md-8 col-lg-8 gutter"
|
|
85
87
|
}, title && /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
86
88
|
className: "type-b2-400"
|
|
87
89
|
}, title, isMandatory && /*#__PURE__*/_react.default.createElement(_styles.RedText, null, "*"))), description && /*#__PURE__*/_react.default.createElement(_styles.Styledescription, null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
@@ -92,7 +94,7 @@ function ApprovalWidget(_ref) {
|
|
|
92
94
|
"data-test": dataTest ? "".concat(dataTest, "--view-button") : undefined,
|
|
93
95
|
onClick: () => viewOnClick(questionId),
|
|
94
96
|
type: "text-only",
|
|
95
|
-
label: isQuestionStyleWidget ?
|
|
97
|
+
label: isQuestionStyleWidget ? "View Previous Description" : "View History"
|
|
96
98
|
}), children)), !isQuestionStyleWidget && /*#__PURE__*/_react.default.createElement("div", {
|
|
97
99
|
className: "col-sm-12 col-md-4 col-lg-4"
|
|
98
100
|
}, /*#__PURE__*/_react.default.createElement(_UploadDownloadWidget.default, _extends({
|
|
@@ -112,7 +114,7 @@ function ApprovalWidget(_ref) {
|
|
|
112
114
|
required: true,
|
|
113
115
|
message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
|
|
114
116
|
"data-test": "".concat(dataTest, "--is-approved-validation-message")
|
|
115
|
-
}, "Approval status needs to be selected.") :
|
|
117
|
+
}, "Approval status needs to be selected.") : "Approval status needs to be selected."
|
|
116
118
|
}]
|
|
117
119
|
}, /*#__PURE__*/_react.default.createElement(_CustomRadio.default.Group, {
|
|
118
120
|
"data-test": dataTest ? "".concat(dataTest, "--is-approved-radio-group") : undefined,
|
|
@@ -132,12 +134,17 @@ function ApprovalWidget(_ref) {
|
|
|
132
134
|
className: "type-b2-400"
|
|
133
135
|
}, "Remarks"), /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
134
136
|
name: "remarks-".concat(questionId),
|
|
135
|
-
initialValue: (_approvalForm$remarks = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.remarks) !== null && _approvalForm$remarks !== void 0 ? _approvalForm$remarks :
|
|
137
|
+
initialValue: (_approvalForm$remarks = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.remarks) !== null && _approvalForm$remarks !== void 0 ? _approvalForm$remarks : "",
|
|
136
138
|
rules: [{
|
|
137
139
|
required: true,
|
|
138
140
|
message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
|
|
139
141
|
"data-test": "".concat(dataTest, "--remarks-validation-message")
|
|
140
|
-
}, "Remarks cannot be empty.") :
|
|
142
|
+
}, "Remarks cannot be empty.") : "Remarks cannot be empty."
|
|
143
|
+
}, maxLength && {
|
|
144
|
+
max: maxLength,
|
|
145
|
+
message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
|
|
146
|
+
"data-test": "".concat(dataTest, "--remarks-maxlength-validation-message")
|
|
147
|
+
}, "Remarks cannot exceed ".concat(maxLength, " characters.")) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "Remarks cannot exceed ".concat(maxLength, " characters."))
|
|
141
148
|
}]
|
|
142
149
|
}, /*#__PURE__*/_react.default.createElement(_antd.Input.TextArea, {
|
|
143
150
|
"data-test": dataTest ? "".concat(dataTest, "--remarks") : undefined,
|
|
@@ -146,7 +153,7 @@ function ApprovalWidget(_ref) {
|
|
|
146
153
|
}
|
|
147
154
|
ApprovalWidget.propTypes = {
|
|
148
155
|
children: _propTypes.default.node,
|
|
149
|
-
|
|
156
|
+
"data-test": _propTypes.default.string,
|
|
150
157
|
description: _propTypes.default.string,
|
|
151
158
|
// Leave description optional
|
|
152
159
|
docDetails: _propTypes.default.shape({
|
|
@@ -176,8 +183,8 @@ ApprovalWidget.propTypes = {
|
|
|
176
183
|
};
|
|
177
184
|
ApprovalWidget.defaultProps = {
|
|
178
185
|
children: null,
|
|
179
|
-
|
|
180
|
-
description:
|
|
186
|
+
"data-test": null,
|
|
187
|
+
description: "",
|
|
181
188
|
docDetails: {},
|
|
182
189
|
approvalForm: {
|
|
183
190
|
disabled: false,
|
|
@@ -184,35 +184,39 @@ function ApprovalWidget(_ref) {
|
|
|
184
184
|
}, "Remarks"), /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
185
185
|
name: "remarks-".concat(questionId),
|
|
186
186
|
initialValue: (_approvalForm$remarks = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.remarks) !== null && _approvalForm$remarks !== void 0 ? _approvalForm$remarks : "",
|
|
187
|
-
rules: isRequired
|
|
187
|
+
rules: [isRequired && {
|
|
188
188
|
required: true,
|
|
189
189
|
message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
|
|
190
190
|
"data-test": "".concat(dataTest, "--remarks-validation-message")
|
|
191
191
|
}, "Remarks cannot be empty.") : "Remarks cannot be empty."
|
|
192
|
-
}
|
|
192
|
+
}, maxLength && {
|
|
193
|
+
max: maxLength,
|
|
194
|
+
message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
|
|
195
|
+
"data-test": "".concat(dataTest, "--remarks-maxlength-validation-message")
|
|
196
|
+
}, "Remarks cannot exceed ".concat(maxLength, " characters.")) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "Remarks cannot exceed ".concat(maxLength, " characters."))
|
|
197
|
+
}]
|
|
193
198
|
}, /*#__PURE__*/_react.default.createElement(_antd.Input.TextArea, {
|
|
194
199
|
"data-test": dataTest ? "".concat(dataTest, "--remarks") : undefined,
|
|
195
|
-
disabled: (_approvalForm$disable3 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable3 !== void 0 ? _approvalForm$disable3 : false
|
|
196
|
-
maxLength: maxLength
|
|
200
|
+
disabled: (_approvalForm$disable3 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable3 !== void 0 ? _approvalForm$disable3 : false
|
|
197
201
|
})));
|
|
198
202
|
};
|
|
199
203
|
|
|
200
204
|
/**
|
|
201
205
|
* BUSINESS LOGIC: Two different radio implementations exist for different approval scenarios
|
|
202
|
-
*
|
|
206
|
+
*
|
|
203
207
|
* "radio" - MANDATORY APPROVAL: Always requires user to select approval status
|
|
204
208
|
* - Used when approval decision is compulsory (e.g., critical business processes)
|
|
205
209
|
* - Both approval status AND remarks (if pending) are mandatory
|
|
206
210
|
* - Cannot proceed without making a selection
|
|
207
|
-
*
|
|
211
|
+
*
|
|
208
212
|
* "radioOptional" - OPTIONAL APPROVAL: Approval status depends on isMandatory flag
|
|
209
213
|
* - Used when approval might be optional based on business rules
|
|
210
214
|
* - If isMandatory=true: Same behavior as "radio" (mandatory)
|
|
211
215
|
* - If isMandatory=false: User can skip approval selection
|
|
212
216
|
* - Provides flexibility for different approval workflows
|
|
213
|
-
*
|
|
217
|
+
*
|
|
214
218
|
* This separation allows the same component to handle both strict and flexible approval processes
|
|
215
|
-
*
|
|
219
|
+
*
|
|
216
220
|
* Renders the approval section based on action render type
|
|
217
221
|
* @returns {React.ReactNode} Approval section component
|
|
218
222
|
*/
|
|
@@ -382,12 +386,17 @@ function ApprovalWidget(_ref) {
|
|
|
382
386
|
validateStatus: form.getFieldError("icQues_remarks_".concat(questionId)) ? "error" : "",
|
|
383
387
|
help: form.getFieldError("icQues_remarks_".concat(questionId)) || ""
|
|
384
388
|
}, getFieldDecorator("icQues_remarks_".concat(questionId), {
|
|
385
|
-
rules: isMandatory
|
|
389
|
+
rules: [isMandatory && {
|
|
386
390
|
required: true,
|
|
387
391
|
message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
|
|
388
392
|
"data-test": "".concat(dataTest, "--remarks-validation-message")
|
|
389
393
|
}, "Remarks cannot be empty.") : "Remarks cannot be empty."
|
|
390
|
-
}
|
|
394
|
+
}, maxLength && {
|
|
395
|
+
max: maxLength,
|
|
396
|
+
message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
|
|
397
|
+
"data-test": "".concat(dataTest, "--remarks-maxlength-validation-message")
|
|
398
|
+
}, "Remarks cannot exceed ".concat(maxLength, " characters.")) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "Remarks cannot exceed ".concat(maxLength, " characters."))
|
|
399
|
+
}],
|
|
391
400
|
initialValue: (_approvalForm$remarks2 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.remarks) !== null && _approvalForm$remarks2 !== void 0 ? _approvalForm$remarks2 : ""
|
|
392
401
|
})( /*#__PURE__*/_react.default.createElement(_antd.Input.TextArea, {
|
|
393
402
|
"data-test": dataTest ? "".concat(dataTest, "--remarks") : undefined,
|