Skip to content

Commit

Permalink
Put tag to searchbar on click on keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
dmstern committed Nov 26, 2018
1 parent 2a72613 commit bd1c07c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ export default class App extends Vue {
this.error.msg = res.data;
});
EventBus.$on(Events.TRIGGER_FILTER_SEARCH, (args: { filters: Searchable[], query: string }) => {
this.activeFilters.push(...args.filters);
});
}
private get searchInput(): HTMLInputElement {
Expand Down
2 changes: 1 addition & 1 deletion src/components/PackageList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default class Packages extends Vue {
this.loadConfig();
EventBus.$on(Events.FILTER_SEARCH, async ( args: { filters: Searchable[], query: string} ) => {
EventBus.$on([Events.FILTER_SEARCH, Events.TRIGGER_FILTER_SEARCH], async ( args: { filters: Searchable[], query: string} ) => {
this.packages.loading = true;
this.packages.all = await DataStore.Instance.getPackages();
this.packages.loading = false;
Expand Down
1 change: 1 addition & 0 deletions src/services/event-bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const EventBus = new Vue();

export enum Events {
FILTER_SEARCH = 'filter-search',
TRIGGER_FILTER_SEARCH = 'trigger-filter-search',
}

export enum Errors {
Expand Down
6 changes: 2 additions & 4 deletions src/views/PackageDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,7 @@
@click="onKeywordClick(tag)"
>
{{tag.value}}
<v-avatar>
<v-icon>{{$vuetify.icons.search}}</v-icon>
</v-avatar>
<v-icon>{{$vuetify.icons.arrowTopLeft}}</v-icon>
</v-chip>
</PackageDetailItem>
</v-layout>
Expand Down Expand Up @@ -320,7 +318,7 @@ export default class PackageDetail extends Vue {
private onKeywordClick(tag) {
router.push(`/`);
this.$nextTick(() => {
EventBus.$emit(Events.FILTER_SEARCH, { filters: [tag] });
EventBus.$emit(Events.TRIGGER_FILTER_SEARCH, { filters: [tag] });
});
}
}
Expand Down

0 comments on commit bd1c07c

Please sign in to comment.