From 087e9c0e55b6ead0f5616327dff16cbf7e6e53f8 Mon Sep 17 00:00:00 2001 From: vhu-axelor <146069039+vhu-axelor@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:52:22 +0100 Subject: [PATCH 1/3] feat: impove attached files screen --- changelogs/unreleased/88612_SearchTreeView.json | 5 +++++ changelogs/unreleased/88612_TreeView.json | 5 +++++ .../templates/DocumentList/DocumentList.tsx | 7 ++++++- .../apps/dms/src/screens/AttachedFilesScreen.tsx | 4 +++- .../templates/SearchTreeView/SearchTreeView.tsx | 8 +++++++- .../molecules/Breadcrumb/Breadcrumb.tsx | 16 +++++++++++++--- .../src/components/templates/TreeView/Branch.tsx | 3 +++ .../components/templates/TreeView/BranchCard.tsx | 3 +++ .../components/templates/TreeView/TreeView.tsx | 3 +++ 9 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 changelogs/unreleased/88612_SearchTreeView.json create mode 100644 changelogs/unreleased/88612_TreeView.json diff --git a/changelogs/unreleased/88612_SearchTreeView.json b/changelogs/unreleased/88612_SearchTreeView.json new file mode 100644 index 0000000000..2cf3bc73a9 --- /dev/null +++ b/changelogs/unreleased/88612_SearchTreeView.json @@ -0,0 +1,5 @@ +{ + "title": "SearchTreeView: add possibility to hide parent search bar", + "type": "feat", + "packages": "core" +} diff --git a/changelogs/unreleased/88612_TreeView.json b/changelogs/unreleased/88612_TreeView.json new file mode 100644 index 0000000000..f8fd70c309 --- /dev/null +++ b/changelogs/unreleased/88612_TreeView.json @@ -0,0 +1,5 @@ +{ + "title": "TreeView: add possibility to hide branch filter quick action", + "type": "feat", + "packages": "ui" +} diff --git a/packages/apps/dms/src/components/templates/DocumentList/DocumentList.tsx b/packages/apps/dms/src/components/templates/DocumentList/DocumentList.tsx index 9f0658346f..25decaed4f 100644 --- a/packages/apps/dms/src/components/templates/DocumentList/DocumentList.tsx +++ b/packages/apps/dms/src/components/templates/DocumentList/DocumentList.tsx @@ -38,9 +38,13 @@ import {File} from '../../../types'; interface DocumentListProps { defaultParent?: any; + isAttachedFilesList?: boolean; } -const DocumentList = ({defaultParent}: DocumentListProps) => { +const DocumentList = ({ + defaultParent, + isAttachedFilesList = false, +}: DocumentListProps) => { const I18n = useTranslator(); const Colors = useThemeColor(); const navigation = useNavigation(); @@ -152,6 +156,7 @@ const DocumentList = ({defaultParent}: DocumentListProps) => { } displayBreadcrumb defaultParent={defaultParent} + isParentSearchBarVisible={!isAttachedFilesList} /> ); diff --git a/packages/apps/dms/src/screens/AttachedFilesScreen.tsx b/packages/apps/dms/src/screens/AttachedFilesScreen.tsx index 21ff25934f..4160da239b 100644 --- a/packages/apps/dms/src/screens/AttachedFilesScreen.tsx +++ b/packages/apps/dms/src/screens/AttachedFilesScreen.tsx @@ -65,7 +65,9 @@ const AttachedFilesScreen = ({navigation, route}) => { return ( <> - {!isVisible && } + {!isVisible && ( + + )} { const I18n = useTranslator(); const dispatch = useDispatch(); @@ -252,7 +254,9 @@ const SearchTreeView = ({ topChildren={ <> {headerTopChildren} - {isHideableParentSearch && renderParentSearchBar()} + {isHideableParentSearch && + isParentSearchBarVisible && + renderParentSearchBar()} } fixedItems={ @@ -271,6 +275,7 @@ const SearchTreeView = ({ {displayBreadcrumb && ( item === EMPTY_PARENT ? EMPTY_PARENT @@ -295,6 +300,7 @@ const SearchTreeView = ({ fetchBranchData={fetchBranchData} branchCondition={branchCondition} onBranchFilterPress={handleChangeParent} + isBranchFilterVisible={isParentSearchBarVisible} moreLoading={moreLoading} isListEnd={isListEnd} translator={I18n.t} diff --git a/packages/ui/src/components/molecules/Breadcrumb/Breadcrumb.tsx b/packages/ui/src/components/molecules/Breadcrumb/Breadcrumb.tsx index c185c92fa7..5f39215bc1 100644 --- a/packages/ui/src/components/molecules/Breadcrumb/Breadcrumb.tsx +++ b/packages/ui/src/components/molecules/Breadcrumb/Breadcrumb.tsx @@ -32,11 +32,17 @@ interface Item { interface BreadcrumbProps { style?: any; + disabled?: boolean; items: Item[]; onHomePress: () => void; } -const Breadcrumb = ({style, items, onHomePress}: BreadcrumbProps) => { +const Breadcrumb = ({ + style, + disabled = false, + items, + onHomePress, +}: BreadcrumbProps) => { const Colors = useThemeColor(); const [visibleItems, setVisibleItems] = useState(items); @@ -86,7 +92,11 @@ const Breadcrumb = ({style, items, onHomePress}: BreadcrumbProps) => { setContainerWidth(e?.nativeEvent?.layout?.width)}> - + {visibleItems.map((item, index) => ( { {item.title} diff --git a/packages/ui/src/components/templates/TreeView/Branch.tsx b/packages/ui/src/components/templates/TreeView/Branch.tsx index d82c127cb5..c153dccf03 100644 --- a/packages/ui/src/components/templates/TreeView/Branch.tsx +++ b/packages/ui/src/components/templates/TreeView/Branch.tsx @@ -132,6 +132,7 @@ interface BranchProps { fetchBranchData: (idParent: number) => Promise; branchCondition: (item: any) => boolean; onBranchFilterPress: (branch: any) => void; + isBranchFilterVisible?: boolean; translator: (translationKey: string) => string; } @@ -148,6 +149,7 @@ const Branch = ({ fetchBranchData, branchCondition, onBranchFilterPress, + isBranchFilterVisible, translator, }: BranchProps) => { const handleBranchPress = useCallback(() => { @@ -194,6 +196,7 @@ const Branch = ({ isOpen={isBranchOpen} parent={branch.item} onFilterPress={onBranchFilterPress} + isBranchFilterVisible={isBranchFilterVisible} infoButtonIndication={branchCardInfoButtonIndication} actionList={getBranchActions?.(branch)} translator={translator} diff --git a/packages/ui/src/components/templates/TreeView/BranchCard.tsx b/packages/ui/src/components/templates/TreeView/BranchCard.tsx index 056fadb9be..58ca6c458a 100644 --- a/packages/ui/src/components/templates/TreeView/BranchCard.tsx +++ b/packages/ui/src/components/templates/TreeView/BranchCard.tsx @@ -64,6 +64,7 @@ interface BranchActionCardProps { isOpen: boolean; parent: any; onFilterPress: (branch: any) => void; + isBranchFilterVisible?: boolean; infoButtonIndication: string; actionList?: ActionCardType[]; translator: (translationKey: string) => string; @@ -75,6 +76,7 @@ const BranchActionCard = ({ isOpen, parent, onFilterPress, + isBranchFilterVisible, infoButtonIndication, actionList = [], translator, @@ -87,6 +89,7 @@ const BranchActionCard = ({ helper: infoButtonIndication, large: true, onPress: () => onFilterPress(parent), + hidden: !isBranchFilterVisible, }} translator={translator}> diff --git a/packages/ui/src/components/templates/TreeView/TreeView.tsx b/packages/ui/src/components/templates/TreeView/TreeView.tsx index 94e881c309..750ff598d9 100644 --- a/packages/ui/src/components/templates/TreeView/TreeView.tsx +++ b/packages/ui/src/components/templates/TreeView/TreeView.tsx @@ -52,6 +52,7 @@ interface TreeViewProps { */ branchCondition: (item: any) => boolean; onBranchFilterPress: (branch: any) => void; + isBranchFilterVisible?: boolean; moreLoading: boolean; isListEnd: boolean; filter?: boolean; @@ -75,6 +76,7 @@ const TreeView = ({ fetchBranchData, branchCondition, onBranchFilterPress, + isBranchFilterVisible = true, moreLoading = false, isListEnd = false, filter = false, @@ -104,6 +106,7 @@ const TreeView = ({ fetchBranchData={fetchBranchData} branchCondition={branchCondition} onBranchFilterPress={onBranchFilterPress} + isBranchFilterVisible={isBranchFilterVisible} translator={translator} /> ) : ( From e9e50586bf4152fdd5c622067707e60066bbe702 Mon Sep 17 00:00:00 2001 From: lme-axelor <102581501+lme-axelor@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:25:12 +0100 Subject: [PATCH 2/3] chore: update test & story --- .../__tests__/components/molecules/Breadcrumb.test.js | 10 ++++++++++ packages/ui/stories/molecules/Breadcrumb.stories.tsx | 1 + 2 files changed, 11 insertions(+) diff --git a/packages/ui/__tests__/components/molecules/Breadcrumb.test.js b/packages/ui/__tests__/components/molecules/Breadcrumb.test.js index 47a8c92548..542b80e526 100644 --- a/packages/ui/__tests__/components/molecules/Breadcrumb.test.js +++ b/packages/ui/__tests__/components/molecules/Breadcrumb.test.js @@ -89,6 +89,16 @@ describe('Breadcrumb Component', () => { expect(nonClickableItem.prop('onPress')).toBeUndefined(); }); + it('renders correctly when disabled', () => { + const wrapper = shallow(); + const items = wrapper.find(TouchableOpacity); + + items.forEach(_item => { + expect(_item.exists()).toBeTruthy(); + expect(_item.prop('disabled')).toBeTruthy(); + }); + }); + it('should apply custom styles to the container when style prop is provided', () => { const customStyle = { fontSize: 25, diff --git a/packages/ui/stories/molecules/Breadcrumb.stories.tsx b/packages/ui/stories/molecules/Breadcrumb.stories.tsx index 182ec5a4d7..ffd3930676 100644 --- a/packages/ui/stories/molecules/Breadcrumb.stories.tsx +++ b/packages/ui/stories/molecules/Breadcrumb.stories.tsx @@ -31,6 +31,7 @@ export default meta; export const Breadcrumb: Story = { args: { numberItems: 5, + disabled: false, }, argTypes: { items: disabledControl, From cc2fbabdea995b94e7fb84e651a6e109aa81964b Mon Sep 17 00:00:00 2001 From: lme-axelor <102581501+lme-axelor@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:55:20 +0100 Subject: [PATCH 3/3] refactor: rename props --- changelogs/unreleased/88612_SearchTreeView.json | 2 +- .../templates/DocumentList/DocumentList.tsx | 2 +- .../templates/SearchTreeView/SearchTreeView.tsx | 17 ++++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/changelogs/unreleased/88612_SearchTreeView.json b/changelogs/unreleased/88612_SearchTreeView.json index 2cf3bc73a9..bfe3386166 100644 --- a/changelogs/unreleased/88612_SearchTreeView.json +++ b/changelogs/unreleased/88612_SearchTreeView.json @@ -1,5 +1,5 @@ { - "title": "SearchTreeView: add possibility to hide parent search bar", + "title": "SearchTreeView: add possibility to remove management of parent filter", "type": "feat", "packages": "core" } diff --git a/packages/apps/dms/src/components/templates/DocumentList/DocumentList.tsx b/packages/apps/dms/src/components/templates/DocumentList/DocumentList.tsx index 25decaed4f..4e149e55a2 100644 --- a/packages/apps/dms/src/components/templates/DocumentList/DocumentList.tsx +++ b/packages/apps/dms/src/components/templates/DocumentList/DocumentList.tsx @@ -156,7 +156,7 @@ const DocumentList = ({ } displayBreadcrumb defaultParent={defaultParent} - isParentSearchBarVisible={!isAttachedFilesList} + manageParentFilter={!isAttachedFilesList} /> ); diff --git a/packages/core/src/components/templates/SearchTreeView/SearchTreeView.tsx b/packages/core/src/components/templates/SearchTreeView/SearchTreeView.tsx index 89ddd0e1dc..364cff7236 100644 --- a/packages/core/src/components/templates/SearchTreeView/SearchTreeView.tsx +++ b/packages/core/src/components/templates/SearchTreeView/SearchTreeView.tsx @@ -70,7 +70,7 @@ interface SearchTreeViewProps { verticalActions?: boolean; displayBreadcrumb?: boolean; defaultParent?: any; - isParentSearchBarVisible?: boolean; + manageParentFilter?: boolean; } const SearchTreeView = ({ @@ -110,7 +110,7 @@ const SearchTreeView = ({ verticalActions, displayBreadcrumb = false, defaultParent, - isParentSearchBarVisible = true, + manageParentFilter = true, }: SearchTreeViewProps) => { const I18n = useTranslator(); const dispatch = useDispatch(); @@ -202,6 +202,10 @@ const SearchTreeView = ({ }, [defaultParent, fetchListAPI, isFocused]); const renderParentSearchBar = useCallback(() => { + if (!manageParentFilter) { + return null; + } + return ( {headerTopChildren} - {isHideableParentSearch && - isParentSearchBarVisible && - renderParentSearchBar()} + {isHideableParentSearch && renderParentSearchBar()} } fixedItems={ @@ -275,7 +278,7 @@ const SearchTreeView = ({ {displayBreadcrumb && ( item === EMPTY_PARENT ? EMPTY_PARENT @@ -300,7 +303,7 @@ const SearchTreeView = ({ fetchBranchData={fetchBranchData} branchCondition={branchCondition} onBranchFilterPress={handleChangeParent} - isBranchFilterVisible={isParentSearchBarVisible} + isBranchFilterVisible={manageParentFilter} moreLoading={moreLoading} isListEnd={isListEnd} translator={I18n.t}