datastake-daf 0.6.798 → 0.6.799
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/components/index.js +3158 -985
- package/dist/context/index.js +6 -6
- package/dist/pages/index.js +252 -13
- package/dist/services/index.js +112 -9
- package/dist/utils/index.js +14 -17
- package/package.json +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/hook.js +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/hook.js +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/AddUser/index.jsx +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/columns.js +79 -0
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/helper.js +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +18 -8
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/index.jsx +6 -6
- package/src/@daf/core/components/Screens/Admin/AdminModals/NewAccount/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +61 -38
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Accounts.jsx +1 -4
- package/src/@daf/core/components/Screens/Admin/AdminScreens/AccountsView.jsx +2 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Location.jsx +6 -7
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Subjects.jsx +2 -3
- package/src/@daf/core/components/Screens/Admin/AdminScreens/SubjectsView.jsx +395 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/index.js +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/column.js +223 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/helper.js +65 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +73 -45
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/columns.js +37 -37
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +48 -22
- package/src/@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/configTransformer.js +137 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.js +9 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.jsx +196 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/configTransformer.js +216 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.js +7 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.jsx +184 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/config.js +64 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/helpers.js +13 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/index.jsx +77 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/config.js +51 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/helpers.js +0 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/index.jsx +75 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +7 -1
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/SidebarMenu/index.jsx +5 -3
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/helper.js +13 -8
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +16 -10
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/View/index.jsx +2 -1
- package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +66 -26
- package/src/@daf/core/components/Screens/Admin/AppInvitation/index.jsx +193 -0
- package/src/@daf/core/components/Screens/Admin/adminRoutes.js +81 -2
- package/src/@daf/layouts/AppLayout/index.jsx +0 -1
- package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/columns.js +180 -0
- package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/config.js +0 -0
- package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/index.jsx +27 -0
- package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/columns.js +157 -0
- package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/config.js +31 -0
- package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/index.js +77 -0
- package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/columns.js +117 -0
- package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/index.jsx +54 -0
- package/src/@daf/pages/SelfAssesment/index.jsx +0 -0
- package/src/@daf/pages/View/hooks/usePrepareForm.js +11 -1
- package/src/@daf/pages/View/index.jsx +13 -2
- package/src/@daf/services/AdminService.js +111 -7
- package/src/@daf/services/AuthenticationService.js +1 -0
- package/src/@daf/services/DashboardService.js +2 -1
- package/src/@daf/utils/filters.js +15 -13
- package/src/constants/locales/en/translation.js +7 -0
- package/src/constants/locales/fr/translation.js +1 -1
- package/src/constants/locales/sp/translation.js +1 -1
- package/src/index.js +1 -0
- package/build/favicon.ico +0 -0
- package/build/logo192.png +0 -0
- package/build/logo512.png +0 -0
- package/build/manifest.json +0 -25
- package/build/robots.txt +0 -3
|
@@ -2,7 +2,7 @@ import { useState, useMemo } from "react";
|
|
|
2
2
|
import { useAdminTable } from "../hook";
|
|
3
3
|
import AdminTable from "../components/index.jsx";
|
|
4
4
|
import DAFTable from "../../../../Table/index.jsx";
|
|
5
|
-
import { theme, Tag } from "antd";
|
|
5
|
+
import { theme, Tag, message } from "antd";
|
|
6
6
|
import CustomIcon from "../../../../Icon/CustomIcon.jsx";
|
|
7
7
|
import {
|
|
8
8
|
getTabs,
|
|
@@ -10,9 +10,10 @@ import {
|
|
|
10
10
|
filtersConfig,
|
|
11
11
|
defaultUrlParams,
|
|
12
12
|
checkboxConfig,
|
|
13
|
-
} from "
|
|
14
|
-
import { getColumns } from "
|
|
13
|
+
} from "./helper.js";
|
|
14
|
+
import { getColumns } from "./column.js";
|
|
15
15
|
import CombineLocationModal from "../../AdminModals/CombineLocation/index.jsx";
|
|
16
|
+
|
|
16
17
|
const { useToken } = theme;
|
|
17
18
|
|
|
18
19
|
export default function LocationTable({
|
|
@@ -28,14 +29,49 @@ export default function LocationTable({
|
|
|
28
29
|
view,
|
|
29
30
|
headerTitle,
|
|
30
31
|
breadcrumbs,
|
|
31
|
-
|
|
32
|
+
mergeLocationsFunction,
|
|
32
33
|
refetchTrigger,
|
|
33
34
|
}) {
|
|
34
35
|
const [showFilters, setShowFilters] = useState(false);
|
|
35
36
|
const [hasError, setHasError] = useState(false);
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
37
|
+
|
|
38
|
+
const [selectedLocations, setSelectedLocations] = useState([]);
|
|
39
|
+
|
|
40
|
+
const { token } = useToken();
|
|
41
|
+
const [isCombineModalOpen, setIsModalOpen] = useState(false);
|
|
42
|
+
|
|
43
|
+
const getDataWithStringPagination = async ({ params }) => {
|
|
44
|
+
const { pagination, tab, filters, search, sort, ...otherParams } = params;
|
|
45
|
+
|
|
46
|
+
let paginationObj = { page: 1, pageSize: 20 };
|
|
47
|
+
if (pagination) {
|
|
48
|
+
try {
|
|
49
|
+
paginationObj = typeof pagination === 'string' ? JSON.parse(pagination) : pagination;
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.error('Failed to parse pagination', e);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let activeTab = tab || "active";
|
|
56
|
+
if (!tab && filters) {
|
|
57
|
+
try {
|
|
58
|
+
const parsedFilters = typeof filters === 'string' ? JSON.parse(filters) : filters;
|
|
59
|
+
activeTab = parsedFilters.activeTab || "active";
|
|
60
|
+
} catch (e) {
|
|
61
|
+
activeTab = "active";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const transformedParams = {
|
|
66
|
+
pagination: {
|
|
67
|
+
skip: String(paginationObj.page || 1),
|
|
68
|
+
take: String(paginationObj.pageSize || 20),
|
|
69
|
+
},
|
|
70
|
+
tab: activeTab,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return getData({ params: transformedParams });
|
|
74
|
+
};
|
|
39
75
|
|
|
40
76
|
const {
|
|
41
77
|
filter,
|
|
@@ -58,7 +94,7 @@ export default function LocationTable({
|
|
|
58
94
|
defaultPageSize,
|
|
59
95
|
filtersConfig,
|
|
60
96
|
getRedirectLink,
|
|
61
|
-
getData,
|
|
97
|
+
getData: getDataWithStringPagination,
|
|
62
98
|
refetchTrigger,
|
|
63
99
|
});
|
|
64
100
|
|
|
@@ -66,7 +102,7 @@ export default function LocationTable({
|
|
|
66
102
|
return {
|
|
67
103
|
category: config.options?.category,
|
|
68
104
|
country: config.options?.countries,
|
|
69
|
-
sources: [],
|
|
105
|
+
sources: [],
|
|
70
106
|
};
|
|
71
107
|
}, [config.options]);
|
|
72
108
|
|
|
@@ -76,7 +112,7 @@ export default function LocationTable({
|
|
|
76
112
|
goTo,
|
|
77
113
|
token,
|
|
78
114
|
module,
|
|
79
|
-
selectedLocations,
|
|
115
|
+
selectedLocations,
|
|
80
116
|
setSelectedLocations,
|
|
81
117
|
getRedirectLink,
|
|
82
118
|
selectOptions,
|
|
@@ -93,8 +129,8 @@ export default function LocationTable({
|
|
|
93
129
|
actionButton={[
|
|
94
130
|
{
|
|
95
131
|
icon: "Merge",
|
|
96
|
-
onClick: () =>
|
|
97
|
-
tooltip: "
|
|
132
|
+
onClick: () => setIsModalOpen(true),
|
|
133
|
+
tooltip: t("admin::merge-locations"),
|
|
98
134
|
disabled: selectedLocations.length < 2,
|
|
99
135
|
},
|
|
100
136
|
]}
|
|
@@ -112,25 +148,15 @@ export default function LocationTable({
|
|
|
112
148
|
breadcrumbs={breadcrumbs}
|
|
113
149
|
>
|
|
114
150
|
{selectedLocations.length > 0 && (
|
|
115
|
-
<div
|
|
116
|
-
className="flex flex-row ml-6 mt-5"
|
|
117
|
-
style={{
|
|
118
|
-
flexWrap: "wrap",
|
|
119
|
-
gap: "8px",
|
|
120
|
-
}}
|
|
121
|
-
>
|
|
151
|
+
<div className="flex flex-row ml-6 mt-5" style={{ flexWrap: "wrap", gap: "8px" }}>
|
|
122
152
|
{selectedLocations.map((account) => (
|
|
123
153
|
<Tag
|
|
124
154
|
key={account.userId}
|
|
125
155
|
className="flex flex-row gap-2 items-center"
|
|
126
156
|
onClick={() =>
|
|
127
|
-
setSelectedLocations((prev) =>
|
|
128
|
-
prev.filter((a) => a.datastakeId !== account.datastakeId),
|
|
129
|
-
)
|
|
157
|
+
setSelectedLocations((prev) => prev.filter((a) => a.datastakeId !== account.datastakeId))
|
|
130
158
|
}
|
|
131
|
-
style={{
|
|
132
|
-
cursor: "pointer",
|
|
133
|
-
}}
|
|
159
|
+
style={{ cursor: "pointer" }}
|
|
134
160
|
>
|
|
135
161
|
<span>{account.datastakeId}</span>
|
|
136
162
|
<CustomIcon name="Close" size={10} />
|
|
@@ -156,25 +182,27 @@ export default function LocationTable({
|
|
|
156
182
|
/>
|
|
157
183
|
</AdminTable>
|
|
158
184
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
setSelectedLocations([])
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
185
|
+
<CombineLocationModal
|
|
186
|
+
isOpen={isCombineModalOpen}
|
|
187
|
+
t={t}
|
|
188
|
+
onClose={() => setIsModalOpen(false)}
|
|
189
|
+
onSuccess={(data) => {
|
|
190
|
+
console.log("Modal Success triggered", data); // 1. Check if this logs
|
|
191
|
+
console.log("Is function?", typeof mergeLocationsFunction);
|
|
192
|
+
setIsModalOpen(false);
|
|
193
|
+
setLoading(true);
|
|
194
|
+
if (typeof mergeLocationsFunction === 'function') {
|
|
195
|
+
mergeLocationsFunction(data).finally(() => {
|
|
196
|
+
setSelectedLocations([]);
|
|
197
|
+
fetchData();
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}}
|
|
201
|
+
selectedLocations={selectedLocations}
|
|
202
|
+
selectOptions={selectOptions}
|
|
203
|
+
module={module}
|
|
204
|
+
entity={headerTitle}
|
|
205
|
+
/>
|
|
178
206
|
</>
|
|
179
207
|
);
|
|
180
|
-
}
|
|
208
|
+
}
|
|
@@ -104,48 +104,48 @@ export const getColumns = ({
|
|
|
104
104
|
return <Tooltip title={country}>{country}</Tooltip>;
|
|
105
105
|
},
|
|
106
106
|
},
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
107
|
+
{
|
|
108
|
+
title: t("Admin Level 1"),
|
|
109
|
+
dataIndex: "administrativeLevel1",
|
|
110
|
+
key: "administrativeLevel1",
|
|
111
|
+
ellipsis: true,
|
|
112
|
+
show: entity.includes("location"),
|
|
113
|
+
render: (value, all) => {
|
|
114
|
+
if (all.empty) {
|
|
115
|
+
return <div className="daf-default-cell" />;
|
|
116
|
+
}
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
let label;
|
|
119
|
+
if(all?.administrativeLevel1 && value === all?.administrativeLevel1) {
|
|
120
|
+
label = all?.linking?.SCL?.[value]?.name
|
|
121
|
+
} else {
|
|
122
|
+
label = getNameByLevel(all?.linking?.SCL, "level_1")?.name
|
|
123
|
+
}
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
},
|
|
125
|
+
return <Tooltip title={label || '-'}>{label || '-'}</Tooltip>;
|
|
127
126
|
},
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
title: t("Admin Level 2"),
|
|
130
|
+
dataIndex: "administrativeLevel2",
|
|
131
|
+
key: "administrativeLevel2",
|
|
132
|
+
show: entity.includes("location"),
|
|
133
|
+
ellipsis: true,
|
|
134
|
+
render: (value, all) => {
|
|
135
|
+
if (all.empty) {
|
|
136
|
+
return <div className="daf-default-cell" />;
|
|
137
|
+
}
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
139
|
+
let label;
|
|
140
|
+
if(all?.administrativeLevel2 && value === all?.administrativeLevel2) {
|
|
141
|
+
label = all?.linking?.SCL?.[value]?.name
|
|
142
|
+
} else {
|
|
143
|
+
label = getNameByLevel(all?.linking?.SCL, "level_2")?.name
|
|
144
|
+
}
|
|
145
145
|
|
|
146
|
-
|
|
147
|
-
},
|
|
146
|
+
return <Tooltip title={label || '-'}>{label || '-'}</Tooltip>;
|
|
148
147
|
},
|
|
148
|
+
},
|
|
149
149
|
{
|
|
150
150
|
title: t("Sources"),
|
|
151
151
|
dataIndex: "sources",
|
|
@@ -210,7 +210,7 @@ export const getColumns = ({
|
|
|
210
210
|
<div
|
|
211
211
|
className="cursor-pointer"
|
|
212
212
|
onClick={() => {
|
|
213
|
-
goTo(getRedirectLink(`/app/
|
|
213
|
+
goTo(getRedirectLink(`/app/view/management-stakeholder/${all.id}`));
|
|
214
214
|
}}
|
|
215
215
|
>
|
|
216
216
|
<CustomIcon name="Link" width={18} height={18} />
|
|
@@ -2,7 +2,7 @@ import { useState, useMemo } from "react";
|
|
|
2
2
|
import { useAdminTable } from "../hook";
|
|
3
3
|
import AdminTable from "../components/index.jsx";
|
|
4
4
|
import DAFTable from "../../../../Table/index.jsx";
|
|
5
|
-
import { theme, Tag } from "antd";
|
|
5
|
+
import { theme, Tag, message } from "antd";
|
|
6
6
|
import CustomIcon from "../../../../Icon/CustomIcon.jsx";
|
|
7
7
|
import {
|
|
8
8
|
getTabs,
|
|
@@ -38,6 +38,41 @@ export default function SubjectsTable({
|
|
|
38
38
|
const { token } = useToken();
|
|
39
39
|
const [isCombineModalOpen, setIsModalOpen] = useState(false);
|
|
40
40
|
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
const getDataWithStringPagination = async ({ params }) => {
|
|
45
|
+
const { pagination, tab, filters, search, sort, ...otherParams } = params;
|
|
46
|
+
|
|
47
|
+
let paginationObj = { page: 1, pageSize: 20 };
|
|
48
|
+
if (pagination) {
|
|
49
|
+
try {
|
|
50
|
+
paginationObj = typeof pagination === 'string' ? JSON.parse(pagination) : pagination;
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.error('Failed to parse pagination', e);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let activeTab = tab || "active";
|
|
57
|
+
if (!tab && filters) {
|
|
58
|
+
try {
|
|
59
|
+
const parsedFilters = typeof filters === 'string' ? JSON.parse(filters) : filters;
|
|
60
|
+
activeTab = parsedFilters.activeTab || "active";
|
|
61
|
+
} catch (e) {
|
|
62
|
+
activeTab = "active";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const transformedParams = {
|
|
67
|
+
pagination: {
|
|
68
|
+
skip: String(paginationObj.page || 1),
|
|
69
|
+
take: String(paginationObj.pageSize || 20),
|
|
70
|
+
},
|
|
71
|
+
tab: activeTab,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return getData({ params: transformedParams });
|
|
75
|
+
};
|
|
41
76
|
const {
|
|
42
77
|
filter,
|
|
43
78
|
activeTab,
|
|
@@ -59,7 +94,7 @@ export default function SubjectsTable({
|
|
|
59
94
|
defaultPageSize,
|
|
60
95
|
filtersConfig,
|
|
61
96
|
getRedirectLink,
|
|
62
|
-
getData,
|
|
97
|
+
getData: getDataWithStringPagination,
|
|
63
98
|
refetchTrigger,
|
|
64
99
|
});
|
|
65
100
|
|
|
@@ -67,7 +102,7 @@ export default function SubjectsTable({
|
|
|
67
102
|
return {
|
|
68
103
|
category: config.options?.category,
|
|
69
104
|
country: config.options?.countries,
|
|
70
|
-
sources: [],
|
|
105
|
+
sources: [],
|
|
71
106
|
};
|
|
72
107
|
}, [config.options]);
|
|
73
108
|
|
|
@@ -113,25 +148,15 @@ export default function SubjectsTable({
|
|
|
113
148
|
breadcrumbs={breadcrumbs}
|
|
114
149
|
>
|
|
115
150
|
{selectedSubjects.length > 0 && (
|
|
116
|
-
<div
|
|
117
|
-
className="flex flex-row ml-6 mt-5"
|
|
118
|
-
style={{
|
|
119
|
-
flexWrap: "wrap",
|
|
120
|
-
gap: "8px",
|
|
121
|
-
}}
|
|
122
|
-
>
|
|
151
|
+
<div className="flex flex-row ml-6 mt-5" style={{ flexWrap: "wrap", gap: "8px" }}>
|
|
123
152
|
{selectedSubjects.map((account) => (
|
|
124
153
|
<Tag
|
|
125
154
|
key={account.userId}
|
|
126
155
|
className="flex flex-row gap-2 items-center"
|
|
127
156
|
onClick={() =>
|
|
128
|
-
setSelectedSubjects((prev) =>
|
|
129
|
-
prev.filter((a) => a.datastakeId !== account.datastakeId),
|
|
130
|
-
)
|
|
157
|
+
setSelectedSubjects((prev) => prev.filter((a) => a.datastakeId !== account.datastakeId))
|
|
131
158
|
}
|
|
132
|
-
style={{
|
|
133
|
-
cursor: "pointer",
|
|
134
|
-
}}
|
|
159
|
+
style={{ cursor: "pointer" }}
|
|
135
160
|
>
|
|
136
161
|
<span>{account.datastakeId}</span>
|
|
137
162
|
<CustomIcon name="Close" size={10} />
|
|
@@ -160,19 +185,20 @@ export default function SubjectsTable({
|
|
|
160
185
|
<CombineSubjectsModal
|
|
161
186
|
isOpen={isCombineModalOpen}
|
|
162
187
|
t={t}
|
|
163
|
-
onClose={() =>
|
|
164
|
-
setIsModalOpen(false);
|
|
165
|
-
}}
|
|
188
|
+
onClose={() => setIsModalOpen(false)}
|
|
166
189
|
onSuccess={(data) => {
|
|
167
190
|
setIsModalOpen(false);
|
|
168
191
|
setLoading(true);
|
|
192
|
+
message.success(t("Subjects successfully merged."))
|
|
169
193
|
if (typeof mergeSubjectsFunction === 'function') {
|
|
170
|
-
mergeSubjectsFunction(data)
|
|
171
|
-
|
|
194
|
+
mergeSubjectsFunction(data).finally(() => {
|
|
195
|
+
setSelectedSubjects([]);
|
|
196
|
+
fetchData();
|
|
197
|
+
});
|
|
172
198
|
}
|
|
173
199
|
}}
|
|
174
200
|
selectedSubjects={selectedSubjects}
|
|
175
|
-
selectOptions={selectOptions
|
|
201
|
+
selectOptions={selectOptions}
|
|
176
202
|
module={module}
|
|
177
203
|
entity={headerTitle}
|
|
178
204
|
/>
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
|
|
2
|
+
export function transformConfigItem(item, formOptions = {}, t = (s) => s) {
|
|
3
|
+
const {
|
|
4
|
+
key,
|
|
5
|
+
label,
|
|
6
|
+
type,
|
|
7
|
+
optionsName,
|
|
8
|
+
level,
|
|
9
|
+
placeholder,
|
|
10
|
+
rules,
|
|
11
|
+
showFormIf,
|
|
12
|
+
disabled,
|
|
13
|
+
defaultValue,
|
|
14
|
+
meta: configMeta = {},
|
|
15
|
+
...rest
|
|
16
|
+
} = item;
|
|
17
|
+
|
|
18
|
+
const option = {
|
|
19
|
+
type: type || "text",
|
|
20
|
+
label: label,
|
|
21
|
+
meta: { ...configMeta },
|
|
22
|
+
...rest,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
if (placeholder) option.placeholder = placeholder;
|
|
26
|
+
if (rules && Array.isArray(rules)) option.rules = rules;
|
|
27
|
+
if (showFormIf) option.showFormIf = showFormIf;
|
|
28
|
+
if (disabled !== undefined) {
|
|
29
|
+
option.disabled = disabled;
|
|
30
|
+
option.meta.disableEdit = disabled;
|
|
31
|
+
}
|
|
32
|
+
if (defaultValue !== undefined) option.meta.defaultValue = defaultValue;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const mapOptions = (sourceKey) => {
|
|
36
|
+
if (sourceKey && formOptions[sourceKey]) {
|
|
37
|
+
return formOptions[sourceKey].map((opt) => {
|
|
38
|
+
if (typeof opt === 'object' && opt !== null) {
|
|
39
|
+
return {
|
|
40
|
+
value: opt.value,
|
|
41
|
+
label: t(opt.label || opt.value),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return { value: opt, label: t(opt) };
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return [];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
if (type === "select" || type === "multiselect") {
|
|
52
|
+
option.options = mapOptions(optionsName || level);
|
|
53
|
+
|
|
54
|
+
if (option.options.length === 0) {
|
|
55
|
+
console.warn(`No options found for field "${key}"`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (type === "multiselect") {
|
|
59
|
+
option.mode = "multiple";
|
|
60
|
+
option.type = "select";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (type === "ajaxSelect") {
|
|
65
|
+
const { entity, method, mapper, filters } = item;
|
|
66
|
+
|
|
67
|
+
if (!entity || !method || !mapper) {
|
|
68
|
+
console.error(`ajaxSelect field "${key}" is missing properties`);
|
|
69
|
+
option.type = "text";
|
|
70
|
+
option.disabled = true;
|
|
71
|
+
} else {
|
|
72
|
+
const filtersString = filters ? JSON.stringify(filters) : "{}";
|
|
73
|
+
const mapperString = JSON.stringify(mapper);
|
|
74
|
+
option.meta.call = `${entity}::${method}(${filtersString})::${mapperString}`;
|
|
75
|
+
option.type = "ajaxSelect";
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if (optionsName || level) {
|
|
79
|
+
option.options = mapOptions(optionsName || level);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (option.meta.noAddNew) {
|
|
83
|
+
option.onNewSetValue = false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (type === "administrative") {
|
|
89
|
+
option.type = "text";
|
|
90
|
+
option.disabled = true;
|
|
91
|
+
option.meta.disableEdit = false;
|
|
92
|
+
if (level) option.meta.level = level;
|
|
93
|
+
}
|
|
94
|
+
if (type === "switch" || type === "checkbox") {
|
|
95
|
+
option.type = type;
|
|
96
|
+
if (defaultValue === undefined) option.meta.defaultValue = false;
|
|
97
|
+
}
|
|
98
|
+
if (type === "date" || type === "datetime" || type === "year") option.type = type;
|
|
99
|
+
if (type === "textarea") {
|
|
100
|
+
option.type = "textarea";
|
|
101
|
+
option.rows = item.rows || 4;
|
|
102
|
+
}
|
|
103
|
+
if (type === "number") {
|
|
104
|
+
option.type = "text";
|
|
105
|
+
option.meta.inputType = "number";
|
|
106
|
+
}
|
|
107
|
+
if (option.position === undefined) option.position = 0;
|
|
108
|
+
|
|
109
|
+
return option;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function transformConfigToEditForm(conf, formOptions = {}, t = (s) => s) {
|
|
113
|
+
if (!conf || !conf.items || !Array.isArray(conf.items)) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const options = {};
|
|
118
|
+
conf.items.forEach((item, index) => {
|
|
119
|
+
const transformedOption = transformConfigItem(item, formOptions, t);
|
|
120
|
+
transformedOption.position = item.position !== undefined ? item.position : index;
|
|
121
|
+
options[item.key] = transformedOption;
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
id: conf.key || "edit-form",
|
|
126
|
+
introText: "",
|
|
127
|
+
formTitles: conf.formTitles || {},
|
|
128
|
+
options,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function getConfigFieldKeys(conf) {
|
|
133
|
+
if (!conf || !conf.items || !Array.isArray(conf.items)) {
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
return conf.items.map((item) => item.key);
|
|
137
|
+
}
|