[ADF-3945] Add Infinite Pagination to configuration editor (#4388)

* [ADF-3945] Add Infinite Pagination to configuration editor

* [ADF-3945] Switch to user preference instead of app config

* Update content-node-selector-panel.component.scss
This commit is contained in:
davidcanonieto
2019-03-08 00:15:26 +00:00
committed by Eugenio Romano
parent 9344dbe969
commit 88ef01011e
3 changed files with 40 additions and 4 deletions

View File

@@ -69,6 +69,13 @@
<mat-icon>info</mat-icon> <mat-icon>info</mat-icon>
</button> </button>
</mat-list-item> </mat-list-item>
<mat-list-item (click)="infinitePaginationConfClick()">
<a matLine id="adf-infinite-pagination-conf">Infinite pagination</a>
<button mat-icon-button>
<mat-icon>info</mat-icon>
</button>
</mat-list-item>
</mat-nav-list> </mat-nav-list>
<div> <div>

View File

@@ -16,7 +16,7 @@
*/ */
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { AppConfigService, NotificationService } from '@alfresco/adf-core'; import { AppConfigService, NotificationService, UserPreferencesService, UserPreferenceValues } from '@alfresco/adf-core';
@Component({ @Component({
selector: 'app-config-editor', selector: 'app-config-editor',
@@ -29,6 +29,8 @@ export class ConfigEditorComponent {
code: any; code: any;
field = 'content-metadata'; field = 'content-metadata';
invalidJson = false; invalidJson = false;
isUserPreference = false;
userPreferenceProperty: string;
editorOptions = { editorOptions = {
theme: 'vs-dark', theme: 'vs-dark',
@@ -43,13 +45,19 @@ export class ConfigEditorComponent {
this.indentCode(); this.indentCode();
} }
constructor(private appConfig: AppConfigService, private notificationService: NotificationService) { constructor(private appConfig: AppConfigService,
private userPreferencesService: UserPreferencesService,
private notificationService: NotificationService) {
this.code = JSON.stringify(appConfig.config['content-metadata']); this.code = JSON.stringify(appConfig.config['content-metadata']);
} }
onSave() { onSave() {
try { try {
this.appConfig.config[this.field] = JSON.parse(this.editor.getValue()); if (this.isUserPreference) {
this.userPreferencesService.set(this.userPreferenceProperty, JSON.parse(this.editor.getValue()));
} else {
this.appConfig.config[this.field] = JSON.parse(this.editor.getValue());
}
} catch (error) { } catch (error) {
this.invalidJson = true; this.invalidJson = true;
this.notificationService.openSnackMessage( this.notificationService.openSnackMessage(
@@ -71,65 +79,85 @@ export class ConfigEditorComponent {
} }
fileConfClick() { fileConfClick() {
this.isUserPreference = false;
this.code = JSON.stringify(this.appConfig.config['files']); this.code = JSON.stringify(this.appConfig.config['files']);
this.field = 'files'; this.field = 'files';
this.indentCode(); this.indentCode();
} }
searchConfClick() { searchConfClick() {
this.isUserPreference = false;
this.code = JSON.stringify(this.appConfig.config['search']); this.code = JSON.stringify(this.appConfig.config['search']);
this.field = 'search'; this.field = 'search';
this.indentCode(); this.indentCode();
} }
metadataConfClick() { metadataConfClick() {
this.isUserPreference = false;
this.code = JSON.stringify(this.appConfig.config['content-metadata']); this.code = JSON.stringify(this.appConfig.config['content-metadata']);
this.field = 'content-metadata'; this.field = 'content-metadata';
this.indentCode(); this.indentCode();
} }
taskHeaderConfClick() { taskHeaderConfClick() {
this.isUserPreference = false;
this.code = JSON.stringify(this.appConfig.config['adf-task-header']); this.code = JSON.stringify(this.appConfig.config['adf-task-header']);
this.field = 'adf-task-header'; this.field = 'adf-task-header';
this.indentCode(); this.indentCode();
} }
processInstanceHeaderConfClick() { processInstanceHeaderConfClick() {
this.isUserPreference = false;
this.code = JSON.stringify(this.appConfig.config['adf-process-instance-header']); this.code = JSON.stringify(this.appConfig.config['adf-process-instance-header']);
this.field = 'adf-process-instance-header'; this.field = 'adf-process-instance-header';
this.indentCode(); this.indentCode();
} }
startProcessConfClick() { startProcessConfClick() {
this.isUserPreference = false;
this.code = JSON.stringify(this.appConfig.config['adf-start-process']); this.code = JSON.stringify(this.appConfig.config['adf-start-process']);
this.field = 'adf-start-process'; this.field = 'adf-start-process';
this.indentCode(); this.indentCode();
} }
taskListCloudConfClick() { taskListCloudConfClick() {
this.isUserPreference = false;
this.code = JSON.stringify(this.appConfig.config['adf-cloud-task-list']); this.code = JSON.stringify(this.appConfig.config['adf-cloud-task-list']);
this.field = 'adf-cloud-task-list'; this.field = 'adf-cloud-task-list';
this.indentCode(); this.indentCode();
} }
editProcessFilterConfClick() { editProcessFilterConfClick() {
this.isUserPreference = false;
this.code = JSON.stringify(this.appConfig.config['adf-edit-process-filter']); this.code = JSON.stringify(this.appConfig.config['adf-edit-process-filter']);
this.field = 'adf-edit-process-filter'; this.field = 'adf-edit-process-filter';
this.indentCode(); this.indentCode();
} }
editTaskFilterConfClick() { editTaskFilterConfClick() {
this.isUserPreference = false;
this.code = JSON.stringify(this.appConfig.config['adf-edit-task-filter']); this.code = JSON.stringify(this.appConfig.config['adf-edit-task-filter']);
this.field = 'adf-edit-task-filter'; this.field = 'adf-edit-task-filter';
this.indentCode(); this.indentCode();
} }
processListCloudConfClick() { processListCloudConfClick() {
this.isUserPreference = false;
this.code = JSON.stringify(this.appConfig.config['adf-cloud-process-list']); this.code = JSON.stringify(this.appConfig.config['adf-cloud-process-list']);
this.field = 'adf-cloud-process-list'; this.field = 'adf-cloud-process-list';
this.indentCode(); this.indentCode();
} }
infinitePaginationConfClick() {
this.isUserPreference = true;
this.userPreferenceProperty = UserPreferenceValues.PaginationSize;
this.userPreferencesService.select(this.userPreferenceProperty).subscribe((pageSize: number) => {
this.code = JSON.stringify(pageSize);
this.field = 'adf-infinite-pagination';
this.indentCode();
});
}
indentCode() { indentCode() {
setTimeout(() => { setTimeout(() => {
this.editor.getAction('editor.action.formatDocument').run(); this.editor.getAction('editor.action.formatDocument').run();

View File

@@ -92,7 +92,8 @@ export class InfinitePaginationComponent implements OnInit, OnDestroy, Paginatio
private paginationSubscription: Subscription; private paginationSubscription: Subscription;
constructor(private cdr: ChangeDetectorRef, private userPreferencesService: UserPreferencesService) { constructor(private cdr: ChangeDetectorRef,
private userPreferencesService: UserPreferencesService) {
} }
ngOnInit() { ngOnInit() {