Skip to content

Commit

Permalink
style(search): move extended search button next to submit search button
Browse files Browse the repository at this point in the history
  • Loading branch information
velrest committed Sep 2, 2022
1 parent 0a1d6e8 commit f478194
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 38 deletions.
2 changes: 2 additions & 0 deletions addon/components/search.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
changeset=this.changeset
onSubmit=this.onSubmit
validateBeforeSubmit=true
extendedSearch=@extendedSearch
idField=@idField
)
(component
"search/result-table"
Expand Down
38 changes: 22 additions & 16 deletions addon/components/search/filters.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,15 @@
prompt=(t "ember-gwr.search.hasErrorPlaceholder")
errorComponent=(component "validated-form-error")
)
(component
"uk-button"
label=(if
this.extendedSearch
(t "ember-gwr.components.search.extendedSearch.collapse")
(t "ember-gwr.components.search.extendedSearch.extend")
)
name=this.extendedSearch
value=this.extendedSearch
onClick=(fn (mut this.extendedSearch) (not this.extendedSearch))
)
Form
}}
{{#if this.extendedSearch}}
{{#if (and @extendedSearch this.extendedSearchActive)}}
{{#let
(component Form.input errorComponent=(component "validated-form-error"))
(component
Form.input
errorComponent=(component "validated-form-error")
disabled=(get Form.model @idField)
)
as |FilterInput|
}}
<div class="uk-flex uk-flex-between uk-margin-small-bottom uk-margin-top">
Expand Down Expand Up @@ -132,9 +125,22 @@
{{/let}}
{{/if}}

<div
class="uk-flex-inline uk-flex-nowrap uk-flex-top uk-margin-top uk-width-1-1 uk-margin-bottom"
>
<div class="uk-flex uk-flex-right">
{{#if @extendedSearch}}
<UkButton
@label={{if
this.extendedSearchActive
(t "ember-gwr.components.search.extendedSearch.collapse")
(t "ember-gwr.components.search.extendedSearch.extend")
}}
@value={{this.extendedSearchActive}}
@onClick={{fn
(mut this.extendedSearchActive)
(not this.extendedSearchActive)
}}
class="uk-margin-small-right"
/>
{{/if}}
<Form.submit
data-test-submit-btn
@label={{@submitLabel}}
Expand Down
2 changes: 1 addition & 1 deletion addon/components/search/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { tracked } from "@glimmer/tracking";
export default class SearchFiltersComponent extends Component {
@service intl;

@tracked extendedSearch = false;
@tracked extendedSearchActive = false;
@tracked errorOptions = [
{
value: true,
Expand Down
11 changes: 2 additions & 9 deletions addon/templates/search-building.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
@extendedSearch={{true}}
@service={{this.building}}
@baseQuery={{this.baseQuery}}
@idField="EGID"
>
<:filters as |Filters|>
<Filters
@submitLabel={{t "ember-gwr.searchBuilding.search"}}
as |FilterInput ErrorSelect ExtendedSearchToggle Form|
as |FilterInput ErrorSelect Form|
>
<div class="uk-flex uk-flex-wrap uk-flex-between">
<div class="uk-width-1-3@m uk-width-1">
Expand Down Expand Up @@ -87,14 +88,6 @@
/>
</div>
</div>
<div class="uk-width-1 uk-flex uk-flex-right">
<div class="uk-margin-small-right">
<ExtendedSearchToggle
class="uk-margin-top uk-width-1-1"
@disabled={{Form.model.EGID}}
/>
</div>
</div>
</div>
</Filters>
</:filters>
Expand Down
11 changes: 2 additions & 9 deletions addon/templates/search-project.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
@service={{this.constructionProject}}
@baseQuery={{this.baseQuery}}
@extendedSearch={{true}}
@idField="EPROID"
>
<:filters as |Filters|>
<Filters
@submitLabel={{t "ember-gwr.searchProject.search"}}
as |FilterInput ErrorSelect ExtendedSearchToggle Form|
as |FilterInput ErrorSelect Form|
>
<div class="uk-flex uk-flex-wrap uk-flex-between">
<div class="uk-width-1-3@m uk-width-1">
Expand Down Expand Up @@ -54,14 +55,6 @@
<ErrorSelect @disabled={{Form.model.EPROID}} />
</div>
</div>
<div class="uk-width-1 uk-flex uk-flex-right">
<div class="uk-margin-small-right">
<ExtendedSearchToggle
class="uk-margin-top uk-width-1-1"
@disabled={{Form.model.EPROID}}
/>
</div>
</div>
</div>
</Filters>
</:filters>
Expand Down
5 changes: 2 additions & 3 deletions tests/integration/components/search/filters-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ module("Integration | Component | search/filters", function (hooks) {

test("it allows toggling of the extended search fields", async function (assert) {
this.changeset = new Changeset({});
this.onSubmit = function () {};
this.onSubmit = { perform: () => {} };

await render(hbs`
<Search::Filters
@changeset={{this.changeset}}
@onSubmit={{this.onSubmit}}
as |FilterInput ErrorSelect ExtendedSearchToggle|
@extendedSearch={{true}}
>
<ExtendedSearchToggle />
</Search::Filters>`);

assert.dom('input[name="realestateIdentification.EGRID"]').isNotVisible();
Expand Down

0 comments on commit f478194

Please sign in to comment.