mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[ADF-2025] Task List - The pagination should be fetched from the UserPreference (#2733)
[ADF-2025] Task List - The pagination should be fetched from the UserPreference
This commit is contained in:
parent
910b2b344c
commit
4462486df1
@ -51,7 +51,8 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"pagination": {
|
"pagination": {
|
||||||
"size": 25
|
"size": 25,
|
||||||
|
"supportedPageSizes": [ 5, 10, 15, 20 ]
|
||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"excluded": [".DS_Store", "desktop.ini", ".git"]
|
"excluded": [".DS_Store", "desktop.ini", ".git"]
|
||||||
@ -83,7 +84,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"document-list": {
|
"document-list": {
|
||||||
"supportedPageSizes": [ 5, 10, 15, 25 ],
|
|
||||||
"presets": {
|
"presets": {
|
||||||
"-trashcan-": [
|
"-trashcan-": [
|
||||||
{
|
{
|
||||||
@ -330,7 +330,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"adf-task-list": {
|
"adf-task-list": {
|
||||||
"supportedPageSizes": [ 5, 10, 15, 25 ],
|
|
||||||
"presets": {
|
"presets": {
|
||||||
"default": [
|
"default": [
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
(nextPage)="onNextPage($event)"
|
(nextPage)="onNextPage($event)"
|
||||||
(prevPage)="onPrevPage($event)"
|
(prevPage)="onPrevPage($event)"
|
||||||
[pagination]="taskPagination"
|
[pagination]="taskPagination"
|
||||||
[supportedPageSizes]="[2, 4, 6, 8, 10, 12]">
|
[supportedPageSizes]="supportedPages">
|
||||||
</adf-pagination>
|
</adf-pagination>
|
||||||
</div>
|
</div>
|
||||||
<div class="adf-grid-item adf-tasks-details" *ngIf="!isStartTaskMode()" fxFlex.gt-md="1 1 auto">
|
<div class="adf-grid-item adf-tasks-details" *ngIf="!isStartTaskMode()" fxFlex.gt-md="1 1 auto">
|
||||||
|
@ -52,7 +52,7 @@ import {
|
|||||||
TaskListService
|
TaskListService
|
||||||
} from '@alfresco/adf-process-services';
|
} from '@alfresco/adf-process-services';
|
||||||
import { LogService } from '@alfresco/adf-core';
|
import { LogService } from '@alfresco/adf-core';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import { AlfrescoApiService, UserPreferencesService } from '@alfresco/adf-core';
|
||||||
import {
|
import {
|
||||||
DataSorting,
|
DataSorting,
|
||||||
ObjectDataRow,
|
ObjectDataRow,
|
||||||
@ -121,6 +121,8 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
|
|||||||
taskPage = 0;
|
taskPage = 0;
|
||||||
processSchemaColumns: any[] = [];
|
processSchemaColumns: any[] = [];
|
||||||
|
|
||||||
|
supportedPages: number[];
|
||||||
|
|
||||||
activeTab: number = this.tabs.tasks; // tasks|processes|reports
|
activeTab: number = this.tabs.tasks; // tasks|processes|reports
|
||||||
|
|
||||||
taskFilter: FilterRepresentationModel;
|
taskFilter: FilterRepresentationModel;
|
||||||
@ -147,9 +149,12 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
|
|||||||
private apiService: AlfrescoApiService,
|
private apiService: AlfrescoApiService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
formRenderingService: FormRenderingService,
|
formRenderingService: FormRenderingService,
|
||||||
formService: FormService) {
|
formService: FormService,
|
||||||
|
private preferenceService: UserPreferencesService) {
|
||||||
this.dataTasks = new ObjectDataTableAdapter();
|
this.dataTasks = new ObjectDataTableAdapter();
|
||||||
this.dataTasks.setSorting(new DataSorting('created', 'desc'));
|
this.dataTasks.setSorting(new DataSorting('created', 'desc'));
|
||||||
|
this.supportedPages = this.preferenceService.getDifferentPageSizes();
|
||||||
|
this.taskPagination.maxItems = this.preferenceService.paginationSize;
|
||||||
|
|
||||||
// Uncomment this line to replace all 'text' field editors with custom component
|
// Uncomment this line to replace all 'text' field editors with custom component
|
||||||
// formRenderingService.setComponentTypeResolver('text', () => CustomEditorComponent, true);
|
// formRenderingService.setComponentTypeResolver('text', () => CustomEditorComponent, true);
|
||||||
@ -200,6 +205,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
|
|||||||
this.taskPage = this.currentPage(skipCount, maxItems);
|
this.taskPage = this.currentPage(skipCount, maxItems);
|
||||||
this.taskPagination.maxItems = maxItems;
|
this.taskPagination.maxItems = maxItems;
|
||||||
this.taskPagination.skipCount = skipCount;
|
this.taskPagination.skipCount = skipCount;
|
||||||
|
this.preferenceService.paginationSize = maxItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
onChangePageNumber(pagination: Pagination): void {
|
onChangePageNumber(pagination: Pagination): void {
|
||||||
|
@ -28,6 +28,7 @@ import { UserPreferencesService } from './user-preferences.service';
|
|||||||
describe('UserPreferencesService', () => {
|
describe('UserPreferencesService', () => {
|
||||||
|
|
||||||
const defaultPaginationSize: number = 10;
|
const defaultPaginationSize: number = 10;
|
||||||
|
const supportedPaginationSize = [5, 10, 15, 20];
|
||||||
let preferences: UserPreferencesService;
|
let preferences: UserPreferencesService;
|
||||||
let storage: StorageService;
|
let storage: StorageService;
|
||||||
let appConfig: AppConfigService;
|
let appConfig: AppConfigService;
|
||||||
@ -55,7 +56,8 @@ describe('UserPreferencesService', () => {
|
|||||||
appConfig = TestBed.get(AppConfigService);
|
appConfig = TestBed.get(AppConfigService);
|
||||||
appConfig.config = {
|
appConfig.config = {
|
||||||
pagination: {
|
pagination: {
|
||||||
size: 10
|
'size': 10,
|
||||||
|
'supportedPageSizes': [ 5, 10, 15, 20 ]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
preferences = TestBed.get(UserPreferencesService);
|
preferences = TestBed.get(UserPreferencesService);
|
||||||
@ -64,7 +66,12 @@ describe('UserPreferencesService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should get default pagination from app config', () => {
|
it('should get default pagination from app config', () => {
|
||||||
expect(preferences.paginationSize).toBe(defaultPaginationSize);
|
expect(preferences.defaults.paginationSize).toBe(defaultPaginationSize);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return supported page sizes defined in the app config', () => {
|
||||||
|
const supportedPages = preferences.getDifferentPageSizes();
|
||||||
|
expect(supportedPages).toEqual(supportedPaginationSize);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use [GUEST] as default storage prefix', () => {
|
it('should use [GUEST] as default storage prefix', () => {
|
||||||
|
@ -26,8 +26,9 @@ import { StorageService } from './storage.service';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserPreferencesService {
|
export class UserPreferencesService {
|
||||||
|
|
||||||
private defaults = {
|
defaults = {
|
||||||
paginationSize: 25,
|
paginationSize: 25,
|
||||||
|
supportedPageSizes: [5, 10, 15, 20],
|
||||||
locale: 'en'
|
locale: 'en'
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -43,7 +44,8 @@ export class UserPreferencesService {
|
|||||||
const currentLocale = this.locale || this.getDefaultLocale();
|
const currentLocale = this.locale || this.getDefaultLocale();
|
||||||
this.localeSubject = new BehaviorSubject(currentLocale);
|
this.localeSubject = new BehaviorSubject(currentLocale);
|
||||||
this.locale$ = this.localeSubject.asObservable();
|
this.locale$ = this.localeSubject.asObservable();
|
||||||
this.defaults.paginationSize = appConfig.get('pagination.size', 25);
|
this.defaults.paginationSize = this.appConfig.get('pagination.size', this.defaults.paginationSize);
|
||||||
|
this.defaults.supportedPageSizes = this.appConfig.get('pagination.supportedPageSizes', this.defaults.supportedPageSizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
get(property: string, defaultValue?: string): string {
|
get(property: string, defaultValue?: string): string {
|
||||||
@ -76,6 +78,10 @@ export class UserPreferencesService {
|
|||||||
return `${this.getStoragePrefix()}__${property}`;
|
return `${this.getStoragePrefix()}__${property}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDifferentPageSizes(): number[] {
|
||||||
|
return this.defaults.supportedPageSizes;
|
||||||
|
}
|
||||||
|
|
||||||
set authType(value: string) {
|
set authType(value: string) {
|
||||||
this.storage.setItem('AUTH_TYPE', value);
|
this.storage.setItem('AUTH_TYPE', value);
|
||||||
this.apiService.reset();
|
this.apiService.reset();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user