@akemona-org/strapi-plugin-content-type-builder 3.7.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.
Files changed (223) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +19 -0
  3. package/admin/src/InjectedComponents/ContentManager/EditSettingViewButton.js +76 -0
  4. package/admin/src/InjectedComponents/ContentManager/EditViewLink.js +44 -0
  5. package/admin/src/assets/images/logo.svg +1 -0
  6. package/admin/src/components/AllowedTypesSelect/MenuList.js +115 -0
  7. package/admin/src/components/AllowedTypesSelect/Text.js +26 -0
  8. package/admin/src/components/AllowedTypesSelect/index.js +55 -0
  9. package/admin/src/components/AttributeOption/Button.js +50 -0
  10. package/admin/src/components/AttributeOption/Card.js +26 -0
  11. package/admin/src/components/AttributeOption/index.js +127 -0
  12. package/admin/src/components/BooleanBox/CT.js +21 -0
  13. package/admin/src/components/BooleanBox/Enumeration.js +10 -0
  14. package/admin/src/components/BooleanBox/EnumerationWrapper.js +14 -0
  15. package/admin/src/components/BooleanBox/Label.js +9 -0
  16. package/admin/src/components/BooleanBox/ST.js +21 -0
  17. package/admin/src/components/BooleanBox/Wrapper.js +75 -0
  18. package/admin/src/components/BooleanBox/icons/CTSelected.js +136 -0
  19. package/admin/src/components/BooleanBox/icons/CTUnselected.js +136 -0
  20. package/admin/src/components/BooleanBox/icons/STSelected.js +80 -0
  21. package/admin/src/components/BooleanBox/icons/STUnselected.js +76 -0
  22. package/admin/src/components/BooleanBox/index.js +103 -0
  23. package/admin/src/components/CheckboxWithDescription/Wrapper.js +12 -0
  24. package/admin/src/components/CheckboxWithDescription/index.js +40 -0
  25. package/admin/src/components/ComponentCard/Close.js +12 -0
  26. package/admin/src/components/ComponentCard/Wrapper.js +84 -0
  27. package/admin/src/components/ComponentCard/index.js +62 -0
  28. package/admin/src/components/ComponentIconPicker/Cell.js +40 -0
  29. package/admin/src/components/ComponentIconPicker/CellRenderer.js +36 -0
  30. package/admin/src/components/ComponentIconPicker/Search.js +12 -0
  31. package/admin/src/components/ComponentIconPicker/SearchWrapper.js +34 -0
  32. package/admin/src/components/ComponentIconPicker/Wrapper.js +60 -0
  33. package/admin/src/components/ComponentIconPicker/index.js +143 -0
  34. package/admin/src/components/ComponentList/index.js +78 -0
  35. package/admin/src/components/ComponentSelect/Category.js +20 -0
  36. package/admin/src/components/ComponentSelect/CategoryName.js +11 -0
  37. package/admin/src/components/ComponentSelect/MenuList.js +110 -0
  38. package/admin/src/components/ComponentSelect/MultipleMenuList.js +271 -0
  39. package/admin/src/components/ComponentSelect/Value.js +83 -0
  40. package/admin/src/components/ComponentSelect/index.js +83 -0
  41. package/admin/src/components/ComponentSelect/utils/HasSomeSubArray.js +5 -0
  42. package/admin/src/components/ComponentSelect/utils/hasSubArray.js +5 -0
  43. package/admin/src/components/CreatableSelect/index.js +58 -0
  44. package/admin/src/components/CustomCheckbox/StyledCustomCheckbox.js +25 -0
  45. package/admin/src/components/CustomCheckbox/index.js +71 -0
  46. package/admin/src/components/CustomLink/P.js +17 -0
  47. package/admin/src/components/CustomLink/StyledCustomLink.js +20 -0
  48. package/admin/src/components/CustomLink/index.js +31 -0
  49. package/admin/src/components/DynamicZoneList/ComponentButton.js +39 -0
  50. package/admin/src/components/DynamicZoneList/index.js +124 -0
  51. package/admin/src/components/HeaderModalNavContainer/index.js +25 -0
  52. package/admin/src/components/HeaderNavLink/Wrapper.js +21 -0
  53. package/admin/src/components/HeaderNavLink/index.js +50 -0
  54. package/admin/src/components/List/List.js +131 -0
  55. package/admin/src/components/List/index.js +295 -0
  56. package/admin/src/components/ListButton/index.js +9 -0
  57. package/admin/src/components/ListHeader/Title.js +19 -0
  58. package/admin/src/components/ListHeader/Wrapper.js +24 -0
  59. package/admin/src/components/ListHeader/index.js +37 -0
  60. package/admin/src/components/ListRow/Wrapper.js +76 -0
  61. package/admin/src/components/ListRow/index.js +334 -0
  62. package/admin/src/components/ModalHeader/ComponentIcon.js +21 -0
  63. package/admin/src/components/ModalHeader/ComponentInfos.js +22 -0
  64. package/admin/src/components/ModalHeader/ComponentInfosWrapper.js +9 -0
  65. package/admin/src/components/ModalHeader/DropdownInfos.js +50 -0
  66. package/admin/src/components/ModalHeader/Icon.js +26 -0
  67. package/admin/src/components/ModalHeader/IconWrapper.js +11 -0
  68. package/admin/src/components/ModalHeader/Item.js +19 -0
  69. package/admin/src/components/ModalHeader/Menu.js +8 -0
  70. package/admin/src/components/ModalHeader/Toggle.js +14 -0
  71. package/admin/src/components/ModalHeader/Wrapper.js +12 -0
  72. package/admin/src/components/ModalHeader/index.js +105 -0
  73. package/admin/src/components/RelationForm/Wrapper.js +9 -0
  74. package/admin/src/components/RelationForm/index.js +66 -0
  75. package/admin/src/components/RelationFormBox/Wrapper.js +34 -0
  76. package/admin/src/components/RelationFormBox/index.js +85 -0
  77. package/admin/src/components/RelationFormNaturePicker/Wrapper.js +53 -0
  78. package/admin/src/components/RelationFormNaturePicker/index.js +112 -0
  79. package/admin/src/components/RelationTargetPicker/Item.js +62 -0
  80. package/admin/src/components/RelationTargetPicker/Wrapper.js +89 -0
  81. package/admin/src/components/RelationTargetPicker/index.js +88 -0
  82. package/admin/src/components/SelectCheckbox/index.js +8 -0
  83. package/admin/src/components/SelectMenuSubUl/ToggleUl.js +23 -0
  84. package/admin/src/components/SelectMenuSubUl/index.js +23 -0
  85. package/admin/src/components/SelectMenuUl/index.js +66 -0
  86. package/admin/src/components/Td/index.js +37 -0
  87. package/admin/src/components/UpperFirst/index.js +14 -0
  88. package/admin/src/components/WrapperSelect/index.js +89 -0
  89. package/admin/src/containers/App/Wrapper.js +14 -0
  90. package/admin/src/containers/App/index.js +39 -0
  91. package/admin/src/containers/App/utils/icons.json +962 -0
  92. package/admin/src/containers/DataManagerProvider/constants.js +15 -0
  93. package/admin/src/containers/DataManagerProvider/index.js +610 -0
  94. package/admin/src/containers/DataManagerProvider/reducer.js +461 -0
  95. package/admin/src/containers/DataManagerProvider/selectors.js +25 -0
  96. package/admin/src/containers/DataManagerProvider/utils/cleanData.js +167 -0
  97. package/admin/src/containers/DataManagerProvider/utils/createDataObject.js +8 -0
  98. package/admin/src/containers/DataManagerProvider/utils/createModifiedDataSchema.js +91 -0
  99. package/admin/src/containers/DataManagerProvider/utils/retrieveComponentsFromSchema.js +55 -0
  100. package/admin/src/containers/DataManagerProvider/utils/retrieveComponentsThatHaveComponents.js +35 -0
  101. package/admin/src/containers/DataManagerProvider/utils/retrieveNestedComponents.js +34 -0
  102. package/admin/src/containers/DataManagerProvider/utils/retrieveSpecificInfoFromComponents.js +12 -0
  103. package/admin/src/containers/FormModal/CustomButton.js +12 -0
  104. package/admin/src/containers/FormModal/attributes/advancedForm.js +269 -0
  105. package/admin/src/containers/FormModal/attributes/attributeOptions.js +99 -0
  106. package/admin/src/containers/FormModal/attributes/baseForm.js +322 -0
  107. package/admin/src/containers/FormModal/attributes/commonBaseForm.js +7 -0
  108. package/admin/src/containers/FormModal/attributes/form.js +9 -0
  109. package/admin/src/containers/FormModal/attributes/index.js +4 -0
  110. package/admin/src/containers/FormModal/attributes/nameField.js +19 -0
  111. package/admin/src/containers/FormModal/attributes/types.js +309 -0
  112. package/admin/src/containers/FormModal/attributes/uiHelpers.js +11 -0
  113. package/admin/src/containers/FormModal/attributes/validation/common.js +151 -0
  114. package/admin/src/containers/FormModal/category/createCategorySchema.js +28 -0
  115. package/admin/src/containers/FormModal/category/form.js +27 -0
  116. package/admin/src/containers/FormModal/category/index.js +3 -0
  117. package/admin/src/containers/FormModal/category/regex.js +3 -0
  118. package/admin/src/containers/FormModal/component/componentField.js +25 -0
  119. package/admin/src/containers/FormModal/component/createComponentSchema.js +49 -0
  120. package/admin/src/containers/FormModal/component/form.js +67 -0
  121. package/admin/src/containers/FormModal/component/index.js +4 -0
  122. package/admin/src/containers/FormModal/constants.js +11 -0
  123. package/admin/src/containers/FormModal/contentType/createContentTypeSchema.js +44 -0
  124. package/admin/src/containers/FormModal/contentType/form.js +116 -0
  125. package/admin/src/containers/FormModal/contentType/index.js +2 -0
  126. package/admin/src/containers/FormModal/dynamicZone/form.js +45 -0
  127. package/admin/src/containers/FormModal/dynamicZone/index.js +2 -0
  128. package/admin/src/containers/FormModal/forms/index.js +164 -0
  129. package/admin/src/containers/FormModal/index.js +1552 -0
  130. package/admin/src/containers/FormModal/reducer.js +293 -0
  131. package/admin/src/containers/FormModal/selectors.js +24 -0
  132. package/admin/src/containers/FormModal/utils/canEditContentType.js +19 -0
  133. package/admin/src/containers/FormModal/utils/createHeadersArray.js +37 -0
  134. package/admin/src/containers/FormModal/utils/createHeadersObjectFromArray.js +27 -0
  135. package/admin/src/containers/FormModal/utils/createUid.js +17 -0
  136. package/admin/src/containers/FormModal/utils/getAttributesToDisplay.js +35 -0
  137. package/admin/src/containers/FormModal/utils/getModalTitleSubHeader.js +25 -0
  138. package/admin/src/containers/FormModal/utils/getNextSearch.js +17 -0
  139. package/admin/src/containers/FormModal/utils/index.js +6 -0
  140. package/admin/src/containers/FormModal/utils/relations.js +9 -0
  141. package/admin/src/containers/FormModal/utils/staticData.js +43 -0
  142. package/admin/src/containers/Initializer/index.js +26 -0
  143. package/admin/src/containers/LeftMenu/Wrapper.js +14 -0
  144. package/admin/src/containers/LeftMenu/index.js +220 -0
  145. package/admin/src/containers/ListView/Wrapper.js +16 -0
  146. package/admin/src/containers/ListView/index.js +322 -0
  147. package/admin/src/containers/NotFoundPage/index.js +20 -0
  148. package/admin/src/containers/RecursivePath/index.js +22 -0
  149. package/admin/src/contexts/DataManagerContext.js +5 -0
  150. package/admin/src/contexts/ListViewContext.js +5 -0
  151. package/admin/src/hooks/useDataManager.js +6 -0
  152. package/admin/src/hooks/useListView.js +6 -0
  153. package/admin/src/icons/Curve.js +26 -0
  154. package/admin/src/icons/ManyToMany.js +98 -0
  155. package/admin/src/icons/ManyToOne.js +64 -0
  156. package/admin/src/icons/ManyWay.js +36 -0
  157. package/admin/src/icons/OneToMany.js +65 -0
  158. package/admin/src/icons/OneToOne.js +47 -0
  159. package/admin/src/icons/OneWay.js +38 -0
  160. package/admin/src/index.js +83 -0
  161. package/admin/src/lifecycles.js +13 -0
  162. package/admin/src/permissions.js +9 -0
  163. package/admin/src/pluginId.js +5 -0
  164. package/admin/src/reducers.js +10 -0
  165. package/admin/src/translations/ar.json +48 -0
  166. package/admin/src/translations/cs.json +151 -0
  167. package/admin/src/translations/de.json +187 -0
  168. package/admin/src/translations/dk.json +181 -0
  169. package/admin/src/translations/en.json +188 -0
  170. package/admin/src/translations/es.json +188 -0
  171. package/admin/src/translations/fr.json +87 -0
  172. package/admin/src/translations/id.json +187 -0
  173. package/admin/src/translations/index.js +51 -0
  174. package/admin/src/translations/it.json +187 -0
  175. package/admin/src/translations/ja.json +50 -0
  176. package/admin/src/translations/ko.json +57 -0
  177. package/admin/src/translations/ms.json +179 -0
  178. package/admin/src/translations/nl.json +171 -0
  179. package/admin/src/translations/pl.json +152 -0
  180. package/admin/src/translations/pt-BR.json +51 -0
  181. package/admin/src/translations/pt.json +51 -0
  182. package/admin/src/translations/ru.json +188 -0
  183. package/admin/src/translations/sk.json +186 -0
  184. package/admin/src/translations/th.json +181 -0
  185. package/admin/src/translations/tr.json +51 -0
  186. package/admin/src/translations/uk.json +180 -0
  187. package/admin/src/translations/zh-Hans.json +188 -0
  188. package/admin/src/translations/zh.json +178 -0
  189. package/admin/src/utils/convertAttrObjToArray.js +7 -0
  190. package/admin/src/utils/formAPI.js +112 -0
  191. package/admin/src/utils/getAttributeDisplayedType.js +31 -0
  192. package/admin/src/utils/getComponents.js +31 -0
  193. package/admin/src/utils/getTrad.js +5 -0
  194. package/admin/src/utils/makeSearch.js +15 -0
  195. package/admin/src/utils/makeUnique.js +3 -0
  196. package/config/functions/bootstrap.js +14 -0
  197. package/config/routes.json +144 -0
  198. package/controllers/Builder.js +7 -0
  199. package/controllers/ComponentCategories.js +43 -0
  200. package/controllers/Components.js +152 -0
  201. package/controllers/Connections.js +9 -0
  202. package/controllers/ContentTypes.js +143 -0
  203. package/controllers/validation/common.js +118 -0
  204. package/controllers/validation/component-category.js +21 -0
  205. package/controllers/validation/component.js +89 -0
  206. package/controllers/validation/content-type.js +161 -0
  207. package/controllers/validation/data-transform.js +32 -0
  208. package/controllers/validation/model-schema.js +91 -0
  209. package/controllers/validation/relations.js +56 -0
  210. package/controllers/validation/types.js +277 -0
  211. package/package.json +63 -0
  212. package/services/Builder.js +7 -0
  213. package/services/ComponentCategories.js +88 -0
  214. package/services/Components.js +103 -0
  215. package/services/ContentTypes.js +263 -0
  216. package/services/api-handler.js +158 -0
  217. package/services/constants.js +59 -0
  218. package/services/schema-builder/component-builder.js +137 -0
  219. package/services/schema-builder/content-type-builder.js +256 -0
  220. package/services/schema-builder/index.js +196 -0
  221. package/services/schema-builder/schema-handler.js +297 -0
  222. package/utils/attributes.js +154 -0
  223. package/utils/helpers.js +31 -0
