Skip to content

Commit

Permalink
improve searchbar to show keyworks
Browse files Browse the repository at this point in the history
  • Loading branch information
dmstern committed Jul 28, 2018
1 parent 5503f88 commit ae3f5ab
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<md-autocomplete
class="search"
v-model="selectedPackage"
:md-options="Object.keys(packages)"
:md-options="searchItems"
md-layout="box">
<label>Search packages</label>
</md-autocomplete>
Expand Down Expand Up @@ -75,7 +75,6 @@

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import PackageService from '@/services/PackageService';
import { PackageMetaData } from '@/api/package-meta-data';
import { PackagesResponse } from '@/api/PackageResponse';
import PackagesService from '@/services/PackageService';
Expand All @@ -88,18 +87,30 @@ export default class App extends Vue {
private menuVisible: boolean;
private packages: PackagesResponse;
private selectedPackage: string|null;
private searchItems: string[];
constructor() {
super();
this.menuVisible = false;
this.packages = {};
this.selectedPackage = null;
this.searchItems = [];
this.loadPackages();
}
private loadPackages(): void {
PackagesService.Instance.getPackages().then((response) => {
this.packages = response;
for (let packageName in this.packages) {
if (this.packages.hasOwnProperty(packageName)) {
this.searchItems.push(packageName);
if (this.packages[packageName].keywords) {
for (let keyword of this.packages[packageName].keywords!) {
this.searchItems.push(`keyword:${keyword}`);
}
}
}
}
});
}
}
Expand Down

0 comments on commit ae3f5ab

Please sign in to comment.