mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
not store locale if not present in app.config.json or changed by the language picker (#4431)
This commit is contained in:
@@ -135,6 +135,14 @@ describe('UserPreferencesService', () => {
|
|||||||
expect(preferences.locale).toBe('fake-store-locate');
|
expect(preferences.locale).toBe('fake-store-locate');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not store in the storage the locale if the app.config.json does not have a value', () => {
|
||||||
|
preferences.locale = 'fake-store-locate';
|
||||||
|
spyOn(translate, 'getBrowserCultureLang').and.returnValue('fake-locate-browser');
|
||||||
|
expect(preferences.locale).toBe('fake-store-locate');
|
||||||
|
|
||||||
|
expect(storage.getItem(UserPreferenceValues.Locale)).toBe(null);
|
||||||
|
});
|
||||||
|
|
||||||
it('should stream the page size value when is set', (done) => {
|
it('should stream the page size value when is set', (done) => {
|
||||||
preferences.paginationSize = 5;
|
preferences.paginationSize = 5;
|
||||||
changeDisposable = preferences.onChange.subscribe((userPreferenceStatus) => {
|
changeDisposable = preferences.onChange.subscribe((userPreferenceStatus) => {
|
||||||
|
@@ -52,11 +52,19 @@ export class UserPreferencesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private initUserPreferenceStatus() {
|
private initUserPreferenceStatus() {
|
||||||
this.set(UserPreferenceValues.Locale, (this.locale || this.getDefaultLocale()));
|
this.initUserLanguage();
|
||||||
this.set(UserPreferenceValues.PaginationSize, this.paginationSize);
|
this.set(UserPreferenceValues.PaginationSize, this.paginationSize);
|
||||||
this.set(UserPreferenceValues.SupportedPageSizes, JSON.stringify(this.supportedPageSizes));
|
this.set(UserPreferenceValues.SupportedPageSizes, JSON.stringify(this.supportedPageSizes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private initUserLanguage() {
|
||||||
|
if (this.locale || this.appConfig.get<string>(UserPreferenceValues.Locale)) {
|
||||||
|
this.set(UserPreferenceValues.Locale, (this.locale || this.getDefaultLocale()));
|
||||||
|
} else {
|
||||||
|
this.setWithoutStore(UserPreferenceValues.Locale, (this.locale || this.getDefaultLocale()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up a callback to notify when a property has changed.
|
* Sets up a callback to notify when a property has changed.
|
||||||
* @param property The property to watch
|
* @param property The property to watch
|
||||||
@@ -102,6 +110,19 @@ export class UserPreferencesService {
|
|||||||
this.onChangeSubject.next(this.userPreferenceStatus);
|
this.onChangeSubject.next(this.userPreferenceStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a preference property.
|
||||||
|
* @param property Name of the property
|
||||||
|
* @param value New value for the property
|
||||||
|
*/
|
||||||
|
setWithoutStore(property: string, value: any) {
|
||||||
|
if (!property) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.userPreferenceStatus[property] = value;
|
||||||
|
this.onChangeSubject.next(this.userPreferenceStatus);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if an item is present in the storage
|
* Check if an item is present in the storage
|
||||||
* @param property Name of the property
|
* @param property Name of the property
|
||||||
|
Reference in New Issue
Block a user