-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show active filters; Toolbar refactor #37
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
b7b3246
Merge Facet types
jeffdaley d1f2381
Convert toolbar to TS
jeffdaley b71094f
Merge branch 'jeffdaley/merge-types' into jeffdaley/show-active-tags
jeffdaley 41fafaa
Merge branch 'main' into jeffdaley/show-active-tags
jeffdaley 0d620fa
Add Toolbar types
jeffdaley 81d538a
Documentation
jeffdaley 8ce8b69
Add tests
jeffdaley d2e1257
Cleanup
jeffdaley 120962b
Renames, docs, cleanup
jeffdaley 5daca93
Refactor `handleClick`
jeffdaley 935c066
Toolbar Service with working filters on all routes
jeffdaley 327362d
Working LinkTo filters
jeffdaley cf37742
Design tags
jeffdaley c5fcd17
Route-based filters
jeffdaley b275ebb
Improve dropdown closing and model loading
jeffdaley 99e2b78
Tests, cleanup and rearranging
jeffdaley 0fc0331
Move styles to SCSS; Documentation; Cleanup
jeffdaley f7bbbff
Merge branch 'main' into jeffdaley/show-active-tags
jeffdaley 868a140
Test `get-facet-query-hash`
jeffdaley 30b5d9e
Refactor route promises
jeffdaley d9cb17c
Merge branch 'main' into jeffdaley/show-active-tags
jeffdaley cfb3b4d
Merge branch 'main' into jeffdaley/show-active-tags
jeffdaley 6e30d37
Merge branch 'main' into jeffdaley/show-active-tags
jeffdaley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<LinkTo @query={{this.query}} class="active-filter-list-item"> | ||
<FlightIcon @name="x" /> | ||
{{@filter}} | ||
</LinkTo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import RouterService from "@ember/routing/router-service"; | ||
import { inject as service } from "@ember/service"; | ||
import Component from "@glimmer/component"; | ||
import ActiveFiltersService from "hermes/services/active-filters"; | ||
|
||
interface HeaderActiveFilterListItemComponentSignature { | ||
Args: { | ||
filter: string; | ||
}; | ||
} | ||
|
||
export default class HeaderActiveFilterListItemComponent extends Component<HeaderActiveFilterListItemComponentSignature> { | ||
@service declare activeFilters: ActiveFiltersService; | ||
@service declare router: RouterService; | ||
|
||
/** | ||
* The query hash to use when clicking the filter. | ||
* I.e., the ActiveFiltersService index minus the current filter. | ||
*/ | ||
get query() { | ||
return Object.fromEntries( | ||
Object.entries(this.activeFilters.index).map(([key, value]) => [ | ||
key, | ||
value.filter((filter) => filter !== this.args.filter), | ||
]) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{{#if this.shownFilters.length}} | ||
<div class="active-filter-list"> | ||
<h3>Showing</h3> | ||
<div class="active-filter-list-container"> | ||
{{#each this.shownFilters as |filter|}} | ||
<Header::ActiveFilterListItem @filter={{filter}} /> | ||
{{/each}} | ||
</div> | ||
<LinkTo @query={{this.defaultQuery}} class="clear-all-link"> | ||
<FlightIcon @name="x-circle" class="mr-1" /> | ||
Clear all | ||
</LinkTo> | ||
</div> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import RouterService from "@ember/routing/router-service"; | ||
import { inject as service } from "@ember/service"; | ||
import Component from "@glimmer/component"; | ||
import ActiveFiltersService from "hermes/services/active-filters"; | ||
|
||
interface HeaderActiveFilterListComponentSignature { | ||
Args: {}; | ||
} | ||
|
||
export default class HeaderActiveFilterListComponent extends Component<HeaderActiveFilterListComponentSignature> { | ||
@service declare activeFilters: ActiveFiltersService; | ||
@service declare router: RouterService; | ||
|
||
/** | ||
* A flat array of all the active filters. | ||
*/ | ||
get shownFilters() { | ||
return Object.values(this.activeFilters.index).flat(); | ||
} | ||
|
||
/** | ||
* The route's default query parameters. Used to reset the filters. | ||
*/ | ||
defaultQuery = { | ||
docType: [], | ||
owners: [], | ||
product: [], | ||
status: [], | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,38 @@ | ||
import Component from "@glimmer/component"; | ||
import { action } from "@ember/object"; | ||
import { FacetDropdownObjects } from "hermes/types/facets"; | ||
import { inject as service } from "@ember/service"; | ||
import RouterService from "@ember/routing/router-service"; | ||
import { next } from "@ember/runloop"; | ||
|
||
interface FacetDropdownComponentSignature { | ||
Args: { | ||
onClick: (facetName: FacetNames, value: string) => void; | ||
label: string; | ||
facets: FacetDropdownObjects; | ||
disabled: boolean; | ||
}; | ||
} | ||
|
||
export enum FacetNames { | ||
DocType = "docType", | ||
Owners = "owners", | ||
Status = "status", | ||
Product = "product", | ||
} | ||
|
||
export default class FacetDropdownComponent extends Component<FacetDropdownComponentSignature> { | ||
get facetName(): FacetNames | undefined { | ||
switch (this.args.label) { | ||
case "Type": | ||
return FacetNames.DocType; | ||
case "Status": | ||
return FacetNames.Status; | ||
case "Product/Area": | ||
return FacetNames.Product; | ||
case "Owner": | ||
return FacetNames.Owners; | ||
} | ||
@service declare router: RouterService; | ||
|
||
protected get currentRouteName(): string { | ||
return this.router.currentRouteName; | ||
} | ||
|
||
get firstTenFacets(): FacetDropdownObjects { | ||
protected get firstTenFacets(): FacetDropdownObjects { | ||
let firstTenEntries = Object.entries(this.args.facets).slice(0, 10); | ||
let firstTenFacetsObjects = Object.fromEntries(firstTenEntries); | ||
return firstTenFacetsObjects; | ||
} | ||
|
||
@action onClick(value: string, close: () => void) { | ||
if (this.facetName) { | ||
this.args.onClick(this.facetName, value); | ||
} | ||
close(); | ||
/** | ||
* Closes the dropdown on the next run loop. | ||
* Done so we don't interfere with Ember's <LinkTo> handling. | ||
*/ | ||
@action protected delayedCloseDropdown(closeDropdown: () => void) { | ||
next(() => { | ||
closeDropdown(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this to
toolbar.ts