datastake-daf 0.6.798 → 0.6.800
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 +1206 -311
- package/dist/context/index.js +6 -6
- package/dist/pages/index.js +250 -14
- package/dist/services/index.js +187 -84
- 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 +10 -8
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Subjects.jsx +5 -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 +225 -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 +78 -46
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/columns.js +41 -39
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +53 -24
- 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 +37 -2
- package/src/@daf/layouts/AppLayout/index.jsx +0 -1
- package/src/@daf/pages/Edit/hooks/usePrepareForm.js +1 -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 +9 -2
- package/src/@daf/services/AdminService.js +112 -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
|
@@ -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,51 @@ export default function LocationTable({
|
|
|
28
29
|
view,
|
|
29
30
|
headerTitle,
|
|
30
31
|
breadcrumbs,
|
|
31
|
-
|
|
32
|
+
mergeLocationsFunction,
|
|
32
33
|
refetchTrigger,
|
|
34
|
+
user,
|
|
35
|
+
options,
|
|
33
36
|
}) {
|
|
34
37
|
const [showFilters, setShowFilters] = useState(false);
|
|
35
38
|
const [hasError, setHasError] = useState(false);
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
+
|
|
40
|
+
const [selectedLocations, setSelectedLocations] = useState([]);
|
|
41
|
+
|
|
42
|
+
const { token } = useToken();
|
|
43
|
+
const [isCombineModalOpen, setIsModalOpen] = useState(false);
|
|
44
|
+
|
|
45
|
+
const getDataWithStringPagination = async ({ params }) => {
|
|
46
|
+
const { pagination, tab, filters, search, sort, ...otherParams } = params;
|
|
47
|
+
|
|
48
|
+
let paginationObj = { page: 1, pageSize: 20 };
|
|
49
|
+
if (pagination) {
|
|
50
|
+
try {
|
|
51
|
+
paginationObj = typeof pagination === 'string' ? JSON.parse(pagination) : pagination;
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.error('Failed to parse pagination', e);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let activeTab = tab || "active";
|
|
58
|
+
if (!tab && filters) {
|
|
59
|
+
try {
|
|
60
|
+
const parsedFilters = typeof filters === 'string' ? JSON.parse(filters) : filters;
|
|
61
|
+
activeTab = parsedFilters.activeTab || "active";
|
|
62
|
+
} catch (e) {
|
|
63
|
+
activeTab = "active";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const transformedParams = {
|
|
68
|
+
pagination: {
|
|
69
|
+
skip: String(paginationObj.page || 1),
|
|
70
|
+
take: String(paginationObj.pageSize || 20),
|
|
71
|
+
},
|
|
72
|
+
tab: activeTab,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return getData({ params: transformedParams });
|
|
76
|
+
};
|
|
39
77
|
|
|
40
78
|
const {
|
|
41
79
|
filter,
|
|
@@ -58,7 +96,7 @@ export default function LocationTable({
|
|
|
58
96
|
defaultPageSize,
|
|
59
97
|
filtersConfig,
|
|
60
98
|
getRedirectLink,
|
|
61
|
-
getData,
|
|
99
|
+
getData: getDataWithStringPagination,
|
|
62
100
|
refetchTrigger,
|
|
63
101
|
});
|
|
64
102
|
|
|
@@ -66,7 +104,7 @@ export default function LocationTable({
|
|
|
66
104
|
return {
|
|
67
105
|
category: config.options?.category,
|
|
68
106
|
country: config.options?.countries,
|
|
69
|
-
sources: [],
|
|
107
|
+
sources: [],
|
|
70
108
|
};
|
|
71
109
|
}, [config.options]);
|
|
72
110
|
|
|
@@ -76,11 +114,13 @@ export default function LocationTable({
|
|
|
76
114
|
goTo,
|
|
77
115
|
token,
|
|
78
116
|
module,
|
|
79
|
-
selectedLocations,
|
|
117
|
+
selectedLocations,
|
|
80
118
|
setSelectedLocations,
|
|
81
119
|
getRedirectLink,
|
|
82
120
|
selectOptions,
|
|
83
|
-
entity: headerTitle
|
|
121
|
+
entity: headerTitle,
|
|
122
|
+
user,
|
|
123
|
+
options,
|
|
84
124
|
});
|
|
85
125
|
}, [t, goTo, module, token, selectedLocations, getRedirectLink, selectOptions, headerTitle]);
|
|
86
126
|
|
|
@@ -93,8 +133,8 @@ export default function LocationTable({
|
|
|
93
133
|
actionButton={[
|
|
94
134
|
{
|
|
95
135
|
icon: "Merge",
|
|
96
|
-
onClick: () =>
|
|
97
|
-
tooltip: "
|
|
136
|
+
onClick: () => setIsModalOpen(true),
|
|
137
|
+
tooltip: t("admin::merge-locations"),
|
|
98
138
|
disabled: selectedLocations.length < 2,
|
|
99
139
|
},
|
|
100
140
|
]}
|
|
@@ -112,25 +152,15 @@ export default function LocationTable({
|
|
|
112
152
|
breadcrumbs={breadcrumbs}
|
|
113
153
|
>
|
|
114
154
|
{selectedLocations.length > 0 && (
|
|
115
|
-
<div
|
|
116
|
-
className="flex flex-row ml-6 mt-5"
|
|
117
|
-
style={{
|
|
118
|
-
flexWrap: "wrap",
|
|
119
|
-
gap: "8px",
|
|
120
|
-
}}
|
|
121
|
-
>
|
|
155
|
+
<div className="flex flex-row ml-6 mt-5" style={{ flexWrap: "wrap", gap: "8px" }}>
|
|
122
156
|
{selectedLocations.map((account) => (
|
|
123
157
|
<Tag
|
|
124
158
|
key={account.userId}
|
|
125
159
|
className="flex flex-row gap-2 items-center"
|
|
126
160
|
onClick={() =>
|
|
127
|
-
setSelectedLocations((prev) =>
|
|
128
|
-
prev.filter((a) => a.datastakeId !== account.datastakeId),
|
|
129
|
-
)
|
|
161
|
+
setSelectedLocations((prev) => prev.filter((a) => a.datastakeId !== account.datastakeId))
|
|
130
162
|
}
|
|
131
|
-
style={{
|
|
132
|
-
cursor: "pointer",
|
|
133
|
-
}}
|
|
163
|
+
style={{ cursor: "pointer" }}
|
|
134
164
|
>
|
|
135
165
|
<span>{account.datastakeId}</span>
|
|
136
166
|
<CustomIcon name="Close" size={10} />
|
|
@@ -156,25 +186,27 @@ export default function LocationTable({
|
|
|
156
186
|
/>
|
|
157
187
|
</AdminTable>
|
|
158
188
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
setSelectedLocations([])
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
189
|
+
<CombineLocationModal
|
|
190
|
+
isOpen={isCombineModalOpen}
|
|
191
|
+
t={t}
|
|
192
|
+
onClose={() => setIsModalOpen(false)}
|
|
193
|
+
onSuccess={(data) => {
|
|
194
|
+
console.log("Modal Success triggered", data); // 1. Check if this logs
|
|
195
|
+
console.log("Is function?", typeof mergeLocationsFunction);
|
|
196
|
+
setIsModalOpen(false);
|
|
197
|
+
setLoading(true);
|
|
198
|
+
if (typeof mergeLocationsFunction === 'function') {
|
|
199
|
+
mergeLocationsFunction(data).finally(() => {
|
|
200
|
+
setSelectedLocations([]);
|
|
201
|
+
fetchData();
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}}
|
|
205
|
+
selectedLocations={selectedLocations}
|
|
206
|
+
selectOptions={selectOptions}
|
|
207
|
+
module={module}
|
|
208
|
+
entity={headerTitle}
|
|
209
|
+
/>
|
|
178
210
|
</>
|
|
179
211
|
);
|
|
180
|
-
}
|
|
212
|
+
}
|
|
@@ -13,6 +13,7 @@ export const getColumns = ({
|
|
|
13
13
|
setSelectedSubjects,
|
|
14
14
|
selectOptions,
|
|
15
15
|
entity,
|
|
16
|
+
options,
|
|
16
17
|
}) => {
|
|
17
18
|
const cols = [
|
|
18
19
|
{
|
|
@@ -84,7 +85,8 @@ export const getColumns = ({
|
|
|
84
85
|
return <div className="daf-default-cell" />;
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
|
|
88
|
+
console.log({value, options})
|
|
89
|
+
const category = findOptions(value, options?.categoriesOptions || []) || "-";
|
|
88
90
|
|
|
89
91
|
return <Tooltip title={category}>{category}</Tooltip>;
|
|
90
92
|
},
|
|
@@ -99,53 +101,53 @@ export const getColumns = ({
|
|
|
99
101
|
if (all.empty) {
|
|
100
102
|
return <div className="daf-default-cell" />;
|
|
101
103
|
}
|
|
102
|
-
const country = findOptions(value,
|
|
104
|
+
const country = findOptions(value, options?.countries || []) || "-";
|
|
103
105
|
|
|
104
106
|
return <Tooltip title={country}>{country}</Tooltip>;
|
|
105
107
|
},
|
|
106
108
|
},
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
109
|
+
{
|
|
110
|
+
title: t("Admin Level 1"),
|
|
111
|
+
dataIndex: "administrativeLevel1",
|
|
112
|
+
key: "administrativeLevel1",
|
|
113
|
+
ellipsis: true,
|
|
114
|
+
show: entity.includes("location"),
|
|
115
|
+
render: (value, all) => {
|
|
116
|
+
if (all.empty) {
|
|
117
|
+
return <div className="daf-default-cell" />;
|
|
118
|
+
}
|
|
117
119
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
let label;
|
|
121
|
+
if(all?.administrativeLevel1 && value === all?.administrativeLevel1) {
|
|
122
|
+
label = all?.linking?.SCL?.[value]?.name
|
|
123
|
+
} else {
|
|
124
|
+
label = getNameByLevel(all?.linking?.SCL, "level_1")?.name
|
|
125
|
+
}
|
|
124
126
|
|
|
125
|
-
|
|
126
|
-
},
|
|
127
|
+
return <Tooltip title={label || '-'}>{label || '-'}</Tooltip>;
|
|
127
128
|
},
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
title: t("Admin Level 2"),
|
|
132
|
+
dataIndex: "administrativeLevel2",
|
|
133
|
+
key: "administrativeLevel2",
|
|
134
|
+
show: entity.includes("location"),
|
|
135
|
+
ellipsis: true,
|
|
136
|
+
render: (value, all) => {
|
|
137
|
+
if (all.empty) {
|
|
138
|
+
return <div className="daf-default-cell" />;
|
|
139
|
+
}
|
|
138
140
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
let label;
|
|
142
|
+
if(all?.administrativeLevel2 && value === all?.administrativeLevel2) {
|
|
143
|
+
label = all?.linking?.SCL?.[value]?.name
|
|
144
|
+
} else {
|
|
145
|
+
label = getNameByLevel(all?.linking?.SCL, "level_2")?.name
|
|
146
|
+
}
|
|
145
147
|
|
|
146
|
-
|
|
147
|
-
},
|
|
148
|
+
return <Tooltip title={label || '-'}>{label || '-'}</Tooltip>;
|
|
148
149
|
},
|
|
150
|
+
},
|
|
149
151
|
{
|
|
150
152
|
title: t("Sources"),
|
|
151
153
|
dataIndex: "sources",
|
|
@@ -210,7 +212,7 @@ export const getColumns = ({
|
|
|
210
212
|
<div
|
|
211
213
|
className="cursor-pointer"
|
|
212
214
|
onClick={() => {
|
|
213
|
-
goTo(getRedirectLink(`/app/
|
|
215
|
+
goTo(getRedirectLink(`/app/view/management-stakeholder/${all.id}`));
|
|
214
216
|
}}
|
|
215
217
|
>
|
|
216
218
|
<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,
|
|
@@ -31,6 +31,8 @@ export default function SubjectsTable({
|
|
|
31
31
|
breadcrumbs,
|
|
32
32
|
mergeSubjectsFunction,
|
|
33
33
|
refetchTrigger,
|
|
34
|
+
user,
|
|
35
|
+
options,
|
|
34
36
|
}) {
|
|
35
37
|
const [showFilters, setShowFilters] = useState(false);
|
|
36
38
|
const [hasError, setHasError] = useState(false);
|
|
@@ -38,6 +40,41 @@ export default function SubjectsTable({
|
|
|
38
40
|
const { token } = useToken();
|
|
39
41
|
const [isCombineModalOpen, setIsModalOpen] = useState(false);
|
|
40
42
|
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
const getDataWithStringPagination = async ({ params }) => {
|
|
47
|
+
const { pagination, tab, filters, search, sort, ...otherParams } = params;
|
|
48
|
+
|
|
49
|
+
let paginationObj = { page: 1, pageSize: 20 };
|
|
50
|
+
if (pagination) {
|
|
51
|
+
try {
|
|
52
|
+
paginationObj = typeof pagination === 'string' ? JSON.parse(pagination) : pagination;
|
|
53
|
+
} catch (e) {
|
|
54
|
+
console.error('Failed to parse pagination', e);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let activeTab = tab || "active";
|
|
59
|
+
if (!tab && filters) {
|
|
60
|
+
try {
|
|
61
|
+
const parsedFilters = typeof filters === 'string' ? JSON.parse(filters) : filters;
|
|
62
|
+
activeTab = parsedFilters.activeTab || "active";
|
|
63
|
+
} catch (e) {
|
|
64
|
+
activeTab = "active";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const transformedParams = {
|
|
69
|
+
pagination: {
|
|
70
|
+
skip: String(paginationObj.page || 1),
|
|
71
|
+
take: String(paginationObj.pageSize || 20),
|
|
72
|
+
},
|
|
73
|
+
tab: activeTab,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return getData({ params: transformedParams });
|
|
77
|
+
};
|
|
41
78
|
const {
|
|
42
79
|
filter,
|
|
43
80
|
activeTab,
|
|
@@ -59,7 +96,7 @@ export default function SubjectsTable({
|
|
|
59
96
|
defaultPageSize,
|
|
60
97
|
filtersConfig,
|
|
61
98
|
getRedirectLink,
|
|
62
|
-
getData,
|
|
99
|
+
getData: getDataWithStringPagination,
|
|
63
100
|
refetchTrigger,
|
|
64
101
|
});
|
|
65
102
|
|
|
@@ -67,7 +104,7 @@ export default function SubjectsTable({
|
|
|
67
104
|
return {
|
|
68
105
|
category: config.options?.category,
|
|
69
106
|
country: config.options?.countries,
|
|
70
|
-
sources: [],
|
|
107
|
+
sources: [],
|
|
71
108
|
};
|
|
72
109
|
}, [config.options]);
|
|
73
110
|
|
|
@@ -81,9 +118,10 @@ export default function SubjectsTable({
|
|
|
81
118
|
setSelectedSubjects,
|
|
82
119
|
getRedirectLink,
|
|
83
120
|
selectOptions,
|
|
84
|
-
entity: headerTitle
|
|
121
|
+
entity: headerTitle,
|
|
122
|
+
options,
|
|
85
123
|
});
|
|
86
|
-
}, [t, goTo, module, token, selectedSubjects, getRedirectLink, selectOptions, headerTitle]);
|
|
124
|
+
}, [t, goTo, module, token, selectedSubjects, getRedirectLink, selectOptions, headerTitle, options]);
|
|
87
125
|
|
|
88
126
|
return (
|
|
89
127
|
<>
|
|
@@ -113,25 +151,15 @@ export default function SubjectsTable({
|
|
|
113
151
|
breadcrumbs={breadcrumbs}
|
|
114
152
|
>
|
|
115
153
|
{selectedSubjects.length > 0 && (
|
|
116
|
-
<div
|
|
117
|
-
className="flex flex-row ml-6 mt-5"
|
|
118
|
-
style={{
|
|
119
|
-
flexWrap: "wrap",
|
|
120
|
-
gap: "8px",
|
|
121
|
-
}}
|
|
122
|
-
>
|
|
154
|
+
<div className="flex flex-row ml-6 mt-5" style={{ flexWrap: "wrap", gap: "8px" }}>
|
|
123
155
|
{selectedSubjects.map((account) => (
|
|
124
156
|
<Tag
|
|
125
157
|
key={account.userId}
|
|
126
158
|
className="flex flex-row gap-2 items-center"
|
|
127
159
|
onClick={() =>
|
|
128
|
-
setSelectedSubjects((prev) =>
|
|
129
|
-
prev.filter((a) => a.datastakeId !== account.datastakeId),
|
|
130
|
-
)
|
|
160
|
+
setSelectedSubjects((prev) => prev.filter((a) => a.datastakeId !== account.datastakeId))
|
|
131
161
|
}
|
|
132
|
-
style={{
|
|
133
|
-
cursor: "pointer",
|
|
134
|
-
}}
|
|
162
|
+
style={{ cursor: "pointer" }}
|
|
135
163
|
>
|
|
136
164
|
<span>{account.datastakeId}</span>
|
|
137
165
|
<CustomIcon name="Close" size={10} />
|
|
@@ -160,19 +188,20 @@ export default function SubjectsTable({
|
|
|
160
188
|
<CombineSubjectsModal
|
|
161
189
|
isOpen={isCombineModalOpen}
|
|
162
190
|
t={t}
|
|
163
|
-
onClose={() =>
|
|
164
|
-
setIsModalOpen(false);
|
|
165
|
-
}}
|
|
191
|
+
onClose={() => setIsModalOpen(false)}
|
|
166
192
|
onSuccess={(data) => {
|
|
167
193
|
setIsModalOpen(false);
|
|
168
194
|
setLoading(true);
|
|
195
|
+
message.success(t("Subjects successfully merged."))
|
|
169
196
|
if (typeof mergeSubjectsFunction === 'function') {
|
|
170
|
-
mergeSubjectsFunction(data)
|
|
171
|
-
|
|
197
|
+
mergeSubjectsFunction(data).finally(() => {
|
|
198
|
+
setSelectedSubjects([]);
|
|
199
|
+
fetchData();
|
|
200
|
+
});
|
|
172
201
|
}
|
|
173
202
|
}}
|
|
174
203
|
selectedSubjects={selectedSubjects}
|
|
175
|
-
selectOptions={selectOptions
|
|
204
|
+
selectOptions={selectOptions}
|
|
176
205
|
module={module}
|
|
177
206
|
entity={headerTitle}
|
|
178
207
|
/>
|
|
@@ -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
|
+
}
|