@blaze-cms/plugin-data-ui 0.129.0-project-admin-customisations.0 → 0.129.0-project-admin-customisations.1
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/EntitiyNavLinks/EntityNavLinks.js +39 -0
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -0
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js +12 -0
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -0
- package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +44 -0
- package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -0
- package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +32 -0
- package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -0
- package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +45 -0
- package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -0
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js +12 -2
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +38 -0
- package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +30 -0
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js +3 -0
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +30 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +26 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +39 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +12 -2
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +24 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -0
- package/package.json +5 -5
- package/src/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +26 -0
- package/src/components/EntityManager/Entity/EntitiyNavLinks/index.js +3 -0
- package/src/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +22 -0
- package/src/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +33 -0
- package/src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +28 -0
- package/src/components/EntityManager/Entity/SideBarRelations/index.js +34 -16
- package/src/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +33 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.129.0-project-admin-customisations.1](https://github.com/thebyte9/blaze/compare/v0.129.0-project-admin-customisations.0...v0.129.0-project-admin-customisations.1) (2023-05-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add ability to define custom info in the admin sidebar ([#3920](https://github.com/thebyte9/blaze/issues/3920)) ([4946eaf](https://github.com/thebyte9/blaze/commit/4946eafb81647980971ac00480489b756b0efcc7))
|
|
12
|
+
* add admin entity edit section navigation in sidebar ([#3908](https://github.com/thebyte9/blaze/issues/3908)) ([0c36686](https://github.com/thebyte9/blaze/commit/0c3668674aa1dc94b797298efae6d7cbfc56b796))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
# [0.129.0-project-admin-customisations.0](https://github.com/thebyte9/blaze/compare/v0.128.2...v0.129.0-project-admin-customisations.0) (2023-05-03)
|
|
7
19
|
|
|
8
20
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.object.define-property.js");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
require("core-js/modules/es.array.map.js");
|
|
11
|
+
require("core-js/modules/es.object.entries.js");
|
|
12
|
+
require("core-js/modules/es.string.starts-with.js");
|
|
13
|
+
var _reactRouterDom = require("react-router-dom");
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
var EntityNavLinks = function EntityNavLinks(_ref) {
|
|
16
|
+
var schema = _ref.schema;
|
|
17
|
+
if (!schema) return null;
|
|
18
|
+
var adminSectionNavigation = schema.displayProperties.adminSectionNavigation;
|
|
19
|
+
if (!adminSectionNavigation) return null;
|
|
20
|
+
var links = Object.entries(adminSectionNavigation).map(function (_ref2) {
|
|
21
|
+
var _ref3 = (0, _slicedToArray2["default"])(_ref2, 2),
|
|
22
|
+
k = _ref3[0],
|
|
23
|
+
v = _ref3[1];
|
|
24
|
+
var label = v.label,
|
|
25
|
+
uri = v.uri;
|
|
26
|
+
var Wrapper = uri.startsWith('#') ? 'a' : _reactRouterDom.Link;
|
|
27
|
+
return /*#__PURE__*/_react["default"].createElement(Wrapper, {
|
|
28
|
+
className: "entity-section-link",
|
|
29
|
+
href: uri,
|
|
30
|
+
to: uri
|
|
31
|
+
}, label);
|
|
32
|
+
});
|
|
33
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
34
|
+
className: "entity-section-links"
|
|
35
|
+
}, links);
|
|
36
|
+
};
|
|
37
|
+
var _default = EntityNavLinks;
|
|
38
|
+
exports["default"] = _default;
|
|
39
|
+
//# sourceMappingURL=EntityNavLinks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityNavLinks.js","names":["_reactRouterDom","require","_react","_interopRequireDefault","EntityNavLinks","_ref","schema","adminSectionNavigation","displayProperties","links","Object","entries","map","_ref2","_ref3","_slicedToArray2","k","v","label","uri","Wrapper","startsWith","Link","createElement","className","href","to","_default","exports"],"sources":["../../../../../src/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js"],"sourcesContent":["import { Link } from 'react-router-dom';\nimport React from 'react';\n\nconst EntityNavLinks = ({ schema }) => {\n if (!schema) return null;\n\n const {\n displayProperties: { adminSectionNavigation }\n } = schema;\n\n if (!adminSectionNavigation) return null;\n\n const links = Object.entries(adminSectionNavigation).map(([k, v]) => {\n const { label, uri } = v;\n const Wrapper = uri.startsWith('#') ? 'a' : Link;\n return (\n <Wrapper className=\"entity-section-link\" href={uri} to={uri}>\n {label}\n </Wrapper>\n );\n });\n\n return <div className=\"entity-section-links\">{links}</div>;\n};\n\nexport default EntityNavLinks;\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAMG,cAAc,GAAG,SAAjBA,cAAcA,CAAAC,IAAA,EAAmB;EAAA,IAAbC,MAAM,GAAAD,IAAA,CAANC,MAAM;EAC9B,IAAI,CAACA,MAAM,EAAE,OAAO,IAAI;EAExB,IACuBC,sBAAsB,GACzCD,MAAM,CADRE,iBAAiB,CAAID,sBAAsB;EAG7C,IAAI,CAACA,sBAAsB,EAAE,OAAO,IAAI;EAExC,IAAME,KAAK,GAAGC,MAAM,CAACC,OAAO,CAACJ,sBAAsB,CAAC,CAACK,GAAG,CAAC,UAAAC,KAAA,EAAY;IAAA,IAAAC,KAAA,OAAAC,eAAA,aAAAF,KAAA;MAAVG,CAAC,GAAAF,KAAA;MAAEG,CAAC,GAAAH,KAAA;IAC7D,IAAQI,KAAK,GAAUD,CAAC,CAAhBC,KAAK;MAAEC,GAAG,GAAKF,CAAC,CAATE,GAAG;IAClB,IAAMC,OAAO,GAAGD,GAAG,CAACE,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG,GAAGC,oBAAI;IAChD,oBACEpB,MAAA,YAAAqB,aAAA,CAACH,OAAO;MAACI,SAAS,EAAC,qBAAqB;MAACC,IAAI,EAAEN,GAAI;MAACO,EAAE,EAAEP;IAAI,GACzDD,KACM,CAAC;EAEd,CAAC,CAAC;EAEF,oBAAOhB,MAAA,YAAAqB,aAAA;IAAKC,SAAS,EAAC;EAAsB,GAAEf,KAAW,CAAC;AAC5D,CAAC;AAAC,IAAAkB,QAAA,GAEavB,cAAc;AAAAwB,OAAA,cAAAD,QAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.object.define-property.js");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
var _EntityNavLinks = _interopRequireDefault(require("./EntityNavLinks"));
|
|
10
|
+
var _default = _EntityNavLinks["default"];
|
|
11
|
+
exports["default"] = _default;
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_EntityNavLinks","_interopRequireDefault","require","_default","EntityNavLinks","exports"],"sources":["../../../../../src/components/EntityManager/Entity/EntitiyNavLinks/index.js"],"sourcesContent":["import EntityNavLinks from './EntityNavLinks';\n\nexport default EntityNavLinks;\n"],"mappings":";;;;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,IAAAC,QAAA,GAE/BC,0BAAc;AAAAC,OAAA,cAAAF,QAAA"}
|
package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.object.define-property.js");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
require("core-js/modules/es.object.keys.js");
|
|
10
|
+
require("core-js/modules/es.array.flat-map.js");
|
|
11
|
+
require("core-js/modules/es.array.unscopables.flat-map.js");
|
|
12
|
+
require("core-js/modules/es.object.to-string.js");
|
|
13
|
+
require("core-js/modules/es.object.values.js");
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
var _react = _interopRequireDefault(require("react"));
|
|
16
|
+
var _useCustomSidebarData2 = _interopRequireDefault(require("../hooks/useCustomSidebarData"));
|
|
17
|
+
var _CustomSidebarInfo = _interopRequireDefault(require("../presentational/CustomSidebarInfo"));
|
|
18
|
+
var CustomSibebarInfoContainer = function CustomSibebarInfoContainer(_ref) {
|
|
19
|
+
var id = _ref.id,
|
|
20
|
+
schema = _ref.schema,
|
|
21
|
+
displayProperties = _ref.displayProperties;
|
|
22
|
+
var _useCustomSidebarData = (0, _useCustomSidebarData2["default"])({
|
|
23
|
+
id: id,
|
|
24
|
+
schema: schema,
|
|
25
|
+
displayProperties: displayProperties
|
|
26
|
+
}),
|
|
27
|
+
data = _useCustomSidebarData.data;
|
|
28
|
+
if (!data || !Object.keys(data) || Object.keys(data).length === 0) return null;
|
|
29
|
+
var items = Object.values(data).flatMap(function (item) {
|
|
30
|
+
return Object.values(item);
|
|
31
|
+
});
|
|
32
|
+
return /*#__PURE__*/_react["default"].createElement(_CustomSidebarInfo["default"], {
|
|
33
|
+
items: items,
|
|
34
|
+
customSidebarInfoKey: displayProperties.key
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var _default = CustomSibebarInfoContainer;
|
|
38
|
+
exports["default"] = _default;
|
|
39
|
+
CustomSibebarInfoContainer.propTypes = {
|
|
40
|
+
id: _propTypes["default"].string.isRequired,
|
|
41
|
+
displayProperties: _propTypes["default"].object.isRequired,
|
|
42
|
+
schema: _propTypes["default"].object.isRequired
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=CustomSidebarInfoContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomSidebarInfoContainer.js","names":["_propTypes","_interopRequireDefault","require","_react","_useCustomSidebarData2","_CustomSidebarInfo","CustomSibebarInfoContainer","_ref","id","schema","displayProperties","_useCustomSidebarData","useCustomSidebarData","data","Object","keys","length","items","values","flatMap","item","createElement","customSidebarInfoKey","key","_default","exports","propTypes","PropTypes","string","isRequired","object"],"sources":["../../../../../../src/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport useCustomSidebarData from '../hooks/useCustomSidebarData';\nimport CustomSidebarInfo from '../presentational/CustomSidebarInfo';\n\nconst CustomSibebarInfoContainer = ({ id, schema, displayProperties }) => {\n const { data } = useCustomSidebarData({ id, schema, displayProperties });\n\n if (!data || !Object.keys(data) || Object.keys(data).length === 0) return null;\n\n const items = Object.values(data).flatMap(item => Object.values(item));\n\n return <CustomSidebarInfo items={items} customSidebarInfoKey={displayProperties.key} />;\n};\n\nexport default CustomSibebarInfoContainer;\n\nCustomSibebarInfoContainer.propTypes = {\n id: PropTypes.string.isRequired,\n displayProperties: PropTypes.object.isRequired,\n schema: PropTypes.object.isRequired\n};\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,sBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,kBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,IAAMI,0BAA0B,GAAG,SAA7BA,0BAA0BA,CAAAC,IAAA,EAA0C;EAAA,IAApCC,EAAE,GAAAD,IAAA,CAAFC,EAAE;IAAEC,MAAM,GAAAF,IAAA,CAANE,MAAM;IAAEC,iBAAiB,GAAAH,IAAA,CAAjBG,iBAAiB;EACjE,IAAAC,qBAAA,GAAiB,IAAAC,iCAAoB,EAAC;MAAEJ,EAAE,EAAFA,EAAE;MAAEC,MAAM,EAANA,MAAM;MAAEC,iBAAiB,EAAjBA;IAAkB,CAAC,CAAC;IAAhEG,IAAI,GAAAF,qBAAA,CAAJE,IAAI;EAEZ,IAAI,CAACA,IAAI,IAAI,CAACC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC,IAAIC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC,CAACG,MAAM,KAAK,CAAC,EAAE,OAAO,IAAI;EAE9E,IAAMC,KAAK,GAAGH,MAAM,CAACI,MAAM,CAACL,IAAI,CAAC,CAACM,OAAO,CAAC,UAAAC,IAAI;IAAA,OAAIN,MAAM,CAACI,MAAM,CAACE,IAAI,CAAC;EAAA,EAAC;EAEtE,oBAAOjB,MAAA,YAAAkB,aAAA,CAAChB,kBAAA,WAAiB;IAACY,KAAK,EAAEA,KAAM;IAACK,oBAAoB,EAAEZ,iBAAiB,CAACa;EAAI,CAAE,CAAC;AACzF,CAAC;AAAC,IAAAC,QAAA,GAEalB,0BAA0B;AAAAmB,OAAA,cAAAD,QAAA;AAEzClB,0BAA0B,CAACoB,SAAS,GAAG;EACrClB,EAAE,EAAEmB,qBAAS,CAACC,MAAM,CAACC,UAAU;EAC/BnB,iBAAiB,EAAEiB,qBAAS,CAACG,MAAM,CAACD,UAAU;EAC9CpB,MAAM,EAAEkB,qBAAS,CAACG,MAAM,CAACD;AAC3B,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.object.define-property.js");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = buildDynamicQuery;
|
|
9
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
10
|
+
require("core-js/modules/es.array.is-array.js");
|
|
11
|
+
require("core-js/modules/es.array.map.js");
|
|
12
|
+
var _client = require("@apollo/client");
|
|
13
|
+
var _coreErrors = require("@blaze-cms/core-errors");
|
|
14
|
+
var _templateObject;
|
|
15
|
+
function buildDynamicQuery(_ref) {
|
|
16
|
+
var id = _ref.id,
|
|
17
|
+
schema = _ref.schema,
|
|
18
|
+
displayProperties = _ref.displayProperties;
|
|
19
|
+
if (!schema || !schema.actions || !schema.actions.get || !schema.properties) {
|
|
20
|
+
throw new _coreErrors.BlazeError('DataEntity query requires get action, properties and fields from entity schema');
|
|
21
|
+
}
|
|
22
|
+
if (displayProperties.adminMainInfoProperty && Array.isArray(displayProperties.adminMainInfoProperty)) {
|
|
23
|
+
var fields = displayProperties.adminMainInfoProperty.map(function (infoProperty) {
|
|
24
|
+
return "".concat(infoProperty, " {\n label\n value\n }");
|
|
25
|
+
});
|
|
26
|
+
return (0, _client.gql)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["query getInfoBoxData($id: String!){\n ", "( id: $id ) {\n id\n ", "\n __typename\n }\n }"])), schema.actions.get, fields.map(function (field) {
|
|
27
|
+
return field;
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=build-dynamic-query.js.map
|
package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-dynamic-query.js","names":["_client","require","_coreErrors","_templateObject","buildDynamicQuery","_ref","id","schema","displayProperties","actions","get","properties","BlazeError","adminMainInfoProperty","Array","isArray","fields","map","infoProperty","concat","gql","_taggedTemplateLiteral2","field"],"sources":["../../../../../../src/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js"],"sourcesContent":["import { gql } from '@apollo/client';\nimport { BlazeError } from '@blaze-cms/core-errors';\n\nexport default function buildDynamicQuery({ id, schema, displayProperties }) {\n if (!schema || !schema.actions || !schema.actions.get || !schema.properties) {\n throw new BlazeError(\n 'DataEntity query requires get action, properties and fields from entity schema'\n );\n }\n\n if (\n displayProperties.adminMainInfoProperty &&\n Array.isArray(displayProperties.adminMainInfoProperty)\n ) {\n const fields = displayProperties.adminMainInfoProperty.map(\n infoProperty =>\n `${infoProperty} {\n label\n value\n }`\n );\n\n return gql`query getInfoBoxData($id: String!){\n ${schema.actions.get}( id: $id ) {\n id\n ${fields.map(field => field)}\n __typename\n }\n }`;\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAAoD,IAAAE,eAAA;AAErC,SAASC,iBAAiBA,CAAAC,IAAA,EAAoC;EAAA,IAAjCC,EAAE,GAAAD,IAAA,CAAFC,EAAE;IAAEC,MAAM,GAAAF,IAAA,CAANE,MAAM;IAAEC,iBAAiB,GAAAH,IAAA,CAAjBG,iBAAiB;EACvE,IAAI,CAACD,MAAM,IAAI,CAACA,MAAM,CAACE,OAAO,IAAI,CAACF,MAAM,CAACE,OAAO,CAACC,GAAG,IAAI,CAACH,MAAM,CAACI,UAAU,EAAE;IAC3E,MAAM,IAAIC,sBAAU,CAClB,gFACF,CAAC;EACH;EAEA,IACEJ,iBAAiB,CAACK,qBAAqB,IACvCC,KAAK,CAACC,OAAO,CAACP,iBAAiB,CAACK,qBAAqB,CAAC,EACtD;IACA,IAAMG,MAAM,GAAGR,iBAAiB,CAACK,qBAAqB,CAACI,GAAG,CACxD,UAAAC,YAAY;MAAA,UAAAC,MAAA,CACPD,YAAY;IAAA,CAInB,CAAC;IAED,WAAOE,WAAG,EAAAjB,eAAA,KAAAA,eAAA,OAAAkB,uBAAA,6IACNd,MAAM,CAACE,OAAO,CAACC,GAAG,EAEjBM,MAAM,CAACC,GAAG,CAAC,UAAAK,KAAK;MAAA,OAAIA,KAAK;IAAA,EAAC;EAIjC;EAEA,OAAO,IAAI;AACb"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.object.define-property.js");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _client = require("@apollo/client");
|
|
12
|
+
var _buildDynamicQuery = _interopRequireDefault(require("../helpers/build-dynamic-query"));
|
|
13
|
+
var _templateObject;
|
|
14
|
+
var useCustomSidebarData = function useCustomSidebarData(_ref) {
|
|
15
|
+
var id = _ref.id,
|
|
16
|
+
schema = _ref.schema,
|
|
17
|
+
displayProperties = _ref.displayProperties;
|
|
18
|
+
var query = (0, _buildDynamicQuery["default"])({
|
|
19
|
+
id: id,
|
|
20
|
+
schema: schema,
|
|
21
|
+
displayProperties: displayProperties
|
|
22
|
+
});
|
|
23
|
+
var customSidebarInfoQuery = query || (0, _client.gql)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n query {\n __typename\n }\n "])));
|
|
24
|
+
var _useQuery = (0, _client.useQuery)(customSidebarInfoQuery, {
|
|
25
|
+
variables: {
|
|
26
|
+
id: id
|
|
27
|
+
},
|
|
28
|
+
skip: !query
|
|
29
|
+
}),
|
|
30
|
+
_useQuery$data = _useQuery.data,
|
|
31
|
+
data = _useQuery$data === void 0 ? {} : _useQuery$data,
|
|
32
|
+
loading = _useQuery.loading,
|
|
33
|
+
error = _useQuery.error;
|
|
34
|
+
return {
|
|
35
|
+
data: data.__typename !== 'Query' ? data : null,
|
|
36
|
+
loading: loading,
|
|
37
|
+
error: error
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
var _default = useCustomSidebarData;
|
|
41
|
+
exports["default"] = _default;
|
|
42
|
+
useCustomSidebarData.propTypes = {
|
|
43
|
+
displayProperties: _propTypes["default"].object.isRequired
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=useCustomSidebarData.js.map
|
package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCustomSidebarData.js","names":["_propTypes","_interopRequireDefault","require","_client","_buildDynamicQuery","_templateObject","useCustomSidebarData","_ref","id","schema","displayProperties","query","buildDynamicQuery","customSidebarInfoQuery","gql","_taggedTemplateLiteral2","_useQuery","useQuery","variables","skip","_useQuery$data","data","loading","error","__typename","_default","exports","propTypes","ProptTypes","object","isRequired"],"sources":["../../../../../../src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js"],"sourcesContent":["import ProptTypes from 'prop-types';\nimport { useQuery, gql } from '@apollo/client';\nimport buildDynamicQuery from '../helpers/build-dynamic-query';\n\nconst useCustomSidebarData = ({ id, schema, displayProperties }) => {\n const query = buildDynamicQuery({ id, schema, displayProperties });\n\n const customSidebarInfoQuery =\n query ||\n gql`\n query {\n __typename\n }\n `;\n\n const { data = {}, loading, error } = useQuery(customSidebarInfoQuery, {\n variables: { id },\n skip: !query\n });\n\n return { data: data.__typename !== 'Query' ? data : null, loading, error };\n};\n\nexport default useCustomSidebarData;\n\nuseCustomSidebarData.propTypes = {\n displayProperties: ProptTypes.object.isRequired\n};\n"],"mappings":";;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA+D,IAAAG,eAAA;AAE/D,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAAAC,IAAA,EAA0C;EAAA,IAApCC,EAAE,GAAAD,IAAA,CAAFC,EAAE;IAAEC,MAAM,GAAAF,IAAA,CAANE,MAAM;IAAEC,iBAAiB,GAAAH,IAAA,CAAjBG,iBAAiB;EAC3D,IAAMC,KAAK,GAAG,IAAAC,6BAAiB,EAAC;IAAEJ,EAAE,EAAFA,EAAE;IAAEC,MAAM,EAANA,MAAM;IAAEC,iBAAiB,EAAjBA;EAAkB,CAAC,CAAC;EAElE,IAAMG,sBAAsB,GAC1BF,KAAK,QACLG,WAAG,EAAAT,eAAA,KAAAA,eAAA,OAAAU,uBAAA,sEAIF;EAEH,IAAAC,SAAA,GAAsC,IAAAC,gBAAQ,EAACJ,sBAAsB,EAAE;MACrEK,SAAS,EAAE;QAAEV,EAAE,EAAFA;MAAG,CAAC;MACjBW,IAAI,EAAE,CAACR;IACT,CAAC,CAAC;IAAAS,cAAA,GAAAJ,SAAA,CAHMK,IAAI;IAAJA,IAAI,GAAAD,cAAA,cAAG,CAAC,CAAC,GAAAA,cAAA;IAAEE,OAAO,GAAAN,SAAA,CAAPM,OAAO;IAAEC,KAAK,GAAAP,SAAA,CAALO,KAAK;EAKjC,OAAO;IAAEF,IAAI,EAAEA,IAAI,CAACG,UAAU,KAAK,OAAO,GAAGH,IAAI,GAAG,IAAI;IAAEC,OAAO,EAAPA,OAAO;IAAEC,KAAK,EAALA;EAAM,CAAC;AAC5E,CAAC;AAAC,IAAAE,QAAA,GAEanB,oBAAoB;AAAAoB,OAAA,cAAAD,QAAA;AAEnCnB,oBAAoB,CAACqB,SAAS,GAAG;EAC/BjB,iBAAiB,EAAEkB,qBAAU,CAACC,MAAM,CAACC;AACvC,CAAC"}
|
|
@@ -28,6 +28,8 @@ var _reactFormBuilder = require("@blaze-cms/react-form-builder");
|
|
|
28
28
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
29
29
|
var _versioningUi = require("@blaze-cms/versioning-ui");
|
|
30
30
|
var _constants = require("../../../../constants");
|
|
31
|
+
var _CustomSidebarInfoContainer = _interopRequireDefault(require("./container/CustomSidebarInfoContainer"));
|
|
32
|
+
var _EntitiyNavLinks = _interopRequireDefault(require("../EntitiyNavLinks"));
|
|
31
33
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
32
34
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
35
|
var SideBarRelations = function SideBarRelations(_ref) {
|
|
@@ -144,16 +146,24 @@ var SideBarRelations = function SideBarRelations(_ref) {
|
|
|
144
146
|
"data-testid": "sideBarRelations-main-div"
|
|
145
147
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
146
148
|
className: "sidebar__content"
|
|
147
|
-
},
|
|
149
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
148
150
|
className: "sidebar__status"
|
|
151
|
+
}, formattedCreated && /*#__PURE__*/_react["default"].createElement("div", {
|
|
152
|
+
className: "sidebar__top"
|
|
149
153
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
150
154
|
className: "sidebar__status__wrapper"
|
|
151
155
|
}, /*#__PURE__*/_react["default"].createElement("b", null, "Status"), /*#__PURE__*/_react["default"].createElement("span", {
|
|
152
156
|
className: statusClassName
|
|
153
|
-
}, formattedStatus)), formattedStatus === _constants.PUBLISHED && /*#__PURE__*/_react["default"].createElement("p", null, formattedStatus, " on: ", /*#__PURE__*/_react["default"].createElement("span", null, " ", formattedPublished)), /*#__PURE__*/_react["default"].createElement("p", null, "Created: ", /*#__PURE__*/_react["default"].createElement("span", null, formattedCreated)), /*#__PURE__*/_react["default"].createElement("p", null, "Updated: ", /*#__PURE__*/_react["default"].createElement("span", null, formattedUpdated))), /*#__PURE__*/_react["default"].createElement(
|
|
157
|
+
}, formattedStatus)), formattedStatus === _constants.PUBLISHED && /*#__PURE__*/_react["default"].createElement("p", null, formattedStatus, " on: ", /*#__PURE__*/_react["default"].createElement("span", null, " ", formattedPublished))), !schema.displayProperties.adminMainInfoProperty && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("p", null, "Created: ", /*#__PURE__*/_react["default"].createElement("span", null, formattedCreated)), /*#__PURE__*/_react["default"].createElement("p", null, "Updated: ", /*#__PURE__*/_react["default"].createElement("span", null, formattedUpdated))), /*#__PURE__*/_react["default"].createElement(_CustomSidebarInfoContainer["default"], {
|
|
158
|
+
id: itemId,
|
|
159
|
+
schema: schema,
|
|
160
|
+
displayProperties: schema.displayProperties
|
|
161
|
+
})), /*#__PURE__*/_react["default"].createElement(_versioningUi.VersionsList, {
|
|
154
162
|
itemEntity: itemEntity,
|
|
155
163
|
itemId: itemId,
|
|
156
164
|
interfaces: interfaces
|
|
165
|
+
}), /*#__PURE__*/_react["default"].createElement(_EntitiyNavLinks["default"], {
|
|
166
|
+
schema: schema
|
|
157
167
|
}), relationsComponents && relationsComponents.map(function (_ref7) {
|
|
158
168
|
var id = _ref7.id,
|
|
159
169
|
staticData = _ref7.staticData,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_v","_client","_adminUiUtils","_reactFormBuilder","_classnames","_versioningUi","_constants","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","SideBarRelations","_ref","schema","onChange","formData","entity","RelationComponent","formFieldTypes","relation","formattedStatus","formattedUpdated","formattedCreated","formattedPublished","status","client","useApolloClient","_useState","useState","_useState2","_slicedToArray2","relationsComponents","setRelationsComponents","useEffect","_asyncToGenerator2","_regenerator","mark","_callee3","fetchRelationSchema","allRelationComponents","wrap","_callee3$","_context3","prev","next","_ref4","_callee","_ref3","entityIdentifier","_yield$client$query","_yield$client$query$d","relationSchema","_callee$","_context","abrupt","query","getQuery","variables","identifier","sent","data","getEntitySchemas","stop","_x","apply","arguments","Promise","all","relations","filter","_ref5","showInForm","foreignKey","properties","map","_ref6","_callee2","_callee2$","_context2","t0","uuidv1","t1","t2","id","staticData","_x2","itemId","itemEntity","interfaces","statusClassName","classnames","PUBLISHED","UNPUBLISHED","createElement","className","VersionsList","_ref7","entitySchema","onSelect","propTypes","PropTypes","object","isRequired","func","defaultProps","_default","exports"],"sources":["../../../../../src/components/EntityManager/Entity/SideBarRelations/index.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport uuidv1 from 'uuid/v1';\nimport { useApolloClient } from '@apollo/client';\nimport { getQuery } from '@blaze-cms/admin-ui-utils';\nimport { formFieldTypes } from '@blaze-cms/react-form-builder';\nimport classnames from 'classnames';\nimport { VersionsList } from '@blaze-cms/versioning-ui';\nimport { PUBLISHED, UNPUBLISHED } from '../../../../constants';\n\nconst SideBarRelations = ({ schema, onChange, formData, entity }) => {\n const { relation: RelationComponent } = formFieldTypes;\n const {\n formattedStatus,\n formattedUpdated,\n formattedCreated,\n formattedPublished,\n status\n } = formData;\n const client = useApolloClient();\n const [relationsComponents, setRelationsComponents] = useState(null);\n useEffect(\n () => {\n (async () => {\n const fetchRelationSchema = async ({ entityIdentifier }) => {\n if (!entityIdentifier) return null;\n\n const {\n data: {\n getEntitySchemas: [relationSchema]\n }\n } = await client.query({\n query: getQuery('GET_ENTITY_SCHEMA'),\n variables: { identifier: entityIdentifier }\n });\n return relationSchema;\n };\n\n if (!relationsComponents && schema) {\n const allRelationComponents = await Promise.all(\n schema.relations\n .filter(({ showInForm, foreignKey }) => showInForm && schema.properties[foreignKey])\n .map(async relation => ({\n id: uuidv1(),\n staticData: relation,\n schema: await fetchRelationSchema(relation)\n }))\n );\n\n setRelationsComponents(allRelationComponents);\n }\n })();\n },\n [client, relationsComponents, schema, schema.relations]\n );\n const { id: itemId } = entity;\n const { identifier: itemEntity, interfaces } = schema;\n\n const statusClassName = classnames('sidebar__status__badge', {\n 'sidebar__status__badge--published': status === PUBLISHED,\n 'sidebar__status__badge--unpublished': status === UNPUBLISHED\n });\n\n return (\n <div className=\"sidebar\" data-testid=\"sideBarRelations-main-div\">\n <div className=\"sidebar__content\">\n {formattedCreated && (\n <div className=\"sidebar__status\">\n <div className=\"sidebar__status__wrapper\">\n <b>Status</b>\n <span className={statusClassName}>{formattedStatus}</span>\n </div>\n {formattedStatus === PUBLISHED && (\n <p>\n {formattedStatus} on: <span> {formattedPublished}</span>\n </p>\n )}\n\n <p>\n Created: <span>{formattedCreated}</span>\n </p>\n <p>\n Updated: <span>{formattedUpdated}</span>\n </p>\n </div>\n )}\n\n <VersionsList itemEntity={itemEntity} itemId={itemId} interfaces={interfaces} />\n {relationsComponents &&\n relationsComponents.map(({ id, staticData, schema: entitySchema }) => (\n <RelationComponent\n formData={formData}\n schema={entitySchema}\n key={id}\n staticData={staticData}\n onSelect={onChange}\n />\n ))}\n </div>\n </div>\n );\n};\n\nSideBarRelations.propTypes = {\n schema: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n formData: PropTypes.object.isRequired,\n entity: PropTypes.object\n};\n\nSideBarRelations.defaultProps = {\n entity: {}\n};\n\nexport default SideBarRelations;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,EAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAL,sBAAA,CAAAF,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AACA,IAAAS,UAAA,GAAAT,OAAA;AAA+D,SAAAU,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAZ,wBAAAgB,GAAA,EAAAJ,WAAA,SAAAA,WAAA,I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F,qBAAS,CAACC;AACpB,CAAC;AAED1F,gBAAgB,CAAC6F,YAAY,GAAG;EAC9BxF,MAAM,EAAE,CAAC;AACX,CAAC;AAAC,IAAAyF,QAAA,GAEa9F,gBAAgB;AAAA+F,OAAA,cAAAD,QAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_v","_client","_adminUiUtils","_reactFormBuilder","_classnames","_versioningUi","_constants","_CustomSidebarInfoContainer","_EntitiyNavLinks","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","SideBarRelations","_ref","schema","onChange","formData","entity","RelationComponent","formFieldTypes","relation","formattedStatus","formattedUpdated","formattedCreated","formattedPublished","status","client","useApolloClient","_useState","useState","_useState2","_slicedToArray2","relationsComponents","setRelationsComponents","useEffect","_asyncToGenerator2","_regenerator","mark","_callee3","fetchRelationSchema","allRelationComponents","wrap","_callee3$","_context3","prev","next","_ref4","_callee","_ref3","entityIdentifier","_yield$client$query","_yield$client$query$d","relationSchema","_callee$","_context","abrupt","query","getQuery","variables","identifier","sent","data","getEntitySchemas","stop","_x","apply","arguments","Promise","all","relations","filter","_ref5","showInForm","foreignKey","properties","map","_ref6","_callee2","_callee2$","_context2","t0","uuidv1","t1","t2","id","staticData","_x2","itemId","itemEntity","interfaces","statusClassName","classnames","PUBLISHED","UNPUBLISHED","createElement","className","displayProperties","adminMainInfoProperty","Fragment","VersionsList","_ref7","entitySchema","onSelect","propTypes","PropTypes","object","isRequired","func","defaultProps","_default","exports"],"sources":["../../../../../src/components/EntityManager/Entity/SideBarRelations/index.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport uuidv1 from 'uuid/v1';\nimport { useApolloClient } from '@apollo/client';\nimport { getQuery } from '@blaze-cms/admin-ui-utils';\nimport { formFieldTypes } from '@blaze-cms/react-form-builder';\nimport classnames from 'classnames';\nimport { VersionsList } from '@blaze-cms/versioning-ui';\nimport { PUBLISHED, UNPUBLISHED } from '../../../../constants';\nimport CustomSidebarInfoContainer from './container/CustomSidebarInfoContainer';\nimport EntityNavLinks from '../EntitiyNavLinks';\n\nconst SideBarRelations = ({ schema, onChange, formData, entity }) => {\n const { relation: RelationComponent } = formFieldTypes;\n const {\n formattedStatus,\n formattedUpdated,\n formattedCreated,\n formattedPublished,\n status\n } = formData;\n const client = useApolloClient();\n\n const [relationsComponents, setRelationsComponents] = useState(null);\n\n useEffect(\n () => {\n (async () => {\n const fetchRelationSchema = async ({ entityIdentifier }) => {\n if (!entityIdentifier) return null;\n\n const {\n data: {\n getEntitySchemas: [relationSchema]\n }\n } = await client.query({\n query: getQuery('GET_ENTITY_SCHEMA'),\n variables: { identifier: entityIdentifier }\n });\n return relationSchema;\n };\n\n if (!relationsComponents && schema) {\n const allRelationComponents = await Promise.all(\n schema.relations\n .filter(({ showInForm, foreignKey }) => showInForm && schema.properties[foreignKey])\n .map(async relation => ({\n id: uuidv1(),\n staticData: relation,\n schema: await fetchRelationSchema(relation)\n }))\n );\n\n setRelationsComponents(allRelationComponents);\n }\n })();\n },\n [client, relationsComponents, schema, schema.relations]\n );\n const { id: itemId } = entity;\n const { identifier: itemEntity, interfaces } = schema;\n\n const statusClassName = classnames('sidebar__status__badge', {\n 'sidebar__status__badge--published': status === PUBLISHED,\n 'sidebar__status__badge--unpublished': status === UNPUBLISHED\n });\n\n return (\n <div className=\"sidebar\" data-testid=\"sideBarRelations-main-div\">\n <div className=\"sidebar__content\">\n <div className=\"sidebar__status\">\n {formattedCreated && (\n <div className=\"sidebar__top\">\n <div className=\"sidebar__status__wrapper\">\n <b>Status</b>\n <span className={statusClassName}>{formattedStatus}</span>\n </div>\n {formattedStatus === PUBLISHED && (\n <p>\n {formattedStatus} on: <span> {formattedPublished}</span>\n </p>\n )}\n </div>\n )}\n\n {!schema.displayProperties.adminMainInfoProperty && (\n <>\n <p>\n Created: <span>{formattedCreated}</span>\n </p>\n <p>\n Updated: <span>{formattedUpdated}</span>\n </p>\n </>\n )}\n\n <CustomSidebarInfoContainer\n id={itemId}\n schema={schema}\n displayProperties={schema.displayProperties}\n />\n </div>\n\n <VersionsList itemEntity={itemEntity} itemId={itemId} interfaces={interfaces} />\n <EntityNavLinks schema={schema} />\n\n {relationsComponents &&\n relationsComponents.map(({ id, staticData, schema: entitySchema }) => (\n <RelationComponent\n formData={formData}\n schema={entitySchema}\n key={id}\n staticData={staticData}\n onSelect={onChange}\n />\n ))}\n </div>\n </div>\n );\n};\n\nSideBarRelations.propTypes = {\n schema: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n formData: PropTypes.object.isRequired,\n entity: PropTypes.object\n};\n\nSideBarRelations.defaultProps = {\n entity: {}\n};\n\nexport default SideBarRelations;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,EAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAL,sBAAA,CAAAF,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AACA,IAAAS,UAAA,GAAAT,OAAA;AACA,IAAAU,2BAAA,GAAAR,sBAAA,CAAAF,OAAA;AACA,IAAAW,gBAAA,GAAAT,sBAAA,CAAAF,OAAA;AAAgD,SAAAY,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF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AY,GAAAD,KAAA,CAApBtF,MAAM;IAAA,oBAC/CtC,MAAA,YAAAsH,aAAA,CAAC5E,iBAAiB;MAChBF,QAAQ,EAAEA,QAAS;MACnBF,MAAM,EAAEuF,YAAa;MACrB/F,GAAG,EAAE8E,EAAG;MACRC,UAAU,EAAEA,UAAW;MACvBiB,QAAQ,EAAEvF;IAAS,CACpB,CAAC;EAAA,CACH,CACA,CACF,CAAC;AAEV,CAAC;AAEDH,gBAAgB,CAAC2F,SAAS,GAAG;EAC3BzF,MAAM,EAAE0F,qBAAS,CAACC,MAAM,CAACC,UAAU;EACnC3F,QAAQ,EAAEyF,qBAAS,CAACG,IAAI,CAACD,UAAU;EACnC1F,QAAQ,EAAEwF,qBAAS,CAACC,MAAM,CAACC,UAAU;EACrCzF,MAAM,EAAEuF,qBAAS,CAACC;AACpB,CAAC;AAED7F,gBAAgB,CAACgG,YAAY,GAAG;EAC9B3F,MAAM,EAAE,CAAC;AACX,CAAC;AAAC,IAAA4F,QAAA,GAEajG,gBAAgB;AAAAkG,OAAA,cAAAD,QAAA"}
|
package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.object.define-property.js");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
require("core-js/modules/es.array.map.js");
|
|
10
|
+
require("core-js/modules/es.array.filter.js");
|
|
11
|
+
require("core-js/modules/es.object.to-string.js");
|
|
12
|
+
require("core-js/modules/es.object.values.js");
|
|
13
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
var CustomSidebarInfo = function CustomSidebarInfo(_ref) {
|
|
16
|
+
var items = _ref.items,
|
|
17
|
+
customSidebarInfoKey = _ref.customSidebarInfoKey;
|
|
18
|
+
if (!items) return null;
|
|
19
|
+
var customSidebarInfoItems = items.map(function (item) {
|
|
20
|
+
return Object.values(item).map(function (info) {
|
|
21
|
+
if (!info.label || !info.value) return null;
|
|
22
|
+
return /*#__PURE__*/_react["default"].createElement("p", null, info.label, ": ", /*#__PURE__*/_react["default"].createElement("span", null, info.value));
|
|
23
|
+
}).filter(Boolean);
|
|
24
|
+
});
|
|
25
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
26
|
+
className: "custom-sidebar-info",
|
|
27
|
+
key: customSidebarInfoKey
|
|
28
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
29
|
+
className: "custom-sidebar-info--container"
|
|
30
|
+
}, customSidebarInfoItems));
|
|
31
|
+
};
|
|
32
|
+
var _default = CustomSidebarInfo;
|
|
33
|
+
exports["default"] = _default;
|
|
34
|
+
CustomSidebarInfo.propTypes = {
|
|
35
|
+
customSidebarInfoKey: _propTypes["default"].string.isRequired,
|
|
36
|
+
items: _propTypes["default"].array.isRequired
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=CustomSidebarInfo.js.map
|
package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomSidebarInfo.js","names":["_propTypes","_interopRequireDefault","require","_react","CustomSidebarInfo","_ref","items","customSidebarInfoKey","customSidebarInfoItems","map","item","Object","values","info","label","value","createElement","filter","Boolean","className","key","_default","exports","propTypes","PropTypes","string","isRequired","array"],"sources":["../../../../../../src/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nconst CustomSidebarInfo = ({ items, customSidebarInfoKey }) => {\n if (!items) return null;\n\n const customSidebarInfoItems = items.map(item =>\n Object.values(item)\n .map(info => {\n if (!info.label || !info.value) return null;\n\n return (\n <p>\n {info.label}: <span>{info.value}</span>\n </p>\n );\n })\n .filter(Boolean)\n );\n\n return (\n <div className=\"custom-sidebar-info\" key={customSidebarInfoKey}>\n <div className=\"custom-sidebar-info--container\">{customSidebarInfoItems}</div>\n </div>\n );\n};\n\nexport default CustomSidebarInfo;\n\nCustomSidebarInfo.propTypes = {\n customSidebarInfoKey: PropTypes.string.isRequired,\n items: PropTypes.array.isRequired\n};\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAME,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAAC,IAAA,EAAwC;EAAA,IAAlCC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAEC,oBAAoB,GAAAF,IAAA,CAApBE,oBAAoB;EACtD,IAAI,CAACD,KAAK,EAAE,OAAO,IAAI;EAEvB,IAAME,sBAAsB,GAAGF,KAAK,CAACG,GAAG,CAAC,UAAAC,IAAI;IAAA,OAC3CC,MAAM,CAACC,MAAM,CAACF,IAAI,CAAC,CAChBD,GAAG,CAAC,UAAAI,IAAI,EAAI;MACX,IAAI,CAACA,IAAI,CAACC,KAAK,IAAI,CAACD,IAAI,CAACE,KAAK,EAAE,OAAO,IAAI;MAE3C,oBACEZ,MAAA,YAAAa,aAAA,YACGH,IAAI,CAACC,KAAK,EAAC,IAAE,eAAAX,MAAA,YAAAa,aAAA,eAAOH,IAAI,CAACE,KAAY,CACrC,CAAC;IAER,CAAC,CAAC,CACDE,MAAM,CAACC,OAAO,CAAC;EAAA,CACpB,CAAC;EAED,oBACEf,MAAA,YAAAa,aAAA;IAAKG,SAAS,EAAC,qBAAqB;IAACC,GAAG,EAAEb;EAAqB,gBAC7DJ,MAAA,YAAAa,aAAA;IAAKG,SAAS,EAAC;EAAgC,GAAEX,sBAA4B,CAC1E,CAAC;AAEV,CAAC;AAAC,IAAAa,QAAA,GAEajB,iBAAiB;AAAAkB,OAAA,cAAAD,QAAA;AAEhCjB,iBAAiB,CAACmB,SAAS,GAAG;EAC5BhB,oBAAoB,EAAEiB,qBAAS,CAACC,MAAM,CAACC,UAAU;EACjDpB,KAAK,EAAEkB,qBAAS,CAACG,KAAK,CAACD;AACzB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Link } from 'react-router-dom';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
const EntityNavLinks = ({
|
|
4
|
+
schema
|
|
5
|
+
}) => {
|
|
6
|
+
if (!schema) return null;
|
|
7
|
+
const {
|
|
8
|
+
displayProperties: {
|
|
9
|
+
adminSectionNavigation
|
|
10
|
+
}
|
|
11
|
+
} = schema;
|
|
12
|
+
if (!adminSectionNavigation) return null;
|
|
13
|
+
const links = Object.entries(adminSectionNavigation).map(([k, v]) => {
|
|
14
|
+
const {
|
|
15
|
+
label,
|
|
16
|
+
uri
|
|
17
|
+
} = v;
|
|
18
|
+
const Wrapper = uri.startsWith('#') ? 'a' : Link;
|
|
19
|
+
return /*#__PURE__*/React.createElement(Wrapper, {
|
|
20
|
+
className: "entity-section-link",
|
|
21
|
+
href: uri,
|
|
22
|
+
to: uri
|
|
23
|
+
}, label);
|
|
24
|
+
});
|
|
25
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
className: "entity-section-links"
|
|
27
|
+
}, links);
|
|
28
|
+
};
|
|
29
|
+
export default EntityNavLinks;
|
|
30
|
+
//# sourceMappingURL=EntityNavLinks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityNavLinks.js","names":["Link","React","EntityNavLinks","schema","displayProperties","adminSectionNavigation","links","Object","entries","map","k","v","label","uri","Wrapper","startsWith","createElement","className","href","to"],"sources":["../../../../../src/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js"],"sourcesContent":["import { Link } from 'react-router-dom';\nimport React from 'react';\n\nconst EntityNavLinks = ({ schema }) => {\n if (!schema) return null;\n\n const {\n displayProperties: { adminSectionNavigation }\n } = schema;\n\n if (!adminSectionNavigation) return null;\n\n const links = Object.entries(adminSectionNavigation).map(([k, v]) => {\n const { label, uri } = v;\n const Wrapper = uri.startsWith('#') ? 'a' : Link;\n return (\n <Wrapper className=\"entity-section-link\" href={uri} to={uri}>\n {label}\n </Wrapper>\n );\n });\n\n return <div className=\"entity-section-links\">{links}</div>;\n};\n\nexport default EntityNavLinks;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,kBAAkB;AACvC,OAAOC,KAAK,MAAM,OAAO;AAEzB,MAAMC,cAAc,GAAGA,CAAC;EAAEC;AAAO,CAAC,KAAK;EACrC,IAAI,CAACA,MAAM,EAAE,OAAO,IAAI;EAExB,MAAM;IACJC,iBAAiB,EAAE;MAAEC;IAAuB;EAC9C,CAAC,GAAGF,MAAM;EAEV,IAAI,CAACE,sBAAsB,EAAE,OAAO,IAAI;EAExC,MAAMC,KAAK,GAAGC,MAAM,CAACC,OAAO,CAACH,sBAAsB,CAAC,CAACI,GAAG,CAAC,CAAC,CAACC,CAAC,EAAEC,CAAC,CAAC,KAAK;IACnE,MAAM;MAAEC,KAAK;MAAEC;IAAI,CAAC,GAAGF,CAAC;IACxB,MAAMG,OAAO,GAAGD,GAAG,CAACE,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG,GAAGf,IAAI;IAChD,oBACEC,KAAA,CAAAe,aAAA,CAACF,OAAO;MAACG,SAAS,EAAC,qBAAqB;MAACC,IAAI,EAAEL,GAAI;MAACM,EAAE,EAAEN;IAAI,GACzDD,KACM,CAAC;EAEd,CAAC,CAAC;EAEF,oBAAOX,KAAA,CAAAe,aAAA;IAAKC,SAAS,EAAC;EAAsB,GAAEX,KAAW,CAAC;AAC5D,CAAC;AAED,eAAeJ,cAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["EntityNavLinks"],"sources":["../../../../../src/components/EntityManager/Entity/EntitiyNavLinks/index.js"],"sourcesContent":["import EntityNavLinks from './EntityNavLinks';\n\nexport default EntityNavLinks;\n"],"mappings":"AAAA,OAAOA,cAAc,MAAM,kBAAkB;AAE7C,eAAeA,cAAc"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import useCustomSidebarData from '../hooks/useCustomSidebarData';
|
|
4
|
+
import CustomSidebarInfo from '../presentational/CustomSidebarInfo';
|
|
5
|
+
const CustomSibebarInfoContainer = ({
|
|
6
|
+
id,
|
|
7
|
+
schema,
|
|
8
|
+
displayProperties
|
|
9
|
+
}) => {
|
|
10
|
+
const {
|
|
11
|
+
data
|
|
12
|
+
} = useCustomSidebarData({
|
|
13
|
+
id,
|
|
14
|
+
schema,
|
|
15
|
+
displayProperties
|
|
16
|
+
});
|
|
17
|
+
if (!data || !Object.keys(data) || Object.keys(data).length === 0) return null;
|
|
18
|
+
const items = Object.values(data).flatMap(item => Object.values(item));
|
|
19
|
+
return /*#__PURE__*/React.createElement(CustomSidebarInfo, {
|
|
20
|
+
items: items,
|
|
21
|
+
customSidebarInfoKey: displayProperties.key
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
export default CustomSibebarInfoContainer;
|
|
25
|
+
CustomSibebarInfoContainer.propTypes = {
|
|
26
|
+
id: PropTypes.string.isRequired,
|
|
27
|
+
displayProperties: PropTypes.object.isRequired,
|
|
28
|
+
schema: PropTypes.object.isRequired
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=CustomSidebarInfoContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomSidebarInfoContainer.js","names":["PropTypes","React","useCustomSidebarData","CustomSidebarInfo","CustomSibebarInfoContainer","id","schema","displayProperties","data","Object","keys","length","items","values","flatMap","item","createElement","customSidebarInfoKey","key","propTypes","string","isRequired","object"],"sources":["../../../../../../src/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport useCustomSidebarData from '../hooks/useCustomSidebarData';\nimport CustomSidebarInfo from '../presentational/CustomSidebarInfo';\n\nconst CustomSibebarInfoContainer = ({ id, schema, displayProperties }) => {\n const { data } = useCustomSidebarData({ id, schema, displayProperties });\n\n if (!data || !Object.keys(data) || Object.keys(data).length === 0) return null;\n\n const items = Object.values(data).flatMap(item => Object.values(item));\n\n return <CustomSidebarInfo items={items} customSidebarInfoKey={displayProperties.key} />;\n};\n\nexport default CustomSibebarInfoContainer;\n\nCustomSibebarInfoContainer.propTypes = {\n id: PropTypes.string.isRequired,\n displayProperties: PropTypes.object.isRequired,\n schema: PropTypes.object.isRequired\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,YAAY;AAClC,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAOC,oBAAoB,MAAM,+BAA+B;AAChE,OAAOC,iBAAiB,MAAM,qCAAqC;AAEnE,MAAMC,0BAA0B,GAAGA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAkB,CAAC,KAAK;EACxE,MAAM;IAAEC;EAAK,CAAC,GAAGN,oBAAoB,CAAC;IAAEG,EAAE;IAAEC,MAAM;IAAEC;EAAkB,CAAC,CAAC;EAExE,IAAI,CAACC,IAAI,IAAI,CAACC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC,IAAIC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC,CAACG,MAAM,KAAK,CAAC,EAAE,OAAO,IAAI;EAE9E,MAAMC,KAAK,GAAGH,MAAM,CAACI,MAAM,CAACL,IAAI,CAAC,CAACM,OAAO,CAACC,IAAI,IAAIN,MAAM,CAACI,MAAM,CAACE,IAAI,CAAC,CAAC;EAEtE,oBAAOd,KAAA,CAAAe,aAAA,CAACb,iBAAiB;IAACS,KAAK,EAAEA,KAAM;IAACK,oBAAoB,EAAEV,iBAAiB,CAACW;EAAI,CAAE,CAAC;AACzF,CAAC;AAED,eAAed,0BAA0B;AAEzCA,0BAA0B,CAACe,SAAS,GAAG;EACrCd,EAAE,EAAEL,SAAS,CAACoB,MAAM,CAACC,UAAU;EAC/Bd,iBAAiB,EAAEP,SAAS,CAACsB,MAAM,CAACD,UAAU;EAC9Cf,MAAM,EAAEN,SAAS,CAACsB,MAAM,CAACD;AAC3B,CAAC"}
|
package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
import { BlazeError } from '@blaze-cms/core-errors';
|
|
3
|
+
export default function buildDynamicQuery({
|
|
4
|
+
id,
|
|
5
|
+
schema,
|
|
6
|
+
displayProperties
|
|
7
|
+
}) {
|
|
8
|
+
if (!schema || !schema.actions || !schema.actions.get || !schema.properties) {
|
|
9
|
+
throw new BlazeError('DataEntity query requires get action, properties and fields from entity schema');
|
|
10
|
+
}
|
|
11
|
+
if (displayProperties.adminMainInfoProperty && Array.isArray(displayProperties.adminMainInfoProperty)) {
|
|
12
|
+
const fields = displayProperties.adminMainInfoProperty.map(infoProperty => `${infoProperty} {
|
|
13
|
+
label
|
|
14
|
+
value
|
|
15
|
+
}`);
|
|
16
|
+
return gql`query getInfoBoxData($id: String!){
|
|
17
|
+
${schema.actions.get}( id: $id ) {
|
|
18
|
+
id
|
|
19
|
+
${fields.map(field => field)}
|
|
20
|
+
__typename
|
|
21
|
+
}
|
|
22
|
+
}`;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=build-dynamic-query.js.map
|
package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-dynamic-query.js","names":["gql","BlazeError","buildDynamicQuery","id","schema","displayProperties","actions","get","properties","adminMainInfoProperty","Array","isArray","fields","map","infoProperty","field"],"sources":["../../../../../../src/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js"],"sourcesContent":["import { gql } from '@apollo/client';\nimport { BlazeError } from '@blaze-cms/core-errors';\n\nexport default function buildDynamicQuery({ id, schema, displayProperties }) {\n if (!schema || !schema.actions || !schema.actions.get || !schema.properties) {\n throw new BlazeError(\n 'DataEntity query requires get action, properties and fields from entity schema'\n );\n }\n\n if (\n displayProperties.adminMainInfoProperty &&\n Array.isArray(displayProperties.adminMainInfoProperty)\n ) {\n const fields = displayProperties.adminMainInfoProperty.map(\n infoProperty =>\n `${infoProperty} {\n label\n value\n }`\n );\n\n return gql`query getInfoBoxData($id: String!){\n ${schema.actions.get}( id: $id ) {\n id\n ${fields.map(field => field)}\n __typename\n }\n }`;\n }\n\n return null;\n}\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,gBAAgB;AACpC,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,eAAe,SAASC,iBAAiBA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAkB,CAAC,EAAE;EAC3E,IAAI,CAACD,MAAM,IAAI,CAACA,MAAM,CAACE,OAAO,IAAI,CAACF,MAAM,CAACE,OAAO,CAACC,GAAG,IAAI,CAACH,MAAM,CAACI,UAAU,EAAE;IAC3E,MAAM,IAAIP,UAAU,CAClB,gFACF,CAAC;EACH;EAEA,IACEI,iBAAiB,CAACI,qBAAqB,IACvCC,KAAK,CAACC,OAAO,CAACN,iBAAiB,CAACI,qBAAqB,CAAC,EACtD;IACA,MAAMG,MAAM,GAAGP,iBAAiB,CAACI,qBAAqB,CAACI,GAAG,CACxDC,YAAY,IACT,GAAEA,YAAa;AACxB;AACA;AACA,QACI,CAAC;IAED,OAAOd,GAAI;AACf,QAAQI,MAAM,CAACE,OAAO,CAACC,GAAI;AAC3B;AACA,SAASK,MAAM,CAACC,GAAG,CAACE,KAAK,IAAIA,KAAK,CAAE;AACpC;AACA;AACA,MAAM;EACJ;EAEA,OAAO,IAAI;AACb"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import ProptTypes from 'prop-types';
|
|
2
|
+
import { useQuery, gql } from '@apollo/client';
|
|
3
|
+
import buildDynamicQuery from '../helpers/build-dynamic-query';
|
|
4
|
+
const useCustomSidebarData = ({
|
|
5
|
+
id,
|
|
6
|
+
schema,
|
|
7
|
+
displayProperties
|
|
8
|
+
}) => {
|
|
9
|
+
const query = buildDynamicQuery({
|
|
10
|
+
id,
|
|
11
|
+
schema,
|
|
12
|
+
displayProperties
|
|
13
|
+
});
|
|
14
|
+
const customSidebarInfoQuery = query || gql`
|
|
15
|
+
query {
|
|
16
|
+
__typename
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
const {
|
|
20
|
+
data = {},
|
|
21
|
+
loading,
|
|
22
|
+
error
|
|
23
|
+
} = useQuery(customSidebarInfoQuery, {
|
|
24
|
+
variables: {
|
|
25
|
+
id
|
|
26
|
+
},
|
|
27
|
+
skip: !query
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
data: data.__typename !== 'Query' ? data : null,
|
|
31
|
+
loading,
|
|
32
|
+
error
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export default useCustomSidebarData;
|
|
36
|
+
useCustomSidebarData.propTypes = {
|
|
37
|
+
displayProperties: ProptTypes.object.isRequired
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=useCustomSidebarData.js.map
|
package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCustomSidebarData.js","names":["ProptTypes","useQuery","gql","buildDynamicQuery","useCustomSidebarData","id","schema","displayProperties","query","customSidebarInfoQuery","data","loading","error","variables","skip","__typename","propTypes","object","isRequired"],"sources":["../../../../../../src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js"],"sourcesContent":["import ProptTypes from 'prop-types';\nimport { useQuery, gql } from '@apollo/client';\nimport buildDynamicQuery from '../helpers/build-dynamic-query';\n\nconst useCustomSidebarData = ({ id, schema, displayProperties }) => {\n const query = buildDynamicQuery({ id, schema, displayProperties });\n\n const customSidebarInfoQuery =\n query ||\n gql`\n query {\n __typename\n }\n `;\n\n const { data = {}, loading, error } = useQuery(customSidebarInfoQuery, {\n variables: { id },\n skip: !query\n });\n\n return { data: data.__typename !== 'Query' ? data : null, loading, error };\n};\n\nexport default useCustomSidebarData;\n\nuseCustomSidebarData.propTypes = {\n displayProperties: ProptTypes.object.isRequired\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AACnC,SAASC,QAAQ,EAAEC,GAAG,QAAQ,gBAAgB;AAC9C,OAAOC,iBAAiB,MAAM,gCAAgC;AAE9D,MAAMC,oBAAoB,GAAGA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAkB,CAAC,KAAK;EAClE,MAAMC,KAAK,GAAGL,iBAAiB,CAAC;IAAEE,EAAE;IAAEC,MAAM;IAAEC;EAAkB,CAAC,CAAC;EAElE,MAAME,sBAAsB,GAC1BD,KAAK,IACLN,GAAI;AACR;AACA;AACA;AACA,KAAK;EAEH,MAAM;IAAEQ,IAAI,GAAG,CAAC,CAAC;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGX,QAAQ,CAACQ,sBAAsB,EAAE;IACrEI,SAAS,EAAE;MAAER;IAAG,CAAC;IACjBS,IAAI,EAAE,CAACN;EACT,CAAC,CAAC;EAEF,OAAO;IAAEE,IAAI,EAAEA,IAAI,CAACK,UAAU,KAAK,OAAO,GAAGL,IAAI,GAAG,IAAI;IAAEC,OAAO;IAAEC;EAAM,CAAC;AAC5E,CAAC;AAED,eAAeR,oBAAoB;AAEnCA,oBAAoB,CAACY,SAAS,GAAG;EAC/BT,iBAAiB,EAAEP,UAAU,CAACiB,MAAM,CAACC;AACvC,CAAC"}
|
|
@@ -7,6 +7,8 @@ import { formFieldTypes } from '@blaze-cms/react-form-builder';
|
|
|
7
7
|
import classnames from 'classnames';
|
|
8
8
|
import { VersionsList } from '@blaze-cms/versioning-ui';
|
|
9
9
|
import { PUBLISHED, UNPUBLISHED } from '../../../../constants';
|
|
10
|
+
import CustomSidebarInfoContainer from './container/CustomSidebarInfoContainer';
|
|
11
|
+
import EntityNavLinks from '../EntitiyNavLinks';
|
|
10
12
|
const SideBarRelations = ({
|
|
11
13
|
schema,
|
|
12
14
|
onChange,
|
|
@@ -72,16 +74,24 @@ const SideBarRelations = ({
|
|
|
72
74
|
"data-testid": "sideBarRelations-main-div"
|
|
73
75
|
}, /*#__PURE__*/React.createElement("div", {
|
|
74
76
|
className: "sidebar__content"
|
|
75
|
-
},
|
|
77
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
76
78
|
className: "sidebar__status"
|
|
79
|
+
}, formattedCreated && /*#__PURE__*/React.createElement("div", {
|
|
80
|
+
className: "sidebar__top"
|
|
77
81
|
}, /*#__PURE__*/React.createElement("div", {
|
|
78
82
|
className: "sidebar__status__wrapper"
|
|
79
83
|
}, /*#__PURE__*/React.createElement("b", null, "Status"), /*#__PURE__*/React.createElement("span", {
|
|
80
84
|
className: statusClassName
|
|
81
|
-
}, formattedStatus)), formattedStatus === PUBLISHED && /*#__PURE__*/React.createElement("p", null, formattedStatus, " on: ", /*#__PURE__*/React.createElement("span", null, " ", formattedPublished)), /*#__PURE__*/React.createElement("p", null, "Created: ", /*#__PURE__*/React.createElement("span", null, formattedCreated)), /*#__PURE__*/React.createElement("p", null, "Updated: ", /*#__PURE__*/React.createElement("span", null, formattedUpdated))), /*#__PURE__*/React.createElement(
|
|
85
|
+
}, formattedStatus)), formattedStatus === PUBLISHED && /*#__PURE__*/React.createElement("p", null, formattedStatus, " on: ", /*#__PURE__*/React.createElement("span", null, " ", formattedPublished))), !schema.displayProperties.adminMainInfoProperty && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", null, "Created: ", /*#__PURE__*/React.createElement("span", null, formattedCreated)), /*#__PURE__*/React.createElement("p", null, "Updated: ", /*#__PURE__*/React.createElement("span", null, formattedUpdated))), /*#__PURE__*/React.createElement(CustomSidebarInfoContainer, {
|
|
86
|
+
id: itemId,
|
|
87
|
+
schema: schema,
|
|
88
|
+
displayProperties: schema.displayProperties
|
|
89
|
+
})), /*#__PURE__*/React.createElement(VersionsList, {
|
|
82
90
|
itemEntity: itemEntity,
|
|
83
91
|
itemId: itemId,
|
|
84
92
|
interfaces: interfaces
|
|
93
|
+
}), /*#__PURE__*/React.createElement(EntityNavLinks, {
|
|
94
|
+
schema: schema
|
|
85
95
|
}), relationsComponents && relationsComponents.map(({
|
|
86
96
|
id,
|
|
87
97
|
staticData,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useState","useEffect","PropTypes","uuidv1","useApolloClient","getQuery","formFieldTypes","classnames","VersionsList","PUBLISHED","UNPUBLISHED","SideBarRelations","schema","onChange","formData","entity","relation","RelationComponent","formattedStatus","formattedUpdated","formattedCreated","formattedPublished","status","client","relationsComponents","setRelationsComponents","fetchRelationSchema","entityIdentifier","data","getEntitySchemas","relationSchema","query","variables","identifier","allRelationComponents","Promise","all","relations","filter","showInForm","foreignKey","properties","map","id","staticData","itemId","itemEntity","interfaces","statusClassName","createElement","className","entitySchema","key","onSelect","propTypes","object","isRequired","func","defaultProps"],"sources":["../../../../../src/components/EntityManager/Entity/SideBarRelations/index.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport uuidv1 from 'uuid/v1';\nimport { useApolloClient } from '@apollo/client';\nimport { getQuery } from '@blaze-cms/admin-ui-utils';\nimport { formFieldTypes } from '@blaze-cms/react-form-builder';\nimport classnames from 'classnames';\nimport { VersionsList } from '@blaze-cms/versioning-ui';\nimport { PUBLISHED, UNPUBLISHED } from '../../../../constants';\n\nconst SideBarRelations = ({ schema, onChange, formData, entity }) => {\n const { relation: RelationComponent } = formFieldTypes;\n const {\n formattedStatus,\n formattedUpdated,\n formattedCreated,\n formattedPublished,\n status\n } = formData;\n const client = useApolloClient();\n const [relationsComponents, setRelationsComponents] = useState(null);\n useEffect(\n () => {\n (async () => {\n const fetchRelationSchema = async ({ entityIdentifier }) => {\n if (!entityIdentifier) return null;\n\n const {\n data: {\n getEntitySchemas: [relationSchema]\n }\n } = await client.query({\n query: getQuery('GET_ENTITY_SCHEMA'),\n variables: { identifier: entityIdentifier }\n });\n return relationSchema;\n };\n\n if (!relationsComponents && schema) {\n const allRelationComponents = await Promise.all(\n schema.relations\n .filter(({ showInForm, foreignKey }) => showInForm && schema.properties[foreignKey])\n .map(async relation => ({\n id: uuidv1(),\n staticData: relation,\n schema: await fetchRelationSchema(relation)\n }))\n );\n\n setRelationsComponents(allRelationComponents);\n }\n })();\n },\n [client, relationsComponents, schema, schema.relations]\n );\n const { id: itemId } = entity;\n const { identifier: itemEntity, interfaces } = schema;\n\n const statusClassName = classnames('sidebar__status__badge', {\n 'sidebar__status__badge--published': status === PUBLISHED,\n 'sidebar__status__badge--unpublished': status === UNPUBLISHED\n });\n\n return (\n <div className=\"sidebar\" data-testid=\"sideBarRelations-main-div\">\n <div className=\"sidebar__content\">\n {formattedCreated && (\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useState","useEffect","PropTypes","uuidv1","useApolloClient","getQuery","formFieldTypes","classnames","VersionsList","PUBLISHED","UNPUBLISHED","CustomSidebarInfoContainer","EntityNavLinks","SideBarRelations","schema","onChange","formData","entity","relation","RelationComponent","formattedStatus","formattedUpdated","formattedCreated","formattedPublished","status","client","relationsComponents","setRelationsComponents","fetchRelationSchema","entityIdentifier","data","getEntitySchemas","relationSchema","query","variables","identifier","allRelationComponents","Promise","all","relations","filter","showInForm","foreignKey","properties","map","id","staticData","itemId","itemEntity","interfaces","statusClassName","createElement","className","displayProperties","adminMainInfoProperty","Fragment","entitySchema","key","onSelect","propTypes","object","isRequired","func","defaultProps"],"sources":["../../../../../src/components/EntityManager/Entity/SideBarRelations/index.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport uuidv1 from 'uuid/v1';\nimport { useApolloClient } from '@apollo/client';\nimport { getQuery } from '@blaze-cms/admin-ui-utils';\nimport { formFieldTypes } from '@blaze-cms/react-form-builder';\nimport classnames from 'classnames';\nimport { VersionsList } from '@blaze-cms/versioning-ui';\nimport { PUBLISHED, UNPUBLISHED } from '../../../../constants';\nimport CustomSidebarInfoContainer from './container/CustomSidebarInfoContainer';\nimport EntityNavLinks from '../EntitiyNavLinks';\n\nconst SideBarRelations = ({ schema, onChange, formData, entity }) => {\n const { relation: RelationComponent } = formFieldTypes;\n const {\n formattedStatus,\n formattedUpdated,\n formattedCreated,\n formattedPublished,\n status\n } = formData;\n const client = useApolloClient();\n\n const [relationsComponents, setRelationsComponents] = useState(null);\n\n useEffect(\n () => {\n (async () => {\n const fetchRelationSchema = async ({ entityIdentifier }) => {\n if (!entityIdentifier) return null;\n\n const {\n data: {\n getEntitySchemas: [relationSchema]\n }\n } = await client.query({\n query: getQuery('GET_ENTITY_SCHEMA'),\n variables: { identifier: entityIdentifier }\n });\n return relationSchema;\n };\n\n if (!relationsComponents && schema) {\n const allRelationComponents = await Promise.all(\n schema.relations\n .filter(({ showInForm, foreignKey }) => showInForm && schema.properties[foreignKey])\n .map(async relation => ({\n id: uuidv1(),\n staticData: relation,\n schema: await fetchRelationSchema(relation)\n }))\n );\n\n setRelationsComponents(allRelationComponents);\n }\n })();\n },\n [client, relationsComponents, schema, schema.relations]\n );\n const { id: itemId } = entity;\n const { identifier: itemEntity, interfaces } = schema;\n\n const statusClassName = classnames('sidebar__status__badge', {\n 'sidebar__status__badge--published': status === PUBLISHED,\n 'sidebar__status__badge--unpublished': status === UNPUBLISHED\n });\n\n return (\n <div className=\"sidebar\" data-testid=\"sideBarRelations-main-div\">\n <div className=\"sidebar__content\">\n <div className=\"sidebar__status\">\n {formattedCreated && (\n <div className=\"sidebar__top\">\n <div className=\"sidebar__status__wrapper\">\n <b>Status</b>\n <span className={statusClassName}>{formattedStatus}</span>\n </div>\n {formattedStatus === PUBLISHED && (\n <p>\n {formattedStatus} on: <span> {formattedPublished}</span>\n </p>\n )}\n </div>\n )}\n\n {!schema.displayProperties.adminMainInfoProperty && (\n <>\n <p>\n Created: <span>{formattedCreated}</span>\n </p>\n <p>\n Updated: <span>{formattedUpdated}</span>\n </p>\n </>\n )}\n\n <CustomSidebarInfoContainer\n id={itemId}\n schema={schema}\n displayProperties={schema.displayProperties}\n />\n </div>\n\n <VersionsList itemEntity={itemEntity} itemId={itemId} interfaces={interfaces} />\n <EntityNavLinks schema={schema} />\n\n {relationsComponents &&\n relationsComponents.map(({ id, staticData, schema: entitySchema }) => (\n <RelationComponent\n formData={formData}\n schema={entitySchema}\n key={id}\n staticData={staticData}\n onSelect={onChange}\n />\n ))}\n </div>\n </div>\n );\n};\n\nSideBarRelations.propTypes = {\n schema: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n formData: PropTypes.object.isRequired,\n entity: PropTypes.object\n};\n\nSideBarRelations.defaultProps = {\n entity: {}\n};\n\nexport default SideBarRelations;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,MAAM,MAAM,SAAS;AAC5B,SAASC,eAAe,QAAQ,gBAAgB;AAChD,SAASC,QAAQ,QAAQ,2BAA2B;AACpD,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,YAAY,QAAQ,0BAA0B;AACvD,SAASC,SAAS,EAAEC,WAAW,QAAQ,uBAAuB;AAC9D,OAAOC,0BAA0B,MAAM,wCAAwC;AAC/E,OAAOC,cAAc,MAAM,oBAAoB;AAE/C,MAAMC,gBAAgB,GAAGA,CAAC;EAAEC,MAAM;EAAEC,QAAQ;EAAEC,QAAQ;EAAEC;AAAO,CAAC,KAA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KAAA,CAAAoD,aAAA,eAAO9B,gBAAuB,CACtC,CACH,CACH,eAEDtB,KAAA,CAAAoD,aAAA,CAACxC,0BAA0B;IACzBkC,EAAE,EAAEE,MAAO;IACXjC,MAAM,EAAEA,MAAO;IACfuC,iBAAiB,EAAEvC,MAAM,CAACuC;EAAkB,CAC7C,CACE,CAAC,eAENtD,KAAA,CAAAoD,aAAA,CAAC3C,YAAY;IAACwC,UAAU,EAAEA,UAAW;IAACD,MAAM,EAAEA,MAAO;IAACE,UAAU,EAAEA;EAAW,CAAE,CAAC,eAChFlD,KAAA,CAAAoD,aAAA,CAACvC,cAAc;IAACE,MAAM,EAAEA;EAAO,CAAE,CAAC,EAEjCY,mBAAmB,IAClBA,mBAAmB,CAACkB,GAAG,CAAC,CAAC;IAAEC,EAAE;IAAEC,UAAU;IAAEhC,MAAM,EAAE0C;EAAa,CAAC,kBAC/DzD,KAAA,CAAAoD,aAAA,CAAChC,iBAAiB;IAChBH,QAAQ,EAAEA,QAAS;IACnBF,MAAM,EAAE0C,YAAa;IACrBC,GAAG,EAAEZ,EAAG;IACRC,UAAU,EAAEA,UAAW;IACvBY,QAAQ,EAAE3C;EAAS,CACpB,CACF,CACA,CACF,CAAC;AAEV,CAAC;AAEDF,gBAAgB,CAAC8C,SAAS,GAAG;EAC3B7C,MAAM,EAAEZ,SAAS,CAAC0D,MAAM,CAACC,UAAU;EACnC9C,QAAQ,EAAEb,SAAS,CAAC4D,IAAI,CAACD,UAAU;EACnC7C,QAAQ,EAAEd,SAAS,CAAC0D,MAAM,CAACC,UAAU;EACrC5C,MAAM,EAAEf,SAAS,CAAC0D;AACpB,CAAC;AAED/C,gBAAgB,CAACkD,YAAY,GAAG;EAC9B9C,MAAM,EAAE,CAAC;AACX,CAAC;AAED,eAAeJ,gBAAgB"}
|
package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
const CustomSidebarInfo = ({
|
|
4
|
+
items,
|
|
5
|
+
customSidebarInfoKey
|
|
6
|
+
}) => {
|
|
7
|
+
if (!items) return null;
|
|
8
|
+
const customSidebarInfoItems = items.map(item => Object.values(item).map(info => {
|
|
9
|
+
if (!info.label || !info.value) return null;
|
|
10
|
+
return /*#__PURE__*/React.createElement("p", null, info.label, ": ", /*#__PURE__*/React.createElement("span", null, info.value));
|
|
11
|
+
}).filter(Boolean));
|
|
12
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
13
|
+
className: "custom-sidebar-info",
|
|
14
|
+
key: customSidebarInfoKey
|
|
15
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
16
|
+
className: "custom-sidebar-info--container"
|
|
17
|
+
}, customSidebarInfoItems));
|
|
18
|
+
};
|
|
19
|
+
export default CustomSidebarInfo;
|
|
20
|
+
CustomSidebarInfo.propTypes = {
|
|
21
|
+
customSidebarInfoKey: PropTypes.string.isRequired,
|
|
22
|
+
items: PropTypes.array.isRequired
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=CustomSidebarInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomSidebarInfo.js","names":["PropTypes","React","CustomSidebarInfo","items","customSidebarInfoKey","customSidebarInfoItems","map","item","Object","values","info","label","value","createElement","filter","Boolean","className","key","propTypes","string","isRequired","array"],"sources":["../../../../../../src/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nconst CustomSidebarInfo = ({ items, customSidebarInfoKey }) => {\n if (!items) return null;\n\n const customSidebarInfoItems = items.map(item =>\n Object.values(item)\n .map(info => {\n if (!info.label || !info.value) return null;\n\n return (\n <p>\n {info.label}: <span>{info.value}</span>\n </p>\n );\n })\n .filter(Boolean)\n );\n\n return (\n <div className=\"custom-sidebar-info\" key={customSidebarInfoKey}>\n <div className=\"custom-sidebar-info--container\">{customSidebarInfoItems}</div>\n </div>\n );\n};\n\nexport default CustomSidebarInfo;\n\nCustomSidebarInfo.propTypes = {\n customSidebarInfoKey: PropTypes.string.isRequired,\n items: PropTypes.array.isRequired\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,YAAY;AAClC,OAAOC,KAAK,MAAM,OAAO;AAEzB,MAAMC,iBAAiB,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAqB,CAAC,KAAK;EAC7D,IAAI,CAACD,KAAK,EAAE,OAAO,IAAI;EAEvB,MAAME,sBAAsB,GAAGF,KAAK,CAACG,GAAG,CAACC,IAAI,IAC3CC,MAAM,CAACC,MAAM,CAACF,IAAI,CAAC,CAChBD,GAAG,CAACI,IAAI,IAAI;IACX,IAAI,CAACA,IAAI,CAACC,KAAK,IAAI,CAACD,IAAI,CAACE,KAAK,EAAE,OAAO,IAAI;IAE3C,oBACEX,KAAA,CAAAY,aAAA,YACGH,IAAI,CAACC,KAAK,EAAC,IAAE,eAAAV,KAAA,CAAAY,aAAA,eAAOH,IAAI,CAACE,KAAY,CACrC,CAAC;EAER,CAAC,CAAC,CACDE,MAAM,CAACC,OAAO,CACnB,CAAC;EAED,oBACEd,KAAA,CAAAY,aAAA;IAAKG,SAAS,EAAC,qBAAqB;IAACC,GAAG,EAAEb;EAAqB,gBAC7DH,KAAA,CAAAY,aAAA;IAAKG,SAAS,EAAC;EAAgC,GAAEX,sBAA4B,CAC1E,CAAC;AAEV,CAAC;AAED,eAAeH,iBAAiB;AAEhCA,iBAAiB,CAACgB,SAAS,GAAG;EAC5Bd,oBAAoB,EAAEJ,SAAS,CAACmB,MAAM,CAACC,UAAU;EACjDjB,KAAK,EAAEH,SAAS,CAACqB,KAAK,CAACD;AACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/plugin-data-ui",
|
|
3
|
-
"version": "0.129.0-project-admin-customisations.
|
|
3
|
+
"version": "0.129.0-project-admin-customisations.1",
|
|
4
4
|
"description": "Blaze plugin data ui",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "GPL-3.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@blaze-cms/admin-ui-utils": "0.129.0-project-admin-customisations.
|
|
30
|
+
"@blaze-cms/admin-ui-utils": "0.129.0-project-admin-customisations.1",
|
|
31
31
|
"@blaze-cms/core-errors": "0.129.0-project-admin-customisations.0",
|
|
32
32
|
"@blaze-cms/plugin-render-hooks-ui": "0.129.0-project-admin-customisations.0",
|
|
33
|
-
"@blaze-cms/react-form-builder": "0.129.0-project-admin-customisations.
|
|
34
|
-
"@blaze-cms/react-page-builder": "0.129.0-project-admin-customisations.
|
|
33
|
+
"@blaze-cms/react-form-builder": "0.129.0-project-admin-customisations.1",
|
|
34
|
+
"@blaze-cms/react-page-builder": "0.129.0-project-admin-customisations.1",
|
|
35
35
|
"@blaze-cms/setup-ui": "0.129.0-project-admin-customisations.0",
|
|
36
36
|
"@blaze-cms/versioning-ui": "0.129.0-project-admin-customisations.0",
|
|
37
37
|
"@blaze-react/button": "0.5.19",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"lib/*",
|
|
67
67
|
"lib-es/*"
|
|
68
68
|
],
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "48fd7d1e3861b250bdfd88e70710ead2bd9f5b2a"
|
|
70
70
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Link } from 'react-router-dom';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const EntityNavLinks = ({ schema }) => {
|
|
5
|
+
if (!schema) return null;
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
displayProperties: { adminSectionNavigation }
|
|
9
|
+
} = schema;
|
|
10
|
+
|
|
11
|
+
if (!adminSectionNavigation) return null;
|
|
12
|
+
|
|
13
|
+
const links = Object.entries(adminSectionNavigation).map(([k, v]) => {
|
|
14
|
+
const { label, uri } = v;
|
|
15
|
+
const Wrapper = uri.startsWith('#') ? 'a' : Link;
|
|
16
|
+
return (
|
|
17
|
+
<Wrapper className="entity-section-link" href={uri} to={uri}>
|
|
18
|
+
{label}
|
|
19
|
+
</Wrapper>
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return <div className="entity-section-links">{links}</div>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default EntityNavLinks;
|
package/src/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import useCustomSidebarData from '../hooks/useCustomSidebarData';
|
|
4
|
+
import CustomSidebarInfo from '../presentational/CustomSidebarInfo';
|
|
5
|
+
|
|
6
|
+
const CustomSibebarInfoContainer = ({ id, schema, displayProperties }) => {
|
|
7
|
+
const { data } = useCustomSidebarData({ id, schema, displayProperties });
|
|
8
|
+
|
|
9
|
+
if (!data || !Object.keys(data) || Object.keys(data).length === 0) return null;
|
|
10
|
+
|
|
11
|
+
const items = Object.values(data).flatMap(item => Object.values(item));
|
|
12
|
+
|
|
13
|
+
return <CustomSidebarInfo items={items} customSidebarInfoKey={displayProperties.key} />;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default CustomSibebarInfoContainer;
|
|
17
|
+
|
|
18
|
+
CustomSibebarInfoContainer.propTypes = {
|
|
19
|
+
id: PropTypes.string.isRequired,
|
|
20
|
+
displayProperties: PropTypes.object.isRequired,
|
|
21
|
+
schema: PropTypes.object.isRequired
|
|
22
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
import { BlazeError } from '@blaze-cms/core-errors';
|
|
3
|
+
|
|
4
|
+
export default function buildDynamicQuery({ id, schema, displayProperties }) {
|
|
5
|
+
if (!schema || !schema.actions || !schema.actions.get || !schema.properties) {
|
|
6
|
+
throw new BlazeError(
|
|
7
|
+
'DataEntity query requires get action, properties and fields from entity schema'
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (
|
|
12
|
+
displayProperties.adminMainInfoProperty &&
|
|
13
|
+
Array.isArray(displayProperties.adminMainInfoProperty)
|
|
14
|
+
) {
|
|
15
|
+
const fields = displayProperties.adminMainInfoProperty.map(
|
|
16
|
+
infoProperty =>
|
|
17
|
+
`${infoProperty} {
|
|
18
|
+
label
|
|
19
|
+
value
|
|
20
|
+
}`
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
return gql`query getInfoBoxData($id: String!){
|
|
24
|
+
${schema.actions.get}( id: $id ) {
|
|
25
|
+
id
|
|
26
|
+
${fields.map(field => field)}
|
|
27
|
+
__typename
|
|
28
|
+
}
|
|
29
|
+
}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import ProptTypes from 'prop-types';
|
|
2
|
+
import { useQuery, gql } from '@apollo/client';
|
|
3
|
+
import buildDynamicQuery from '../helpers/build-dynamic-query';
|
|
4
|
+
|
|
5
|
+
const useCustomSidebarData = ({ id, schema, displayProperties }) => {
|
|
6
|
+
const query = buildDynamicQuery({ id, schema, displayProperties });
|
|
7
|
+
|
|
8
|
+
const customSidebarInfoQuery =
|
|
9
|
+
query ||
|
|
10
|
+
gql`
|
|
11
|
+
query {
|
|
12
|
+
__typename
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const { data = {}, loading, error } = useQuery(customSidebarInfoQuery, {
|
|
17
|
+
variables: { id },
|
|
18
|
+
skip: !query
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return { data: data.__typename !== 'Query' ? data : null, loading, error };
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default useCustomSidebarData;
|
|
25
|
+
|
|
26
|
+
useCustomSidebarData.propTypes = {
|
|
27
|
+
displayProperties: ProptTypes.object.isRequired
|
|
28
|
+
};
|
|
@@ -7,6 +7,8 @@ import { formFieldTypes } from '@blaze-cms/react-form-builder';
|
|
|
7
7
|
import classnames from 'classnames';
|
|
8
8
|
import { VersionsList } from '@blaze-cms/versioning-ui';
|
|
9
9
|
import { PUBLISHED, UNPUBLISHED } from '../../../../constants';
|
|
10
|
+
import CustomSidebarInfoContainer from './container/CustomSidebarInfoContainer';
|
|
11
|
+
import EntityNavLinks from '../EntitiyNavLinks';
|
|
10
12
|
|
|
11
13
|
const SideBarRelations = ({ schema, onChange, formData, entity }) => {
|
|
12
14
|
const { relation: RelationComponent } = formFieldTypes;
|
|
@@ -18,7 +20,9 @@ const SideBarRelations = ({ schema, onChange, formData, entity }) => {
|
|
|
18
20
|
status
|
|
19
21
|
} = formData;
|
|
20
22
|
const client = useApolloClient();
|
|
23
|
+
|
|
21
24
|
const [relationsComponents, setRelationsComponents] = useState(null);
|
|
25
|
+
|
|
22
26
|
useEffect(
|
|
23
27
|
() => {
|
|
24
28
|
(async () => {
|
|
@@ -64,28 +68,42 @@ const SideBarRelations = ({ schema, onChange, formData, entity }) => {
|
|
|
64
68
|
return (
|
|
65
69
|
<div className="sidebar" data-testid="sideBarRelations-main-div">
|
|
66
70
|
<div className="sidebar__content">
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<div className="
|
|
70
|
-
<
|
|
71
|
-
|
|
71
|
+
<div className="sidebar__status">
|
|
72
|
+
{formattedCreated && (
|
|
73
|
+
<div className="sidebar__top">
|
|
74
|
+
<div className="sidebar__status__wrapper">
|
|
75
|
+
<b>Status</b>
|
|
76
|
+
<span className={statusClassName}>{formattedStatus}</span>
|
|
77
|
+
</div>
|
|
78
|
+
{formattedStatus === PUBLISHED && (
|
|
79
|
+
<p>
|
|
80
|
+
{formattedStatus} on: <span> {formattedPublished}</span>
|
|
81
|
+
</p>
|
|
82
|
+
)}
|
|
72
83
|
</div>
|
|
73
|
-
|
|
84
|
+
)}
|
|
85
|
+
|
|
86
|
+
{!schema.displayProperties.adminMainInfoProperty && (
|
|
87
|
+
<>
|
|
74
88
|
<p>
|
|
75
|
-
|
|
89
|
+
Created: <span>{formattedCreated}</span>
|
|
76
90
|
</p>
|
|
77
|
-
|
|
91
|
+
<p>
|
|
92
|
+
Updated: <span>{formattedUpdated}</span>
|
|
93
|
+
</p>
|
|
94
|
+
</>
|
|
95
|
+
)}
|
|
78
96
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
</div>
|
|
86
|
-
)}
|
|
97
|
+
<CustomSidebarInfoContainer
|
|
98
|
+
id={itemId}
|
|
99
|
+
schema={schema}
|
|
100
|
+
displayProperties={schema.displayProperties}
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
87
103
|
|
|
88
104
|
<VersionsList itemEntity={itemEntity} itemId={itemId} interfaces={interfaces} />
|
|
105
|
+
<EntityNavLinks schema={schema} />
|
|
106
|
+
|
|
89
107
|
{relationsComponents &&
|
|
90
108
|
relationsComponents.map(({ id, staticData, schema: entitySchema }) => (
|
|
91
109
|
<RelationComponent
|
package/src/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const CustomSidebarInfo = ({ items, customSidebarInfoKey }) => {
|
|
5
|
+
if (!items) return null;
|
|
6
|
+
|
|
7
|
+
const customSidebarInfoItems = items.map(item =>
|
|
8
|
+
Object.values(item)
|
|
9
|
+
.map(info => {
|
|
10
|
+
if (!info.label || !info.value) return null;
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<p>
|
|
14
|
+
{info.label}: <span>{info.value}</span>
|
|
15
|
+
</p>
|
|
16
|
+
);
|
|
17
|
+
})
|
|
18
|
+
.filter(Boolean)
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div className="custom-sidebar-info" key={customSidebarInfoKey}>
|
|
23
|
+
<div className="custom-sidebar-info--container">{customSidebarInfoItems}</div>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default CustomSidebarInfo;
|
|
29
|
+
|
|
30
|
+
CustomSidebarInfo.propTypes = {
|
|
31
|
+
customSidebarInfoKey: PropTypes.string.isRequired,
|
|
32
|
+
items: PropTypes.array.isRequired
|
|
33
|
+
};
|