@blaze-cms/plugin-data-ui 0.146.0-rc-eagle-3.9 → 0.146.0-rc-eagle-3.11
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/lib/components/EntityManager/Entity/Entity.js +26 -1
- package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js +14 -1
- package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
- package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +16 -2
- package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
- package/lib/components/EntityManager/utils/entity.js +22 -1
- package/lib/components/EntityManager/utils/entity.js.map +1 -1
- package/lib/components/ListingTable/ListingTable.js +1 -1
- package/lib/components/ListingTable/ListingTable.js.map +1 -1
- package/lib/constants.js +3 -1
- package/lib/constants.js.map +1 -1
- package/lib/utils/add-content-menu-items.js +25 -22
- package/lib/utils/add-content-menu-items.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/Entity.js +29 -4
- package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/EntityHeader/EntityHeader.js +14 -1
- package/lib-es/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +16 -2
- package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
- package/lib-es/components/EntityManager/utils/entity.js +23 -3
- package/lib-es/components/EntityManager/utils/entity.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTable.js +1 -1
- package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
- package/lib-es/constants.js +3 -1
- package/lib-es/constants.js.map +1 -1
- package/lib-es/utils/add-content-menu-items.js +25 -22
- package/lib-es/utils/add-content-menu-items.js.map +1 -1
- package/package.json +5 -5
- package/src/components/EntityManager/Entity/Entity.js +31 -5
- package/src/components/EntityManager/Entity/EntityHeader/EntityHeader.js +17 -1
- package/src/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +19 -2
- package/src/components/EntityManager/utils/entity.js +28 -8
- package/src/components/ListingTable/ListingTable.js +1 -1
- package/src/constants.js +4 -0
- package/src/utils/add-content-menu-items.js +21 -20
|
@@ -2,6 +2,13 @@ import { getQuery } from '@blaze-cms/admin-ui-utils';
|
|
|
2
2
|
|
|
3
3
|
const { MENU_PERMISSIONS } = require('../constants');
|
|
4
4
|
|
|
5
|
+
// Menu items label a listing of many records, so they use the plural. The
|
|
6
|
+
// fallback matters: this package and the API are published independently, so an
|
|
7
|
+
// admin bundle can run against an API that does not yet resolve the field.
|
|
8
|
+
function getMenuLabel({ displayName, displayNamePlural }) {
|
|
9
|
+
return displayNamePlural || displayName || '';
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
function getAddContentMenuItems(app) {
|
|
6
13
|
return async ({ addConfig }) => {
|
|
7
14
|
const client = app.getClient();
|
|
@@ -17,30 +24,31 @@ function getAddContentMenuItems(app) {
|
|
|
17
24
|
|
|
18
25
|
if (!getEntitySchemas || !getEntitySchemas.length) return; // no items so don't add section
|
|
19
26
|
|
|
20
|
-
const menuItems = {};
|
|
21
27
|
const sectionMenuItems = { settings: {} };
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
// Order by the label that is rendered, not by displayName. getEntitySchemas
|
|
30
|
+
// is sorted on displayName server-side and that order serves every other
|
|
31
|
+
// consumer, which shows the singular, so the plural ordering belongs here.
|
|
32
|
+
// The explicit `order` is what MenuSectionItems reads to sort.
|
|
33
|
+
const orderedEntities = [...getEntitySchemas].sort((entityA, entityB) =>
|
|
34
|
+
getMenuLabel(entityA).localeCompare(getMenuLabel(entityB))
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
orderedEntities.forEach((entity, order) => {
|
|
38
|
+
const { id, displayProperties } = entity;
|
|
39
|
+
if (!displayProperties) return;
|
|
25
40
|
|
|
26
41
|
const { adminMenu: { sectionKey = 'settings' } = {} } = displayProperties;
|
|
27
42
|
const sectionItems = sectionMenuItems[sectionKey] || {};
|
|
28
43
|
sectionItems[id] = {
|
|
29
|
-
label:
|
|
44
|
+
label: getMenuLabel(entity),
|
|
45
|
+
order,
|
|
30
46
|
uri: `/data-listing/${id}`
|
|
31
47
|
};
|
|
32
48
|
sectionMenuItems[sectionKey] = sectionItems;
|
|
33
49
|
});
|
|
34
50
|
|
|
35
|
-
const menuConfig = {
|
|
36
|
-
main: {
|
|
37
|
-
items: {
|
|
38
|
-
settings: {
|
|
39
|
-
items: menuItems
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
51
|
+
const menuConfig = { main: { items: {} } };
|
|
44
52
|
|
|
45
53
|
Object.entries(sectionMenuItems).forEach(([sectionKey, sectionItems]) => {
|
|
46
54
|
const sectionConfig = menuConfig.main.items[sectionKey] || {};
|
|
@@ -48,13 +56,6 @@ function getAddContentMenuItems(app) {
|
|
|
48
56
|
menuConfig.main.items[sectionKey] = sectionConfig;
|
|
49
57
|
});
|
|
50
58
|
|
|
51
|
-
getEntitySchemas.forEach(({ id, displayName }) => {
|
|
52
|
-
menuItems[id] = {
|
|
53
|
-
label: displayName,
|
|
54
|
-
uri: `/data-listing/${id}`
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
|
|
58
59
|
addConfig(menuConfig);
|
|
59
60
|
};
|
|
60
61
|
}
|