From 41a2aee38cf812510010da09de9bae53590ec119 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 May 2016 16:23:10 +0200 Subject: Follow the angular styleguide for the directories structure --- client/app/shared/search.component.ts | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 client/app/shared/search.component.ts (limited to 'client/app/shared/search.component.ts') diff --git a/client/app/shared/search.component.ts b/client/app/shared/search.component.ts new file mode 100644 index 000000000..519810f9b --- /dev/null +++ b/client/app/shared/search.component.ts @@ -0,0 +1,47 @@ +import { Component, EventEmitter, Output } from '@angular/core'; + +import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown'; + +import { Search } from './search.model'; +import { SearchField } from './search-field.type'; + +@Component({ + selector: 'my-search', + templateUrl: 'client/app/shared/search.component.html', + directives: [ DROPDOWN_DIRECTIVES ] +}) + +export class SearchComponent { + @Output() search: EventEmitter = new EventEmitter(); + + searchCriterias: Search = { + field: 'name', + value: '' + }; + fieldChoices = { + name: 'Name', + author: 'Author', + podUrl: 'Pod Url', + magnetUri: 'Magnet Uri' + }; + + get choiceKeys() { + return Object.keys(this.fieldChoices); + } + + getStringChoice(choiceKey: SearchField): string { + return this.fieldChoices[choiceKey]; + } + + choose($event:MouseEvent, choice: SearchField) { + $event.preventDefault(); + $event.stopPropagation(); + + this.searchCriterias.field = choice; + } + + doSearch(): void { + this.search.emit(this.searchCriterias); + } + +} -- cgit v1.2.3