@blaze-cms/plugin-data-ui 0.139.0 → 0.139.1-alpha.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 +12 -0
- package/lib/components/EntityManager/Entity/Entity.js +18 -7
- package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +9 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -1
- package/lib/components/EntityManager/utils/RecordEditContext/index.js +13 -0
- package/lib/components/EntityManager/utils/RecordEditContext/index.js.map +1 -0
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js +17 -2
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -1
- package/lib/components/InfoBoxes/hooks/useData.js +4 -2
- package/lib/components/InfoBoxes/hooks/useData.js.map +1 -1
- package/lib/components/ListingTable/ListingTable.js +2 -10
- package/lib/components/ListingTable/ListingTable.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/Entity.js +11 -3
- package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +10 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -1
- package/lib-es/components/EntityManager/utils/RecordEditContext/index.js +6 -0
- package/lib-es/components/EntityManager/utils/RecordEditContext/index.js.map +1 -0
- package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js +10 -2
- package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -1
- package/lib-es/components/InfoBoxes/hooks/useData.js +4 -2
- package/lib-es/components/InfoBoxes/hooks/useData.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTable.js +2 -7
- package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
- package/package.json +5 -5
- package/src/components/EntityManager/Entity/Entity.js +86 -75
- package/src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +12 -1
- package/src/components/EntityManager/utils/RecordEditContext/index.js +7 -0
- package/src/components/InfoBoxes/container/InfoBoxContainer.js +12 -2
- package/src/components/InfoBoxes/hooks/useData.js +5 -2
- package/src/components/ListingTable/ListingTable.js +11 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/plugin-data-ui",
|
|
3
|
-
"version": "0.139.0",
|
|
3
|
+
"version": "0.139.1-alpha.0",
|
|
4
4
|
"description": "Blaze plugin data ui",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"@blaze-cms/admin-ui-utils": "^0.139.0",
|
|
31
31
|
"@blaze-cms/core-errors": "^0.139.0",
|
|
32
32
|
"@blaze-cms/plugin-render-hooks-ui": "^0.139.0",
|
|
33
|
-
"@blaze-cms/react-form-builder": "
|
|
34
|
-
"@blaze-cms/react-page-builder": "
|
|
33
|
+
"@blaze-cms/react-form-builder": "0.139.1-alpha.0",
|
|
34
|
+
"@blaze-cms/react-page-builder": "0.139.1-alpha.0",
|
|
35
35
|
"@blaze-cms/setup-ui": "^0.139.0",
|
|
36
36
|
"@blaze-cms/versioning-ui": "^0.139.0",
|
|
37
37
|
"@blaze-react/button": "0.5.19",
|
|
38
38
|
"@blaze-react/more": "0.5.19",
|
|
39
39
|
"@blaze-react/multiselect": "0.6.6",
|
|
40
|
-
"@blaze-react/select": "0.
|
|
40
|
+
"@blaze-react/select": "0.8.0-alpha.64",
|
|
41
41
|
"@blaze-react/table": "0.5.31",
|
|
42
42
|
"@blaze-react/toaster": "0.5.17",
|
|
43
43
|
"@blaze-react/utils": "0.5.15",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"lib/*",
|
|
67
67
|
"lib-es/*"
|
|
68
68
|
],
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "d31f49b1c9609bd8ef1f34b8b4f533295b0a440f"
|
|
70
70
|
}
|
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
} from '../utils/entity';
|
|
37
37
|
import useToggle from '../../../utils/hooks/useToggle';
|
|
38
38
|
import InfoBoxes from '../../InfoBoxes/InfoBoxes';
|
|
39
|
+
import { RecordEditContextProvider } from '../utils/RecordEditContext';
|
|
39
40
|
|
|
40
41
|
const Entity = ({
|
|
41
42
|
formData,
|
|
@@ -68,6 +69,7 @@ const Entity = ({
|
|
|
68
69
|
const [formDataFromCopy, setFormDataFromCopy] = useState(null);
|
|
69
70
|
const [newUpdatedDate, setNewUpdatedDate] = useState(null);
|
|
70
71
|
const [saveButtonText, setSaveButtonText] = useState(SAVE_BUTTON_TEXTS.save);
|
|
72
|
+
const [externalUpdateTime, setExternalUpdateTime] = useState(null);
|
|
71
73
|
|
|
72
74
|
const isCreatePage = history.location.pathname.includes('create');
|
|
73
75
|
const [isNewEntity, setIsNewEntity] = useState(isCreatePage);
|
|
@@ -238,6 +240,7 @@ const Entity = ({
|
|
|
238
240
|
if (componentIsMounted.current) {
|
|
239
241
|
setIsFormValid(isValid);
|
|
240
242
|
}
|
|
243
|
+
|
|
241
244
|
if (isValidAndNewValueSet && componentIsMounted.current) {
|
|
242
245
|
setIsSaveButtonAvailable(true);
|
|
243
246
|
setSaveButtonText(SAVE_BUTTON_TEXTS.save);
|
|
@@ -404,89 +407,97 @@ const Entity = ({
|
|
|
404
407
|
schema?.interfaces?.includes('page-builder/page-builder');
|
|
405
408
|
|
|
406
409
|
return (
|
|
407
|
-
<
|
|
408
|
-
<
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
<div className="
|
|
426
|
-
<
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
<div className="page__content">
|
|
444
|
-
<div className="
|
|
445
|
-
<
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
410
|
+
<RecordEditContextProvider value={{ externalUpdateTime }}>
|
|
411
|
+
<div className="page">
|
|
412
|
+
<EntityHeader
|
|
413
|
+
entityData={entityData}
|
|
414
|
+
entityIdentifier={entityIdentifier}
|
|
415
|
+
pageTitle={pageTitle}
|
|
416
|
+
pageName={pageName}
|
|
417
|
+
onSubmit={onSubmit}
|
|
418
|
+
handlePublishAndUnpublish={handlePublishAndUnpublish}
|
|
419
|
+
isSaveButtonAvailable={isSaveButtonAvailable}
|
|
420
|
+
isEnablePublishButton={isEnablePublishButton}
|
|
421
|
+
isEnablePreviewButton={isEnablePreviewButton}
|
|
422
|
+
toggleCopyModal={setCopyModalStatus}
|
|
423
|
+
toggleModal={setModalStatus}
|
|
424
|
+
formData={formData}
|
|
425
|
+
onViewUrl={onViewUrlHandler}
|
|
426
|
+
saveButtonText={saveButtonText}
|
|
427
|
+
/>
|
|
428
|
+
<div className="page-wrapper__content">
|
|
429
|
+
<div className="tabs-wrapper tabs-wrapper__tab">
|
|
430
|
+
<Prompt when={hasToDisplayPrompt} message={LEAVE_PAGE_MESSAGE} />
|
|
431
|
+
{showModal && (
|
|
432
|
+
<DeleteAction
|
|
433
|
+
onClose={setModalStatus}
|
|
434
|
+
deleteAction={onDelete}
|
|
435
|
+
itemName={formData.values.name}
|
|
436
|
+
/>
|
|
437
|
+
)}
|
|
438
|
+
{copyModalStatus && (
|
|
439
|
+
<CopyDataFromAction
|
|
440
|
+
onClose={handleCopyDataFromClose}
|
|
441
|
+
copyAction={onCopy}
|
|
442
|
+
getFormData={getFormData}
|
|
443
|
+
/>
|
|
444
|
+
)}
|
|
445
|
+
|
|
446
|
+
<div className="page__content--fixed">
|
|
447
|
+
<div className="page__content">
|
|
448
|
+
<div className="content">
|
|
449
|
+
<RenderHook
|
|
450
|
+
hookKey={`entity:${action}:main:top`}
|
|
451
|
+
entity={entity}
|
|
452
|
+
schema={schema}
|
|
453
|
+
/>
|
|
454
|
+
<InfoBoxes id={entity.id} schema={schema} />
|
|
455
|
+
<Tabs
|
|
456
|
+
enabled={showPageBuilderTabs}
|
|
457
|
+
onTabChange={tabId => {
|
|
458
|
+
client.writeQuery({
|
|
459
|
+
query: GET_CURRENT_TAB_ID,
|
|
460
|
+
data: { currentTabId: tabId }
|
|
461
|
+
});
|
|
462
|
+
setCurrentTabId(tabId);
|
|
463
|
+
}}>
|
|
464
|
+
<FormBuilder
|
|
465
|
+
getIsFormValid={setIsFormValid}
|
|
466
|
+
getFormValues={getFormValues}
|
|
467
|
+
schema={schema}
|
|
468
|
+
data={clonedFormData}
|
|
469
|
+
onChange={onChangeFormValues}
|
|
470
|
+
shouldCopyData={shouldCopyData}
|
|
471
|
+
updateCopyData={updateCopyData}
|
|
472
|
+
formValues={formValues}
|
|
473
|
+
isNewEntity={isNewEntity}
|
|
474
|
+
onExternalUpdate={setExternalUpdateTime}
|
|
475
|
+
dataUpdatedDateTime={newUpdatedDate}
|
|
476
|
+
/>
|
|
477
|
+
</Tabs>
|
|
478
|
+
<RenderHook
|
|
479
|
+
hookKey={`entity:${action}:main:bottom`}
|
|
480
|
+
entity={entity}
|
|
459
481
|
schema={schema}
|
|
460
|
-
data={clonedFormData}
|
|
461
|
-
onChange={onChangeFormValues}
|
|
462
|
-
shouldCopyData={shouldCopyData}
|
|
463
|
-
updateCopyData={updateCopyData}
|
|
464
|
-
formValues={formValues}
|
|
465
|
-
isNewEntity={isNewEntity}
|
|
466
482
|
/>
|
|
467
|
-
</
|
|
468
|
-
<RenderHook
|
|
469
|
-
hookKey={`entity:${action}:main:bottom`}
|
|
470
|
-
entity={entity}
|
|
471
|
-
schema={schema}
|
|
472
|
-
/>
|
|
483
|
+
</div>
|
|
473
484
|
</div>
|
|
474
485
|
</div>
|
|
475
486
|
</div>
|
|
476
|
-
</div>
|
|
477
487
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
488
|
+
<div className="column column--one-third page-sidebar page-sidebar--relations">
|
|
489
|
+
{showSideBarRelations && (
|
|
490
|
+
<SideBarRelations
|
|
491
|
+
entity={entity}
|
|
492
|
+
formData={formData.values}
|
|
493
|
+
schema={schema}
|
|
494
|
+
onChange={onChangeSideBarRelations}
|
|
495
|
+
/>
|
|
496
|
+
)}
|
|
497
|
+
</div>
|
|
487
498
|
</div>
|
|
488
499
|
</div>
|
|
489
|
-
</
|
|
500
|
+
</RecordEditContextProvider>
|
|
490
501
|
);
|
|
491
502
|
};
|
|
492
503
|
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { useContext, useEffect } from 'react';
|
|
1
2
|
import ProptTypes from 'prop-types';
|
|
2
3
|
import { useQuery, gql } from '@apollo/client';
|
|
3
4
|
import buildDynamicQuery from '../helpers/build-dynamic-query';
|
|
5
|
+
import { RecordEditContext } from '../../../utils/RecordEditContext';
|
|
4
6
|
|
|
5
7
|
const useCustomSidebarData = ({ id, schema, displayProperties }) => {
|
|
8
|
+
const { externalUpdateTime } = useContext(RecordEditContext);
|
|
9
|
+
|
|
6
10
|
const query = buildDynamicQuery({ id, schema, displayProperties });
|
|
7
11
|
|
|
8
12
|
const customSidebarInfoQuery =
|
|
@@ -13,11 +17,18 @@ const useCustomSidebarData = ({ id, schema, displayProperties }) => {
|
|
|
13
17
|
}
|
|
14
18
|
`;
|
|
15
19
|
|
|
16
|
-
const { data = {}, loading, error } = useQuery(customSidebarInfoQuery, {
|
|
20
|
+
const { data = {}, loading, error, refetch } = useQuery(customSidebarInfoQuery, {
|
|
17
21
|
variables: { id },
|
|
18
22
|
skip: !query
|
|
19
23
|
});
|
|
20
24
|
|
|
25
|
+
useEffect(
|
|
26
|
+
() => {
|
|
27
|
+
refetch();
|
|
28
|
+
},
|
|
29
|
+
[externalUpdateTime, refetch]
|
|
30
|
+
);
|
|
31
|
+
|
|
21
32
|
return { data: data.__typename !== 'Query' ? data : null, loading, error };
|
|
22
33
|
};
|
|
23
34
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const RecordEditContext = React.createContext();
|
|
4
|
+
const RecordEditContextProvider = RecordEditContext.Provider;
|
|
5
|
+
const RecordEditContextConsumer = RecordEditContext.Consumer;
|
|
6
|
+
|
|
7
|
+
export { RecordEditContext, RecordEditContextProvider, RecordEditContextConsumer };
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useContext, useEffect } from 'react';
|
|
3
3
|
import useData from '../hooks/useData';
|
|
4
4
|
import InfoBox from '../presentational/InfoBox';
|
|
5
|
+
import { RecordEditContext } from '../../EntityManager/utils/RecordEditContext';
|
|
5
6
|
|
|
6
7
|
const InfoBoxContainer = ({ id, schema, infoBox }) => {
|
|
7
|
-
const {
|
|
8
|
+
const { externalUpdateTime } = useContext(RecordEditContext);
|
|
9
|
+
|
|
10
|
+
const { data, refetch } = useData({ id, schema, infoBox });
|
|
11
|
+
|
|
12
|
+
useEffect(
|
|
13
|
+
() => {
|
|
14
|
+
refetch();
|
|
15
|
+
},
|
|
16
|
+
[externalUpdateTime, refetch]
|
|
17
|
+
);
|
|
8
18
|
|
|
9
19
|
if (!data || !Object.keys(data) || Object.keys(data).length === 0) return null;
|
|
10
20
|
|
|
@@ -12,9 +12,12 @@ function useData({ id, schema, infoBox }) {
|
|
|
12
12
|
}
|
|
13
13
|
`;
|
|
14
14
|
|
|
15
|
-
const { data = {}, loading, error } = useQuery(infoBoxQuery, {
|
|
15
|
+
const { data = {}, loading, error, refetch } = useQuery(infoBoxQuery, {
|
|
16
|
+
variables: { id },
|
|
17
|
+
skip: !query
|
|
18
|
+
});
|
|
16
19
|
|
|
17
|
-
return { data: data.__typename !== 'Query' ? data : null, loading, error };
|
|
20
|
+
return { data: data.__typename !== 'Query' ? data : null, loading, error, refetch };
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
export default useData;
|
|
@@ -24,7 +24,6 @@ const ListingTable = ({ match, entitySchema }) => {
|
|
|
24
24
|
const queryParamsDefault = getDefaultQueryParams(entitySchema);
|
|
25
25
|
const [queryParams, setQueryParams] = useState(queryParamsDefault);
|
|
26
26
|
const [listFilters, setListFilters] = useState([]);
|
|
27
|
-
const [displayCardPrompt, setDisplayCardPrompt] = useState(true);
|
|
28
27
|
const client = useApolloClient();
|
|
29
28
|
const { addToast } = useToasts();
|
|
30
29
|
|
|
@@ -167,7 +166,7 @@ const ListingTable = ({ match, entitySchema }) => {
|
|
|
167
166
|
};
|
|
168
167
|
|
|
169
168
|
if (!tableData || !tableData.rows) return 'loading';
|
|
170
|
-
const showAddButton = !!tableData.rows.length
|
|
169
|
+
const showAddButton = !!tableData.rows.length;
|
|
171
170
|
|
|
172
171
|
return (
|
|
173
172
|
<div className="page">
|
|
@@ -198,20 +197,16 @@ const ListingTable = ({ match, entitySchema }) => {
|
|
|
198
197
|
</Fragment>
|
|
199
198
|
)}
|
|
200
199
|
</PageHeader>
|
|
201
|
-
{
|
|
202
|
-
|
|
203
|
-
<
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
Add
|
|
212
|
-
</Link>
|
|
213
|
-
</CardPrompt>
|
|
214
|
-
)}
|
|
200
|
+
{!showAddButton && (
|
|
201
|
+
<CardPrompt>
|
|
202
|
+
<Link
|
|
203
|
+
className="button button--rounded button--cta"
|
|
204
|
+
to={`${match.url}/create`}
|
|
205
|
+
data-testid="add-button">
|
|
206
|
+
Add
|
|
207
|
+
</Link>
|
|
208
|
+
</CardPrompt>
|
|
209
|
+
)}
|
|
215
210
|
<RenderHook
|
|
216
211
|
hookKey="entity:listing:main:top"
|
|
217
212
|
schema={entitySchema}
|