@nkhang1902/strapi-plugin-export-import-clsx 1.4.9 → 1.5.1
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.
|
@@ -79,7 +79,9 @@ const ExportButtonsEditView = (props) => {
|
|
|
79
79
|
const a = document.createElement("a");
|
|
80
80
|
a.href = url;
|
|
81
81
|
|
|
82
|
-
const filename =
|
|
82
|
+
const filename = response.headers
|
|
83
|
+
.get("Content-Disposition")
|
|
84
|
+
.split("filename=")[1];
|
|
83
85
|
|
|
84
86
|
a.download = filename;
|
|
85
87
|
document.body.appendChild(a);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nkhang1902/strapi-plugin-export-import-clsx",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "A powerful Strapi plugin for exporting and importing data with Excel support and advanced filtering",
|
|
5
5
|
"main": "./strapi-server.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,9 +15,19 @@ module.exports = ({ strapi }) => ({
|
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
const filename = `${
|
|
18
|
-
contentType?.
|
|
18
|
+
contentType?.split(".")[1]|| "strapi"
|
|
19
19
|
}-export-${new Date().toISOString().split("T")[0]}.xlsx`;
|
|
20
20
|
|
|
21
|
+
if (mode === "participant") {
|
|
22
|
+
const expName = await strapi.documents(contentType).findOne({
|
|
23
|
+
select: ["name"],
|
|
24
|
+
filters: {
|
|
25
|
+
documentId: ctx.query[`filters[documentId][$eq]`],
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
filename = `${expName.name}-participant-export-${new Date().toISOString().split("T")[0]}.xlsx`;
|
|
29
|
+
}
|
|
30
|
+
|
|
21
31
|
ctx.set(
|
|
22
32
|
"Content-Type",
|
|
23
33
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
@@ -40,7 +50,10 @@ module.exports = ({ strapi }) => ({
|
|
|
40
50
|
ctx.set("Content-Type", "application/json");
|
|
41
51
|
ctx.set("Content-Disposition", `attachment; filename="${filename}"`);
|
|
42
52
|
|
|
43
|
-
ctx.body = JSON.stringify(
|
|
53
|
+
ctx.body = JSON.stringify({
|
|
54
|
+
filename: filename,
|
|
55
|
+
data: data,
|
|
56
|
+
}, null, 2);
|
|
44
57
|
}
|
|
45
58
|
} catch (error) {
|
|
46
59
|
strapi.log.error("Export error:", error);
|
|
@@ -91,10 +91,29 @@ module.exports = ({ strapi }) => ({
|
|
|
91
91
|
strapi.log.info(`Parsed query filters: ${JSON.stringify(filters)}`);
|
|
92
92
|
|
|
93
93
|
try {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
if (mode === 'participant') {
|
|
95
|
+
entries = await strapi.documents(ct).findMany({
|
|
96
|
+
filters: { ...filters },
|
|
97
|
+
populate: {
|
|
98
|
+
corporates: true,
|
|
99
|
+
investors: {
|
|
100
|
+
populate: {
|
|
101
|
+
companyInformation: true,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
vipGuests: {
|
|
105
|
+
populate: {
|
|
106
|
+
companyInformation: true,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
} else {
|
|
112
|
+
entries = await strapi.documents(ct).findMany({
|
|
113
|
+
filters: { ...filters },
|
|
114
|
+
populate: "*",
|
|
115
|
+
});
|
|
116
|
+
}
|
|
98
117
|
strapi.log.info(
|
|
99
118
|
`EntityService found ${entries?.length || 0} entries`
|
|
100
119
|
);
|
|
@@ -402,7 +421,7 @@ module.exports = ({ strapi }) => ({
|
|
|
402
421
|
const participants = [
|
|
403
422
|
...tag(experienceData?.corporates, 'corporate'),
|
|
404
423
|
...tag(experienceData?.investors, 'investor'),
|
|
405
|
-
...tag(experienceData?.vipGuests, '
|
|
424
|
+
...tag(experienceData?.vipGuests, 'vipGuest'),
|
|
406
425
|
];
|
|
407
426
|
|
|
408
427
|
const data = participants.map((p) => ({
|
|
@@ -413,13 +432,13 @@ module.exports = ({ strapi }) => ({
|
|
|
413
432
|
p.fullName ??
|
|
414
433
|
[p.firstName, p.lastName].filter(Boolean).join(' ') ??
|
|
415
434
|
'',
|
|
416
|
-
|
|
417
|
-
lastName: p.lastName ?? '',
|
|
435
|
+
salutation: p.salutation ?? '',
|
|
418
436
|
businessEmail: p.businessEmail ?? '',
|
|
437
|
+
businessTitle: p.businessTitle ?? '',
|
|
438
|
+
companyName: p.companyInformation?.companyName ?? '',
|
|
419
439
|
mobile: p.mobile ?? '',
|
|
420
440
|
}));
|
|
421
441
|
|
|
422
|
-
console.log(data)
|
|
423
442
|
const worksheet = XLSX.utils.json_to_sheet(data);
|
|
424
443
|
XLSX.utils.book_append_sheet(
|
|
425
444
|
workbook,
|