Skip to content

Commit

Permalink
feat: impove attached files screen
Browse files Browse the repository at this point in the history
  • Loading branch information
vhu-axelor authored and lme-axelor committed Dec 17, 2024
1 parent c069c5a commit 087e9c0
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 6 deletions.
5 changes: 5 additions & 0 deletions changelogs/unreleased/88612_SearchTreeView.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"title": "SearchTreeView: add possibility to hide parent search bar",
"type": "feat",
"packages": "core"
}
5 changes: 5 additions & 0 deletions changelogs/unreleased/88612_TreeView.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"title": "TreeView: add possibility to hide branch filter quick action",
"type": "feat",
"packages": "ui"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -152,6 +156,7 @@ const DocumentList = ({defaultParent}: DocumentListProps) => {
}
displayBreadcrumb
defaultParent={defaultParent}
isParentSearchBarVisible={!isAttachedFilesList}
/>
</Screen>
);
Expand Down
4 changes: 3 additions & 1 deletion packages/apps/dms/src/screens/AttachedFilesScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ const AttachedFilesScreen = ({navigation, route}) => {

return (
<>
{!isVisible && <DocumentList defaultParent={parent} />}
{!isVisible && (
<DocumentList defaultParent={parent} isAttachedFilesList />
)}
<Alert
visible={isVisible}
title={I18n.t('Dms_NoAttachedFiles')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ interface SearchTreeViewProps {
verticalActions?: boolean;
displayBreadcrumb?: boolean;
defaultParent?: any;
isParentSearchBarVisible?: boolean;
}

const SearchTreeView = ({
Expand Down Expand Up @@ -109,6 +110,7 @@ const SearchTreeView = ({
verticalActions,
displayBreadcrumb = false,
defaultParent,
isParentSearchBarVisible = true,
}: SearchTreeViewProps) => {
const I18n = useTranslator();
const dispatch = useDispatch();
Expand Down Expand Up @@ -252,7 +254,9 @@ const SearchTreeView = ({
topChildren={
<>
{headerTopChildren}
{isHideableParentSearch && renderParentSearchBar()}
{isHideableParentSearch &&
isParentSearchBarVisible &&
renderParentSearchBar()}
</>
}
fixedItems={
Expand All @@ -271,6 +275,7 @@ const SearchTreeView = ({
{displayBreadcrumb && (
<Breadcrumb
style={styles.breadcrumb}
disabled={!isParentSearchBarVisible}
items={parent.map((item, index) =>
item === EMPTY_PARENT
? EMPTY_PARENT
Expand All @@ -295,6 +300,7 @@ const SearchTreeView = ({
fetchBranchData={fetchBranchData}
branchCondition={branchCondition}
onBranchFilterPress={handleChangeParent}
isBranchFilterVisible={isParentSearchBarVisible}
moreLoading={moreLoading}
isListEnd={isListEnd}
translator={I18n.t}
Expand Down
16 changes: 13 additions & 3 deletions packages/ui/src/components/molecules/Breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -86,7 +92,11 @@ const Breadcrumb = ({style, items, onHomePress}: BreadcrumbProps) => {
<View
style={[styles.container, style]}
onLayout={e => setContainerWidth(e?.nativeEvent?.layout?.width)}>
<Icon name="house-door-fill" touchable onPress={onHomePress} />
<Icon
name="house-door-fill"
touchable={!disabled}
onPress={onHomePress}
/>
{visibleItems.map((item, index) => (
<View
style={styles.contentContainer}
Expand All @@ -96,7 +106,7 @@ const Breadcrumb = ({style, items, onHomePress}: BreadcrumbProps) => {
<TouchableOpacity
style={styles.textContainer}
activeOpacity={0.7}
disabled={!item.onPress}
disabled={disabled || !item.onPress}
onPress={item.onPress}>
<Text>{item.title}</Text>
</TouchableOpacity>
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/src/components/templates/TreeView/Branch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ interface BranchProps {
fetchBranchData: (idParent: number) => Promise<any>;
branchCondition: (item: any) => boolean;
onBranchFilterPress: (branch: any) => void;
isBranchFilterVisible?: boolean;
translator: (translationKey: string) => string;
}

Expand All @@ -148,6 +149,7 @@ const Branch = ({
fetchBranchData,
branchCondition,
onBranchFilterPress,
isBranchFilterVisible,
translator,
}: BranchProps) => {
const handleBranchPress = useCallback(() => {
Expand Down Expand Up @@ -194,6 +196,7 @@ const Branch = ({
isOpen={isBranchOpen}
parent={branch.item}
onFilterPress={onBranchFilterPress}
isBranchFilterVisible={isBranchFilterVisible}
infoButtonIndication={branchCardInfoButtonIndication}
actionList={getBranchActions?.(branch)}
translator={translator}
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/src/components/templates/TreeView/BranchCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ interface BranchActionCardProps {
isOpen: boolean;
parent: any;
onFilterPress: (branch: any) => void;
isBranchFilterVisible?: boolean;
infoButtonIndication: string;
actionList?: ActionCardType[];
translator: (translationKey: string) => string;
Expand All @@ -75,6 +76,7 @@ const BranchActionCard = ({
isOpen,
parent,
onFilterPress,
isBranchFilterVisible,
infoButtonIndication,
actionList = [],
translator,
Expand All @@ -87,6 +89,7 @@ const BranchActionCard = ({
helper: infoButtonIndication,
large: true,
onPress: () => onFilterPress(parent),
hidden: !isBranchFilterVisible,
}}
translator={translator}>
<BranchCard onPress={onPress} children={children} isOpen={isOpen} />
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/src/components/templates/TreeView/TreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ interface TreeViewProps {
*/
branchCondition: (item: any) => boolean;
onBranchFilterPress: (branch: any) => void;
isBranchFilterVisible?: boolean;
moreLoading: boolean;
isListEnd: boolean;
filter?: boolean;
Expand All @@ -75,6 +76,7 @@ const TreeView = ({
fetchBranchData,
branchCondition,
onBranchFilterPress,
isBranchFilterVisible = true,
moreLoading = false,
isListEnd = false,
filter = false,
Expand Down Expand Up @@ -104,6 +106,7 @@ const TreeView = ({
fetchBranchData={fetchBranchData}
branchCondition={branchCondition}
onBranchFilterPress={onBranchFilterPress}
isBranchFilterVisible={isBranchFilterVisible}
translator={translator}
/>
) : (
Expand Down

0 comments on commit 087e9c0

Please sign in to comment.