@bigbinary/neeto-pdf-frontend 1.0.2 → 1.0.3
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/dist/.ready +1 -1
- package/dist/AttachmentCard-Blp45MKz.js +64 -0
- package/dist/AttachmentCard-Blp45MKz.js.map +1 -0
- package/dist/AttachmentCard-CbDrjY7P.js +67 -0
- package/dist/AttachmentCard-CbDrjY7P.js.map +1 -0
- package/dist/FilenameUtilities-DFEKeP7n.js +150 -0
- package/dist/FilenameUtilities-DFEKeP7n.js.map +1 -0
- package/dist/{FilenameUtilities-BRCCinT2.js → FilenameUtilities-Di7TmEIR.js} +9 -184
- package/dist/FilenameUtilities-Di7TmEIR.js.map +1 -0
- package/dist/FilenameUtilities-SpduImYz.js +139 -0
- package/dist/FilenameUtilities-SpduImYz.js.map +1 -0
- package/dist/{FilenameUtilities-DHtvZ32y.js → FilenameUtilities-Xttn7r8R.js} +2 -177
- package/dist/FilenameUtilities-Xttn7r8R.js.map +1 -0
- package/dist/IconBlock-BZvD1k7W.js +17 -0
- package/dist/IconBlock-BZvD1k7W.js.map +1 -0
- package/dist/IconBlock-Cte1G732.js +15 -0
- package/dist/IconBlock-Cte1G732.js.map +1 -0
- package/dist/PdfDocumentsPage.js +2 -1
- package/dist/PdfDocumentsPage.js.map +1 -1
- package/dist/PdfEditorPage.js +3 -146
- package/dist/PdfEditorPage.js.map +1 -1
- package/dist/cjs/PdfDocumentsPage.js +2 -1
- package/dist/cjs/PdfDocumentsPage.js.map +1 -1
- package/dist/cjs/PdfEditorPage.js +12 -155
- package/dist/cjs/PdfEditorPage.js.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/v2/PdfAttachmentSelector.js +95 -0
- package/dist/cjs/v2/PdfAttachmentSelector.js.map +1 -0
- package/dist/cjs/v2/PdfAttachmentsPreview.js +45 -0
- package/dist/cjs/v2/PdfAttachmentsPreview.js.map +1 -0
- package/dist/cjs/v2/PdfDocumentsPage.js +555 -0
- package/dist/cjs/v2/PdfDocumentsPage.js.map +1 -0
- package/dist/cjs/v2/PdfEditorPage.js +1920 -0
- package/dist/cjs/v2/PdfEditorPage.js.map +1 -0
- package/dist/cjs/v2/index.js +67 -0
- package/dist/cjs/v2/index.js.map +1 -0
- package/dist/constants-DDj0SAA-.js +8 -0
- package/dist/constants-DDj0SAA-.js.map +1 -0
- package/dist/constants-MHmmvZDo.js +5 -0
- package/dist/constants-MHmmvZDo.js.map +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/pdf_documents-PKt4xiTc.js +181 -0
- package/dist/pdf_documents-PKt4xiTc.js.map +1 -0
- package/dist/pdf_documents-j2CBlJrR.js +179 -0
- package/dist/pdf_documents-j2CBlJrR.js.map +1 -0
- package/dist/pdf_mapping_schema-CS6f9Kug.js +149 -0
- package/dist/pdf_mapping_schema-CS6f9Kug.js.map +1 -0
- package/dist/pdf_mapping_schema-Co4FN4KU.js +147 -0
- package/dist/pdf_mapping_schema-Co4FN4KU.js.map +1 -0
- package/dist/v2/PdfAttachmentSelector.js +93 -0
- package/dist/v2/PdfAttachmentSelector.js.map +1 -0
- package/dist/v2/PdfAttachmentsPreview.js +43 -0
- package/dist/v2/PdfAttachmentsPreview.js.map +1 -0
- package/dist/v2/PdfDocumentsPage.js +553 -0
- package/dist/v2/PdfDocumentsPage.js.map +1 -0
- package/dist/v2/PdfEditorPage.js +1899 -0
- package/dist/v2/PdfEditorPage.js.map +1 -0
- package/dist/v2/index.js +58 -0
- package/dist/v2/index.js.map +1 -0
- package/package.json +13 -1
- package/dist/FilenameUtilities-BRCCinT2.js.map +0 -1
- package/dist/FilenameUtilities-DHtvZ32y.js.map +0 -1
package/dist/.ready
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Built at 2026-07-
|
|
1
|
+
Built at 2026-07-20T10:19:43.454Z
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Typography } from '@bigbinary/neeto-atoms';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import File from '@bigbinary/neeto-icons/File';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { I as IconBlock } from './IconBlock-Cte1G732.js';
|
|
6
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
var getSelectedPdfDocuments = function getSelectedPdfDocuments() {
|
|
9
|
+
var documents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
10
|
+
var selectedIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
11
|
+
var selectedIdSet = new Set(selectedIds);
|
|
12
|
+
return documents.filter(function (document) {
|
|
13
|
+
return selectedIdSet.has(document.id);
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var formatFileSize = function formatFileSize(byteSize) {
|
|
17
|
+
if (!byteSize) return "";
|
|
18
|
+
if (byteSize < 1024 * 1024) return "".concat(Math.ceil(byteSize / 1024), " KB");
|
|
19
|
+
return "".concat((byteSize / (1024 * 1024)).toFixed(1), " MB");
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var AttachmentCard = function AttachmentCard(_ref) {
|
|
23
|
+
var _document$templateFil;
|
|
24
|
+
var document = _ref.document,
|
|
25
|
+
_ref$compact = _ref.compact,
|
|
26
|
+
compact = _ref$compact === void 0 ? false : _ref$compact,
|
|
27
|
+
_ref$variant = _ref.variant,
|
|
28
|
+
variant = _ref$variant === void 0 ? "card" : _ref$variant;
|
|
29
|
+
var _useTranslation = useTranslation(),
|
|
30
|
+
t = _useTranslation.t;
|
|
31
|
+
var fileSize = formatFileSize((_document$templateFil = document.templateFile) === null || _document$templateFil === void 0 ? void 0 : _document$templateFil.byteSize);
|
|
32
|
+
var isCard = variant === "card";
|
|
33
|
+
return /*#__PURE__*/jsxs("div", {
|
|
34
|
+
className: classNames("flex min-w-0 items-start text-left", {
|
|
35
|
+
"border-border bg-background rounded-lg shadow-sm gap-3 border px-4 py-3": isCard,
|
|
36
|
+
"gap-4": !isCard
|
|
37
|
+
}),
|
|
38
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
39
|
+
className: "mt-1 shrink-0",
|
|
40
|
+
children: /*#__PURE__*/jsx(IconBlock, {
|
|
41
|
+
icon: File
|
|
42
|
+
})
|
|
43
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
44
|
+
className: "min-w-0 flex-1",
|
|
45
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
46
|
+
className: "truncate",
|
|
47
|
+
style: compact ? "body2" : "h4",
|
|
48
|
+
weight: "semibold",
|
|
49
|
+
children: document.name
|
|
50
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
51
|
+
className: "text-muted-foreground truncate font-mono",
|
|
52
|
+
variant: "body2",
|
|
53
|
+
children: document.outputFilename
|
|
54
|
+
}), fileSize && /*#__PURE__*/jsxs(Typography, {
|
|
55
|
+
className: "text-muted-foreground",
|
|
56
|
+
variant: "body3",
|
|
57
|
+
children: [t("neetoPdf.pdfDocuments.attachments.fileType"), " - ", fileSize]
|
|
58
|
+
})]
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export { AttachmentCard as A, getSelectedPdfDocuments as g };
|
|
64
|
+
//# sourceMappingURL=AttachmentCard-Blp45MKz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttachmentCard-Blp45MKz.js","sources":["../app/javascript/src/v2/components/PdfDocuments/utils.js","../app/javascript/src/v2/components/PdfDocuments/AttachmentCard.jsx"],"sourcesContent":["export const buildSubmitterEmailNotificationParams = formId => ({\n notificationHolderType: \"Form\",\n notificationHolderId: formId,\n customFields: { notificationType: \"ThankYou\" },\n});\n\nexport const buildReceiverEmailNotificationParams = formId => ({\n notificationHolderType: \"Form\",\n notificationHolderId: formId,\n customFields: { notificationType: \"Push\" },\n});\n\nexport const getSelectedPdfDocumentIds = emailNotification =>\n emailNotification?.customFields?.pdfDocumentIds || [];\n\nexport const getSelectedPdfDocuments = (documents = [], selectedIds = []) => {\n const selectedIdSet = new Set(selectedIds);\n\n return documents.filter(document => selectedIdSet.has(document.id));\n};\n\nexport const formatFileSize = byteSize => {\n if (!byteSize) return \"\";\n\n if (byteSize < 1024 * 1024) return `${Math.ceil(byteSize / 1024)} KB`;\n\n return `${(byteSize / (1024 * 1024)).toFixed(1)} MB`;\n};\n","import { Typography } from \"@bigbinary/neeto-atoms\";\nimport classNames from \"classnames\";\nimport { File } from \"neetoicons\";\nimport { useTranslation } from \"react-i18next\";\n\nimport IconBlock from \"./IconBlock\";\nimport { formatFileSize } from \"./utils\";\n\nconst AttachmentCard = ({ document, compact = false, variant = \"card\" }) => {\n const { t } = useTranslation();\n const fileSize = formatFileSize(document.templateFile?.byteSize);\n const isCard = variant === \"card\";\n\n return (\n <div\n className={classNames(\"flex min-w-0 items-start text-left\", {\n \"border-border bg-background rounded-lg shadow-sm gap-3 border px-4 py-3\":\n isCard,\n \"gap-4\": !isCard,\n })}\n >\n <div className=\"mt-1 shrink-0\">\n <IconBlock icon={File} />\n </div>\n <div className=\"min-w-0 flex-1\">\n <Typography\n className=\"truncate\"\n style={compact ? \"body2\" : \"h4\"}\n weight=\"semibold\"\n >\n {document.name}\n </Typography>\n <Typography\n className=\"text-muted-foreground truncate font-mono\"\n variant=\"body2\"\n >\n {document.outputFilename}\n </Typography>\n {fileSize && (\n <Typography className=\"text-muted-foreground\" variant=\"body3\">\n {t(\"neetoPdf.pdfDocuments.attachments.fileType\")} - {fileSize}\n </Typography>\n )}\n </div>\n </div>\n );\n};\n\nexport default AttachmentCard;\n"],"names":["getSelectedPdfDocuments","documents","arguments","length","undefined","selectedIds","selectedIdSet","Set","filter","document","has","id","formatFileSize","byteSize","concat","Math","ceil","toFixed","AttachmentCard","_ref","_document$templateFil","_ref$compact","compact","_ref$variant","variant","_useTranslation","useTranslation","t","fileSize","templateFile","isCard","_j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OAAO;QAAAU,QAAA,EAEdzB,QAAQ,CAACkC;AAAc,OACd,CAAC,EACZf,QAAQ,iBACPG,IAAA,CAACQ,UAAU,EAAA;AAACP,QAAAA,SAAS,EAAC,uBAAuB;AAACR,QAAAA,OAAO,EAAC,OAAO;QAAAU,QAAA,EAAA,CAC1DP,CAAC,CAAC,4CAA4C,CAAC,EAAC,KAAG,EAACC,QAAQ;AAAA,OACnD,CACb;AAAA,KACE,CAAC;AAAA,GACH,CAAC;AAEV;;;;"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var neetoAtoms = require('@bigbinary/neeto-atoms');
|
|
4
|
+
var classNames = require('classnames');
|
|
5
|
+
var File = require('@bigbinary/neeto-icons/File');
|
|
6
|
+
var reactI18next = require('react-i18next');
|
|
7
|
+
var IconBlock = require('./IconBlock-BZvD1k7W.js');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
var getSelectedPdfDocuments = function getSelectedPdfDocuments() {
|
|
11
|
+
var documents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
12
|
+
var selectedIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
13
|
+
var selectedIdSet = new Set(selectedIds);
|
|
14
|
+
return documents.filter(function (document) {
|
|
15
|
+
return selectedIdSet.has(document.id);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
var formatFileSize = function formatFileSize(byteSize) {
|
|
19
|
+
if (!byteSize) return "";
|
|
20
|
+
if (byteSize < 1024 * 1024) return "".concat(Math.ceil(byteSize / 1024), " KB");
|
|
21
|
+
return "".concat((byteSize / (1024 * 1024)).toFixed(1), " MB");
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
var AttachmentCard = function AttachmentCard(_ref) {
|
|
25
|
+
var _document$templateFil;
|
|
26
|
+
var document = _ref.document,
|
|
27
|
+
_ref$compact = _ref.compact,
|
|
28
|
+
compact = _ref$compact === void 0 ? false : _ref$compact,
|
|
29
|
+
_ref$variant = _ref.variant,
|
|
30
|
+
variant = _ref$variant === void 0 ? "card" : _ref$variant;
|
|
31
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
32
|
+
t = _useTranslation.t;
|
|
33
|
+
var fileSize = formatFileSize((_document$templateFil = document.templateFile) === null || _document$templateFil === void 0 ? void 0 : _document$templateFil.byteSize);
|
|
34
|
+
var isCard = variant === "card";
|
|
35
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
36
|
+
className: classNames("flex min-w-0 items-start text-left", {
|
|
37
|
+
"border-border bg-background rounded-lg shadow-sm gap-3 border px-4 py-3": isCard,
|
|
38
|
+
"gap-4": !isCard
|
|
39
|
+
}),
|
|
40
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
41
|
+
className: "mt-1 shrink-0",
|
|
42
|
+
children: /*#__PURE__*/jsxRuntime.jsx(IconBlock.IconBlock, {
|
|
43
|
+
icon: File
|
|
44
|
+
})
|
|
45
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
46
|
+
className: "min-w-0 flex-1",
|
|
47
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
|
|
48
|
+
className: "truncate",
|
|
49
|
+
style: compact ? "body2" : "h4",
|
|
50
|
+
weight: "semibold",
|
|
51
|
+
children: document.name
|
|
52
|
+
}), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
|
|
53
|
+
className: "text-muted-foreground truncate font-mono",
|
|
54
|
+
variant: "body2",
|
|
55
|
+
children: document.outputFilename
|
|
56
|
+
}), fileSize && /*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Typography, {
|
|
57
|
+
className: "text-muted-foreground",
|
|
58
|
+
variant: "body3",
|
|
59
|
+
children: [t("neetoPdf.pdfDocuments.attachments.fileType"), " - ", fileSize]
|
|
60
|
+
})]
|
|
61
|
+
})]
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.AttachmentCard = AttachmentCard;
|
|
66
|
+
exports.getSelectedPdfDocuments = getSelectedPdfDocuments;
|
|
67
|
+
//# sourceMappingURL=AttachmentCard-CbDrjY7P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttachmentCard-CbDrjY7P.js","sources":["../app/javascript/src/v2/components/PdfDocuments/utils.js","../app/javascript/src/v2/components/PdfDocuments/AttachmentCard.jsx"],"sourcesContent":["export const buildSubmitterEmailNotificationParams = formId => ({\n notificationHolderType: \"Form\",\n notificationHolderId: formId,\n customFields: { notificationType: \"ThankYou\" },\n});\n\nexport const buildReceiverEmailNotificationParams = formId => ({\n notificationHolderType: \"Form\",\n notificationHolderId: formId,\n customFields: { notificationType: \"Push\" },\n});\n\nexport const getSelectedPdfDocumentIds = emailNotification =>\n emailNotification?.customFields?.pdfDocumentIds || [];\n\nexport const getSelectedPdfDocuments = (documents = [], selectedIds = []) => {\n const selectedIdSet = new Set(selectedIds);\n\n return documents.filter(document => selectedIdSet.has(document.id));\n};\n\nexport const formatFileSize = byteSize => {\n if (!byteSize) return \"\";\n\n if (byteSize < 1024 * 1024) return `${Math.ceil(byteSize / 1024)} KB`;\n\n return `${(byteSize / (1024 * 1024)).toFixed(1)} MB`;\n};\n","import { Typography } from \"@bigbinary/neeto-atoms\";\nimport classNames from \"classnames\";\nimport { File } from \"neetoicons\";\nimport { useTranslation } from \"react-i18next\";\n\nimport IconBlock from \"./IconBlock\";\nimport { formatFileSize } from \"./utils\";\n\nconst AttachmentCard = ({ document, compact = false, variant = \"card\" }) => {\n const { t } = useTranslation();\n const fileSize = formatFileSize(document.templateFile?.byteSize);\n const isCard = variant === \"card\";\n\n return (\n <div\n className={classNames(\"flex min-w-0 items-start text-left\", {\n \"border-border bg-background rounded-lg shadow-sm gap-3 border px-4 py-3\":\n isCard,\n \"gap-4\": !isCard,\n })}\n >\n <div className=\"mt-1 shrink-0\">\n <IconBlock icon={File} />\n </div>\n <div className=\"min-w-0 flex-1\">\n <Typography\n className=\"truncate\"\n style={compact ? \"body2\" : \"h4\"}\n weight=\"semibold\"\n >\n {document.name}\n </Typography>\n <Typography\n className=\"text-muted-foreground truncate font-mono\"\n variant=\"body2\"\n >\n {document.outputFilename}\n </Typography>\n {fileSize && (\n <Typography className=\"text-muted-foreground\" variant=\"body3\">\n {t(\"neetoPdf.pdfDocuments.attachments.fileType\")} - {fileSize}\n </Typography>\n )}\n </div>\n </div>\n );\n};\n\nexport default AttachmentCard;\n"],"names":["getSelectedPdfDocuments","documents","arguments","length","undefined","selectedIds","selectedIdSet","Set","filter","document","has","id","formatFileSize","byteSize","concat","Math","ceil","toFixed","AttachmentCard","_ref","_document$templateFil","_ref$compact","compact","_ref$variant","variant","_useTranslation","useTranslation","t","fileSize","templateFile","isCard","_jsxs","className","classNames","children","_jsx","IconBlock","icon","File","Typography","style","weight","name","outputFilename"],"mappings":";;;;;;;;;IAeaA,uBAAuB,GAAG,SAA1BA,uBAAuBA,GAAyC;AAAA,EAAA,IAArCC,SAAS,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE;AAAA,EAAA,IAAEG,WAAW,GAAAH,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE;AACtE,EAAA,IAAMI,aAAa,GAAG,IAAIC,GAAG,CAACF,WAAW,CAAC;AAE1C,EAAA,OAAOJ,SAAS,CAACO,MAAM,CAAC,UAAAC,QAAQ,EAAA;AAAA,IAAA,OAAIH,aAAa,CAACI,GAAG,CAACD,QAAQ,CAACE,EAAE,CAAC;EAAA,CAAA,CAAC;AACrE;AAEO,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAGC,QAAQ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EHC,cAAA,CAAA,KAAA,EAAA;AAAKH,MAAAA,SAAS,EAAC,eAAe;MAAAE,QAAA,eAC5BC,cAAA,CAACC,mBAAS,EAAA;AAACC,QAAAA,IAAI,EAAEC;OAAO;KACrB,CAAC,eACNP,eAAA,CAAA,KAAA,EAAA;AAAKC,MAAAA,SAAS,EAAC,gBAAgB;MAAAE,QAAA,EAAA,cAC7BC,cAAA,CAACI,qBAAU,EAAA;AACTP,QAAAA,SAAS,EAAC,UAAU;AACpBQ,QAAAA,KAAK,EAAElB,OAAO,GAAG,OAAO,GAAG,IAAK;AAChCmB,QAAAA,MAAM,EAAC,UAAU;QAAAP,QAAA,EAEhBzB,QAAQ,CAACiC;AAAI,OACJ,CAAC,eACbP,cAAA,CAACI,qBAAU,EAAA;AACTP,QAAAA,SAAS,EAAC,0CAA0C;AACpDR,QAAAA,OAAO,EAAC,OAAO;QAAAU,QAAA,EAEdzB,QAAQ,CAACkC;AAAc,OACd,CAAC,EACZf,QAAQ,iBACPG,eAAA,CAACQ,qBAAU,EAAA;AAACP,QAAAA,SAAS,EAAC,uBAAuB;AAACR,QAAAA,OAAO,EAAC,OAAO;QAAAU,QAAA,EAAA,CAC1DP,CAAC,CAAC,4CAA4C,CAAC,EAAC,KAAG,EAACC,QAAQ;AAAA,OACnD,CACb;AAAA,KACE,CAAC;AAAA,GACH,CAAC;AAEV;;;;;"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
4
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
5
|
+
var reactQuery = require('@tanstack/react-query');
|
|
6
|
+
var reactUtils = require('@bigbinary/neeto-commons-frontend/v2/react-utils');
|
|
7
|
+
var pdf_documents = require('./pdf_documents-PKt4xiTc.js');
|
|
8
|
+
|
|
9
|
+
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; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
var documentKeys = function documentKeys(ownerId, apiBaseUrl) {
|
|
12
|
+
return ["neeto-pdf-documents", apiBaseUrl, ownerId];
|
|
13
|
+
};
|
|
14
|
+
var useInvalidatingMutation = function useInvalidatingMutation(mutationFn, ownerId, apiBaseUrl) {
|
|
15
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
16
|
+
return reactUtils.useMutationWithInvalidation(mutationFn, _objectSpread({
|
|
17
|
+
keysToInvalidate: [documentKeys(ownerId, apiBaseUrl)]
|
|
18
|
+
}, options));
|
|
19
|
+
};
|
|
20
|
+
var getPdfDocumentApiErrorMessage = function getPdfDocumentApiErrorMessage(error, fallback) {
|
|
21
|
+
var _error$response;
|
|
22
|
+
return (error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.data) === null || _error$response === void 0 ? void 0 : _error$response.error) || fallback;
|
|
23
|
+
};
|
|
24
|
+
var useFetchPdfDocuments = function useFetchPdfDocuments(_ref) {
|
|
25
|
+
var apiBaseUrl = _ref.apiBaseUrl,
|
|
26
|
+
ownerId = _ref.ownerId,
|
|
27
|
+
_ref$options = _ref.options,
|
|
28
|
+
options = _ref$options === void 0 ? {} : _ref$options;
|
|
29
|
+
return reactQuery.useQuery(_objectSpread({
|
|
30
|
+
queryKey: documentKeys(ownerId, apiBaseUrl),
|
|
31
|
+
queryFn: function queryFn() {
|
|
32
|
+
return pdf_documents.pdfDocumentsApi.list({
|
|
33
|
+
apiBaseUrl: apiBaseUrl,
|
|
34
|
+
ownerId: ownerId
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
enabled: Boolean(apiBaseUrl && ownerId)
|
|
38
|
+
}, options));
|
|
39
|
+
};
|
|
40
|
+
var useFetchPdfDocument = function useFetchPdfDocument(_ref2) {
|
|
41
|
+
var apiBaseUrl = _ref2.apiBaseUrl,
|
|
42
|
+
ownerId = _ref2.ownerId,
|
|
43
|
+
documentId = _ref2.documentId,
|
|
44
|
+
_ref2$options = _ref2.options,
|
|
45
|
+
options = _ref2$options === void 0 ? {} : _ref2$options;
|
|
46
|
+
return reactQuery.useQuery(_objectSpread({
|
|
47
|
+
queryKey: [].concat(_toConsumableArray(documentKeys(ownerId, apiBaseUrl)), [documentId]),
|
|
48
|
+
queryFn: function queryFn() {
|
|
49
|
+
return pdf_documents.pdfDocumentsApi.show({
|
|
50
|
+
apiBaseUrl: apiBaseUrl,
|
|
51
|
+
ownerId: ownerId,
|
|
52
|
+
documentId: documentId
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
enabled: Boolean(apiBaseUrl && ownerId && documentId)
|
|
56
|
+
}, options));
|
|
57
|
+
};
|
|
58
|
+
var useCreatePdfDocument = function useCreatePdfDocument(_ref3) {
|
|
59
|
+
var apiBaseUrl = _ref3.apiBaseUrl,
|
|
60
|
+
ownerId = _ref3.ownerId,
|
|
61
|
+
_ref3$options = _ref3.options,
|
|
62
|
+
options = _ref3$options === void 0 ? {} : _ref3$options;
|
|
63
|
+
return useInvalidatingMutation(function (file) {
|
|
64
|
+
return pdf_documents.pdfDocumentsApi.create({
|
|
65
|
+
apiBaseUrl: apiBaseUrl,
|
|
66
|
+
ownerId: ownerId,
|
|
67
|
+
file: file
|
|
68
|
+
});
|
|
69
|
+
}, ownerId, apiBaseUrl, options);
|
|
70
|
+
};
|
|
71
|
+
var useUpdatePdfDocument = function useUpdatePdfDocument(_ref4) {
|
|
72
|
+
var apiBaseUrl = _ref4.apiBaseUrl,
|
|
73
|
+
ownerId = _ref4.ownerId,
|
|
74
|
+
_ref4$options = _ref4.options,
|
|
75
|
+
options = _ref4$options === void 0 ? {} : _ref4$options;
|
|
76
|
+
return useInvalidatingMutation(function (_ref5) {
|
|
77
|
+
var documentId = _ref5.documentId,
|
|
78
|
+
payload = _ref5.payload;
|
|
79
|
+
return pdf_documents.pdfDocumentsApi.update({
|
|
80
|
+
apiBaseUrl: apiBaseUrl,
|
|
81
|
+
ownerId: ownerId,
|
|
82
|
+
documentId: documentId,
|
|
83
|
+
payload: payload
|
|
84
|
+
});
|
|
85
|
+
}, ownerId, apiBaseUrl, options);
|
|
86
|
+
};
|
|
87
|
+
var useUpdatePdfDocumentTemplateFile = function useUpdatePdfDocumentTemplateFile(_ref6) {
|
|
88
|
+
var apiBaseUrl = _ref6.apiBaseUrl,
|
|
89
|
+
ownerId = _ref6.ownerId,
|
|
90
|
+
_ref6$options = _ref6.options,
|
|
91
|
+
options = _ref6$options === void 0 ? {} : _ref6$options;
|
|
92
|
+
return useInvalidatingMutation(function (_ref7) {
|
|
93
|
+
var documentId = _ref7.documentId,
|
|
94
|
+
file = _ref7.file;
|
|
95
|
+
return pdf_documents.pdfDocumentsApi.updateTemplateFile({
|
|
96
|
+
apiBaseUrl: apiBaseUrl,
|
|
97
|
+
ownerId: ownerId,
|
|
98
|
+
documentId: documentId,
|
|
99
|
+
file: file
|
|
100
|
+
});
|
|
101
|
+
}, ownerId, apiBaseUrl, options);
|
|
102
|
+
};
|
|
103
|
+
var useClonePdfDocument = function useClonePdfDocument(_ref8) {
|
|
104
|
+
var apiBaseUrl = _ref8.apiBaseUrl,
|
|
105
|
+
ownerId = _ref8.ownerId,
|
|
106
|
+
_ref8$options = _ref8.options,
|
|
107
|
+
options = _ref8$options === void 0 ? {} : _ref8$options;
|
|
108
|
+
return useInvalidatingMutation(function (documentId) {
|
|
109
|
+
return pdf_documents.pdfDocumentsApi.clone({
|
|
110
|
+
apiBaseUrl: apiBaseUrl,
|
|
111
|
+
ownerId: ownerId,
|
|
112
|
+
documentId: documentId
|
|
113
|
+
});
|
|
114
|
+
}, ownerId, apiBaseUrl, options);
|
|
115
|
+
};
|
|
116
|
+
var useDeletePdfDocument = function useDeletePdfDocument(_ref9) {
|
|
117
|
+
var apiBaseUrl = _ref9.apiBaseUrl,
|
|
118
|
+
ownerId = _ref9.ownerId,
|
|
119
|
+
_ref9$options = _ref9.options,
|
|
120
|
+
options = _ref9$options === void 0 ? {} : _ref9$options;
|
|
121
|
+
return useInvalidatingMutation(function (documentId) {
|
|
122
|
+
return pdf_documents.pdfDocumentsApi.destroy({
|
|
123
|
+
apiBaseUrl: apiBaseUrl,
|
|
124
|
+
ownerId: ownerId,
|
|
125
|
+
documentId: documentId
|
|
126
|
+
});
|
|
127
|
+
}, ownerId, apiBaseUrl, options);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
var buildOutputFilenameTemplate = function buildOutputFilenameTemplate(name) {
|
|
131
|
+
var parameterizedName = (name || "").trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
132
|
+
return "".concat(parameterizedName || "document", "-{{id}}.pdf");
|
|
133
|
+
};
|
|
134
|
+
var buildOutputFilename = function buildOutputFilename(pdfDocument, submission) {
|
|
135
|
+
var base = (pdfDocument === null || pdfDocument === void 0 ? void 0 : pdfDocument.outputFilename) || "".concat((pdfDocument === null || pdfDocument === void 0 ? void 0 : pdfDocument.name) || "document", ".pdf");
|
|
136
|
+
var withId = base.replace(/\{\{\s*id\s*\}\}/g, (submission === null || submission === void 0 ? void 0 : submission.id) || "");
|
|
137
|
+
return withId.endsWith(".pdf") ? withId : "".concat(withId, ".pdf");
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
exports.buildOutputFilename = buildOutputFilename;
|
|
141
|
+
exports.buildOutputFilenameTemplate = buildOutputFilenameTemplate;
|
|
142
|
+
exports.getPdfDocumentApiErrorMessage = getPdfDocumentApiErrorMessage;
|
|
143
|
+
exports.useClonePdfDocument = useClonePdfDocument;
|
|
144
|
+
exports.useCreatePdfDocument = useCreatePdfDocument;
|
|
145
|
+
exports.useDeletePdfDocument = useDeletePdfDocument;
|
|
146
|
+
exports.useFetchPdfDocument = useFetchPdfDocument;
|
|
147
|
+
exports.useFetchPdfDocuments = useFetchPdfDocuments;
|
|
148
|
+
exports.useUpdatePdfDocument = useUpdatePdfDocument;
|
|
149
|
+
exports.useUpdatePdfDocumentTemplateFile = useUpdatePdfDocumentTemplateFile;
|
|
150
|
+
//# sourceMappingURL=FilenameUtilities-DFEKeP7n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilenameUtilities-DFEKeP7n.js","sources":["../app/javascript/src/v2/hooks/usePdfDocumentsApi.js","../app/javascript/src/v2/components/PdfDocuments/FilenameUtilities.js"],"sourcesContent":["import { useQuery } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/v2/react-utils\";\n\nimport pdfDocumentsApi from \"src/apis/pdf_documents\";\n\nconst documentKeys = (ownerId, apiBaseUrl) => [\n \"neeto-pdf-documents\",\n apiBaseUrl,\n ownerId,\n];\n\nconst useInvalidatingMutation = (\n mutationFn,\n ownerId,\n apiBaseUrl,\n options = {}\n) =>\n useMutationWithInvalidation(mutationFn, {\n keysToInvalidate: [documentKeys(ownerId, apiBaseUrl)],\n ...options,\n });\n\nexport const getPdfDocumentApiErrorMessage = (error, fallback) =>\n error?.response?.data?.error || fallback;\n\nexport const useFetchPdfDocuments = ({ apiBaseUrl, ownerId, options = {} }) =>\n useQuery({\n queryKey: documentKeys(ownerId, apiBaseUrl),\n queryFn: () => pdfDocumentsApi.list({ apiBaseUrl, ownerId }),\n enabled: Boolean(apiBaseUrl && ownerId),\n ...options,\n });\n\nexport const useFetchPdfDocument = ({\n apiBaseUrl,\n ownerId,\n documentId,\n options = {},\n}) =>\n useQuery({\n queryKey: [...documentKeys(ownerId, apiBaseUrl), documentId],\n queryFn: () => pdfDocumentsApi.show({ apiBaseUrl, ownerId, documentId }),\n enabled: Boolean(apiBaseUrl && ownerId && documentId),\n ...options,\n });\n\nexport const useCreatePdfDocument = ({ apiBaseUrl, ownerId, options = {} }) =>\n useInvalidatingMutation(\n file => pdfDocumentsApi.create({ apiBaseUrl, ownerId, file }),\n ownerId,\n apiBaseUrl,\n options\n );\n\nexport const useUpdatePdfDocument = ({ apiBaseUrl, ownerId, options = {} }) =>\n useInvalidatingMutation(\n ({ documentId, payload }) =>\n pdfDocumentsApi.update({ apiBaseUrl, ownerId, documentId, payload }),\n ownerId,\n apiBaseUrl,\n options\n );\n\nexport const useUpdatePdfDocumentTemplateFile = ({\n apiBaseUrl,\n ownerId,\n options = {},\n}) =>\n useInvalidatingMutation(\n ({ documentId, file }) =>\n pdfDocumentsApi.updateTemplateFile({\n apiBaseUrl,\n ownerId,\n documentId,\n file,\n }),\n ownerId,\n apiBaseUrl,\n options\n );\n\nexport const useClonePdfDocument = ({ apiBaseUrl, ownerId, options = {} }) =>\n useInvalidatingMutation(\n documentId => pdfDocumentsApi.clone({ apiBaseUrl, ownerId, documentId }),\n ownerId,\n apiBaseUrl,\n options\n );\n\nexport const useDeletePdfDocument = ({ apiBaseUrl, ownerId, options = {} }) =>\n useInvalidatingMutation(\n documentId => pdfDocumentsApi.destroy({ apiBaseUrl, ownerId, documentId }),\n ownerId,\n apiBaseUrl,\n options\n );\n","export const buildOutputFilenameTemplate = name => {\n const parameterizedName = (name || \"\")\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n\n return `${parameterizedName || \"document\"}-{{id}}.pdf`;\n};\n\nexport const buildOutputFilename = (pdfDocument, submission) => {\n const base =\n pdfDocument?.outputFilename || `${pdfDocument?.name || \"document\"}.pdf`;\n const withId = base.replace(/\\{\\{\\s*id\\s*\\}\\}/g, submission?.id || \"\");\n\n return withId.endsWith(\".pdf\") ? withId : `${withId}.pdf`;\n};\n"],"names":["documentKeys","ownerId","apiBaseUrl","useInvalidatingMutation","mutationFn","options","arguments","length","undefined","useMutationWithInvalidation","_objectSpread","keysToInvalidate","getPdfDocumentApiErrorMessage","error","fallback","_error$response","response","data","useFetchPdfDocuments","_ref","_ref$options","useQuery","queryKey","queryFn","pdfDocumentsApi","list","enabled","Boolean","useFetchPdfDocument","_ref2","documentId","_ref2$options","concat","_toConsumableArray","show","useCreatePdfDocument","_ref3","_ref3$options","file","create","useUpdatePdfDocument","_ref4","_ref4$options","_ref5","payload","update","useUpdatePdfDocumentTemplateFile","_ref6","_ref6$options","_ref7","updateTemplateFile","useClonePdfDocument","_ref8","_ref8$options","clone","useDeletePdfDocument","_ref9","_ref9$options","destroy","buildOutputFilenameTemplate","name","parameterizedName","trim","toLowerCase","replace","buildOutputFilename","pdfDocument","submission","base","outputFilename","withId","id","endsWith"],"mappings":";;;;;;;;;;AAKA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,CAAIC,OAAO,EAAEC,UAAU,EAAA;AAAA,EAAA,OAAK,CAC5C,qBAAqB,EACrBA,UAAU,EACVD,OAAO,CACR;AAAA,CAAA;AAED,IAAME,uBAAuB,GAAG,SAA1BA,uBAAuBA,CAC3BC,UAAU,EACVH,OAAO,EACPC,UAAU,EAAA;AAAA,EAAA,IACVG,OAAO,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE;AAAA,EAAA,OAEZG,sCAA2B,CAACL,UAAU,EAAAM,aAAA,CAAA;AACpCC,IAAAA,gBAAgB,EAAE,CAACX,YAAY,CAACC,OAAO,EAAEC,UAAU,CAAC;GAAC,EAClDG,OAAO,CACX,CAAC;AAAA,CAAA;AAEG,IAAMO,6BAA6B,GAAG,SAAhCA,6BAA6BA,CAAIC,KAAK,EAAEC,QAAQ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AC3BA,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;AAE1B,EAAA,OAAA,EAAA,CAAAhC,MAAA,CAAU6B,iBAAiB,IAAI,UAAU,EAAA,aAAA,CAAA;AAC3C;AAEO,IAAMI,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAIC,WAAW,EAAEC,UAAU,EAAK;EAC9D,IAAMC,IAAI,GACR,CAAAF,WAAW,aAAXA,WAAW,KAAA,MAAA,GAAA,MAAA,GAAXA,WAAW,CAAEG,cAAc,KAAA,EAAA,CAAArC,MAAA,CAAO,CAAAkC,WAAW,KAAA,IAAA,IAAXA,WAAW,KAAA,MAAA,GAAA,MAAA,GAAXA,WAAW,CAAEN,IAAI,KAAI,UAAU,EAAA,MAAA,CAAM;AACzE,EAAA,IAAMU,MAAM,GAAGF,IAAI,CAACJ,OAAO,CAAC,mBAAmB,EAAE,CAAAG,UAAU,KAAA,IAAA,IAAVA,UAAU,KAAA,MAAA,GAAA,MAAA,GAAVA,UAAU,CAAEI,EAAE,KAAI,EAAE,CAAC;AAEtE,EAAA,OAAOD,MAAM,CAACE,QAAQ,CAAC,MAAM,CAAC,GAAGF,MAAM,GAAA,EAAA,CAAAtC,MAAA,CAAMsC,MAAM,EAAA,MAAA,CAAM;AAC3D;;;;;;;;;;;;;"}
|
|
@@ -4,182 +4,7 @@ var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
|
4
4
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
5
5
|
var reactQuery = require('@tanstack/react-query');
|
|
6
6
|
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
7
|
-
var
|
|
8
|
-
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
9
|
-
var axios = require('axios');
|
|
10
|
-
|
|
11
|
-
var trimTrailingSlash = function trimTrailingSlash(value) {
|
|
12
|
-
return (value === null || value === void 0 ? void 0 : value.replace(/\/+$/, "")) || "";
|
|
13
|
-
};
|
|
14
|
-
var documentsUrl = function documentsUrl(apiBaseUrl) {
|
|
15
|
-
return "".concat(trimTrailingSlash(apiBaseUrl), "/documents");
|
|
16
|
-
};
|
|
17
|
-
var documentUrl = function documentUrl(_ref) {
|
|
18
|
-
var apiBaseUrl = _ref.apiBaseUrl,
|
|
19
|
-
documentId = _ref.documentId;
|
|
20
|
-
return "".concat(documentsUrl(apiBaseUrl), "/").concat(documentId);
|
|
21
|
-
};
|
|
22
|
-
var documentActionUrl = function documentActionUrl(_ref2) {
|
|
23
|
-
var apiBaseUrl = _ref2.apiBaseUrl,
|
|
24
|
-
documentId = _ref2.documentId,
|
|
25
|
-
_ref2$suffix = _ref2.suffix,
|
|
26
|
-
suffix = _ref2$suffix === void 0 ? "" : _ref2$suffix;
|
|
27
|
-
return "".concat(documentUrl({
|
|
28
|
-
apiBaseUrl: apiBaseUrl,
|
|
29
|
-
documentId: documentId
|
|
30
|
-
})).concat(suffix);
|
|
31
|
-
};
|
|
32
|
-
var normalizeResponse = /*#__PURE__*/function () {
|
|
33
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(request) {
|
|
34
|
-
var _response$data;
|
|
35
|
-
var response;
|
|
36
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
37
|
-
while (1) switch (_context.prev = _context.next) {
|
|
38
|
-
case 0:
|
|
39
|
-
_context.next = 2;
|
|
40
|
-
return request;
|
|
41
|
-
case 2:
|
|
42
|
-
response = _context.sent;
|
|
43
|
-
return _context.abrupt("return", (_response$data = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data !== void 0 ? _response$data : response);
|
|
44
|
-
case 4:
|
|
45
|
-
case "end":
|
|
46
|
-
return _context.stop();
|
|
47
|
-
}
|
|
48
|
-
}, _callee);
|
|
49
|
-
}));
|
|
50
|
-
return function normalizeResponse(_x) {
|
|
51
|
-
return _ref3.apply(this, arguments);
|
|
52
|
-
};
|
|
53
|
-
}();
|
|
54
|
-
var list = function list(_ref4) {
|
|
55
|
-
var apiBaseUrl = _ref4.apiBaseUrl,
|
|
56
|
-
ownerId = _ref4.ownerId;
|
|
57
|
-
return normalizeResponse(axios.get(documentsUrl(apiBaseUrl), {
|
|
58
|
-
params: {
|
|
59
|
-
ownerId: ownerId
|
|
60
|
-
}
|
|
61
|
-
}));
|
|
62
|
-
};
|
|
63
|
-
var show = function show(_ref5) {
|
|
64
|
-
var apiBaseUrl = _ref5.apiBaseUrl,
|
|
65
|
-
ownerId = _ref5.ownerId,
|
|
66
|
-
documentId = _ref5.documentId;
|
|
67
|
-
return normalizeResponse(axios.get(documentUrl({
|
|
68
|
-
apiBaseUrl: apiBaseUrl,
|
|
69
|
-
documentId: documentId
|
|
70
|
-
}), {
|
|
71
|
-
params: {
|
|
72
|
-
ownerId: ownerId
|
|
73
|
-
}
|
|
74
|
-
}));
|
|
75
|
-
};
|
|
76
|
-
var create = function create(_ref6) {
|
|
77
|
-
var _file$name2, _file$name2$trim;
|
|
78
|
-
var apiBaseUrl = _ref6.apiBaseUrl,
|
|
79
|
-
ownerId = _ref6.ownerId,
|
|
80
|
-
file = _ref6.file;
|
|
81
|
-
if (file !== null && file !== void 0 && file.signedId) {
|
|
82
|
-
var _file$name;
|
|
83
|
-
return normalizeResponse(axios.post(documentsUrl(apiBaseUrl), {
|
|
84
|
-
template_file: file.signedId,
|
|
85
|
-
name: (_file$name = file.name) === null || _file$name === void 0 ? void 0 : _file$name.replace(/\.[^/.]+$/, "")
|
|
86
|
-
}, {
|
|
87
|
-
params: {
|
|
88
|
-
ownerId: ownerId
|
|
89
|
-
}
|
|
90
|
-
}));
|
|
91
|
-
}
|
|
92
|
-
var formData = new FormData();
|
|
93
|
-
var sanitizedName = file === null || file === void 0 || (_file$name2 = file.name) === null || _file$name2 === void 0 || (_file$name2$trim = _file$name2.trim) === null || _file$name2$trim === void 0 ? void 0 : _file$name2$trim.call(_file$name2).replace(/\.[^/.]+$/, "");
|
|
94
|
-
var baseName = sanitizedName || "";
|
|
95
|
-
formData.append("template_file", file);
|
|
96
|
-
formData.append("name", baseName);
|
|
97
|
-
return normalizeResponse(axios.post(documentsUrl(apiBaseUrl), formData, {
|
|
98
|
-
params: {
|
|
99
|
-
ownerId: ownerId
|
|
100
|
-
}
|
|
101
|
-
}));
|
|
102
|
-
};
|
|
103
|
-
var update = function update(_ref7) {
|
|
104
|
-
var apiBaseUrl = _ref7.apiBaseUrl,
|
|
105
|
-
ownerId = _ref7.ownerId,
|
|
106
|
-
documentId = _ref7.documentId,
|
|
107
|
-
payload = _ref7.payload;
|
|
108
|
-
return normalizeResponse(axios.put(documentUrl({
|
|
109
|
-
apiBaseUrl: apiBaseUrl,
|
|
110
|
-
documentId: documentId
|
|
111
|
-
}), payload, {
|
|
112
|
-
params: {
|
|
113
|
-
ownerId: ownerId
|
|
114
|
-
}
|
|
115
|
-
}));
|
|
116
|
-
};
|
|
117
|
-
var updateTemplateFile = function updateTemplateFile(_ref8) {
|
|
118
|
-
var apiBaseUrl = _ref8.apiBaseUrl,
|
|
119
|
-
ownerId = _ref8.ownerId,
|
|
120
|
-
documentId = _ref8.documentId,
|
|
121
|
-
file = _ref8.file;
|
|
122
|
-
if (file !== null && file !== void 0 && file.signedId) {
|
|
123
|
-
return normalizeResponse(axios.patch(documentActionUrl({
|
|
124
|
-
apiBaseUrl: apiBaseUrl,
|
|
125
|
-
documentId: documentId,
|
|
126
|
-
suffix: "/template_file"
|
|
127
|
-
}), {
|
|
128
|
-
template_file: file.signedId
|
|
129
|
-
}, {
|
|
130
|
-
params: {
|
|
131
|
-
ownerId: ownerId
|
|
132
|
-
}
|
|
133
|
-
}));
|
|
134
|
-
}
|
|
135
|
-
var formData = new FormData();
|
|
136
|
-
formData.append("template_file", file);
|
|
137
|
-
return normalizeResponse(axios.patch(documentActionUrl({
|
|
138
|
-
apiBaseUrl: apiBaseUrl,
|
|
139
|
-
documentId: documentId,
|
|
140
|
-
suffix: "/template_file"
|
|
141
|
-
}), formData, {
|
|
142
|
-
params: {
|
|
143
|
-
ownerId: ownerId
|
|
144
|
-
}
|
|
145
|
-
}));
|
|
146
|
-
};
|
|
147
|
-
var clone = function clone(_ref9) {
|
|
148
|
-
var apiBaseUrl = _ref9.apiBaseUrl,
|
|
149
|
-
ownerId = _ref9.ownerId,
|
|
150
|
-
documentId = _ref9.documentId;
|
|
151
|
-
return normalizeResponse(axios.post(documentActionUrl({
|
|
152
|
-
apiBaseUrl: apiBaseUrl,
|
|
153
|
-
documentId: documentId,
|
|
154
|
-
suffix: "/clone"
|
|
155
|
-
}), null, {
|
|
156
|
-
params: {
|
|
157
|
-
ownerId: ownerId
|
|
158
|
-
}
|
|
159
|
-
}));
|
|
160
|
-
};
|
|
161
|
-
var destroy = function destroy(_ref0) {
|
|
162
|
-
var apiBaseUrl = _ref0.apiBaseUrl,
|
|
163
|
-
ownerId = _ref0.ownerId,
|
|
164
|
-
documentId = _ref0.documentId;
|
|
165
|
-
return normalizeResponse(axios["delete"](documentUrl({
|
|
166
|
-
apiBaseUrl: apiBaseUrl,
|
|
167
|
-
documentId: documentId
|
|
168
|
-
}), {
|
|
169
|
-
params: {
|
|
170
|
-
ownerId: ownerId
|
|
171
|
-
}
|
|
172
|
-
}));
|
|
173
|
-
};
|
|
174
|
-
var pdfDocumentsApi = {
|
|
175
|
-
clone: clone,
|
|
176
|
-
create: create,
|
|
177
|
-
update: update,
|
|
178
|
-
updateTemplateFile: updateTemplateFile,
|
|
179
|
-
destroy: destroy,
|
|
180
|
-
list: list,
|
|
181
|
-
show: show
|
|
182
|
-
};
|
|
7
|
+
var pdf_documents = require('./pdf_documents-PKt4xiTc.js');
|
|
183
8
|
|
|
184
9
|
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; }
|
|
185
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -204,7 +29,7 @@ var useFetchPdfDocuments = function useFetchPdfDocuments(_ref) {
|
|
|
204
29
|
return reactQuery.useQuery(_objectSpread({
|
|
205
30
|
queryKey: documentKeys(ownerId, apiBaseUrl),
|
|
206
31
|
queryFn: function queryFn() {
|
|
207
|
-
return pdfDocumentsApi.list({
|
|
32
|
+
return pdf_documents.pdfDocumentsApi.list({
|
|
208
33
|
apiBaseUrl: apiBaseUrl,
|
|
209
34
|
ownerId: ownerId
|
|
210
35
|
});
|
|
@@ -221,7 +46,7 @@ var useFetchPdfDocument = function useFetchPdfDocument(_ref2) {
|
|
|
221
46
|
return reactQuery.useQuery(_objectSpread({
|
|
222
47
|
queryKey: [].concat(_toConsumableArray(documentKeys(ownerId, apiBaseUrl)), [documentId]),
|
|
223
48
|
queryFn: function queryFn() {
|
|
224
|
-
return pdfDocumentsApi.show({
|
|
49
|
+
return pdf_documents.pdfDocumentsApi.show({
|
|
225
50
|
apiBaseUrl: apiBaseUrl,
|
|
226
51
|
ownerId: ownerId,
|
|
227
52
|
documentId: documentId
|
|
@@ -236,7 +61,7 @@ var useCreatePdfDocument = function useCreatePdfDocument(_ref3) {
|
|
|
236
61
|
_ref3$options = _ref3.options,
|
|
237
62
|
options = _ref3$options === void 0 ? {} : _ref3$options;
|
|
238
63
|
return useInvalidatingMutation(function (file) {
|
|
239
|
-
return pdfDocumentsApi.create({
|
|
64
|
+
return pdf_documents.pdfDocumentsApi.create({
|
|
240
65
|
apiBaseUrl: apiBaseUrl,
|
|
241
66
|
ownerId: ownerId,
|
|
242
67
|
file: file
|
|
@@ -251,7 +76,7 @@ var useUpdatePdfDocument = function useUpdatePdfDocument(_ref4) {
|
|
|
251
76
|
return useInvalidatingMutation(function (_ref5) {
|
|
252
77
|
var documentId = _ref5.documentId,
|
|
253
78
|
payload = _ref5.payload;
|
|
254
|
-
return pdfDocumentsApi.update({
|
|
79
|
+
return pdf_documents.pdfDocumentsApi.update({
|
|
255
80
|
apiBaseUrl: apiBaseUrl,
|
|
256
81
|
ownerId: ownerId,
|
|
257
82
|
documentId: documentId,
|
|
@@ -267,7 +92,7 @@ var useUpdatePdfDocumentTemplateFile = function useUpdatePdfDocumentTemplateFile
|
|
|
267
92
|
return useInvalidatingMutation(function (_ref7) {
|
|
268
93
|
var documentId = _ref7.documentId,
|
|
269
94
|
file = _ref7.file;
|
|
270
|
-
return pdfDocumentsApi.updateTemplateFile({
|
|
95
|
+
return pdf_documents.pdfDocumentsApi.updateTemplateFile({
|
|
271
96
|
apiBaseUrl: apiBaseUrl,
|
|
272
97
|
ownerId: ownerId,
|
|
273
98
|
documentId: documentId,
|
|
@@ -281,7 +106,7 @@ var useClonePdfDocument = function useClonePdfDocument(_ref8) {
|
|
|
281
106
|
_ref8$options = _ref8.options,
|
|
282
107
|
options = _ref8$options === void 0 ? {} : _ref8$options;
|
|
283
108
|
return useInvalidatingMutation(function (documentId) {
|
|
284
|
-
return pdfDocumentsApi.clone({
|
|
109
|
+
return pdf_documents.pdfDocumentsApi.clone({
|
|
285
110
|
apiBaseUrl: apiBaseUrl,
|
|
286
111
|
ownerId: ownerId,
|
|
287
112
|
documentId: documentId
|
|
@@ -294,7 +119,7 @@ var useDeletePdfDocument = function useDeletePdfDocument(_ref9) {
|
|
|
294
119
|
_ref9$options = _ref9.options,
|
|
295
120
|
options = _ref9$options === void 0 ? {} : _ref9$options;
|
|
296
121
|
return useInvalidatingMutation(function (documentId) {
|
|
297
|
-
return pdfDocumentsApi.destroy({
|
|
122
|
+
return pdf_documents.pdfDocumentsApi.destroy({
|
|
298
123
|
apiBaseUrl: apiBaseUrl,
|
|
299
124
|
ownerId: ownerId,
|
|
300
125
|
documentId: documentId
|
|
@@ -322,4 +147,4 @@ exports.useFetchPdfDocument = useFetchPdfDocument;
|
|
|
322
147
|
exports.useFetchPdfDocuments = useFetchPdfDocuments;
|
|
323
148
|
exports.useUpdatePdfDocument = useUpdatePdfDocument;
|
|
324
149
|
exports.useUpdatePdfDocumentTemplateFile = useUpdatePdfDocumentTemplateFile;
|
|
325
|
-
//# sourceMappingURL=FilenameUtilities-
|
|
150
|
+
//# sourceMappingURL=FilenameUtilities-Di7TmEIR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilenameUtilities-Di7TmEIR.js","sources":["../app/javascript/src/hooks/usePdfDocumentsApi.js","../app/javascript/src/components/PdfDocuments/FilenameUtilities.js"],"sourcesContent":["import { useQuery } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/react-utils\";\n\nimport pdfDocumentsApi from \"src/apis/pdf_documents\";\n\nconst documentKeys = (ownerId, apiBaseUrl) => [\n \"neeto-pdf-documents\",\n apiBaseUrl,\n ownerId,\n];\n\nconst useInvalidatingMutation = (\n mutationFn,\n ownerId,\n apiBaseUrl,\n options = {}\n) =>\n useMutationWithInvalidation(mutationFn, {\n keysToInvalidate: [documentKeys(ownerId, apiBaseUrl)],\n ...options,\n });\n\nexport const getPdfDocumentApiErrorMessage = (error, fallback) =>\n error?.response?.data?.error || fallback;\n\nexport const useFetchPdfDocuments = ({ apiBaseUrl, ownerId, options = {} }) =>\n useQuery({\n queryKey: documentKeys(ownerId, apiBaseUrl),\n queryFn: () => pdfDocumentsApi.list({ apiBaseUrl, ownerId }),\n enabled: Boolean(apiBaseUrl && ownerId),\n ...options,\n });\n\nexport const useFetchPdfDocument = ({\n apiBaseUrl,\n ownerId,\n documentId,\n options = {},\n}) =>\n useQuery({\n queryKey: [...documentKeys(ownerId, apiBaseUrl), documentId],\n queryFn: () => pdfDocumentsApi.show({ apiBaseUrl, ownerId, documentId }),\n enabled: Boolean(apiBaseUrl && ownerId && documentId),\n ...options,\n });\n\nexport const useCreatePdfDocument = ({ apiBaseUrl, ownerId, options = {} }) =>\n useInvalidatingMutation(\n file => pdfDocumentsApi.create({ apiBaseUrl, ownerId, file }),\n ownerId,\n apiBaseUrl,\n options\n );\n\nexport const useUpdatePdfDocument = ({ apiBaseUrl, ownerId, options = {} }) =>\n useInvalidatingMutation(\n ({ documentId, payload }) =>\n pdfDocumentsApi.update({ apiBaseUrl, ownerId, documentId, payload }),\n ownerId,\n apiBaseUrl,\n options\n );\n\nexport const useUpdatePdfDocumentTemplateFile = ({\n apiBaseUrl,\n ownerId,\n options = {},\n}) =>\n useInvalidatingMutation(\n ({ documentId, file }) =>\n pdfDocumentsApi.updateTemplateFile({\n apiBaseUrl,\n ownerId,\n documentId,\n file,\n }),\n ownerId,\n apiBaseUrl,\n options\n );\n\nexport const useClonePdfDocument = ({ apiBaseUrl, ownerId, options = {} }) =>\n useInvalidatingMutation(\n documentId => pdfDocumentsApi.clone({ apiBaseUrl, ownerId, documentId }),\n ownerId,\n apiBaseUrl,\n options\n );\n\nexport const useDeletePdfDocument = ({ apiBaseUrl, ownerId, options = {} }) =>\n useInvalidatingMutation(\n documentId => pdfDocumentsApi.destroy({ apiBaseUrl, ownerId, documentId }),\n ownerId,\n apiBaseUrl,\n options\n );\n","export const buildOutputFilenameTemplate = name => {\n const parameterizedName = (name || \"\")\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n\n return `${parameterizedName || \"document\"}-{{id}}.pdf`;\n};\n\nexport const buildOutputFilename = (pdfDocument, submission) => {\n const base =\n pdfDocument?.outputFilename || `${pdfDocument?.name || \"document\"}.pdf`;\n const withId = base.replace(/\\{\\{\\s*id\\s*\\}\\}/g, submission?.id || \"\");\n\n return withId.endsWith(\".pdf\") ? withId : `${withId}.pdf`;\n};\n"],"names":["documentKeys","ownerId","apiBaseUrl","useInvalidatingMutation","mutationFn","options","arguments","length","undefined","useMutationWithInvalidation","_objectSpread","keysToInvalidate","getPdfDocumentApiErrorMessage","error","fallback","_error$response","response","data","useFetchPdfDocuments","_ref","_ref$options","useQuery","queryKey","queryFn","pdfDocumentsApi","list","enabled","Boolean","useFetchPdfDocument","_ref2","documentId","_ref2$options","concat","_toConsumableArray","show","useCreatePdfDocument","_ref3","_ref3$options","file","create","useUpdatePdfDocument","_ref4","_ref4$options","_ref5","payload","update","useUpdatePdfDocumentTemplateFile","_ref6","_ref6$options","_ref7","updateTemplateFile","useClonePdfDocument","_ref8","_ref8$options","clone","useDeletePdfDocument","_ref9","_ref9$options","destroy","buildOutputFilenameTemplate","name","parameterizedName","trim","toLowerCase","replace","buildOutputFilename","pdfDocument","submission","base","outputFilename","withId","id","endsWith"],"mappings":";;;;;;;;;;AAKA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,CAAIC,OAAO,EAAEC,UAAU,EAAA;AAAA,EAAA,OAAK,CAC5C,qBAAqB,EACrBA,UAAU,EACVD,OAAO,CACR;AAAA,CAAA;AAED,IAAME,uBAAuB,GAAG,SAA1BA,uBAAuBA,CAC3BC,UAAU,EACVH,OAAO,EACPC,UAAU,EAAA;AAAA,EAAA,IACVG,OAAO,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE;AAAA,EAAA,OAEZG,sCAA2B,CAACL,UAAU,EAAAM,aAAA,CAAA;AACpCC,IAAAA,gBAAgB,EAAE,CAACX,YAAY,CAACC,OAAO,EAAEC,UAAU,CAAC;GAAC,EAClDG,OAAO,CACX,CAAC;AAAA,CAAA;AAEG,IAAMO,6BAA6B,GAAG,SAAhCA,6BAA6BA,CAAIC,KAAK,EAAEC,QAAQ,EAAA;AAAA,EAAA,IAAAC,eAAA;EAAA,OAC3D,CAAAF,KAAK,KAAA,IAAA,IAALA,KAAK,KAAA,MAAA,IAAA,CAAAE,eAAA,GAAL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