@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,88 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Search
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { memo } from 'react';
|
|
8
|
+
import { isEmpty, upperFirst } from 'lodash';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import { FormattedMessage } from 'react-intl';
|
|
11
|
+
import { HeaderSearch, GlobalContext } from 'strapi-helper-plugin';
|
|
12
|
+
import getTrad from '../../utils/getTrad';
|
|
13
|
+
|
|
14
|
+
const WAIT = 400;
|
|
15
|
+
|
|
16
|
+
class Search extends React.Component {
|
|
17
|
+
static contextType = GlobalContext;
|
|
18
|
+
|
|
19
|
+
state = { didType: false, value: this.props.initValue };
|
|
20
|
+
|
|
21
|
+
timer = null;
|
|
22
|
+
|
|
23
|
+
componentDidUpdate(prevProps) {
|
|
24
|
+
const { model, value } = this.props;
|
|
25
|
+
|
|
26
|
+
if (prevProps.model !== model || (!isEmpty(prevProps.value) && isEmpty(value))) {
|
|
27
|
+
this.resetState();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
resetState = () => this.setState({ value: '' });
|
|
32
|
+
|
|
33
|
+
handleChange = ({ target }) => {
|
|
34
|
+
if (!this.state.didType) {
|
|
35
|
+
this.context.emitEvent('didSearch');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
clearTimeout(this.timer);
|
|
39
|
+
this.setState({ value: target.value, didType: !!target.value });
|
|
40
|
+
this.timer = setTimeout(() => this.triggerChange(target.value), WAIT);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
handleClick = () => {
|
|
44
|
+
this.setState({ value: '', didType: false });
|
|
45
|
+
this.triggerChange('');
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
triggerChange = value => {
|
|
49
|
+
const method = value ? 'push' : 'remove';
|
|
50
|
+
const params = method === 'push' ? { _q: value, page: 1 } : { _q: '' };
|
|
51
|
+
|
|
52
|
+
this.props.changeParams(params, method);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
render() {
|
|
56
|
+
const { model } = this.props;
|
|
57
|
+
const { value } = this.state;
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<FormattedMessage id={getTrad('components.Search.placeholder')}>
|
|
61
|
+
{placeholder => (
|
|
62
|
+
<HeaderSearch
|
|
63
|
+
label={upperFirst(model)}
|
|
64
|
+
onChange={this.handleChange}
|
|
65
|
+
onClear={this.handleClick}
|
|
66
|
+
placeholder={placeholder}
|
|
67
|
+
value={value}
|
|
68
|
+
/>
|
|
69
|
+
)}
|
|
70
|
+
</FormattedMessage>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Search.defaultProps = {
|
|
76
|
+
changeParams: () => {},
|
|
77
|
+
model: '',
|
|
78
|
+
value: '',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
Search.propTypes = {
|
|
82
|
+
changeParams: PropTypes.func,
|
|
83
|
+
initValue: PropTypes.string.isRequired,
|
|
84
|
+
model: PropTypes.string,
|
|
85
|
+
value: PropTypes.string,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export default memo(Search);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { FormattedMessage } from 'react-intl';
|
|
4
|
+
|
|
5
|
+
import pluginId from '../../pluginId';
|
|
6
|
+
import Title from './Title';
|
|
7
|
+
|
|
8
|
+
const SectionTitle = ({ isSettings }) => {
|
|
9
|
+
const suffix = isSettings ? 'settings' : 'view';
|
|
10
|
+
const msgId = `${pluginId}.containers.SettingPage.${suffix}`;
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<div style={{ marginBottom: '18px' }}>
|
|
14
|
+
<FormattedMessage id={msgId}>
|
|
15
|
+
{msg => <Title>{msg}</Title>}
|
|
16
|
+
</FormattedMessage>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
SectionTitle.propTypes = {
|
|
22
|
+
isSettings: PropTypes.bool,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
SectionTitle.defaultProps = {
|
|
26
|
+
isSettings: false,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default memo(SectionTitle);
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React, { memo, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useDrag, useDrop } from 'react-dnd';
|
|
4
|
+
import { getEmptyImage } from 'react-dnd-html5-backend';
|
|
5
|
+
import { has } from 'lodash';
|
|
6
|
+
|
|
7
|
+
import pluginId from '../../pluginId';
|
|
8
|
+
import ItemTypes from '../../utils/ItemTypes';
|
|
9
|
+
|
|
10
|
+
import { Li } from './components';
|
|
11
|
+
import Relation from './Relation';
|
|
12
|
+
|
|
13
|
+
function ListItem({
|
|
14
|
+
data,
|
|
15
|
+
displayNavigationLink,
|
|
16
|
+
findRelation,
|
|
17
|
+
isDisabled,
|
|
18
|
+
mainField,
|
|
19
|
+
moveRelation,
|
|
20
|
+
onRemove,
|
|
21
|
+
searchToPersist,
|
|
22
|
+
targetModel,
|
|
23
|
+
}) {
|
|
24
|
+
const to = `/plugins/${pluginId}/collectionType/${targetModel}/${data.id}`;
|
|
25
|
+
|
|
26
|
+
const hasDraftAndPublish = has(data, 'published_at');
|
|
27
|
+
|
|
28
|
+
const originalIndex = findRelation(data.id).index;
|
|
29
|
+
const [{ isDragging }, drag, preview] = useDrag({
|
|
30
|
+
item: {
|
|
31
|
+
type: ItemTypes.RELATION,
|
|
32
|
+
id: data.id,
|
|
33
|
+
originalIndex,
|
|
34
|
+
data,
|
|
35
|
+
hasDraftAndPublish,
|
|
36
|
+
mainField,
|
|
37
|
+
},
|
|
38
|
+
collect: monitor => ({
|
|
39
|
+
isDragging: monitor.isDragging(),
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
const [, drop] = useDrop({
|
|
43
|
+
accept: ItemTypes.RELATION,
|
|
44
|
+
canDrop: () => false,
|
|
45
|
+
hover({ id: draggedId }) {
|
|
46
|
+
if (draggedId !== data.id) {
|
|
47
|
+
const { index: overIndex } = findRelation(data.id);
|
|
48
|
+
moveRelation(draggedId, overIndex);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
preview(getEmptyImage(), { captureDraggingState: true });
|
|
55
|
+
}, [preview]);
|
|
56
|
+
|
|
57
|
+
const opacity = isDragging ? 0.2 : 1;
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Li
|
|
61
|
+
ref={node => {
|
|
62
|
+
if (!isDisabled) {
|
|
63
|
+
drag(drop(node));
|
|
64
|
+
}
|
|
65
|
+
}}
|
|
66
|
+
style={{ opacity }}
|
|
67
|
+
>
|
|
68
|
+
<Relation
|
|
69
|
+
displayNavigationLink={displayNavigationLink}
|
|
70
|
+
hasDraftAndPublish={hasDraftAndPublish}
|
|
71
|
+
mainField={mainField}
|
|
72
|
+
onRemove={onRemove}
|
|
73
|
+
data={data}
|
|
74
|
+
to={to}
|
|
75
|
+
isDisabled={isDisabled}
|
|
76
|
+
searchToPersist={searchToPersist}
|
|
77
|
+
/>
|
|
78
|
+
</Li>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
ListItem.defaultProps = {
|
|
83
|
+
findRelation: () => {},
|
|
84
|
+
moveRelation: () => {},
|
|
85
|
+
onRemove: () => {},
|
|
86
|
+
searchToPersist: null,
|
|
87
|
+
targetModel: '',
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
ListItem.propTypes = {
|
|
91
|
+
data: PropTypes.object.isRequired,
|
|
92
|
+
displayNavigationLink: PropTypes.bool.isRequired,
|
|
93
|
+
findRelation: PropTypes.func,
|
|
94
|
+
isDisabled: PropTypes.bool.isRequired,
|
|
95
|
+
mainField: PropTypes.shape({
|
|
96
|
+
name: PropTypes.string.isRequired,
|
|
97
|
+
schema: PropTypes.shape({
|
|
98
|
+
type: PropTypes.string.isRequired,
|
|
99
|
+
}).isRequired,
|
|
100
|
+
}).isRequired,
|
|
101
|
+
moveRelation: PropTypes.func,
|
|
102
|
+
onRemove: PropTypes.func,
|
|
103
|
+
searchToPersist: PropTypes.string,
|
|
104
|
+
targetModel: PropTypes.string,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default memo(ListItem);
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
2
|
+
import React, { memo, useMemo } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { Link, useLocation } from 'react-router-dom';
|
|
5
|
+
import { isEmpty } from 'lodash';
|
|
6
|
+
import { useIntl } from 'react-intl';
|
|
7
|
+
import { RelationDPState } from 'strapi-helper-plugin';
|
|
8
|
+
import { getDisplayedValue, getTrad } from '../../utils';
|
|
9
|
+
import IconRemove from '../../assets/images/icon_remove.svg';
|
|
10
|
+
import { Span } from './components';
|
|
11
|
+
|
|
12
|
+
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
13
|
+
|
|
14
|
+
const Relation = ({
|
|
15
|
+
data,
|
|
16
|
+
displayNavigationLink,
|
|
17
|
+
hasDraftAndPublish,
|
|
18
|
+
isDisabled,
|
|
19
|
+
isDragging,
|
|
20
|
+
mainField,
|
|
21
|
+
onRemove,
|
|
22
|
+
searchToPersist,
|
|
23
|
+
to,
|
|
24
|
+
}) => {
|
|
25
|
+
const { formatMessage } = useIntl();
|
|
26
|
+
const cursor = useMemo(() => {
|
|
27
|
+
if (isDisabled) {
|
|
28
|
+
return 'not-allowed';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!displayNavigationLink) {
|
|
32
|
+
return 'default';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return 'pointer';
|
|
36
|
+
}, [displayNavigationLink, isDisabled]);
|
|
37
|
+
const { pathname } = useLocation();
|
|
38
|
+
const isDraft = isEmpty(data.published_at);
|
|
39
|
+
const titleLabelID = isDraft
|
|
40
|
+
? 'components.Select.draft-info-title'
|
|
41
|
+
: 'components.Select.publish-info-title';
|
|
42
|
+
let title = hasDraftAndPublish
|
|
43
|
+
? formatMessage({ id: getTrad(titleLabelID) })
|
|
44
|
+
: formatMessage({ id: getTrad('containers.Edit.clickToJump') });
|
|
45
|
+
|
|
46
|
+
const value = data[mainField.name];
|
|
47
|
+
const formattedValue = getDisplayedValue(mainField.schema.type, value, mainField.name);
|
|
48
|
+
|
|
49
|
+
if (isDragging || !displayNavigationLink) {
|
|
50
|
+
title = '';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<>
|
|
55
|
+
<div style={{ cursor }} title={title}>
|
|
56
|
+
<div className="dragHandle">
|
|
57
|
+
<span />
|
|
58
|
+
</div>
|
|
59
|
+
{hasDraftAndPublish && (
|
|
60
|
+
<div>
|
|
61
|
+
<RelationDPState isDraft={isDraft} />
|
|
62
|
+
</div>
|
|
63
|
+
)}
|
|
64
|
+
{displayNavigationLink ? (
|
|
65
|
+
<Link
|
|
66
|
+
to={{ pathname: to, state: { from: pathname }, search: searchToPersist }}
|
|
67
|
+
title={title}
|
|
68
|
+
>
|
|
69
|
+
<Span>{formattedValue} </Span>
|
|
70
|
+
</Link>
|
|
71
|
+
) : (
|
|
72
|
+
<Span>{formattedValue} </Span>
|
|
73
|
+
)}
|
|
74
|
+
</div>
|
|
75
|
+
<div style={{ cursor, width: 'auto' }}>
|
|
76
|
+
<img src={IconRemove} alt="Remove Icon" onClick={onRemove} />
|
|
77
|
+
</div>
|
|
78
|
+
</>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
Relation.defaultProps = {
|
|
83
|
+
isDragging: false,
|
|
84
|
+
onRemove: () => {},
|
|
85
|
+
searchToPersist: null,
|
|
86
|
+
to: '',
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
Relation.propTypes = {
|
|
90
|
+
data: PropTypes.object.isRequired,
|
|
91
|
+
displayNavigationLink: PropTypes.bool.isRequired,
|
|
92
|
+
hasDraftAndPublish: PropTypes.bool.isRequired,
|
|
93
|
+
isDisabled: PropTypes.bool.isRequired,
|
|
94
|
+
isDragging: PropTypes.bool,
|
|
95
|
+
mainField: PropTypes.shape({
|
|
96
|
+
name: PropTypes.string.isRequired,
|
|
97
|
+
schema: PropTypes.shape({
|
|
98
|
+
type: PropTypes.string.isRequired,
|
|
99
|
+
}).isRequired,
|
|
100
|
+
}).isRequired,
|
|
101
|
+
onRemove: PropTypes.func,
|
|
102
|
+
searchToPersist: PropTypes.string,
|
|
103
|
+
to: PropTypes.string,
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default memo(Relation);
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
const ListWrapper = styled.div`
|
|
4
|
+
max-height: 116px;
|
|
5
|
+
|
|
6
|
+
> ul {
|
|
7
|
+
margin: 0 -20px 0;
|
|
8
|
+
padding: 0 20px !important;
|
|
9
|
+
list-style: none !important;
|
|
10
|
+
overflow: auto;
|
|
11
|
+
max-height: 110px;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
const ListShadow = styled.div`
|
|
16
|
+
position: relative;
|
|
17
|
+
display: inline-block;
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 0px;
|
|
20
|
+
|
|
21
|
+
&:after {
|
|
22
|
+
position: absolute;
|
|
23
|
+
top: -15px;
|
|
24
|
+
left: -5px;
|
|
25
|
+
content: '';
|
|
26
|
+
display: inline-block;
|
|
27
|
+
width: calc(100% + 10px);
|
|
28
|
+
height: 1px;
|
|
29
|
+
margin-bottom: -25px;
|
|
30
|
+
box-shadow: 0px -2px 4px 0px rgba(227, 233, 243, 0.5);
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
const Li = styled.li`
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-wrap: nowrap;
|
|
37
|
+
align-content: center;
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
height: 18px;
|
|
40
|
+
margin-top: 9px;
|
|
41
|
+
line-height: 1;
|
|
42
|
+
&:last-of-type {
|
|
43
|
+
margin-bottom: 0px;
|
|
44
|
+
}
|
|
45
|
+
&:active {
|
|
46
|
+
.dragHandle {
|
|
47
|
+
> span {
|
|
48
|
+
background: #aed4fb;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.dragHandle {
|
|
54
|
+
outline: none;
|
|
55
|
+
text-decoration: none;
|
|
56
|
+
margin-top: -1px;
|
|
57
|
+
|
|
58
|
+
> span {
|
|
59
|
+
vertical-align: middle;
|
|
60
|
+
position: relative;
|
|
61
|
+
display: inline-block;
|
|
62
|
+
width: 6px;
|
|
63
|
+
height: 1px;
|
|
64
|
+
padding: 0px !important;
|
|
65
|
+
background: #b3b5b9;
|
|
66
|
+
overflow: visible !important;
|
|
67
|
+
transition: background 0.25s ease-out;
|
|
68
|
+
|
|
69
|
+
&:before,
|
|
70
|
+
&:after {
|
|
71
|
+
content: '';
|
|
72
|
+
display: inline-block;
|
|
73
|
+
width: 6px;
|
|
74
|
+
height: 1px;
|
|
75
|
+
background: inherit;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&:before {
|
|
79
|
+
position: absolute;
|
|
80
|
+
top: -2px;
|
|
81
|
+
left: 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&:after {
|
|
85
|
+
position: absolute;
|
|
86
|
+
bottom: -2px;
|
|
87
|
+
left: 0;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
> div {
|
|
93
|
+
width: 90%;
|
|
94
|
+
> a {
|
|
95
|
+
flex-grow: 2;
|
|
96
|
+
max-width: 100%;
|
|
97
|
+
color: rgb(35, 56, 77);
|
|
98
|
+
}
|
|
99
|
+
> a:hover {
|
|
100
|
+
text-decoration: none;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&:first-of-type {
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
transition: color 0.25s ease-out;
|
|
107
|
+
|
|
108
|
+
&:hover {
|
|
109
|
+
.dragHandle {
|
|
110
|
+
> span {
|
|
111
|
+
background: #007eff;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
> a {
|
|
115
|
+
color: #007eff;
|
|
116
|
+
}
|
|
117
|
+
color: #007eff;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
span {
|
|
121
|
+
&:last-of-type {
|
|
122
|
+
padding-left: 10px;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&:last-of-type {
|
|
128
|
+
display: inline-block;
|
|
129
|
+
height: 100%;
|
|
130
|
+
padding-right: 0px;
|
|
131
|
+
line-height: 18px;
|
|
132
|
+
text-align: right;
|
|
133
|
+
white-space: nowrap;
|
|
134
|
+
overflow: hidden;
|
|
135
|
+
text-overflow: ellipsis;
|
|
136
|
+
|
|
137
|
+
img {
|
|
138
|
+
display: inline-block;
|
|
139
|
+
height: 14px;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
`;
|
|
144
|
+
|
|
145
|
+
const Span = styled.span`
|
|
146
|
+
display: block;
|
|
147
|
+
max-width: calc(100% - 10px);
|
|
148
|
+
overflow: hidden;
|
|
149
|
+
text-overflow: ellipsis;
|
|
150
|
+
white-space: nowrap;
|
|
151
|
+
`;
|
|
152
|
+
|
|
153
|
+
export { ListShadow, ListWrapper, Li, Span };
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import React, { memo, useCallback } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { isEmpty } from 'lodash';
|
|
4
|
+
import { useDrop } from 'react-dnd';
|
|
5
|
+
import Select, { createFilter } from 'react-select';
|
|
6
|
+
import ItemTypes from '../../utils/ItemTypes';
|
|
7
|
+
import { ListShadow, ListWrapper } from './components';
|
|
8
|
+
import ListItem from './ListItem';
|
|
9
|
+
|
|
10
|
+
function SelectMany({
|
|
11
|
+
addRelation,
|
|
12
|
+
components,
|
|
13
|
+
displayNavigationLink,
|
|
14
|
+
mainField,
|
|
15
|
+
name,
|
|
16
|
+
isDisabled,
|
|
17
|
+
isLoading,
|
|
18
|
+
move,
|
|
19
|
+
onInputChange,
|
|
20
|
+
onMenuClose,
|
|
21
|
+
onMenuOpen,
|
|
22
|
+
onMenuScrollToBottom,
|
|
23
|
+
onRemove,
|
|
24
|
+
options,
|
|
25
|
+
placeholder,
|
|
26
|
+
searchToPersist,
|
|
27
|
+
styles,
|
|
28
|
+
targetModel,
|
|
29
|
+
value,
|
|
30
|
+
}) {
|
|
31
|
+
const [, drop] = useDrop({ accept: ItemTypes.RELATION });
|
|
32
|
+
const findRelation = id => {
|
|
33
|
+
const relation = value.filter(c => {
|
|
34
|
+
return `${c.id}` === `${id}`;
|
|
35
|
+
})[0];
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
relation,
|
|
39
|
+
index: value.indexOf(relation),
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const moveRelation = useCallback(
|
|
44
|
+
(id, atIndex) => {
|
|
45
|
+
const { index } = findRelation(id);
|
|
46
|
+
|
|
47
|
+
move(index, atIndex, name);
|
|
48
|
+
},
|
|
49
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
50
|
+
[value]
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const filterConfig = {
|
|
54
|
+
ignoreCase: true,
|
|
55
|
+
ignoreAccents: true,
|
|
56
|
+
trim: false,
|
|
57
|
+
matchFrom: 'any',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
<Select
|
|
63
|
+
components={components}
|
|
64
|
+
isDisabled={isDisabled}
|
|
65
|
+
id={name}
|
|
66
|
+
filterOption={(candidate, input) => {
|
|
67
|
+
if (!isEmpty(value)) {
|
|
68
|
+
const isSelected = value.findIndex(item => item.id === candidate.value.id) !== -1;
|
|
69
|
+
|
|
70
|
+
if (isSelected) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (input) {
|
|
76
|
+
return createFilter(filterConfig)(candidate, input);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return true;
|
|
80
|
+
}}
|
|
81
|
+
mainField={mainField}
|
|
82
|
+
isLoading={isLoading}
|
|
83
|
+
isMulti
|
|
84
|
+
isSearchable
|
|
85
|
+
options={options}
|
|
86
|
+
onChange={addRelation}
|
|
87
|
+
onInputChange={onInputChange}
|
|
88
|
+
onMenuClose={onMenuClose}
|
|
89
|
+
onMenuOpen={onMenuOpen}
|
|
90
|
+
onMenuScrollToBottom={onMenuScrollToBottom}
|
|
91
|
+
placeholder={placeholder}
|
|
92
|
+
styles={styles}
|
|
93
|
+
value={[]}
|
|
94
|
+
/>
|
|
95
|
+
|
|
96
|
+
<ListWrapper ref={drop}>
|
|
97
|
+
{!isEmpty(value) && (
|
|
98
|
+
<ul>
|
|
99
|
+
{value.map((data, index) => (
|
|
100
|
+
<ListItem
|
|
101
|
+
key={data.id}
|
|
102
|
+
data={data}
|
|
103
|
+
displayNavigationLink={displayNavigationLink}
|
|
104
|
+
isDisabled={isDisabled}
|
|
105
|
+
findRelation={findRelation}
|
|
106
|
+
mainField={mainField}
|
|
107
|
+
moveRelation={moveRelation}
|
|
108
|
+
onRemove={() => {
|
|
109
|
+
if (!isDisabled) {
|
|
110
|
+
onRemove(`${name}.${index}`);
|
|
111
|
+
}
|
|
112
|
+
}}
|
|
113
|
+
searchToPersist={searchToPersist}
|
|
114
|
+
targetModel={targetModel}
|
|
115
|
+
/>
|
|
116
|
+
))}
|
|
117
|
+
</ul>
|
|
118
|
+
)}
|
|
119
|
+
{!isEmpty(value) && value.length > 4 && <ListShadow />}
|
|
120
|
+
</ListWrapper>
|
|
121
|
+
</>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
SelectMany.defaultProps = {
|
|
126
|
+
components: {},
|
|
127
|
+
move: () => {},
|
|
128
|
+
searchToPersist: null,
|
|
129
|
+
value: null,
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
SelectMany.propTypes = {
|
|
133
|
+
addRelation: PropTypes.func.isRequired,
|
|
134
|
+
components: PropTypes.object,
|
|
135
|
+
displayNavigationLink: PropTypes.bool.isRequired,
|
|
136
|
+
isDisabled: PropTypes.bool.isRequired,
|
|
137
|
+
isLoading: PropTypes.bool.isRequired,
|
|
138
|
+
mainField: PropTypes.shape({
|
|
139
|
+
name: PropTypes.string.isRequired,
|
|
140
|
+
schema: PropTypes.shape({
|
|
141
|
+
type: PropTypes.string.isRequired,
|
|
142
|
+
}).isRequired,
|
|
143
|
+
}).isRequired,
|
|
144
|
+
move: PropTypes.func,
|
|
145
|
+
name: PropTypes.string.isRequired,
|
|
146
|
+
onInputChange: PropTypes.func.isRequired,
|
|
147
|
+
onMenuClose: PropTypes.func.isRequired,
|
|
148
|
+
onMenuOpen: PropTypes.func.isRequired,
|
|
149
|
+
onMenuScrollToBottom: PropTypes.func.isRequired,
|
|
150
|
+
onRemove: PropTypes.func.isRequired,
|
|
151
|
+
options: PropTypes.array.isRequired,
|
|
152
|
+
placeholder: PropTypes.node.isRequired,
|
|
153
|
+
searchToPersist: PropTypes.string,
|
|
154
|
+
styles: PropTypes.object.isRequired,
|
|
155
|
+
targetModel: PropTypes.string.isRequired,
|
|
156
|
+
value: PropTypes.array,
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export default memo(SelectMany);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { components } from 'react-select';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { get, has, isEmpty } from 'lodash';
|
|
5
|
+
import { Flex, Padded, Text } from '@buffetjs/core';
|
|
6
|
+
import { RelationDPState } from 'strapi-helper-plugin';
|
|
7
|
+
import { getDisplayedValue } from '../../utils';
|
|
8
|
+
|
|
9
|
+
const SingleValue = props => {
|
|
10
|
+
const Component = components.SingleValue;
|
|
11
|
+
const hasDraftAndPublish = has(get(props, 'data.value'), 'published_at');
|
|
12
|
+
const isDraft = isEmpty(get(props, 'data.value.published_at'));
|
|
13
|
+
const mainField = get(props, ['selectProps', 'mainField'], {});
|
|
14
|
+
const value = getDisplayedValue(mainField.schema.type, props.data.label, mainField.name);
|
|
15
|
+
|
|
16
|
+
if (hasDraftAndPublish) {
|
|
17
|
+
return (
|
|
18
|
+
<Component {...props}>
|
|
19
|
+
<Padded left size="sm" right>
|
|
20
|
+
<Flex>
|
|
21
|
+
<RelationDPState
|
|
22
|
+
marginLeft="0"
|
|
23
|
+
marginTop="1px"
|
|
24
|
+
marginRight="10px"
|
|
25
|
+
isDraft={isDraft}
|
|
26
|
+
marginBottom="0"
|
|
27
|
+
/>
|
|
28
|
+
<div>
|
|
29
|
+
<Text ellipsis>{value}</Text>
|
|
30
|
+
</div>
|
|
31
|
+
</Flex>
|
|
32
|
+
</Padded>
|
|
33
|
+
</Component>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Component {...props}>
|
|
39
|
+
<Padded left right size="sm">
|
|
40
|
+
{value}
|
|
41
|
+
</Padded>
|
|
42
|
+
</Component>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
SingleValue.propTypes = {
|
|
47
|
+
data: PropTypes.object.isRequired,
|
|
48
|
+
selectProps: PropTypes.shape({
|
|
49
|
+
mainField: PropTypes.shape({
|
|
50
|
+
name: PropTypes.string.isRequired,
|
|
51
|
+
schema: PropTypes.shape({
|
|
52
|
+
type: PropTypes.string.isRequired,
|
|
53
|
+
}).isRequired,
|
|
54
|
+
}).isRequired,
|
|
55
|
+
}).isRequired,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default SingleValue;
|