diff --git a/changelogs/unreleased/88573.json b/changelogs/unreleased/88573.json new file mode 100644 index 0000000000..685c733cb5 --- /dev/null +++ b/changelogs/unreleased/88573.json @@ -0,0 +1,5 @@ +{ + "title": "SearchTreeView: add onParentChange props to get parent update", + "type": "feat", + "packages": "core" +} diff --git a/packages/apps/dms/src/components/organisms/ParentDirectorySearchBar/ParentDirectorySearchBar.tsx b/packages/apps/dms/src/components/organisms/ParentDirectorySearchBar/ParentDirectorySearchBar.tsx index 3bd53da62f..341ed0b752 100644 --- a/packages/apps/dms/src/components/organisms/ParentDirectorySearchBar/ParentDirectorySearchBar.tsx +++ b/packages/apps/dms/src/components/organisms/ParentDirectorySearchBar/ParentDirectorySearchBar.tsx @@ -16,9 +16,10 @@ * along with this program. If not, see . */ -import React, {useCallback, useMemo} from 'react'; +import React, {useCallback} from 'react'; +import {StyleSheet} from 'react-native'; import {useDispatch, useSelector, useTranslator} from '@axelor/aos-mobile-core'; -import {AutoCompleteSearch} from '@axelor/aos-mobile-ui'; +import {AutoCompleteSearch, Label} from '@axelor/aos-mobile-ui'; import {searchDirectory} from '../../../features/documentSlice'; interface ParentDirectorySearchBarProps { @@ -28,6 +29,7 @@ interface ParentDirectorySearchBarProps { onChange?: (any: any) => void; readonly?: boolean; required?: boolean; + displayRootInfo?: boolean; } const ParentDirectorySearchBar = ({ @@ -37,12 +39,11 @@ const ParentDirectorySearchBar = ({ onChange = () => {}, readonly = false, required = false, + displayRootInfo = false, }: ParentDirectorySearchBarProps) => { const I18n = useTranslator(); const dispatch = useDispatch(); - const {user} = useSelector(state => state.user); - const {mobileSettings} = useSelector(state => state.appConfig); const { loadingDirectory, moreLoadingDirectory, @@ -50,17 +51,6 @@ const ParentDirectorySearchBar = ({ directoryList, } = useSelector(state => state.dms_document); - const extendedDirectoryList = useMemo( - () => [ - { - ...(user.dmsRoot ?? mobileSettings?.defaultDmsRoot), - fileName: I18n.t('Dms_Root'), - }, - ...directoryList, - ], - [I18n, directoryList, mobileSettings?.defaultDmsRoot, user.dmsRoot], - ); - const searchParentDirectoryAPI = useCallback( ({searchValue, page = 0}) => { dispatch((searchDirectory as any)({searchValue, page})); @@ -69,26 +59,42 @@ const ParentDirectorySearchBar = ({ ); return ( - item.fileName} - placeholder={I18n.t(title)} - showDetailsPopup={true} - loadingList={loadingDirectory} - moreLoading={moreLoadingDirectory} - isListEnd={isListEndDirectory} - navigate={false} - oneFilter={false} - translator={I18n.t} - /> + <> + {displayRootInfo && defaultValue == null && ( +