Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.

Commit eab4618

Browse files
committed
feat: single select filter changes
1 parent b8154c9 commit eab4618

File tree

2 files changed

+40
-45
lines changed

2 files changed

+40
-45
lines changed

src/Filter/AdvancedFilter.tsx

+40-19
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,9 @@ export class AdvancedFilter extends React.Component<AdvancedFilterProps, {}> {
9292
return tags;
9393
}
9494

95-
render() {
96-
const { disabled, label, helpText } = this.props;
95+
renderHeader() {
96+
const { helpText, label } = this.props;
9797
const text = helpText ? <p>{helpText}</p> : undefined;
98-
// replace "-" with spaces, replace "." with nothing.
99-
const id = label.replace(/\ /g, "-").replace(/\./g, "");
100-
if (disabled) {
101-
// tslint:disable-next-line:no-null-keyword
102-
return null;
103-
}
104-
10598
const tooltip = generateTooltip({
10699
helpText: text,
107100
displayIcon: text !== undefined,
@@ -112,21 +105,49 @@ export class AdvancedFilter extends React.Component<AdvancedFilterProps, {}> {
112105
)
113106
});
114107

108+
return (
109+
<div className="filter-container-header">
110+
<label>{tooltip}</label>
111+
</div>
112+
);
113+
}
114+
115+
renderBody() {
116+
const { displayAllButton, isMultiSelect } = this.props;
117+
const orientationVertical =
118+
displayAllButton === true || isMultiSelect === true;
119+
120+
return (
121+
<div
122+
className={`${
123+
orientationVertical ? "nested-btn-group" : ""
124+
} btn-group-sm toggle-group ${
125+
orientationVertical ? "vertical" : "horizontal"
126+
}`}
127+
data-toggle="buttons"
128+
>
129+
{this.renderAllBtnContainer()}
130+
<div className="btn-group filter-btn-group">{this.renderTags()}</div>
131+
</div>
132+
);
133+
}
134+
135+
render() {
136+
const { disabled, label, helpText } = this.props;
137+
// replace "-" with spaces, replace "." with nothing.
138+
const id = label.replace(/\ /g, "-").replace(/\./g, "");
139+
if (disabled) {
140+
// tslint:disable-next-line:no-null-keyword
141+
return null;
142+
}
143+
115144
return (
116145
<div
117146
id={`${id}-filter`.toLocaleLowerCase()}
118147
className={"filter-selection"}
119148
>
120-
<div className="filter-container-header">
121-
<label>{tooltip}</label>
122-
</div>
123-
<div
124-
className="nested-btn-group btn-group-sm toggle-group vertical"
125-
data-toggle="buttons"
126-
>
127-
{this.renderAllBtnContainer()}
128-
<div className="btn-group filter-btn-group">{this.renderTags()}</div>
129-
</div>
149+
{this.renderHeader()}
150+
{this.renderBody()}
130151
</div>
131152
);
132153
}

src/Filter/SideFilter.tsx

-26
This file was deleted.

0 commit comments

Comments
 (0)