Skip to content

Commit 1a16bf8

Browse files
committed
expand/collapse attribute section
1 parent 955cc1c commit 1a16bf8

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

UI/web-app/src/components/HRQuerySource/HRQuerySource.base.tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT license.
33

44
import React, { useEffect, useRef, useState } from 'react';
5-
import { classNamesFunction, Stack, type IProcessedStyleSet, IStackTokens, Label, IconButton, TooltipHost, ChoiceGroup, IChoiceGroupOption, SpinButton, NormalPeoplePicker, DirectionalHint, IDropdownOption, ActionButton, DetailsList, DetailsListLayoutMode, Dropdown, Selection, IColumn, ComboBox, IComboBoxOption, IComboBox, IDropdownStyles} from '@fluentui/react';
5+
import { classNamesFunction, Stack, type IProcessedStyleSet, IStackTokens, Label, IconButton, TooltipHost, ChoiceGroup, IChoiceGroupOption, SpinButton, NormalPeoplePicker, DirectionalHint, IDropdownOption, ActionButton, DetailsList, DetailsListLayoutMode, Dropdown, Selection, IColumn, ComboBox, IComboBoxOption, IComboBox, IDropdownStyles, Separator} from '@fluentui/react';
66
import { useTheme } from '@fluentui/react/lib/Theme';
77
import { TextField } from '@fluentui/react/lib/TextField';
88
import { IPersonaProps } from '@fluentui/react/lib/Persona';
@@ -75,6 +75,7 @@ export const HRQuerySourceBase: React.FunctionComponent<HRQuerySourceProps> = (p
7575
const [selectedIndices, setSelectedIndices] = useState<number[]>([]);
7676
const [groupingEnabled, setGroupingEnabled] = useState(false);
7777
const [filterTextEnabled, setFilterTextEnabled] = useState(false);
78+
const [expanded, setExpanded] = useState(true);
7879

7980
useEffect(() => {
8081
if (!groupingEnabled) {
@@ -170,6 +171,10 @@ function setItemsBasedOnGroups(groups: Group[]) {
170171
setItems(items);
171172
}
172173

174+
const toggleExpand = () => {
175+
setExpanded(!expanded);
176+
};
177+
173178
const getGroupLabels = (groups: Group[]) => {
174179
const str = stringifyGroups(groups);
175180
const filter = str;
@@ -572,6 +577,7 @@ const checkType = (value: string, type: string | undefined): string => {
572577
const handleIncludeFilterChange = (ev?: React.FormEvent<HTMLElement | HTMLInputElement>, option?: IChoiceGroupOption) => {
573578
if (option?.key === "No") {
574579
setIncludeFilter(false);
580+
setExpanded(false);
575581
setFilteredOptions({});
576582
setFilteredValueOptions({});
577583
const filter = "";
@@ -586,6 +592,7 @@ const checkType = (value: string, type: string | undefined): string => {
586592
addComponent();
587593
}
588594
setIncludeFilter(true);
595+
setExpanded(true);
589596
dispatch(fetchDefaultSqlMembershipSourceAttributes());
590597
setSource(prevSource => {
591598
const newSource = { ...prevSource };
@@ -1664,6 +1671,21 @@ const checkType = (value: string, type: string | undefined): string => {
16641671
}}
16651672
/>
16661673

1674+
{(includeFilter || source.filter) &&
1675+
<div className={classNames.cardHeader}>
1676+
<div className={classNames.cardTitle}>
1677+
Attributes
1678+
</div>
1679+
<IconButton
1680+
iconProps={{ iconName: expanded ? 'ChevronUp' : 'ChevronDown' }}
1681+
styles={{ root: classNames.expandButton }}
1682+
onClick={toggleExpand}
1683+
title={strings.ManageMembership.labels.expandCollapse}
1684+
/>
1685+
</div>}
1686+
1687+
{(includeFilter || source.filter) && <Separator styles={{root: classNames.separator}} />}
1688+
16671689
{(source.filter && (filterTextEnabled || !attributes)) ?
16681690
(
16691691
<><div className={classNames.labelContainer}>
@@ -1682,7 +1704,7 @@ const checkType = (value: string, type: string | undefined): string => {
16821704
validateOnLoad={false}
16831705
validateOnFocusOut={false}
16841706
></TextField></>
1685-
) : attributes && attributes.length > 0 && (includeFilter || source.filter) ?
1707+
) : attributes && attributes.length > 0 && expanded && (includeFilter || source.filter) ?
16861708
(
16871709
<div>
16881710
<ActionButton
@@ -1700,7 +1722,7 @@ const checkType = (value: string, type: string | undefined): string => {
17001722
<br/>
17011723

17021724

1703-
{(groupingEnabled) ? (
1725+
{(groupingEnabled && expanded) ? (
17041726

17051727
<div>
17061728
{groups.map((group: Group, index: number) => (

UI/web-app/src/components/HRQuerySource/HRQuerySource.styles.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ export const getStyles = (props: HRQuerySourceStyleProps): HRQuerySourceStyles =
2727
'> *': { marginRight: '20px' },
2828
flexWrap: 'wrap'
2929
},
30+
expandButton: {
31+
fontSize: 12,
32+
height: 14
33+
},
34+
separator: {
35+
minWidth: 1200
36+
},
37+
cardHeader: {
38+
display: 'flex',
39+
flexDirection: 'row',
40+
alignItems: 'space-between',
41+
marginTop: 50,
42+
minWidth: 1200
43+
},
44+
cardTitle: {
45+
flex: 1,
46+
fontSize: 16,
47+
fontStyle: 'normal',
48+
fontWeight: 'normal',
49+
lineHeight: '22px'
50+
},
3051
labelContainer: {
3152
display: 'flex',
3253
alignItems: 'center'

UI/web-app/src/components/HRQuerySource/HRQuerySource.types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ export type HRQuerySourceStyles = {
2424
betweenChildrenDropdown: IStyle;
2525
startOfNestedGroupDropdown: IStyle;
2626
endOfNestedGroupDropdown: IStyle;
27+
expandButton: IStyle;
28+
separator: IStyle;
29+
cardHeader: IStyle;
30+
cardTitle: IStyle;
2731
};
2832

2933
export type HRQuerySourceStyleProps = {

0 commit comments

Comments
 (0)