mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[ADF-3830] Remove landingTaskId and selectRowFirst properties (#4208)
This commit is contained in:
parent
f8c379a0d9
commit
eb3a45cde9
@ -55,12 +55,10 @@ when the process list is empty:
|
|||||||
| businessKey | `string` | "" | Filter the tasks to display only the ones with this businessKey value. |
|
| businessKey | `string` | "" | Filter the tasks to display only the ones with this businessKey value. |
|
||||||
| id | `string` | "" | Filter the processes to display only the ones with this ID. |
|
| id | `string` | "" | Filter the processes to display only the ones with this ID. |
|
||||||
| initiator | `string` | "" | Name of the initiator of the process. |
|
| initiator | `string` | "" | Name of the initiator of the process. |
|
||||||
| landingTaskId | `string` | | Define which task id should be selected after reloading. If the task id doesn't exist or nothing is passed then the first task will be selected. |
|
|
||||||
| multiselect | `boolean` | false | Toggles multiple row selection and renders checkboxes at the beginning of each row |
|
| multiselect | `boolean` | false | Toggles multiple row selection and renders checkboxes at the beginning of each row |
|
||||||
| name | `string` | "" | Filter the processes to display only the ones with this name. |
|
| name | `string` | "" | Filter the processes to display only the ones with this name. |
|
||||||
| processDefinitionId | `string` | "" | Filter the processes to display only the ones with this process definition ID. |
|
| processDefinitionId | `string` | "" | Filter the processes to display only the ones with this process definition ID. |
|
||||||
| processDefinitionKey | `string` | "" | Filter the processes to display only the ones with this process definition key. |
|
| processDefinitionKey | `string` | "" | Filter the processes to display only the ones with this process definition key. |
|
||||||
| selectFirstRow | `boolean` | true | Toggles default selection of the first row |
|
|
||||||
| selectionMode | `string` | "single" | Row selection mode. Can be "none", "single" or "multiple". For multiple mode, you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows. |
|
| selectionMode | `string` | "single" | Row selection mode. Can be "none", "single" or "multiple". For multiple mode, you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows. |
|
||||||
| sorting | [`ProcessListCloudSortingModel`](../../lib/process-services-cloud/src/lib/process/process-list/models/process-list-sorting.model.ts)`[]` | | Array of objects specifying the sort order and direction for the list. The sort parameters are for BE sorting. |
|
| sorting | [`ProcessListCloudSortingModel`](../../lib/process-services-cloud/src/lib/process/process-list/models/process-list-sorting.model.ts)`[]` | | Array of objects specifying the sort order and direction for the list. The sort parameters are for BE sorting. |
|
||||||
| status | `string` | "" | Filter the processes to display only the ones with this status. |
|
| status | `string` | "" | Filter the processes to display only the ones with this status. |
|
||||||
|
@ -56,7 +56,6 @@ when the task list is empty:
|
|||||||
| createdDate | `string` | "" | Filter the tasks. Display only tasks created on the supplied date. |
|
| createdDate | `string` | "" | Filter the tasks. Display only tasks created on the supplied date. |
|
||||||
| dueDate | `string` | "" | Filter the tasks. Display only tasks with dueDate equal to the supplied date. |
|
| dueDate | `string` | "" | Filter the tasks. Display only tasks with dueDate equal to the supplied date. |
|
||||||
| id | `string` | "" | Filter the tasks. Display only tasks with id equal to the supplied value. |
|
| id | `string` | "" | Filter the tasks. Display only tasks with id equal to the supplied value. |
|
||||||
| landingTaskId | `string` | | Define which task id should be selected after reloading. If the task id doesn't exist or nothing is passed then the first task will be selected. |
|
|
||||||
| multiselect | `boolean` | false | Toggles multiple row selection, rendering a checkbox at the beginning of each row. |
|
| multiselect | `boolean` | false | Toggles multiple row selection, rendering a checkbox at the beginning of each row. |
|
||||||
| name | `string` | "" | Filter the tasks. Display only tasks with the supplied name. |
|
| name | `string` | "" | Filter the tasks. Display only tasks with the supplied name. |
|
||||||
| parentTaskId | `string` | "" | Filter the tasks. Display only tasks with parentTaskId equal to the supplied value. |
|
| parentTaskId | `string` | "" | Filter the tasks. Display only tasks with parentTaskId equal to the supplied value. |
|
||||||
|
@ -178,40 +178,6 @@ describe('ProcessListCloudComponent', () => {
|
|||||||
component.onRowClick(rowEvent);
|
component.onRowClick(rowEvent);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('component changes', () => {
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
component.rows = fakeProcessCloudList.list.entries;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should NOT reload the tasks if the landingTaskId is the same of the current task', () => {
|
|
||||||
spyOn(component, 'reload').and.stub();
|
|
||||||
component.currentInstanceId = '999';
|
|
||||||
component.rows = [{ entry: { id: '999', name: 'Fake-name' } }];
|
|
||||||
const landingTaskId = '999';
|
|
||||||
let change = new SimpleChange('999', landingTaskId, true);
|
|
||||||
component.ngOnChanges({ 'landingTaskId': change });
|
|
||||||
expect(component.reload).not.toHaveBeenCalled();
|
|
||||||
expect(component.rows.length).toEqual(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reload the tasks if the loadingTaskId is different from the current task', (done) => {
|
|
||||||
component.currentInstanceId = '999';
|
|
||||||
component.rows = [{ id: '999', name: 'Fake-name' }];
|
|
||||||
const landingTaskId = '888';
|
|
||||||
let change = new SimpleChange(null, landingTaskId, true);
|
|
||||||
component.applicationName = 'fake';
|
|
||||||
spyOn(processListCloudService, 'getProcessByRequest').and.returnValue(of(fakeProcessCloudList));
|
|
||||||
component.success.subscribe((res) => {
|
|
||||||
expect(res).toBeDefined();
|
|
||||||
expect(component.rows).toBeDefined();
|
|
||||||
expect(component.rows.length).toEqual(3);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
component.ngOnChanges({ 'landingTaskId': change });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('Injecting custom colums for tasklist - CustomTaskListComponent', () => {
|
describe('Injecting custom colums for tasklist - CustomTaskListComponent', () => {
|
||||||
|
|
||||||
let fixtureCustom: ComponentFixture<CustomTaskListComponent>;
|
let fixtureCustom: ComponentFixture<CustomTaskListComponent>;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, ViewEncapsulation, OnChanges, AfterContentInit, ContentChild, Output, EventEmitter, SimpleChanges, SimpleChange, Input } from '@angular/core';
|
import { Component, ViewEncapsulation, OnChanges, AfterContentInit, ContentChild, Output, EventEmitter, SimpleChanges, Input } from '@angular/core';
|
||||||
import { DataTableSchema, PaginatedComponent,
|
import { DataTableSchema, PaginatedComponent,
|
||||||
CustomEmptyContentTemplateDirective, AppConfigService,
|
CustomEmptyContentTemplateDirective, AppConfigService,
|
||||||
UserPreferencesService, PaginationModel,
|
UserPreferencesService, PaginationModel,
|
||||||
@ -25,7 +25,6 @@ import { BehaviorSubject } from 'rxjs';
|
|||||||
import { processCloudPresetsDefaultModel } from '../models/process-cloud-preset.model';
|
import { processCloudPresetsDefaultModel } from '../models/process-cloud-preset.model';
|
||||||
import { ProcessQueryCloudRequestModel } from '../models/process-cloud-query-request.model';
|
import { ProcessQueryCloudRequestModel } from '../models/process-cloud-query-request.model';
|
||||||
import { ProcessListCloudSortingModel } from '../models/process-list-sorting.model';
|
import { ProcessListCloudSortingModel } from '../models/process-list-sorting.model';
|
||||||
import { NodeEntry } from '@alfresco/js-api';
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-cloud-process-list',
|
selector: 'adf-cloud-process-list',
|
||||||
templateUrl: './process-list-cloud.component.html',
|
templateUrl: './process-list-cloud.component.html',
|
||||||
@ -78,18 +77,6 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
|
|||||||
@Input()
|
@Input()
|
||||||
businessKey: string = '';
|
businessKey: string = '';
|
||||||
|
|
||||||
/** Toggles default selection of the first row */
|
|
||||||
@Input()
|
|
||||||
selectFirstRow: boolean = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define which task id should be selected after reloading.
|
|
||||||
* If the task id doesn't exist or nothing is passed then the first
|
|
||||||
* task will be selected.
|
|
||||||
*/
|
|
||||||
@Input()
|
|
||||||
landingTaskId: string;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Row selection mode. Can be "none", "single" or "multiple".
|
* Row selection mode. Can be "none", "single" or "multiple".
|
||||||
* For multiple mode, you can use Cmd (macOS) or Ctrl (Win) modifier
|
* For multiple mode, you can use Cmd (macOS) or Ctrl (Win) modifier
|
||||||
@ -154,8 +141,7 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (this.isPropertyChanged(changes) &&
|
if (this.isPropertyChanged(changes)) {
|
||||||
!this.isEqualToCurrentId(changes['landingTaskId'])) {
|
|
||||||
this.reload();
|
this.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,7 +164,6 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
|
|||||||
this.processListCloudService.getProcessByRequest(requestNode).subscribe(
|
this.processListCloudService.getProcessByRequest(requestNode).subscribe(
|
||||||
(processes) => {
|
(processes) => {
|
||||||
this.rows = processes.list.entries;
|
this.rows = processes.list.entries;
|
||||||
this.selectTask(this.landingTaskId);
|
|
||||||
this.success.emit(processes);
|
this.success.emit(processes);
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
this.pagination.next(processes.list.pagination);
|
this.pagination.next(processes.list.pagination);
|
||||||
@ -188,10 +173,6 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private isEqualToCurrentId(landingTaskChanged: SimpleChange): boolean {
|
|
||||||
return landingTaskChanged && this.currentInstanceId === landingTaskChanged.currentValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
private isPropertyChanged(changes: SimpleChanges): boolean {
|
private isPropertyChanged(changes: SimpleChanges): boolean {
|
||||||
for (let property in changes) {
|
for (let property in changes) {
|
||||||
if (changes.hasOwnProperty(property)) {
|
if (changes.hasOwnProperty(property)) {
|
||||||
@ -204,26 +185,6 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectTask(taskIdSelected: string) {
|
|
||||||
if (!this.isListEmpty()) {
|
|
||||||
let dataRow: any = null;
|
|
||||||
if (taskIdSelected) {
|
|
||||||
dataRow = this.rows.find((currentRow: NodeEntry) => {
|
|
||||||
return currentRow.entry.id === taskIdSelected;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (!dataRow && this.selectFirstRow) {
|
|
||||||
dataRow = this.rows[0];
|
|
||||||
}
|
|
||||||
if (dataRow) {
|
|
||||||
dataRow.isSelected = true;
|
|
||||||
this.currentInstanceId = dataRow.entry.id;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.currentInstanceId = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isListEmpty(): boolean {
|
isListEmpty(): boolean {
|
||||||
return !this.rows || this.rows.length === 0;
|
return !this.rows || this.rows.length === 0;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import { AppConfigService, setupTestBed, CoreModule } from '@alfresco/adf-core';
|
|||||||
import { DataRowEvent, ObjectDataRow } from '@alfresco/adf-core';
|
import { DataRowEvent, ObjectDataRow } from '@alfresco/adf-core';
|
||||||
import { TaskListCloudService } from '../services/task-list-cloud.service';
|
import { TaskListCloudService } from '../services/task-list-cloud.service';
|
||||||
import { TaskListCloudComponent } from './task-list-cloud.component';
|
import { TaskListCloudComponent } from './task-list-cloud.component';
|
||||||
import { fakeGlobalTask, fakeCustomSchema, fakeTaskCloudList } from '../mock/fakeTaskResponseMock';
|
import { fakeGlobalTask, fakeCustomSchema } from '../mock/fakeTaskResponseMock';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
|
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
|
||||||
import { TaskListCloudModule } from '../task-list-cloud.module';
|
import { TaskListCloudModule } from '../task-list-cloud.module';
|
||||||
@ -160,21 +160,6 @@ describe('TaskListCloudComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a currentId null when the taskList is empty', () => {
|
|
||||||
component.selectTask(null);
|
|
||||||
expect(component.getCurrentId()).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return selected id for the selected task', () => {
|
|
||||||
component.rows = [
|
|
||||||
{ entry: { id: '999', name: 'Fake-name' } },
|
|
||||||
{ entry: { id: '888', name: 'Fake-name-888' } }
|
|
||||||
];
|
|
||||||
component.selectTask('888');
|
|
||||||
expect(component.rows).toBeDefined();
|
|
||||||
expect(component.currentInstanceId).toEqual('888');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reload tasks when reload() is called', (done) => {
|
it('should reload tasks when reload() is called', (done) => {
|
||||||
component.applicationName = 'fake';
|
component.applicationName = 'fake';
|
||||||
spyOn(taskListCloudService, 'getTaskByRequest').and.returnValue(of(fakeGlobalTask));
|
spyOn(taskListCloudService, 'getTaskByRequest').and.returnValue(of(fakeGlobalTask));
|
||||||
@ -210,33 +195,6 @@ describe('TaskListCloudComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should NOT reload the tasks if the landingTaskId is the same of the current task', () => {
|
|
||||||
spyOn(component, 'reload').and.stub();
|
|
||||||
component.currentInstanceId = '999';
|
|
||||||
component.rows = [{ entry: { id: '999', name: 'Fake-name' } }];
|
|
||||||
const landingTaskId = '999';
|
|
||||||
let change = new SimpleChange('999', landingTaskId, true);
|
|
||||||
component.ngOnChanges({ 'landingTaskId': change });
|
|
||||||
expect(component.reload).not.toHaveBeenCalled();
|
|
||||||
expect(component.rows.length).toEqual(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reload the tasks if the loadingTaskId is different from the current task', (done) => {
|
|
||||||
component.currentInstanceId = '999';
|
|
||||||
component.rows = [{ id: '999', name: 'Fake-name' }];
|
|
||||||
const landingTaskId = '888';
|
|
||||||
let change = new SimpleChange(null, landingTaskId, true);
|
|
||||||
component.applicationName = 'fake';
|
|
||||||
spyOn(taskListCloudService, 'getTaskByRequest').and.returnValue(of(fakeTaskCloudList));
|
|
||||||
component.success.subscribe((res) => {
|
|
||||||
expect(res).toBeDefined();
|
|
||||||
expect(component.rows).toBeDefined();
|
|
||||||
expect(component.rows.length).toEqual(2);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
component.ngOnChanges({ 'landingTaskId': change });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should NOT reload the task list when no parameters changed', () => {
|
it('should NOT reload the task list when no parameters changed', () => {
|
||||||
component.rows = null;
|
component.rows = null;
|
||||||
component.ngOnChanges({});
|
component.ngOnChanges({});
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, ViewEncapsulation, OnChanges, Input, SimpleChanges, Output, EventEmitter, ContentChild, AfterContentInit, SimpleChange } from '@angular/core';
|
import { Component, ViewEncapsulation, OnChanges, Input, SimpleChanges, Output, EventEmitter, ContentChild, AfterContentInit } from '@angular/core';
|
||||||
import { AppConfigService, UserPreferencesService,
|
import { AppConfigService, UserPreferencesService,
|
||||||
DataTableSchema, UserPreferenceValues,
|
DataTableSchema, UserPreferenceValues,
|
||||||
PaginatedComponent, PaginationModel,
|
PaginatedComponent, PaginationModel,
|
||||||
@ -24,7 +24,6 @@ import { taskPresetsCloudDefaultModel } from '../models/task-preset-cloud.model'
|
|||||||
import { TaskQueryCloudRequestModel } from '../models/filter-cloud-model';
|
import { TaskQueryCloudRequestModel } from '../models/filter-cloud-model';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
import { TaskListCloudService } from '../services/task-list-cloud.service';
|
import { TaskListCloudService } from '../services/task-list-cloud.service';
|
||||||
import { NodeEntry } from '@alfresco/js-api';
|
|
||||||
import { TaskListCloudSortingModel } from '../models/task-list-sorting.model';
|
import { TaskListCloudSortingModel } from '../models/task-list-sorting.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -85,13 +84,6 @@ export class TaskListCloudComponent extends DataTableSchema implements OnChanges
|
|||||||
@Input()
|
@Input()
|
||||||
status: string = '';
|
status: string = '';
|
||||||
|
|
||||||
/**
|
|
||||||
* Define which task id should be selected after reloading. If the task id doesn't
|
|
||||||
* exist or nothing is passed then the first task will be selected.
|
|
||||||
*/
|
|
||||||
@Input()
|
|
||||||
landingTaskId: string;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Row selection mode. Can be none, `single` or `multiple`. For `multiple` mode,
|
* Row selection mode. Can be none, `single` or `multiple`. For `multiple` mode,
|
||||||
* you can use the Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for
|
* you can use the Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for
|
||||||
@ -154,8 +146,7 @@ export class TaskListCloudComponent extends DataTableSchema implements OnChanges
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (this.isPropertyChanged(changes) &&
|
if (this.isPropertyChanged(changes)) {
|
||||||
!this.isEqualToCurrentId(changes['landingTaskId'])) {
|
|
||||||
this.reload();
|
this.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,10 +159,6 @@ export class TaskListCloudComponent extends DataTableSchema implements OnChanges
|
|||||||
return this.currentInstanceId;
|
return this.currentInstanceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
isEqualToCurrentId(landingTaskChanged: SimpleChange): boolean {
|
|
||||||
return landingTaskChanged && this.currentInstanceId === landingTaskChanged.currentValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
private isPropertyChanged(changes: SimpleChanges): boolean {
|
private isPropertyChanged(changes: SimpleChanges): boolean {
|
||||||
for (let property in changes) {
|
for (let property in changes) {
|
||||||
if (changes.hasOwnProperty(property)) {
|
if (changes.hasOwnProperty(property)) {
|
||||||
@ -198,7 +185,6 @@ export class TaskListCloudComponent extends DataTableSchema implements OnChanges
|
|||||||
this.taskListCloudService.getTaskByRequest(requestNode).subscribe(
|
this.taskListCloudService.getTaskByRequest(requestNode).subscribe(
|
||||||
(tasks) => {
|
(tasks) => {
|
||||||
this.rows = tasks.list.entries;
|
this.rows = tasks.list.entries;
|
||||||
this.selectTask(this.landingTaskId);
|
|
||||||
this.success.emit(tasks);
|
this.success.emit(tasks);
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
this.pagination.next(tasks.list.pagination);
|
this.pagination.next(tasks.list.pagination);
|
||||||
@ -208,23 +194,6 @@ export class TaskListCloudComponent extends DataTableSchema implements OnChanges
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
selectTask(taskIdSelected: string) {
|
|
||||||
if (!this.isListEmpty()) {
|
|
||||||
let dataRow: any = null;
|
|
||||||
if (taskIdSelected) {
|
|
||||||
dataRow = this.rows.find((currentRow: NodeEntry) => {
|
|
||||||
return currentRow.entry.id === taskIdSelected;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (dataRow) {
|
|
||||||
dataRow.isSelected = true;
|
|
||||||
this.currentInstanceId = dataRow.entry.id;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.currentInstanceId = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isListEmpty(): boolean {
|
isListEmpty(): boolean {
|
||||||
return !this.rows || this.rows.length === 0;
|
return !this.rows || this.rows.length === 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user