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',
|
path: 'favorites',
|
||||||
|
data: {
|
||||||
|
preferencePrefix: 'favorites'
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
@@ -80,6 +83,9 @@ export const APP_ROUTES: Routes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'libraries',
|
path: 'libraries',
|
||||||
|
data: {
|
||||||
|
preferencePrefix: 'libraries'
|
||||||
|
},
|
||||||
children: [{
|
children: [{
|
||||||
path: '',
|
path: '',
|
||||||
component: LibrariesComponent,
|
component: LibrariesComponent,
|
||||||
@@ -90,7 +96,8 @@ export const APP_ROUTES: Routes = [
|
|||||||
path: ':folderId',
|
path: ':folderId',
|
||||||
component: FilesComponent,
|
component: FilesComponent,
|
||||||
data: {
|
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',
|
path: 'personal-files',
|
||||||
|
data: {
|
||||||
|
preferencePrefix: 'personal-files'
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
@@ -144,6 +154,9 @@ export const APP_ROUTES: Routes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'recent-files',
|
path: 'recent-files',
|
||||||
|
data: {
|
||||||
|
preferencePrefix: 'recent-files'
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
@@ -165,6 +178,9 @@ export const APP_ROUTES: Routes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'shared',
|
path: 'shared',
|
||||||
|
data: {
|
||||||
|
preferencePrefix: 'shared-files'
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
@@ -188,7 +204,8 @@ export const APP_ROUTES: Routes = [
|
|||||||
path: 'trashcan',
|
path: 'trashcan',
|
||||||
component: TrashcanComponent,
|
component: TrashcanComponent,
|
||||||
data: {
|
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) {
|
preferences: UserPreferencesService) {
|
||||||
super(preferences);
|
super(preferences);
|
||||||
|
|
||||||
const sortingKey = preferences.get('favorites.sorting.key') || 'modifiedAt';
|
const sortingKey = preferences.get(`${this.prefix}.sorting.key`) || 'modifiedAt';
|
||||||
const sortingDirection = preferences.get('favorites.sorting.direction') || 'desc';
|
const sortingDirection = preferences.get(`${this.prefix}.sorting.direction`) || 'desc';
|
||||||
|
|
||||||
this.sorting = [sortingKey, sortingDirection];
|
this.sorting = [sortingKey, sortingDirection];
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,11 @@ export class FavoritesComponent extends PageComponent implements OnInit, OnDestr
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSortingChanged(event: CustomEvent) {
|
onSortingChanged(event: CustomEvent) {
|
||||||
this.preferences.set('favorites.sorting.key', event.detail.key || 'modifiedAt');
|
this.preferences.set(`${this.prefix}.sorting.key`, event.detail.key || 'modifiedAt');
|
||||||
this.preferences.set('favorites.sorting.direction', event.detail.direction || 'desc');
|
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) {
|
preferences: UserPreferencesService) {
|
||||||
super(preferences);
|
super(preferences);
|
||||||
|
|
||||||
const sortingKey = preferences.get('personal-files.sorting.key') || 'modifiedAt';
|
const sortingKey = this.preferences.get(`${this.prefix}.sorting.key`) || 'modifiedAt';
|
||||||
const sortingDirection = preferences.get('personal-files.sorting.direction') || 'desc';
|
const sortingDirection = this.preferences.get(`${this.prefix}.sorting.direction`) || 'desc';
|
||||||
|
|
||||||
this.sorting = [sortingKey, sortingDirection];
|
this.sorting = [sortingKey, sortingDirection];
|
||||||
}
|
}
|
||||||
@@ -309,7 +309,11 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSortingChanged(event: CustomEvent) {
|
onSortingChanged(event: CustomEvent) {
|
||||||
this.preferences.set('personal-files.sorting.key', event.detail.key || 'modifiedAt');
|
this.preferences.set(`${this.prefix}.sorting.key`, event.detail.key || 'modifiedAt');
|
||||||
this.preferences.set('personal-files.sorting.direction', event.detail.direction || 'desc');
|
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) {
|
preferences: UserPreferencesService) {
|
||||||
super(preferences);
|
super(preferences);
|
||||||
|
|
||||||
const sortingKey = preferences.get('libraries.sorting.key') || 'title';
|
const sortingKey = preferences.get(`${this.prefix}.sorting.key`) || 'title';
|
||||||
const sortingDirection = preferences.get('libraries.sorting.direction') || 'desc';
|
const sortingDirection = preferences.get(`${this.prefix}.sorting.direction`) || 'desc';
|
||||||
|
|
||||||
this.sorting = [sortingKey, sortingDirection];
|
this.sorting = [sortingKey, sortingDirection];
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,11 @@ export class LibrariesComponent extends PageComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSortingChanged(event: CustomEvent) {
|
onSortingChanged(event: CustomEvent) {
|
||||||
this.preferences.set('libraries.sorting.key', event.detail.key || 'modifiedAt');
|
this.preferences.set(`${this.prefix}.sorting.key`, event.detail.key || 'modifiedAt');
|
||||||
this.preferences.set('libraries.sorting.direction', event.detail.direction || 'desc');
|
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) {
|
preferences: UserPreferencesService) {
|
||||||
super(preferences);
|
super(preferences);
|
||||||
|
|
||||||
const sortingKey = preferences.get('recent-files.sorting.key') || 'modifiedAt';
|
const sortingKey = preferences.get(`${this.prefix}.sorting.key`) || 'modifiedAt';
|
||||||
const sortingDirection = preferences.get('recent-files.sorting.direction') || 'desc';
|
const sortingDirection = preferences.get(`${this.prefix}.sorting.direction`) || 'desc';
|
||||||
|
|
||||||
this.sorting = [sortingKey, sortingDirection];
|
this.sorting = [sortingKey, sortingDirection];
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,11 @@ export class RecentFilesComponent extends PageComponent implements OnInit, OnDes
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSortingChanged(event: CustomEvent) {
|
onSortingChanged(event: CustomEvent) {
|
||||||
this.preferences.set('recent-files.sorting.key', event.detail.key || 'modifiedAt');
|
this.preferences.set(`${this.prefix}.sorting.key`, event.detail.key || 'modifiedAt');
|
||||||
this.preferences.set('recent-files.sorting.direction', event.detail.direction || 'desc');
|
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) {
|
preferences: UserPreferencesService) {
|
||||||
super(preferences);
|
super(preferences);
|
||||||
|
|
||||||
const sortingKey = preferences.get('shared-files.sorting.key') || 'modifiedAt';
|
const sortingKey = preferences.get(`${this.prefix}.sorting.key`) || 'modifiedAt';
|
||||||
const sortingDirection = preferences.get('shared-files.sorting.direction') || 'desc';
|
const sortingDirection = preferences.get(`${this.prefix}.sorting.direction`) || 'desc';
|
||||||
|
|
||||||
this.sorting = [sortingKey, sortingDirection];
|
this.sorting = [sortingKey, sortingDirection];
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,11 @@ export class SharedFilesComponent extends PageComponent implements OnInit, OnDes
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSortingChanged(event: CustomEvent) {
|
onSortingChanged(event: CustomEvent) {
|
||||||
this.preferences.set('shared-files.sorting.key', event.detail.key || 'modifiedAt');
|
this.preferences.set(`${this.prefix}.sorting.key`, event.detail.key || 'modifiedAt');
|
||||||
this.preferences.set('shared-files.sorting.direction', event.detail.direction || 'desc');
|
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
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* 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 { TestBed, async } from '@angular/core/testing';
|
||||||
import { CoreModule, AlfrescoApiService } from '@alfresco/adf-core';
|
import { CoreModule, AlfrescoApiService } from '@alfresco/adf-core';
|
||||||
import { TrashcanComponent } from './trashcan.component';
|
import { TrashcanComponent } from './trashcan.component';
|
||||||
@@ -49,6 +49,7 @@ describe('TrashcanComponent', () => {
|
|||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
RouterTestingModule,
|
||||||
CoreModule,
|
CoreModule,
|
||||||
CommonModule
|
CommonModule
|
||||||
],
|
],
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core';
|
import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { Subscription } from 'rxjs/Rx';
|
import { Subscription } from 'rxjs/Rx';
|
||||||
import { Pagination } from 'alfresco-js-api';
|
import { Pagination } from 'alfresco-js-api';
|
||||||
import { UserPreferencesService } from '@alfresco/adf-core';
|
import { UserPreferencesService } from '@alfresco/adf-core';
|
||||||
@@ -41,9 +42,12 @@ export class TrashcanComponent implements OnInit, OnDestroy {
|
|||||||
sorting = [ 'archivedAt', 'desc' ];
|
sorting = [ 'archivedAt', 'desc' ];
|
||||||
|
|
||||||
constructor(private contentManagementService: ContentManagementService,
|
constructor(private contentManagementService: ContentManagementService,
|
||||||
private preferences: UserPreferencesService) {
|
private preferences: UserPreferencesService,
|
||||||
const sortingKey = preferences.get('trashcan.sorting.key') || 'archivedAt';
|
private route: ActivatedRoute) {
|
||||||
const sortingDirection = preferences.get('trashcan.sorting.direction') || 'desc';
|
|
||||||
|
const sortingKey = preferences.get(`${this.prefix}.sorting.key`) || 'archivedAt';
|
||||||
|
const sortingDirection = preferences.get(`${this.prefix}.sorting.direction`) || 'desc';
|
||||||
|
|
||||||
this.sorting = [sortingKey, sortingDirection];
|
this.sorting = [sortingKey, sortingDirection];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +69,11 @@ export class TrashcanComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSortingChanged(event: CustomEvent) {
|
onSortingChanged(event: CustomEvent) {
|
||||||
this.preferences.set('trashcan.sorting.key', event.detail.key || 'archivedAt');
|
this.preferences.set(`${this.prefix}.sorting.key`, event.detail.key || 'archivedAt');
|
||||||
this.preferences.set('trashcan.sorting.direction', event.detail.direction || 'desc');
|
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