@nkhang1902/strapi-plugin-export-import-clsx 1.4.1 → 1.4.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.
|
@@ -6,7 +6,6 @@ import { Download, Upload } from "@strapi/icons";
|
|
|
6
6
|
import { useNotification } from "@strapi/strapi/admin";
|
|
7
7
|
|
|
8
8
|
const ExportImportButtons = (props) => {
|
|
9
|
-
const { isExpParticipantsExporting } = props;
|
|
10
9
|
const [isExporting, setIsExporting] = useState(false);
|
|
11
10
|
const [isImporting, setIsImporting] = useState(false);
|
|
12
11
|
const { toggleNotification } = useNotification();
|
|
@@ -42,32 +42,6 @@ const ExportButtonsEditView = (props) => {
|
|
|
42
42
|
return null;
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
// Get event filter for event manager - simplified with exclude list
|
|
46
|
-
const getEventFilter = () => {
|
|
47
|
-
const path = window.location.pathname;
|
|
48
|
-
const eventManagerMatch = path.match(
|
|
49
|
-
/\/admin\/plugins\/event-manager\/([^\/]+)\/([^\/]+)/
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
if (eventManagerMatch) {
|
|
53
|
-
const eventId = eventManagerMatch[1];
|
|
54
|
-
const collectionType = eventManagerMatch[2];
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
eventId &&
|
|
58
|
-
eventId !== "events" &&
|
|
59
|
-
allowedContentTypes.includes(collectionType)
|
|
60
|
-
) {
|
|
61
|
-
return {
|
|
62
|
-
eventId,
|
|
63
|
-
relationField: "event",
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return null;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
45
|
const currentContentType = getContentType();
|
|
72
46
|
|
|
73
47
|
const handleExport = async () => {
|
|
@@ -82,22 +56,22 @@ const ExportButtonsEditView = (props) => {
|
|
|
82
56
|
|
|
83
57
|
setIsExporting(true);
|
|
84
58
|
try {
|
|
85
|
-
const
|
|
86
|
-
|
|
59
|
+
const documentId = window.location.pathname.split('/').pop();
|
|
60
|
+
console.log(documentId)
|
|
87
61
|
const queryParams = new URLSearchParams({
|
|
88
62
|
format: "excel",
|
|
89
63
|
contentType: contentType,
|
|
90
64
|
});
|
|
91
65
|
|
|
92
66
|
// Add event filter if we're in event manager
|
|
93
|
-
if (
|
|
67
|
+
if (documentId) {
|
|
94
68
|
queryParams.set(
|
|
95
|
-
`filters[
|
|
96
|
-
|
|
69
|
+
`filters[documentId][$eq]`,
|
|
70
|
+
documentId
|
|
97
71
|
);
|
|
98
72
|
}
|
|
99
73
|
|
|
100
|
-
const response = await fetch(`/export-import-clsx/export?${queryParams}&mode=
|
|
74
|
+
const response = await fetch(`/export-import-clsx/export?${queryParams}&mode=participant`);
|
|
101
75
|
|
|
102
76
|
if (response.ok) {
|
|
103
77
|
const blob = await response.blob();
|
|
@@ -142,7 +116,7 @@ const ExportButtonsEditView = (props) => {
|
|
|
142
116
|
loading={isExporting}
|
|
143
117
|
startIcon={<Download />}
|
|
144
118
|
variant="secondary"
|
|
145
|
-
|
|
119
|
+
fullWidth
|
|
146
120
|
>
|
|
147
121
|
Export Participants
|
|
148
122
|
</Button>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nkhang1902/strapi-plugin-export-import-clsx",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
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": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module.exports = ({ strapi }) => ({
|
|
2
2
|
async export(ctx) {
|
|
3
3
|
try {
|
|
4
|
-
const { format = "excel", contentType, ...filters } = ctx.query;
|
|
4
|
+
const { format = "excel", contentType, mode, ...filters } = ctx.query;
|
|
5
5
|
const exportService = strapi
|
|
6
6
|
.plugin("export-import-clsx")
|
|
7
7
|
.service("export-service");
|
|
@@ -28,7 +28,8 @@ module.exports = ({ strapi }) => ({
|
|
|
28
28
|
const data = await exportService.exportData(
|
|
29
29
|
"json",
|
|
30
30
|
contentType,
|
|
31
|
-
filters
|
|
31
|
+
filters,
|
|
32
|
+
mode
|
|
32
33
|
);
|
|
33
34
|
|
|
34
35
|
const filename = `${
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const XLSX = require("xlsx");
|
|
2
2
|
|
|
3
3
|
module.exports = ({ strapi }) => ({
|
|
4
|
-
async exportData(format = "json", contentType = null, rawFilters = {}) {
|
|
4
|
+
async exportData(format = "json", contentType = null, rawFilters = {}, mode) {
|
|
5
5
|
// Normalize content type - handle both content-manager and event-manager formats
|
|
6
6
|
if (contentType && !contentType.startsWith("api::")) {
|
|
7
7
|
// If it's already in api:: format from event-manager, use as is
|
|
@@ -102,6 +102,7 @@ module.exports = ({ strapi }) => ({
|
|
|
102
102
|
} catch (error) {
|
|
103
103
|
strapi.log.error(`Failed to query entries:`, error);
|
|
104
104
|
}
|
|
105
|
+
console.log({entries})
|
|
105
106
|
|
|
106
107
|
strapi.log.info(
|
|
107
108
|
`Final result: ${
|