@@ -0,0 +1,91 @@
1
+ import { fromJS, OrderedMap } from 'immutable';
2
+ import { get } from 'lodash';
3
+
4
+ const createModifiedDataSchema = (
5
+ contentTypeSchema,
6
+ retrievedComponents,
7
+ allComponentsSchema,
8
+ isInContentTypeView
9
+ ) => {
10
+ const componentsAssociatedToContentType = retrievedComponents.reduce(
11
+ (acc, current) => {
12
+ const componentSchema = get(allComponentsSchema, current, {});
13
+
14
+ acc[current] = componentSchema;
15
+
16
+ return acc;
17
+ },
18
+ {}
19
+ );
20
+ const keyName = isInContentTypeView ? 'contentType' : 'component';
21
+ const schema = {
22
+ [keyName]: contentTypeSchema,
23
+ components: componentsAssociatedToContentType,
24
+ };
25
+
26
+ return schema;
27
+ };
28
+
29
+ const orderAllDataAttributesWithImmutable = (
30
+ allDataSchema,
31
+ isInContentTypeView
32
+ ) => {
33
+ const attributesPath = ['schema', 'attributes'];
34
+ const componentsSchema = allDataSchema.components;
35
+ const componentsWithImmutableSchema = Object.keys(componentsSchema).reduce(
36
+ (acc, current) => {
37
+ const currentSchema = get(componentsSchema, [current], {});
38
+
39
+ const currentAttributes = get(currentSchema, attributesPath, {});
40
+
41
+ const fromJSAttributes = Object.keys(currentAttributes).reduce(
42
+ (acc, current) => {
43
+ acc[current] = fromJS(currentAttributes[current]);
44
+
45
+ return acc;
46
+ },
47
+ {}
48
+ );
49
+
50
+ // TODO refacto
51
+ const currentImmutableSchemas = fromJS(currentSchema).setIn(
52
+ ['schema', 'attributes'],
53
+ fromJS(OrderedMap(fromJSAttributes))
54
+ );
55
+
56
+ acc[current] = fromJS(currentImmutableSchemas);
57
+
58
+ return acc;
59
+ },
60
+ {}
61
+ );
62
+ const keyName = isInContentTypeView ? 'contentType' : 'component';
63
+ const mainSchema = get(allDataSchema, [keyName], {});
64
+ const mainImmutableSchema = fromJS(mainSchema).setIn(
65
+ attributesPath,
66
+ fromJS(
67
+ OrderedMap(
68
+ Object.keys(get(mainSchema, attributesPath, {})).reduce(
69
+ (acc, current) => {
70
+ acc[current] = fromJS(
71
+ get(mainSchema, [...attributesPath, current], {})
72
+ );
73
+
74
+ return acc;
75
+ },
76
+ {}
77
+ )
78
+ )
79
+ )
80
+ );
81
+
82
+ const immutableData = fromJS({
83
+ components: componentsWithImmutableSchema,
84
+ [keyName]: mainImmutableSchema,
85
+ });
86
+
87
+ return immutableData;
88
+ };
89
+
90
+ export default createModifiedDataSchema;
91
+ export { orderAllDataAttributesWithImmutable };
@@ -0,0 +1,55 @@
1
+ import { get } from 'lodash';
2
+ import makeUnique from '../../../utils/makeUnique';
3
+
4
+ const retrieveComponentsFromSchema = (attributes, allComponentsData) => {
5
+ const allComponents = Object.keys(attributes).reduce((acc, current) => {
6
+ const type = get(attributes, [current, 'type'], '');
7
+
8
+ if (type === 'component') {
9
+ const currentComponentName = attributes[current].component;
10
+ // Push the existing compo
11
+ acc.push(currentComponentName);
12
+
13
+ const currentComponentAttributes = get(
14
+ allComponentsData,
15
+ [currentComponentName, 'schema', 'attributes'],
16
+ {}
17
+ );
18
+
19
+ // Retrieve the nested ones
20
+ acc.push(
21
+ ...retrieveComponentsFromSchema(
22
+ currentComponentAttributes,
23
+ allComponentsData
24
+ )
25
+ );
26
+ }
27
+
28
+ if (type === 'dynamiczone') {
29
+ const dynamicZoneComponents = attributes[current].components;
30
+ const componentsFromDZComponents = dynamicZoneComponents.reduce(
31
+ (acc2, currentUid) => {
32
+ const compoAttrs = get(
33
+ allComponentsData,
34
+ [currentUid, 'schema', 'attributes'],
35
+ {}
36
+ );
37
+
38
+ return [
39
+ ...acc2,
40
+ ...retrieveComponentsFromSchema(compoAttrs, allComponentsData),
41
+ ];
42
+ },
43
+ []
44
+ );
45
+
46
+ return [...acc, ...dynamicZoneComponents, ...componentsFromDZComponents];
47
+ }
48
+
49
+ return acc;
50
+ }, []);
51
+
52
+ return makeUnique(allComponents);
53
+ };
54
+
55
+ export default retrieveComponentsFromSchema;
@@ -0,0 +1,35 @@
1
+ import { get } from 'lodash';
2
+ import makeUnique from '../../../utils/makeUnique';
3
+
4
+ const retrieveComponentsThatHaveComponents = allComponents => {
5
+ const componentsThatHaveNestedComponents = Object.keys(allComponents).reduce(
6
+ (acc, current) => {
7
+ const currentComponent = get(allComponents, [current], {});
8
+ const uid = currentComponent.uid;
9
+
10
+ if (doesComponentHaveAComponentField(currentComponent)) {
11
+ acc.push(uid);
12
+ }
13
+
14
+ return acc;
15
+ },
16
+ []
17
+ );
18
+
19
+ return makeUnique(componentsThatHaveNestedComponents);
20
+ };
21
+
22
+ const doesComponentHaveAComponentField = component => {
23
+ const attributes = get(component, ['schema', 'attributes'], {});
24
+
25
+ return Object.keys(attributes).some(attributeName => {
26
+ const type = get(attributes, [attributeName, 'type'], '');
27
+
28
+ return type === 'component';
29
+ });
30
+ };
31
+
32
+ export {
33
+ doesComponentHaveAComponentField,
34
+ retrieveComponentsThatHaveComponents,
35
+ };
@@ -0,0 +1,34 @@
1
+ import { get } from 'lodash';
2
+ import makeUnique from '../../../utils/makeUnique';
3
+
4
+ const retrieveNestedComponents = appComponents => {
5
+ const nestedComponents = Object.keys(appComponents).reduce((acc, current) => {
6
+ const componentAttributes = get(
7
+ appComponents,
8
+ [current, 'schema', 'attributes'],
9
+ {}
10
+ );
11
+ const currentComponentNestedCompos = getComponentsFromComponent(
12
+ componentAttributes
13
+ );
14
+
15
+ return [...acc, ...currentComponentNestedCompos];
16
+ }, []);
17
+
18
+ return makeUnique(nestedComponents);
19
+ };
20
+
21
+ const getComponentsFromComponent = componentAttributes => {
22
+ return Object.keys(componentAttributes).reduce((acc, current) => {
23
+ const attribute = get(componentAttributes, current, {});
24
+ const { type, component } = attribute;
25
+
26
+ if (type === 'component') {
27
+ acc.push(component);
28
+ }
29
+
30
+ return acc;
31
+ }, []);
32
+ };
33
+
34
+ export default retrieveNestedComponents;
@@ -0,0 +1,12 @@
1
+ import { get } from 'lodash';
2
+ import makeUnique from '../../../utils/makeUnique';
3
+
4
+ const retrieveSpecificInfoFromComponents = (allComponents, keysToRetrieve) => {
5
+ const allData = Object.keys(allComponents).map(compo => {
6
+ return get(allComponents, [compo, ...keysToRetrieve], '');
7
+ });
8
+
9
+ return makeUnique(allData);
10
+ };
11
+
12
+ export default retrieveSpecificInfoFromComponents;
@@ -0,0 +1,12 @@
1
+ import styled from 'styled-components';
2
+ import { Button } from '@buffetjs/core';
3
+
4
+ const CustomButton = styled(Button)`
5
+ svg {
6
+ height: 11px;
7
+ width: 11px;
8
+ vertical-align: initial;
9
+ }
10
+ `;
11
+
12
+ export default CustomButton;
@@ -0,0 +1,269 @@
1
+ import React from 'react';
2
+ import { FormattedMessage } from 'react-intl';
3
+ import { get, isEmpty } from 'lodash';
4
+ import getTrad from '../../../utils/getTrad';
5
+ import { componentForm } from '../component';
6
+ import options from './attributeOptions';
7
+ import uiHelpers from './uiHelpers';
8
+
9
+ const advancedForm = {
10
+ boolean: () => {
11
+ return {
12
+ items: [
13
+ [
14
+ {
15
+ autoFocus: true,
16
+ type: 'enum',
17
+ label: {
18
+ id: getTrad('form.attribute.settings.default'),
19
+ },
20
+ name: 'default',
21
+ options: [
22
+ { value: 'true', label: 'TRUE' },
23
+ { value: '', label: 'NULL' },
24
+ { value: 'false', label: 'FALSE' },
25
+ ],
26
+ validations: {},
27
+ },
28
+ ],
29
+ [uiHelpers.divider],
30
+ [options.required, options.unique],
31
+ [options.private],
32
+ ],
33
+ };
34
+ },
35
+ component: ({ repeatable }, step) => {
36
+ if (step === '1') {
37
+ return { items: componentForm.advanced('componentToCreate') };
38
+ }
39
+
40
+ if (repeatable) {
41
+ return { items: [[options.required], [uiHelpers.divider], [options.max, options.min]] };
42
+ }
43
+
44
+ return {
45
+ items: [[options.required]],
46
+ };
47
+ },
48
+ date: ({ type }) => {
49
+ return {
50
+ items: [
51
+ [
52
+ {
53
+ ...options.default,
54
+ type: type || 'date',
55
+ value: null,
56
+ withDefaultValue: false,
57
+ disabled: !type,
58
+ autoFocus: false,
59
+ },
60
+ ],
61
+ [uiHelpers.divider],
62
+ [options.required, options.unique],
63
+ [options.private],
64
+ ],
65
+ };
66
+ },
67
+ dynamiczone: () => {
68
+ return {
69
+ items: [[options.required], [uiHelpers.divider], [options.max, options.min]],
70
+ };
71
+ },
72
+ email: () => {
73
+ return {
74
+ items: [
75
+ [
76
+ {
77
+ ...options.default,
78
+ type: 'email',
79
+ },
80
+ ],
81
+ [uiHelpers.divider],
82
+ [options.required, options.unique],
83
+ [options.maxLength, options.minLength],
84
+ [options.private],
85
+ ],
86
+ };
87
+ },
88
+ enumeration: data => {
89
+ return {
90
+ items: [
91
+ [
92
+ {
93
+ autoFocus: false,
94
+ name: 'default',
95
+ type: 'select',
96
+ label: {
97
+ id: getTrad('form.attribute.settings.default'),
98
+ },
99
+ validations: {},
100
+ options: [
101
+ <FormattedMessage
102
+ key="hidden___value__placeholder"
103
+ id="components.InputSelect.option.placeholder"
104
+ >
105
+ {msg => <option value="">{msg}</option>}
106
+ </FormattedMessage>,
107
+ ].concat(
108
+ data.enum
109
+ ? data.enum
110
+ .filter((val, index) => data.enum.indexOf(val) === index && !isEmpty(val))
111
+ .map(val => (
112
+ <option key={val} value={val}>
113
+ {val}
114
+ </option>
115
+ ))
116
+ : []
117
+ ),
118
+ },
119
+ {
120
+ label: {
121
+ id: getTrad('form.attribute.item.enumeration.graphql'),
122
+ },
123
+ name: 'enumName',
124
+ type: 'text',
125
+ validations: {},
126
+ description: {
127
+ id: getTrad('form.attribute.item.enumeration.graphql.description'),
128
+ },
129
+ },
130
+ ],
131
+ [uiHelpers.divider],
132
+ [options.required, options.unique],
133
+ [options.private],
134
+ ],
135
+ };
136
+ },
137
+ json: () => {
138
+ return {
139
+ items: [[uiHelpers.divider], [options.required, options.unique], [options.private]],
140
+ };
141
+ },
142
+ media: () => {
143
+ return {
144
+ items: [
145
+ [uiHelpers.divider],
146
+ [options.required, options.unique],
147
+ [
148
+ {
149
+ label: {
150
+ id: getTrad('form.attribute.media.allowed-types'),
151
+ },
152
+ name: 'allowedTypes',
153
+ type: 'allowedTypesSelect',
154
+ value: '',
155
+ validations: {},
156
+ },
157
+ ],
158
+ [options.private],
159
+ ],
160
+ };
161
+ },
162
+ number: data => {
163
+ const inputStep = data.type === 'decimal' || data.type === 'float' ? 'any' : '1';
164
+
165
+ return {
166
+ items: [
167
+ [
168
+ {
169
+ autoFocus: true,
170
+ name: 'default',
171
+ type: data.type === 'biginteger' ? 'text' : 'number',
172
+ step: inputStep,
173
+ label: {
174
+ id: getTrad('form.attribute.settings.default'),
175
+ },
176
+ validations: {},
177
+ },
178
+ ],
179
+ [uiHelpers.divider],
180
+ [options.required, options.unique],
181
+ [options.max, options.min],
182
+ [options.private],
183
+ ],
184
+ };
185
+ },
186
+ password: () => {
187
+ return {
188
+ items: [
189
+ [options.default],
190
+ [uiHelpers.divider],
191
+ [options.required, options.unique],
192
+ [options.maxLength, options.minLength],
193
+ [options.private],
194
+ ],
195
+ };
196
+ },
197
+ relation: data => {
198
+ const targetAttributeValue = get(data, 'targetAttribute', null);
199
+ const nameValue = get(data, 'name', null);
200
+
201
+ return {
202
+ items: [
203
+ [uiHelpers.divider],
204
+ [options.private],
205
+ [options.unique],
206
+ [
207
+ {
208
+ autoFocus: false,
209
+ disabled: nameValue === null,
210
+ name: 'columnName',
211
+ type: 'addon',
212
+ addon: nameValue,
213
+ label: {
214
+ id: getTrad('form.attribute.item.customColumnName'),
215
+ },
216
+ inputDescription: {
217
+ id: getTrad('form.attribute.item.customColumnName.description'),
218
+ },
219
+ validations: {},
220
+ },
221
+ {
222
+ autoFocus: false,
223
+ disabled: targetAttributeValue === null || targetAttributeValue === '-',
224
+ name: 'targetColumnName',
225
+ label: '',
226
+ type: 'addon',
227
+ addon: targetAttributeValue,
228
+ validations: {},
229
+ },
230
+ ],
231
+ ],
232
+ };
233
+ },
234
+ richtext: () => {
235
+ return {
236
+ items: [
237
+ [options.default],
238
+ [uiHelpers.divider],
239
+ [options.required, options.unique],
240
+ [options.maxLength, options.minLength],
241
+ [options.private],
242
+ ],
243
+ };
244
+ },
245
+ text: () => {
246
+ return {
247
+ items: [
248
+ [options.default, options.regex],
249
+ [uiHelpers.divider],
250
+ [options.required, options.unique],
251
+ [options.maxLength, options.minLength],
252
+ [options.private],
253
+ ],
254
+ };
255
+ },
256
+ uid: data => {
257
+ return {
258
+ items: [
259
+ [{ ...options.default, disabled: Boolean(data.targetField), type: 'text' }],
260
+ [uiHelpers.divider],
261
+ [options.required],
262
+ [options.maxLength, options.minLength],
263
+ [options.private],
264
+ ],
265
+ };
266
+ },
267
+ };
268
+
269
+ export default advancedForm;
@@ -0,0 +1,99 @@
1
+ import getTrad from '../../../utils/getTrad';
2
+
3
+ const attributeOptions = {
4
+ default: {
5
+ autoFocus: true,
6
+ name: 'default',
7
+ type: 'text',
8
+ label: {
9
+ id: getTrad('form.attribute.settings.default'),
10
+ },
11
+ validations: {},
12
+ },
13
+ max: {
14
+ autoFocus: false,
15
+ name: 'max',
16
+ type: 'customCheckboxWithChildren',
17
+ label: {
18
+ id: getTrad('form.attribute.item.maximum'),
19
+ },
20
+ validations: {},
21
+ },
22
+ maxLength: {
23
+ autoFocus: false,
24
+ name: 'maxLength',
25
+ type: 'customCheckboxWithChildren',
26
+ label: {
27
+ id: getTrad('form.attribute.item.maximumLength'),
28
+ },
29
+ validations: {},
30
+ },
31
+ min: {
32
+ autoFocus: false,
33
+ name: 'min',
34
+ type: 'customCheckboxWithChildren',
35
+ label: {
36
+ id: getTrad('form.attribute.item.minimum'),
37
+ },
38
+ validations: {},
39
+ },
40
+ minLength: {
41
+ autoFocus: false,
42
+ name: 'minLength',
43
+ type: 'customCheckboxWithChildren',
44
+ label: {
45
+ id: getTrad('form.attribute.item.minimumLength'),
46
+ },
47
+ validations: {},
48
+ },
49
+ private: {
50
+ autoFocus: false,
51
+ name: 'private',
52
+ type: 'checkbox',
53
+ label: {
54
+ id: getTrad('form.attribute.item.privateField'),
55
+ },
56
+ description: {
57
+ id: getTrad('form.attribute.item.privateField.description'),
58
+ },
59
+ validations: {},
60
+ },
61
+ regex: {
62
+ autoFocus: false,
63
+ label: {
64
+ id: getTrad('form.attribute.item.text.regex'),
65
+ },
66
+ name: 'regex',
67
+ type: 'text',
68
+ validations: {},
69
+ description: {
70
+ id: getTrad('form.attribute.item.text.regex.description'),
71
+ },
72
+ },
73
+ required: {
74
+ autoFocus: false,
75
+ name: 'required',
76
+ type: 'checkbox',
77
+ label: {
78
+ id: getTrad('form.attribute.item.requiredField'),
79
+ },
80
+ description: {
81
+ id: getTrad('form.attribute.item.requiredField.description'),
82
+ },
83
+ validations: {},
84
+ },
85
+ unique: {
86
+ autoFocus: false,
87
+ name: 'unique',
88
+ type: 'checkbox',
89
+ label: {
90
+ id: getTrad('form.attribute.item.uniqueField'),
91
+ },
92
+ description: {
93
+ id: getTrad('form.attribute.item.uniqueField.description'),
94
+ },
95
+ validations: {},
96
+ },
97
+ };
98
+
99
+ export default attributeOptions;