mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
route defined preference data prefix (#195)
This commit is contained in:
committed by
Denys Vuika
parent
8e0bcad285
commit
3cbb7fa065
@@ -59,6 +59,9 @@ export const APP_ROUTES: Routes = [
|
||||
},
|
||||
{
|
||||
path: 'favorites',
|
||||
data: {
|
||||
preferencePrefix: 'favorites'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
@@ -80,6 +83,9 @@ export const APP_ROUTES: Routes = [
|
||||
},
|
||||
{
|
||||
path: 'libraries',
|
||||
data: {
|
||||
preferencePrefix: 'libraries'
|
||||
},
|
||||
children: [{
|
||||
path: '',
|
||||
component: LibrariesComponent,
|
||||
@@ -90,7 +96,8 @@ export const APP_ROUTES: Routes = [
|
||||
path: ':folderId',
|
||||
component: FilesComponent,
|
||||
data: {
|
||||
i18nTitle: 'APP.BROWSE.LIBRARIES.TITLE'
|
||||
i18nTitle: 'APP.BROWSE.LIBRARIES.TITLE',
|
||||
preferencePrefix: 'libraries-files'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -106,6 +113,9 @@ export const APP_ROUTES: Routes = [
|
||||
},
|
||||
{
|
||||
path: 'personal-files',
|
||||
data: {
|
||||
preferencePrefix: 'personal-files'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
@@ -144,6 +154,9 @@ export const APP_ROUTES: Routes = [
|
||||
},
|
||||
{
|
||||
path: 'recent-files',
|
||||
data: {
|
||||
preferencePrefix: 'recent-files'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
@@ -165,6 +178,9 @@ export const APP_ROUTES: Routes = [
|
||||
},
|
||||
{
|
||||
path: 'shared',
|
||||
data: {
|
||||
preferencePrefix: 'shared-files'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
@@ -188,7 +204,8 @@ export const APP_ROUTES: Routes = [
|
||||
path: 'trashcan',
|
||||
component: TrashcanComponent,
|
||||
data: {
|
||||
i18nTitle: 'APP.BROWSE.TRASHCAN.TITLE'
|
||||
i18nTitle: 'APP.BROWSE.TRASHCAN.TITLE',
|
||||
preferencePrefix: 'trashcan'
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@@ -54,8 +54,8 @@ export class FavoritesComponent extends PageComponent implements OnInit, OnDestr
|
||||
preferences: UserPreferencesService) {
|
||||
super(preferences);
|
||||
|
||||
const sortingKey = preferences.get('favorites.sorting.key') || 'modifiedAt';
|
||||
const sortingDirection = preferences.get('favorites.sorting.direction') || 'desc';
|
||||
const sortingKey = preferences.get(`${this.prefix}.sorting.key`) || 'modifiedAt';
|
||||
const sortingDirection = preferences.get(`${this.prefix}.sorting.direction`) || 'desc';
|
||||
|
||||
this.sorting = [sortingKey, sortingDirection];
|
||||
}
|
||||
@@ -118,7 +118,11 @@ export class FavoritesComponent extends PageComponent implements OnInit, OnDestr
|
||||
}
|
||||
|
||||
onSortingChanged(event: CustomEvent) {
|
||||
this.preferences.set('favorites.sorting.key', event.detail.key || 'modifiedAt');
|
||||
this.preferences.set('favorites.sorting.direction', event.detail.direction || 'desc');
|
||||
this.preferences.set(`${this.prefix}.sorting.key`, event.detail.key || 'modifiedAt');
|
||||
this.preferences.set(`${this.prefix}.sorting.direction`, event.detail.direction || 'desc');
|
||||
}
|
||||
|
||||
private get prefix() {
|
||||
return this.route.snapshot.data.preferencePrefix;
|
||||
}
|
||||
}
|
||||
|
@@ -64,8 +64,8 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
preferences: UserPreferencesService) {
|
||||
super(preferences);
|
||||
|
||||
const sortingKey = preferences.get('personal-files.sorting.key') || 'modifiedAt';
|
||||
const sortingDirection = preferences.get('personal-files.sorting.direction') || 'desc';
|
||||
const sortingKey = this.preferences.get(`${this.prefix}.sorting.key`) || 'modifiedAt';
|
||||
const sortingDirection = this.preferences.get(`${this.prefix}.sorting.direction`) || 'desc';
|
||||
|
||||
this.sorting = [sortingKey, sortingDirection];
|
||||
}
|
||||
@@ -309,7 +309,11 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
onSortingChanged(event: CustomEvent) {
|
||||
this.preferences.set('personal-files.sorting.key', event.detail.key || 'modifiedAt');
|
||||
this.preferences.set('personal-files.sorting.direction', event.detail.direction || 'desc');
|
||||
this.preferences.set(`${this.prefix}.sorting.key`, event.detail.key || 'modifiedAt');
|
||||
this.preferences.set(`${this.prefix}.sorting.direction`, event.detail.direction || 'desc');
|
||||
}
|
||||
|
||||
private get prefix() {
|
||||
return this.route.snapshot.data.preferencePrefix;
|
||||
}
|
||||
}
|
||||
|
@@ -46,8 +46,8 @@ export class LibrariesComponent extends PageComponent {
|
||||
preferences: UserPreferencesService) {
|
||||
super(preferences);
|
||||
|
||||
const sortingKey = preferences.get('libraries.sorting.key') || 'title';
|
||||
const sortingDirection = preferences.get('libraries.sorting.direction') || 'desc';
|
||||
const sortingKey = preferences.get(`${this.prefix}.sorting.key`) || 'title';
|
||||
const sortingDirection = preferences.get(`${this.prefix}.sorting.direction`) || 'desc';
|
||||
|
||||
this.sorting = [sortingKey, sortingDirection];
|
||||
}
|
||||
@@ -98,7 +98,11 @@ export class LibrariesComponent extends PageComponent {
|
||||
}
|
||||
|
||||
onSortingChanged(event: CustomEvent) {
|
||||
this.preferences.set('libraries.sorting.key', event.detail.key || 'modifiedAt');
|
||||
this.preferences.set('libraries.sorting.direction', event.detail.direction || 'desc');
|
||||
this.preferences.set(`${this.prefix}.sorting.key`, event.detail.key || 'modifiedAt');
|
||||
this.preferences.set(`${this.prefix}.sorting.direction`, event.detail.direction || 'desc');
|
||||
}
|
||||
|
||||
private get prefix() {
|
||||
return this.route.snapshot.data.preferencePrefix;
|
||||
}
|
||||
}
|
||||
|
@@ -52,8 +52,8 @@ export class RecentFilesComponent extends PageComponent implements OnInit, OnDes
|
||||
preferences: UserPreferencesService) {
|
||||
super(preferences);
|
||||
|
||||
const sortingKey = preferences.get('recent-files.sorting.key') || 'modifiedAt';
|
||||
const sortingDirection = preferences.get('recent-files.sorting.direction') || 'desc';
|
||||
const sortingKey = preferences.get(`${this.prefix}.sorting.key`) || 'modifiedAt';
|
||||
const sortingDirection = preferences.get(`${this.prefix}.sorting.direction`) || 'desc';
|
||||
|
||||
this.sorting = [sortingKey, sortingDirection];
|
||||
}
|
||||
@@ -90,7 +90,11 @@ export class RecentFilesComponent extends PageComponent implements OnInit, OnDes
|
||||
}
|
||||
|
||||
onSortingChanged(event: CustomEvent) {
|
||||
this.preferences.set('recent-files.sorting.key', event.detail.key || 'modifiedAt');
|
||||
this.preferences.set('recent-files.sorting.direction', event.detail.direction || 'desc');
|
||||
this.preferences.set(`${this.prefix}.sorting.key`, event.detail.key || 'modifiedAt');
|
||||
this.preferences.set(`${this.prefix}.sorting.direction`, event.detail.direction || 'desc');
|
||||
}
|
||||
|
||||
private get prefix() {
|
||||
return this.route.snapshot.data.preferencePrefix;
|
||||
}
|
||||
}
|
||||
|
@@ -52,8 +52,8 @@ export class SharedFilesComponent extends PageComponent implements OnInit, OnDes
|
||||
preferences: UserPreferencesService) {
|
||||
super(preferences);
|
||||
|
||||
const sortingKey = preferences.get('shared-files.sorting.key') || 'modifiedAt';
|
||||
const sortingDirection = preferences.get('shared-files.sorting.direction') || 'desc';
|
||||
const sortingKey = preferences.get(`${this.prefix}.sorting.key`) || 'modifiedAt';
|
||||
const sortingDirection = preferences.get(`${this.prefix}.sorting.direction`) || 'desc';
|
||||
|
||||
this.sorting = [sortingKey, sortingDirection];
|
||||
}
|
||||
@@ -99,7 +99,11 @@ export class SharedFilesComponent extends PageComponent implements OnInit, OnDes
|
||||
}
|
||||
|
||||
onSortingChanged(event: CustomEvent) {
|
||||
this.preferences.set('shared-files.sorting.key', event.detail.key || 'modifiedAt');
|
||||
this.preferences.set('shared-files.sorting.direction', event.detail.direction || 'desc');
|
||||
this.preferences.set(`${this.prefix}.sorting.key`, event.detail.key || 'modifiedAt');
|
||||
this.preferences.set(`${this.prefix}.sorting.direction`, event.detail.direction || 'desc');
|
||||
}
|
||||
|
||||
private get prefix() {
|
||||
return this.route.snapshot.data.preferencePrefix;
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { CoreModule, AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { TrashcanComponent } from './trashcan.component';
|
||||
@@ -49,6 +49,7 @@ describe('TrashcanComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
RouterTestingModule,
|
||||
CoreModule,
|
||||
CommonModule
|
||||
],
|
||||
|
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Subscription } from 'rxjs/Rx';
|
||||
import { Pagination } from 'alfresco-js-api';
|
||||
import { UserPreferencesService } from '@alfresco/adf-core';
|
||||
@@ -41,9 +42,12 @@ export class TrashcanComponent implements OnInit, OnDestroy {
|
||||
sorting = [ 'archivedAt', 'desc' ];
|
||||
|
||||
constructor(private contentManagementService: ContentManagementService,
|
||||
private preferences: UserPreferencesService) {
|
||||
const sortingKey = preferences.get('trashcan.sorting.key') || 'archivedAt';
|
||||
const sortingDirection = preferences.get('trashcan.sorting.direction') || 'desc';
|
||||
private preferences: UserPreferencesService,
|
||||
private route: ActivatedRoute) {
|
||||
|
||||
const sortingKey = preferences.get(`${this.prefix}.sorting.key`) || 'archivedAt';
|
||||
const sortingDirection = preferences.get(`${this.prefix}.sorting.direction`) || 'desc';
|
||||
|
||||
this.sorting = [sortingKey, sortingDirection];
|
||||
}
|
||||
|
||||
@@ -65,7 +69,11 @@ export class TrashcanComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
onSortingChanged(event: CustomEvent) {
|
||||
this.preferences.set('trashcan.sorting.key', event.detail.key || 'archivedAt');
|
||||
this.preferences.set('trashcan.sorting.direction', event.detail.direction || 'desc');
|
||||
this.preferences.set(`${this.prefix}.sorting.key`, event.detail.key || 'archivedAt');
|
||||
this.preferences.set(`${this.prefix}.sorting.direction`, event.detail.direction || 'desc');
|
||||
}
|
||||
|
||||
private get prefix() {
|
||||
return this.route.snapshot.data.preferencePrefix;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user