@unimaze/billing 0.21.34 → 0.21.36
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.
|
@@ -12,6 +12,7 @@ interface AttachmentModalProps extends WrappedComponentProps {
|
|
|
12
12
|
formInstance: FormInstance;
|
|
13
13
|
onRemove: (file: UploadFile) => void;
|
|
14
14
|
onSave: () => void;
|
|
15
|
+
onCancel: () => void;
|
|
15
16
|
}
|
|
16
17
|
declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<AttachmentModalProps, "intl"> & {
|
|
17
18
|
forwardedRef?: React.Ref<any>;
|
|
@@ -182,7 +182,7 @@ var AttachmentModal = function (props) {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
|
-
return (React.createElement(antd_1.Modal, { open: props.isModalOpen, onCancel:
|
|
185
|
+
return (React.createElement(antd_1.Modal, { open: props.isModalOpen, onCancel: props.onCancel, title: props.intl.formatMessage(translationMessages.attachment_title), footer: React.createElement(antd_1.Button, { disabled: isSaveAttachmentsDisabled, icon: React.createElement(icons_1.CheckCircleOutlined, null), type: "primary", style: { width: "100%" }, size: "large", onClick: function () {
|
|
186
186
|
props.onSave();
|
|
187
187
|
props.setIsModalOpen(false);
|
|
188
188
|
} }, props.intl.formatMessage(translationMessages.attachment_saveButton_title)) },
|
|
@@ -202,7 +202,6 @@ var AttachmentModal = function (props) {
|
|
|
202
202
|
React.createElement(lib_1.Form.Item, { name: ["attachments", "file".concat(index + 1), "file"], initialValue: attachment.file, hidden: true }),
|
|
203
203
|
attachment.file.status === "uploading" ? (React.createElement(icons_1.LoadingOutlined, null)) : (React.createElement(antd_1.Typography.Text, { type: attachment.file.status === "error" ? "danger" : undefined },
|
|
204
204
|
React.createElement(icons_1.DeleteOutlined, { onClick: function () {
|
|
205
|
-
props.formInstance.setFieldValue(["attachments", "file".concat(index + 1), "description"], "");
|
|
206
205
|
props.onRemove(attachment.file);
|
|
207
206
|
} })))),
|
|
208
207
|
attachment.fieldValidation === "success" && (React.createElement(lib_1.Form.Item, __assign({}, formLayout_1.fullWidthInput, { rules: [
|
|
@@ -69,6 +69,8 @@ var icons_1 = require("@ant-design/icons");
|
|
|
69
69
|
var AttachmentModal_1 = __importDefault(require("./AttachmentModal"));
|
|
70
70
|
var react_use_1 = require("react-use");
|
|
71
71
|
var FileUploadUtility_1 = require("../../../utils/FileUploadUtility");
|
|
72
|
+
var lodash_1 = __importDefault(require("lodash"));
|
|
73
|
+
var react_1 = require("react");
|
|
72
74
|
var translationMessages = (0, react_intl_1.defineMessages)({
|
|
73
75
|
attachment_title: {
|
|
74
76
|
id: "attachment_title",
|
|
@@ -86,13 +88,14 @@ var translationMessages = (0, react_intl_1.defineMessages)({
|
|
|
86
88
|
var AttachmentsGroup = function (props) {
|
|
87
89
|
var _a = React.useState(false), isModalOpen = _a[0], setIsModalOpen = _a[1];
|
|
88
90
|
var _b = React.useState([]), attachments = _b[0], setAttachments = _b[1];
|
|
89
|
-
var _c =
|
|
90
|
-
var _d = React.useState(false),
|
|
91
|
-
var _e = React.useState(
|
|
92
|
-
var _f = React.useState(
|
|
93
|
-
var _g = React.useState(""),
|
|
91
|
+
var _c = (0, react_1.useState)([]), tempAttachments = _c[0], setTempAttachments = _c[1];
|
|
92
|
+
var _d = React.useState(false), displayAttachments = _d[0], setDisplayAttachments = _d[1];
|
|
93
|
+
var _e = React.useState(false), previewOpen = _e[0], setPreviewOpen = _e[1];
|
|
94
|
+
var _f = React.useState(undefined), previewImage = _f[0], setPreviewImage = _f[1];
|
|
95
|
+
var _g = React.useState(""), previewDescription = _g[0], setPreviewDescription = _g[1];
|
|
96
|
+
var _h = React.useState(""), previewPDFUrl = _h[0], setPreviewPDFUrl = _h[1];
|
|
94
97
|
var width = (0, react_use_1.useWindowSize)().width;
|
|
95
|
-
var
|
|
98
|
+
var _j = React.useState(false), isMobile = _j[0], setIsMobile = _j[1];
|
|
96
99
|
var token = antd_1.theme.useToken().token;
|
|
97
100
|
React.useEffect(function () {
|
|
98
101
|
if (width < 768) {
|
|
@@ -104,9 +107,12 @@ var AttachmentsGroup = function (props) {
|
|
|
104
107
|
}, [width]);
|
|
105
108
|
var removeFile = function (file) {
|
|
106
109
|
var updatedAttachments = attachments.filter(function (attachment) { return attachment.file.uid !== file.uid; });
|
|
110
|
+
setTempAttachments(updatedAttachments);
|
|
107
111
|
setAttachments(updatedAttachments);
|
|
112
|
+
clearFileFields(file);
|
|
108
113
|
};
|
|
109
114
|
var clearFileFields = function (file) {
|
|
115
|
+
// tslint:disable-next-line:no-shadowed-variable
|
|
110
116
|
var fileIndex = attachments.findIndex(function (attachment) { return attachment.file.uid === file.uid; });
|
|
111
117
|
if (fileIndex === -1)
|
|
112
118
|
return;
|
|
@@ -169,10 +175,75 @@ var AttachmentsGroup = function (props) {
|
|
|
169
175
|
setPreviewDescription("");
|
|
170
176
|
setPreviewOpen(false);
|
|
171
177
|
};
|
|
178
|
+
var clearAttachmentsInForm = function () {
|
|
179
|
+
props.formInstance.setFields([
|
|
180
|
+
{
|
|
181
|
+
name: ["attachments", "file".concat(1), "file"],
|
|
182
|
+
value: undefined,
|
|
183
|
+
},
|
|
184
|
+
]);
|
|
185
|
+
props.formInstance.setFields([
|
|
186
|
+
{
|
|
187
|
+
name: ["attachments", "file".concat(1), "description"],
|
|
188
|
+
value: undefined,
|
|
189
|
+
},
|
|
190
|
+
]);
|
|
191
|
+
props.formInstance.setFields([
|
|
192
|
+
{
|
|
193
|
+
name: ["attachments", "file".concat(2), "file"],
|
|
194
|
+
value: undefined,
|
|
195
|
+
},
|
|
196
|
+
]);
|
|
197
|
+
props.formInstance.setFields([
|
|
198
|
+
{
|
|
199
|
+
name: ["attachments", "file".concat(2), "description"],
|
|
200
|
+
value: undefined,
|
|
201
|
+
},
|
|
202
|
+
]);
|
|
203
|
+
props.formInstance.setFields([
|
|
204
|
+
{
|
|
205
|
+
name: ["attachments", "file".concat(3), "file"],
|
|
206
|
+
value: undefined,
|
|
207
|
+
},
|
|
208
|
+
]);
|
|
209
|
+
props.formInstance.setFields([
|
|
210
|
+
{
|
|
211
|
+
name: ["attachments", "file".concat(3), "description"],
|
|
212
|
+
value: undefined,
|
|
213
|
+
},
|
|
214
|
+
]);
|
|
215
|
+
};
|
|
216
|
+
var updateFormState = function (attachmentsForForm) {
|
|
217
|
+
clearAttachmentsInForm();
|
|
218
|
+
attachmentsForForm.forEach(function (at, index) {
|
|
219
|
+
props.formInstance.setFields([
|
|
220
|
+
{
|
|
221
|
+
name: ["attachments", "file".concat(index + 1), "file"],
|
|
222
|
+
value: at.file,
|
|
223
|
+
},
|
|
224
|
+
]);
|
|
225
|
+
props.formInstance.setFields([
|
|
226
|
+
{
|
|
227
|
+
name: ["attachments", "file".concat(index + 1), "description"],
|
|
228
|
+
value: at.description,
|
|
229
|
+
},
|
|
230
|
+
]);
|
|
231
|
+
});
|
|
232
|
+
};
|
|
172
233
|
var saveFiles = function () {
|
|
234
|
+
var clonedAttachments = lodash_1.default.cloneDeep(tempAttachments);
|
|
235
|
+
var filteredAttachments = clonedAttachments.filter(function (at) { return at.description; });
|
|
236
|
+
setAttachments(filteredAttachments);
|
|
237
|
+
updateFormState(filteredAttachments);
|
|
238
|
+
setTempAttachments(filteredAttachments);
|
|
173
239
|
setDisplayAttachments(true);
|
|
174
240
|
setIsModalOpen(false);
|
|
175
241
|
};
|
|
242
|
+
var onModalCancel = function () {
|
|
243
|
+
setTempAttachments(attachments);
|
|
244
|
+
updateFormState(attachments);
|
|
245
|
+
setIsModalOpen(false);
|
|
246
|
+
};
|
|
176
247
|
return (React.createElement(antd_1.Flex, { style: {
|
|
177
248
|
backgroundColor: token.colorInfoBg,
|
|
178
249
|
margin: isMobile ? "0 -20px" : 0,
|
|
@@ -191,20 +262,18 @@ var AttachmentsGroup = function (props) {
|
|
|
191
262
|
React.createElement(antd_1.Flex, { vertical: true },
|
|
192
263
|
React.createElement(antd_1.Typography.Text, { disabled: true }, props.intl.formatMessage(translationMessages.attachment_title))),
|
|
193
264
|
React.createElement(antd_1.Divider, { style: { padding: 0, margin: 0 } }),
|
|
194
|
-
attachments.map(function (attachment) { return (React.createElement(
|
|
195
|
-
React.createElement(antd_1.
|
|
196
|
-
React.createElement(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
React.createElement(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
} }))))); }))),
|
|
207
|
-
React.createElement(AttachmentModal_1.default, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, attachments: attachments, setAttachments: setAttachments, uploadSizeLimit: props.uploadSizeLimit, formInstance: props.formInstance, onRemove: removeFile, onSave: saveFiles }),
|
|
265
|
+
attachments.map(function (attachment) { return (React.createElement(antd_1.Flex, { gap: "middle", justify: "space-between" },
|
|
266
|
+
React.createElement(antd_1.Button, { type: "link", onClick: function () { return handlePreview(attachment.file, attachment.description); }, style: { padding: 0 }, size: "small" },
|
|
267
|
+
React.createElement(icons_1.PaperClipOutlined, { style: { fontSize: token.fontSizeIcon } }),
|
|
268
|
+
attachment.file.name),
|
|
269
|
+
React.createElement(antd_1.Flex, { gap: "middle" },
|
|
270
|
+
React.createElement(icons_1.EditOutlined, { style: { fontSize: token.fontSizeHeading4 }, onClick: function () {
|
|
271
|
+
setIsModalOpen(true);
|
|
272
|
+
} }),
|
|
273
|
+
React.createElement(icons_1.DeleteOutlined, { style: { fontSize: token.fontSizeHeading4 }, onClick: function () {
|
|
274
|
+
removeFile(attachment.file);
|
|
275
|
+
} })))); }))),
|
|
276
|
+
React.createElement(AttachmentModal_1.default, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, attachments: tempAttachments, setAttachments: setTempAttachments, uploadSizeLimit: props.uploadSizeLimit, formInstance: props.formInstance, onRemove: removeFile, onSave: saveFiles, onCancel: onModalCancel }),
|
|
208
277
|
React.createElement(antd_1.Modal, { open: previewOpen, onCancel: handleClosePreview, footer: null },
|
|
209
278
|
previewPDFUrl && (React.createElement("iframe", { src: previewPDFUrl, style: { width: "100%", height: "700px", maxHeight: "75vh" } })),
|
|
210
279
|
previewImage && React.createElement(antd_1.Image, { src: previewImage, preview: false }),
|