@blaze-cms/plugin-data-ui 0.133.0-project-admin-customisations.0 → 0.133.0
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/CHANGELOG.md +41 -22
- package/README.md +0 -42
- package/lib/components/EntityDataListing/EntityDataListing.js +24 -3
- package/lib/components/EntityDataListing/EntityDataListing.js.map +1 -1
- package/lib/components/EntityManager/Entity/Entity.js +17 -32
- package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js +7 -23
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib/components/ListingTable/ListingTable.js +80 -113
- package/lib/components/ListingTable/ListingTable.js.map +1 -1
- package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +20 -8
- package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
- package/lib/components/ListingTable/mappers/populate-rows.js +26 -92
- package/lib/components/ListingTable/mappers/populate-rows.js.map +1 -1
- package/lib/components/ListingTable/service/index.js +11 -73
- package/lib/components/ListingTable/service/index.js.map +1 -1
- package/lib/index.js +11 -3
- package/lib/index.js.map +1 -1
- package/lib/utils/add-content-menu-items.js +13 -64
- package/lib/utils/add-content-menu-items.js.map +1 -1
- package/lib/utils/build-listing-query.js +2 -11
- package/lib/utils/build-listing-query.js.map +1 -1
- package/lib/utils/get-default-query-params.js +4 -3
- package/lib/utils/get-default-query-params.js.map +1 -1
- package/lib-es/components/EntityDataListing/EntityDataListing.js +14 -3
- package/lib-es/components/EntityDataListing/EntityDataListing.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/Entity.js +17 -32
- package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +8 -24
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTable.js +49 -46
- package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +19 -11
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
- package/lib-es/components/ListingTable/mappers/populate-rows.js +24 -76
- package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -1
- package/lib-es/components/ListingTable/service/index.js +7 -65
- package/lib-es/components/ListingTable/service/index.js.map +1 -1
- package/lib-es/index.js +9 -1
- package/lib-es/index.js.map +1 -1
- package/lib-es/utils/add-content-menu-items.js +5 -49
- package/lib-es/utils/add-content-menu-items.js.map +1 -1
- package/lib-es/utils/build-listing-query.js +1 -10
- package/lib-es/utils/build-listing-query.js.map +1 -1
- package/lib-es/utils/get-default-query-params.js +3 -1
- package/lib-es/utils/get-default-query-params.js.map +1 -1
- package/package.json +9 -10
- package/src/components/EntityDataListing/EntityDataListing.js +12 -3
- package/src/components/EntityManager/Entity/Entity.js +57 -68
- package/src/components/EntityManager/Entity/SideBarRelations/index.js +19 -51
- package/src/components/ListingTable/ListingTable.js +38 -57
- package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +22 -8
- package/src/components/ListingTable/mappers/populate-rows.js +18 -83
- package/src/components/ListingTable/service/index.js +5 -42
- package/src/index.js +8 -1
- package/src/utils/add-content-menu-items.js +3 -45
- package/src/utils/build-listing-query.js +1 -11
- package/src/utils/get-default-query-params.js +1 -1
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +0 -39
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +0 -1
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js +0 -12
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +0 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +0 -44
- package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +0 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +0 -32
- package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +0 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +0 -45
- package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +0 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +0 -38
- package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +0 -1
- package/lib/components/InfoBoxes/InfoBoxes.js +0 -36
- package/lib/components/InfoBoxes/InfoBoxes.js.map +0 -1
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js +0 -44
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +0 -1
- package/lib/components/InfoBoxes/helpers/build-dynamic-query.js +0 -25
- package/lib/components/InfoBoxes/helpers/build-dynamic-query.js.map +0 -1
- package/lib/components/InfoBoxes/hooks/useData.js +0 -42
- package/lib/components/InfoBoxes/hooks/useData.js.map +0 -1
- package/lib/components/InfoBoxes/hooks/useInfoBox.js +0 -26
- package/lib/components/InfoBoxes/hooks/useInfoBox.js.map +0 -1
- package/lib/components/InfoBoxes/index.js +0 -12
- package/lib/components/InfoBoxes/index.js.map +0 -1
- package/lib/components/InfoBoxes/presentational/InfoBox.js +0 -46
- package/lib/components/InfoBoxes/presentational/InfoBox.js.map +0 -1
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +0 -30
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +0 -1
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js +0 -3
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +0 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +0 -30
- package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +0 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +0 -26
- package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +0 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +0 -39
- package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +0 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +0 -24
- package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +0 -1
- package/lib-es/components/InfoBoxes/InfoBoxes.js +0 -28
- package/lib-es/components/InfoBoxes/InfoBoxes.js.map +0 -1
- package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js +0 -30
- package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +0 -1
- package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js +0 -25
- package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +0 -1
- package/lib-es/components/InfoBoxes/hooks/useData.js +0 -37
- package/lib-es/components/InfoBoxes/hooks/useData.js.map +0 -1
- package/lib-es/components/InfoBoxes/hooks/useInfoBox.js +0 -19
- package/lib-es/components/InfoBoxes/hooks/useInfoBox.js.map +0 -1
- package/lib-es/components/InfoBoxes/index.js +0 -3
- package/lib-es/components/InfoBoxes/index.js.map +0 -1
- package/lib-es/components/InfoBoxes/presentational/InfoBox.js +0 -31
- package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +0 -1
- package/src/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +0 -26
- package/src/components/EntityManager/Entity/EntitiyNavLinks/index.js +0 -3
- package/src/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +0 -22
- package/src/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +0 -33
- package/src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +0 -28
- package/src/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +0 -33
- package/src/components/InfoBoxes/InfoBoxes.js +0 -24
- package/src/components/InfoBoxes/container/InfoBoxContainer.js +0 -22
- package/src/components/InfoBoxes/helpers/build-dynamic-query.js +0 -25
- package/src/components/InfoBoxes/hooks/useData.js +0 -20
- package/src/components/InfoBoxes/hooks/useInfoBox.js +0 -13
- package/src/components/InfoBoxes/index.js +0 -3
- package/src/components/InfoBoxes/presentational/InfoBox.js +0 -34
|
@@ -6,18 +6,19 @@ import React, { useEffect, useState, Fragment } from 'react';
|
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { withRouter, Link } from 'react-router-dom';
|
|
8
8
|
import More from '@blaze-react/more';
|
|
9
|
+
import { MainContext, useMainContext } from '@blaze-cms/admin-ui-utils';
|
|
9
10
|
import { PageHeader, DeleteAction } from '@blaze-cms/admin';
|
|
10
11
|
import { useToasts } from '@blaze-react/toaster';
|
|
11
|
-
import { RenderHook } from '@blaze-cms/plugin-render-hooks-ui';
|
|
12
12
|
import ListingTableContent from './ListingTableContent';
|
|
13
13
|
import availableActions from '../EntityManager/Entity/actions-handlers';
|
|
14
14
|
import { fetchData } from './service';
|
|
15
|
-
import { populateRows, formatRows
|
|
15
|
+
import { populateRows, formatRows } from './mappers/populate-rows';
|
|
16
16
|
import { getDefaultQueryParams } from '../../utils/get-default-query-params';
|
|
17
17
|
const OVER_SCAN_BUFFER = 10;
|
|
18
18
|
const ListingTable = ({
|
|
19
19
|
match,
|
|
20
|
-
entitySchema
|
|
20
|
+
entitySchema,
|
|
21
|
+
selectedMenuItem
|
|
21
22
|
}) => {
|
|
22
23
|
const [tableData, setTableData] = useState({});
|
|
23
24
|
const [modalStatus, setModalStatus] = useState(false);
|
|
@@ -27,9 +28,14 @@ const ListingTable = ({
|
|
|
27
28
|
});
|
|
28
29
|
const [scrollToIndex, setScrollToIndex] = useState(0);
|
|
29
30
|
const [verifiedRanges, setVerifiedRanges] = useState([]);
|
|
30
|
-
const queryParamsDefault = getDefaultQueryParams(
|
|
31
|
+
const queryParamsDefault = getDefaultQueryParams({
|
|
32
|
+
schema: entitySchema
|
|
33
|
+
});
|
|
31
34
|
const [queryParams, setQueryParams] = useState(queryParamsDefault);
|
|
32
|
-
const
|
|
35
|
+
const {
|
|
36
|
+
menuItems,
|
|
37
|
+
setMenuItems
|
|
38
|
+
} = useMainContext(MainContext);
|
|
33
39
|
const client = useApolloClient();
|
|
34
40
|
const {
|
|
35
41
|
addToast
|
|
@@ -37,7 +43,20 @@ const ListingTable = ({
|
|
|
37
43
|
useEffect(() => {
|
|
38
44
|
(async () => {
|
|
39
45
|
if (entitySchema.id !== previousSchema.id || previousSchema.id === null && entitySchema.id) {
|
|
40
|
-
await
|
|
46
|
+
const data = await fetchData({
|
|
47
|
+
client,
|
|
48
|
+
querySettings: {
|
|
49
|
+
entitySchema,
|
|
50
|
+
queryParams: queryParamsDefault
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const populatedTable = populateRows({
|
|
54
|
+
toggleModal,
|
|
55
|
+
url: match.url,
|
|
56
|
+
entitySchema,
|
|
57
|
+
rows: data
|
|
58
|
+
});
|
|
59
|
+
setTableData(populatedTable);
|
|
41
60
|
setPreviousSchema({
|
|
42
61
|
id: entitySchema.id
|
|
43
62
|
});
|
|
@@ -46,28 +65,20 @@ const ListingTable = ({
|
|
|
46
65
|
}, [client, entitySchema, match.url, previousSchema.id, queryParams] // eslint-disable-line react-hooks/exhaustive-deps
|
|
47
66
|
);
|
|
48
67
|
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
querySettings: {
|
|
53
|
-
entitySchema,
|
|
54
|
-
queryParams: queryParamsDefault
|
|
55
|
-
},
|
|
56
|
-
listFilters: filters
|
|
57
|
-
});
|
|
58
|
-
const populatedTable = populateRows({
|
|
59
|
-
toggleModal,
|
|
60
|
-
url: match.url,
|
|
61
|
-
entitySchema,
|
|
62
|
-
rows: data
|
|
68
|
+
const onCloseCardPrompt = () => {
|
|
69
|
+
const updatedSelectedMenuItem = _objectSpread(_objectSpread({}, selectedMenuItem), {}, {
|
|
70
|
+
isDisplayedPrompt: false
|
|
63
71
|
});
|
|
64
|
-
|
|
72
|
+
const [{
|
|
73
|
+
header,
|
|
74
|
+
items
|
|
75
|
+
}] = menuItems;
|
|
76
|
+
const updatedItems = items.map(item => item.name === selectedMenuItem.name ? updatedSelectedMenuItem : item);
|
|
77
|
+
setMenuItems([{
|
|
78
|
+
header,
|
|
79
|
+
items: updatedItems
|
|
80
|
+
}]);
|
|
65
81
|
};
|
|
66
|
-
const updateListingFilters = async filters => {
|
|
67
|
-
await doQuery(filters);
|
|
68
|
-
setListFilters(filters);
|
|
69
|
-
};
|
|
70
|
-
const onCloseCardPrompt = () => null;
|
|
71
82
|
const toggleModal = item => {
|
|
72
83
|
setModalStatus(!!item);
|
|
73
84
|
setItemToDelete(item || {});
|
|
@@ -104,12 +115,10 @@ const ListingTable = ({
|
|
|
104
115
|
querySettings: {
|
|
105
116
|
entitySchema,
|
|
106
117
|
queryParams: sortQueryParams
|
|
107
|
-
}
|
|
108
|
-
listFilters
|
|
118
|
+
}
|
|
109
119
|
});
|
|
110
120
|
const {
|
|
111
|
-
columns
|
|
112
|
-
isEnquiry
|
|
121
|
+
columns
|
|
113
122
|
} = tableData;
|
|
114
123
|
const [firstColumn] = columns;
|
|
115
124
|
setTableData(_objectSpread(_objectSpread({}, tableData), {}, {
|
|
@@ -117,11 +126,10 @@ const ListingTable = ({
|
|
|
117
126
|
[property]: direction
|
|
118
127
|
},
|
|
119
128
|
rows: formatRows({
|
|
120
|
-
rows:
|
|
129
|
+
rows: data,
|
|
121
130
|
url: match.url,
|
|
122
131
|
toggleModal,
|
|
123
|
-
firstColumn
|
|
124
|
-
isEnquiry
|
|
132
|
+
firstColumn
|
|
125
133
|
})
|
|
126
134
|
}));
|
|
127
135
|
};
|
|
@@ -140,14 +148,12 @@ const ListingTable = ({
|
|
|
140
148
|
querySettings: {
|
|
141
149
|
entitySchema,
|
|
142
150
|
queryParams: updatedQueryParams
|
|
143
|
-
}
|
|
144
|
-
listFilters
|
|
151
|
+
}
|
|
145
152
|
});
|
|
146
153
|
const updatedRows = [...tableData.rows, ...formatRows({
|
|
147
|
-
rows:
|
|
154
|
+
rows: data,
|
|
148
155
|
url: match.url,
|
|
149
|
-
toggleModal
|
|
150
|
-
isEnquiry: tableData.isEnquiry
|
|
156
|
+
toggleModal
|
|
151
157
|
})];
|
|
152
158
|
setVerifiedRanges([...verifiedRanges, loadIndex]);
|
|
153
159
|
setQueryParams(updatedQueryParams);
|
|
@@ -158,7 +164,6 @@ const ListingTable = ({
|
|
|
158
164
|
}
|
|
159
165
|
};
|
|
160
166
|
if (!tableData || !tableData.rows) return 'loading';
|
|
161
|
-
const showAddButton = !!tableData.rows.length && !tableData.isEnquiry;
|
|
162
167
|
return /*#__PURE__*/React.createElement("div", {
|
|
163
168
|
className: "page"
|
|
164
169
|
}, modalStatus && /*#__PURE__*/React.createElement(DeleteAction, {
|
|
@@ -168,7 +173,7 @@ const ListingTable = ({
|
|
|
168
173
|
}), /*#__PURE__*/React.createElement(PageHeader, {
|
|
169
174
|
title: entitySchema.displayName,
|
|
170
175
|
subtitle: ""
|
|
171
|
-
},
|
|
176
|
+
}, (!selectedMenuItem.isDisplayedPrompt || !!tableData.rows.length) && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Link, {
|
|
172
177
|
"data-testid": "addEntity",
|
|
173
178
|
className: "button button--small",
|
|
174
179
|
to: `${match.url}/create`
|
|
@@ -178,22 +183,20 @@ const ListingTable = ({
|
|
|
178
183
|
className: "material-icons"
|
|
179
184
|
}, "more_vert")), /*#__PURE__*/React.createElement(More.Content, {
|
|
180
185
|
isMoreMenu: true
|
|
181
|
-
}))))), /*#__PURE__*/React.createElement(
|
|
182
|
-
hookKey: "entity:listing:main:top",
|
|
183
|
-
schema: entitySchema,
|
|
184
|
-
setListFilters: updateListingFilters
|
|
185
|
-
}), /*#__PURE__*/React.createElement(ListingTableContent, {
|
|
186
|
+
}))))), /*#__PURE__*/React.createElement(ListingTableContent, {
|
|
186
187
|
overScanBuffer: OVER_SCAN_BUFFER,
|
|
187
188
|
onSort: handleSort,
|
|
188
189
|
onRenderItems: handleRenderedItems,
|
|
189
190
|
tableData: tableData,
|
|
190
191
|
onCloseCardPrompt: onCloseCardPrompt,
|
|
192
|
+
selectedMenuItem: selectedMenuItem,
|
|
191
193
|
scrollToIndex: scrollToIndex
|
|
192
194
|
}));
|
|
193
195
|
};
|
|
194
196
|
ListingTable.propTypes = {
|
|
195
197
|
entitySchema: PropTypes.object.isRequired,
|
|
196
|
-
match: PropTypes.object.isRequired
|
|
198
|
+
match: PropTypes.object.isRequired,
|
|
199
|
+
selectedMenuItem: PropTypes.object.isRequired
|
|
197
200
|
};
|
|
198
201
|
export default withRouter(ListingTable);
|
|
199
202
|
//# sourceMappingURL=ListingTable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListingTable.js","names":["useApolloClient","React","useEffect","useState","Fragment","PropTypes","withRouter","Link","More","PageHeader","DeleteAction","useToasts","RenderHook","ListingTableContent","availableActions","fetchData","populateRows","formatRows","getParsedRowData","getDefaultQueryParams","OVER_SCAN_BUFFER","ListingTable","match","entitySchema","tableData","setTableData","modalStatus","setModalStatus","itemToDelete","setItemToDelete","previousSchema","setPreviousSchema","id","scrollToIndex","setScrollToIndex","verifiedRanges","setVerifiedRanges","queryParamsDefault","queryParams","setQueryParams","listFilters","setListFilters","client","addToast","doQuery","url","filters","data","querySettings","populatedTable","toggleModal","rows","updateListingFilters","onCloseCardPrompt","item","deleteAction","delete","submit","parsedFormValues","updatedTableData","_objectSpread","filter","handleSort","event","property","direction","Object","entries","sortQueryParams","sort","columns","isEnquiry","firstColumn","appliedSort","handleRenderedItems","params","startIndex","rowsLength","length","loadIndex","Math","floor","includes","updatedQueryParams","offset","updatedRows","showAddButton","createElement","className","onClose","itemName","name","title","displayName","subtitle","to","Actions","Avatar","isMoreMenu","Content","hookKey","schema","overScanBuffer","onSort","onRenderItems","propTypes","object","isRequired"],"sources":["../../../src/components/ListingTable/ListingTable.js"],"sourcesContent":["import { useApolloClient } from '@apollo/client';\nimport React, { useEffect, useState, Fragment } from 'react';\nimport PropTypes from 'prop-types';\nimport { withRouter, Link } from 'react-router-dom';\nimport More from '@blaze-react/more';\nimport { PageHeader, DeleteAction } from '@blaze-cms/admin';\nimport { useToasts } from '@blaze-react/toaster';\nimport { RenderHook } from '@blaze-cms/plugin-render-hooks-ui';\nimport ListingTableContent from './ListingTableContent';\nimport availableActions from '../EntityManager/Entity/actions-handlers';\nimport { fetchData } from './service';\nimport { populateRows, formatRows, getParsedRowData } from './mappers/populate-rows';\nimport { getDefaultQueryParams } from '../../utils/get-default-query-params';\n\nconst OVER_SCAN_BUFFER = 10;\n\nconst ListingTable = ({ match, entitySchema }) => {\n const [tableData, setTableData] = useState({});\n const [modalStatus, setModalStatus] = useState(false);\n const [itemToDelete, setItemToDelete] = useState({});\n const [previousSchema, setPreviousSchema] = useState({ id: null });\n const [scrollToIndex, setScrollToIndex] = useState(0);\n const [verifiedRanges, setVerifiedRanges] = useState([]);\n const queryParamsDefault = getDefaultQueryParams(entitySchema);\n const [queryParams, setQueryParams] = useState(queryParamsDefault);\n const [listFilters, setListFilters] = useState([]);\n const client = useApolloClient();\n const { addToast } = useToasts();\n\n useEffect(\n () => {\n (async () => {\n if (\n entitySchema.id !== previousSchema.id ||\n (previousSchema.id === null && entitySchema.id)\n ) {\n await doQuery();\n setPreviousSchema({ id: entitySchema.id });\n }\n })();\n },\n [client, entitySchema, match.url, previousSchema.id, queryParams] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n const doQuery = async (filters = listFilters) => {\n const data = await fetchData({\n client,\n querySettings: {\n entitySchema,\n queryParams: queryParamsDefault\n },\n listFilters: filters\n });\n\n const populatedTable = populateRows({\n toggleModal,\n url: match.url,\n entitySchema,\n rows: data\n });\n\n setTableData(populatedTable);\n };\n\n const updateListingFilters = async filters => {\n await doQuery(filters);\n setListFilters(filters);\n };\n\n const onCloseCardPrompt = () => null;\n\n const toggleModal = item => {\n setModalStatus(!!item);\n setItemToDelete(item || {});\n };\n\n const deleteAction = async () => {\n await availableActions.delete.submit(\n {\n entitySchema,\n parsedFormValues: { id: itemToDelete.id },\n client\n },\n addToast\n );\n\n toggleModal();\n\n const updatedTableData = {\n ...tableData,\n rows: tableData.rows.filter(({ id }) => id !== itemToDelete.id)\n };\n\n setTableData(updatedTableData);\n };\n\n const handleSort = async event => {\n const [[property, direction]] = Object.entries(event);\n const sortQueryParams = {\n ...queryParamsDefault,\n sort: [{ property, direction }]\n };\n setScrollToIndex(0);\n setVerifiedRanges([]);\n setQueryParams(sortQueryParams);\n\n const data = await fetchData({\n client,\n querySettings: {\n entitySchema,\n queryParams: sortQueryParams\n },\n listFilters\n });\n const { columns, isEnquiry } = tableData;\n const [firstColumn] = columns;\n\n setTableData({\n ...tableData,\n appliedSort: { [property]: direction },\n rows: formatRows({\n rows: getParsedRowData(data),\n url: match.url,\n toggleModal,\n firstColumn,\n isEnquiry\n })\n });\n };\n\n const handleRenderedItems = async params => {\n const { startIndex } = params;\n const rowsLength = tableData.rows.length;\n const loadIndex = Math.floor(rowsLength / 3) - OVER_SCAN_BUFFER;\n if (loadIndex > 0 && loadIndex < startIndex && !verifiedRanges.includes(loadIndex)) {\n const updatedQueryParams = {\n ...queryParams,\n offset: rowsLength\n };\n const data = await fetchData({\n client,\n querySettings: {\n entitySchema,\n queryParams: updatedQueryParams\n },\n listFilters\n });\n const updatedRows = [\n ...tableData.rows,\n ...formatRows({\n rows: getParsedRowData(data),\n url: match.url,\n toggleModal,\n isEnquiry: tableData.isEnquiry\n })\n ];\n\n setVerifiedRanges([...verifiedRanges, loadIndex]);\n setQueryParams(updatedQueryParams);\n setTableData({\n ...tableData,\n rows: updatedRows\n });\n setScrollToIndex(startIndex + OVER_SCAN_BUFFER);\n }\n };\n\n if (!tableData || !tableData.rows) return 'loading';\n const showAddButton = !!tableData.rows.length && !tableData.isEnquiry;\n\n return (\n <div className=\"page\">\n {modalStatus && (\n <DeleteAction\n onClose={toggleModal}\n deleteAction={deleteAction}\n itemName={itemToDelete.name}\n />\n )}\n <PageHeader title={entitySchema.displayName} subtitle=\"\">\n {showAddButton && (\n <Fragment>\n <Link\n data-testid=\"addEntity\"\n className=\"button button--small\"\n to={`${match.url}/create`}>\n Add\n </Link>\n <PageHeader.Actions>\n <More>\n <More.Avatar isMoreMenu>\n <span className=\"material-icons\">more_vert</span>\n </More.Avatar>\n <More.Content isMoreMenu />\n </More>\n </PageHeader.Actions>\n </Fragment>\n )}\n </PageHeader>\n <RenderHook\n hookKey=\"entity:listing:main:top\"\n schema={entitySchema}\n setListFilters={updateListingFilters}\n />\n <ListingTableContent\n overScanBuffer={OVER_SCAN_BUFFER}\n onSort={handleSort}\n onRenderItems={handleRenderedItems}\n tableData={tableData}\n onCloseCardPrompt={onCloseCardPrompt}\n scrollToIndex={scrollToIndex}\n />\n </div>\n );\n};\nListingTable.propTypes = {\n entitySchema: PropTypes.object.isRequired,\n match: PropTypes.object.isRequired\n};\n\nexport default withRouter(ListingTable);\n"],"mappings":";;;AAAA,SAASA,eAAe,QAAQ,gBAAgB;AAChD,OAAOC,KAAK,IAAIC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,OAAO;AAC5D,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,UAAU,EAAEC,IAAI,QAAQ,kBAAkB;AACnD,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,UAAU,EAAEC,YAAY,QAAQ,kBAAkB;AAC3D,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,UAAU,QAAQ,mCAAmC;AAC9D,OAAOC,mBAAmB,MAAM,uBAAuB;AACvD,OAAOC,gBAAgB,MAAM,0CAA0C;AACvE,SAASC,SAAS,QAAQ,WAAW;AACrC,SAASC,YAAY,EAAEC,UAAU,EAAEC,gBAAgB,QAAQ,yB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B,aAAa,EAAEA;EAAc,CAC9B,CACE,CAAC;AAEV,CAAC;AACDZ,YAAY,CAACoF,SAAS,GAAG;EACvBlF,YAAY,EAAElB,SAAS,CAACqG,MAAM,CAACC,UAAU;EACzCrF,KAAK,EAAEjB,SAAS,CAACqG,MAAM,CAACC;AAC1B,CAAC;AAED,eAAerG,UAAU,CAACe,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"ListingTable.js","names":["useApolloClient","React","useEffect","useState","Fragment","PropTypes","withRouter","Link","More","MainContext","useMainContext","PageHeader","DeleteAction","useToasts","ListingTableContent","availableActions","fetchData","populateRows","formatRows","getDefaultQueryParams","OVER_SCAN_BUFFER","ListingTable","match","entitySchema","selectedMenuItem","tableData","setTableData","modalStatus","setModalStatus","itemToDelete","setItemToDelete","previousSchema","setPreviousSchema","id","scrollToIndex","setScrollToIndex","verifiedRanges","setVerifiedRanges","queryParamsDefault","schema","queryParams","setQueryParams","menuItems","setMenuItems","client","addToast","data","querySettings","populatedTable","toggleModal","url","rows","onCloseCardPrompt","updatedSelectedMenuItem","_objectSpread","isDisplayedPrompt","header","items","updatedItems","map","item","name","deleteAction","delete","submit","parsedFormValues","updatedTableData","filter","handleSort","event","property","direction","Object","entries","sortQueryParams","sort","columns","firstColumn","appliedSort","handleRenderedItems","params","startIndex","rowsLength","length","loadIndex","Math","floor","includes","updatedQueryParams","offset","updatedRows","createElement","className","onClose","itemName","title","displayName","subtitle","to","Actions","Avatar","isMoreMenu","Content","overScanBuffer","onSort","onRenderItems","propTypes","object","isRequired"],"sources":["../../../src/components/ListingTable/ListingTable.js"],"sourcesContent":["import { useApolloClient } from '@apollo/client';\nimport React, { useEffect, useState, Fragment } from 'react';\nimport PropTypes from 'prop-types';\nimport { withRouter, Link } from 'react-router-dom';\nimport More from '@blaze-react/more';\nimport { MainContext, useMainContext } from '@blaze-cms/admin-ui-utils';\nimport { PageHeader, DeleteAction } from '@blaze-cms/admin';\nimport { useToasts } from '@blaze-react/toaster';\nimport ListingTableContent from './ListingTableContent';\nimport availableActions from '../EntityManager/Entity/actions-handlers';\nimport { fetchData } from './service';\nimport { populateRows, formatRows } from './mappers/populate-rows';\nimport { getDefaultQueryParams } from '../../utils/get-default-query-params';\n\nconst OVER_SCAN_BUFFER = 10;\n\nconst ListingTable = ({ match, entitySchema, selectedMenuItem }) => {\n const [tableData, setTableData] = useState({});\n const [modalStatus, setModalStatus] = useState(false);\n const [itemToDelete, setItemToDelete] = useState({});\n const [previousSchema, setPreviousSchema] = useState({ id: null });\n const [scrollToIndex, setScrollToIndex] = useState(0);\n const [verifiedRanges, setVerifiedRanges] = useState([]);\n const queryParamsDefault = getDefaultQueryParams({ schema: entitySchema });\n const [queryParams, setQueryParams] = useState(queryParamsDefault);\n const { menuItems, setMenuItems } = useMainContext(MainContext);\n const client = useApolloClient();\n const { addToast } = useToasts();\n\n useEffect(\n () => {\n (async () => {\n if (\n entitySchema.id !== previousSchema.id ||\n (previousSchema.id === null && entitySchema.id)\n ) {\n const data = await fetchData({\n client,\n querySettings: {\n entitySchema,\n queryParams: queryParamsDefault\n }\n });\n const populatedTable = populateRows({\n toggleModal,\n url: match.url,\n entitySchema,\n rows: data\n });\n setTableData(populatedTable);\n setPreviousSchema({ id: entitySchema.id });\n }\n })();\n },\n [client, entitySchema, match.url, previousSchema.id, queryParams] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n const onCloseCardPrompt = () => {\n const updatedSelectedMenuItem = {\n ...selectedMenuItem,\n isDisplayedPrompt: false\n };\n const [{ header, items }] = menuItems;\n const updatedItems = items.map(\n item => (item.name === selectedMenuItem.name ? updatedSelectedMenuItem : item)\n );\n setMenuItems([{ header, items: updatedItems }]);\n };\n\n const toggleModal = item => {\n setModalStatus(!!item);\n setItemToDelete(item || {});\n };\n\n const deleteAction = async () => {\n await availableActions.delete.submit(\n {\n entitySchema,\n parsedFormValues: { id: itemToDelete.id },\n client\n },\n addToast\n );\n\n toggleModal();\n\n const updatedTableData = {\n ...tableData,\n rows: tableData.rows.filter(({ id }) => id !== itemToDelete.id)\n };\n\n setTableData(updatedTableData);\n };\n\n const handleSort = async event => {\n const [[property, direction]] = Object.entries(event);\n const sortQueryParams = {\n ...queryParamsDefault,\n sort: [{ property, direction }]\n };\n setScrollToIndex(0);\n setVerifiedRanges([]);\n setQueryParams(sortQueryParams);\n\n const data = await fetchData({\n client,\n querySettings: {\n entitySchema,\n queryParams: sortQueryParams\n }\n });\n const { columns } = tableData;\n const [firstColumn] = columns;\n\n setTableData({\n ...tableData,\n appliedSort: { [property]: direction },\n rows: formatRows({ rows: data, url: match.url, toggleModal, firstColumn })\n });\n };\n\n const handleRenderedItems = async params => {\n const { startIndex } = params;\n const rowsLength = tableData.rows.length;\n const loadIndex = Math.floor(rowsLength / 3) - OVER_SCAN_BUFFER;\n if (loadIndex > 0 && loadIndex < startIndex && !verifiedRanges.includes(loadIndex)) {\n const updatedQueryParams = {\n ...queryParams,\n offset: rowsLength\n };\n const data = await fetchData({\n client,\n querySettings: {\n entitySchema,\n queryParams: updatedQueryParams\n }\n });\n const updatedRows = [\n ...tableData.rows,\n ...formatRows({ rows: data, url: match.url, toggleModal })\n ];\n\n setVerifiedRanges([...verifiedRanges, loadIndex]);\n setQueryParams(updatedQueryParams);\n setTableData({\n ...tableData,\n rows: updatedRows\n });\n setScrollToIndex(startIndex + OVER_SCAN_BUFFER);\n }\n };\n\n if (!tableData || !tableData.rows) return 'loading';\n\n return (\n <div className=\"page\">\n {modalStatus && (\n <DeleteAction\n onClose={toggleModal}\n deleteAction={deleteAction}\n itemName={itemToDelete.name}\n />\n )}\n <PageHeader title={entitySchema.displayName} subtitle=\"\">\n {(!selectedMenuItem.isDisplayedPrompt || !!tableData.rows.length) && (\n <Fragment>\n <Link\n data-testid=\"addEntity\"\n className=\"button button--small\"\n to={`${match.url}/create`}>\n Add\n </Link>\n <PageHeader.Actions>\n <More>\n <More.Avatar isMoreMenu>\n <span className=\"material-icons\">more_vert</span>\n </More.Avatar>\n <More.Content isMoreMenu />\n </More>\n </PageHeader.Actions>\n </Fragment>\n )}\n </PageHeader>\n <ListingTableContent\n overScanBuffer={OVER_SCAN_BUFFER}\n onSort={handleSort}\n onRenderItems={handleRenderedItems}\n tableData={tableData}\n onCloseCardPrompt={onCloseCardPrompt}\n selectedMenuItem={selectedMenuItem}\n scrollToIndex={scrollToIndex}\n />\n </div>\n );\n};\nListingTable.propTypes = {\n entitySchema: PropTypes.object.isRequired,\n match: PropTypes.object.isRequired,\n selectedMenuItem: PropTypes.object.isRequired\n};\n\nexport default withRouter(ListingTable);\n"],"mappings":";;;AAAA,SAASA,eAAe,QAAQ,gBAAgB;AAChD,OAAOC,KAAK,IAAIC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,OAAO;AAC5D,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,UAAU,EAAEC,IAAI,QAAQ,kBAAkB;AACnD,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,WAAW,EAAEC,cAAc,QAAQ,2BAA2B;AACvE,SAASC,UAAU,EAAEC,YAAY,QAAQ,kBAAkB;AAC3D,SAASC,SAAS,QAAQ,sBAAsB;AAChD,OAAOC,mBAAmB,MAAM,uBAAuB;AACvD,OAAOC,gBAAgB,MAAM,0CAA0C;AACvE,SAASC,SAAS,QAAQ,WAAW;AACrC,SAASC,YAAY,EAAEC,UAAU,QAAQ,yBAAyB;AAClE,SAASC,qBAAqB,QAAQ,sCAAsC;AAE5E,MAAMC,gBAAgB,GAAG,EAAE;AAE3B,MAAMC,YAAY,GAAGA,CAAC;EAAEC,KAAK;EAAEC,YAAY;EAAEC;AAAiB,CAAC,KAAK;EAClE,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGvB,QAAQ,CAAC,CAAC,CAAC,CAAC;EAC9C,MAAM,CAACwB,WAAW,EAAEC,cAAc,CAAC,GAAGzB,QAAQ,CAAC,KAAK,CAAC;EACrD,MAAM,CAAC0B,YAAY,EAAEC,eAAe,CAAC,GA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9DlF,KAAA,CAAA0F,aAAA,CAACvF,QAAQ,qBACPH,KAAA,CAAA0F,aAAA,CAACpF,IAAI;IACH,eAAY,WAAW;IACvBqF,SAAS,EAAC,sBAAsB;IAChCM,EAAE,EAAG,GAAE5E,KAAK,CAAC4B,GAAI;EAAS,GAAC,KAEvB,CAAC,eACPjD,KAAA,CAAA0F,aAAA,CAAChF,UAAU,CAACwF,OAAO,qBACjBlG,KAAA,CAAA0F,aAAA,CAACnF,IAAI,qBACHP,KAAA,CAAA0F,aAAA,CAACnF,IAAI,CAAC4F,MAAM;IAACC,UAAU;EAAA,gBACrBpG,KAAA,CAAA0F,aAAA;IAAMC,SAAS,EAAC;EAAgB,GAAC,WAAe,CACrC,CAAC,eACd3F,KAAA,CAAA0F,aAAA,CAACnF,IAAI,CAAC8F,OAAO;IAACD,UAAU;EAAA,CAAE,CACtB,CACY,CACZ,CAEF,CAAC,eACbpG,KAAA,CAAA0F,aAAA,CAAC7E,mBAAmB;IAClByF,cAAc,EAAEnF,gBAAiB;IACjCoF,MAAM,EAAEpC,UAAW;IACnBqC,aAAa,EAAE1B,mBAAoB;IACnCtD,SAAS,EAAEA,SAAU;IACrB2B,iBAAiB,EAAEA,iBAAkB;IACrC5B,gBAAgB,EAAEA,gBAAiB;IACnCU,aAAa,EAAEA;EAAc,CAC9B,CACE,CAAC;AAEV,CAAC;AACDb,YAAY,CAACqF,SAAS,GAAG;EACvBnF,YAAY,EAAElB,SAAS,CAACsG,MAAM,CAACC,UAAU;EACzCtF,KAAK,EAAEjB,SAAS,CAACsG,MAAM,CAACC,UAAU;EAClCpF,gBAAgB,EAAEnB,SAAS,CAACsG,MAAM,CAACC;AACrC,CAAC;AAED,eAAetG,UAAU,CAACe,YAAY,CAAC"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Table from '@blaze-react/table';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import {
|
|
4
|
+
import { CardPrompt } from '@blaze-cms/admin';
|
|
5
|
+
import { Link, withRouter } from 'react-router-dom';
|
|
5
6
|
const ListingTableContent = ({
|
|
6
7
|
tableData,
|
|
7
8
|
handleSelect,
|
|
9
|
+
onCloseCardPrompt,
|
|
10
|
+
selectedMenuItem,
|
|
11
|
+
match,
|
|
8
12
|
onSort,
|
|
9
13
|
onClickRow,
|
|
10
14
|
overScanBuffer,
|
|
@@ -12,12 +16,8 @@ const ListingTableContent = ({
|
|
|
12
16
|
scrollToIndex
|
|
13
17
|
}) => {
|
|
14
18
|
const displayTable = tableData && tableData.rows && !!tableData.rows.length;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} = tableData;
|
|
18
|
-
const className = `page__content${isEnquiry ? ' array-table' : ''}`;
|
|
19
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, displayTable && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
20
|
-
className: className
|
|
19
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, displayTable ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
className: "page__content"
|
|
21
21
|
}, /*#__PURE__*/React.createElement(Table, {
|
|
22
22
|
scrollToIndex: scrollToIndex,
|
|
23
23
|
onSort: onSort,
|
|
@@ -25,13 +25,22 @@ const ListingTableContent = ({
|
|
|
25
25
|
overScanBuffer: overScanBuffer,
|
|
26
26
|
onRenderItems: onRenderItems,
|
|
27
27
|
data: tableData,
|
|
28
|
-
checkboxes:
|
|
28
|
+
checkboxes: true,
|
|
29
29
|
onSelect: handleSelect,
|
|
30
30
|
"data-testid": "listing-table-content"
|
|
31
|
-
})))
|
|
31
|
+
}))) : selectedMenuItem.isDisplayedPrompt && /*#__PURE__*/React.createElement(CardPrompt, {
|
|
32
|
+
onClose: onCloseCardPrompt,
|
|
33
|
+
"data-testid": "card-prompt"
|
|
34
|
+
}, /*#__PURE__*/React.createElement(Link, {
|
|
35
|
+
className: "button button--rounded button--cta",
|
|
36
|
+
to: `${match.url}/create`,
|
|
37
|
+
"data-testid": "add-button"
|
|
38
|
+
}, "Add")));
|
|
32
39
|
};
|
|
33
40
|
ListingTableContent.propTypes = {
|
|
34
41
|
tableData: PropTypes.object.isRequired,
|
|
42
|
+
onCloseCardPrompt: PropTypes.func.isRequired,
|
|
43
|
+
selectedMenuItem: PropTypes.object.isRequired,
|
|
35
44
|
match: PropTypes.shape({
|
|
36
45
|
url: PropTypes.string
|
|
37
46
|
}).isRequired,
|
|
@@ -48,8 +57,7 @@ ListingTableContent.defaultProps = {
|
|
|
48
57
|
onClickRow: () => {},
|
|
49
58
|
overScanBuffer: 0,
|
|
50
59
|
scrollToIndex: 0,
|
|
51
|
-
onRenderItems: () => {}
|
|
52
|
-
selectedMenuItem: null
|
|
60
|
+
onRenderItems: () => {}
|
|
53
61
|
};
|
|
54
62
|
export default withRouter(ListingTableContent);
|
|
55
63
|
//# sourceMappingURL=ListingTableContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListingTableContent.js","names":["React","Table","PropTypes","withRouter","ListingTableContent","tableData","handleSelect","onSort","onClickRow","overScanBuffer","onRenderItems","scrollToIndex","displayTable","rows","length","
|
|
1
|
+
{"version":3,"file":"ListingTableContent.js","names":["React","Table","PropTypes","CardPrompt","Link","withRouter","ListingTableContent","tableData","handleSelect","onCloseCardPrompt","selectedMenuItem","match","onSort","onClickRow","overScanBuffer","onRenderItems","scrollToIndex","displayTable","rows","length","createElement","Fragment","className","data","checkboxes","onSelect","isDisplayedPrompt","onClose","to","url","propTypes","object","isRequired","func","shape","string","number","defaultProps"],"sources":["../../../../src/components/ListingTable/ListingTableContent/ListingTableContent.js"],"sourcesContent":["import React from 'react';\nimport Table from '@blaze-react/table';\nimport PropTypes from 'prop-types';\nimport { CardPrompt } from '@blaze-cms/admin';\nimport { Link, withRouter } from 'react-router-dom';\n\nconst ListingTableContent = ({\n tableData,\n handleSelect,\n onCloseCardPrompt,\n selectedMenuItem,\n match,\n onSort,\n onClickRow,\n overScanBuffer,\n onRenderItems,\n scrollToIndex\n}) => {\n const displayTable = tableData && tableData.rows && !!tableData.rows.length;\n\n return (\n <>\n {displayTable ? (\n <>\n <div className=\"page__content\">\n <Table\n scrollToIndex={scrollToIndex}\n onSort={onSort}\n onClickRow={onClickRow}\n overScanBuffer={overScanBuffer}\n onRenderItems={onRenderItems}\n data={tableData}\n checkboxes\n onSelect={handleSelect}\n data-testid=\"listing-table-content\"\n />\n </div>\n </>\n ) : (\n selectedMenuItem.isDisplayedPrompt && (\n <CardPrompt onClose={onCloseCardPrompt} data-testid=\"card-prompt\">\n <Link\n className=\"button button--rounded button--cta\"\n to={`${match.url}/create`}\n data-testid=\"add-button\">\n Add\n </Link>\n </CardPrompt>\n )\n )}\n </>\n );\n};\n\nListingTableContent.propTypes = {\n tableData: PropTypes.object.isRequired,\n onCloseCardPrompt: PropTypes.func.isRequired,\n selectedMenuItem: PropTypes.object.isRequired,\n match: PropTypes.shape({\n url: PropTypes.string\n }).isRequired,\n handleSelect: PropTypes.func,\n onSort: PropTypes.func,\n onClickRow: PropTypes.func,\n overScanBuffer: PropTypes.number,\n scrollToIndex: PropTypes.number,\n onRenderItems: PropTypes.func\n};\n\nListingTableContent.defaultProps = {\n handleSelect: () => {},\n onSort: () => {},\n onClickRow: () => {},\n overScanBuffer: 0,\n scrollToIndex: 0,\n onRenderItems: () => {}\n};\n\nexport default withRouter(ListingTableContent);\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,KAAK,MAAM,oBAAoB;AACtC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,IAAI,EAAEC,UAAU,QAAQ,kBAAkB;AAEnD,MAAMC,mBAAmB,GAAGA,CAAC;EAC3BC,SAAS;EACTC,YAAY;EACZC,iBAAiB;EACjBC,gBAAgB;EAChBC,KAAK;EACLC,MAAM;EACNC,UA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B,CAAC,CAAC,CAACH,UAAU;EACbxB,YAAY,EAAEN,SAAS,CAAC+B,IAAI;EAC5BrB,MAAM,EAAEV,SAAS,CAAC+B,IAAI;EACtBpB,UAAU,EAAEX,SAAS,CAAC+B,IAAI;EAC1BnB,cAAc,EAAEZ,SAAS,CAACkC,MAAM;EAChCpB,aAAa,EAAEd,SAAS,CAACkC,MAAM;EAC/BrB,aAAa,EAAEb,SAAS,CAAC+B;AAC3B,CAAC;AAED3B,mBAAmB,CAAC+B,YAAY,GAAG;EACjC7B,YAAY,EAAEA,CAAA,KAAM,CAAC,CAAC;EACtBI,MAAM,EAAEA,CAAA,KAAM,CAAC,CAAC;EAChBC,UAAU,EAAEA,CAAA,KAAM,CAAC,CAAC;EACpBC,cAAc,EAAE,CAAC;EACjBE,aAAa,EAAE,CAAC;EAChBD,aAAa,EAAEA,CAAA,KAAM,CAAC;AACxB,CAAC;AAED,eAAeV,UAAU,CAACC,mBAAmB,CAAC"}
|
|
@@ -10,22 +10,20 @@ const formatRows = ({
|
|
|
10
10
|
url,
|
|
11
11
|
toggleModal,
|
|
12
12
|
label,
|
|
13
|
-
firstColumn = 'name'
|
|
14
|
-
isEnquiry
|
|
13
|
+
firstColumn = 'name'
|
|
15
14
|
}) => rows.map(data => {
|
|
16
15
|
const editUrl = `${url}/update/${data.id}`;
|
|
17
|
-
|
|
16
|
+
return _objectSpread(_objectSpread({}, data), {}, {
|
|
18
17
|
[firstColumn]: /*#__PURE__*/React.createElement(Link, {
|
|
19
18
|
to: editUrl,
|
|
20
19
|
role: "button"
|
|
21
|
-
}, data[firstColumn])
|
|
20
|
+
}, data[firstColumn]),
|
|
21
|
+
actions: /*#__PURE__*/React.createElement(TableActions, {
|
|
22
|
+
editUrl: editUrl,
|
|
23
|
+
data: data,
|
|
24
|
+
showDeleteModal: toggleModal
|
|
25
|
+
})
|
|
22
26
|
});
|
|
23
|
-
if (!isEnquiry) rowProps.actions = /*#__PURE__*/React.createElement(TableActions, {
|
|
24
|
-
editUrl: editUrl,
|
|
25
|
-
data: data,
|
|
26
|
-
showDeleteModal: toggleModal
|
|
27
|
-
});
|
|
28
|
-
return rowProps;
|
|
29
27
|
});
|
|
30
28
|
const getSanitizedColumnLabel = columnProp => {
|
|
31
29
|
let sanitizedChar = '';
|
|
@@ -34,57 +32,14 @@ const getSanitizedColumnLabel = columnProp => {
|
|
|
34
32
|
}
|
|
35
33
|
return sanitizedChar;
|
|
36
34
|
};
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}) => /*#__PURE__*/React.createElement("div", {
|
|
46
|
-
className: "table-row-list__group__item"
|
|
47
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
48
|
-
className: "table-row-list__group__item__label"
|
|
49
|
-
}, " ", label, ":"), url ? /*#__PURE__*/React.createElement(Link, {
|
|
50
|
-
to: url,
|
|
51
|
-
role: "button",
|
|
52
|
-
className: "table-row-list__group__item__value"
|
|
53
|
-
}, value) : /*#__PURE__*/React.createElement("span", {
|
|
54
|
-
className: "table-row-list__group__item__value"
|
|
55
|
-
}, " ", value))))));
|
|
56
|
-
const buildArrayRowData = rowData => {
|
|
57
|
-
const dataGroups = [];
|
|
58
|
-
const groups = Math.ceil(rowData.length / 3) || 1;
|
|
59
|
-
for (let index = 0; index < groups; index += 1) {
|
|
60
|
-
const currentStart = index * groups;
|
|
61
|
-
dataGroups[index] = rowData.slice(currentStart, currentStart + 3);
|
|
62
|
-
}
|
|
63
|
-
return buildArrayRowContent(dataGroups);
|
|
64
|
-
};
|
|
65
|
-
const getParsedRowData = rows => rows.map(rowData => Object.keys(rowData).reduce((acc, key) => {
|
|
66
|
-
const parsedData = Array.isArray(rowData[key]) ? buildArrayRowData(rowData[key]) : rowData[key];
|
|
67
|
-
return _objectSpread(_objectSpread({}, acc), {}, {
|
|
68
|
-
[key]: parsedData
|
|
69
|
-
});
|
|
70
|
-
}, {}));
|
|
71
|
-
const getColumnsAndLabels = (listingProperties, allProperties, rows) => {
|
|
72
|
-
const columns = [];
|
|
73
|
-
const labels = {};
|
|
74
|
-
listingProperties.forEach(listingProperty => {
|
|
75
|
-
const propKey = listingProperty.includes(' ') ? listingProperty.split(' ')[0] : listingProperty;
|
|
76
|
-
const {
|
|
77
|
-
label
|
|
78
|
-
} = allProperties[propKey] || {};
|
|
79
|
-
columns.push(propKey);
|
|
80
|
-
labels[propKey] = label || getSanitizedColumnLabel(propKey);
|
|
81
|
-
});
|
|
82
|
-
const parsedRowData = getParsedRowData(rows);
|
|
83
|
-
return {
|
|
84
|
-
columns,
|
|
85
|
-
labels,
|
|
86
|
-
parsedRowData
|
|
87
|
-
};
|
|
35
|
+
const getColumnLabels = (listingProperties, properties, dynamicProperties) => {
|
|
36
|
+
const allProperties = _objectSpread(_objectSpread({}, properties), dynamicProperties);
|
|
37
|
+
return listingProperties.reduce((acc, listingProperty) => {
|
|
38
|
+
const label = allProperties[listingProperty].label || getSanitizedColumnLabel(listingProperty);
|
|
39
|
+
return _objectSpread(_objectSpread({}, acc), {
|
|
40
|
+
[listingProperty]: label
|
|
41
|
+
});
|
|
42
|
+
}, {});
|
|
88
43
|
};
|
|
89
44
|
const populateRows = ({
|
|
90
45
|
toggleModal,
|
|
@@ -93,21 +48,16 @@ const populateRows = ({
|
|
|
93
48
|
rows
|
|
94
49
|
}) => {
|
|
95
50
|
const {
|
|
96
|
-
id: schemaId,
|
|
97
51
|
listingProperties,
|
|
98
52
|
properties,
|
|
99
53
|
dynamicProperties = {},
|
|
100
54
|
formProperties
|
|
101
55
|
} = entitySchema;
|
|
102
|
-
const
|
|
103
|
-
const columnOptions = !isEnquiry ? [...listingProperties, ACTIONS] : [...listingProperties];
|
|
104
|
-
const allProperties = _objectSpread(_objectSpread({}, properties), dynamicProperties);
|
|
105
|
-
const {
|
|
106
|
-
columns,
|
|
107
|
-
labels,
|
|
108
|
-
parsedRowData
|
|
109
|
-
} = getColumnsAndLabels(columnOptions, allProperties, rows);
|
|
56
|
+
const columns = [...listingProperties, ACTIONS];
|
|
110
57
|
const [firstColumn] = columns;
|
|
58
|
+
const labels = _objectSpread(_objectSpread({}, getColumnLabels(listingProperties, properties, dynamicProperties)), {}, {
|
|
59
|
+
[ACTIONS]: ACTIONS
|
|
60
|
+
});
|
|
111
61
|
return {
|
|
112
62
|
identification: 'id',
|
|
113
63
|
sort: null,
|
|
@@ -116,13 +66,11 @@ const populateRows = ({
|
|
|
116
66
|
orderBy: [...formProperties],
|
|
117
67
|
rows: formatRows({
|
|
118
68
|
firstColumn,
|
|
119
|
-
rows
|
|
69
|
+
rows,
|
|
120
70
|
url,
|
|
121
|
-
toggleModal
|
|
122
|
-
|
|
123
|
-
}),
|
|
124
|
-
isEnquiry
|
|
71
|
+
toggleModal
|
|
72
|
+
})
|
|
125
73
|
};
|
|
126
74
|
};
|
|
127
|
-
export { populateRows, formatRows
|
|
75
|
+
export { populateRows, formatRows };
|
|
128
76
|
//# sourceMappingURL=populate-rows.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"populate-rows.js","names":["React","Link","TableActions","ACTIONS","formatRows","rows","url","toggleModal","label","firstColumn","
|
|
1
|
+
{"version":3,"file":"populate-rows.js","names":["React","Link","TableActions","ACTIONS","formatRows","rows","url","toggleModal","label","firstColumn","map","data","editUrl","id","_objectSpread","createElement","to","role","actions","showDeleteModal","getSanitizedColumnLabel","columnProp","sanitizedChar","index","length","toUpperCase","toLowerCase","getColumnLabels","listingProperties","properties","dynamicProperties","allProperties","reduce","acc","listingProperty","populateRows","entitySchema","formProperties","columns","labels","identification","sort","orderBy"],"sources":["../../../../src/components/ListingTable/mappers/populate-rows.js"],"sourcesContent":["import React from 'react';\nimport { Link } from 'react-router-dom';\nimport TableActions from '../TableActions';\nimport { ACTIONS } from '../../../constants';\n\nconst formatRows = ({ rows, url, toggleModal, label, firstColumn = 'name' }) =>\n rows.map(data => {\n const editUrl = `${url}/update/${data.id}`;\n return {\n ...data,\n [firstColumn]: (\n <Link to={editUrl} role=\"button\">\n {data[firstColumn]}\n </Link>\n ),\n actions: <TableActions editUrl={editUrl} data={data} showDeleteModal={toggleModal} />\n };\n });\n\nconst getSanitizedColumnLabel = columnProp => {\n let sanitizedChar = '';\n\n for (let index = 0; index < columnProp.length; index += 1) {\n if (index && columnProp[index] === columnProp[index].toUpperCase())\n sanitizedChar = `${sanitizedChar} ${columnProp[index].toLowerCase()}`;\n else sanitizedChar += columnProp[index];\n }\n return sanitizedChar;\n};\n\nconst getColumnLabels = (listingProperties, properties, dynamicProperties) => {\n const allProperties = { ...properties, ...dynamicProperties };\n return listingProperties.reduce((acc, listingProperty) => {\n const label = allProperties[listingProperty].label || getSanitizedColumnLabel(listingProperty);\n return { ...acc, ...{ [listingProperty]: label } };\n }, {});\n};\n\nconst populateRows = ({ toggleModal, url, entitySchema, rows }) => {\n const { listingProperties, properties, dynamicProperties = {}, formProperties } = entitySchema;\n const columns = [...listingProperties, ACTIONS];\n const [firstColumn] = columns;\n const labels = {\n ...getColumnLabels(listingProperties, properties, dynamicProperties),\n [ACTIONS]: ACTIONS\n };\n\n return {\n identification: 'id',\n sort: null,\n columns,\n labels,\n orderBy: [...formProperties],\n rows: formatRows({ firstColumn, rows, url, toggleModal })\n };\n};\n\nexport { populateRows, formatRows };\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,kBAAkB;AACvC,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,MAAMC,UAAU,GAAGA,CAAC;EAAEC,IAAI;EAAEC,GAAG;EAAEC,WAAW;EAAEC,KAAK;EAAEC,WAAW,GAAG;AAAO,CAAC,KACzEJ,IAAI,CAACK,GAAG,CAACC,IAAI,IAAI;EACf,MAAMC,OAAO,GAAI,GAAEN,GAAI,WAAUK,IAAI,CAACE,EAAG,EAAC;EAC1C,OAAAC,aAAA,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C,EAAE,CAAC,CAAC,CAAC;AACR,CAAC;AAED,MAAM2B,YAAY,GAAGA,CAAC;EAAE5B,WAAW;EAAED,GAAG;EAAE8B,YAAY;EAAE/B;AAAK,CAAC,KAAK;EACjE,MAAM;IAAEuB,iBAAiB;IAAEC,UAAU;IAAEC,iBAAiB,GAAG,CAAC,CAAC;IAAEO;EAAe,CAAC,GAAGD,YAAY;EAC9F,MAAME,OAAO,GAAG,CAAC,GAAGV,iBAAiB,EAAEzB,OAAO,CAAC;EAC/C,MAAM,CAACM,WAAW,CAAC,GAAG6B,OAAO;EAC7B,MAAMC,MAAM,GAAAzB,aAAA,CAAAA,aAAA,KACPa,eAAe,CAACC,iBAAiB,EAAEC,UAAU,EAAEC,iBAAiB,CAAC;IACpE,CAAC3B,OAAO,GAAGA;EAAO,EACnB;EAED,OAAO;IACLqC,cAAc,EAAE,IAAI;IACpBC,IAAI,EAAE,IAAI;IACVH,OAAO;IACPC,MAAM;IACNG,OAAO,EAAE,CAAC,GAAGL,cAAc,CAAC;IAC5BhC,IAAI,EAAED,UAAU,CAAC;MAAEK,WAAW;MAAEJ,IAAI;MAAEC,GAAG;MAAEC;IAAY,CAAC;EAC1D,CAAC;AACH,CAAC;AAED,SAAS4B,YAAY,EAAE/B,UAAU"}
|
|
@@ -1,80 +1,22 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
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; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).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; }
|
|
4
1
|
import buildListingQuery from '../../../utils/build-listing-query';
|
|
5
|
-
function buildVariables({
|
|
6
|
-
entitySchema,
|
|
7
|
-
isSearchQuery,
|
|
8
|
-
listFilters = [],
|
|
9
|
-
queryParams = {}
|
|
10
|
-
}) {
|
|
11
|
-
const {
|
|
12
|
-
identifier
|
|
13
|
-
} = entitySchema;
|
|
14
|
-
const {
|
|
15
|
-
sort,
|
|
16
|
-
offset,
|
|
17
|
-
limit,
|
|
18
|
-
where
|
|
19
|
-
} = queryParams;
|
|
20
|
-
const [{
|
|
21
|
-
property,
|
|
22
|
-
direction
|
|
23
|
-
}] = sort;
|
|
24
|
-
const parsedOffset = `${property}:${direction}`;
|
|
25
|
-
if (!isSearchQuery) return _objectSpread(_objectSpread({}, queryParams), {}, {
|
|
26
|
-
where: !Array.isArray(listFilters) ? listFilters : where
|
|
27
|
-
});
|
|
28
|
-
const rawQuery = {
|
|
29
|
-
bool: {
|
|
30
|
-
must: listFilters || [],
|
|
31
|
-
filter: [{
|
|
32
|
-
term: {
|
|
33
|
-
entityIdentifier: identifier
|
|
34
|
-
}
|
|
35
|
-
}]
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
return {
|
|
39
|
-
limit,
|
|
40
|
-
offset,
|
|
41
|
-
sort: parsedOffset,
|
|
42
|
-
where: JSON.stringify(rawQuery)
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
2
|
const fetchData = async ({
|
|
46
3
|
client,
|
|
47
4
|
querySettings: {
|
|
48
5
|
entitySchema,
|
|
49
6
|
queryParams
|
|
50
|
-
}
|
|
51
|
-
listFilters
|
|
7
|
+
}
|
|
52
8
|
}) => {
|
|
9
|
+
const query = buildListingQuery(entitySchema);
|
|
53
10
|
const {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
source
|
|
58
|
-
} = {}
|
|
59
|
-
} = {}
|
|
60
|
-
} = {}
|
|
61
|
-
} = entitySchema;
|
|
62
|
-
const isSearchQuery = source === 'search';
|
|
63
|
-
const query = buildListingQuery(entitySchema, isSearchQuery);
|
|
64
|
-
const variables = buildVariables({
|
|
65
|
-
entitySchema,
|
|
66
|
-
listFilters,
|
|
67
|
-
queryParams,
|
|
68
|
-
isSearchQuery
|
|
69
|
-
});
|
|
70
|
-
const {
|
|
71
|
-
data = {}
|
|
11
|
+
data: {
|
|
12
|
+
listingData
|
|
13
|
+
}
|
|
72
14
|
} = await client.query({
|
|
73
15
|
query,
|
|
74
|
-
variables,
|
|
16
|
+
variables: queryParams,
|
|
75
17
|
fetchPolicy: 'network-only'
|
|
76
18
|
});
|
|
77
|
-
return
|
|
19
|
+
return listingData;
|
|
78
20
|
};
|
|
79
21
|
export { fetchData };
|
|
80
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["buildListingQuery","
|
|
1
|
+
{"version":3,"file":"index.js","names":["buildListingQuery","fetchData","client","querySettings","entitySchema","queryParams","query","data","listingData","variables","fetchPolicy"],"sources":["../../../../src/components/ListingTable/service/index.js"],"sourcesContent":["import buildListingQuery from '../../../utils/build-listing-query';\n\nconst fetchData = async ({ client, querySettings: { entitySchema, queryParams } }) => {\n const query = buildListingQuery(entitySchema);\n const {\n data: { listingData }\n } = await client.query({ query, variables: queryParams, fetchPolicy: 'network-only' });\n\n return listingData;\n};\n\nexport { fetchData };\n"],"mappings":"AAAA,OAAOA,iBAAiB,MAAM,oCAAoC;AAElE,MAAMC,SAAS,GAAG,MAAAA,CAAO;EAAEC,MAAM;EAAEC,aAAa,EAAE;IAAEC,YAAY;IAAEC;EAAY;AAAE,CAAC,KAAK;EACpF,MAAMC,KAAK,GAAGN,iBAAiB,CAACI,YAAY,CAAC;EAC7C,MAAM;IACJG,IAAI,EAAE;MAAEC;IAAY;EACtB,CAAC,GAAG,MAAMN,MAAM,CAACI,KAAK,CAAC;IAAEA,KAAK;IAAEG,SAAS,EAAEJ,WAAW;IAAEK,WAAW,EAAE;EAAe,CAAC,CAAC;EAEtF,OAAOF,WAAW;AACpB,CAAC;AAED,SAASP,SAAS"}
|