Skip to content

Commit

Permalink
rename SearchItem to Keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
dmstern committed Sep 5, 2018
1 parent 01d46d2 commit f188722
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
import { Component, Prop, Vue } from 'vue-property-decorator';
import DataStore from '@/services/DataStore';
import Package from '../types/Package';
import { SearchItem } from '../types/SearchItem';
import { Keyword } from '../types/Keyword';
import router from '@/router';
import { setTimeout } from 'timers';
import { EventBus, Events, Errors } from '@/services/event-bus';
Expand All @@ -178,7 +178,7 @@ export default class App extends Vue {
};
@Prop() private menuVisibleProp!: boolean;
@Prop() private activeFiltersProp!: SearchItem[];
@Prop() private activeFiltersProp!: Keyword[];
@Prop() private clippedProp!: boolean;
@Prop() private hasFocusProp!: boolean;
@Prop() private titleProp!: string;
Expand Down Expand Up @@ -245,11 +245,11 @@ export default class App extends Vue {
return item.getSearchItemText();
}
private isPackage(item: SearchItem | Package | Crafter): boolean {
private isPackage(item: Searchable): boolean {
return item instanceof Package;
}
private isCrafter(item: SearchItem | Package | Crafter): boolean {
private isCrafter(item: Searchable): boolean {
return item instanceof Crafter;
}
Expand All @@ -273,7 +273,7 @@ export default class App extends Vue {
this.fireSearchFilterEvent();
}
private onSearchChange(values: Array<Package|SearchItem>) {
private onSearchChange(values: Searchable[]) {
this.hasFocus = true;
for (const value of values) {
if (value instanceof Package) {
Expand Down
6 changes: 3 additions & 3 deletions src/services/DataStore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import BackendApi from '@/services/BackendApi';
import { PackagesResponse } from '../../types/PackageResponse';
import Package from '../../types/Package';
import { SearchItem } from '../../types/SearchItem';
import { Keyword } from '../../types/Keyword';
import { PackageMetaDataDTO } from '../../types/package-meta-data';
import Crafter from '../../types/Crafter';
import Searchable from '../../types/Searchable';
Expand All @@ -26,7 +26,7 @@ export default class DataStore {

private request!: Promise<Package[]>;
private packages!: Package[];
private searchItemList!: SearchItem[];
private searchItemList!: Keyword[];
private crafterList!: Crafter[];
private packageDetails!: {
[packageName: string]: {
Expand Down Expand Up @@ -105,7 +105,7 @@ export default class DataStore {
if (modifiedPackage.keywords) {
for (const keyword of modifiedPackage.keywords!) {
if (! this.searchItemList.some((currentSearchItem) => keyword === currentSearchItem.value)) {
this.searchItemList.push(new SearchItem(keyword));
this.searchItemList.push(new Keyword(keyword));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions types/SearchItem.ts → types/Keyword.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Searchable from './Searchable';
import Package from './Package';
export class SearchItem implements Searchable {
export class Keyword implements Searchable {
public value: string;

constructor(value: string) {
this.value = value;
}

public matches(other: Searchable, packages: Package[]): boolean {
if (other instanceof SearchItem && other.value === this.value) {
if (other instanceof Keyword && other.value === this.value) {
return true;
}
if (
Expand Down
4 changes: 2 additions & 2 deletions types/Package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { IDistTags, ITimes, IVersions } from './package-meta-data';
import { PackageMetaDataDTO } from './package-meta-data';
import Crafter from './Crafter';
import Searchable from './Searchable';
import { SearchItem } from './SearchItem';
import { Keyword } from './Keyword';

export default class Package implements PackageMetaDataDTO, Searchable {
public readonly distTags!: IDistTags;
Expand Down Expand Up @@ -103,7 +103,7 @@ export default class Package implements PackageMetaDataDTO, Searchable {
}

public matches(other: Searchable): boolean {
if (other instanceof SearchItem) {
if (other instanceof Keyword) {
return this.keywords !== undefined && this.keywords.indexOf(other.value) > -1;
}
if (other instanceof Crafter) {
Expand Down

0 comments on commit f188722

Please sign in to comment.