[ADF-3830] Remove landingTaskId and selectRowFirst properties (#4208)

This commit is contained in:
davidcanonieto 2019-01-27 02:15:37 +00:00 committed by Eugenio Romano
parent f8c379a0d9
commit eb3a45cde9
6 changed files with 5 additions and 154 deletions

View File

@ -55,12 +55,10 @@ when the process list is empty:
| 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. |
| 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 |
| 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. |
| 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. |
| 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. |

View File

@ -56,7 +56,6 @@ when the task list is empty:
| 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. |
| 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. |
| 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. |

View File

@ -178,40 +178,6 @@ describe('ProcessListCloudComponent', () => {
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', () => {
let fixtureCustom: ComponentFixture<CustomTaskListComponent>;

View File

@ -15,7 +15,7 @@
* 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,
CustomEmptyContentTemplateDirective, AppConfigService,
UserPreferencesService, PaginationModel,
@ -25,7 +25,6 @@ import { BehaviorSubject } from 'rxjs';
import { processCloudPresetsDefaultModel } from '../models/process-cloud-preset.model';
import { ProcessQueryCloudRequestModel } from '../models/process-cloud-query-request.model';
import { ProcessListCloudSortingModel } from '../models/process-list-sorting.model';
import { NodeEntry } from '@alfresco/js-api';
@Component({
selector: 'adf-cloud-process-list',
templateUrl: './process-list-cloud.component.html',
@ -78,18 +77,6 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
@Input()
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".
* 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) {
if (this.isPropertyChanged(changes) &&
!this.isEqualToCurrentId(changes['landingTaskId'])) {
if (this.isPropertyChanged(changes)) {
this.reload();
}
}
@ -178,7 +164,6 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
this.processListCloudService.getProcessByRequest(requestNode).subscribe(
(processes) => {
this.rows = processes.list.entries;
this.selectTask(this.landingTaskId);
this.success.emit(processes);
this.isLoading = false;
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 {
for (let property in changes) {
if (changes.hasOwnProperty(property)) {
@ -204,26 +185,6 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
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 {
return !this.rows || this.rows.length === 0;
}

View File

@ -22,7 +22,7 @@ import { AppConfigService, setupTestBed, CoreModule } from '@alfresco/adf-core';
import { DataRowEvent, ObjectDataRow } from '@alfresco/adf-core';
import { TaskListCloudService } from '../services/task-list-cloud.service';
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 { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
import { TaskListCloudModule } from '../task-list-cloud.module';
@ -160,21 +160,6 @@ describe('TaskListCloudComponent', () => {
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) => {
component.applicationName = 'fake';
spyOn(taskListCloudService, 'getTaskByRequest').and.returnValue(of(fakeGlobalTask));
@ -210,33 +195,6 @@ describe('TaskListCloudComponent', () => {
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', () => {
component.rows = null;
component.ngOnChanges({});

View File

@ -15,7 +15,7 @@
* 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,
DataTableSchema, UserPreferenceValues,
PaginatedComponent, PaginationModel,
@ -24,7 +24,6 @@ import { taskPresetsCloudDefaultModel } from '../models/task-preset-cloud.model'
import { TaskQueryCloudRequestModel } from '../models/filter-cloud-model';
import { BehaviorSubject } from 'rxjs';
import { TaskListCloudService } from '../services/task-list-cloud.service';
import { NodeEntry } from '@alfresco/js-api';
import { TaskListCloudSortingModel } from '../models/task-list-sorting.model';
@Component({
@ -85,13 +84,6 @@ export class TaskListCloudComponent extends DataTableSchema implements OnChanges
@Input()
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,
* 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) {
if (this.isPropertyChanged(changes) &&
!this.isEqualToCurrentId(changes['landingTaskId'])) {
if (this.isPropertyChanged(changes)) {
this.reload();
}
}
@ -168,10 +159,6 @@ export class TaskListCloudComponent extends DataTableSchema implements OnChanges
return this.currentInstanceId;
}
isEqualToCurrentId(landingTaskChanged: SimpleChange): boolean {
return landingTaskChanged && this.currentInstanceId === landingTaskChanged.currentValue;
}
private isPropertyChanged(changes: SimpleChanges): boolean {
for (let property in changes) {
if (changes.hasOwnProperty(property)) {
@ -198,7 +185,6 @@ export class TaskListCloudComponent extends DataTableSchema implements OnChanges
this.taskListCloudService.getTaskByRequest(requestNode).subscribe(
(tasks) => {
this.rows = tasks.list.entries;
this.selectTask(this.landingTaskId);
this.success.emit(tasks);
this.isLoading = false;
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 {
return !this.rows || this.rows.length === 0;
}