Explorar el Código

Merge branch 'master' of github.com:pwm-project/pwm into bugfix/helpdesk-change-password-ie

Joseph White hace 7 años
padre
commit
d5623c8c87

+ 18 - 5
client/src/modules/helpdesk/helpdesk-detail.component.ts

@@ -28,11 +28,14 @@ import {noop} from 'angular';
 import {IActionButton, IHelpDeskConfigService, PASSWORD_UI_MODES} from '../../services/helpdesk-config.service';
 import {IPerson} from '../../models/person.model';
 import {IChangePasswordSuccess} from '../../components/changepassword/success-change-password.controller';
+import LocalStorageService from '../../services/local-storage.service';
 
-let autogenChangePasswordTemplateUrl = require('../../components/changepassword/autogen-change-password.component.html');
+let autogenChangePasswordTemplateUrl =
+    require('../../components/changepassword/autogen-change-password.component.html');
 let helpdeskDetailDialogTemplateUrl = require('./helpdesk-detail-dialog.template.html');
 let randomChangePasswordTemplateUrl = require('../../components/changepassword/random-change-password.component.html');
-let successChangePasswordTemplateUrl = require('../../components/changepassword/success-change-password.component.html');
+let successChangePasswordTemplateUrl =
+    require('../../components/changepassword/success-change-password.component.html');
 let typeChangePasswordTemplateUrl = require('../../components/changepassword/type-change-password.component.html');
 let verificationsDialogTemplateUrl = require('./verifications-dialog.template.html');
 
@@ -50,6 +53,7 @@ export default class HelpDeskDetailComponent {
     person: any;
     personCard: IPerson;
     photosEnabled: boolean;
+    searchViewLocalStorageKey: string;
 
     static $inject = [
         '$state',
@@ -57,7 +61,8 @@ export default class HelpDeskDetailComponent {
         'ConfigService',
         'HelpDeskService',
         'IasDialogService',
-        'IasToggleService'
+        'IasToggleService',
+        'LocalStorageService'
     ];
 
     constructor(private $state: ui.IStateService,
@@ -65,7 +70,9 @@ export default class HelpDeskDetailComponent {
                 private configService: IHelpDeskConfigService,
                 private helpDeskService: IHelpDeskService,
                 private IasDialogService: any,
-                private toggleService: { showComponent: (componentName: string) => null }) {
+                private toggleService: { showComponent: (componentName: string) => null },
+                private localStorageService: LocalStorageService) {
+        this.searchViewLocalStorageKey = this.localStorageService.keys.HELPDESK_SEARCH_VIEW;
     }
 
     $onInit(): void {
@@ -353,7 +360,13 @@ export default class HelpDeskDetailComponent {
     }
 
     gotoSearch(): void {
-        this.$state.go('search.cards');
+        let view = this.localStorageService.getItem(this.searchViewLocalStorageKey);
+        if (view) {
+            this.$state.go(view);
+        }
+        else {
+            this.$state.go('search.cards');
+        }
     }
 
     initialize(): void {

+ 15 - 1
client/src/modules/helpdesk/helpdesk-search-base.component.ts

@@ -45,10 +45,10 @@ export default abstract class HelpDeskSearchBaseComponent {
     searchTextLocalStorageKey: string;
     searchViewLocalStorageKey: string;
     verificationsEnabled: boolean;
-    view: string;
 
     constructor(protected $q: IQService,
                 protected $scope: IScope,
+                protected $state: angular.ui.IStateService,
                 protected $stateParams: angular.ui.IStateParamsService,
                 protected $timeout: ITimeoutService,
                 protected $translate: angular.translate.ITranslateService,
@@ -152,6 +152,10 @@ export default abstract class HelpDeskSearchBaseComponent {
             }.bind(this));
     }
 
+    private gotoState(state: string): void {
+        this.$state.go(state, { query: this.query });
+    }
+
     private onSearchTextChange(newValue: string, oldValue: string): void {
         if (newValue === oldValue) {
             return;
@@ -230,4 +234,14 @@ export default abstract class HelpDeskSearchBaseComponent {
     protected storeSearchText(): void {
         this.localStorageService.setItem(this.searchTextLocalStorageKey, this.query || '');
     }
+
+    protected toggleView(state: string): void {
+        this.storeSearchView(state);
+        this.storeSearchText();
+        this.gotoState(state);
+    }
+
+    private storeSearchView(state: string) {
+        this.localStorageService.setItem(this.searchViewLocalStorageKey, state);
+    }
 }

+ 3 - 3
client/src/modules/helpdesk/helpdesk-search-cards.component.ts

@@ -53,7 +53,7 @@ export default class HelpDeskSearchCardsComponent extends HelpDeskSearchBaseComp
     ];
     constructor($q: IQService,
                 $scope: IScope,
-                private $state: angular.ui.IStateService,
+                $state: angular.ui.IStateService,
                 $stateParams: angular.ui.IStateParamsService,
                 $timeout: ITimeoutService,
                 $translate: angular.translate.ITranslateService,
@@ -63,7 +63,7 @@ export default class HelpDeskSearchCardsComponent extends HelpDeskSearchBaseComp
                 localStorageService: LocalStorageService,
                 promiseService: PromiseService,
                 pwmService: IPwmService) {
-        super($q, $scope, $stateParams, $timeout, $translate, configService, helpDeskService, IasDialogService,
+        super($q, $scope, $state, $stateParams, $timeout, $translate, configService, helpDeskService, IasDialogService,
             localStorageService, promiseService, pwmService);
     }
 
@@ -84,7 +84,7 @@ export default class HelpDeskSearchCardsComponent extends HelpDeskSearchBaseComp
     }
 
     gotoTableView(): void {
-        this.$state.go('search.table', {query: this.query});
+        this.toggleView('search.table');
     }
 
     private onSearchResult(searchResult: SearchResult): void {

+ 3 - 3
client/src/modules/helpdesk/helpdesk-search-table.component.ts

@@ -54,7 +54,7 @@ export default class HelpDeskSearchTableComponent extends HelpDeskSearchBaseComp
     ];
     constructor($q: IQService,
                 $scope: IScope,
-                private $state: angular.ui.IStateService,
+                $state: angular.ui.IStateService,
                 $stateParams: angular.ui.IStateParamsService,
                 $timeout: ITimeoutService,
                 $translate: angular.translate.ITranslateService,
@@ -64,7 +64,7 @@ export default class HelpDeskSearchTableComponent extends HelpDeskSearchBaseComp
                 localStorageService: LocalStorageService,
                 promiseService: PromiseService,
                 pwmService: IPwmService) {
-        super($q, $scope, $stateParams, $timeout, $translate, configService, helpDeskService, IasDialogService,
+        super($q, $scope, $state, $stateParams, $timeout, $translate, configService, helpDeskService, IasDialogService,
               localStorageService, promiseService, pwmService);
     }
 
@@ -99,7 +99,7 @@ export default class HelpDeskSearchTableComponent extends HelpDeskSearchBaseComp
     }
 
     gotoCardsView(): void {
-        this.$state.go('search.cards', {query: this.query});
+        this.toggleView('search.cards');
     }
 
     toggleColumnVisible(event, columnId): void {

+ 1 - 0
client/src/services/local-storage.service.ts

@@ -28,6 +28,7 @@ const KEYS = {
     SEARCH_TEXT: 'searchText',
     HELPDESK_SEARCH_TEXT: 'helpdeskSearchText',
     SEARCH_VIEW: 'searchView',
+    HELPDESK_SEARCH_VIEW: 'helpdeskSearchView',
     VERIFICATION_STATE: 'verificationState'
 };