Преглед на файлове

Focus person details dialog box on page load

Joseph White преди 8 години
родител
ревизия
c686bcf4d9

+ 13 - 3
src/main/angular/src/peoplesearch/person-details-dialog.component.ts

@@ -24,6 +24,7 @@
 import { Component } from '../component';
 import { IPeopleService } from '../services/people.service';
 import Person from '../models/person.model';
+import { IAugmentedJQuery, IScope, ITimeoutService } from 'angular';
 
 @Component({
     stylesheetUrl: require('peoplesearch/person-details-dialog.component.scss'),
@@ -32,14 +33,16 @@ import Person from '../models/person.model';
 export default class PersonDetailsDialogComponent {
     person: Person;
 
-    static $inject = [ '$state', '$stateParams', 'PeopleService' ];
-    constructor(private $state: angular.ui.IStateService,
+    static $inject = [ '$element', '$state', '$stateParams', '$timeout', 'PeopleService' ];
+    constructor(private $element: IAugmentedJQuery,
+                private $state: angular.ui.IStateService,
                 private $stateParams: angular.ui.IStateParamsService,
+                private $timeout: ITimeoutService,
                 private peopleService: IPeopleService) {
     }
 
     $onInit(): void {
-        var personId = this.$stateParams['personId'];
+        const personId = this.$stateParams['personId'];
 
         this.peopleService
             .getPerson(personId)
@@ -48,6 +51,13 @@ export default class PersonDetailsDialogComponent {
             });
     }
 
+    $postLink() {
+        const self = this;
+        this.$timeout(() => {
+            self.$element.find('button')[0].focus();
+        }, 100);
+    }
+
     closeDialog(): void {
         this.$state.go('^', { query: this.$stateParams['query'] });
     }

+ 1 - 0
src/main/angular/src/services/people.service.ts

@@ -47,6 +47,7 @@ export default class PeopleService implements IPeopleService {
         return this.search(query, { 'includeDisplayName': true })
             .then((searchResult: SearchResult) => {
                 let people = searchResult.people;
+                console.log(people);
                 if (people && people.length > 10) {
                     return this.$q.resolve(people.slice(0, 10));
                 }

+ 7 - 7
src/main/angular/src/ux/search-bar.component.ts

@@ -38,22 +38,22 @@ export default class SearchBarComponent {
     focused: boolean;
     searchText: string;
 
-    static $inject = [ '$compile', '$element', '$scope', '$timeout' ];
+    static $inject = [ '$compile', '$element', '$scope' ];
     constructor(private $compile: ICompileService,
                 private $element: IAugmentedJQuery,
-                private $scope: IScope,
-                private $timeout: ITimeoutService) {
+                private $scope: IScope) {
     }
 
     $onInit(): void {
-        var self = this;
-
         this.autoFocus = this.autoFocus !== undefined;
+    }
 
+    $postLink() {
+        const self = this;
         if (this.autoFocus) {
-            this.$timeout(() => {
+            this.$scope.$evalAsync(() => {
                 self.focusInput();
-            }, 100);
+            });
         }
     }