@blaze-cms/plugin-data-ui 0.129.0-project-admin-customisations.0 → 0.129.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 +13 -11
- package/README.md +0 -42
- package/lib/components/EntityDataListing/EntityDataListing.js +24 -3
- package/lib/components/EntityDataListing/EntityDataListing.js.map +1 -1
- package/lib/components/EntityManager/Entity/Entity.js +18 -29
- package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js +6 -12
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib/components/ListingTable/ListingTable.js +26 -5
- package/lib/components/ListingTable/ListingTable.js.map +1 -1
- package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +12 -5
- package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
- package/lib/index.js +11 -3
- package/lib/index.js.map +1 -1
- package/lib/utils/add-content-menu-items.js +13 -64
- package/lib/utils/add-content-menu-items.js.map +1 -1
- package/lib-es/components/EntityDataListing/EntityDataListing.js +14 -3
- package/lib-es/components/EntityDataListing/EntityDataListing.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/Entity.js +18 -29
- package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +7 -13
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTable.js +25 -4
- package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +13 -6
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
- package/lib-es/index.js +9 -1
- package/lib-es/index.js.map +1 -1
- package/lib-es/utils/add-content-menu-items.js +5 -49
- package/lib-es/utils/add-content-menu-items.js.map +1 -1
- package/package.json +9 -10
- package/src/components/EntityDataListing/EntityDataListing.js +12 -3
- package/src/components/EntityManager/Entity/Entity.js +59 -65
- package/src/components/EntityManager/Entity/SideBarRelations/index.js +9 -23
- package/src/components/ListingTable/ListingTable.js +18 -4
- package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +16 -5
- package/src/index.js +8 -1
- package/src/utils/add-content-menu-items.js +3 -45
- package/lib/components/InfoBoxes/InfoBoxes.js +0 -36
- package/lib/components/InfoBoxes/InfoBoxes.js.map +0 -1
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js +0 -44
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +0 -1
- package/lib/components/InfoBoxes/helpers/build-dynamic-query.js +0 -25
- package/lib/components/InfoBoxes/helpers/build-dynamic-query.js.map +0 -1
- package/lib/components/InfoBoxes/hooks/useData.js +0 -42
- package/lib/components/InfoBoxes/hooks/useData.js.map +0 -1
- package/lib/components/InfoBoxes/hooks/useInfoBox.js +0 -26
- package/lib/components/InfoBoxes/hooks/useInfoBox.js.map +0 -1
- package/lib/components/InfoBoxes/index.js +0 -12
- package/lib/components/InfoBoxes/index.js.map +0 -1
- package/lib/components/InfoBoxes/presentational/InfoBox.js +0 -46
- package/lib/components/InfoBoxes/presentational/InfoBox.js.map +0 -1
- package/lib-es/components/InfoBoxes/InfoBoxes.js +0 -28
- package/lib-es/components/InfoBoxes/InfoBoxes.js.map +0 -1
- package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js +0 -30
- package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +0 -1
- package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js +0 -25
- package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +0 -1
- package/lib-es/components/InfoBoxes/hooks/useData.js +0 -37
- package/lib-es/components/InfoBoxes/hooks/useData.js.map +0 -1
- package/lib-es/components/InfoBoxes/hooks/useInfoBox.js +0 -19
- package/lib-es/components/InfoBoxes/hooks/useInfoBox.js.map +0 -1
- package/lib-es/components/InfoBoxes/index.js +0 -3
- package/lib-es/components/InfoBoxes/index.js.map +0 -1
- package/lib-es/components/InfoBoxes/presentational/InfoBox.js +0 -31
- package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +0 -1
- package/src/components/InfoBoxes/InfoBoxes.js +0 -24
- package/src/components/InfoBoxes/container/InfoBoxContainer.js +0 -22
- package/src/components/InfoBoxes/helpers/build-dynamic-query.js +0 -25
- package/src/components/InfoBoxes/hooks/useData.js +0 -20
- package/src/components/InfoBoxes/hooks/useInfoBox.js +0 -13
- package/src/components/InfoBoxes/index.js +0 -3
- package/src/components/InfoBoxes/presentational/InfoBox.js +0 -34
|
@@ -1,42 +0,0 @@
|
|
|
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 _client = require("@apollo/client");
|
|
11
|
-
var _useInfoBox = _interopRequireDefault(require("./useInfoBox"));
|
|
12
|
-
var _templateObject;
|
|
13
|
-
function useData(_ref) {
|
|
14
|
-
var id = _ref.id,
|
|
15
|
-
schema = _ref.schema,
|
|
16
|
-
infoBox = _ref.infoBox;
|
|
17
|
-
var _useInfoBoxData = (0, _useInfoBox["default"])({
|
|
18
|
-
id: id,
|
|
19
|
-
schema: schema,
|
|
20
|
-
infoBox: infoBox
|
|
21
|
-
}),
|
|
22
|
-
query = _useInfoBoxData.query;
|
|
23
|
-
var infoBoxQuery = query || (0, _client.gql)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n query {\n __typename\n }\n "])));
|
|
24
|
-
var _useQuery = (0, _client.useQuery)(infoBoxQuery, {
|
|
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 = useData;
|
|
41
|
-
exports["default"] = _default;
|
|
42
|
-
//# sourceMappingURL=useData.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useData.js","names":["_client","require","_useInfoBox","_interopRequireDefault","_templateObject","useData","_ref","id","schema","infoBox","_useInfoBoxData","useInfoBoxData","query","infoBoxQuery","gql","_taggedTemplateLiteral2","_useQuery","useQuery","variables","skip","_useQuery$data","data","loading","error","__typename","_default","exports"],"sources":["../../../../src/components/InfoBoxes/hooks/useData.js"],"sourcesContent":["import { useQuery, gql } from '@apollo/client';\nimport useInfoBoxData from './useInfoBox';\n\nfunction useData({ id, schema, infoBox }) {\n const { query } = useInfoBoxData({ id, schema, infoBox });\n\n const infoBoxQuery =\n query ||\n gql`\n query {\n __typename\n }\n `;\n\n const { data = {}, loading, error } = useQuery(infoBoxQuery, { variables: { id }, skip: !query });\n\n return { data: data.__typename !== 'Query' ? data : null, loading, error };\n}\n\nexport default useData;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA0C,IAAAG,eAAA;AAE1C,SAASC,OAAOA,CAAAC,IAAA,EAA0B;EAAA,IAAvBC,EAAE,GAAAD,IAAA,CAAFC,EAAE;IAAEC,MAAM,GAAAF,IAAA,CAANE,MAAM;IAAEC,OAAO,GAAAH,IAAA,CAAPG,OAAO;EACpC,IAAAC,eAAA,GAAkB,IAAAC,sBAAc,EAAC;MAAEJ,EAAE,EAAFA,EAAE;MAAEC,MAAM,EAANA,MAAM;MAAEC,OAAO,EAAPA;IAAQ,CAAC,CAAC;IAAjDG,KAAK,GAAAF,eAAA,CAALE,KAAK;EAEb,IAAMC,YAAY,GAChBD,KAAK,QACLE,WAAG,EAAAV,eAAA,KAAAA,eAAA,OAAAW,uBAAA,sEAIF;EAEH,IAAAC,SAAA,GAAsC,IAAAC,gBAAQ,EAACJ,YAAY,EAAE;MAAEK,SAAS,EAAE;QAAEX,EAAE,EAAFA;MAAG,CAAC;MAAEY,IAAI,EAAE,CAACP;IAAM,CAAC,CAAC;IAAAQ,cAAA,GAAAJ,SAAA,CAAzFK,IAAI;IAAJA,IAAI,GAAAD,cAAA,cAAG,CAAC,CAAC,GAAAA,cAAA;IAAEE,OAAO,GAAAN,SAAA,CAAPM,OAAO;IAAEC,KAAK,GAAAP,SAAA,CAALO,KAAK;EAEjC,OAAO;IAAEF,IAAI,EAAEA,IAAI,CAACG,UAAU,KAAK,OAAO,GAAGH,IAAI,GAAG,IAAI;IAAEC,OAAO,EAAPA,OAAO;IAAEC,KAAK,EAALA;EAAM,CAAC;AAC5E;AAAC,IAAAE,QAAA,GAEcpB,OAAO;AAAAqB,OAAA,cAAAD,QAAA"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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 _buildDynamicQuery2 = _interopRequireDefault(require("../helpers/build-dynamic-query"));
|
|
10
|
-
function useInfoBox(_ref) {
|
|
11
|
-
var id = _ref.id,
|
|
12
|
-
schema = _ref.schema,
|
|
13
|
-
infoBox = _ref.infoBox;
|
|
14
|
-
var _buildDynamicQuery = (0, _buildDynamicQuery2["default"])({
|
|
15
|
-
id: id,
|
|
16
|
-
schema: schema,
|
|
17
|
-
infoBox: infoBox
|
|
18
|
-
}),
|
|
19
|
-
query = _buildDynamicQuery.query;
|
|
20
|
-
return {
|
|
21
|
-
query: query || null
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
var _default = useInfoBox;
|
|
25
|
-
exports["default"] = _default;
|
|
26
|
-
//# sourceMappingURL=useInfoBox.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInfoBox.js","names":["_buildDynamicQuery2","_interopRequireDefault","require","useInfoBox","_ref","id","schema","infoBox","_buildDynamicQuery","buildDynamicQuery","query","_default","exports"],"sources":["../../../../src/components/InfoBoxes/hooks/useInfoBox.js"],"sourcesContent":["import buildDynamicQuery from '../helpers/build-dynamic-query';\n\nfunction useInfoBox({ id, schema, infoBox }) {\n const { query } = buildDynamicQuery({\n id,\n schema,\n infoBox\n });\n\n return { query: query || null };\n}\n\nexport default useInfoBox;\n"],"mappings":";;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,SAASC,UAAUA,CAAAC,IAAA,EAA0B;EAAA,IAAvBC,EAAE,GAAAD,IAAA,CAAFC,EAAE;IAAEC,MAAM,GAAAF,IAAA,CAANE,MAAM;IAAEC,OAAO,GAAAH,IAAA,CAAPG,OAAO;EACvC,IAAAC,kBAAA,GAAkB,IAAAC,8BAAiB,EAAC;MAClCJ,EAAE,EAAFA,EAAE;MACFC,MAAM,EAANA,MAAM;MACNC,OAAO,EAAPA;IACF,CAAC,CAAC;IAJMG,KAAK,GAAAF,kBAAA,CAALE,KAAK;EAMb,OAAO;IAAEA,KAAK,EAAEA,KAAK,IAAI;EAAK,CAAC;AACjC;AAAC,IAAAC,QAAA,GAEcR,UAAU;AAAAS,OAAA,cAAAD,QAAA"}
|
|
@@ -1,12 +0,0 @@
|
|
|
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 _InfoBoxes = _interopRequireDefault(require("./InfoBoxes"));
|
|
10
|
-
var _default = _InfoBoxes["default"];
|
|
11
|
-
exports["default"] = _default;
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_InfoBoxes","_interopRequireDefault","require","_default","InfoBoxes","exports"],"sources":["../../../src/components/InfoBoxes/index.js"],"sourcesContent":["import InfoBoxes from './InfoBoxes';\n\nexport default InfoBoxes;\n"],"mappings":";;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAoC,IAAAC,QAAA,GAErBC,qBAAS;AAAAC,OAAA,cAAAF,QAAA"}
|
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
require("core-js/modules/es.array.concat.js");
|
|
14
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
var _react = _interopRequireDefault(require("react"));
|
|
16
|
-
var InfoBox = function InfoBox(_ref) {
|
|
17
|
-
var items = _ref.items,
|
|
18
|
-
infoBoxKey = _ref.infoBoxKey;
|
|
19
|
-
if (!items) return null;
|
|
20
|
-
var infoBoxItems = items.map(function (item) {
|
|
21
|
-
return Object.values(item).map(function (info) {
|
|
22
|
-
if (!info.label || !info.value) return null;
|
|
23
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
24
|
-
className: "info-box--item",
|
|
25
|
-
key: "".concat(infoBoxKey, "-").concat(info.label.toLowerCase())
|
|
26
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
27
|
-
className: "info-box--label"
|
|
28
|
-
}, info.label, ": "), /*#__PURE__*/_react["default"].createElement("div", {
|
|
29
|
-
className: "info-box--value"
|
|
30
|
-
}, info.value));
|
|
31
|
-
}).filter(Boolean);
|
|
32
|
-
});
|
|
33
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
34
|
-
className: "info-box",
|
|
35
|
-
key: infoBoxKey
|
|
36
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
37
|
-
className: "info-box--container"
|
|
38
|
-
}, infoBoxItems));
|
|
39
|
-
};
|
|
40
|
-
var _default = InfoBox;
|
|
41
|
-
exports["default"] = _default;
|
|
42
|
-
InfoBox.propTypes = {
|
|
43
|
-
infoBoxKey: _propTypes["default"].string.isRequired,
|
|
44
|
-
items: _propTypes["default"].array.isRequired
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=InfoBox.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InfoBox.js","names":["_propTypes","_interopRequireDefault","require","_react","InfoBox","_ref","items","infoBoxKey","infoBoxItems","map","item","Object","values","info","label","value","createElement","className","key","concat","toLowerCase","filter","Boolean","_default","exports","propTypes","PropTypes","string","isRequired","array"],"sources":["../../../../src/components/InfoBoxes/presentational/InfoBox.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nconst InfoBox = ({ items, infoBoxKey }) => {\n if (!items) return null;\n\n const infoBoxItems = items.map(item =>\n Object.values(item)\n .map(info => {\n if (!info.label || !info.value) return null;\n\n return (\n <div className=\"info-box--item\" key={`${infoBoxKey}-${info.label.toLowerCase()}`}>\n <div className=\"info-box--label\">{info.label}: </div>\n <div className=\"info-box--value\">{info.value}</div>\n </div>\n );\n })\n .filter(Boolean)\n );\n\n return (\n <div className=\"info-box\" key={infoBoxKey}>\n <div className=\"info-box--container\">{infoBoxItems}</div>\n </div>\n );\n};\n\nexport default InfoBox;\n\nInfoBox.propTypes = {\n infoBoxKey: 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,OAAO,GAAG,SAAVA,OAAOA,CAAAC,IAAA,EAA8B;EAAA,IAAxBC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAEC,UAAU,GAAAF,IAAA,CAAVE,UAAU;EAClC,IAAI,CAACD,KAAK,EAAE,OAAO,IAAI;EAEvB,IAAME,YAAY,GAAGF,KAAK,CAACG,GAAG,CAAC,UAAAC,IAAI;IAAA,OACjCC,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;QAAKC,SAAS,EAAC,gBAAgB;QAACC,GAAG,KAAAC,MAAA,CAAKZ,UAAU,OAAAY,MAAA,CAAIN,IAAI,CAACC,KAAK,CAACM,WAAW,CAAC,CAAC;MAAG,gBAC/EjB,MAAA,YAAAa,aAAA;QAAKC,SAAS,EAAC;MAAiB,GAAEJ,IAAI,CAACC,KAAK,EAAC,IAAO,CAAC,eACrDX,MAAA,YAAAa,aAAA;QAAKC,SAAS,EAAC;MAAiB,GAAEJ,IAAI,CAACE,KAAW,CAC/C,CAAC;IAEV,CAAC,CAAC,CACDM,MAAM,CAACC,OAAO,CAAC;EAAA,CACpB,CAAC;EAED,oBACEnB,MAAA,YAAAa,aAAA;IAAKC,SAAS,EAAC,UAAU;IAACC,GAAG,EAAEX;EAAW,gBACxCJ,MAAA,YAAAa,aAAA;IAAKC,SAAS,EAAC;EAAqB,GAAET,YAAkB,CACrD,CAAC;AAEV,CAAC;AAAC,IAAAe,QAAA,GAEanB,OAAO;AAAAoB,OAAA,cAAAD,QAAA;AAEtBnB,OAAO,CAACqB,SAAS,GAAG;EAClBlB,UAAU,EAAEmB,qBAAS,CAACC,MAAM,CAACC,UAAU;EACvCtB,KAAK,EAAEoB,qBAAS,CAACG,KAAK,CAACD;AACzB,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import InfoBoxContainer from './container/InfoBoxContainer';
|
|
4
|
-
const InfoBoxes = ({
|
|
5
|
-
id,
|
|
6
|
-
schema
|
|
7
|
-
}) => {
|
|
8
|
-
const {
|
|
9
|
-
displayProperties: {
|
|
10
|
-
adminInfoBoxes = []
|
|
11
|
-
}
|
|
12
|
-
} = schema;
|
|
13
|
-
if (adminInfoBoxes.length <= 0) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
return adminInfoBoxes.map(infoBox => /*#__PURE__*/React.createElement(InfoBoxContainer, {
|
|
17
|
-
id: id,
|
|
18
|
-
schema: schema,
|
|
19
|
-
key: infoBox.key,
|
|
20
|
-
infoBox: infoBox
|
|
21
|
-
}));
|
|
22
|
-
};
|
|
23
|
-
export default InfoBoxes;
|
|
24
|
-
InfoBoxes.propTypes = {
|
|
25
|
-
id: PropTypes.string.isRequired,
|
|
26
|
-
schema: PropTypes.object.isRequired
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=InfoBoxes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InfoBoxes.js","names":["PropTypes","React","InfoBoxContainer","InfoBoxes","id","schema","displayProperties","adminInfoBoxes","length","map","infoBox","createElement","key","propTypes","string","isRequired","object"],"sources":["../../../src/components/InfoBoxes/InfoBoxes.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport InfoBoxContainer from './container/InfoBoxContainer';\n\nconst InfoBoxes = ({ id, schema }) => {\n const {\n displayProperties: { adminInfoBoxes = [] }\n } = schema;\n\n if (adminInfoBoxes.length <= 0) {\n return null;\n }\n\n return adminInfoBoxes.map(infoBox => (\n <InfoBoxContainer id={id} schema={schema} key={infoBox.key} infoBox={infoBox} />\n ));\n};\n\nexport default InfoBoxes;\n\nInfoBoxes.propTypes = {\n id: PropTypes.string.isRequired,\n schema: PropTypes.object.isRequired\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,YAAY;AAClC,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAOC,gBAAgB,MAAM,8BAA8B;AAE3D,MAAMC,SAAS,GAAGA,CAAC;EAAEC,EAAE;EAAEC;AAAO,CAAC,KAAK;EACpC,MAAM;IACJC,iBAAiB,EAAE;MAAEC,cAAc,GAAG;IAAG;EAC3C,CAAC,GAAGF,MAAM;EAEV,IAAIE,cAAc,CAACC,MAAM,IAAI,CAAC,EAAE;IAC9B,OAAO,IAAI;EACb;EAEA,OAAOD,cAAc,CAACE,GAAG,CAACC,OAAO,iBAC/BT,KAAA,CAAAU,aAAA,CAACT,gBAAgB;IAACE,EAAE,EAAEA,EAAG;IAACC,MAAM,EAAEA,MAAO;IAACO,GAAG,EAAEF,OAAO,CAACE,GAAI;IAACF,OAAO,EAAEA;EAAQ,CAAE,CAChF,CAAC;AACJ,CAAC;AAED,eAAeP,SAAS;AAExBA,SAAS,CAACU,SAAS,GAAG;EACpBT,EAAE,EAAEJ,SAAS,CAACc,MAAM,CAACC,UAAU;EAC/BV,MAAM,EAAEL,SAAS,CAACgB,MAAM,CAACD;AAC3B,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import useData from '../hooks/useData';
|
|
4
|
-
import InfoBox from '../presentational/InfoBox';
|
|
5
|
-
const InfoBoxContainer = ({
|
|
6
|
-
id,
|
|
7
|
-
schema,
|
|
8
|
-
infoBox
|
|
9
|
-
}) => {
|
|
10
|
-
const {
|
|
11
|
-
data
|
|
12
|
-
} = useData({
|
|
13
|
-
id,
|
|
14
|
-
schema,
|
|
15
|
-
infoBox
|
|
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(InfoBox, {
|
|
20
|
-
items: items,
|
|
21
|
-
infoBoxKey: infoBox.key
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
export default InfoBoxContainer;
|
|
25
|
-
InfoBoxContainer.propTypes = {
|
|
26
|
-
id: PropTypes.string.isRequired,
|
|
27
|
-
infoBox: PropTypes.object.isRequired,
|
|
28
|
-
schema: PropTypes.object.isRequired
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=InfoBoxContainer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InfoBoxContainer.js","names":["PropTypes","React","useData","InfoBox","InfoBoxContainer","id","schema","infoBox","data","Object","keys","length","items","values","flatMap","item","createElement","infoBoxKey","key","propTypes","string","isRequired","object"],"sources":["../../../../src/components/InfoBoxes/container/InfoBoxContainer.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport useData from '../hooks/useData';\nimport InfoBox from '../presentational/InfoBox';\n\nconst InfoBoxContainer = ({ id, schema, infoBox }) => {\n const { data } = useData({ id, schema, infoBox });\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 <InfoBox items={items} infoBoxKey={infoBox.key} />;\n};\n\nexport default InfoBoxContainer;\n\nInfoBoxContainer.propTypes = {\n id: PropTypes.string.isRequired,\n infoBox: PropTypes.object.isRequired,\n schema: PropTypes.object.isRequired\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,YAAY;AAClC,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAOC,OAAO,MAAM,kBAAkB;AACtC,OAAOC,OAAO,MAAM,2BAA2B;AAE/C,MAAMC,gBAAgB,GAAGA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAQ,CAAC,KAAK;EACpD,MAAM;IAAEC;EAAK,CAAC,GAAGN,OAAO,CAAC;IAAEG,EAAE;IAAEC,MAAM;IAAEC;EAAQ,CAAC,CAAC;EAEjD,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,OAAO;IAACS,KAAK,EAAEA,KAAM;IAACK,UAAU,EAAEV,OAAO,CAACW;EAAI,CAAE,CAAC;AAC3D,CAAC;AAED,eAAed,gBAAgB;AAE/BA,gBAAgB,CAACe,SAAS,GAAG;EAC3Bd,EAAE,EAAEL,SAAS,CAACoB,MAAM,CAACC,UAAU;EAC/Bd,OAAO,EAAEP,SAAS,CAACsB,MAAM,CAACD,UAAU;EACpCf,MAAM,EAAEN,SAAS,CAACsB,MAAM,CAACD;AAC3B,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { gql } from '@apollo/client';
|
|
2
|
-
import { BlazeError } from '@blaze-cms/core-errors';
|
|
3
|
-
export default function buildDynamicQuery({
|
|
4
|
-
id,
|
|
5
|
-
schema,
|
|
6
|
-
infoBox
|
|
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
|
-
const fields = `${infoBox.property} {
|
|
12
|
-
label
|
|
13
|
-
value
|
|
14
|
-
}`;
|
|
15
|
-
return {
|
|
16
|
-
query: gql`query getInfoBoxData($id: String!){
|
|
17
|
-
${schema.actions.get}( id: $id ) {
|
|
18
|
-
id
|
|
19
|
-
${fields}
|
|
20
|
-
__typename
|
|
21
|
-
}
|
|
22
|
-
}`
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=build-dynamic-query.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-dynamic-query.js","names":["gql","BlazeError","buildDynamicQuery","id","schema","infoBox","actions","get","properties","fields","property","query"],"sources":["../../../../src/components/InfoBoxes/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, infoBox }) {\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 const fields = `${infoBox.property} {\n label\n value\n }`;\n\n return {\n query: gql`query getInfoBoxData($id: String!){\n ${schema.actions.get}( id: $id ) {\n id\n ${fields}\n __typename\n }\n }`\n };\n}\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,gBAAgB;AACpC,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,eAAe,SAASC,iBAAiBA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAQ,CAAC,EAAE;EACjE,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,MAAMQ,MAAM,GAAI,GAAEJ,OAAO,CAACK,QAAS;AACrC;AACA;AACA,MAAM;EAEJ,OAAO;IACLC,KAAK,EAAEX,GAAI;AACf,MAAMI,MAAM,CAACE,OAAO,CAACC,GAAI;AACzB;AACA,OAAOE,MAAO;AACd;AACA;AACA;EACE,CAAC;AACH"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { useQuery, gql } from '@apollo/client';
|
|
2
|
-
import useInfoBoxData from './useInfoBox';
|
|
3
|
-
function useData({
|
|
4
|
-
id,
|
|
5
|
-
schema,
|
|
6
|
-
infoBox
|
|
7
|
-
}) {
|
|
8
|
-
const {
|
|
9
|
-
query
|
|
10
|
-
} = useInfoBoxData({
|
|
11
|
-
id,
|
|
12
|
-
schema,
|
|
13
|
-
infoBox
|
|
14
|
-
});
|
|
15
|
-
const infoBoxQuery = query || gql`
|
|
16
|
-
query {
|
|
17
|
-
__typename
|
|
18
|
-
}
|
|
19
|
-
`;
|
|
20
|
-
const {
|
|
21
|
-
data = {},
|
|
22
|
-
loading,
|
|
23
|
-
error
|
|
24
|
-
} = useQuery(infoBoxQuery, {
|
|
25
|
-
variables: {
|
|
26
|
-
id
|
|
27
|
-
},
|
|
28
|
-
skip: !query
|
|
29
|
-
});
|
|
30
|
-
return {
|
|
31
|
-
data: data.__typename !== 'Query' ? data : null,
|
|
32
|
-
loading,
|
|
33
|
-
error
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export default useData;
|
|
37
|
-
//# sourceMappingURL=useData.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useData.js","names":["useQuery","gql","useInfoBoxData","useData","id","schema","infoBox","query","infoBoxQuery","data","loading","error","variables","skip","__typename"],"sources":["../../../../src/components/InfoBoxes/hooks/useData.js"],"sourcesContent":["import { useQuery, gql } from '@apollo/client';\nimport useInfoBoxData from './useInfoBox';\n\nfunction useData({ id, schema, infoBox }) {\n const { query } = useInfoBoxData({ id, schema, infoBox });\n\n const infoBoxQuery =\n query ||\n gql`\n query {\n __typename\n }\n `;\n\n const { data = {}, loading, error } = useQuery(infoBoxQuery, { variables: { id }, skip: !query });\n\n return { data: data.__typename !== 'Query' ? data : null, loading, error };\n}\n\nexport default useData;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,GAAG,QAAQ,gBAAgB;AAC9C,OAAOC,cAAc,MAAM,cAAc;AAEzC,SAASC,OAAOA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAQ,CAAC,EAAE;EACxC,MAAM;IAAEC;EAAM,CAAC,GAAGL,cAAc,CAAC;IAAEE,EAAE;IAAEC,MAAM;IAAEC;EAAQ,CAAC,CAAC;EAEzD,MAAME,YAAY,GAChBD,KAAK,IACLN,GAAI;AACR;AACA;AACA;AACA,KAAK;EAEH,MAAM;IAAEQ,IAAI,GAAG,CAAC,CAAC;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGX,QAAQ,CAACQ,YAAY,EAAE;IAAEI,SAAS,EAAE;MAAER;IAAG,CAAC;IAAES,IAAI,EAAE,CAACN;EAAM,CAAC,CAAC;EAEjG,OAAO;IAAEE,IAAI,EAAEA,IAAI,CAACK,UAAU,KAAK,OAAO,GAAGL,IAAI,GAAG,IAAI;IAAEC,OAAO;IAAEC;EAAM,CAAC;AAC5E;AAEA,eAAeR,OAAO"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import buildDynamicQuery from '../helpers/build-dynamic-query';
|
|
2
|
-
function useInfoBox({
|
|
3
|
-
id,
|
|
4
|
-
schema,
|
|
5
|
-
infoBox
|
|
6
|
-
}) {
|
|
7
|
-
const {
|
|
8
|
-
query
|
|
9
|
-
} = buildDynamicQuery({
|
|
10
|
-
id,
|
|
11
|
-
schema,
|
|
12
|
-
infoBox
|
|
13
|
-
});
|
|
14
|
-
return {
|
|
15
|
-
query: query || null
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export default useInfoBox;
|
|
19
|
-
//# sourceMappingURL=useInfoBox.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInfoBox.js","names":["buildDynamicQuery","useInfoBox","id","schema","infoBox","query"],"sources":["../../../../src/components/InfoBoxes/hooks/useInfoBox.js"],"sourcesContent":["import buildDynamicQuery from '../helpers/build-dynamic-query';\n\nfunction useInfoBox({ id, schema, infoBox }) {\n const { query } = buildDynamicQuery({\n id,\n schema,\n infoBox\n });\n\n return { query: query || null };\n}\n\nexport default useInfoBox;\n"],"mappings":"AAAA,OAAOA,iBAAiB,MAAM,gCAAgC;AAE9D,SAASC,UAAUA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAQ,CAAC,EAAE;EAC3C,MAAM;IAAEC;EAAM,CAAC,GAAGL,iBAAiB,CAAC;IAClCE,EAAE;IACFC,MAAM;IACNC;EACF,CAAC,CAAC;EAEF,OAAO;IAAEC,KAAK,EAAEA,KAAK,IAAI;EAAK,CAAC;AACjC;AAEA,eAAeJ,UAAU"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["InfoBoxes"],"sources":["../../../src/components/InfoBoxes/index.js"],"sourcesContent":["import InfoBoxes from './InfoBoxes';\n\nexport default InfoBoxes;\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,aAAa;AAEnC,eAAeA,SAAS"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
const InfoBox = ({
|
|
4
|
-
items,
|
|
5
|
-
infoBoxKey
|
|
6
|
-
}) => {
|
|
7
|
-
if (!items) return null;
|
|
8
|
-
const infoBoxItems = items.map(item => Object.values(item).map(info => {
|
|
9
|
-
if (!info.label || !info.value) return null;
|
|
10
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
11
|
-
className: "info-box--item",
|
|
12
|
-
key: `${infoBoxKey}-${info.label.toLowerCase()}`
|
|
13
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
14
|
-
className: "info-box--label"
|
|
15
|
-
}, info.label, ": "), /*#__PURE__*/React.createElement("div", {
|
|
16
|
-
className: "info-box--value"
|
|
17
|
-
}, info.value));
|
|
18
|
-
}).filter(Boolean));
|
|
19
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
20
|
-
className: "info-box",
|
|
21
|
-
key: infoBoxKey
|
|
22
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
23
|
-
className: "info-box--container"
|
|
24
|
-
}, infoBoxItems));
|
|
25
|
-
};
|
|
26
|
-
export default InfoBox;
|
|
27
|
-
InfoBox.propTypes = {
|
|
28
|
-
infoBoxKey: PropTypes.string.isRequired,
|
|
29
|
-
items: PropTypes.array.isRequired
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=InfoBox.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InfoBox.js","names":["PropTypes","React","InfoBox","items","infoBoxKey","infoBoxItems","map","item","Object","values","info","label","value","createElement","className","key","toLowerCase","filter","Boolean","propTypes","string","isRequired","array"],"sources":["../../../../src/components/InfoBoxes/presentational/InfoBox.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nconst InfoBox = ({ items, infoBoxKey }) => {\n if (!items) return null;\n\n const infoBoxItems = items.map(item =>\n Object.values(item)\n .map(info => {\n if (!info.label || !info.value) return null;\n\n return (\n <div className=\"info-box--item\" key={`${infoBoxKey}-${info.label.toLowerCase()}`}>\n <div className=\"info-box--label\">{info.label}: </div>\n <div className=\"info-box--value\">{info.value}</div>\n </div>\n );\n })\n .filter(Boolean)\n );\n\n return (\n <div className=\"info-box\" key={infoBoxKey}>\n <div className=\"info-box--container\">{infoBoxItems}</div>\n </div>\n );\n};\n\nexport default InfoBox;\n\nInfoBox.propTypes = {\n infoBoxKey: PropTypes.string.isRequired,\n items: PropTypes.array.isRequired\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,YAAY;AAClC,OAAOC,KAAK,MAAM,OAAO;AAEzB,MAAMC,OAAO,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAW,CAAC,KAAK;EACzC,IAAI,CAACD,KAAK,EAAE,OAAO,IAAI;EAEvB,MAAME,YAAY,GAAGF,KAAK,CAACG,GAAG,CAACC,IAAI,IACjCC,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;MAAKC,SAAS,EAAC,gBAAgB;MAACC,GAAG,EAAG,GAAEX,UAAW,IAAGM,IAAI,CAACC,KAAK,CAACK,WAAW,CAAC,CAAE;IAAE,gBAC/Ef,KAAA,CAAAY,aAAA;MAAKC,SAAS,EAAC;IAAiB,GAAEJ,IAAI,CAACC,KAAK,EAAC,IAAO,CAAC,eACrDV,KAAA,CAAAY,aAAA;MAAKC,SAAS,EAAC;IAAiB,GAAEJ,IAAI,CAACE,KAAW,CAC/C,CAAC;EAEV,CAAC,CAAC,CACDK,MAAM,CAACC,OAAO,CACnB,CAAC;EAED,oBACEjB,KAAA,CAAAY,aAAA;IAAKC,SAAS,EAAC,UAAU;IAACC,GAAG,EAAEX;EAAW,gBACxCH,KAAA,CAAAY,aAAA;IAAKC,SAAS,EAAC;EAAqB,GAAET,YAAkB,CACrD,CAAC;AAEV,CAAC;AAED,eAAeH,OAAO;AAEtBA,OAAO,CAACiB,SAAS,GAAG;EAClBf,UAAU,EAAEJ,SAAS,CAACoB,MAAM,CAACC,UAAU;EACvClB,KAAK,EAAEH,SAAS,CAACsB,KAAK,CAACD;AACzB,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import InfoBoxContainer from './container/InfoBoxContainer';
|
|
4
|
-
|
|
5
|
-
const InfoBoxes = ({ id, schema }) => {
|
|
6
|
-
const {
|
|
7
|
-
displayProperties: { adminInfoBoxes = [] }
|
|
8
|
-
} = schema;
|
|
9
|
-
|
|
10
|
-
if (adminInfoBoxes.length <= 0) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return adminInfoBoxes.map(infoBox => (
|
|
15
|
-
<InfoBoxContainer id={id} schema={schema} key={infoBox.key} infoBox={infoBox} />
|
|
16
|
-
));
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default InfoBoxes;
|
|
20
|
-
|
|
21
|
-
InfoBoxes.propTypes = {
|
|
22
|
-
id: PropTypes.string.isRequired,
|
|
23
|
-
schema: PropTypes.object.isRequired
|
|
24
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import useData from '../hooks/useData';
|
|
4
|
-
import InfoBox from '../presentational/InfoBox';
|
|
5
|
-
|
|
6
|
-
const InfoBoxContainer = ({ id, schema, infoBox }) => {
|
|
7
|
-
const { data } = useData({ id, schema, infoBox });
|
|
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 <InfoBox items={items} infoBoxKey={infoBox.key} />;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default InfoBoxContainer;
|
|
17
|
-
|
|
18
|
-
InfoBoxContainer.propTypes = {
|
|
19
|
-
id: PropTypes.string.isRequired,
|
|
20
|
-
infoBox: PropTypes.object.isRequired,
|
|
21
|
-
schema: PropTypes.object.isRequired
|
|
22
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { gql } from '@apollo/client';
|
|
2
|
-
import { BlazeError } from '@blaze-cms/core-errors';
|
|
3
|
-
|
|
4
|
-
export default function buildDynamicQuery({ id, schema, infoBox }) {
|
|
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
|
-
const fields = `${infoBox.property} {
|
|
12
|
-
label
|
|
13
|
-
value
|
|
14
|
-
}`;
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
query: gql`query getInfoBoxData($id: String!){
|
|
18
|
-
${schema.actions.get}( id: $id ) {
|
|
19
|
-
id
|
|
20
|
-
${fields}
|
|
21
|
-
__typename
|
|
22
|
-
}
|
|
23
|
-
}`
|
|
24
|
-
};
|
|
25
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useQuery, gql } from '@apollo/client';
|
|
2
|
-
import useInfoBoxData from './useInfoBox';
|
|
3
|
-
|
|
4
|
-
function useData({ id, schema, infoBox }) {
|
|
5
|
-
const { query } = useInfoBoxData({ id, schema, infoBox });
|
|
6
|
-
|
|
7
|
-
const infoBoxQuery =
|
|
8
|
-
query ||
|
|
9
|
-
gql`
|
|
10
|
-
query {
|
|
11
|
-
__typename
|
|
12
|
-
}
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
|
-
const { data = {}, loading, error } = useQuery(infoBoxQuery, { variables: { id }, skip: !query });
|
|
16
|
-
|
|
17
|
-
return { data: data.__typename !== 'Query' ? data : null, loading, error };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default useData;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import buildDynamicQuery from '../helpers/build-dynamic-query';
|
|
2
|
-
|
|
3
|
-
function useInfoBox({ id, schema, infoBox }) {
|
|
4
|
-
const { query } = buildDynamicQuery({
|
|
5
|
-
id,
|
|
6
|
-
schema,
|
|
7
|
-
infoBox
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
return { query: query || null };
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default useInfoBox;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
const InfoBox = ({ items, infoBoxKey }) => {
|
|
5
|
-
if (!items) return null;
|
|
6
|
-
|
|
7
|
-
const infoBoxItems = items.map(item =>
|
|
8
|
-
Object.values(item)
|
|
9
|
-
.map(info => {
|
|
10
|
-
if (!info.label || !info.value) return null;
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<div className="info-box--item" key={`${infoBoxKey}-${info.label.toLowerCase()}`}>
|
|
14
|
-
<div className="info-box--label">{info.label}: </div>
|
|
15
|
-
<div className="info-box--value">{info.value}</div>
|
|
16
|
-
</div>
|
|
17
|
-
);
|
|
18
|
-
})
|
|
19
|
-
.filter(Boolean)
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div className="info-box" key={infoBoxKey}>
|
|
24
|
-
<div className="info-box--container">{infoBoxItems}</div>
|
|
25
|
-
</div>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default InfoBox;
|
|
30
|
-
|
|
31
|
-
InfoBox.propTypes = {
|
|
32
|
-
infoBoxKey: PropTypes.string.isRequired,
|
|
33
|
-
items: PropTypes.array.isRequired
|
|
34
|
-
};
|