@akemona-org/strapi-plugin-content-manager 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.
- package/LICENSE +22 -0
- package/README.md +27 -0
- package/admin/src/InjectedComponents/ContentTypeBuilder/ConfigureViewButton/index.js +78 -0
- package/admin/src/assets/images/background_input.svg +1 -0
- package/admin/src/assets/images/icon-cross-blue.svg +1 -0
- package/admin/src/assets/images/icon_remove.svg +19 -0
- package/admin/src/assets/images/logo.svg +1 -0
- package/admin/src/components/AddDropdown/components.js +113 -0
- package/admin/src/components/AddDropdown/index.js +76 -0
- package/admin/src/components/Block/components.js +28 -0
- package/admin/src/components/Block/index.js +45 -0
- package/admin/src/components/ComponentInitializer/P.js +9 -0
- package/admin/src/components/ComponentInitializer/index.js +43 -0
- package/admin/src/components/Container/index.js +7 -0
- package/admin/src/components/CustomInputCheckbox/components.js +77 -0
- package/admin/src/components/CustomInputCheckbox/index.js +53 -0
- package/admin/src/components/CustomTable/ActionCollapse/Delete.js +14 -0
- package/admin/src/components/CustomTable/ActionCollapse/DeleteAll.js +18 -0
- package/admin/src/components/CustomTable/ActionCollapse/Wrapper.js +20 -0
- package/admin/src/components/CustomTable/ActionCollapse/index.js +38 -0
- package/admin/src/components/CustomTable/Headers/Header.js +59 -0
- package/admin/src/components/CustomTable/Headers/Thead.js +35 -0
- package/admin/src/components/CustomTable/Headers/index.js +46 -0
- package/admin/src/components/CustomTable/Row/ActionContainer.js +19 -0
- package/admin/src/components/CustomTable/Row/Cell.js +55 -0
- package/admin/src/components/CustomTable/Row/index.js +112 -0
- package/admin/src/components/CustomTable/index.js +162 -0
- package/admin/src/components/CustomTable/styledComponents.js +85 -0
- package/admin/src/components/DragLayer/index.js +102 -0
- package/admin/src/components/DraggedField/Close/index.js +10 -0
- package/admin/src/components/DraggedField/GrabWrapper.js +38 -0
- package/admin/src/components/DraggedField/Link.js +17 -0
- package/admin/src/components/DraggedField/NameWrapper.js +29 -0
- package/admin/src/components/DraggedField/RemoveWrapper.js +32 -0
- package/admin/src/components/DraggedField/SubWrapper.js +36 -0
- package/admin/src/components/DraggedField/Wrapper.js +134 -0
- package/admin/src/components/DraggedField/index.js +196 -0
- package/admin/src/components/DraggedField/utils/getColor.js +12 -0
- package/admin/src/components/DraggedField/utils/getHeight.js +3 -0
- package/admin/src/components/DraggedFieldWithPreview/Carret.js +24 -0
- package/admin/src/components/DraggedFieldWithPreview/DynamicComponent.js +70 -0
- package/admin/src/components/DraggedFieldWithPreview/DynamicZoneWrapper.js +10 -0
- package/admin/src/components/DraggedFieldWithPreview/Tooltip.js +19 -0
- package/admin/src/components/DraggedFieldWithPreview/Wrapper.js +24 -0
- package/admin/src/components/DraggedFieldWithPreview/index.js +194 -0
- package/admin/src/components/DynamicComponentCard/Wrapper.js +63 -0
- package/admin/src/components/DynamicComponentCard/index.js +49 -0
- package/admin/src/components/DynamicZone/BaselineAlignement.js +11 -0
- package/admin/src/components/DynamicZone/Button.js +31 -0
- package/admin/src/components/DynamicZone/Component/RoundCTA.js +45 -0
- package/admin/src/components/DynamicZone/Component/index.js +79 -0
- package/admin/src/components/DynamicZone/ComponentWrapper.js +44 -0
- package/admin/src/components/DynamicZone/DynamicZoneWrapper.js +12 -0
- package/admin/src/components/DynamicZone/Label.js +42 -0
- package/admin/src/components/DynamicZone/Picker/Category/Banner/Wrapper.js +78 -0
- package/admin/src/components/DynamicZone/Picker/Category/Banner/index.js +33 -0
- package/admin/src/components/DynamicZone/Picker/Category/index.js +53 -0
- package/admin/src/components/DynamicZone/Picker/Wrapper.js +32 -0
- package/admin/src/components/DynamicZone/Picker/index.js +88 -0
- package/admin/src/components/DynamicZone/Wrapper.js +34 -0
- package/admin/src/components/DynamicZone/index.js +238 -0
- package/admin/src/components/DynamicZone/utils/connect.js +12 -0
- package/admin/src/components/DynamicZone/utils/select.js +49 -0
- package/admin/src/components/FieldComponent/ComponentIcon.js +44 -0
- package/admin/src/components/FieldComponent/EmptyComponent.js +19 -0
- package/admin/src/components/FieldComponent/Label.js +10 -0
- package/admin/src/components/FieldComponent/ResetComponent.js +41 -0
- package/admin/src/components/FieldComponent/Wrapper.js +18 -0
- package/admin/src/components/FieldComponent/index.js +171 -0
- package/admin/src/components/FieldComponent/utils/connect.js +12 -0
- package/admin/src/components/FieldComponent/utils/select.js +123 -0
- package/admin/src/components/FieldsReorder/Item.js +249 -0
- package/admin/src/components/FieldsReorder/components.js +8 -0
- package/admin/src/components/FieldsReorder/index.js +102 -0
- package/admin/src/components/FilterOptionsCTA/index.js +14 -0
- package/admin/src/components/FilterPicker/components.js +56 -0
- package/admin/src/components/FilterPicker/index.js +258 -0
- package/admin/src/components/FilterPicker/init.js +25 -0
- package/admin/src/components/FilterPicker/reducer.js +58 -0
- package/admin/src/components/FilterPickerOption/Input.js +58 -0
- package/admin/src/components/FilterPickerOption/Option.js +18 -0
- package/admin/src/components/FilterPickerOption/components.js +60 -0
- package/admin/src/components/FilterPickerOption/index.js +101 -0
- package/admin/src/components/FormTitle/index.js +26 -0
- package/admin/src/components/FormWrapper/index.js +20 -0
- package/admin/src/components/InputJSON/components.js +30 -0
- package/admin/src/components/InputJSON/index.js +184 -0
- package/admin/src/components/InputJSON/jsonlint.js +424 -0
- package/admin/src/components/InputJSONWithErrors/Wrapper.js +32 -0
- package/admin/src/components/InputJSONWithErrors/index.js +168 -0
- package/admin/src/components/InputUID/InputUID.js +26 -0
- package/admin/src/components/InputUID/Options/Option.js +22 -0
- package/admin/src/components/InputUID/Options/OptionsTitle.js +12 -0
- package/admin/src/components/InputUID/Options/RightOptionLabel.js +10 -0
- package/admin/src/components/InputUID/Options/index.js +34 -0
- package/admin/src/components/InputUID/Options/wrapper.js +13 -0
- package/admin/src/components/InputUID/RegenerateButton.js +18 -0
- package/admin/src/components/InputUID/RightContent.js +14 -0
- package/admin/src/components/InputUID/RightContentLabel.js +10 -0
- package/admin/src/components/InputUID/RightLabel.js +42 -0
- package/admin/src/components/InputUID/SubLabel.js +9 -0
- package/admin/src/components/InputUID/Wrapper.js +8 -0
- package/admin/src/components/InputUID/index.js +325 -0
- package/admin/src/components/InputUID/regex.js +3 -0
- package/admin/src/components/Inputs/index.js +283 -0
- package/admin/src/components/Inputs/utils/VALIDATIONS_TO_OMIT.js +12 -0
- package/admin/src/components/Inputs/utils/connect.js +12 -0
- package/admin/src/components/Inputs/utils/generateOptions.js +19 -0
- package/admin/src/components/Inputs/utils/getInputType.js +44 -0
- package/admin/src/components/Inputs/utils/getStep.js +15 -0
- package/admin/src/components/Inputs/utils/index.js +6 -0
- package/admin/src/components/Inputs/utils/select.js +38 -0
- package/admin/src/components/LayoutTitle/index.js +19 -0
- package/admin/src/components/MediaPreviewList/StyledMediaPreviewList.js +171 -0
- package/admin/src/components/MediaPreviewList/index.js +110 -0
- package/admin/src/components/NonRepeatableComponent/index.js +73 -0
- package/admin/src/components/NonRepeatableWrapper/index.js +73 -0
- package/admin/src/components/PlusButton/index.js +52 -0
- package/admin/src/components/PopupForm/index.js +93 -0
- package/admin/src/components/PreviewCarret/components.js +27 -0
- package/admin/src/components/PreviewCarret/index.js +22 -0
- package/admin/src/components/PreviewWysiwyg/Wrapper.js +133 -0
- package/admin/src/components/PreviewWysiwyg/index.js +34 -0
- package/admin/src/components/PreviewWysiwyg/utils/mdRenderer.js +72 -0
- package/admin/src/components/PreviewWysiwyg/utils/satinizeHtml.js +16 -0
- package/admin/src/components/RelationPreviewList/CountWrapper.js +7 -0
- package/admin/src/components/RelationPreviewList/RelationPreviewTooltip.js +117 -0
- package/admin/src/components/RelationPreviewList/index.js +111 -0
- package/admin/src/components/RepeatableComponent/AddFieldButton.js +64 -0
- package/admin/src/components/RepeatableComponent/Banner.js +112 -0
- package/admin/src/components/RepeatableComponent/BannerWrapper.js +194 -0
- package/admin/src/components/RepeatableComponent/CarretTop.js +14 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/index.js +245 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/utils/connect.js +11 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/utils/index.js +2 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/utils/select.js +30 -0
- package/admin/src/components/RepeatableComponent/EmptyComponent.js +27 -0
- package/admin/src/components/RepeatableComponent/FormWrapper.js +27 -0
- package/admin/src/components/RepeatableComponent/index.js +187 -0
- package/admin/src/components/RepeatableComponent/reducer.js +73 -0
- package/admin/src/components/RepeatableComponent/utils/connect.js +11 -0
- package/admin/src/components/RepeatableComponent/utils/select.js +12 -0
- package/admin/src/components/Search/index.js +88 -0
- package/admin/src/components/SectionTitle/Title.js +11 -0
- package/admin/src/components/SectionTitle/index.js +29 -0
- package/admin/src/components/SelectMany/ListItem.js +107 -0
- package/admin/src/components/SelectMany/Relation.js +106 -0
- package/admin/src/components/SelectMany/components.js +153 -0
- package/admin/src/components/SelectMany/index.js +159 -0
- package/admin/src/components/SelectOne/SingleValue.js +58 -0
- package/admin/src/components/SelectOne/index.js +71 -0
- package/admin/src/components/SelectWrapper/ClearIndicator.js +15 -0
- package/admin/src/components/SelectWrapper/IndicatorSeparator.js +3 -0
- package/admin/src/components/SelectWrapper/Option.js +76 -0
- package/admin/src/components/SelectWrapper/components.js +14 -0
- package/admin/src/components/SelectWrapper/index.js +393 -0
- package/admin/src/components/SelectWrapper/utils/connect.js +12 -0
- package/admin/src/components/SelectWrapper/utils/index.js +3 -0
- package/admin/src/components/SelectWrapper/utils/select.js +45 -0
- package/admin/src/components/SelectWrapper/utils/styles.js +105 -0
- package/admin/src/components/Separator/index.js +9 -0
- package/admin/src/components/SettingFormWrapper/index.js +9 -0
- package/admin/src/components/SettingsViewWrapper/index.js +283 -0
- package/admin/src/components/SortWrapper/index.js +9 -0
- package/admin/src/components/SortableList/Item.js +126 -0
- package/admin/src/components/SortableList/index.js +60 -0
- package/admin/src/components/State/Wrapper.js +30 -0
- package/admin/src/components/State/index.js +26 -0
- package/admin/src/components/Truncate/index.js +5 -0
- package/admin/src/components/Truncated/index.js +10 -0
- package/admin/src/components/Wysiwyg/EditorWrapper.js +122 -0
- package/admin/src/components/Wysiwyg/MediaLib.js +71 -0
- package/admin/src/components/Wysiwyg/PreviewControlWrapper.js +30 -0
- package/admin/src/components/Wysiwyg/SelectWrapper.js +24 -0
- package/admin/src/components/Wysiwyg/ToggleModeWrapper.js +30 -0
- package/admin/src/components/Wysiwyg/constants.js +98 -0
- package/admin/src/components/Wysiwyg/customSelect.js +39 -0
- package/admin/src/components/Wysiwyg/helpers.js +116 -0
- package/admin/src/components/Wysiwyg/index.js +819 -0
- package/admin/src/components/Wysiwyg/previewControl.js +29 -0
- package/admin/src/components/Wysiwyg/toggleMode.js +44 -0
- package/admin/src/components/Wysiwyg/utils.js +70 -0
- package/admin/src/components/WysiwygBottomControls/components.js +44 -0
- package/admin/src/components/WysiwygBottomControls/index.js +33 -0
- package/admin/src/components/WysiwygDropUpload/Label.js +16 -0
- package/admin/src/components/WysiwygDropUpload/index.js +18 -0
- package/admin/src/components/WysiwygEditor/index.js +26 -0
- package/admin/src/components/WysiwygInlineControls/Button.js +77 -0
- package/admin/src/components/WysiwygInlineControls/StyledButton.js +54 -0
- package/admin/src/components/WysiwygInlineControls/Wrapper.js +25 -0
- package/admin/src/components/WysiwygInlineControls/index.js +66 -0
- package/admin/src/components/WysiwygWithErrors/Wrapper.js +38 -0
- package/admin/src/components/WysiwygWithErrors/index.js +158 -0
- package/admin/src/containers/CollectionTypeFormWrapper/index.js +376 -0
- package/admin/src/containers/CollectionTypeFormWrapper/utils/getRequestUrl.js +5 -0
- package/admin/src/containers/CollectionTypeFormWrapper/utils/index.js +2 -0
- package/admin/src/containers/CollectionTypeRecursivePath/index.js +125 -0
- package/admin/src/containers/ComponentSetttingsView/index.js +55 -0
- package/admin/src/containers/EditSettingsView/index.js +408 -0
- package/admin/src/containers/EditSettingsView/init.js +18 -0
- package/admin/src/containers/EditSettingsView/reducer.js +126 -0
- package/admin/src/containers/EditSettingsView/utils/createPossibleMainFieldsForModelsAndComponents.js +26 -0
- package/admin/src/containers/EditSettingsView/utils/getInputProps.js +30 -0
- package/admin/src/containers/EditSettingsView/utils/index.js +2 -0
- package/admin/src/containers/EditSettingsView/utils/layout.js +98 -0
- package/admin/src/containers/EditView/DeleteLink/index.js +94 -0
- package/admin/src/containers/EditView/DeleteLink/utils/connect.js +12 -0
- package/admin/src/containers/EditView/DeleteLink/utils/index.js +2 -0
- package/admin/src/containers/EditView/DeleteLink/utils/select.js +21 -0
- package/admin/src/containers/EditView/Header/index.js +258 -0
- package/admin/src/containers/EditView/Header/utils/connect.js +12 -0
- package/admin/src/containers/EditView/Header/utils/getDraftRelations.js +62 -0
- package/admin/src/containers/EditView/Header/utils/index.js +3 -0
- package/admin/src/containers/EditView/Header/utils/select.js +31 -0
- package/admin/src/containers/EditView/InformationCard.js +100 -0
- package/admin/src/containers/EditView/components.js +74 -0
- package/admin/src/containers/EditView/index.js +297 -0
- package/admin/src/containers/EditView/utils/createAttributesLayout.js +39 -0
- package/admin/src/containers/EditView/utils/getFieldsActionMatchingPermissions.js +23 -0
- package/admin/src/containers/EditView/utils/index.js +3 -0
- package/admin/src/containers/EditViewDataManagerProvider/index.js +519 -0
- package/admin/src/containers/EditViewDataManagerProvider/reducer.js +218 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/cleanData.js +88 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/getYupInnerErrors.js +17 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/index.js +3 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/schema.js +368 -0
- package/admin/src/containers/EditViewLayoutManager/Permissions.js +30 -0
- package/admin/src/containers/EditViewLayoutManager/actions.js +9 -0
- package/admin/src/containers/EditViewLayoutManager/constants.js +2 -0
- package/admin/src/containers/EditViewLayoutManager/index.js +44 -0
- package/admin/src/containers/EditViewLayoutManager/reducer.js +30 -0
- package/admin/src/containers/EditViewLayoutManager/selectors.js +5 -0
- package/admin/src/containers/LayoutDndProvider/index.js +75 -0
- package/admin/src/containers/ListSettingsView/DragWrapper.js +21 -0
- package/admin/src/containers/ListSettingsView/DropdownButton.js +8 -0
- package/admin/src/containers/ListSettingsView/Label.js +91 -0
- package/admin/src/containers/ListSettingsView/MenuDropdown.js +41 -0
- package/admin/src/containers/ListSettingsView/Toggle.js +51 -0
- package/admin/src/containers/ListSettingsView/forms.json +64 -0
- package/admin/src/containers/ListSettingsView/index.js +298 -0
- package/admin/src/containers/ListSettingsView/init.js +11 -0
- package/admin/src/containers/ListSettingsView/reducer.js +77 -0
- package/admin/src/containers/ListView/FieldPicker/ConfigureLink/StyledLink.js +28 -0
- package/admin/src/containers/ListView/FieldPicker/ConfigureLink/Wrapper.js +8 -0
- package/admin/src/containers/ListView/FieldPicker/ConfigureLink/index.js +29 -0
- package/admin/src/containers/ListView/FieldPicker/Field/Wrapper.js +15 -0
- package/admin/src/containers/ListView/FieldPicker/Field/index.js +24 -0
- package/admin/src/containers/ListView/FieldPicker/Fields/Wrapper.js +18 -0
- package/admin/src/containers/ListView/FieldPicker/Fields/index.js +27 -0
- package/admin/src/containers/ListView/FieldPicker/Header/Reset.js +8 -0
- package/admin/src/containers/ListView/FieldPicker/Header/index.js +42 -0
- package/admin/src/containers/ListView/FieldPicker/Wrapper.js +9 -0
- package/admin/src/containers/ListView/FieldPicker/index.js +46 -0
- package/admin/src/containers/ListView/Filter.js +83 -0
- package/admin/src/containers/ListView/Footer.js +60 -0
- package/admin/src/containers/ListView/actions.js +91 -0
- package/admin/src/containers/ListView/components.js +138 -0
- package/admin/src/containers/ListView/constants.js +16 -0
- package/admin/src/containers/ListView/index.js +573 -0
- package/admin/src/containers/ListView/reducer.js +182 -0
- package/admin/src/containers/ListView/selectors.js +24 -0
- package/admin/src/containers/ListView/utils/buildQueryString.js +26 -0
- package/admin/src/containers/ListView/utils/createPluginsFilter.js +13 -0
- package/admin/src/containers/ListView/utils/getAllAllowedHeaders.js +17 -0
- package/admin/src/containers/ListView/utils/getFirstSortableHeader.js +14 -0
- package/admin/src/containers/ListView/utils/index.js +3 -0
- package/admin/src/containers/ListViewLayoutManager/Permissions.js +29 -0
- package/admin/src/containers/ListViewLayoutManager/index.js +60 -0
- package/admin/src/containers/ListViewProvider/index.js +16 -0
- package/admin/src/containers/Main/actions.js +13 -0
- package/admin/src/containers/Main/constants.js +3 -0
- package/admin/src/containers/Main/index.js +100 -0
- package/admin/src/containers/Main/reducer.js +37 -0
- package/admin/src/containers/Main/selectors.js +20 -0
- package/admin/src/containers/RBACManager/actions.js +14 -0
- package/admin/src/containers/RBACManager/constants.js +2 -0
- package/admin/src/containers/RBACManager/reducer.js +32 -0
- package/admin/src/containers/RBACManager/useSyncRbac.js +28 -0
- package/admin/src/containers/SingleTypeFormWrapper/index.js +317 -0
- package/admin/src/containers/SingleTypeFormWrapper/utils/getRequestUrl.js +5 -0
- package/admin/src/containers/SingleTypeFormWrapper/utils/index.js +2 -0
- package/admin/src/containers/SingleTypeRecursivePath/index.js +84 -0
- package/admin/src/containers/WysiwygProvider/index.js +16 -0
- package/admin/src/contexts/ContentTypeLayout.js +5 -0
- package/admin/src/contexts/LayoutDnd.js +5 -0
- package/admin/src/contexts/ListView.js +5 -0
- package/admin/src/contexts/Wysiwyg.js +5 -0
- package/admin/src/contexts/index.js +4 -0
- package/admin/src/hooks/index.js +6 -0
- package/admin/src/hooks/useContentTypeLayout/index.js +19 -0
- package/admin/src/hooks/useFetchContentTypeLayout/index.js +83 -0
- package/admin/src/hooks/useFetchContentTypeLayout/reducer.js +56 -0
- package/admin/src/hooks/useFetchContentTypeLayout/utils/formatLayouts.js +235 -0
- package/admin/src/hooks/useFindRedirectionLink/index.js +14 -0
- package/admin/src/hooks/useFindRedirectionLink/selectors.js +7 -0
- package/admin/src/hooks/useFindRedirectionLink/utils/getRedirectionLink.js +45 -0
- package/admin/src/hooks/useLayoutDnd.js +6 -0
- package/admin/src/hooks/useListView.js +6 -0
- package/admin/src/hooks/useWysiwyg.js +6 -0
- package/admin/src/icons/Bold/index.js +22 -0
- package/admin/src/icons/Code/index.js +13 -0
- package/admin/src/icons/Cross/index.js +33 -0
- package/admin/src/icons/Italic/index.js +23 -0
- package/admin/src/icons/Link/index.js +21 -0
- package/admin/src/icons/Media/index.js +14 -0
- package/admin/src/icons/Na/index.js +58 -0
- package/admin/src/icons/Ol/index.js +13 -0
- package/admin/src/icons/Quote/index.js +13 -0
- package/admin/src/icons/Striked/index.js +24 -0
- package/admin/src/icons/Ul/index.js +15 -0
- package/admin/src/icons/Underline/index.js +22 -0
- package/admin/src/index.js +52 -0
- package/admin/src/lifecycles.js +19 -0
- package/admin/src/permissions.js +27 -0
- package/admin/src/pluginId.js +5 -0
- package/admin/src/reducers.js +16 -0
- package/admin/src/selectors.js +6 -0
- package/admin/src/sharedReducers/crudReducer/actions.js +44 -0
- package/admin/src/sharedReducers/crudReducer/constants.js +7 -0
- package/admin/src/sharedReducers/crudReducer/reducer.js +75 -0
- package/admin/src/sharedReducers/crudReducer/selectors.js +5 -0
- package/admin/src/testUtils/data.js +305 -0
- package/admin/src/testUtils/index.js +4 -0
- package/admin/src/translations/ar.json +94 -0
- package/admin/src/translations/cs.json +130 -0
- package/admin/src/translations/de.json +177 -0
- package/admin/src/translations/dk.json +180 -0
- package/admin/src/translations/en.json +177 -0
- package/admin/src/translations/es.json +177 -0
- package/admin/src/translations/fr.json +162 -0
- package/admin/src/translations/id.json +175 -0
- package/admin/src/translations/index.js +53 -0
- package/admin/src/translations/it.json +177 -0
- package/admin/src/translations/ja.json +94 -0
- package/admin/src/translations/ko.json +110 -0
- package/admin/src/translations/ms.json +148 -0
- package/admin/src/translations/nl.json +94 -0
- package/admin/src/translations/pl.json +142 -0
- package/admin/src/translations/pt-BR.json +94 -0
- package/admin/src/translations/pt.json +94 -0
- package/admin/src/translations/ru.json +177 -0
- package/admin/src/translations/sk.json +172 -0
- package/admin/src/translations/th.json +155 -0
- package/admin/src/translations/tr.json +177 -0
- package/admin/src/translations/uk.json +148 -0
- package/admin/src/translations/vi.json +110 -0
- package/admin/src/translations/zh-Hans.json +177 -0
- package/admin/src/translations/zh.json +94 -0
- package/admin/src/utils/ItemTypes.js +7 -0
- package/admin/src/utils/checkIfAttributeIsDisplayable.js +13 -0
- package/admin/src/utils/createDefaultForm.js +50 -0
- package/admin/src/utils/dateFormats.js +18 -0
- package/admin/src/utils/formatFiltersFromQuery.js +55 -0
- package/admin/src/utils/formatFiltersToQuery.js +27 -0
- package/admin/src/utils/formatLayoutToApi.js +44 -0
- package/admin/src/utils/generatePermissionsObject.js +20 -0
- package/admin/src/utils/getComponents.js +50 -0
- package/admin/src/utils/getDisplayedValue.js +61 -0
- package/admin/src/utils/getFieldName.js +6 -0
- package/admin/src/utils/getMaxTempKey.js +12 -0
- package/admin/src/utils/getRequestUrl.js +5 -0
- package/admin/src/utils/getTrad.js +5 -0
- package/admin/src/utils/index.js +17 -0
- package/admin/src/utils/mergeMetasWithSchema.js +20 -0
- package/admin/src/utils/removeKeyInObject.js +45 -0
- package/admin/src/utils/removePasswordFieldsFromData.js +54 -0
- package/config/admin.json +5 -0
- package/config/functions/bootstrap.js +9 -0
- package/config/policies/has-draft-and-publish.js +19 -0
- package/config/policies/hasPermissions.js +34 -0
- package/config/policies/routing.js +27 -0
- package/config/routes.json +275 -0
- package/controllers/collection-types.js +282 -0
- package/controllers/components.js +66 -0
- package/controllers/content-types.js +112 -0
- package/controllers/relations.js +63 -0
- package/controllers/single-types.js +170 -0
- package/controllers/uid.js +41 -0
- package/controllers/validation/index.js +104 -0
- package/controllers/validation/model-configuration.js +114 -0
- package/oas.yml +757 -0
- package/package.json +77 -0
- package/services/components.js +92 -0
- package/services/configuration.js +79 -0
- package/services/content-types.js +73 -0
- package/services/data-mapper.js +98 -0
- package/services/entity-manager.js +140 -0
- package/services/metrics.js +34 -0
- package/services/permission-checker.js +69 -0
- package/services/permission.js +95 -0
- package/services/uid.js +63 -0
- package/services/utils/configuration/attributes.js +175 -0
- package/services/utils/configuration/index.js +43 -0
- package/services/utils/configuration/layouts.js +185 -0
- package/services/utils/configuration/metadatas.js +142 -0
- package/services/utils/configuration/settings.js +52 -0
- package/services/utils/store.js +93 -0
- package/utils/index.js +16 -0
- package/utils/pick-writable-attributes.js +6 -0
- package/utils/wrap-bad-request.js +15 -0
- package/validation/policies/hasPermissions.js +17 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { prop } = require('lodash/fp');
|
|
4
|
+
const { contentTypes: contentTypesUtils } = require('@akemona-org/strapi-utils');
|
|
5
|
+
const { getService } = require('../utils');
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
canConfigureContentType({ userAbility, contentType }) {
|
|
9
|
+
const action = contentTypesUtils.isSingleType(contentType)
|
|
10
|
+
? 'plugins::content-manager.single-types.configure-view'
|
|
11
|
+
: 'plugins::content-manager.collection-types.configure-view';
|
|
12
|
+
|
|
13
|
+
return userAbility.can(action);
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
async registerPermissions() {
|
|
17
|
+
const displayedContentTypes = getService('content-types').findDisplayedContentTypes();
|
|
18
|
+
|
|
19
|
+
const contentTypesUids = displayedContentTypes.map(prop('uid'));
|
|
20
|
+
|
|
21
|
+
const draftAndPublishContentTypesUids = displayedContentTypes
|
|
22
|
+
.filter(contentTypesUtils.hasDraftAndPublish)
|
|
23
|
+
.map(prop('uid'));
|
|
24
|
+
|
|
25
|
+
const actions = [
|
|
26
|
+
{
|
|
27
|
+
section: 'contentTypes',
|
|
28
|
+
displayName: 'Create',
|
|
29
|
+
uid: 'explorer.create',
|
|
30
|
+
pluginName: 'content-manager',
|
|
31
|
+
subjects: contentTypesUids,
|
|
32
|
+
options: {
|
|
33
|
+
applyToProperties: ['fields'],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
section: 'contentTypes',
|
|
38
|
+
displayName: 'Read',
|
|
39
|
+
uid: 'explorer.read',
|
|
40
|
+
pluginName: 'content-manager',
|
|
41
|
+
subjects: contentTypesUids,
|
|
42
|
+
options: {
|
|
43
|
+
applyToProperties: ['fields'],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
section: 'contentTypes',
|
|
48
|
+
displayName: 'Update',
|
|
49
|
+
uid: 'explorer.update',
|
|
50
|
+
pluginName: 'content-manager',
|
|
51
|
+
subjects: contentTypesUids,
|
|
52
|
+
options: {
|
|
53
|
+
applyToProperties: ['fields'],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
section: 'contentTypes',
|
|
58
|
+
displayName: 'Delete',
|
|
59
|
+
uid: 'explorer.delete',
|
|
60
|
+
pluginName: 'content-manager',
|
|
61
|
+
subjects: contentTypesUids,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
section: 'contentTypes',
|
|
65
|
+
displayName: 'Publish',
|
|
66
|
+
uid: 'explorer.publish',
|
|
67
|
+
pluginName: 'content-manager',
|
|
68
|
+
subjects: draftAndPublishContentTypesUids,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
section: 'plugins',
|
|
72
|
+
displayName: 'Configure view',
|
|
73
|
+
uid: 'single-types.configure-view',
|
|
74
|
+
subCategory: 'single types',
|
|
75
|
+
pluginName: 'content-manager',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
section: 'plugins',
|
|
79
|
+
displayName: 'Configure view',
|
|
80
|
+
uid: 'collection-types.configure-view',
|
|
81
|
+
subCategory: 'collection types',
|
|
82
|
+
pluginName: 'content-manager',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
section: 'plugins',
|
|
86
|
+
displayName: 'Configure Layout',
|
|
87
|
+
uid: 'components.configure-layout',
|
|
88
|
+
subCategory: 'components',
|
|
89
|
+
pluginName: 'content-manager',
|
|
90
|
+
},
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
await strapi.admin.services.permission.actionProvider.registerMany(actions);
|
|
94
|
+
},
|
|
95
|
+
};
|
package/services/uid.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const _ = require('lodash');
|
|
4
|
+
const slugify = require('@sindresorhus/slugify');
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
async generateUIDField({ contentTypeUID, field, data }) {
|
|
8
|
+
const contentType = strapi.contentTypes[contentTypeUID];
|
|
9
|
+
const { attributes } = contentType;
|
|
10
|
+
|
|
11
|
+
const { targetField, default: defaultValue, options } = attributes[field];
|
|
12
|
+
const targetValue = _.get(data, targetField);
|
|
13
|
+
|
|
14
|
+
if (!_.isEmpty(targetValue)) {
|
|
15
|
+
return this.findUniqueUID({
|
|
16
|
+
contentTypeUID,
|
|
17
|
+
field,
|
|
18
|
+
value: slugify(targetValue, options),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return this.findUniqueUID({
|
|
23
|
+
contentTypeUID,
|
|
24
|
+
field,
|
|
25
|
+
value: slugify(defaultValue || contentType.modelName, options),
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
async findUniqueUID({ contentTypeUID, field, value }) {
|
|
30
|
+
const query = strapi.db.query(contentTypeUID);
|
|
31
|
+
|
|
32
|
+
const possibleColisions = await query
|
|
33
|
+
.find({
|
|
34
|
+
[`${field}_contains`]: value,
|
|
35
|
+
_limit: -1,
|
|
36
|
+
})
|
|
37
|
+
.then(results => results.map(result => result[field]));
|
|
38
|
+
|
|
39
|
+
if (possibleColisions.length === 0) {
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let i = 1;
|
|
44
|
+
let tmpUId = `${value}-${i}`;
|
|
45
|
+
while (possibleColisions.includes(tmpUId)) {
|
|
46
|
+
i += 1;
|
|
47
|
+
tmpUId = `${value}-${i}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return tmpUId;
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
async checkUIDAvailability({ contentTypeUID, field, value }) {
|
|
54
|
+
const query = strapi.db.query(contentTypeUID);
|
|
55
|
+
|
|
56
|
+
const count = await query.count({
|
|
57
|
+
[field]: value,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (count > 0) return false;
|
|
61
|
+
return true;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const _ = require('lodash');
|
|
4
|
+
const { contentTypes: contentTypesUtils } = require('@akemona-org/strapi-utils');
|
|
5
|
+
|
|
6
|
+
const { PUBLISHED_AT_ATTRIBUTE } = contentTypesUtils.constants;
|
|
7
|
+
|
|
8
|
+
const NON_SORTABLES = ['component', 'json', 'media', 'richtext', 'dynamiczone'];
|
|
9
|
+
const SORTABLE_RELATIONS = ['oneWay', 'oneToOne', 'manyToOne'];
|
|
10
|
+
|
|
11
|
+
const NON_LISTABLES = ['component', 'json', 'password', 'richtext', 'dynamiczone'];
|
|
12
|
+
const LISTABLE_RELATIONS = [
|
|
13
|
+
'oneWay',
|
|
14
|
+
'oneToOne',
|
|
15
|
+
'oneToMany',
|
|
16
|
+
'manyToOne',
|
|
17
|
+
'manyToMany',
|
|
18
|
+
'manyWay',
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
// hidden fields are fields that are configured to be hidden from list, and edit views
|
|
22
|
+
const isHidden = (schema, name) => {
|
|
23
|
+
if (!_.has(schema.attributes, name)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const isHidden = _.get(schema, ['config', 'attributes', name, 'hidden'], false);
|
|
28
|
+
if (isHidden === true) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const isListable = (schema, name) => {
|
|
36
|
+
if (!_.has(schema.attributes, name)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (isHidden(schema, name)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const attribute = schema.attributes[name];
|
|
45
|
+
if (NON_LISTABLES.includes(attribute.type)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (isRelation(attribute) && !LISTABLE_RELATIONS.includes(attribute.relationType)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return true;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const isSortable = (schema, name) => {
|
|
57
|
+
if (!_.has(schema.attributes, name)) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (schema.modelType === 'component' && name === 'id') return false;
|
|
62
|
+
|
|
63
|
+
const attribute = schema.attributes[name];
|
|
64
|
+
if (NON_SORTABLES.includes(attribute.type)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (isRelation(attribute) && !SORTABLE_RELATIONS.includes(attribute.relationType)) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return true;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const isSearchable = (schema, name) => {
|
|
76
|
+
return isSortable(schema, name);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const isVisible = (schema, name) => {
|
|
80
|
+
if (!_.has(schema.attributes, name)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (isHidden(schema, name)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (isTimestamp(schema, name) || name === 'id') {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (isPublicationField(name)) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return true;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const isPublicationField = (name) => {
|
|
100
|
+
return PUBLISHED_AT_ATTRIBUTE === name;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const isTimestamp = (schema, name) => {
|
|
104
|
+
if (!_.has(schema.attributes, name)) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const timestampsOpt = _.get(schema, ['options', 'timestamps']);
|
|
109
|
+
if (!timestampsOpt || !Array.isArray(timestampsOpt)) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (timestampsOpt.includes(name)) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const isRelation = (attribute) => attribute.type === 'relation';
|
|
119
|
+
|
|
120
|
+
const hasRelationAttribute = (schema, name) => {
|
|
121
|
+
if (!_.has(schema.attributes, name)) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (isHidden(schema, name)) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!isVisible(schema, name)) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return isRelation(schema.attributes[name]);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const hasEditableAttribute = (schema, name) => {
|
|
137
|
+
if (!_.has(schema.attributes, name)) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (isHidden(schema, name)) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (!isVisible(schema, name)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (isRelation(schema.attributes[name])) {
|
|
150
|
+
if (schema.modelType === 'component') return true;
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return true;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const findFirstStringAttribute = (schema) => {
|
|
158
|
+
return Object.keys(schema.attributes || {}).find((key) => {
|
|
159
|
+
const { type } = schema.attributes[key];
|
|
160
|
+
return type === 'string' && key !== 'id';
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const getDefaultMainField = (schema) => findFirstStringAttribute(schema) || 'id';
|
|
165
|
+
|
|
166
|
+
module.exports = {
|
|
167
|
+
isSortable,
|
|
168
|
+
isVisible,
|
|
169
|
+
isSearchable,
|
|
170
|
+
isRelation,
|
|
171
|
+
isListable,
|
|
172
|
+
hasEditableAttribute,
|
|
173
|
+
hasRelationAttribute,
|
|
174
|
+
getDefaultMainField,
|
|
175
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { createModelConfigurationSchema } = require('../../../controllers/validation');
|
|
4
|
+
const { createDefaultSettings, syncSettings } = require('./settings');
|
|
5
|
+
const { createDefaultMetadatas, syncMetadatas } = require('./metadatas');
|
|
6
|
+
const { createDefaultLayouts, syncLayouts } = require('./layouts');
|
|
7
|
+
|
|
8
|
+
async function validateCustomConfig(schema) {
|
|
9
|
+
try {
|
|
10
|
+
await createModelConfigurationSchema(schema, {
|
|
11
|
+
allowUndefined: true,
|
|
12
|
+
}).validate(schema.config);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
`Invalid Model configuration for model ${schema.uid}. Verify your {{modelName}}.config.js(on) file:\n - ${error.message}\n`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function createDefaultConfiguration(schema) {
|
|
21
|
+
await validateCustomConfig(schema);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
settings: await createDefaultSettings(schema),
|
|
25
|
+
metadatas: await createDefaultMetadatas(schema),
|
|
26
|
+
layouts: await createDefaultLayouts(schema),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function syncConfiguration(conf, schema) {
|
|
31
|
+
await validateCustomConfig(schema);
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
settings: await syncSettings(conf, schema),
|
|
35
|
+
layouts: await syncLayouts(conf, schema),
|
|
36
|
+
metadatas: await syncMetadatas(conf, schema),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = {
|
|
41
|
+
createDefaultConfiguration,
|
|
42
|
+
syncConfiguration,
|
|
43
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const _ = require('lodash');
|
|
4
|
+
const {
|
|
5
|
+
isListable,
|
|
6
|
+
hasEditableAttribute,
|
|
7
|
+
hasRelationAttribute,
|
|
8
|
+
} = require('./attributes');
|
|
9
|
+
|
|
10
|
+
const DEFAULT_LIST_LENGTH = 4;
|
|
11
|
+
const MAX_ROW_SIZE = 12;
|
|
12
|
+
|
|
13
|
+
const typeToSize = type => {
|
|
14
|
+
switch (type) {
|
|
15
|
+
case 'checkbox':
|
|
16
|
+
case 'boolean':
|
|
17
|
+
case 'date':
|
|
18
|
+
case 'time':
|
|
19
|
+
case 'biginteger':
|
|
20
|
+
case 'decimal':
|
|
21
|
+
case 'float':
|
|
22
|
+
case 'integer':
|
|
23
|
+
case 'number':
|
|
24
|
+
return MAX_ROW_SIZE / 3;
|
|
25
|
+
case 'json':
|
|
26
|
+
case 'component':
|
|
27
|
+
case 'richtext':
|
|
28
|
+
case 'dynamiczone':
|
|
29
|
+
return MAX_ROW_SIZE;
|
|
30
|
+
|
|
31
|
+
default:
|
|
32
|
+
return MAX_ROW_SIZE / 2;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
async function createDefaultLayouts(schema) {
|
|
37
|
+
return {
|
|
38
|
+
list: createDefaultListLayout(schema),
|
|
39
|
+
editRelations: createDefaultEditRelationsLayout(schema),
|
|
40
|
+
edit: createDefaultEditLayout(schema),
|
|
41
|
+
..._.pick(_.get(schema, ['config', 'layouts'], {}), [
|
|
42
|
+
'list',
|
|
43
|
+
'edit',
|
|
44
|
+
'editRelations',
|
|
45
|
+
]),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function createDefaultListLayout(schema) {
|
|
50
|
+
return Object.keys(schema.attributes)
|
|
51
|
+
.filter(name => isListable(schema, name))
|
|
52
|
+
.slice(0, DEFAULT_LIST_LENGTH);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function createDefaultEditRelationsLayout(schema) {
|
|
56
|
+
if (schema.modelType === 'component') return [];
|
|
57
|
+
|
|
58
|
+
return Object.keys(schema.attributes).filter(name =>
|
|
59
|
+
hasRelationAttribute(schema, name)
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const rowSize = els => els.reduce((sum, el) => sum + el.size, 0);
|
|
64
|
+
|
|
65
|
+
function createDefaultEditLayout(schema) {
|
|
66
|
+
const keys = Object.keys(schema.attributes).filter(name =>
|
|
67
|
+
hasEditableAttribute(schema, name)
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return appendToEditLayout([], keys, schema);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Synchronisation functions */
|
|
74
|
+
|
|
75
|
+
function syncLayouts(configuration, schema) {
|
|
76
|
+
if (_.isEmpty(configuration.layouts)) return createDefaultLayouts(schema);
|
|
77
|
+
|
|
78
|
+
const { list = [], editRelations = [], edit = [] } =
|
|
79
|
+
configuration.layouts || {};
|
|
80
|
+
|
|
81
|
+
let cleanList = list.filter(attr => isListable(schema, attr));
|
|
82
|
+
|
|
83
|
+
let cleanEditRelations = editRelations.filter(attr =>
|
|
84
|
+
hasRelationAttribute(schema, attr)
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
let elementsToReAppend = [];
|
|
88
|
+
let cleanEdit = [];
|
|
89
|
+
for (let row of edit) {
|
|
90
|
+
let newRow = [];
|
|
91
|
+
|
|
92
|
+
for (let el of row) {
|
|
93
|
+
if (!hasEditableAttribute(schema, el.name)) continue;
|
|
94
|
+
|
|
95
|
+
// if size of the element has changed (type changes)
|
|
96
|
+
if (typeToSize(schema.attributes[el.name].type) !== el.size) {
|
|
97
|
+
elementsToReAppend.push(el.name);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
newRow.push(el);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (newRow.length > 0) {
|
|
105
|
+
cleanEdit.push(newRow);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
cleanEdit = appendToEditLayout(cleanEdit, elementsToReAppend, schema);
|
|
110
|
+
|
|
111
|
+
const newAttributes = _.difference(
|
|
112
|
+
Object.keys(schema.attributes),
|
|
113
|
+
Object.keys(configuration.metadatas)
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
/** Add new attributes where they belong */
|
|
117
|
+
|
|
118
|
+
if (cleanList.length < DEFAULT_LIST_LENGTH) {
|
|
119
|
+
// add newAttributes
|
|
120
|
+
// only add valid listable attributes
|
|
121
|
+
cleanList = _.uniq(
|
|
122
|
+
cleanList
|
|
123
|
+
.concat(newAttributes.filter(key => isListable(schema, key)))
|
|
124
|
+
.slice(0, DEFAULT_LIST_LENGTH)
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// add new relations to layout
|
|
129
|
+
if (schema.modelType !== 'component') {
|
|
130
|
+
const newRelations = newAttributes.filter(key =>
|
|
131
|
+
hasRelationAttribute(schema, key)
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
cleanEditRelations = _.uniq(cleanEditRelations.concat(newRelations));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// add new attributes to edit view
|
|
138
|
+
const newEditAttributes = newAttributes.filter(key =>
|
|
139
|
+
hasEditableAttribute(schema, key)
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
cleanEdit = appendToEditLayout(cleanEdit, newEditAttributes, schema);
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
list: cleanList.length > 0 ? cleanList : createDefaultListLayout(schema),
|
|
146
|
+
edit: cleanEdit.length > 0 ? cleanEdit : createDefaultEditLayout(schema),
|
|
147
|
+
editRelations:
|
|
148
|
+
cleanEditRelations.length > 0
|
|
149
|
+
? cleanEditRelations
|
|
150
|
+
: createDefaultEditRelationsLayout(schema),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const appendToEditLayout = (layout = [], keysToAppend, schema) => {
|
|
155
|
+
if (keysToAppend.length === 0) return layout;
|
|
156
|
+
let currentRowIndex = Math.max(layout.length - 1, 0);
|
|
157
|
+
|
|
158
|
+
// init currentRow if necessary
|
|
159
|
+
if (!layout[currentRowIndex]) {
|
|
160
|
+
layout[currentRowIndex] = [];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
for (let key of keysToAppend) {
|
|
164
|
+
const attribute = schema.attributes[key];
|
|
165
|
+
const attributeSize = typeToSize(attribute.type);
|
|
166
|
+
let currenRowSize = rowSize(layout[currentRowIndex]);
|
|
167
|
+
|
|
168
|
+
if (currenRowSize + attributeSize > MAX_ROW_SIZE) {
|
|
169
|
+
currentRowIndex += 1;
|
|
170
|
+
layout[currentRowIndex] = [];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
layout[currentRowIndex].push({
|
|
174
|
+
name: key,
|
|
175
|
+
size: attributeSize,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return layout;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
module.exports = {
|
|
183
|
+
createDefaultLayouts,
|
|
184
|
+
syncLayouts,
|
|
185
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const _ = require('lodash');
|
|
4
|
+
const { getService } = require('../../../utils');
|
|
5
|
+
const {
|
|
6
|
+
isSortable,
|
|
7
|
+
isSearchable,
|
|
8
|
+
isVisible,
|
|
9
|
+
isRelation,
|
|
10
|
+
getDefaultMainField,
|
|
11
|
+
} = require('./attributes');
|
|
12
|
+
|
|
13
|
+
function createDefaultMetadatas(schema) {
|
|
14
|
+
return {
|
|
15
|
+
...Object.keys(schema.attributes).reduce((acc, name) => {
|
|
16
|
+
acc[name] = createDefaultMetadata(schema, name);
|
|
17
|
+
return acc;
|
|
18
|
+
}, {}),
|
|
19
|
+
id: {
|
|
20
|
+
edit: {},
|
|
21
|
+
list: {
|
|
22
|
+
label: 'Id',
|
|
23
|
+
searchable: true,
|
|
24
|
+
sortable: true,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function createDefaultMetadata(schema, name) {
|
|
31
|
+
const edit = {
|
|
32
|
+
label: _.upperFirst(name),
|
|
33
|
+
description: '',
|
|
34
|
+
placeholder: '',
|
|
35
|
+
visible: isVisible(schema, name),
|
|
36
|
+
editable: true,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (isRelation(schema.attributes[name])) {
|
|
40
|
+
const { targetModel } = schema.attributes[name];
|
|
41
|
+
|
|
42
|
+
const targetSchema = getTargetSchema(targetModel);
|
|
43
|
+
|
|
44
|
+
if (targetSchema) {
|
|
45
|
+
edit.mainField = getDefaultMainField(targetSchema);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
_.assign(
|
|
50
|
+
edit,
|
|
51
|
+
_.pick(_.get(schema, ['config', 'metadatas', name, 'edit'], {}), [
|
|
52
|
+
'label',
|
|
53
|
+
'description',
|
|
54
|
+
'placeholder',
|
|
55
|
+
'visible',
|
|
56
|
+
'editable',
|
|
57
|
+
'mainField',
|
|
58
|
+
])
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const list = {
|
|
62
|
+
label: _.upperFirst(name),
|
|
63
|
+
searchable: isSearchable(schema, name),
|
|
64
|
+
sortable: isSortable(schema, name),
|
|
65
|
+
..._.pick(_.get(schema, ['config', 'metadatas', name, 'list'], {}), [
|
|
66
|
+
'label',
|
|
67
|
+
'searchable',
|
|
68
|
+
'sortable',
|
|
69
|
+
]),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return { edit, list };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Synchronisation functions */
|
|
76
|
+
|
|
77
|
+
async function syncMetadatas(configuration, schema) {
|
|
78
|
+
// clear all keys that do not exist anymore
|
|
79
|
+
if (_.isEmpty(configuration.metadatas)) {
|
|
80
|
+
return createDefaultMetadatas(schema);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// remove old keys
|
|
84
|
+
const metasWithValidKeys = _.pick(configuration.metadatas, Object.keys(schema.attributes));
|
|
85
|
+
|
|
86
|
+
// add new keys and missing fields
|
|
87
|
+
const metasWithDefaults = _.merge({}, createDefaultMetadatas(schema), metasWithValidKeys);
|
|
88
|
+
|
|
89
|
+
// clear the invalid mainFields
|
|
90
|
+
const updatedMetas = Object.keys(metasWithDefaults).reduce((acc, key) => {
|
|
91
|
+
const { edit, list } = metasWithDefaults[key];
|
|
92
|
+
const attr = schema.attributes[key];
|
|
93
|
+
|
|
94
|
+
let updatedMeta = { edit, list };
|
|
95
|
+
// update sortable attr
|
|
96
|
+
if (list.sortable && !isSortable(schema, key)) {
|
|
97
|
+
_.set(updatedMeta, ['list', 'sortable'], false);
|
|
98
|
+
_.set(acc, [key], updatedMeta);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (list.searchable && !isSearchable(schema, key)) {
|
|
102
|
+
_.set(updatedMeta, ['list', 'searchable'], false);
|
|
103
|
+
_.set(acc, [key], updatedMeta);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!_.has(edit, 'mainField')) return acc;
|
|
107
|
+
|
|
108
|
+
// remove mainField if the attribute is not a relation anymore
|
|
109
|
+
if (!isRelation(attr)) {
|
|
110
|
+
_.set(updatedMeta, 'edit', _.omit(edit, ['mainField']));
|
|
111
|
+
_.set(acc, [key], updatedMeta);
|
|
112
|
+
return acc;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// if the mainField is id you can keep it
|
|
116
|
+
if (edit.mainField === 'id') return acc;
|
|
117
|
+
|
|
118
|
+
// check the mainField in the targetModel
|
|
119
|
+
const targetSchema = getTargetSchema(attr.targetModel);
|
|
120
|
+
|
|
121
|
+
if (!targetSchema) return acc;
|
|
122
|
+
|
|
123
|
+
if (!isSortable(targetSchema, edit.mainField)) {
|
|
124
|
+
_.set(updatedMeta, ['edit', 'mainField'], getDefaultMainField(targetSchema));
|
|
125
|
+
_.set(acc, [key], updatedMeta);
|
|
126
|
+
return acc;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return acc;
|
|
130
|
+
}, {});
|
|
131
|
+
|
|
132
|
+
return _.assign(metasWithDefaults, updatedMetas);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const getTargetSchema = targetModel => {
|
|
136
|
+
return getService('content-types').findContentType(targetModel);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
module.exports = {
|
|
140
|
+
createDefaultMetadatas,
|
|
141
|
+
syncMetadatas,
|
|
142
|
+
};
|