Skip to content

Commit

Permalink
Search tool changes to format menu , search icon always visible (#3670)
Browse files Browse the repository at this point in the history
  • Loading branch information
MV88 authored and offtherailz committed Apr 4, 2019
1 parent 167515a commit 6cc4248
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 28 deletions.
59 changes: 36 additions & 23 deletions web/client/components/mapcontrols/search/SearchBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,12 @@ class SearchBar extends React.Component {
className: "square-button-md no-border " + (this.props.isSearchClickable || activeTool !== "addressSearch" ? "magnifying-glass clickable" : "magnifying-glass"),
bsStyle: "default",
pullRight: true,
visible: activeTool === "addressSearch" && (!(this.props.searchText !== "" || this.props.selectedItems && this.props.selectedItems.length > 0) || !this.props.splitTools),
visible: activeTool === "addressSearch" && (!(this.props.searchText !== "" || this.props.selectedItems && this.props.selectedItems.length > 0) || !this.props.splitTools) || activeTool === "coordinatesSearch",
onClick: () => {
if (this.props.isSearchClickable || activeTool !== "addressSearch") {
if (activeTool === "coordinatesSearch" && this.areValidCoordinates()) {
this.zoomToPoint();
}
if (this.props.isSearchClickable) {
this.search();
}
}
Expand All @@ -328,27 +331,6 @@ class SearchBar extends React.Component {
visible: !!this.props.error,
onClick: this.clearSearch
}, {
buttonConfig: {
title: <Glyphicon glyph="cog"/>,
tooltipId: "search.changeSearchInputField",
tooltipPosition: "bottom",
className: "square-button-md no-border",
pullRight: true
},
menuOptions: [
{
active: this.props.format === "decimal",
onClick: () => { this.props.onChangeFormat("decimal"); },
text: <Message msgId="search.decimal"/>
}, {
active: this.props.format === "aeronautical",
onClick: () => { this.props.onChangeFormat("aeronautical"); },
text: <Message msgId="search.aeronautical"/>
}
],
visible: this.props.showOptions && activeTool === "coordinatesSearch",
Element: DropdownToolbarOptions
}, {
buttonConfig: {
title: <Glyphicon glyph="menu-hamburger"/>,
tooltipId: "search.changeSearchInputField",
Expand All @@ -371,6 +353,37 @@ class SearchBar extends React.Component {
Element: DropdownToolbarOptions
}]}
/>
{
this.props.showOptions && activeTool === "coordinatesSearch" ? <Toolbar
btnGroupProps = {{ className: 'btn-group-menu-options-format'}}
transitionProps = {null}
btnDefaultProps = {{ className: 'square-button-md', bsStyle: 'primary' }}
buttons={[
{
buttonConfig: {
title: <Glyphicon glyph="cog"/>,
tooltipId: "search.changeSearchInputField",
tooltipPosition: "bottom",
className: "square-button-md no-border",
pullRight: true
},
menuOptions: [
{
active: this.props.format === "decimal",
onClick: () => { this.props.onChangeFormat("decimal"); },
text: <Message msgId="search.decimal"/>
}, {
active: this.props.format === "aeronautical",
onClick: () => { this.props.onChangeFormat("aeronautical"); },
text: <Message msgId="search.aeronautical"/>
}
],
visible: this.props.showOptions && activeTool === "coordinatesSearch",
Element: DropdownToolbarOptions
}
]}
/> : null
}
</span>);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,24 +240,24 @@ describe("test the SearchBar", () => {
expect(reset).toExist();
expect(search.length).toBe(1);
});
it('test zoomToPoint and reset, with decimal, with reset', () => {
it('test zoomToPoint, with search, with decimal, with reset', () => {
const tb = ReactDOM.render(<SearchBar format="decimal" coordinate={{"lat": 2, "lon": 2}} activeSearchTool="coordinatesSearch" showOptions searchText={"va"} delay={0} typeAhead={false} />, document.getElementById("container"));
let reset = TestUtils.scryRenderedDOMComponentsWithClass(tb, "glyphicon-1-close");
let search = TestUtils.scryRenderedDOMComponentsWithClass(tb, "glyphicon-search");
let cog = TestUtils.scryRenderedDOMComponentsWithClass(tb, "glyphicon-cog");
expect(reset.length).toBe(1);
expect(search.length).toBe(1);
expect(search.length).toBe(2);
expect(cog.length).toBe(2);
});

it('test zoomToPoint and reset, with aeronautical', () => {
it('test zoomToPoint, with search, with aeronautical, with reset', () => {
const tb = ReactDOM.render(<SearchBar format="aeronautical" activeSearchTool="coordinatesSearch" showOptions searchText={"va"} delay={0} typeAhead={false} />, document.getElementById("container"));
let reset = TestUtils.scryRenderedDOMComponentsWithClass(tb, "glyphicon-1-close");
let search = TestUtils.scryRenderedDOMComponentsWithClass(tb, "glyphicon-search");
let cog = TestUtils.scryRenderedDOMComponentsWithClass(tb, "glyphicon-cog");
let inputs = TestUtils.scryRenderedDOMComponentsWithTag(tb, "input");
expect(reset.length).toBe(0);
expect(search.length).toBe(1);
expect(search.length).toBe(2);
expect(cog.length).toBe(2);
expect(inputs.length).toBe(6);
});
Expand Down
6 changes: 5 additions & 1 deletion web/client/themes/default/less/map-search-bar.less
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ div.MapSearchBar .input-group-addon {
background-color: @dropdown-link-active-bg;
}
}
.btn-group-menu-options {
.btn-group-menu-options, .btn-group-menu-options-format {
position: absolute;
top: 13px;
right: 5px;
Expand All @@ -179,5 +179,9 @@ div.MapSearchBar .input-group-addon {
}
}
}
.btn-group-menu-options-format {
top: 60px;

}
}
}

0 comments on commit 6cc4248

Please sign in to comment.