|
@@ -1,4 +1,6 @@
|
|
|
import { Component } from '../component';
|
|
|
+import { IScope } from 'angular';
|
|
|
+import PeopleSearchService from './peoplesearch.service';
|
|
|
|
|
|
var templateUrl = require('peoplesearch/peoplesearch.component.html');
|
|
|
var stylesheetUrl = require('peoplesearch/peoplesearch.component.scss');
|
|
@@ -8,27 +10,36 @@ var stylesheetUrl = require('peoplesearch/peoplesearch.component.scss');
|
|
|
stylesheetUrl: stylesheetUrl
|
|
|
})
|
|
|
export default class PeopleSearchComponent {
|
|
|
+ query: string;
|
|
|
viewToggleClass: string;
|
|
|
|
|
|
- static $inject = ['$state'];
|
|
|
- public constructor(private $state: angular.ui.IStateService) {
|
|
|
+ static $inject = ['$scope', '$state', 'PeopleSearchService'];
|
|
|
+ constructor(
|
|
|
+ private $scope: IScope,
|
|
|
+ private $state: angular.ui.IStateService,
|
|
|
+ private peopleSearchService: PeopleSearchService) {
|
|
|
}
|
|
|
|
|
|
- public $onInit() {
|
|
|
- if (this.$state.is('search.table')) {
|
|
|
- this.viewToggleClass = 'fa fa-th-large';
|
|
|
- } else {
|
|
|
- this.viewToggleClass = 'fa fa-list-alt';
|
|
|
- }
|
|
|
+ $onInit() {
|
|
|
+ this.setViewToggleClass();
|
|
|
+
|
|
|
+ this.$scope.$watch('$ctrl.query', (newValue: string, oldValue: string) => {
|
|
|
+ this.peopleSearchService.search(newValue);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private setViewToggleClass() {
|
|
|
+ this.viewToggleClass = this.$state.is('search.table') ? 'fa fa-th-large' : 'fa fa-list-alt';
|
|
|
}
|
|
|
|
|
|
private viewToggleClicked() {
|
|
|
+ this.setViewToggleClass();
|
|
|
+
|
|
|
if (this.$state.is('search.table')) {
|
|
|
this.$state.go('search.cards');
|
|
|
- this.viewToggleClass = 'fa fa-list-alt';
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
this.$state.go('search.table');
|
|
|
- this.viewToggleClass = 'fa fa-th-large';
|
|
|
}
|
|
|
}
|
|
|
}
|