From 6e57cd3e17e66f69ad16805ad68a2f6f4b43a11a Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Thu, 15 Feb 2018 09:30:35 +0000 Subject: [PATCH] [ADF-2265] fix user preference null value (#2948) * fix user preference null value * fix method call test public --- lib/core/services/authentication.service.ts | 4 ++-- lib/core/services/user-preferences.service.spec.ts | 8 +++++++- lib/core/services/user-preferences.service.ts | 2 +- .../task-list/services/task-filter.service.ts | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/core/services/authentication.service.ts b/lib/core/services/authentication.service.ts index cf331b1ddd..1ea5263e36 100644 --- a/lib/core/services/authentication.service.ts +++ b/lib/core/services/authentication.service.ts @@ -191,8 +191,8 @@ export class AuthenticationService { * The method save the AUTH ticket in the Storage */ saveTicketAuth(): void { - if (this.alfrescoApi.getInstance() && (this.alfrescoApi.getInstance()).getTicketAuth()) { - this.storage.setItem('ticket-AUTH', (this.alfrescoApi.getInstance()).getTicketAuth()); + if (this.alfrescoApi.getInstance() && ( this.alfrescoApi.getInstance()).getTicketAuth()) { + this.storage.setItem('ticket-AUTH', ( this.alfrescoApi.getInstance()).getTicketAuth()); } } diff --git a/lib/core/services/user-preferences.service.spec.ts b/lib/core/services/user-preferences.service.spec.ts index 3a613bee54..37ae41949b 100644 --- a/lib/core/services/user-preferences.service.spec.ts +++ b/lib/core/services/user-preferences.service.spec.ts @@ -57,7 +57,7 @@ describe('UserPreferencesService', () => { appConfig.config = { pagination: { 'size': 10, - 'supportedPageSizes': [ 5, 10, 15, 20 ] + 'supportedPageSizes': [5, 10, 15, 20] } }; preferences = TestBed.get(UserPreferencesService); @@ -99,6 +99,12 @@ describe('UserPreferencesService', () => { expect(storage.getItem(propertyKey)).toBe('valueA'); }); + it('should null value return default prefix', () => { + storage.setItem('paginationSize', null); + const paginationSize = preferences.getPropertyKey('paginationSize'); + expect(preferences.get(paginationSize, 'default')).toBe('default'); + }); + it('should save value with custom prefix', () => { preferences.setStoragePrefix('USER_A'); preferences.set('propertyA', 'valueA'); diff --git a/lib/core/services/user-preferences.service.ts b/lib/core/services/user-preferences.service.ts index acf7092653..ce16929210 100644 --- a/lib/core/services/user-preferences.service.ts +++ b/lib/core/services/user-preferences.service.ts @@ -51,7 +51,7 @@ export class UserPreferencesService { get(property: string, defaultValue?: string): string { const key = this.getPropertyKey(property); const value = this.storage.getItem(key); - if (value === undefined) { + if (value === undefined || value === null) { return defaultValue; } return value; diff --git a/lib/process-services/task-list/services/task-filter.service.ts b/lib/process-services/task-list/services/task-filter.service.ts index 5b70e4b6fa..f106483858 100644 --- a/lib/process-services/task-list/services/task-filter.service.ts +++ b/lib/process-services/task-list/services/task-filter.service.ts @@ -87,7 +87,7 @@ export class TaskFilterService { /** * Retrieve all the Tasks filters */ - getTaskListFilters(appId?: number): Observable { + getTaskListFilters(appId?: number): Observable { return Observable.fromPromise(this.callApiTaskFilters(appId)) .map((response: any) => { let filters: FilterRepresentationModel[] = [];