[AAE-7243] fix process services eslint warnings (#7498)

* fix process services eslint warnings

* fix constants

* revert type changes
This commit is contained in:
Denys Vuika
2022-02-17 13:07:13 +00:00
committed by GitHub
parent 1a6746ff3c
commit e017423c8c
91 changed files with 1863 additions and 1920 deletions

View File

@@ -48,13 +48,13 @@ import {
ProcessInstanceDetailsComponent, ProcessInstanceDetailsComponent,
ProcessInstanceListComponent, ProcessInstanceListComponent,
StartProcessInstanceComponent, StartProcessInstanceComponent,
AppsListComponent,
FilterRepresentationModel, FilterRepresentationModel,
TaskDetailsComponent, TaskDetailsComponent,
TaskDetailsEvent, TaskDetailsEvent,
TaskFiltersComponent, TaskFiltersComponent,
TaskListComponent, TaskListComponent,
ProcessFormRenderingService ProcessFormRenderingService,
APP_LIST_LAYOUT_LIST
} from '@alfresco/adf-process-services'; } from '@alfresco/adf-process-services';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { /*CustomEditorComponent*/ CustomStencil01 } from './custom-editor/custom-editor.component'; import { /*CustomEditorComponent*/ CustomStencil01 } from './custom-editor/custom-editor.component';
@@ -270,7 +270,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
this.processFilter = null; this.processFilter = null;
this.currentProcessInstanceId = null; this.currentProcessInstanceId = null;
}); });
this.layoutType = AppsListComponent.LAYOUT_GRID; this.layoutType = APP_LIST_LAYOUT_LIST;
} }
ngOnDestroy() { ngOnDestroy() {

View File

@@ -24,13 +24,13 @@
"@typescript-eslint/naming-convention": "warn", "@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/consistent-type-assertions": "warn", "@typescript-eslint/consistent-type-assertions": "warn",
"@typescript-eslint/prefer-for-of": "warn", "@typescript-eslint/prefer-for-of": "warn",
"no-underscore-dangle": "warn", "no-underscore-dangle": ["error", { "allowAfterThis": true }],
"no-shadow": "warn", "no-shadow": "warn",
"quote-props": "warn", "quote-props": "warn",
"object-shorthand": "warn", "object-shorthand": "warn",
"prefer-const": "warn", "prefer-const": "warn",
"arrow-body-style": "warn", "arrow-body-style": "warn",
"@angular-eslint/no-output-native": "warn", "@angular-eslint/no-output-native": "off",
"space-before-function-paren": "warn", "space-before-function-paren": "warn",
"@angular-eslint/component-selector": [ "@angular-eslint/component-selector": [

View File

@@ -22,7 +22,7 @@ import { AppsProcessService, setupTestBed } from '@alfresco/adf-core';
import { of, throwError } from 'rxjs'; import { of, throwError } from 'rxjs';
import { defaultApp, deployedApps, nonDeployedApps } from '../mock/apps-list.mock'; import { defaultApp, deployedApps, nonDeployedApps } from '../mock/apps-list.mock';
import { AppsListComponent } from './apps-list.component'; import { AppsListComponent, APP_LIST_LAYOUT_GRID, APP_LIST_LAYOUT_LIST } from './apps-list.component';
import { ProcessTestingModule } from '../testing/process.testing.module'; import { ProcessTestingModule } from '../testing/process.testing.module';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@@ -181,14 +181,14 @@ describe('AppsListComponent', () => {
}); });
it('should display a grid when configured to', () => { it('should display a grid when configured to', () => {
component.layoutType = AppsListComponent.LAYOUT_GRID; component.layoutType = APP_LIST_LAYOUT_GRID;
fixture.detectChanges(); fixture.detectChanges();
expect(component.isGrid()).toBe(true); expect(component.isGrid()).toBe(true);
expect(component.isList()).toBe(false); expect(component.isList()).toBe(false);
}); });
it('should display a list when configured to', () => { it('should display a list when configured to', () => {
component.layoutType = AppsListComponent.LAYOUT_LIST; component.layoutType = APP_LIST_LAYOUT_LIST;
fixture.detectChanges(); fixture.detectChanges();
expect(component.isGrid()).toBe(false); expect(component.isGrid()).toBe(false);
expect(component.isList()).toBe(true); expect(component.isList()).toBe(true);

View File

@@ -22,6 +22,14 @@ import { AppDefinitionRepresentationModel } from '../task-list';
import { IconModel } from './icon.model'; import { IconModel } from './icon.model';
import { share, takeUntil, finalize } from 'rxjs/operators'; import { share, takeUntil, finalize } from 'rxjs/operators';
const DEFAULT_TASKS_APP: string = 'tasks';
const DEFAULT_TASKS_APP_NAME: string = 'ADF_TASK_LIST.APPS.TASK_APP_NAME';
const DEFAULT_TASKS_APP_THEME: string = 'theme-2';
const DEFAULT_TASKS_APP_ICON: string = 'glyphicon-asterisk';
export const APP_LIST_LAYOUT_LIST: string = 'LIST';
export const APP_LIST_LAYOUT_GRID: string = 'GRID';
@Component({ @Component({
selector: 'adf-apps', selector: 'adf-apps',
templateUrl: './apps-list.component.html', templateUrl: './apps-list.component.html',
@@ -31,14 +39,6 @@ import { share, takeUntil, finalize } from 'rxjs/operators';
}) })
export class AppsListComponent implements OnInit, AfterContentInit, OnDestroy { export class AppsListComponent implements OnInit, AfterContentInit, OnDestroy {
public static LAYOUT_LIST: string = 'LIST';
public static LAYOUT_GRID: string = 'GRID';
public static DEFAULT_TASKS_APP: string = 'tasks';
public static DEFAULT_TASKS_APP_NAME: string = 'ADF_TASK_LIST.APPS.TASK_APP_NAME';
public static DEFAULT_TASKS_APP_THEME: string = 'theme-2';
public static DEFAULT_TASKS_APP_ICON: string = 'glyphicon-asterisk';
public static DEFAULT_TASKS_APP_MATERIAL_ICON: string = 'favorite_border';
@ContentChild(CustomEmptyContentTemplateDirective) @ContentChild(CustomEmptyContentTemplateDirective)
emptyCustomContent: CustomEmptyContentTemplateDirective; emptyCustomContent: CustomEmptyContentTemplateDirective;
@@ -46,7 +46,7 @@ export class AppsListComponent implements OnInit, AfterContentInit, OnDestroy {
* values, "GRID" and "LIST". * values, "GRID" and "LIST".
*/ */
@Input() @Input()
layoutType: string = AppsListComponent.LAYOUT_GRID; layoutType: string = APP_LIST_LAYOUT_GRID;
/** Provides a way to filter the apps to show. */ /** Provides a way to filter the apps to show. */
@Input() @Input()
@@ -54,22 +54,20 @@ export class AppsListComponent implements OnInit, AfterContentInit, OnDestroy {
/** Emitted when an app entry is clicked. */ /** Emitted when an app entry is clicked. */
@Output() @Output()
appClick: EventEmitter<AppDefinitionRepresentationModel> = new EventEmitter<AppDefinitionRepresentationModel>(); appClick = new EventEmitter<AppDefinitionRepresentationModel>();
/** Emitted when an error occurs. */ /** Emitted when an error occurs. */
@Output() @Output()
error: EventEmitter<any> = new EventEmitter<any>(); error = new EventEmitter<any>();
private appsObserver: Observer<AppDefinitionRepresentationModel>;
apps$: Observable<AppDefinitionRepresentationModel>; apps$: Observable<AppDefinitionRepresentationModel>;
currentApp: AppDefinitionRepresentationModel; currentApp: AppDefinitionRepresentationModel;
appList: AppDefinitionRepresentationModel [] = []; appList: AppDefinitionRepresentationModel [] = [];
private iconsMDL: IconModel;
loading: boolean = false; loading: boolean = false;
hasEmptyCustomContentTemplate: boolean = false; hasEmptyCustomContentTemplate: boolean = false;
private appsObserver: Observer<AppDefinitionRepresentationModel>;
private iconsMDL: IconModel;
private onDestroy$ = new Subject<boolean>(); private onDestroy$ = new Subject<boolean>();
constructor( constructor(
@@ -103,6 +101,79 @@ export class AppsListComponent implements OnInit, AfterContentInit, OnDestroy {
} }
} }
isDefaultApp(app) {
return app.defaultAppId === DEFAULT_TASKS_APP;
}
getAppName(app) {
return this.isDefaultApp(app)
? this.translationService.get(DEFAULT_TASKS_APP_NAME)
: of(app.name);
}
/**
* Pass the selected app as next
*
* @param app
*/
selectApp(app: AppDefinitionRepresentationModel) {
this.currentApp = app;
this.appClick.emit(app);
}
/**
* Return true if the appId is the current app
*
* @param appId
*/
isSelected(appId: number): boolean {
return (this.currentApp !== undefined && appId === this.currentApp.id);
}
/**
* Check if the value of the layoutType property is an allowed value
*/
isValidType(): boolean {
return this.layoutType && (this.layoutType === APP_LIST_LAYOUT_LIST || this.layoutType === APP_LIST_LAYOUT_GRID);
}
/**
* Assign the default value to LayoutType
*/
setDefaultLayoutType(): void {
this.layoutType = APP_LIST_LAYOUT_GRID;
}
/**
* Return true if the layout type is LIST
*/
isList(): boolean {
return this.layoutType === APP_LIST_LAYOUT_LIST;
}
/**
* Return true if the layout type is GRID
*/
isGrid(): boolean {
return this.layoutType === APP_LIST_LAYOUT_GRID;
}
isEmpty(): boolean {
return this.appList.length === 0;
}
isLoading(): boolean {
return this.loading;
}
getTheme(app: AppDefinitionRepresentationModel): string {
return app.theme ? app.theme : '';
}
getBackgroundIcon(app: AppDefinitionRepresentationModel): string {
return this.iconsMDL.mapGlyphiconToMaterialDesignIcons(app.icon);
}
private load() { private load() {
this.loading = true; this.loading = true;
this.appsProcessService this.appsProcessService
@@ -112,8 +183,8 @@ export class AppsListComponent implements OnInit, AfterContentInit, OnDestroy {
(res: AppDefinitionRepresentationModel[]) => { (res: AppDefinitionRepresentationModel[]) => {
this.filterApps(res).forEach((app) => { this.filterApps(res).forEach((app) => {
if (this.isDefaultApp(app)) { if (this.isDefaultApp(app)) {
app.theme = AppsListComponent.DEFAULT_TASKS_APP_THEME; app.theme = DEFAULT_TASKS_APP_THEME;
app.icon = AppsListComponent.DEFAULT_TASKS_APP_ICON; app.icon = DEFAULT_TASKS_APP_ICON;
this.appsObserver.next(app); this.appsObserver.next(app);
} else if (app.deploymentId) { } else if (app.deploymentId) {
this.appsObserver.next(app); this.appsObserver.next(app);
@@ -126,33 +197,6 @@ export class AppsListComponent implements OnInit, AfterContentInit, OnDestroy {
); );
} }
isDefaultApp(app) {
return app.defaultAppId === AppsListComponent.DEFAULT_TASKS_APP;
}
getAppName(app) {
return this.isDefaultApp(app)
? this.translationService.get(AppsListComponent.DEFAULT_TASKS_APP_NAME)
: of(app.name);
}
/**
* Pass the selected app as next
* @param app
*/
public selectApp(app: AppDefinitionRepresentationModel) {
this.currentApp = app;
this.appClick.emit(app);
}
/**
* Return true if the appId is the current app
* @param appId
*/
isSelected(appId: number): boolean {
return (this.currentApp !== undefined && appId === this.currentApp.id);
}
private filterApps(apps: AppDefinitionRepresentationModel []): AppDefinitionRepresentationModel[] { private filterApps(apps: AppDefinitionRepresentationModel []): AppDefinitionRepresentationModel[] {
const filteredApps: AppDefinitionRepresentationModel[] = []; const filteredApps: AppDefinitionRepresentationModel[] = [];
if (this.filtersAppId) { if (this.filtersAppId) {
@@ -173,49 +217,4 @@ export class AppsListComponent implements OnInit, AfterContentInit, OnDestroy {
} }
return filteredApps; return filteredApps;
} }
/**
* Check if the value of the layoutType property is an allowed value
*/
isValidType(): boolean {
return this.layoutType && (this.layoutType === AppsListComponent.LAYOUT_LIST || this.layoutType === AppsListComponent.LAYOUT_GRID);
}
/**
* Assign the default value to LayoutType
*/
setDefaultLayoutType(): void {
this.layoutType = AppsListComponent.LAYOUT_GRID;
}
/**
* Return true if the layout type is LIST
*/
isList(): boolean {
return this.layoutType === AppsListComponent.LAYOUT_LIST;
}
/**
* Return true if the layout type is GRID
*/
isGrid(): boolean {
return this.layoutType === AppsListComponent.LAYOUT_GRID;
}
isEmpty(): boolean {
return this.appList.length === 0;
}
isLoading(): boolean {
return this.loading;
}
getTheme(app: AppDefinitionRepresentationModel): string {
return app.theme ? app.theme : '';
}
getBackgroundIcon(app: AppDefinitionRepresentationModel): string {
return this.iconsMDL.mapGlyphiconToMaterialDesignIcons(app.icon);
}
} }

View File

@@ -15,10 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
const DEFAULT_TASKS_APP_MATERIAL_ICON: string = 'favorite_border';
/* spellchecker: disable */ /* spellchecker: disable */
export class IconModel { export class IconModel {
public static DEFAULT_TASKS_APP_MATERIAL_ICON: string = 'favorite_border';
private iconsMDL: Map<string, string>; private iconsMDL: Map<string, string>;
constructor() { constructor() {
@@ -26,7 +26,7 @@ export class IconModel {
} }
mapGlyphiconToMaterialDesignIcons(icon: string) { mapGlyphiconToMaterialDesignIcons(icon: string) {
return this.iconsMDL.get(icon) ? this.iconsMDL.get(icon) : IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON; return this.iconsMDL.get(icon) ? this.iconsMDL.get(icon) : DEFAULT_TASKS_APP_MATERIAL_ICON;
} }
/** /**
@@ -114,51 +114,51 @@ export class IconModel {
this.iconsMDL.set('glyphicon-eye-close', 'remove_red_eye'); this.iconsMDL.set('glyphicon-eye-close', 'remove_red_eye');
this.iconsMDL.set('glyphicon-warning-sign', 'warning'); this.iconsMDL.set('glyphicon-warning-sign', 'warning');
this.iconsMDL.set('glyphicon-plane', 'airplanemode_active'); this.iconsMDL.set('glyphicon-plane', 'airplanemode_active');
this.iconsMDL.set('glyphicon-calendar', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-calendar', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-random', 'shuffle'); this.iconsMDL.set('glyphicon-random', 'shuffle');
this.iconsMDL.set('glyphicon-comment', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-comment', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-magnet', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-magnet', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-retweet', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-retweet', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-shopping-cart', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-shopping-cart', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-folder-close', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-folder-close', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-folder-open', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-folder-open', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-hdd', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-hdd', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-bullhorn', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-bullhorn', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-bell', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-bell', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-certificate', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-certificate', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-thumbs-up', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-thumbs-up', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-thumbs-down', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-thumbs-down', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-hand-left', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-hand-left', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-globe', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-globe', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-wrench', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-wrench', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-tasks', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-tasks', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-filter', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-filter', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-briefcase', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-briefcase', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-dashboard', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-dashboard', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-paperclip', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-paperclip', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-link', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-link', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-phone', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-phone', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-pushpin', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-pushpin', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-usd', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-usd', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-gbp', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-gbp', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-sort', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-sort', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-flash', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-flash', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-record', 'radio_button_checked'); this.iconsMDL.set('glyphicon-record', 'radio_button_checked');
this.iconsMDL.set('glyphicon-save', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-save', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-open', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-open', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-saved', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-saved', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-send', 'send'); this.iconsMDL.set('glyphicon-send', 'send');
this.iconsMDL.set('glyphicon-floppy-disk', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-floppy-disk', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-credit-card', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-credit-card', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-cutlery', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-cutlery', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-earphone', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-earphone', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-phone-alt', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-phone-alt', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-tower', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-tower', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-stats', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-stats', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-cloud-download', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-cloud-download', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-cloud-upload', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-cloud-upload', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-tree-conifer', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-tree-conifer', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-tree-deciduous', IconModel.DEFAULT_TASKS_APP_MATERIAL_ICON); this.iconsMDL.set('glyphicon-tree-deciduous', DEFAULT_TASKS_APP_MATERIAL_ICON);
this.iconsMDL.set('glyphicon-align-left', 'format_align_left'); this.iconsMDL.set('glyphicon-align-left', 'format_align_left');
} }
} }

View File

@@ -34,10 +34,8 @@ export class SelectAppsDialogComponent {
@Inject(MAT_DIALOG_DATA) public data: any) { @Inject(MAT_DIALOG_DATA) public data: any) {
this.appsProcessService.getDeployedApplications().subscribe( this.appsProcessService.getDeployedApplications().subscribe(
(apps: any[]) => { (apps) => {
this.processApps = apps.filter((currentApp) => { this.processApps = apps.filter((currentApp) => currentApp.id);
return currentApp.id;
});
} }
); );
} }

View File

@@ -31,7 +31,7 @@ describe('CreateProcessAttachmentComponent', () => {
let element: HTMLElement; let element: HTMLElement;
const file = new File([new Blob()], 'Test'); const file = new File([new Blob()], 'Test');
const fileObj = { entry: null, file: file, relativeFolder: '/' }; const fileObj = { entry: null, file, relativeFolder: '/' };
const customEvent = { detail: { files: [fileObj] } }; const customEvent = { detail: { files: [fileObj] } };
const fakeUploadResponse = { const fakeUploadResponse = {
@@ -76,7 +76,7 @@ describe('CreateProcessAttachmentComponent', () => {
component.processInstanceId = null; component.processInstanceId = null;
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
expect(component.processInstanceId).toBe('123'); expect(component.processInstanceId).toBe('123');
}); });
@@ -92,14 +92,14 @@ describe('CreateProcessAttachmentComponent', () => {
component.onFileUpload(customEvent); component.onFileUpload(customEvent);
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeUploadResponse) responseText: JSON.stringify(fakeUploadResponse)
}); });
}); });
it('should allow user to upload files via button', (done) => { it('should allow user to upload files via button', (done) => {
const buttonUpload: HTMLElement = <HTMLElement> element.querySelector('#add_new_process_content_button'); const buttonUpload = element.querySelector<HTMLElement>('#add_new_process_content_button');
expect(buttonUpload).toBeDefined(); expect(buttonUpload).toBeDefined();
expect(buttonUpload).not.toBeNull(); expect(buttonUpload).not.toBeNull();
@@ -115,7 +115,7 @@ describe('CreateProcessAttachmentComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeUploadResponse) responseText: JSON.stringify(fakeUploadResponse)
}); });

View File

@@ -52,13 +52,13 @@ describe('AttachmentComponent', () => {
it('should not call createTaskRelatedContent service when taskId changed', () => { it('should not call createTaskRelatedContent service when taskId changed', () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({'taskId': change}); component.ngOnChanges({taskId: change});
expect(createTaskRelatedContentSpy).not.toHaveBeenCalled(); expect(createTaskRelatedContentSpy).not.toHaveBeenCalled();
}); });
it('should not call createTaskRelatedContent service when there is no file uploaded', () => { it('should not call createTaskRelatedContent service when there is no file uploaded', () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({'taskId': change}); component.ngOnChanges({taskId: change});
const customEvent: any = { const customEvent: any = {
detail: { detail: {
files: [] files: []
@@ -70,7 +70,7 @@ describe('AttachmentComponent', () => {
it('should call createTaskRelatedContent service when there is a file uploaded', () => { it('should call createTaskRelatedContent service when there is a file uploaded', () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({'taskId': change}); component.ngOnChanges({taskId: change});
const file = new File([new Blob()], 'Test'); const file = new File([new Blob()], 'Test');
const customEvent = { const customEvent = {
detail: { detail: {

View File

@@ -100,7 +100,7 @@ describe('ProcessAttachmentListComponent', () => {
afterEach(() => { afterEach(() => {
fixture.destroy(); fixture.destroy();
const overlayContainers = <any> window.document.querySelectorAll('.cdk-overlay-container'); const overlayContainers = window.document.querySelectorAll('.cdk-overlay-container');
overlayContainers.forEach((overlayContainer) => { overlayContainers.forEach((overlayContainer) => {
overlayContainer.innerHTML = ''; overlayContainer.innerHTML = '';
@@ -109,7 +109,7 @@ describe('ProcessAttachmentListComponent', () => {
it('should load attachments when processInstanceId specified', () => { it('should load attachments when processInstanceId specified', () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
expect(getProcessRelatedContentSpy).toHaveBeenCalled(); expect(getProcessRelatedContentSpy).toHaveBeenCalled();
}); });
@@ -117,7 +117,7 @@ describe('ProcessAttachmentListComponent', () => {
const emitSpy = spyOn(component.error, 'emit'); const emitSpy = spyOn(component.error, 'emit');
getProcessRelatedContentSpy.and.returnValue(throwError({})); getProcessRelatedContentSpy.and.returnValue(throwError({}));
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
expect(emitSpy).toHaveBeenCalled(); expect(emitSpy).toHaveBeenCalled();
}); });
@@ -128,7 +128,7 @@ describe('ProcessAttachmentListComponent', () => {
expect(attachments[0].id).toEqual(mockAttachment.data[0].id); expect(attachments[0].id).toEqual(mockAttachment.data[0].id);
}); });
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
}); });
it('should not attach when no processInstanceId is specified', () => { it('should not attach when no processInstanceId is specified', () => {
@@ -138,7 +138,7 @@ describe('ProcessAttachmentListComponent', () => {
it('should display attachments when the process has attachments', async () => { it('should display attachments when the process has attachments', async () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
expect(fixture.debugElement.queryAll(By.css('.adf-datatable-body > .adf-datatable-row')).length).toBe(2); expect(fixture.debugElement.queryAll(By.css('.adf-datatable-body > .adf-datatable-row')).length).toBe(2);
@@ -146,7 +146,7 @@ describe('ProcessAttachmentListComponent', () => {
it('should display all actions if attachments are not read only', async () => { it('should display all actions if attachments are not read only', async () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -166,7 +166,7 @@ describe('ProcessAttachmentListComponent', () => {
it('should not display remove action if attachments are read only', async () => { it('should not display remove action if attachments are read only', async () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
component.disabled = true; component.disabled = true;
fixture.detectChanges(); fixture.detectChanges();
@@ -186,13 +186,13 @@ describe('ProcessAttachmentListComponent', () => {
it('should show the empty list component when the attachments list is empty', async () => { it('should show the empty list component when the attachments list is empty', async () => {
getProcessRelatedContentSpy.and.returnValue(of({ getProcessRelatedContentSpy.and.returnValue(of({
'size': 0, size: 0,
'total': 0, total: 0,
'start': 0, start: 0,
'data': [] data: []
})); }));
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
expect(fixture.nativeElement.querySelector('div[adf-empty-list-header]').innerText.trim()).toEqual('ADF_PROCESS_LIST.PROCESS-ATTACHMENT.EMPTY.HEADER'); expect(fixture.nativeElement.querySelector('div[adf-empty-list-header]').innerText.trim()).toEqual('ADF_PROCESS_LIST.PROCESS-ATTACHMENT.EMPTY.HEADER');
@@ -200,13 +200,13 @@ describe('ProcessAttachmentListComponent', () => {
it('should not show the empty list drag and drop component when is disabled', async () => { it('should not show the empty list drag and drop component when is disabled', async () => {
getProcessRelatedContentSpy.and.returnValue(of({ getProcessRelatedContentSpy.and.returnValue(of({
'size': 0, size: 0,
'total': 0, total: 0,
'start': 0, start: 0,
'data': [] data: []
})); }));
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
component.disabled = true; component.disabled = true;
fixture.detectChanges(); fixture.detectChanges();
@@ -217,13 +217,13 @@ describe('ProcessAttachmentListComponent', () => {
it('should show the empty list component when the attachments list is empty for completed process', async () => { it('should show the empty list component when the attachments list is empty for completed process', async () => {
getProcessRelatedContentSpy.and.returnValue(of({ getProcessRelatedContentSpy.and.returnValue(of({
'size': 0, size: 0,
'total': 0, total: 0,
'start': 0, start: 0,
'data': [] data: []
})); }));
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
component.disabled = true; component.disabled = true;
fixture.detectChanges(); fixture.detectChanges();
@@ -236,7 +236,7 @@ describe('ProcessAttachmentListComponent', () => {
it('should not show the empty list component when the attachments list is not empty for completed process', async () => { it('should not show the empty list component when the attachments list is not empty for completed process', async () => {
getProcessRelatedContentSpy.and.returnValue(of(mockAttachment)); getProcessRelatedContentSpy.and.returnValue(of(mockAttachment));
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
component.disabled = true; component.disabled = true;
fixture.detectChanges(); fixture.detectChanges();
@@ -248,7 +248,7 @@ describe('ProcessAttachmentListComponent', () => {
getProcessRelatedContentSpy.and.returnValue(of(mockAttachment)); getProcessRelatedContentSpy.and.returnValue(of(mockAttachment));
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
const isRelatedContent = 'true'; const isRelatedContent = 'true';
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
expect(getProcessRelatedContentSpy).toHaveBeenCalled(); expect(getProcessRelatedContentSpy).toHaveBeenCalled();
expect(getProcessRelatedContentSpy).toHaveBeenCalledWith('123', { isRelatedContent }); expect(getProcessRelatedContentSpy).toHaveBeenCalledWith('123', { isRelatedContent });
}); });
@@ -265,7 +265,7 @@ describe('ProcessAttachmentListComponent', () => {
}); });
it('should fetch new attachments when processInstanceId changed', () => { it('should fetch new attachments when processInstanceId changed', () => {
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
const isRelatedContent = 'true'; const isRelatedContent = 'true';
expect(getProcessRelatedContentSpy).toHaveBeenCalledWith('456', { isRelatedContent }); expect(getProcessRelatedContentSpy).toHaveBeenCalledWith('456', { isRelatedContent });
}); });
@@ -276,7 +276,7 @@ describe('ProcessAttachmentListComponent', () => {
}); });
it('should NOT fetch new attachments when processInstanceId changed to null', () => { it('should NOT fetch new attachments when processInstanceId changed to null', () => {
component.ngOnChanges({ 'processInstanceId': nullChange }); component.ngOnChanges({ processInstanceId: nullChange });
expect(getProcessRelatedContentSpy).not.toHaveBeenCalled(); expect(getProcessRelatedContentSpy).not.toHaveBeenCalled();
}); });
}); });

View File

@@ -117,46 +117,6 @@ export class ProcessAttachmentListComponent implements OnChanges, AfterContentIn
}); });
} }
private loadAttachmentsByProcessInstanceId(processInstanceId: string) {
if (processInstanceId) {
this.reset();
this.isLoading = true;
const isRelatedContent = 'true';
this.activitiContentService.getProcessRelatedContent(processInstanceId, { isRelatedContent }).subscribe(
(res: any) => {
res.data.forEach((content) => {
this.attachments.push({
id: content.id,
name: content.name,
created: content.created,
createdBy: content.createdBy.firstName + ' ' + content.createdBy.lastName,
icon: this.thumbnailService.getMimeTypeIcon(content.mimeType)
});
});
this.success.emit(this.attachments);
this.isLoading = false;
},
(err) => {
this.error.emit(err);
this.isLoading = false;
});
}
}
private deleteAttachmentById(contentId: number) {
if (contentId) {
this.activitiContentService.deleteRelatedContent(contentId).subscribe(
() => {
this.attachments = this.attachments.filter((content) => {
return content.id !== contentId;
});
},
(err) => {
this.error.emit(err);
});
}
}
isEmpty(): boolean { isEmpty(): boolean {
return this.attachments && this.attachments.length === 0; return this.attachments && this.attachments.length === 0;
} }
@@ -228,4 +188,42 @@ export class ProcessAttachmentListComponent implements OnChanges, AfterContentIn
isDisabled(): boolean { isDisabled(): boolean {
return this.disabled; return this.disabled;
} }
private loadAttachmentsByProcessInstanceId(processInstanceId: string) {
if (processInstanceId) {
this.reset();
this.isLoading = true;
const isRelatedContent = 'true';
this.activitiContentService.getProcessRelatedContent(processInstanceId, { isRelatedContent }).subscribe(
(res: any) => {
res.data.forEach((content) => {
this.attachments.push({
id: content.id,
name: content.name,
created: content.created,
createdBy: content.createdBy.firstName + ' ' + content.createdBy.lastName,
icon: this.thumbnailService.getMimeTypeIcon(content.mimeType)
});
});
this.success.emit(this.attachments);
this.isLoading = false;
},
(err) => {
this.error.emit(err);
this.isLoading = false;
});
}
}
private deleteAttachmentById(contentId: number) {
if (contentId) {
this.activitiContentService.deleteRelatedContent(contentId).subscribe(
() => {
this.attachments = this.attachments.filter((content) => content.id !== contentId);
},
(err) => {
this.error.emit(err);
});
}
}
} }

View File

@@ -98,7 +98,7 @@ describe('TaskAttachmentList', () => {
}); });
afterEach(() => { afterEach(() => {
const overlayContainers = <any> window.document.querySelectorAll('.cdk-overlay-container'); const overlayContainers = window.document.querySelectorAll('.cdk-overlay-container');
overlayContainers.forEach((overlayContainer) => { overlayContainers.forEach((overlayContainer) => {
overlayContainer.innerHTML = ''; overlayContainer.innerHTML = '';
}); });
@@ -110,7 +110,7 @@ describe('TaskAttachmentList', () => {
it('should load attachments when taskId specified', () => { it('should load attachments when taskId specified', () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
expect(getTaskRelatedContentSpy).toHaveBeenCalled(); expect(getTaskRelatedContentSpy).toHaveBeenCalled();
}); });
@@ -118,7 +118,7 @@ describe('TaskAttachmentList', () => {
const emitSpy = spyOn(component.error, 'emit'); const emitSpy = spyOn(component.error, 'emit');
getTaskRelatedContentSpy.and.returnValue(throwError({})); getTaskRelatedContentSpy.and.returnValue(throwError({}));
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
expect(emitSpy).toHaveBeenCalled(); expect(emitSpy).toHaveBeenCalled();
}); });
@@ -129,7 +129,7 @@ describe('TaskAttachmentList', () => {
expect(attachments[0].id).toEqual(mockAttachment.data[0].id); expect(attachments[0].id).toEqual(mockAttachment.data[0].id);
}); });
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
}); });
it('should not attach when no taskId is specified', () => { it('should not attach when no taskId is specified', () => {
@@ -139,7 +139,7 @@ describe('TaskAttachmentList', () => {
it('should display attachments when the task has attachments', async () => { it('should display attachments when the task has attachments', async () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
expect(fixture.debugElement.queryAll(By.css('.adf-datatable-body > .adf-datatable-row')).length).toBe(2); expect(fixture.debugElement.queryAll(By.css('.adf-datatable-body > .adf-datatable-row')).length).toBe(2);
@@ -159,13 +159,13 @@ describe('TaskAttachmentList', () => {
it('should show the empty default message when has no custom template', async () => { it('should show the empty default message when has no custom template', async () => {
getTaskRelatedContentSpy.and.returnValue(of({ getTaskRelatedContentSpy.and.returnValue(of({
'size': 0, size: 0,
'total': 0, total: 0,
'start': 0, start: 0,
'data': [] data: []
})); }));
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
component.hasCustomTemplate = false; component.hasCustomTemplate = false;
fixture.detectChanges(); fixture.detectChanges();
@@ -177,7 +177,7 @@ describe('TaskAttachmentList', () => {
it('should display all actions if attachments are not read only', async () => { it('should display all actions if attachments are not read only', async () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -195,7 +195,7 @@ describe('TaskAttachmentList', () => {
it('should not display remove action if attachments are read only', async () => { it('should not display remove action if attachments are read only', async () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
component.disabled = true; component.disabled = true;
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -215,13 +215,13 @@ describe('TaskAttachmentList', () => {
it('should show the empty list component when the attachments list is empty', async () => { it('should show the empty list component when the attachments list is empty', async () => {
getTaskRelatedContentSpy.and.returnValue(of({ getTaskRelatedContentSpy.and.returnValue(of({
'size': 0, size: 0,
'total': 0, total: 0,
'start': 0, start: 0,
'data': [] data: []
})); }));
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -231,13 +231,13 @@ describe('TaskAttachmentList', () => {
it('should show the empty list component when the attachments list is empty for completed task', async () => { it('should show the empty list component when the attachments list is empty for completed task', async () => {
getTaskRelatedContentSpy.and.returnValue(of({ getTaskRelatedContentSpy.and.returnValue(of({
'size': 0, size: 0,
'total': 0, total: 0,
'start': 0, start: 0,
'data': [] data: []
})); }));
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
component.disabled = true; component.disabled = true;
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
@@ -249,7 +249,7 @@ describe('TaskAttachmentList', () => {
it('should not show the empty list component when the attachments list is not empty for completed task', async () => { it('should not show the empty list component when the attachments list is not empty for completed task', async () => {
getTaskRelatedContentSpy.and.returnValue(of(mockAttachment)); getTaskRelatedContentSpy.and.returnValue(of(mockAttachment));
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
component.disabled = true; component.disabled = true;
fixture.detectChanges(); fixture.detectChanges();
@@ -281,7 +281,7 @@ describe('TaskAttachmentList', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const isRelatedContent = 'true'; const isRelatedContent = 'true';
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
expect(getTaskRelatedContentSpy).toHaveBeenCalledWith('456', { isRelatedContent }); expect(getTaskRelatedContentSpy).toHaveBeenCalledWith('456', { isRelatedContent });
}); });
@@ -291,7 +291,7 @@ describe('TaskAttachmentList', () => {
}); });
it('should NOT fetch new attachments when taskId changed to null', () => { it('should NOT fetch new attachments when taskId changed to null', () => {
component.ngOnChanges({ 'taskId': nullChange }); component.ngOnChanges({ taskId: nullChange });
expect(getTaskRelatedContentSpy).not.toHaveBeenCalled(); expect(getTaskRelatedContentSpy).not.toHaveBeenCalled();
}); });
}); });

View File

@@ -114,41 +114,11 @@ export class TaskAttachmentListComponent implements OnChanges, AfterContentInit
}); });
} }
private loadAttachmentsByTaskId(taskId: string) {
if (taskId) {
this.isLoading = true;
this.reset();
const isRelatedContent = 'true';
this.activitiContentService.getTaskRelatedContent(taskId, { isRelatedContent }).subscribe(
(res: any) => {
const attachList = [];
res.data.forEach((content) => {
attachList.push({
id: content.id,
name: content.name,
created: content.created,
createdBy: content.createdBy.firstName + ' ' + content.createdBy.lastName,
icon: this.thumbnailService.getMimeTypeIcon(content.mimeType)
});
});
this.attachments = attachList;
this.success.emit(this.attachments);
this.isLoading = false;
},
(err) => {
this.error.emit(err);
this.isLoading = false;
});
}
}
deleteAttachmentById(contentId: number) { deleteAttachmentById(contentId: number) {
if (contentId) { if (contentId) {
this.activitiContentService.deleteRelatedContent(contentId).subscribe( this.activitiContentService.deleteRelatedContent(contentId).subscribe(
() => { () => {
this.attachments = this.attachments.filter((content) => { this.attachments = this.attachments.filter((content) => content.id !== contentId);
return content.id !== contentId;
});
}, },
(err) => { (err) => {
this.error.emit(err); this.error.emit(err);
@@ -227,4 +197,32 @@ export class TaskAttachmentListComponent implements OnChanges, AfterContentInit
isDisabled(): boolean { isDisabled(): boolean {
return this.disabled; return this.disabled;
} }
private loadAttachmentsByTaskId(taskId: string) {
if (taskId) {
this.isLoading = true;
this.reset();
const isRelatedContent = 'true';
this.activitiContentService.getTaskRelatedContent(taskId, { isRelatedContent }).subscribe(
(res: any) => {
const attachList = [];
res.data.forEach((content) => {
attachList.push({
id: content.id,
name: content.name,
created: content.created,
createdBy: content.createdBy.firstName + ' ' + content.createdBy.lastName,
icon: this.thumbnailService.getMimeTypeIcon(content.mimeType)
});
});
this.attachments = attachList;
this.success.emit(this.attachments);
this.isLoading = false;
},
(err) => {
this.error.emit(err);
this.isLoading = false;
});
}
}
} }

View File

@@ -74,15 +74,13 @@ describe('AttachFileWidgetDialogComponent', () => {
matDialogRef = fixture.debugElement.injector.get(MatDialogRef); matDialogRef = fixture.debugElement.injector.get(MatDialogRef);
apiService = fixture.debugElement.injector.get(AlfrescoApiService); apiService = fixture.debugElement.injector.get(AlfrescoApiService);
spyOn(documentListService, 'getFolderNode').and.returnValue(of(<NodeEntry> { entry: { path: { elements: [] } } })); spyOn(documentListService, 'getFolderNode').and.returnValue(of({ entry: { path: { elements: [] } } } as NodeEntry));
spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test')); spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test'));
spyOn(nodeService, 'getNode').and.returnValue(of(new Node({ id: 'fake-node', path: { elements: [{ nodeType: 'st:site', name: 'fake-site'}] } }))); spyOn(nodeService, 'getNode').and.returnValue(of(new Node({ id: 'fake-node', path: { elements: [{ nodeType: 'st:site', name: 'fake-site'}] } })));
spyOn(siteService, 'getSite').and.returnValue(of(fakeSite)); spyOn(siteService, 'getSite').and.returnValue(of(fakeSite));
spyOn(siteService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } }))); spyOn(siteService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
spyOn(widget, 'isLoggedIn').and.callFake(() => { spyOn(widget, 'isLoggedIn').and.callFake(() => isLogged);
return isLogged;
});
}); });
afterEach(() => { afterEach(() => {

View File

@@ -49,7 +49,7 @@ export class AttachFileWidgetDialogComponent {
private externalApiService: AlfrescoApiService, private externalApiService: AlfrescoApiService,
private authenticationService: AuthenticationService, private authenticationService: AuthenticationService,
private matDialogRef: MatDialogRef<AttachFileWidgetDialogComponent>) { private matDialogRef: MatDialogRef<AttachFileWidgetDialogComponent>) {
(<any> externalApiService).init(data.ecmHost, data.context); (externalApiService as any).init(data.ecmHost, data.context);
this.action = data.actionName ? data.actionName.toUpperCase() : 'CHOOSE'; this.action = data.actionName ? data.actionName.toUpperCase() : 'CHOOSE';
this.buttonActionName = `ATTACH-FILE.ACTIONS.${this.action}`; this.buttonActionName = `ATTACH-FILE.ACTIONS.${this.action}`;
this.updateTitle('DROPDOWN.MY_FILES_OPTION'); this.updateTitle('DROPDOWN.MY_FILES_OPTION');
@@ -63,14 +63,6 @@ export class AttachFileWidgetDialogComponent {
} }
} }
private registerAndClose() {
this.data.registerExternalHost(this.data.accountIdentifier, this.externalApiService);
if (this.data.loginOnly) {
this.data.selected.complete();
this.matDialogRef.close();
}
}
isLoggedIn() { isLoggedIn() {
return this.externalApiService.getInstance().isLoggedIn(); return this.externalApiService.getInstance().isLoggedIn();
} }
@@ -109,4 +101,12 @@ export class AttachFileWidgetDialogComponent {
hasNodeSelected(): boolean { hasNodeSelected(): boolean {
return this.chosenNode?.length > 0; return this.chosenNode?.length > 0;
} }
private registerAndClose() {
this.data.registerExternalHost(this.data.accountIdentifier, this.externalApiService);
if (this.data.loginOnly) {
this.data.selected.complete();
this.matDialogRef.close();
}
}
} }

View File

@@ -29,11 +29,11 @@ import { switchMap } from 'rxjs/operators';
}) })
// eslint-disable-next-line @angular-eslint/directive-class-suffix // eslint-disable-next-line @angular-eslint/directive-class-suffix
export class AttachFileWidgetDialogService { export class AttachFileWidgetDialogService {
private externalApis: { [key: string]: AlfrescoApiService } = {};
/** Emitted when an error occurs. */ /** Emitted when an error occurs. */
@Output() @Output()
error: EventEmitter<any> = new EventEmitter<any>(); error = new EventEmitter<any>();
private externalApis: { [key: string]: AlfrescoApiService } = {};
constructor(private dialog: MatDialog, constructor(private dialog: MatDialog,
private translation: TranslationService) { private translation: TranslationService) {
@@ -41,6 +41,7 @@ export class AttachFileWidgetDialogService {
/** /**
* Opens a dialog to choose a file to upload. * Opens a dialog to choose a file to upload.
*
* @param repository Alfresco endpoint that represents the content service * @param repository Alfresco endpoint that represents the content service
* @param currentFolderId Upload file from specific folder * @param currentFolderId Upload file from specific folder
* @returns Information about the chosen file(s) * @returns Information about the chosen file(s)
@@ -62,19 +63,6 @@ export class AttachFileWidgetDialogService {
return selected; return selected;
} }
private openLoginDialog(data: AttachFileWidgetDialogComponentData, currentPanelClass: string, chosenWidth: string) {
this.dialog.open(AttachFileWidgetDialogComponent, { data, panelClass: currentPanelClass, width: chosenWidth });
}
private showExternalHostLoginDialog(repository: AlfrescoEndpointRepresentation): Observable<AlfrescoApiService> {
const data = {
...this.constructPayload(repository),
loginOnly: true
};
return this.dialog.open(AttachFileWidgetDialogComponent, { data, panelClass: 'adf-attach-file-widget-dialog', width: '630px' })
.afterClosed();
}
downloadURL(repository: AlfrescoEndpointRepresentation, sourceId: string): Observable<string> { downloadURL(repository: AlfrescoEndpointRepresentation, sourceId: string): Observable<string> {
const { accountIdentifier } = this.constructPayload(repository); const { accountIdentifier } = this.constructPayload(repository);
@@ -94,6 +82,30 @@ export class AttachFileWidgetDialogService {
); );
} }
addService(accountIdentifier: string, apiService: AlfrescoApiService) {
if (!this.externalApis[accountIdentifier]) {
this.externalApis[accountIdentifier] = apiService;
}
}
/** Closes the currently open dialog. */
close() {
this.dialog.closeAll();
}
private openLoginDialog(data: AttachFileWidgetDialogComponentData, currentPanelClass: string, chosenWidth: string) {
this.dialog.open(AttachFileWidgetDialogComponent, { data, panelClass: currentPanelClass, width: chosenWidth });
}
private showExternalHostLoginDialog(repository: AlfrescoEndpointRepresentation): Observable<AlfrescoApiService> {
const data = {
...this.constructPayload(repository),
loginOnly: true
};
return this.dialog.open(AttachFileWidgetDialogComponent, { data, panelClass: 'adf-attach-file-widget-dialog', width: '630px' })
.afterClosed();
}
private constructPayload(repository: AlfrescoEndpointRepresentation) { private constructPayload(repository: AlfrescoEndpointRepresentation) {
const accountIdentifier = 'alfresco-' + repository.id + '-' + repository.name; const accountIdentifier = 'alfresco-' + repository.id + '-' + repository.name;
const ecmHost = repository.repositoryUrl.replace('/alfresco', ''); const ecmHost = repository.repositoryUrl.replace('/alfresco', '');
@@ -106,17 +118,6 @@ export class AttachFileWidgetDialogService {
return { ecmHost, accountIdentifier, selected, title, registerExternalHost }; return { ecmHost, accountIdentifier, selected, title, registerExternalHost };
} }
addService(accountIdentifier: string, apiService: AlfrescoApiService) {
if (!this.externalApis[accountIdentifier]) {
this.externalApis[accountIdentifier] = apiService;
}
}
/** Closes the currently open dialog. */
close() {
this.dialog.closeAll();
}
private getLoginTitleTranslation(ecmHost: string): string { private getLoginTitleTranslation(ecmHost: string): string {
return this.translation.instant(`ATTACH-FILE.DIALOG.LOGIN`, { ecmHost }); return this.translation.instant(`ATTACH-FILE.DIALOG.LOGIN`, { ecmHost });
} }

View File

@@ -38,27 +38,27 @@ import { AttachFileWidgetDialogService } from './attach-file-widget-dialog.servi
const fakeRepositoryListAnswer = [ const fakeRepositoryListAnswer = [
{ {
'authorized': true, authorized: true,
'serviceId': 'alfresco-9999-SHAREME', serviceId: 'alfresco-9999-SHAREME',
'metaDataAllowed': true, metaDataAllowed: true,
'name': 'SHAREME', name: 'SHAREME',
'repositoryUrl': 'http://localhost:0000/SHAREME', repositoryUrl: 'http://localhost:0000/SHAREME',
'id': 1000 id: 1000
}, },
{ {
'authorized': true, authorized: true,
'serviceId': 'alfresco-0000-GOKUSHARE', serviceId: 'alfresco-0000-GOKUSHARE',
'metaDataAllowed': true, metaDataAllowed: true,
'name': 'GOKUSHARE', name: 'GOKUSHARE',
'repositoryUrl': 'http://localhost:0000/GOKUSHARE' repositoryUrl: 'http://localhost:0000/GOKUSHARE'
}, },
{ {
'authorized': true, authorized: true,
'serviceId': 'alfresco-2000-external', serviceId: 'alfresco-2000-external',
'metaDataAllowed': true, metaDataAllowed: true,
'name': 'external', name: 'external',
'repositoryUrl': 'http://externalhost.com/alfresco', repositoryUrl: 'http://externalhost.com/alfresco',
'id': 2000 id: 2000
} }
]; ];
@@ -66,21 +66,21 @@ const onlyLocalParams = {
fileSource: { fileSource: {
serviceId: 'local-file' serviceId: 'local-file'
} }
}; } as FormFieldMetadata;
const allSourceParams = { const allSourceParams = {
fileSource: { fileSource: {
serviceId: 'all-file-sources' serviceId: 'all-file-sources'
}, },
link: false link: false
}; } as FormFieldMetadata;
const allSourceParamsWithLinkEnabled = { const allSourceParamsWithLinkEnabled = {
fileSource: { fileSource: {
serviceId: 'all-file-sources' serviceId: 'all-file-sources'
}, },
link: true link: true
}; } as FormFieldMetadata;
const definedSourceParams = { const definedSourceParams = {
fileSource: { fileSource: {
@@ -90,7 +90,7 @@ const definedSourceParams = {
accountId: 'goku-share-account-id' accountId: 'goku-share-account-id'
} }
} }
}; } as FormFieldMetadata;
const externalDefinedSourceParams = { const externalDefinedSourceParams = {
fileSource: { fileSource: {
@@ -100,44 +100,44 @@ const externalDefinedSourceParams = {
accountId: 'external-account-id' accountId: 'external-account-id'
} }
} }
}; } as FormFieldMetadata;
const fakeMinimalNode: Node = <Node> { const fakeMinimalNode: Node = {
id: 'fake', id: 'fake',
name: 'fake-name', name: 'fake-name',
content: { content: {
mimeType: 'application/pdf' mimeType: 'application/pdf'
} }
}; } as Node;
const fakePngUpload: any = { const fakePngUpload: any = {
'id': 1166, id: 1166,
'name': 'fake-png.png', name: 'fake-png.png',
'created': '2017-07-25T17:17:37.099Z', created: '2017-07-25T17:17:37.099Z',
'createdBy': { 'id': 1001, 'firstName': 'Admin', 'lastName': 'admin', 'email': 'admin' }, createdBy: { id: 1001, firstName: 'Admin', lastName: 'admin', email: 'admin' },
'relatedContent': false, relatedContent: false,
'contentAvailable': true, contentAvailable: true,
'link': false, link: false,
'isExternal': false, isExternal: false,
'mimeType': 'image/png', mimeType: 'image/png',
'simpleType': 'image', simpleType: 'image',
'previewStatus': 'queued', previewStatus: 'queued',
'thumbnailStatus': 'queued' thumbnailStatus: 'queued'
}; };
const fakePngAnswer: any = { const fakePngAnswer: any = {
'id': 1155, id: 1155,
'name': 'a_png_file.png', name: 'a_png_file.png',
'created': '2017-07-25T17:17:37.099Z', created: '2017-07-25T17:17:37.099Z',
'createdBy': { 'id': 1001, 'firstName': 'Admin', 'lastName': 'admin', 'email': 'admin' }, createdBy: { id: 1001, firstName: 'Admin', lastName: 'admin', email: 'admin' },
'relatedContent': false, relatedContent: false,
'contentAvailable': true, contentAvailable: true,
'isExternal': false, isExternal: false,
'link': false, link: false,
'mimeType': 'image/png', mimeType: 'image/png',
'simpleType': 'image', simpleType: 'image',
'previewStatus': 'queued', previewStatus: 'queued',
'thumbnailStatus': 'queued' thumbnailStatus: 'queued'
}; };
describe('AttachFileWidgetComponent', () => { describe('AttachFileWidgetComponent', () => {
@@ -183,7 +183,7 @@ describe('AttachFileWidgetComponent', () => {
value: [] value: []
}); });
widget.field.id = 'simple-upload-button'; widget.field.id = 'simple-upload-button';
widget.field.params = <FormFieldMetadata> onlyLocalParams; widget.field.params = onlyLocalParams;
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
expect(element.querySelector('#simple-upload-button')).not.toBeNull(); expect(element.querySelector('#simple-upload-button')).not.toBeNull();
@@ -195,7 +195,7 @@ describe('AttachFileWidgetComponent', () => {
value: [] value: []
}); });
widget.field.id = 'attach-file-attach'; widget.field.id = 'attach-file-attach';
widget.field.params = <FormFieldMetadata> allSourceParams; widget.field.params = allSourceParams;
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer)); spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenRenderingDone(); await fixture.whenRenderingDone();
@@ -226,7 +226,7 @@ describe('AttachFileWidgetComponent', () => {
value: [] value: []
}); });
widget.field.id = 'attach-file-attach'; widget.field.id = 'attach-file-attach';
widget.field.params = <FormFieldMetadata> allSourceParamsWithLinkEnabled; widget.field.params = allSourceParamsWithLinkEnabled;
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer)); spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenRenderingDone(); await fixture.whenRenderingDone();
@@ -260,7 +260,7 @@ describe('AttachFileWidgetComponent', () => {
value: [] value: []
}); });
widget.field.id = 'attach-file-attach'; widget.field.id = 'attach-file-attach';
widget.field.params = <FormFieldMetadata> allSourceParamsWithLinkEnabled; widget.field.params = allSourceParamsWithLinkEnabled;
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenRenderingDone(); await fixture.whenRenderingDone();
@@ -285,7 +285,7 @@ describe('AttachFileWidgetComponent', () => {
value: [] value: []
}); });
widget.field.id = 'attach-file-attach'; widget.field.id = 'attach-file-attach';
widget.field.params = <FormFieldMetadata> allSourceParams; widget.field.params = allSourceParams;
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenRenderingDone(); await fixture.whenRenderingDone();
@@ -310,7 +310,7 @@ describe('AttachFileWidgetComponent', () => {
value: [] value: []
}); });
widget.field.id = 'attach-file-attach'; widget.field.id = 'attach-file-attach';
widget.field.params = <FormFieldMetadata> allSourceParams; widget.field.params = allSourceParams;
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -345,7 +345,7 @@ describe('AttachFileWidgetComponent', () => {
value: [] value: []
}); });
widget.field.id = 'attach-file-attach'; widget.field.id = 'attach-file-attach';
widget.field.params = <FormFieldMetadata> allSourceParams; widget.field.params = allSourceParams;
widget.field.params.multiple = true; widget.field.params.multiple = true;
fixture.detectChanges(); fixture.detectChanges();
@@ -373,7 +373,7 @@ describe('AttachFileWidgetComponent', () => {
value: [] value: []
}); });
widget.field.id = 'attach-file-attach'; widget.field.id = 'attach-file-attach';
widget.field.params = <FormFieldMetadata> definedSourceParams; widget.field.params = definedSourceParams;
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer)); spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer)); spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
spyOn(contentNodeDialogService, 'openFileBrowseDialogByFolderId').and.returnValue(of([fakeMinimalNode])); spyOn(contentNodeDialogService, 'openFileBrowseDialogByFolderId').and.returnValue(of([fakeMinimalNode]));
@@ -403,7 +403,7 @@ describe('AttachFileWidgetComponent', () => {
value: [] value: []
}); });
widget.field.id = 'attach-file-attach'; widget.field.id = 'attach-file-attach';
widget.field.params = <FormFieldMetadata> onlyLocalParams; widget.field.params = onlyLocalParams;
spyOn(processContentService, 'createTemporaryRawRelatedContent').and.returnValue(of(fakePngAnswer)); spyOn(processContentService, 'createTemporaryRawRelatedContent').and.returnValue(of(fakePngAnswer));
fixture.detectChanges(); fixture.detectChanges();
@@ -423,7 +423,7 @@ describe('AttachFileWidgetComponent', () => {
}); });
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(null)); spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(null));
widget.field.id = 'attach-file-attach'; widget.field.id = 'attach-file-attach';
widget.field.params = <FormFieldMetadata> onlyLocalParams; widget.field.params = onlyLocalParams;
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -439,7 +439,7 @@ describe('AttachFileWidgetComponent', () => {
value: [] value: []
}); });
widget.field.id = 'attach-file-attach'; widget.field.id = 'attach-file-attach';
widget.field.params = <FormFieldMetadata> onlyLocalParams; widget.field.params = onlyLocalParams;
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(null)); spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(null));
spyOn(processContentService, 'createTemporaryRawRelatedContent').and.returnValue(of(fakePngAnswer)); spyOn(processContentService, 'createTemporaryRawRelatedContent').and.returnValue(of(fakePngAnswer));
@@ -476,7 +476,7 @@ describe('AttachFileWidgetComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const removeOption = <HTMLButtonElement> fixture.debugElement.query(By.css('#file-1155-remove')).nativeElement; const removeOption = fixture.debugElement.query(By.css('#file-1155-remove')).nativeElement as HTMLButtonElement;
removeOption.click(); removeOption.click();
fixture.detectChanges(); fixture.detectChanges();
@@ -494,7 +494,7 @@ describe('AttachFileWidgetComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const downloadOption = <HTMLButtonElement> fixture.debugElement.query(By.css('#file-1155-download-file')).nativeElement; const downloadOption = fixture.debugElement.query(By.css('#file-1155-download-file')).nativeElement as HTMLButtonElement;
downloadOption.click(); downloadOption.click();
fixture.detectChanges(); fixture.detectChanges();
@@ -516,7 +516,7 @@ describe('AttachFileWidgetComponent', () => {
menuButton.click(); menuButton.click();
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const showOption = <HTMLButtonElement> fixture.debugElement.query(By.css('#file-1155-show-file')).nativeElement; const showOption = fixture.debugElement.query(By.css('#file-1155-show-file')).nativeElement as HTMLButtonElement;
showOption.click(); showOption.click();
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -531,7 +531,7 @@ describe('AttachFileWidgetComponent', () => {
menuButton.click(); menuButton.click();
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const showOption = <HTMLButtonElement> fixture.debugElement.query(By.css('#file-1155-show-file')).nativeElement; const showOption = fixture.debugElement.query(By.css('#file-1155-show-file')).nativeElement as HTMLButtonElement;
expect(showOption.disabled).toBeTruthy(); expect(showOption.disabled).toBeTruthy();
}); });
@@ -544,7 +544,7 @@ describe('AttachFileWidgetComponent', () => {
menuButton.click(); menuButton.click();
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const downloadOption = <HTMLButtonElement> fixture.debugElement.query(By.css('#file-1155-download-file')).nativeElement; const downloadOption = fixture.debugElement.query(By.css('#file-1155-download-file')).nativeElement as HTMLButtonElement;
expect(downloadOption.disabled).toBeTruthy(); expect(downloadOption.disabled).toBeTruthy();
}); });
@@ -557,7 +557,7 @@ describe('AttachFileWidgetComponent', () => {
menuButton.click(); menuButton.click();
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const downloadOption: HTMLButtonElement = <HTMLButtonElement> fixture.debugElement.query(By.css('#file-1155-download-file')).nativeElement; const downloadOption = fixture.debugElement.query(By.css('#file-1155-download-file')).nativeElement as HTMLButtonElement;
expect(downloadOption.disabled).toBeFalsy(); expect(downloadOption.disabled).toBeFalsy();
}); });
@@ -571,7 +571,7 @@ describe('AttachFileWidgetComponent', () => {
menuButton.click(); menuButton.click();
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const showOption = <HTMLButtonElement> fixture.debugElement.query(By.css('#file-1155-show-file')).nativeElement; const showOption = fixture.debugElement.query(By.css('#file-1155-show-file')).nativeElement as HTMLButtonElement;
expect(showOption.disabled).toBeTruthy(); expect(showOption.disabled).toBeTruthy();
}); });
}); });
@@ -579,7 +579,7 @@ describe('AttachFileWidgetComponent', () => {
it('should be able to upload files when a defined folder from external content service', async () => { it('should be able to upload files when a defined folder from external content service', async () => {
widget.field = new FormFieldModel(new FormModel(), { type: FormFieldTypes.UPLOAD, value: [] }); widget.field = new FormFieldModel(new FormModel(), { type: FormFieldTypes.UPLOAD, value: [] });
widget.field.id = 'attach-external-file-attach'; widget.field.id = 'attach-external-file-attach';
widget.field.params = <FormFieldMetadata> externalDefinedSourceParams; widget.field.params = externalDefinedSourceParams;
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer)); spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer)); spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
spyOn(attachFileWidgetDialogService, 'openLogin').and.returnValue(of([fakeMinimalNode])); spyOn(attachFileWidgetDialogService, 'openLogin').and.returnValue(of([fakeMinimalNode]));
@@ -604,7 +604,7 @@ describe('AttachFileWidgetComponent', () => {
it('should pass a valid repository id to open the external login', async () => { it('should pass a valid repository id to open the external login', async () => {
widget.field = new FormFieldModel(new FormModel(), { type: FormFieldTypes.UPLOAD, value: [] }); widget.field = new FormFieldModel(new FormModel(), { type: FormFieldTypes.UPLOAD, value: [] });
widget.field.id = 'attach-external-file-attach'; widget.field.id = 'attach-external-file-attach';
widget.field.params = <FormFieldMetadata> externalDefinedSourceParams; widget.field.params = externalDefinedSourceParams;
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer)); spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer)); spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
const openLoginSpy = spyOn(attachFileWidgetDialogService, 'openLogin').and.returnValue(of([fakeMinimalNode])); const openLoginSpy = spyOn(attachFileWidgetDialogService, 'openLogin').and.returnValue(of([fakeMinimalNode]));

View File

@@ -165,7 +165,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
onRemoveAttachFile(file: File | RelatedContentRepresentation) { onRemoveAttachFile(file: File | RelatedContentRepresentation) {
if (this.isTemporaryFile(file)) { if (this.isTemporaryFile(file)) {
this.tempFilesList.splice(this.tempFilesList.indexOf((<RelatedContentRepresentation> file).contentBlob), 1); this.tempFilesList.splice(this.tempFilesList.indexOf((file as RelatedContentRepresentation).contentBlob), 1);
} }
this.removeFile(file); this.removeFile(file);
} }
@@ -184,7 +184,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
downloadContent(file: any | RelatedContentRepresentation): void { downloadContent(file: any | RelatedContentRepresentation): void {
if (this.isTemporaryFile(file)) { if (this.isTemporaryFile(file)) {
const fileBlob = (<RelatedContentRepresentation> file).contentBlob; const fileBlob = (file as RelatedContentRepresentation).contentBlob;
if (fileBlob) { if (fileBlob) {
this.downloadService.downloadBlob(fileBlob, file.name); this.downloadService.downloadBlob(fileBlob, file.name);
} else { } else {
@@ -204,9 +204,9 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
this.downloadService.downloadUrl(nodeUrl, file.name); this.downloadService.downloadUrl(nodeUrl, file.name);
} }
} else { } else {
this.processContentService.getFileRawContent((<any> file).id).subscribe( this.processContentService.getFileRawContent(file.id).subscribe(
(blob: Blob) => { (blob: Blob) => {
this.downloadService.downloadBlob(blob, (<any> file).name); this.downloadService.downloadBlob(blob, file.name);
}, },
() => { () => {
this.logger.error('Impossible retrieve content for download'); this.logger.error('Impossible retrieve content for download');

View File

@@ -30,10 +30,10 @@ import { Node } from '@alfresco/js-api';
import { ProcessTestingModule } from '../testing/process.testing.module'; import { ProcessTestingModule } from '../testing/process.testing.module';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
const fakeMinimalNode: Node = <Node> { const fakeMinimalNode: Node = {
id: 'fake', id: 'fake',
name: 'fake-name' name: 'fake-name'
}; } as Node;
const definedSourceParams = { const definedSourceParams = {
folderSource : { folderSource : {

View File

@@ -61,7 +61,7 @@ describe('FormComponent', () => {
] ]
}); });
function buildWidget(type: string, injector: Injector): any { const buildWidget = (type: string, injector: Injector): any => {
const resolver = formRenderingService.getComponentTypeResolver(type); const resolver = formRenderingService.getComponentTypeResolver(type);
const widgetType = resolver(null); const widgetType = resolver(null);
@@ -70,7 +70,7 @@ describe('FormComponent', () => {
const componentRef = factory.create(injector); const componentRef = factory.create(injector);
return componentRef.instance; return componentRef.instance;
} };
beforeEach(() => { beforeEach(() => {
visibilityService = TestBed.inject(WidgetVisibilityService); visibilityService = TestBed.inject(WidgetVisibilityService);
@@ -230,20 +230,16 @@ describe('FormComponent', () => {
}); });
it('should get process variable if is a process task', () => { it('should get process variable if is a process task', () => {
spyOn(formService, 'getTaskForm').and.callFake((currentTaskId) => { spyOn(formService, 'getTaskForm').and.callFake((currentTaskId) => new Observable((observer) => {
return new Observable((observer) => {
observer.next({ taskId: currentTaskId }); observer.next({ taskId: currentTaskId });
observer.complete(); observer.complete();
}); }));
});
spyOn(visibilityService, 'getTaskProcessVariable').and.returnValue(of(null)); spyOn(visibilityService, 'getTaskProcessVariable').and.returnValue(of(null));
spyOn(formService, 'getTask').and.callFake((currentTaskId) => { spyOn(formService, 'getTask').and.callFake((currentTaskId) => new Observable((observer) => {
return new Observable((observer) => {
observer.next({ taskId: currentTaskId, processDefinitionId: '10201' }); observer.next({ taskId: currentTaskId, processDefinitionId: '10201' });
observer.complete(); observer.complete();
}); }));
});
const taskId = '123'; const taskId = '123';
formComponent.taskId = taskId; formComponent.taskId = taskId;
@@ -253,20 +249,16 @@ describe('FormComponent', () => {
}); });
it('should not get process variable if is not a process task', () => { it('should not get process variable if is not a process task', () => {
spyOn(formService, 'getTaskForm').and.callFake((currentTaskId) => { spyOn(formService, 'getTaskForm').and.callFake((currentTaskId) => new Observable((observer) => {
return new Observable((observer) => {
observer.next({ taskId: currentTaskId }); observer.next({ taskId: currentTaskId });
observer.complete(); observer.complete();
}); }));
});
spyOn(visibilityService, 'getTaskProcessVariable').and.returnValue(of(null)); spyOn(visibilityService, 'getTaskProcessVariable').and.returnValue(of(null));
spyOn(formService, 'getTask').and.callFake((currentTaskId) => { spyOn(formService, 'getTask').and.callFake((currentTaskId) => new Observable((observer) => {
return new Observable((observer) => {
observer.next({ taskId: currentTaskId, processDefinitionId: 'null' }); observer.next({ taskId: currentTaskId, processDefinitionId: 'null' });
observer.complete(); observer.complete();
}); }));
});
const taskId = '123'; const taskId = '123';
formComponent.taskId = taskId; formComponent.taskId = taskId;
@@ -311,7 +303,7 @@ describe('FormComponent', () => {
const taskId = '<task id>'; const taskId = '<task id>';
const change = new SimpleChange(null, taskId, true); const change = new SimpleChange(null, taskId, true);
formComponent.ngOnChanges({ 'taskId': change }); formComponent.ngOnChanges({ taskId: change });
expect(formComponent.getFormByTaskId).toHaveBeenCalledWith(taskId); expect(formComponent.getFormByTaskId).toHaveBeenCalledWith(taskId);
}); });
@@ -321,7 +313,7 @@ describe('FormComponent', () => {
const formId = '123'; const formId = '123';
const change = new SimpleChange(null, formId, true); const change = new SimpleChange(null, formId, true);
formComponent.ngOnChanges({ 'formId': change }); formComponent.ngOnChanges({ formId: change });
expect(formComponent.getFormDefinitionByFormId).toHaveBeenCalledWith(formId); expect(formComponent.getFormDefinitionByFormId).toHaveBeenCalledWith(formId);
}); });
@@ -331,7 +323,7 @@ describe('FormComponent', () => {
const formName = '<form>'; const formName = '<form>';
const change = new SimpleChange(null, formName, true); const change = new SimpleChange(null, formName, true);
formComponent.ngOnChanges({ 'formName': change }); formComponent.ngOnChanges({ formName: change });
expect(formComponent.getFormDefinitionByFormName).toHaveBeenCalledWith(formName); expect(formComponent.getFormDefinitionByFormName).toHaveBeenCalledWith(formName);
}); });
@@ -356,7 +348,7 @@ describe('FormComponent', () => {
spyOn(formComponent, 'getFormDefinitionByFormId').and.stub(); spyOn(formComponent, 'getFormDefinitionByFormId').and.stub();
spyOn(formComponent, 'getFormDefinitionByFormName').and.stub(); spyOn(formComponent, 'getFormDefinitionByFormName').and.stub();
formComponent.ngOnChanges({ 'tag': new SimpleChange(null, 'hello world', true) }); formComponent.ngOnChanges({ tag: new SimpleChange(null, 'hello world', true) });
expect(formComponent.getFormByTaskId).not.toHaveBeenCalled(); expect(formComponent.getFormByTaskId).not.toHaveBeenCalled();
expect(formComponent.getFormDefinitionByFormId).not.toHaveBeenCalled(); expect(formComponent.getFormDefinitionByFormId).not.toHaveBeenCalled();
@@ -479,12 +471,10 @@ describe('FormComponent', () => {
it('should fetch and parse form by task id', (done) => { it('should fetch and parse form by task id', (done) => {
spyOn(formService, 'getTask').and.returnValue(of({})); spyOn(formService, 'getTask').and.returnValue(of({}));
spyOn(formService, 'getTaskForm').and.callFake((currentTaskId) => { spyOn(formService, 'getTaskForm').and.callFake((currentTaskId) => new Observable((observer) => {
return new Observable((observer) => {
observer.next({ taskId: currentTaskId }); observer.next({ taskId: currentTaskId });
observer.complete(); observer.complete();
}); }));
});
const taskId = '456'; const taskId = '456';
formComponent.formLoaded.subscribe(() => { formComponent.formLoaded.subscribe(() => {
@@ -503,9 +493,7 @@ describe('FormComponent', () => {
spyOn(formService, 'getTask').and.returnValue(of({})); spyOn(formService, 'getTask').and.returnValue(of({}));
spyOn(formComponent, 'handleError').and.stub(); spyOn(formComponent, 'handleError').and.stub();
spyOn(formService, 'getTaskForm').and.callFake(() => { spyOn(formService, 'getTaskForm').and.callFake(() => throwError(error));
return throwError(error);
});
formComponent.getFormByTaskId('123').then((_) => { formComponent.getFormByTaskId('123').then((_) => {
expect(formComponent.handleError).toHaveBeenCalledWith(error); expect(formComponent.handleError).toHaveBeenCalledWith(error);
@@ -515,12 +503,10 @@ describe('FormComponent', () => {
it('should apply readonly state when getting form by task id', (done) => { it('should apply readonly state when getting form by task id', (done) => {
spyOn(formService, 'getTask').and.returnValue(of({})); spyOn(formService, 'getTask').and.returnValue(of({}));
spyOn(formService, 'getTaskForm').and.callFake((taskId) => { spyOn(formService, 'getTaskForm').and.callFake((taskId) => new Observable((observer) => {
return new Observable((observer) => { observer.next({ taskId });
observer.next({ taskId: taskId });
observer.complete(); observer.complete();
}); }));
});
formComponent.readOnly = true; formComponent.readOnly = true;
formComponent.getFormByTaskId('123').then((_) => { formComponent.getFormByTaskId('123').then((_) => {
@@ -531,12 +517,10 @@ describe('FormComponent', () => {
}); });
it('should fetch and parse form definition by id', () => { it('should fetch and parse form definition by id', () => {
spyOn(formService, 'getFormDefinitionById').and.callFake((currentFormId) => { spyOn(formService, 'getFormDefinitionById').and.callFake((currentFormId) => new Observable((observer) => {
return new Observable((observer) => {
observer.next({ id: currentFormId }); observer.next({ id: currentFormId });
observer.complete(); observer.complete();
}); }));
});
const formId = 456; const formId = 456;
let loaded = false; let loaded = false;
@@ -561,19 +545,15 @@ describe('FormComponent', () => {
}); });
it('should fetch and parse form definition by form name', () => { it('should fetch and parse form definition by form name', () => {
spyOn(formService, 'getFormDefinitionByName').and.callFake((currentFormName) => { spyOn(formService, 'getFormDefinitionByName').and.callFake((currentFormName) => new Observable((observer) => {
return new Observable((observer) => {
observer.next(currentFormName); observer.next(currentFormName);
observer.complete(); observer.complete();
}); }));
});
spyOn(formService, 'getFormDefinitionById').and.callFake((currentFormName) => { spyOn(formService, 'getFormDefinitionById').and.callFake((currentFormName) => new Observable((observer) => {
return new Observable((observer) => {
observer.next({ name: currentFormName }); observer.next({ name: currentFormName });
observer.complete(); observer.complete();
}); }));
});
const formName = '<form>'; const formName = '<form>';
let loaded = false; let loaded = false;
@@ -589,12 +569,10 @@ describe('FormComponent', () => {
}); });
it('should save task form and raise corresponding event', () => { it('should save task form and raise corresponding event', () => {
spyOn(formService, 'saveTaskForm').and.callFake(() => { spyOn(formService, 'saveTaskForm').and.callFake(() => new Observable((observer) => {
return new Observable((observer) => {
observer.next(); observer.next();
observer.complete(); observer.complete();
}); }));
});
let saved = false; let saved = false;
let savedForm = null; let savedForm = null;
@@ -654,12 +632,10 @@ describe('FormComponent', () => {
}); });
it('should complete form and raise corresponding event', () => { it('should complete form and raise corresponding event', () => {
spyOn(formService, 'completeTaskForm').and.callFake(() => { spyOn(formService, 'completeTaskForm').and.callFake(() => new Observable((observer) => {
return new Observable((observer) => {
observer.next(); observer.next();
observer.complete(); observer.complete();
}); }));
});
const outcome = 'complete'; const outcome = 'complete';
let completed = false; let completed = false;
@@ -766,7 +742,7 @@ describe('FormComponent', () => {
const nodeId = '<id>'; const nodeId = '<id>';
const change = new SimpleChange(null, nodeId, false); const change = new SimpleChange(null, nodeId, false);
formComponent.ngOnChanges({ 'nodeId': change }); formComponent.ngOnChanges({ nodeId: change });
expect(nodeService.getNodeMetadata).toHaveBeenCalledWith(nodeId); expect(nodeService.getNodeMetadata).toHaveBeenCalledWith(nodeId);
expect(formComponent.loadFormFromActiviti).toHaveBeenCalled(); expect(formComponent.loadFormFromActiviti).toHaveBeenCalled();
@@ -987,7 +963,7 @@ describe('FormComponent', () => {
formValues.radio = { id: 'option_2', name: 'Option 2' }; formValues.radio = { id: 'option_2', name: 'Option 2' };
const change = new SimpleChange(null, formValues, false); const change = new SimpleChange(null, formValues, false);
formComponent.data = formValues; formComponent.data = formValues;
formComponent.ngOnChanges({ 'data': change }); formComponent.ngOnChanges({ data: change });
formFields = formComponent.form.getFormFields(); formFields = formComponent.form.getFormFields();
dropdownField = formFields.find((field) => field.id === 'dropdownId'); dropdownField = formFields.find((field) => field.id === 'dropdownId');
@@ -1007,7 +983,7 @@ describe('FormComponent', () => {
formValues.radio = 'option_3'; formValues.radio = 'option_3';
const change = new SimpleChange(null, formValues, false); const change = new SimpleChange(null, formValues, false);
formComponent.data = formValues; formComponent.data = formValues;
formComponent.ngOnChanges({ 'data': change }); formComponent.ngOnChanges({ data: change });
formFields = formComponent.form.getFormFields(); formFields = formComponent.form.getFormFields();
radioFieldById = formFields.find((field) => field.id === 'radio'); radioFieldById = formFields.find((field) => field.id === 'radio');

View File

@@ -295,6 +295,7 @@ export class FormComponent extends FormBaseComponent implements OnInit, OnDestro
/** /**
* Get custom set of outcomes for a Form Definition. * Get custom set of outcomes for a Form Definition.
*
* @param form Form definition model. * @param form Form definition model.
*/ */
getFormDefinitionOutcomes(form: FormModel): FormOutcomeModel[] { getFormDefinitionOutcomes(form: FormModel): FormOutcomeModel[] {
@@ -309,20 +310,6 @@ export class FormComponent extends FormBaseComponent implements OnInit, OnDestro
} }
} }
private refreshFormData() {
this.form = this.parseForm(this.form.json);
this.onFormLoaded(this.form);
this.onFormDataRefreshed(this.form);
}
private loadFormForEcmNode(nodeId: string): void {
this.nodeService.getNodeMetadata(nodeId).subscribe((data) => {
this.data = data.metadata;
this.loadFormFromActiviti(data.nodeType);
},
this.handleError);
}
loadFormFromActiviti(nodeType: string): any { loadFormFromActiviti(nodeType: string): any {
this.formService.searchFrom(nodeType).subscribe( this.formService.searchFrom(nodeType).subscribe(
(form) => { (form) => {
@@ -340,11 +327,6 @@ export class FormComponent extends FormBaseComponent implements OnInit, OnDestro
); );
} }
private loadFormFromFormId(formId: number) {
this.formId = formId;
this.loadForm();
}
protected storeFormAsMetadata() { protected storeFormAsMetadata() {
if (this.saveMetadata) { if (this.saveMetadata) {
this.ecmModelService.createEcmTypeForActivitiForm(this.formName, this.form).subscribe((type) => { this.ecmModelService.createEcmTypeForActivitiForm(this.formName, this.form).subscribe((type) => {
@@ -398,4 +380,23 @@ export class FormComponent extends FormBaseComponent implements OnInit, OnDestro
this.executeOutcome.emit(args); this.executeOutcome.emit(args);
return !args.defaultPrevented; return !args.defaultPrevented;
} }
private refreshFormData() {
this.form = this.parseForm(this.form.json);
this.onFormLoaded(this.form);
this.onFormDataRefreshed(this.form);
}
private loadFormForEcmNode(nodeId: string): void {
this.nodeService.getNodeMetadata(nodeId).subscribe((data) => {
this.data = data.metadata;
this.loadFormFromActiviti(data.nodeType);
},
this.handleError);
}
private loadFormFromFormId(formId: number) {
this.formId = formId;
this.loadForm();
}
} }

View File

@@ -34,10 +34,10 @@ describe('FormComponent UI and visibility', () => {
let service: FormService; let service: FormService;
let fixture: ComponentFixture<FormComponent>; let fixture: ComponentFixture<FormComponent>;
function openSelect() { const openSelect = () => {
const dropdown = fixture.debugElement.nativeElement.querySelector('.mat-select-trigger'); const dropdown = fixture.debugElement.nativeElement.querySelector('.mat-select-trigger');
dropdown.click(); dropdown.click();
} };
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -64,7 +64,7 @@ describe('FormComponent UI and visibility', () => {
spyOn(service, 'getTaskForm').and.returnValue(of(formDefinitionTwoTextFields)); spyOn(service, 'getTaskForm').and.returnValue(of(formDefinitionTwoTextFields));
const change = new SimpleChange(null, 1, true); const change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
fixture.detectChanges(); fixture.detectChanges();
expect(fixture.debugElement.query(By.css('#adf-valid-form-icon'))).toBeDefined(); expect(fixture.debugElement.query(By.css('#adf-valid-form-icon'))).toBeDefined();
expect(fixture.debugElement.query(By.css('#adf-valid-form-icon'))).not.toBeNull(); expect(fixture.debugElement.query(By.css('#adf-valid-form-icon'))).not.toBeNull();
@@ -76,7 +76,7 @@ describe('FormComponent UI and visibility', () => {
spyOn(service, 'getTaskForm').and.returnValue(of(formDefinitionRequiredField)); spyOn(service, 'getTaskForm').and.returnValue(of(formDefinitionRequiredField));
const change = new SimpleChange(null, 1, true); const change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
fixture.detectChanges(); fixture.detectChanges();
expect(fixture.debugElement.query(By.css('#adf-valid-form-icon'))).toBeNull(); expect(fixture.debugElement.query(By.css('#adf-valid-form-icon'))).toBeNull();
expect(fixture.debugElement.query(By.css('#adf-invalid-form-icon'))).toBeDefined(); expect(fixture.debugElement.query(By.css('#adf-invalid-form-icon'))).toBeDefined();
@@ -88,7 +88,7 @@ describe('FormComponent UI and visibility', () => {
spyOn(service, 'getTaskForm').and.returnValue(of(formDefinitionTwoTextFields)); spyOn(service, 'getTaskForm').and.returnValue(of(formDefinitionTwoTextFields));
const change = new SimpleChange(null, 1, true); const change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
component.showValidationIcon = false; component.showValidationIcon = false;
fixture.detectChanges(); fixture.detectChanges();
expect(fixture.debugElement.query(By.css('#adf-valid-form-icon'))).toBeNull(); expect(fixture.debugElement.query(By.css('#adf-valid-form-icon'))).toBeNull();
@@ -103,7 +103,7 @@ describe('FormComponent UI and visibility', () => {
spyOn(service, 'getTaskForm').and.returnValue(of(formDefinitionTwoTextFields)); spyOn(service, 'getTaskForm').and.returnValue(of(formDefinitionTwoTextFields));
const change = new SimpleChange(null, 1, true); const change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
fixture.detectChanges(); fixture.detectChanges();
const firstNameEl = fixture.debugElement.query(By.css('#firstname')); const firstNameEl = fixture.debugElement.query(By.css('#firstname'));
@@ -120,7 +120,7 @@ describe('FormComponent UI and visibility', () => {
spyOn(service, 'getTaskForm').and.returnValue(of(formDefinitionDropdownField)); spyOn(service, 'getTaskForm').and.returnValue(of(formDefinitionDropdownField));
const change = new SimpleChange(null, 1, true); const change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -154,7 +154,7 @@ describe('FormComponent UI and visibility', () => {
spyOn(service, 'getTaskForm').and.returnValue(of(formDefVisibilitiFieldDependsOnNextOne)); spyOn(service, 'getTaskForm').and.returnValue(of(formDefVisibilitiFieldDependsOnNextOne));
const change = new SimpleChange(null, 1, true); const change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
fixture.detectChanges(); fixture.detectChanges();
const firstEl = fixture.debugElement.query(By.css('#field-country-container')); const firstEl = fixture.debugElement.query(By.css('#field-country-container'));
@@ -171,7 +171,7 @@ describe('FormComponent UI and visibility', () => {
spyOn(service, 'getTaskForm').and.returnValue(of(formDefVisibilitiFieldDependsOnPreviousOne)); spyOn(service, 'getTaskForm').and.returnValue(of(formDefVisibilitiFieldDependsOnPreviousOne));
const change = new SimpleChange(null, 1, true); const change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
fixture.detectChanges(); fixture.detectChanges();
const firstEl = fixture.debugElement.query(By.css('#name')); const firstEl = fixture.debugElement.query(By.css('#name'));
@@ -188,7 +188,7 @@ describe('FormComponent UI and visibility', () => {
spyOn(service, 'getTaskForm').and.returnValue(of(formDefVisibilitiFieldDependsOnNextOne)); spyOn(service, 'getTaskForm').and.returnValue(of(formDefVisibilitiFieldDependsOnNextOne));
const change = new SimpleChange(null, 1, true); const change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
fixture.detectChanges(); fixture.detectChanges();
let firstEl = fixture.debugElement.query(By.css('#field-country-container')); let firstEl = fixture.debugElement.query(By.css('#field-country-container'));
@@ -213,7 +213,7 @@ describe('FormComponent UI and visibility', () => {
spyOn(service, 'getTaskForm').and.returnValue(of(formReadonlyTwoTextFields)); spyOn(service, 'getTaskForm').and.returnValue(of(formReadonlyTwoTextFields));
const change = new SimpleChange(null, 1, true); const change = new SimpleChange(null, 1, true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();

View File

@@ -28,7 +28,7 @@ export class ProcessFormRenderingService extends FormRenderingService {
super(); super();
this.register({ this.register({
'upload': () => AttachFileWidgetComponent, upload: () => AttachFileWidgetComponent,
'select-folder': () => AttachFolderWidgetComponent 'select-folder': () => AttachFolderWidgetComponent
}, true); }, true);
} }

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
export let startFormDateWidgetMock = { export const startFormDateWidgetMock = {
id: 4, id: 4,
name: 'Claim Review Process', name: 'Claim Review Process',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',
@@ -38,7 +38,7 @@ export let startFormDateWidgetMock = {
}] }]
}; };
export let startFormNumberWidgetMock = { export const startFormNumberWidgetMock = {
id: 4, id: 4,
name: 'Claim Review Process', name: 'Claim Review Process',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',
@@ -61,7 +61,7 @@ export let startFormNumberWidgetMock = {
}] }]
}; };
export let startFormAmountWidgetMock = { export const startFormAmountWidgetMock = {
id: 4, id: 4,
name: 'Claim Review Process', name: 'Claim Review Process',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',
@@ -84,7 +84,7 @@ export let startFormAmountWidgetMock = {
}] }]
}; };
export let startFormRadioButtonWidgetMock = { export const startFormRadioButtonWidgetMock = {
id: 4, id: 4,
name: 'Claim Review Process', name: 'Claim Review Process',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',
@@ -107,7 +107,7 @@ export let startFormRadioButtonWidgetMock = {
}] }]
}; };
export let startFormTextDefinitionMock = { export const startFormTextDefinitionMock = {
id: 4, id: 4,
name: 'Claim Review Process', name: 'Claim Review Process',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',
@@ -130,7 +130,7 @@ export let startFormTextDefinitionMock = {
}] }]
}; };
export let startFormDropdownDefinitionMock = { export const startFormDropdownDefinitionMock = {
id: 4, id: 4,
name: 'Claim Review Process', name: 'Claim Review Process',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',
@@ -179,7 +179,7 @@ export let startFormDropdownDefinitionMock = {
}] }]
}; };
export let startMockForm = { export const startMockForm = {
id: 4, id: 4,
name: 'Claim Review Process', name: 'Claim Review Process',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',
@@ -593,7 +593,7 @@ export let startMockForm = {
globalDateFormat: 'D - M - YYYY' globalDateFormat: 'D - M - YYYY'
}; };
export let startMockFormWithTab = { export const startMockFormWithTab = {
id: 4, id: 4,
taskName: 'Mock Title', taskName: 'Mock Title',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',
@@ -1056,7 +1056,7 @@ export const taskFormSingleUploadMock = {
visibilityCondition: null, visibilityCondition: null,
numberOfColumns: 2, numberOfColumns: 2,
fields: { fields: {
'1': [ 1: [
{ {
fieldType: 'AttachFileFieldRepresentation', fieldType: 'AttachFileFieldRepresentation',
id: 'fake-single-upload', id: 'fake-single-upload',
@@ -1138,7 +1138,7 @@ export const taskFormMultipleUploadMock = {
visibilityCondition: null, visibilityCondition: null,
numberOfColumns: 2, numberOfColumns: 2,
fields: { fields: {
'1': [ 1: [
{ {
fieldType: 'AttachFileFieldRepresentation', fieldType: 'AttachFileFieldRepresentation',
id: 'fake-multiple-upload', id: 'fake-multiple-upload',

View File

@@ -60,12 +60,8 @@ describe('StartFormComponent', () => {
processDefinitionName: 'my:process' processDefinitionName: 'my:process'
})); }));
spyOn(translate, 'instant').and.callFake((key) => { spyOn(translate, 'instant').and.callFake((key) => key);
return key; spyOn(translate, 'get').and.callFake((key) => of(key));
});
spyOn(translate, 'get').and.callFake((key) => {
return of(key);
});
}); });
afterEach(() => { afterEach(() => {

View File

@@ -17,7 +17,7 @@
import { AppDefinitionRepresentationModel } from '../task-list'; import { AppDefinitionRepresentationModel } from '../task-list';
export let nonDeployedApps = [new AppDefinitionRepresentationModel({ export const nonDeployedApps = [new AppDefinitionRepresentationModel({
id: '1', id: '1',
name: '1', name: '1',
icon: 'icon1' icon: 'icon1'
@@ -30,7 +30,7 @@ export let nonDeployedApps = [new AppDefinitionRepresentationModel({
name: '3', name: '3',
icon: 'icon3' icon: 'icon3'
})]; })];
export let deployedApps = [new AppDefinitionRepresentationModel({ export const deployedApps = [new AppDefinitionRepresentationModel({
id: 1, id: 1,
name: 'App1', name: 'App1',
icon: 'icon1', icon: 'icon1',
@@ -74,6 +74,6 @@ export let deployedApps = [new AppDefinitionRepresentationModel({
tenantId: 9, tenantId: 9,
modelId: 66 modelId: 66
})]; })];
export let defaultApp = [new AppDefinitionRepresentationModel({ export const defaultApp = [new AppDefinitionRepresentationModel({
defaultAppId: 'tasks' defaultAppId: 'tasks'
})]; })];

View File

@@ -17,7 +17,7 @@
import { CommentModel } from '@alfresco/adf-core'; import { CommentModel } from '@alfresco/adf-core';
export let mockProcessInstanceComments = [ export const mockProcessInstanceComments = [
new CommentModel({ message: 'Test1', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} }), new CommentModel({ message: 'Test1', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} }),
new CommentModel({ message: 'Test2', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} }), new CommentModel({ message: 'Test2', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} }),
new CommentModel({ message: 'Test3', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} }) new CommentModel({ message: 'Test3', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} })

View File

@@ -17,7 +17,7 @@
import { FilterProcessRepresentationModel } from '../../process-list/models/filter-process.model'; import { FilterProcessRepresentationModel } from '../../process-list/models/filter-process.model';
export let fakeProcessFilters = [ export const fakeProcessFilters = [
new FilterProcessRepresentationModel({ new FilterProcessRepresentationModel({
id: 10, id: 10,
name: 'FakeCompleted', name: 'FakeCompleted',
@@ -38,14 +38,14 @@ export let fakeProcessFilters = [
}) })
]; ];
export let fakeProcessFiltersResponse = { export const fakeProcessFiltersResponse = {
size: 1, total: 1, start: 0, size: 1, total: 1, start: 0,
data: [new FilterProcessRepresentationModel({ data: [new FilterProcessRepresentationModel({
'name': 'Running', name: 'Running',
'appId': '22', appId: '22',
'id': 333, id: 333,
'recent': true, recent: true,
'icon': 'glyphicon-random', icon: 'glyphicon-random',
'filter': { 'sort': 'created-desc', 'name': '', 'state': 'running' } filter: { sort: 'created-desc', name: '', state: 'running' }
})] })]
}; };

View File

@@ -17,7 +17,7 @@
import { ProcessListModel } from '../../process-list/models/process-list.model'; import { ProcessListModel } from '../../process-list/models/process-list.model';
export let fakeProcessInstance = new ProcessListModel({ export const fakeProcessInstance = new ProcessListModel({
size: 2, size: 2,
total: 2, total: 2,
start: 0, start: 0,
@@ -85,7 +85,7 @@ export let fakeProcessInstance = new ProcessListModel({
] ]
}); });
export let fakeProcessInstancesWithNoName = { export const fakeProcessInstancesWithNoName = {
size: 2, size: 2,
total: 2, total: 2,
start: 0, start: 0,
@@ -125,14 +125,14 @@ export let fakeProcessInstancesWithNoName = {
] ]
}; };
export let fakeProcessInstancesEmpty = new ProcessListModel({ export const fakeProcessInstancesEmpty = new ProcessListModel({
size: 0, size: 0,
total: 0, total: 0,
start: 0, start: 0,
data: [] data: []
}); });
export let fakeProcessCustomSchema = [ export const fakeProcessCustomSchema = [
{ {
key: 'fakeName', key: 'fakeName',
type: 'text', type: 'text',
@@ -147,7 +147,7 @@ export let fakeProcessCustomSchema = [
} }
]; ];
export let fakeProcessColumnSchema = { export const fakeProcessColumnSchema = {
default: [ default: [
{ {
key: 'default-name', key: 'default-name',

View File

@@ -34,13 +34,13 @@ export class SingleProcessList extends ProcessList {
constructor(name?: string) { constructor(name?: string) {
const instance = new ProcessInstance({ const instance = new ProcessInstance({
id: '123', id: '123',
name: name name
}); });
super([instance]); super([instance]);
} }
} }
export let exampleProcess = new ProcessInstance({ export const exampleProcess = new ProcessInstance({
id: '123', id: '123',
name: 'Process 123', name: 'Process 123',
started: '2016-11-10T03:37:30.010+0000', started: '2016-11-10T03:37:30.010+0000',
@@ -52,7 +52,7 @@ export let exampleProcess = new ProcessInstance({
} }
}); });
export let processEnded = new ProcessInstance({ export const processEnded = new ProcessInstance({
id: '123', id: '123',
name: 'Process 123', name: 'Process 123',
started: '2016-11-10T03:37:30.010+0000', started: '2016-11-10T03:37:30.010+0000',
@@ -65,7 +65,7 @@ export let processEnded = new ProcessInstance({
ended: '2016-11-11T03:37:30.010+0000' ended: '2016-11-11T03:37:30.010+0000'
}); });
export let mockRunningProcess = new ProcessInstance({ export const mockRunningProcess = new ProcessInstance({
id: '123', id: '123',
name: 'Process 123', name: 'Process 123',
started: '2016-11-10T03:37:30.010+0000', started: '2016-11-10T03:37:30.010+0000',
@@ -78,7 +78,7 @@ export let mockRunningProcess = new ProcessInstance({
ended: null ended: null
}); });
export let exampleProcessNoName = new ProcessInstance({ export const exampleProcessNoName = new ProcessInstance({
id: '123', id: '123',
name: null, name: null,
started: '2016-11-10T03:37:30.010+0000', started: '2016-11-10T03:37:30.010+0000',
@@ -91,7 +91,7 @@ export let exampleProcessNoName = new ProcessInstance({
processDefinitionName: 'My Process' processDefinitionName: 'My Process'
}); });
export let fakeProcessInstances = { export const fakeProcessInstances = {
size: 2, size: 2,
total: 2, total: 2,
start: 0, start: 0,

View File

@@ -18,12 +18,12 @@
import { AppDefinitionRepresentationModel, TaskDetailsModel } from '../../task-list'; import { AppDefinitionRepresentationModel, TaskDetailsModel } from '../../task-list';
import { ProcessDefinitionRepresentation } from '../../process-list/models/process-definition.model'; import { ProcessDefinitionRepresentation } from '../../process-list/models/process-definition.model';
export let mockError = { export const mockError = {
message: null, message: null,
messageKey: 'GENERAL.ERROR.FORBIDDEN' messageKey: 'GENERAL.ERROR.FORBIDDEN'
}; };
export let fakeApp1 = new AppDefinitionRepresentationModel({ export const fakeApp1 = new AppDefinitionRepresentationModel({
deploymentId: 26, deploymentId: 26,
name: 'HR processes', name: 'HR processes',
icon: 'glyphicon-cloud', icon: 'glyphicon-cloud',
@@ -33,7 +33,7 @@ export let fakeApp1 = new AppDefinitionRepresentationModel({
id: 1 id: 1
}); });
export let fakeApp2 = new AppDefinitionRepresentationModel({ export const fakeApp2 = new AppDefinitionRepresentationModel({
deploymentId: 2501, deploymentId: 2501,
name: 'Sales onboarding', name: 'Sales onboarding',
icon: 'glyphicon-asterisk', icon: 'glyphicon-asterisk',
@@ -43,7 +43,7 @@ export let fakeApp2 = new AppDefinitionRepresentationModel({
id: 1000 id: 1000
}); });
export let fakeTasksList = { export const fakeTasksList = {
data: [new TaskDetailsModel({ data: [new TaskDetailsModel({
id: 1, id: 1,
name: 'Task 1', name: 'Task 1',
@@ -57,7 +57,7 @@ export let fakeTasksList = {
})] })]
}; };
export let fakeProcessDef = new ProcessDefinitionRepresentation({ export const fakeProcessDef = new ProcessDefinitionRepresentation({
id: '32323', id: '32323',
key: 'blah', key: 'blah',
name: 'Process 1' name: 'Process 1'

View File

@@ -18,24 +18,24 @@
import { ProcessDefinitionRepresentation } from '../../process-list/models/process-definition.model'; import { ProcessDefinitionRepresentation } from '../../process-list/models/process-definition.model';
import { ProcessInstance } from '../../process-list/models/process-instance.model'; import { ProcessInstance } from '../../process-list/models/process-instance.model';
export let newProcess = new ProcessInstance({ export const newProcess = new ProcessInstance({
id: '32323', id: '32323',
name: 'Process' name: 'Process'
}); });
export let testProcessDef = new ProcessDefinitionRepresentation({ export const testProcessDef = new ProcessDefinitionRepresentation({
id: 'my:process1', id: 'my:process1',
name: 'My Process 1', name: 'My Process 1',
hasStartForm: false hasStartForm: false
}); });
export let testProcessDefinitions = [new ProcessDefinitionRepresentation({ export const testProcessDefinitions = [new ProcessDefinitionRepresentation({
id: 'my:process1', id: 'my:process1',
name: 'My Process 1', name: 'My Process 1',
hasStartForm: false hasStartForm: false
})]; })];
export let testMultipleProcessDefs = [new ProcessDefinitionRepresentation({ export const testMultipleProcessDefs = [new ProcessDefinitionRepresentation({
id: 'my:process1', id: 'my:process1',
name: 'My Process 1', name: 'My Process 1',
hasStartForm: false hasStartForm: false
@@ -45,7 +45,7 @@ export let testMultipleProcessDefs = [new ProcessDefinitionRepresentation({
hasStartForm: true hasStartForm: true
})]; })];
export let testProcessDefWithForm = [new ProcessDefinitionRepresentation({ export const testProcessDefWithForm = [new ProcessDefinitionRepresentation({
id: 'my:process1', id: 'my:process1',
name: 'My Process 1', name: 'My Process 1',
hasStartForm: true hasStartForm: true

View File

@@ -15,20 +15,11 @@
* limitations under the License. * limitations under the License.
*/ */
export let startTaskMock = { export const startTaskMock = {
'name': 'fakeName', name: 'fakeName',
'description': 'fakeDescription', description: 'fakeDescription',
'assignee': null, assignee: null,
'dueDate': '2017-11-03T15:25:42.749+0000', dueDate: '2017-11-03T15:25:42.749+0000',
'formKey': null, formKey: null,
'category': 'fakeAppId' category: 'fakeAppId'
}; };
//
// export let noDataMock = {
// 'name': '',
// 'description': '',
// 'assignee': {},
// 'dueDate': '',
// 'formKey': '',
// 'category': ';'
// };

View File

@@ -15,6 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
export let mockTaskDetailsComponent = { export const mockTaskDetailsComponent = {
noTaskDetailsTemplateComponent: null noTaskDetailsTemplateComponent: null
}; };

View File

@@ -18,7 +18,7 @@
import { UserRepresentation } from '@alfresco/js-api'; import { UserRepresentation } from '@alfresco/js-api';
import { TaskDetailsModel } from '../../task-list/models/task-details.model'; import { TaskDetailsModel } from '../../task-list/models/task-details.model';
export let standaloneTaskWithForm = new TaskDetailsModel({ export const standaloneTaskWithForm = new TaskDetailsModel({
id: '100', id: '100',
name: 'Standalone Task With Form', name: 'Standalone Task With Form',
description: null, description: null,
@@ -58,7 +58,7 @@ export let standaloneTaskWithForm = new TaskDetailsModel({
memberOfCandidateGroup: false memberOfCandidateGroup: false
}); });
export let standaloneTaskWithoutForm = new TaskDetailsModel({ export const standaloneTaskWithoutForm = new TaskDetailsModel({
id: '200', id: '200',
name: 'Standalone Task Without Form', name: 'Standalone Task Without Form',
description: null, description: null,
@@ -98,7 +98,7 @@ export let standaloneTaskWithoutForm = new TaskDetailsModel({
memberOfCandidateGroup: false memberOfCandidateGroup: false
}); });
export let completedStandaloneTaskWithoutForm = new TaskDetailsModel({ export const completedStandaloneTaskWithoutForm = new TaskDetailsModel({
id: '200', id: '200',
name: 'Standalone Task Without Form', name: 'Standalone Task Without Form',
description: null, description: null,
@@ -138,7 +138,7 @@ export let completedStandaloneTaskWithoutForm = new TaskDetailsModel({
memberOfCandidateGroup: false memberOfCandidateGroup: false
}); });
export let taskDetailsMock = new TaskDetailsModel({ export const taskDetailsMock = new TaskDetailsModel({
id: '91', id: '91',
name: 'Request translation', name: 'Request translation',
description: null, description: null,
@@ -178,7 +178,7 @@ export let taskDetailsMock = new TaskDetailsModel({
memberOfCandidateGroup: false memberOfCandidateGroup: false
}); });
export let initiatorCanCompleteTaskDetailsMock = new TaskDetailsModel({ export const initiatorCanCompleteTaskDetailsMock = new TaskDetailsModel({
id: '91', id: '91',
name: 'Request translation', name: 'Request translation',
description: null, description: null,
@@ -213,7 +213,7 @@ export let initiatorCanCompleteTaskDetailsMock = new TaskDetailsModel({
memberOfCandidateGroup: false memberOfCandidateGroup: false
}); });
export let initiatorWithCandidatesTaskDetailsMock = new TaskDetailsModel({ export const initiatorWithCandidatesTaskDetailsMock = new TaskDetailsModel({
id: '91', id: '91',
name: 'Request translation', name: 'Request translation',
description: null, description: null,
@@ -261,7 +261,7 @@ export let initiatorWithCandidatesTaskDetailsMock = new TaskDetailsModel({
memberOfCandidateGroup: true memberOfCandidateGroup: true
}); });
export let taskDetailsWithOutAssigneeMock = new TaskDetailsModel({ export const taskDetailsWithOutAssigneeMock = new TaskDetailsModel({
id: '91', id: '91',
name: 'Request translation', name: 'Request translation',
description: null, description: null,
@@ -296,7 +296,7 @@ export let taskDetailsWithOutAssigneeMock = new TaskDetailsModel({
memberOfCandidateGroup: false memberOfCandidateGroup: false
}); });
export let claimableTaskDetailsMock = new TaskDetailsModel({ export const claimableTaskDetailsMock = new TaskDetailsModel({
id: '91', id: '91',
name: 'Request translation', name: 'Request translation',
description: null, description: null,
@@ -336,7 +336,7 @@ export let claimableTaskDetailsMock = new TaskDetailsModel({
memberOfCandidateUsers: false memberOfCandidateUsers: false
}); });
export let claimedTaskDetailsMock = new TaskDetailsModel({ export const claimedTaskDetailsMock = new TaskDetailsModel({
id: '91', id: '91',
name: 'Request translation', name: 'Request translation',
description: null, description: null,
@@ -389,7 +389,7 @@ export let claimedTaskDetailsMock = new TaskDetailsModel({
memberOfCandidateUsers: true memberOfCandidateUsers: true
}); });
export let claimedByGroupMemberMock = new TaskDetailsModel({ export const claimedByGroupMemberMock = new TaskDetailsModel({
id: '91', id: '91',
name: 'Request translation', name: 'Request translation',
description: null, description: null,
@@ -439,7 +439,7 @@ export let claimedByGroupMemberMock = new TaskDetailsModel({
memberOfCandidateUsers: true memberOfCandidateUsers: true
}); });
export let taskDetailsWithOutCandidateGroup = new TaskDetailsModel({ export const taskDetailsWithOutCandidateGroup = new TaskDetailsModel({
id: '91', id: '91',
name: 'Request translation', name: 'Request translation',
description: null, description: null,
@@ -481,7 +481,7 @@ export let taskDetailsWithOutCandidateGroup = new TaskDetailsModel({
] ]
}); });
export let completedTaskWithFormMock = new TaskDetailsModel({ export const completedTaskWithFormMock = new TaskDetailsModel({
id: '91', id: '91',
name: 'Request translation', name: 'Request translation',
description: null, description: null,
@@ -511,7 +511,7 @@ export let completedTaskWithFormMock = new TaskDetailsModel({
memberOfCandidateUsers: false memberOfCandidateUsers: false
}); });
export let completedTaskDetailsMock = new TaskDetailsModel({ export const completedTaskDetailsMock = new TaskDetailsModel({
id: '91', id: '91',
name: 'Request translation', name: 'Request translation',
description: null, description: null,
@@ -541,38 +541,38 @@ export let completedTaskDetailsMock = new TaskDetailsModel({
memberOfCandidateUsers: false memberOfCandidateUsers: false
}); });
export let taskDetailsWithOutFormMock = new TaskDetailsModel({ export const taskDetailsWithOutFormMock = new TaskDetailsModel({
'id': '91', id: '91',
'name': 'Request translation', name: 'Request translation',
'description': 'fake description', description: 'fake description',
'category': null, category: null,
'assignee': {'id': 1001, 'firstName': 'Admin', 'lastName': 'Paul', 'email': 'fake-email@gmail.com' }, assignee: {id: 1001, firstName: 'Admin', lastName: 'Paul', email: 'fake-email@gmail.com' },
'created': '2016-11-03T15:25:42.749+0000', created: '2016-11-03T15:25:42.749+0000',
'dueDate': '2016-11-03T15:25:42.749+0000', dueDate: '2016-11-03T15:25:42.749+0000',
'endDate': null, endDate: null,
'duration': null, duration: null,
'priority': 50, priority: 50,
'parentTaskId': null, parentTaskId: null,
'parentTaskName': null, parentTaskName: null,
'processInstanceId': '86', processInstanceId: '86',
'processInstanceName': null, processInstanceName: null,
'processDefinitionId': 'TranslationProcess:2:8', processDefinitionId: 'TranslationProcess:2:8',
'processDefinitionName': 'Translation Process', processDefinitionName: 'Translation Process',
'processDefinitionDescription': null, processDefinitionDescription: null,
'processDefinitionKey': 'TranslationProcess', processDefinitionKey: 'TranslationProcess',
'processDefinitionCategory': 'http://www.activiti.org/processdef', processDefinitionCategory: 'http://www.activiti.org/processdef',
'processDefinitionVersion': 2, processDefinitionVersion: 2,
'processDefinitionDeploymentId': '5', processDefinitionDeploymentId: '5',
'formKey': null, formKey: null,
'processInstanceStartUserId': '1001', processInstanceStartUserId: '1001',
'initiatorCanCompleteTask': false, initiatorCanCompleteTask: false,
'adhocTaskCanBeReassigned': false, adhocTaskCanBeReassigned: false,
'taskDefinitionKey': 'sid-DDECD9E4-0299-433F-9193-C3D905C3EEBE', taskDefinitionKey: 'sid-DDECD9E4-0299-433F-9193-C3D905C3EEBE',
'executionId': '86', executionId: '86',
'involvedPeople': [], involvedPeople: [],
'memberOfCandidateUsers': false, memberOfCandidateUsers: false,
'managerOfCandidateGroup': false, managerOfCandidateGroup: false,
'memberOfCandidateGroup': false memberOfCandidateGroup: false
}); });
export const taskFormMock = { export const taskFormMock = {
@@ -619,7 +619,7 @@ export const taskFormMock = {
visibilityCondition: null, visibilityCondition: null,
numberOfColumns: 2, numberOfColumns: 2,
fields: { fields: {
'1': [ 1: [
{ {
fieldType: 'FormFieldRepresentation', fieldType: 'FormFieldRepresentation',
id: 'text1', id: 'text1',
@@ -655,7 +655,7 @@ export const taskFormMock = {
visibilityCondition: null visibilityCondition: null
} }
], ],
'2': [ 2: [
{ {
fieldType: 'FormFieldRepresentation', fieldType: 'FormFieldRepresentation',
id: 'text2', id: 'text2',
@@ -727,7 +727,7 @@ export const taskFormMock = {
visibilityCondition: null, visibilityCondition: null,
numberOfColumns: 2, numberOfColumns: 2,
fields: { fields: {
'1': [ 1: [
{ {
fieldType: 'FormFieldRepresentation', fieldType: 'FormFieldRepresentation',
id: 'text3', id: 'text3',
@@ -773,7 +773,7 @@ export const taskFormMock = {
} }
} }
], ],
'2': [ 2: [
{ {
fieldType: 'FormFieldRepresentation', fieldType: 'FormFieldRepresentation',
id: 'numberField', id: 'numberField',
@@ -831,9 +831,9 @@ export const taskFormMock = {
globalDateFormat: 'D-M-YYYY' globalDateFormat: 'D-M-YYYY'
}; };
export let tasksMock = [new TaskDetailsModel(taskDetailsMock)]; export const tasksMock = [new TaskDetailsModel(taskDetailsMock)];
export let noDataMock = [ export const noDataMock = [
new TaskDetailsModel({ new TaskDetailsModel({
id: 1005, id: 1005,
message: 'example-message', message: 'example-message',

View File

@@ -15,9 +15,9 @@
* limitations under the License. * limitations under the License.
*/ */
import { FilterRepresentationModel } from '../../task-list/models/filter.model'; import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../../task-list/models/filter.model';
export let fakeFiltersResponse: any = { export const fakeFiltersResponse: any = {
size: 2, total: 2, start: 0, size: 2, total: 2, start: 0,
data: [ data: [
{ {
@@ -31,7 +31,7 @@ export let fakeFiltersResponse: any = {
] ]
}; };
export let fakeTaskFilters = [ export const fakeTaskFilters = [
new FilterRepresentationModel({ new FilterRepresentationModel({
name: 'FakeInvolvedTasks', name: 'FakeInvolvedTasks',
icon: 'glyphicon-align-left', icon: 'glyphicon-align-left',
@@ -52,7 +52,7 @@ export let fakeTaskFilters = [
}) })
]; ];
export let fakeAppFilter = { export const fakeAppFilter = {
size: 1, total: 1, start: 0, size: 1, total: 1, start: 0,
data: [ data: [
{ {
@@ -62,11 +62,14 @@ export let fakeAppFilter = {
] ]
}; };
export let fakeFilter = { export const fakeFilter: TaskQueryRequestRepresentationModel = {
sort: 'created-desc', text: '', state: 'open', assignment: 'fake-assignee' sort: 'created-desc',
text: '',
state: 'open',
assignment: 'fake-assignee'
}; };
export let fakeRepresentationFilter1: FilterRepresentationModel = new FilterRepresentationModel({ export const fakeRepresentationFilter1: FilterRepresentationModel = new FilterRepresentationModel({
appId: 1, appId: 1,
name: 'CONTAIN FILTER', name: 'CONTAIN FILTER',
recent: true, recent: true,
@@ -83,7 +86,7 @@ export let fakeRepresentationFilter1: FilterRepresentationModel = new FilterRepr
} }
}); });
export let fakeRepresentationFilter2: FilterRepresentationModel = new FilterRepresentationModel({ export const fakeRepresentationFilter2: FilterRepresentationModel = new FilterRepresentationModel({
appId: 2, appId: 2,
name: 'NO TASK FILTER', name: 'NO TASK FILTER',
recent: false, recent: false,

View File

@@ -78,7 +78,7 @@ export const fakeGlobalTask = new TaskListModel({
] ]
}); });
export let fakeCustomSchema = [ export const fakeCustomSchema = [
{ {
key: 'fakeName', key: 'fakeName',
type: 'text', type: 'text',
@@ -93,7 +93,7 @@ export let fakeCustomSchema = [
} }
]; ];
export let fakeColumnSchema = { export const fakeColumnSchema = {
default: [ default: [
{ {
key: 'default-name', key: 'default-name',
@@ -119,7 +119,7 @@ export let fakeColumnSchema = {
fakeCustomSchema fakeCustomSchema
}; };
export let fakeEmptyTask = { export const fakeEmptyTask = {
size: 0, size: 0,
start: 0, start: 0,
total: 0, total: 0,
@@ -127,163 +127,163 @@ export let fakeEmptyTask = {
}; };
export const paginatedTask = new TaskListModel({ export const paginatedTask = new TaskListModel({
'size': 5, size: 5,
'total': 9, total: 9,
'start': 0, start: 0,
'data': [{ data: [{
'id': '69211', id: '69211',
'name': 'My Task Name', name: 'My Task Name',
'description': '', description: '',
'category': null, category: null,
'assignee': {'id': 1493, 'firstName': 'fake name', 'lastName': 'fake', 'email': 'abc@test.com'}, assignee: {id: 1493, firstName: 'fake name', lastName: 'fake', email: 'abc@test.com'},
'created': '2020-02-06T18:41:21.587+0000', created: '2020-02-06T18:41:21.587+0000',
'dueDate': null, dueDate: null,
'endDate': null, endDate: null,
'duration': null, duration: null,
'priority': 50, priority: 50,
'parentTaskId': null, parentTaskId: null,
'parentTaskName': null, parentTaskName: null,
'processInstanceId': null, processInstanceId: null,
'processInstanceName': null, processInstanceName: null,
'processDefinitionId': null, processDefinitionId: null,
'processDefinitionName': null, processDefinitionName: null,
'processDefinitionDescription': null, processDefinitionDescription: null,
'processDefinitionKey': null, processDefinitionKey: null,
'processDefinitionCategory': null, processDefinitionCategory: null,
'processDefinitionVersion': 0, processDefinitionVersion: 0,
'processDefinitionDeploymentId': null, processDefinitionDeploymentId: null,
'formKey': null, formKey: null,
'processInstanceStartUserId': null, processInstanceStartUserId: null,
'initiatorCanCompleteTask': false, initiatorCanCompleteTask: false,
'adhocTaskCanBeReassigned': false, adhocTaskCanBeReassigned: false,
'taskDefinitionKey': null, taskDefinitionKey: null,
'executionId': null, executionId: null,
'memberOfCandidateGroup': false, memberOfCandidateGroup: false,
'memberOfCandidateUsers': false, memberOfCandidateUsers: false,
'managerOfCandidateGroup': false managerOfCandidateGroup: false
}, { }, {
'id': '61054', id: '61054',
'name': null, name: null,
'description': null, description: null,
'category': null, category: null,
'assignee': {'id': 19, 'firstName': 'Mm9ntWGB', 'lastName': 'jfQOzSDL', 'email': 'c4jly@activiti.test.com'}, assignee: {id: 19, firstName: 'Mm9ntWGB', lastName: 'jfQOzSDL', email: 'c4jly@activiti.test.com'},
'created': '2020-02-06T15:26:32.488+0000', created: '2020-02-06T15:26:32.488+0000',
'dueDate': null, dueDate: null,
'endDate': null, endDate: null,
'duration': null, duration: null,
'priority': 50, priority: 50,
'parentTaskId': null, parentTaskId: null,
'parentTaskName': null, parentTaskName: null,
'processInstanceId': '61049', processInstanceId: '61049',
'processInstanceName': null, processInstanceName: null,
'processDefinitionId': 'upload:1:50118', processDefinitionId: 'upload:1:50118',
'processDefinitionName': 'upload', processDefinitionName: 'upload',
'processDefinitionDescription': null, processDefinitionDescription: null,
'processDefinitionKey': 'upload', processDefinitionKey: 'upload',
'processDefinitionCategory': 'http://www.activiti.org/processdef', processDefinitionCategory: 'http://www.activiti.org/processdef',
'processDefinitionVersion': 1, processDefinitionVersion: 1,
'processDefinitionDeploymentId': '50115', processDefinitionDeploymentId: '50115',
'formKey': '8474', formKey: '8474',
'processInstanceStartUserId': null, processInstanceStartUserId: null,
'initiatorCanCompleteTask': false, initiatorCanCompleteTask: false,
'adhocTaskCanBeReassigned': false, adhocTaskCanBeReassigned: false,
'taskDefinitionKey': 'sid-7A12380E-28F8-4B15-9326-C5CFB8DD5BBC', taskDefinitionKey: 'sid-7A12380E-28F8-4B15-9326-C5CFB8DD5BBC',
'executionId': '61049', executionId: '61049',
'memberOfCandidateGroup': false, memberOfCandidateGroup: false,
'memberOfCandidateUsers': false, memberOfCandidateUsers: false,
'managerOfCandidateGroup': false managerOfCandidateGroup: false
}, { }, {
'id': '61048', id: '61048',
'name': 'My Task Name', name: 'My Task Name',
'description': null, description: null,
'category': null, category: null,
'assignee': {'id': 1493, 'firstName': 'fake name', 'lastName': 'fake', 'email': 'abc@test.com'}, assignee: {id: 1493, firstName: 'fake name', lastName: 'fake', email: 'abc@test.com'},
'created': '2020-02-06T15:26:03.012+0000', created: '2020-02-06T15:26:03.012+0000',
'dueDate': null, dueDate: null,
'endDate': null, endDate: null,
'duration': null, duration: null,
'priority': 50, priority: 50,
'parentTaskId': null, parentTaskId: null,
'parentTaskName': null, parentTaskName: null,
'processInstanceId': null, processInstanceId: null,
'processInstanceName': null, processInstanceName: null,
'processDefinitionId': null, processDefinitionId: null,
'processDefinitionName': null, processDefinitionName: null,
'processDefinitionDescription': null, processDefinitionDescription: null,
'processDefinitionKey': null, processDefinitionKey: null,
'processDefinitionCategory': null, processDefinitionCategory: null,
'processDefinitionVersion': 0, processDefinitionVersion: 0,
'processDefinitionDeploymentId': null, processDefinitionDeploymentId: null,
'formKey': null, formKey: null,
'processInstanceStartUserId': null, processInstanceStartUserId: null,
'initiatorCanCompleteTask': false, initiatorCanCompleteTask: false,
'adhocTaskCanBeReassigned': false, adhocTaskCanBeReassigned: false,
'taskDefinitionKey': null, taskDefinitionKey: null,
'executionId': null, executionId: null,
'memberOfCandidateGroup': false, memberOfCandidateGroup: false,
'memberOfCandidateUsers': false, memberOfCandidateUsers: false,
'managerOfCandidateGroup': false managerOfCandidateGroup: false
}, { }, {
'id': '54705', id: '54705',
'name': 'My Task Name', name: 'My Task Name',
'description': '', description: '',
'category': '1349', category: '1349',
'assignee': {'id': 1493, 'firstName': 'fake name', 'lastName': 'fake', 'email': 'abc@test.com'}, assignee: {id: 1493, firstName: 'fake name', lastName: 'fake', email: 'abc@test.com'},
'created': '2020-02-06T13:01:23.403+0000', created: '2020-02-06T13:01:23.403+0000',
'dueDate': null, dueDate: null,
'endDate': null, endDate: null,
'duration': null, duration: null,
'priority': 50, priority: 50,
'parentTaskId': null, parentTaskId: null,
'parentTaskName': null, parentTaskName: null,
'processInstanceId': null, processInstanceId: null,
'processInstanceName': null, processInstanceName: null,
'processDefinitionId': null, processDefinitionId: null,
'processDefinitionName': null, processDefinitionName: null,
'processDefinitionDescription': null, processDefinitionDescription: null,
'processDefinitionKey': null, processDefinitionKey: null,
'processDefinitionCategory': null, processDefinitionCategory: null,
'processDefinitionVersion': 0, processDefinitionVersion: 0,
'processDefinitionDeploymentId': null, processDefinitionDeploymentId: null,
'formKey': null, formKey: null,
'processInstanceStartUserId': null, processInstanceStartUserId: null,
'initiatorCanCompleteTask': false, initiatorCanCompleteTask: false,
'adhocTaskCanBeReassigned': false, adhocTaskCanBeReassigned: false,
'taskDefinitionKey': null, taskDefinitionKey: null,
'executionId': null, executionId: null,
'memberOfCandidateGroup': false, memberOfCandidateGroup: false,
'memberOfCandidateUsers': false, memberOfCandidateUsers: false,
'managerOfCandidateGroup': false managerOfCandidateGroup: false
}, { }, {
'id': '50158', id: '50158',
'name': 'My Task Name', name: 'My Task Name',
'description': '', description: '',
'category': '1349', category: '1349',
'assignee': {'id': 1493, 'firstName': 'fake name', 'lastName': 'fake', 'email': 'abc@test.com'}, assignee: {id: 1493, firstName: 'fake name', lastName: 'fake', email: 'abc@test.com'},
'created': '2020-02-06T09:13:55.532+0000', created: '2020-02-06T09:13:55.532+0000',
'dueDate': '2019-01-09T11:53:00.000+0000', dueDate: '2019-01-09T11:53:00.000+0000',
'endDate': null, endDate: null,
'duration': null, duration: null,
'priority': 0, priority: 0,
'parentTaskId': null, parentTaskId: null,
'parentTaskName': null, parentTaskName: null,
'processInstanceId': null, processInstanceId: null,
'processInstanceName': null, processInstanceName: null,
'processDefinitionId': null, processDefinitionId: null,
'processDefinitionName': null, processDefinitionName: null,
'processDefinitionDescription': null, processDefinitionDescription: null,
'processDefinitionKey': null, processDefinitionKey: null,
'processDefinitionCategory': null, processDefinitionCategory: null,
'processDefinitionVersion': 0, processDefinitionVersion: 0,
'processDefinitionDeploymentId': null, processDefinitionDeploymentId: null,
'formKey': '8484', formKey: '8484',
'processInstanceStartUserId': null, processInstanceStartUserId: null,
'initiatorCanCompleteTask': false, initiatorCanCompleteTask: false,
'adhocTaskCanBeReassigned': false, adhocTaskCanBeReassigned: false,
'taskDefinitionKey': null, taskDefinitionKey: null,
'executionId': null, executionId: null,
'memberOfCandidateGroup': false, memberOfCandidateGroup: false,
'memberOfCandidateUsers': false, memberOfCandidateUsers: false,
'managerOfCandidateGroup': false managerOfCandidateGroup: false
}] }]
}); });

View File

@@ -18,25 +18,25 @@
import { TaskListModel } from '../../task-list/models/task-list.model'; import { TaskListModel } from '../../task-list/models/task-list.model';
import { fakeAppFilter } from './task-filters.mock'; import { fakeAppFilter } from './task-filters.mock';
export let fakeApps = { export const fakeApps = {
size: 2, total: 2, start: 0, size: 2, total: 2, start: 0,
data: [ data: [
{ {
id: 1, defaultAppId: null, name: 'Sales-Fakes-App', description: 'desc-fake1', modelId: 22, id: 1, defaultAppId: null, name: 'Sales-Fakes-App', description: 'desc-fake1', modelId: 22,
theme: 'theme-1-fake', icon: 'glyphicon-asterisk', 'deploymentId': '111', 'tenantId': null theme: 'theme-1-fake', icon: 'glyphicon-asterisk', deploymentId: '111', tenantId: null
}, },
{ {
id: 2, defaultAppId: null, name: 'health-care-Fake', description: 'desc-fake2', modelId: 33, id: 2, defaultAppId: null, name: 'health-care-Fake', description: 'desc-fake2', modelId: 33,
theme: 'theme-2-fake', icon: 'glyphicon-asterisk', 'deploymentId': '444', 'tenantId': null theme: 'theme-2-fake', icon: 'glyphicon-asterisk', deploymentId: '444', tenantId: null
} }
] ]
}; };
export let fakeUser1 = { id: 1, email: 'fake-email@dom.com', firstName: 'firstName', lastName: 'lastName' }; export const fakeUser1 = { id: 1, email: 'fake-email@dom.com', firstName: 'firstName', lastName: 'lastName' };
export let fakeUser2 = { id: 1001, email: 'some-one@somegroup.com', firstName: 'some', lastName: 'one' }; export const fakeUser2 = { id: 1001, email: 'some-one@somegroup.com', firstName: 'some', lastName: 'one' };
export let fakeTaskList = new TaskListModel({ export const fakeTaskList = new TaskListModel({
size: 1, total: 1, start: 0, size: 1, total: 1, start: 0,
data: [ data: [
{ {
@@ -47,7 +47,7 @@ export let fakeTaskList = new TaskListModel({
] ]
}); });
export let fakeTaskListDifferentProcessDefinitionKey = { export const fakeTaskListDifferentProcessDefinitionKey = {
size: 2, total: 1, start: 0, size: 2, total: 1, start: 0,
data: [ data: [
{ {
@@ -65,7 +65,7 @@ export let fakeTaskListDifferentProcessDefinitionKey = {
] ]
}; };
export let secondFakeTaskList = { export const secondFakeTaskList = {
size: 1, total: 1, start: 0, size: 1, total: 1, start: 0,
data: [ data: [
{ {
@@ -76,13 +76,13 @@ export let secondFakeTaskList = {
] ]
}; };
export let mockErrorTaskList = { export const mockErrorTaskList = {
error: 'wrong request' error: 'wrong request'
}; };
export let fakeTaskDetails = { id: '999', name: 'fake-task-name', formKey: '99', assignee: fakeUser1 }; export const fakeTaskDetails = { id: '999', name: 'fake-task-name', formKey: '99', assignee: fakeUser1 };
export let fakeTasksComment = { export const fakeTasksComment = {
size: 2, total: 2, start: 0, size: 2, total: 2, start: 0,
data: [ data: [
{ {
@@ -94,7 +94,7 @@ export let fakeTasksComment = {
] ]
}; };
export let fakeTasksChecklist = { export const fakeTasksChecklist = {
size: 1, total: 1, start: 0, size: 1, total: 1, start: 0,
data: [ data: [
{ {
@@ -110,11 +110,11 @@ export let fakeTasksChecklist = {
] ]
}; };
export let fakeAppPromise = new Promise(function (resolve) { export const fakeAppPromise = new Promise((resolve) => {
resolve(fakeAppFilter); resolve(fakeAppFilter);
}); });
export let fakeFormList = { export const fakeFormList = {
size: 2, size: 2,
total: 2, total: 2,
start: 0, start: 0,
@@ -157,7 +157,7 @@ export let fakeFormList = {
}] }]
}; };
export let fakeTaskOpen1 = { export const fakeTaskOpen1 = {
id: '1', name: 'FakeOpenTask1', description: null, category: null, id: '1', name: 'FakeOpenTask1', description: null, category: null,
assignee: fakeUser1, assignee: fakeUser1,
created: '2017-07-15T11:19:17.440+0000', created: '2017-07-15T11:19:17.440+0000',
@@ -165,7 +165,7 @@ export let fakeTaskOpen1 = {
endDate: null endDate: null
}; };
export let fakeTaskOpen2 = { export const fakeTaskOpen2 = {
id: '1', name: 'FakeOpenTask2', description: null, category: null, id: '1', name: 'FakeOpenTask2', description: null, category: null,
assignee: { id: 1, email: 'fake-open-email@dom.com', firstName: 'firstName', lastName: 'lastName' }, assignee: { id: 1, email: 'fake-open-email@dom.com', firstName: 'firstName', lastName: 'lastName' },
created: '2017-07-15T11:19:17.440+0000', created: '2017-07-15T11:19:17.440+0000',
@@ -173,7 +173,7 @@ export let fakeTaskOpen2 = {
endDate: null endDate: null
}; };
export let fakeTaskCompleted1 = { export const fakeTaskCompleted1 = {
id: '1', name: 'FakeCompletedTaskName1', description: null, category: null, id: '1', name: 'FakeCompletedTaskName1', description: null, category: null,
assignee: { id: 1, email: 'fake-completed-email@dom.com', firstName: 'firstName', lastName: 'lastName' }, assignee: { id: 1, email: 'fake-completed-email@dom.com', firstName: 'firstName', lastName: 'lastName' },
created: '2016-07-15T11:19:17.440+0000', created: '2016-07-15T11:19:17.440+0000',
@@ -181,7 +181,7 @@ export let fakeTaskCompleted1 = {
endDate: '2016-11-03T15:25:42.749+0000' endDate: '2016-11-03T15:25:42.749+0000'
}; };
export let fakeTaskCompleted2 = { export const fakeTaskCompleted2 = {
id: '1', name: 'FakeCompletedTaskName2', description: null, category: null, id: '1', name: 'FakeCompletedTaskName2', description: null, category: null,
assignee: fakeUser1, assignee: fakeUser1,
created: null, created: null,
@@ -189,14 +189,14 @@ export let fakeTaskCompleted2 = {
endDate: '2016-11-03T15:25:42.749+0000' endDate: '2016-11-03T15:25:42.749+0000'
}; };
export let fakeOpenTaskList = new TaskListModel({ export const fakeOpenTaskList = new TaskListModel({
size: 2, size: 2,
total: 2, total: 2,
start: 0, start: 0,
data: [fakeTaskOpen1, fakeTaskOpen2] data: [fakeTaskOpen1, fakeTaskOpen2]
}); });
export let fakeCompletedTaskList = new TaskListModel({ export const fakeCompletedTaskList = new TaskListModel({
size: 2, size: 2,
total: 2, total: 2,
start: 0, start: 0,

View File

@@ -27,7 +27,7 @@ import { getDisplayUser } from '../../helpers/get-display-user';
selector: 'adf-people-search-field', selector: 'adf-people-search-field',
templateUrl: './people-search-field.component.html', templateUrl: './people-search-field.component.html',
styleUrls: ['./people-search-field.component.scss'], styleUrls: ['./people-search-field.component.scss'],
host: { 'class': 'adf-people-search-field' }, host: { class: 'adf-people-search-field' },
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })

View File

@@ -102,7 +102,7 @@ describe('PeopleSearchComponent', () => {
fixture.whenStable() fixture.whenStable()
.then(() => { .then(() => {
peopleSearchComponent.onRowClick(fakeUser); peopleSearchComponent.onRowClick(fakeUser);
const addUserButton = <HTMLElement> element.querySelector('#add-people'); const addUserButton = element.querySelector<HTMLElement>('#add-people');
addUserButton.click(); addUserButton.click();
}); });
}); });
@@ -118,7 +118,7 @@ describe('PeopleSearchComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
peopleSearchComponent.onRowClick(fakeUser); peopleSearchComponent.onRowClick(fakeUser);
const addUserButton = <HTMLElement> element.querySelector('#add-people'); const addUserButton = element.querySelector<HTMLElement>('#add-people');
addUserButton.click(); addUserButton.click();
fixture.detectChanges(); fixture.detectChanges();

View File

@@ -26,7 +26,7 @@ import { map } from 'rxjs/operators';
templateUrl: './people-search.component.html', templateUrl: './people-search.component.html',
styleUrls: ['./people-search.component.scss'], styleUrls: ['./people-search.component.scss'],
host: { host: {
'class': 'adf-people-search' class: 'adf-people-search'
}, },
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
@@ -53,23 +53,14 @@ export class PeopleSearchComponent implements OnInit {
selectedUser: UserProcessModel = {}; selectedUser: UserProcessModel = {};
performSearch: PerformSearchCallback; performSearch: PerformSearchCallback;
constructor() {}
ngOnInit() { ngOnInit() {
this.filteredResults$ = this.results this.filteredResults$ = this.results
.pipe( .pipe(
map((users) => { map((users) => users.filter((user) => user.id !== this.selectedUser.id))
return users.filter((user) => user.id !== this.selectedUser.id);
})
); );
this.performSearch = this.performSearchCallback.bind(this); this.performSearch = this.performSearchCallback.bind(this);
} }
private performSearchCallback(event: any): Observable<UserProcessModel[]> {
this.searchPeople.emit(event);
return this.filteredResults$;
}
onRowClick(user: UserProcessModel) { onRowClick(user: UserProcessModel) {
this.selectedUser = user; this.selectedUser = user;
} }
@@ -89,4 +80,9 @@ export class PeopleSearchComponent implements OnInit {
} }
this.success.emit(this.selectedUser); this.success.emit(this.selectedUser);
} }
private performSearchCallback(event: any): Observable<UserProcessModel[]> {
this.searchPeople.emit(event);
return this.filteredResults$;
}
} }

View File

@@ -29,7 +29,7 @@ const DEFAULT_ASSIGNEE_PLACEHOLDER = 'ADF_TASK_LIST.PEOPLE.ASSIGNEE';
selector: 'adf-people-selector', selector: 'adf-people-selector',
templateUrl: './people-selector.component.html', templateUrl: './people-selector.component.html',
styleUrls: ['./people-selector.component.scss'], styleUrls: ['./people-selector.component.scss'],
host: { 'class': 'adf-people-selector' }, host: { class: 'adf-people-selector' },
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
@@ -66,11 +66,6 @@ export class PeopleSelectorComponent {
); );
} }
private onSearchUserError(): Observable<UserProcessModel[]> {
this.logService.error('getWorkflowUsers threw error');
return of([]);
}
userSelected(user: UserProcessModel): void { userSelected(user: UserProcessModel): void {
this.updateUserSelection(user); this.updateUserSelection(user);
} }
@@ -79,6 +74,11 @@ export class PeopleSelectorComponent {
this.updateUserSelection(undefined); this.updateUserSelection(undefined);
} }
private onSearchUserError(): Observable<UserProcessModel[]> {
this.logService.error('getWorkflowUsers threw error');
return of([]);
}
private updateUserSelection(user: UserProcessModel): void { private updateUserSelection(user: UserProcessModel): void {
this.selectedUser = user; this.selectedUser = user;
this.peopleIdChange.emit(user && user.id || undefined); this.peopleIdChange.emit(user && user.id || undefined);

View File

@@ -46,9 +46,9 @@ export class PeopleComponent {
peopleSearch: PeopleSearchComponent; peopleSearch: PeopleSearchComponent;
showAssignment: boolean = false; showAssignment: boolean = false;
peopleSearch$: Observable<UserProcessModel[]>;
private peopleSearchObserver: Observer<UserProcessModel[]>; private peopleSearchObserver: Observer<UserProcessModel[]>;
peopleSearch$: Observable<UserProcessModel[]>;
constructor(private logService: LogService, public peopleProcessService: PeopleProcessService) { constructor(private logService: LogService, public peopleProcessService: PeopleProcessService) {
this.peopleSearch$ = new Observable<UserProcessModel[]>((observer) => this.peopleSearchObserver = observer) this.peopleSearch$ = new Observable<UserProcessModel[]>((observer) => this.peopleSearchObserver = observer)

View File

@@ -15,8 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
export function getDisplayUser(firstName: string, lastName: string, delimiter: string = '-'): string { export const getDisplayUser = (firstName: string, lastName: string, delimiter: string = '-'): string => {
firstName = (firstName !== null ? firstName : ''); firstName = (firstName !== null ? firstName : '');
lastName = (lastName !== null ? lastName : ''); lastName = (lastName !== null ? lastName : '');
return firstName + delimiter + lastName; return firstName + delimiter + lastName;
} };

View File

@@ -20,28 +20,28 @@ import moment from 'moment-es6';
import { LocalizedDatePipe } from '@alfresco/adf-core'; import { LocalizedDatePipe } from '@alfresco/adf-core';
import { ProcessInstance } from '../process-list'; import { ProcessInstance } from '../process-list';
const DATE_TIME_IDENTIFIER_REG_EXP = new RegExp('%{datetime}', 'i');
const PROCESS_DEFINITION_IDENTIFIER_REG_EXP = new RegExp('%{processdefinition}', 'i');
@Pipe({ name: 'processName' }) @Pipe({ name: 'processName' })
export class ProcessNamePipe implements PipeTransform { export class ProcessNamePipe implements PipeTransform {
static DATE_TIME_IDENTIFIER_REG_EXP = new RegExp('%{datetime}', 'i');
static PROCESS_DEFINITION_IDENTIFIER_REG_EXP = new RegExp('%{processdefinition}', 'i');
constructor(private localizedDatePipe: LocalizedDatePipe) { constructor(private localizedDatePipe: LocalizedDatePipe) {
} }
transform(processNameFormat: string, processInstance?: ProcessInstance): string { transform(processNameFormat: string, processInstance?: ProcessInstance): string {
let processName = processNameFormat; let processName = processNameFormat;
if (processName.match(ProcessNamePipe.DATE_TIME_IDENTIFIER_REG_EXP)) { if (processName.match(DATE_TIME_IDENTIFIER_REG_EXP)) {
const presentDateTime = moment.now(); const presentDateTime = moment.now();
processName = processName.replace( processName = processName.replace(
ProcessNamePipe.DATE_TIME_IDENTIFIER_REG_EXP, DATE_TIME_IDENTIFIER_REG_EXP,
this.localizedDatePipe.transform(presentDateTime, 'medium') this.localizedDatePipe.transform(presentDateTime, 'medium')
); );
} }
if (processName.match(ProcessNamePipe.PROCESS_DEFINITION_IDENTIFIER_REG_EXP)) { if (processName.match(PROCESS_DEFINITION_IDENTIFIER_REG_EXP)) {
const selectedProcessDefinitionName = processInstance ? processInstance.processDefinitionName : ''; const selectedProcessDefinitionName = processInstance ? processInstance.processDefinitionName : '';
processName = processName.replace( processName = processName.replace(
ProcessNamePipe.PROCESS_DEFINITION_IDENTIFIER_REG_EXP, PROCESS_DEFINITION_IDENTIFIER_REG_EXP,
selectedProcessDefinitionName selectedProcessDefinitionName
); );
} }

View File

@@ -51,7 +51,7 @@ describe('ProcessCommentsComponent', () => {
it('should load comments when processInstanceId specified', () => { it('should load comments when processInstanceId specified', () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
fixture.detectChanges(); fixture.detectChanges();
expect(getCommentsSpy).toHaveBeenCalled(); expect(getCommentsSpy).toHaveBeenCalled();
}); });
@@ -61,7 +61,7 @@ describe('ProcessCommentsComponent', () => {
getCommentsSpy.and.returnValue(throwError({})); getCommentsSpy.and.returnValue(throwError({}));
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
fixture.detectChanges(); fixture.detectChanges();
expect(emitSpy).toHaveBeenCalled(); expect(emitSpy).toHaveBeenCalled();
@@ -74,7 +74,7 @@ describe('ProcessCommentsComponent', () => {
it('should display comments when the process has comments', async () => { it('should display comments when the process has comments', async () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -85,7 +85,7 @@ describe('ProcessCommentsComponent', () => {
it('should display comments count when the process has comments', async () => { it('should display comments count when the process has comments', async () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -96,7 +96,7 @@ describe('ProcessCommentsComponent', () => {
it('should not display comments when the process has no comments', async () => { it('should not display comments when the process has no comments', async () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
getCommentsSpy.and.returnValue(of([])); getCommentsSpy.and.returnValue(of([]));
@@ -108,7 +108,7 @@ describe('ProcessCommentsComponent', () => {
it('should not display comments input by default', async () => { it('should not display comments input by default', async () => {
const change = new SimpleChange(null, '123', true); const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();

View File

@@ -42,16 +42,13 @@ export class ProcessCommentsComponent implements OnChanges, OnDestroy {
error: EventEmitter<any> = new EventEmitter<any>(); error: EventEmitter<any> = new EventEmitter<any>();
comments: CommentModel [] = []; comments: CommentModel [] = [];
comment$: Observable<CommentModel>;
message: string;
beingAdded: boolean = false;
private commentObserver: Observer<CommentModel>; private commentObserver: Observer<CommentModel>;
comment$: Observable<CommentModel>;
private onDestroy$ = new Subject<boolean>(); private onDestroy$ = new Subject<boolean>();
message: string;
beingAdded: boolean = false;
constructor(private commentProcessService: CommentProcessService) { constructor(private commentProcessService: CommentProcessService) {
this.comment$ = new Observable<CommentModel>(observer => this.commentObserver = observer).pipe(share()); this.comment$ = new Observable<CommentModel>(observer => this.commentObserver = observer).pipe(share());
this.comment$ this.comment$
@@ -75,31 +72,6 @@ export class ProcessCommentsComponent implements OnChanges, OnDestroy {
} }
} }
private getProcessInstanceComments(processInstanceId: string): void {
this.resetComments();
if (processInstanceId) {
this.commentProcessService.getProcessInstanceComments(processInstanceId).subscribe(
(res: CommentModel[]) => {
res = res.sort((comment1: CommentModel, comment2: CommentModel) => {
const date1 = new Date(comment1.created);
const date2 = new Date(comment2.created);
return date1 > date2 ? -1 : date1 < date2 ? 1 : 0;
});
res.forEach((comment) => {
this.commentObserver.next(comment);
});
},
(err) => {
this.error.emit(err);
}
);
}
}
private resetComments(): void {
this.comments = [];
}
add(): void { add(): void {
if (this.message && this.message.trim() && !this.beingAdded) { if (this.message && this.message.trim() && !this.beingAdded) {
this.beingAdded = true; this.beingAdded = true;
@@ -131,4 +103,28 @@ export class ProcessCommentsComponent implements OnChanges, OnDestroy {
this.error.emit(error); this.error.emit(error);
} }
private getProcessInstanceComments(processInstanceId: string): void {
this.resetComments();
if (processInstanceId) {
this.commentProcessService.getProcessInstanceComments(processInstanceId).subscribe(
(res: CommentModel[]) => {
res = res.sort((comment1: CommentModel, comment2: CommentModel) => {
const date1 = new Date(comment1.created);
const date2 = new Date(comment2.created);
return date1 > date2 ? -1 : date1 < date2 ? 1 : 0;
});
res.forEach((comment) => {
this.commentObserver.next(comment);
});
},
(err) => {
this.error.emit(err);
}
);
}
}
private resetComments(): void {
this.comments = [];
}
} }

View File

@@ -51,7 +51,7 @@ describe('ProcessAuditDirective', () => {
let component: BasicButtonComponent; let component: BasicButtonComponent;
let service: ProcessService; let service: ProcessService;
function createFakePdfBlob(): Blob { const createFakePdfBlob = (): Blob => {
const pdfData = atob( const pdfData = atob(
'JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwog' + 'JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwog' +
'IC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAv' + 'IC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAv' +
@@ -67,7 +67,8 @@ describe('ProcessAuditDirective', () => {
'MDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9v' + 'MDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9v' +
'dCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G'); 'dCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G');
return new Blob([pdfData], {type: 'application/pdf'}); return new Blob([pdfData], {type: 'application/pdf'});
} };
const blob = createFakePdfBlob(); const blob = createFakePdfBlob();
setupTestBed({ setupTestBed({

View File

@@ -28,7 +28,7 @@ const PDF_FORMAT: string = 'pdf';
// eslint-disable-next-line @angular-eslint/directive-selector // eslint-disable-next-line @angular-eslint/directive-selector
selector: 'button[adf-process-audit]', selector: 'button[adf-process-audit]',
host: { host: {
'role': 'button', role: 'button',
'(click)': 'onClickAudit()' '(click)': 'onClickAudit()'
} }
}) })

View File

@@ -70,7 +70,7 @@ describe('ProcessFiltersComponent', () => {
spyOn(filterList, 'getFiltersByAppId').and.callThrough(); spyOn(filterList, 'getFiltersByAppId').and.callThrough();
filterList.ngOnChanges({ 'appId': change }); filterList.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -90,7 +90,7 @@ describe('ProcessFiltersComponent', () => {
done(); done();
}); });
filterList.ngOnChanges({ 'appId': change }); filterList.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -107,7 +107,7 @@ describe('ProcessFiltersComponent', () => {
done(); done();
}); });
filterList.ngOnChanges({ 'appId': change }); filterList.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
}); });
@@ -135,7 +135,7 @@ describe('ProcessFiltersComponent', () => {
filterList.currentFilter = nonExistingFilterParam; filterList.currentFilter = nonExistingFilterParam;
filterList.filterParam = new FilterProcessRepresentationModel(nonExistingFilterParam); filterList.filterParam = new FilterProcessRepresentationModel(nonExistingFilterParam);
filterList.ngOnChanges({ 'appId': change }); filterList.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -147,7 +147,7 @@ describe('ProcessFiltersComponent', () => {
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters)); spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
const change = new SimpleChange(null, 'test', true); const change = new SimpleChange(null, 'test', true);
filterList.ngOnChanges({ 'appName': change }); filterList.ngOnChanges({ appName: change });
filterList.success.subscribe((res) => { filterList.success.subscribe((res) => {
const deployApp: any = appsProcessService.getDeployedApplicationsByName; const deployApp: any = appsProcessService.getDeployedApplicationsByName;
@@ -167,7 +167,7 @@ describe('ProcessFiltersComponent', () => {
const appId = '1'; const appId = '1';
const change = new SimpleChange(null, appId, true); const change = new SimpleChange(null, appId, true);
filterList.ngOnChanges({ 'appId': change }); filterList.ngOnChanges({ appId: change });
filterList.error.subscribe((err) => { filterList.error.subscribe((err) => {
expect(err).toBeDefined(); expect(err).toBeDefined();
@@ -185,7 +185,7 @@ describe('ProcessFiltersComponent', () => {
const appId = 'fake-app'; const appId = 'fake-app';
const change = new SimpleChange(null, appId, true); const change = new SimpleChange(null, appId, true);
filterList.ngOnChanges({ 'appName': change }); filterList.ngOnChanges({ appName: change });
filterList.error.subscribe((err) => { filterList.error.subscribe((err) => {
expect(err).toBeDefined(); expect(err).toBeDefined();
@@ -217,7 +217,7 @@ describe('ProcessFiltersComponent', () => {
const appId = '1'; const appId = '1';
const change = new SimpleChange(null, appId, true); const change = new SimpleChange(null, appId, true);
filterList.ngOnChanges({ 'appId': change }); filterList.ngOnChanges({ appId: change });
expect(filterList.getFiltersByAppId).toHaveBeenCalledWith(appId); expect(filterList.getFiltersByAppId).toHaveBeenCalledWith(appId);
}); });
@@ -227,7 +227,7 @@ describe('ProcessFiltersComponent', () => {
const appId = null; const appId = null;
const change = new SimpleChange(null, appId, true); const change = new SimpleChange(null, appId, true);
filterList.ngOnChanges({ 'appId': change }); filterList.ngOnChanges({ appId: change });
expect(filterList.getFiltersByAppId).toHaveBeenCalledWith(appId); expect(filterList.getFiltersByAppId).toHaveBeenCalledWith(appId);
}); });
@@ -237,7 +237,7 @@ describe('ProcessFiltersComponent', () => {
const appName = 'fake-app-name'; const appName = 'fake-app-name';
const change = new SimpleChange(null, appName, true); const change = new SimpleChange(null, appName, true);
filterList.ngOnChanges({ 'appName': change }); filterList.ngOnChanges({ appName: change });
expect(filterList.getFiltersByAppName).toHaveBeenCalledWith(appName); expect(filterList.getFiltersByAppName).toHaveBeenCalledWith(appName);
}); });
@@ -260,7 +260,7 @@ describe('ProcessFiltersComponent', () => {
const appId = 1; const appId = 1;
const change = new SimpleChange(null, appId, true); const change = new SimpleChange(null, appId, true);
filterList.ngOnChanges({ 'appId': change }); filterList.ngOnChanges({ appId: change });
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
fixture.detectChanges(); fixture.detectChanges();
@@ -280,7 +280,7 @@ describe('ProcessFiltersComponent', () => {
const appId = 1; const appId = 1;
const change = new SimpleChange(null, appId, true); const change = new SimpleChange(null, appId, true);
filterList.ngOnChanges({ 'appId': change }); filterList.ngOnChanges({ appId: change });
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
fixture.detectChanges(); fixture.detectChanges();
@@ -296,7 +296,7 @@ describe('ProcessFiltersComponent', () => {
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters)); spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
filterList.showIcon = true; filterList.showIcon = true;
const change = new SimpleChange(undefined, 1, true); const change = new SimpleChange(undefined, 1, true);
filterList.ngOnChanges({ 'appId': change }); filterList.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
fixture.detectChanges(); fixture.detectChanges();
@@ -314,7 +314,7 @@ describe('ProcessFiltersComponent', () => {
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters)); spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
filterList.showIcon = false; filterList.showIcon = false;
const change = new SimpleChange(undefined, 1, true); const change = new SimpleChange(undefined, 1, true);
filterList.ngOnChanges({ 'appId': change }); filterList.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
fixture.detectChanges(); fixture.detectChanges();

View File

@@ -98,6 +98,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
/** /**
* Return the filter list filtered by appId * Return the filter list filtered by appId
*
* @param appId - optional * @param appId - optional
*/ */
getFiltersByAppId(appId?: number) { getFiltersByAppId(appId?: number) {
@@ -130,6 +131,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
/** /**
* Return the filter list filtered by appName * Return the filter list filtered by appName
*
* @param appName * @param appName
*/ */
getFiltersByAppName(appName: string) { getFiltersByAppName(appName: string) {
@@ -145,6 +147,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
/** /**
* Pass the selected filter as next * Pass the selected filter as next
*
* @param filter * @param filter
*/ */
selectFilter(filter: ProcessInstanceFilterRepresentation) { selectFilter(filter: ProcessInstanceFilterRepresentation) {
@@ -174,6 +177,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
/** /**
* Select the Running filter * Select the Running filter
*
* @deprecated in 3.9.0, Use the filterParam Input() with a running filter instance instead * @deprecated in 3.9.0, Use the filterParam Input() with a running filter instance instead
*/ */
selectRunningFilter() { selectRunningFilter() {
@@ -204,6 +208,13 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
return this.filters === undefined || (this.filters && this.filters.length === 0); return this.filters === undefined || (this.filters && this.filters.length === 0);
} }
/**
* Return current filter icon
*/
getFilterIcon(icon: string): string {
return this.iconsMDL.mapGlyphiconToMaterialDesignIcons(icon);
}
/** /**
* Reset the filters properties * Reset the filters properties
*/ */
@@ -211,11 +222,4 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
this.filters = []; this.filters = [];
this.currentFilter = undefined; this.currentFilter = undefined;
} }
/**
* Return current filter icon
*/
getFilterIcon(icon: string): string {
return this.iconsMDL.mapGlyphiconToMaterialDesignIcons(icon);
}
} }

View File

@@ -77,7 +77,7 @@ describe('ProcessInstanceDetailsComponent', () => {
it('should display a header when the processInstanceId is provided', async () => { it('should display a header when the processInstanceId is provided', async () => {
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges({ 'processInstanceId': new SimpleChange(null, '123', true) }); component.ngOnChanges({ processInstanceId: new SimpleChange(null, '123', true) });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -91,7 +91,7 @@ describe('ProcessInstanceDetailsComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
getProcessSpy.and.returnValue(of(exampleProcessNoName)); getProcessSpy.and.returnValue(of(exampleProcessNoName));
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges({ 'processInstanceId': new SimpleChange(null, '123', true) }); component.ngOnChanges({ processInstanceId: new SimpleChange(null, '123', true) });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -105,7 +105,7 @@ describe('ProcessInstanceDetailsComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
getProcessSpy.and.returnValue(of(mockRunningProcess)); getProcessSpy.and.returnValue(of(mockRunningProcess));
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges({ 'processInstanceId': new SimpleChange(null, '123', true) }); component.ngOnChanges({ processInstanceId: new SimpleChange(null, '123', true) });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -119,7 +119,7 @@ describe('ProcessInstanceDetailsComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
getProcessSpy.and.returnValue(of(processEnded)); getProcessSpy.and.returnValue(of(processEnded));
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges({ 'processInstanceId': new SimpleChange(null, '123', true) }); component.ngOnChanges({ processInstanceId: new SimpleChange(null, '123', true) });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -142,7 +142,7 @@ describe('ProcessInstanceDetailsComponent', () => {
it('should fetch new process details when processInstanceId changed', async () => { it('should fetch new process details when processInstanceId changed', async () => {
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -162,7 +162,7 @@ describe('ProcessInstanceDetailsComponent', () => {
it('should NOT fetch new process details when processInstanceId changed to null', async () => { it('should NOT fetch new process details when processInstanceId changed to null', async () => {
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges({ 'processInstanceId': nullChange }); component.ngOnChanges({ processInstanceId: nullChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -171,7 +171,7 @@ describe('ProcessInstanceDetailsComponent', () => {
}); });
it('should set a placeholder message when processInstanceId changed to null', async () => { it('should set a placeholder message when processInstanceId changed to null', async () => {
component.ngOnChanges({ 'processInstanceId': nullChange }); component.ngOnChanges({ processInstanceId: nullChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -180,7 +180,7 @@ describe('ProcessInstanceDetailsComponent', () => {
}); });
it('should display cancel button if process is running', async () => { it('should display cancel button if process is running', async () => {
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ processInstanceId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();

View File

@@ -62,14 +62,15 @@ export class ProcessInstanceDetailsComponent implements OnChanges {
@Output() @Output()
taskClick = new EventEmitter<TaskDetailsEvent>(); taskClick = new EventEmitter<TaskDetailsEvent>();
processInstanceDetails: ProcessInstance;
/** Emitted when the "show diagram" button is clicked. */ /** Emitted when the "show diagram" button is clicked. */
@Output() @Output()
showProcessDiagram = new EventEmitter<any>(); showProcessDiagram = new EventEmitter<any>();
processInstanceDetails: ProcessInstance;
/** /**
* Constructor * Constructor
*
* @param translate Translation service * @param translate Translation service
* @param activitiProcess Process service * @param activitiProcess Process service
*/ */

View File

@@ -170,8 +170,8 @@ describe('ProcessInstanceHeaderComponent', () => {
it('should show only the properties from the configuration file', () => { it('should show only the properties from the configuration file', () => {
appConfigService.config['adf-process-instance-header'] = { appConfigService.config['adf-process-instance-header'] = {
'presets': { presets: {
'properties': ['status', 'ended'] properties: ['status', 'ended']
} }
}; };
component.ngOnChanges(); component.ngOnChanges();

View File

@@ -52,6 +52,27 @@ export class ProcessInstanceHeaderComponent implements OnChanges {
} }
} }
getProcessStatus(): string {
if (this.processInstance) {
return this.isRunning() ? 'Running' : 'Completed';
}
return 'Unknown';
}
getStartedByFullName(): string {
let fullName = '';
if (this.processInstance && this.processInstance.startedBy) {
fullName += this.processInstance.startedBy.firstName || '';
fullName += fullName ? ' ' : '';
fullName += this.processInstance.startedBy.lastName || '';
}
return fullName;
}
isRunning(): boolean {
return this.processInstance && !this.processInstance.ended;
}
private initDefaultProperties(): any[] { private initDefaultProperties(): any[] {
return [ return [
new CardViewTextItemModel( new CardViewTextItemModel(
@@ -115,25 +136,4 @@ export class ProcessInstanceHeaderComponent implements OnChanges {
private isValidSelection(filteredProperties: string[], cardItem: CardViewBaseItemModel): boolean { private isValidSelection(filteredProperties: string[], cardItem: CardViewBaseItemModel): boolean {
return filteredProperties ? filteredProperties.indexOf(cardItem.key) >= 0 : true; return filteredProperties ? filteredProperties.indexOf(cardItem.key) >= 0 : true;
} }
getProcessStatus(): string {
if (this.processInstance) {
return this.isRunning() ? 'Running' : 'Completed';
}
return 'Unknown';
}
getStartedByFullName(): string {
let fullName = '';
if (this.processInstance && this.processInstance.startedBy) {
fullName += this.processInstance.startedBy.firstName || '';
fullName += fullName ? ' ' : '';
fullName += this.processInstance.startedBy.lastName || '';
}
return fullName;
}
isRunning(): boolean {
return this.processInstance && !this.processInstance.ended;
}
} }

View File

@@ -95,12 +95,12 @@ describe('ProcessInstanceTasksComponent', () => {
it('should display active tasks', async () => { it('should display active tasks', async () => {
const change = new SimpleChange(null, exampleProcessInstance, true); const change = new SimpleChange(null, exampleProcessInstance, true);
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges({ 'processInstanceDetails': change }); component.ngOnChanges({ processInstanceDetails: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'processInstanceDetails': change }); component.ngOnChanges({ processInstanceDetails: change });
const listEl = fixture.debugElement.query(By.css('[data-automation-id="active-tasks"]')); const listEl = fixture.debugElement.query(By.css('[data-automation-id="active-tasks"]'));
expect(listEl).not.toBeNull(); expect(listEl).not.toBeNull();
expect(listEl.queryAll(By.css('mat-list-item')).length).toBe(1); expect(listEl.queryAll(By.css('mat-list-item')).length).toBe(1);
@@ -109,7 +109,7 @@ describe('ProcessInstanceTasksComponent', () => {
it('should display completed tasks', async () => { it('should display completed tasks', async () => {
const change = new SimpleChange(null, exampleProcessInstance, true); const change = new SimpleChange(null, exampleProcessInstance, true);
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges({ 'processInstanceDetails': change }); component.ngOnChanges({ processInstanceDetails: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();

View File

@@ -44,19 +44,7 @@ export class ProcessInstanceTasksComponent implements OnInit, OnChanges, OnDestr
/** Emitted when an error occurs. */ /** Emitted when an error occurs. */
@Output() @Output()
error: EventEmitter<any> = new EventEmitter<any>(); error = new EventEmitter<any>();
activeTasks: TaskDetailsModel[] = [];
completedTasks: TaskDetailsModel[] = [];
private taskObserver: Observer<TaskDetailsModel>;
private completedTaskObserver: Observer<TaskDetailsModel>;
private onDestroy$ = new Subject<boolean>();
task$: Observable<TaskDetailsModel>;
completedTask$: Observable<TaskDetailsModel>;
message: string;
processId: string;
@ViewChild('startDialog') @ViewChild('startDialog')
startDialog: any; startDialog: any;
@@ -66,7 +54,18 @@ export class ProcessInstanceTasksComponent implements OnInit, OnChanges, OnDestr
/** Emitted when a task is clicked. */ /** Emitted when a task is clicked. */
@Output() @Output()
taskClick: EventEmitter<TaskDetailsEvent> = new EventEmitter<TaskDetailsEvent>(); taskClick = new EventEmitter<TaskDetailsEvent>();
activeTasks: TaskDetailsModel[] = [];
completedTasks: TaskDetailsModel[] = [];
task$: Observable<TaskDetailsModel>;
completedTask$: Observable<TaskDetailsModel>;
message: string;
processId: string;
private taskObserver: Observer<TaskDetailsModel>;
private completedTaskObserver: Observer<TaskDetailsModel>;
private onDestroy$ = new Subject<boolean>();
constructor(private activitiProcess: ProcessService, constructor(private activitiProcess: ProcessService,
private logService: LogService, private logService: LogService,

View File

@@ -65,7 +65,7 @@ describe('ProcessInstanceListComponent', () => {
getProcessInstancesSpy = spyOn(service, 'getProcessInstances').and.returnValue(of(fakeProcessInstance)); getProcessInstancesSpy = spyOn(service, 'getProcessInstances').and.returnValue(of(fakeProcessInstance));
appConfig.config['adf-process-list'] = { appConfig.config['adf-process-list'] = {
'presets': fakeProcessColumnSchema presets: fakeProcessColumnSchema
}; };
}); });
@@ -283,12 +283,12 @@ describe('ProcessInstanceListComponent', () => {
it('should show custom resolved value in the column', async () => { it('should show custom resolved value in the column', async () => {
appConfig.config['adf-process-list'] = { appConfig.config['adf-process-list'] = {
'presets': { presets: {
'fakeProcessCustomSchema': [ fakeProcessCustomSchema: [
{ {
'key': 'variables', key: 'variables',
'type': 'text', type: 'text',
'title': 'Variables' title: 'Variables'
} }
] ]
} }
@@ -335,7 +335,7 @@ describe('ProcessInstanceListComponent', () => {
done(); done();
}); });
component.ngOnChanges({'appId': change}); component.ngOnChanges({appId: change});
}); });
it('should reload the list when the state parameter changes', (done) => { it('should reload the list when the state parameter changes', (done) => {
@@ -351,7 +351,7 @@ describe('ProcessInstanceListComponent', () => {
done(); done();
}); });
component.ngOnChanges({'state': change}); component.ngOnChanges({state: change});
}); });
it('should reload the list when the sort parameter changes', (done) => { it('should reload the list when the sort parameter changes', (done) => {
@@ -367,7 +367,7 @@ describe('ProcessInstanceListComponent', () => {
done(); done();
}); });
component.ngOnChanges({'sort': change}); component.ngOnChanges({sort: change});
}); });
it('should reload the process list when the processDefinitionId parameter changes', (done) => { it('should reload the process list when the processDefinitionId parameter changes', (done) => {
@@ -383,7 +383,7 @@ describe('ProcessInstanceListComponent', () => {
done(); done();
}); });
component.ngOnChanges({'processDefinitionId': change}); component.ngOnChanges({processDefinitionId: change});
}); });
it('should reload the process list when the processDefinitionId parameter changes to null', (done) => { it('should reload the process list when the processDefinitionId parameter changes to null', (done) => {
@@ -399,7 +399,7 @@ describe('ProcessInstanceListComponent', () => {
done(); done();
}); });
component.ngOnChanges({'processDefinitionId': change}); component.ngOnChanges({processDefinitionId: change});
}); });
it('should reload the process list when the processInstanceId parameter changes', (done) => { it('should reload the process list when the processInstanceId parameter changes', (done) => {
@@ -415,7 +415,7 @@ describe('ProcessInstanceListComponent', () => {
done(); done();
}); });
component.ngOnChanges({'processInstanceId': change}); component.ngOnChanges({processInstanceId: change});
}); });
it('should reload the process list when the processInstanceId parameter changes to null', (done) => { it('should reload the process list when the processInstanceId parameter changes to null', (done) => {
@@ -431,7 +431,7 @@ describe('ProcessInstanceListComponent', () => {
done(); done();
}); });
component.ngOnChanges({'processInstanceId': change}); component.ngOnChanges({processInstanceId: change});
}); });
it('should update the columns when presetColumn schema changes', () => { it('should update the columns when presetColumn schema changes', () => {
@@ -442,7 +442,7 @@ describe('ProcessInstanceListComponent', () => {
component.presetColumn = 'fakeRunningProcessSchema'; component.presetColumn = 'fakeRunningProcessSchema';
const presetColumnChange = new SimpleChange(null, 'fakeRunningProcessSchema', false); const presetColumnChange = new SimpleChange(null, 'fakeRunningProcessSchema', false);
component.ngOnChanges({ 'presetColumn': presetColumnChange }); component.ngOnChanges({ presetColumn: presetColumnChange });
const newColumnSchema = component.mergeJsonAndHtmlSchema(); const newColumnSchema = component.mergeJsonAndHtmlSchema();
const expectedColumn1 = new ObjectDataColumn(fakeProcessColumnSchema.fakeRunningProcessSchema[0]); const expectedColumn1 = new ObjectDataColumn(fakeProcessColumnSchema.fakeRunningProcessSchema[0]);
@@ -569,12 +569,12 @@ describe('Process List: Custom EmptyTemplateComponent', () => {
</data-columns> </data-columns>
</adf-process-instance-list>` </adf-process-instance-list>`
}) })
class ProcessListContextMenuComponent implements OnInit { class ProcessListContextMenuComponent implements OnInit {
appId: number;
@Output() @Output()
contextAction = new EventEmitter<any>(); contextAction = new EventEmitter<any>();
appId: number;
private performAction$ = new Subject<any>(); private performAction$ = new Subject<any>();
ngOnInit() { ngOnInit() {

View File

@@ -47,6 +47,8 @@ import { BehaviorSubject } from 'rxjs';
import { ProcessListModel } from '../models/process-list.model'; import { ProcessListModel } from '../models/process-list.model';
import { finalize } from 'rxjs/operators'; import { finalize } from 'rxjs/operators';
const PRESET_KEY = 'adf-process-list.presets';
@Component({ @Component({
selector: 'adf-process-instance-list', selector: 'adf-process-instance-list',
styleUrls: ['./process-list.component.css'], styleUrls: ['./process-list.component.css'],
@@ -54,8 +56,6 @@ import { finalize } from 'rxjs/operators';
}) })
export class ProcessInstanceListComponent extends DataTableSchema implements OnChanges, AfterContentInit, PaginatedComponent { export class ProcessInstanceListComponent extends DataTableSchema implements OnChanges, AfterContentInit, PaginatedComponent {
static PRESET_KEY = 'adf-process-list.presets';
@ContentChild(CustomEmptyContentTemplateDirective) @ContentChild(CustomEmptyContentTemplateDirective)
customEmptyContent: CustomEmptyContentTemplateDirective; customEmptyContent: CustomEmptyContentTemplateDirective;
@@ -154,10 +154,10 @@ export class ProcessInstanceListComponent extends DataTableSchema implements OnC
constructor(private processService: ProcessService, constructor(private processService: ProcessService,
private userPreferences: UserPreferencesService, private userPreferences: UserPreferencesService,
appConfig: AppConfigService) { appConfig: AppConfigService) {
super(appConfig, ProcessInstanceListComponent.PRESET_KEY, processPresetsDefaultModel); super(appConfig, PRESET_KEY, processPresetsDefaultModel);
this.size = this.userPreferences.paginationSize; this.size = this.userPreferences.paginationSize;
this.pagination = new BehaviorSubject<PaginationModel>(<PaginationModel> { this.pagination = new BehaviorSubject<PaginationModel>({
maxItems: this.size, maxItems: this.size,
skipCount: 0, skipCount: 0,
totalItems: 0 totalItems: 0
@@ -190,6 +190,98 @@ export class ProcessInstanceListComponent extends DataTableSchema implements OnC
} }
} }
reload() {
this.requestNode = this.createRequestNode();
this.load(this.requestNode);
}
/**
* Select the first instance of a list if present
*/
selectFirst() {
if (this.selectFirstRow) {
if (!this.isListEmpty()) {
const dataRow = this.rows[0];
dataRow.isSelected = true;
this.currentInstanceId = dataRow['id'];
} else {
this.currentInstanceId = null;
}
}
}
/**
* Return the current id
*/
getCurrentId(): string {
return this.currentInstanceId;
}
/**
* Check if the list is empty
*/
isListEmpty(): boolean {
return !this.rows || this.rows.length === 0;
}
/**
* Emit the event rowClick passing the current task id when the row is clicked
*
* @param event
*/
onRowClick(event: DataRowEvent) {
const item = event;
this.currentInstanceId = item.value.getValue('id');
this.rowClick.emit(this.currentInstanceId);
}
/**
* Emit the event rowClick passing the current task id when pressed the Enter key on the selected row
*
* @param event
*/
onRowKeyUp(event: CustomEvent<any>) {
if (event.detail.keyboardEvent.key === 'Enter') {
event.preventDefault();
this.currentInstanceId = event.detail.row.getValue('id');
this.rowClick.emit(this.currentInstanceId);
}
}
onShowRowContextMenu(event: DataCellEvent) {
this.showRowContextMenu.emit(event);
}
updatePagination(params: PaginationModel) {
const needsReload = params.maxItems || params.skipCount;
this.size = params.maxItems;
this.page = this.currentPage(params.skipCount, params.maxItems);
if (needsReload) {
this.reload();
}
}
currentPage(skipCount: number, maxItems: number): number {
return (skipCount && maxItems) ? Math.floor(skipCount / maxItems) : 0;
}
private createRequestNode(): ProcessFilterParamRepresentationModel {
return new ProcessFilterParamRepresentationModel({
appDefinitionId: this.appId,
processDefinitionId: this.processDefinitionId,
processInstanceId: this.processInstanceId,
state: this.state,
sort: this.sort,
page: this.page,
size: this.size,
start: 0
});
}
private isSortChanged(changes: SimpleChanges): boolean { private isSortChanged(changes: SimpleChanges): boolean {
const actualSort = changes['sort']; const actualSort = changes['sort'];
return actualSort && actualSort.currentValue && actualSort.currentValue !== actualSort.previousValue; return actualSort && actualSort.currentValue && actualSort.currentValue !== actualSort.previousValue;
@@ -224,11 +316,6 @@ export class ProcessInstanceListComponent extends DataTableSchema implements OnC
return changed; return changed;
} }
public reload() {
this.requestNode = this.createRequestNode();
this.load(this.requestNode);
}
private load(requestNode: ProcessFilterParamRepresentationModel) { private load(requestNode: ProcessFilterParamRepresentationModel) {
this.isLoading = true; this.isLoading = true;
this.processService.getProcesses(requestNode) this.processService.getProcesses(requestNode)
@@ -250,89 +337,4 @@ export class ProcessInstanceListComponent extends DataTableSchema implements OnC
} }
); );
} }
/**
* Select the first instance of a list if present
*/
selectFirst() {
if (this.selectFirstRow) {
if (!this.isListEmpty()) {
const dataRow = this.rows[0];
dataRow.isSelected = true;
this.currentInstanceId = dataRow['id'];
} else {
this.currentInstanceId = null;
}
}
}
/**
* Return the current id
*/
getCurrentId(): string {
return this.currentInstanceId;
}
/**
* Check if the list is empty
*/
isListEmpty(): boolean {
return !this.rows || this.rows.length === 0;
}
/**
* Emit the event rowClick passing the current task id when the row is clicked
* @param event
*/
onRowClick(event: DataRowEvent) {
const item = event;
this.currentInstanceId = item.value.getValue('id');
this.rowClick.emit(this.currentInstanceId);
}
/**
* Emit the event rowClick passing the current task id when pressed the Enter key on the selected row
* @param event
*/
onRowKeyUp(event: CustomEvent<any>) {
if (event.detail.keyboardEvent.key === 'Enter') {
event.preventDefault();
this.currentInstanceId = event.detail.row.getValue('id');
this.rowClick.emit(this.currentInstanceId);
}
}
onShowRowContextMenu(event: DataCellEvent) {
this.showRowContextMenu.emit(event);
}
private createRequestNode(): ProcessFilterParamRepresentationModel {
return new ProcessFilterParamRepresentationModel({
appDefinitionId: this.appId,
processDefinitionId: this.processDefinitionId,
processInstanceId: this.processInstanceId,
state: this.state,
sort: this.sort,
page: this.page,
size: this.size,
start: 0
});
}
updatePagination(params: PaginationModel) {
const needsReload = params.maxItems || params.skipCount;
this.size = params.maxItems;
this.page = this.currentPage(params.skipCount, params.maxItems);
if (needsReload) {
this.reload();
}
}
currentPage(skipCount: number, maxItems: number): number {
return (skipCount && maxItems) ? Math.floor(skipCount / maxItems) : 0;
}
} }

View File

@@ -101,7 +101,7 @@ describe('StartFormComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
component.name = 'My new process'; component.name = 'My new process';
const change = new SimpleChange(null, 123, true); const change = new SimpleChange(null, 123, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -163,7 +163,7 @@ describe('StartFormComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
getDefinitionsSpy.and.returnValue(of(testProcessDefWithForm)); getDefinitionsSpy.and.returnValue(of(testProcessDefWithForm));
const change = new SimpleChange(null, 123, true); const change = new SimpleChange(null, 123, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
}); });
it('should initialize start form', async () => { it('should initialize start form', async () => {
@@ -242,7 +242,7 @@ describe('StartFormComponent', () => {
it('Should get the alfrescoRepositoryName from the config json', async () => { it('Should get the alfrescoRepositoryName from the config json', async () => {
appConfig.config = Object.assign(appConfig.config, { appConfig.config = Object.assign(appConfig.config, {
'alfrescoRepositoryName': 'alfresco-123' alfrescoRepositoryName: 'alfresco-123'
}); });
expect(component.getAlfrescoRepositoryName()).toBe('alfresco-123Alfresco'); expect(component.getAlfrescoRepositoryName()).toBe('alfresco-123Alfresco');
@@ -341,7 +341,7 @@ describe('StartFormComponent', () => {
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of([])); getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of([]));
component.appId = 123; component.appId = 123;
const change = new SimpleChange(null, 123, true); const change = new SimpleChange(null, 123, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -367,7 +367,7 @@ describe('StartFormComponent', () => {
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testProcessDefinitions)); getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testProcessDefinitions));
component.appId = 123; component.appId = 123;
const change = new SimpleChange(null, 123, true); const change = new SimpleChange(null, 123, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -379,7 +379,7 @@ describe('StartFormComponent', () => {
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs)); getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs));
component.appId = 123; component.appId = 123;
const change = new SimpleChange(null, 123, true); const change = new SimpleChange(null, 123, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -562,7 +562,7 @@ describe('StartFormComponent', () => {
component.appId = 123; component.appId = 123;
const appIdChange = new SimpleChange(null, 123, true); const appIdChange = new SimpleChange(null, 123, true);
component.ngOnChanges({ 'appId': appIdChange }); component.ngOnChanges({ appId: appIdChange });
fixture.detectChanges(); fixture.detectChanges();
selectOptionByName(testProcessDef.name); selectOptionByName(testProcessDef.name);
@@ -626,7 +626,7 @@ describe('StartFormComponent', () => {
getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs)); getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs));
const change = new SimpleChange(null, 3, true); const change = new SimpleChange(null, 3, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
const appsSelector = fixture.nativeElement.querySelector('[data-automation-id="adf-start-process-apps-drop-down"]'); const appsSelector = fixture.nativeElement.querySelector('[data-automation-id="adf-start-process-apps-drop-down"]');
const lableElement = fixture.nativeElement.querySelector('.adf-start-process-app-list .mat-form-field-label'); const lableElement = fixture.nativeElement.querySelector('.adf-start-process-app-list .mat-form-field-label');
@@ -653,7 +653,7 @@ describe('StartFormComponent', () => {
getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs)); getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs));
const change = new SimpleChange(null, 3, true); const change = new SimpleChange(null, 3, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
expect(component.appId).toBe(component.selectedApplication.id); expect(component.appId).toBe(component.selectedApplication.id);
@@ -668,7 +668,7 @@ describe('StartFormComponent', () => {
getDefinitionsSpy.and.returnValue(of([ { id: 'my:process 3', name: 'My Process 3', hasStartForm: true } ])); getDefinitionsSpy.and.returnValue(of([ { id: 'my:process 3', name: 'My Process 3', hasStartForm: true } ]));
fixture.detectChanges(); fixture.detectChanges();
const newApplication = <MatSelectChange> { value: deployedApps[1] }; const newApplication = { value: deployedApps[1] } as MatSelectChange;
component.onAppSelectionChange(newApplication); component.onAppSelectionChange(newApplication);
fixture.detectChanges(); fixture.detectChanges();
@@ -685,7 +685,7 @@ describe('StartFormComponent', () => {
getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs)); getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs));
const change = new SimpleChange(null, 123, true); const change = new SimpleChange(null, 123, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
expect(getDeployedApplicationsSpy).toHaveBeenCalled(); expect(getDeployedApplicationsSpy).toHaveBeenCalled();
expect(component.applications.length).toEqual(1); expect(component.applications.length).toEqual(1);
@@ -698,7 +698,7 @@ describe('StartFormComponent', () => {
const change = new SimpleChange(null, 123, true); const change = new SimpleChange(null, 123, true);
component.appId = 123; component.appId = 123;
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -731,7 +731,7 @@ describe('StartFormComponent', () => {
const change = new SimpleChange(null, 123, true); const change = new SimpleChange(null, 123, true);
component.appId = 123; component.appId = 123;
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -762,7 +762,7 @@ describe('StartFormComponent', () => {
it('Should be able to pre-select an application from the apps based given appId', () => { it('Should be able to pre-select an application from the apps based given appId', () => {
component.appId = 2; component.appId = 2;
const change = new SimpleChange(null, 2, true); const change = new SimpleChange(null, 2, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
expect(getDeployedApplicationsSpy).toHaveBeenCalled(); expect(getDeployedApplicationsSpy).toHaveBeenCalled();
expect(component.applications.length).toEqual(6); expect(component.applications.length).toEqual(6);
@@ -774,7 +774,7 @@ describe('StartFormComponent', () => {
it('Should be able to disable process name and definitions inputs if there is no application selected by default', () => { it('Should be able to disable process name and definitions inputs if there is no application selected by default', () => {
component.appId = 12345; component.appId = 12345;
const change = new SimpleChange(null, 12345, true); const change = new SimpleChange(null, 12345, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
expect(getDeployedApplicationsSpy).toHaveBeenCalled(); expect(getDeployedApplicationsSpy).toHaveBeenCalled();
expect(component.applications.length).toEqual(6); expect(component.applications.length).toEqual(6);
@@ -790,7 +790,7 @@ describe('StartFormComponent', () => {
it('Should be able to enable process name and definitions inputs if the application selected by given appId', () => { it('Should be able to enable process name and definitions inputs if the application selected by given appId', () => {
component.appId = 2; component.appId = 2;
const change = new SimpleChange(null, 2, true); const change = new SimpleChange(null, 2, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
expect(getDeployedApplicationsSpy).toHaveBeenCalled(); expect(getDeployedApplicationsSpy).toHaveBeenCalled();
expect(component.applications.length).toEqual(6); expect(component.applications.length).toEqual(6);
@@ -806,7 +806,7 @@ describe('StartFormComponent', () => {
it('Should be able to enable process name and definitions inputs when the application selected from the apps drop-down', () => { it('Should be able to enable process name and definitions inputs when the application selected from the apps drop-down', () => {
component.appId = 12345; component.appId = 12345;
const change = new SimpleChange(null, 12345, true); const change = new SimpleChange(null, 12345, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
expect(getDeployedApplicationsSpy).toHaveBeenCalled(); expect(getDeployedApplicationsSpy).toHaveBeenCalled();
expect(component.applications.length).toEqual(6); expect(component.applications.length).toEqual(6);
@@ -837,7 +837,7 @@ describe('StartFormComponent', () => {
getDeployedApplicationsSpy.and.returnValues(of([singleDeployedApp])); getDeployedApplicationsSpy.and.returnValues(of([singleDeployedApp]));
const change = new SimpleChange(null, mockAppid, true); const change = new SimpleChange(null, mockAppid, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
expect(getDeployedApplicationsSpy).toHaveBeenCalled(); expect(getDeployedApplicationsSpy).toHaveBeenCalled();
@@ -867,7 +867,7 @@ describe('StartFormComponent', () => {
it('[C333522] Should be able to list multiple deployed apps with multiple process', async () => { it('[C333522] Should be able to list multiple deployed apps with multiple process', async () => {
const change = new SimpleChange(null, 123, true); const change = new SimpleChange(null, 123, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
const application1 = deployedApps[0]; const application1 = deployedApps[0];
@@ -878,7 +878,7 @@ describe('StartFormComponent', () => {
const processDefWithStartForm = testProcessDefWithForm[0]; const processDefWithStartForm = testProcessDefWithForm[0];
getDefinitionsSpy.and.returnValues(of([processDefWithStartForm])); getDefinitionsSpy.and.returnValues(of([processDefWithStartForm]));
component.onAppSelectionChange(<MatSelectChange> { value: application1 }); component.onAppSelectionChange({ value: application1 } as MatSelectChange);
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -892,7 +892,7 @@ describe('StartFormComponent', () => {
expect(component.selectedProcessDef.hasStartForm).toEqual(processDefWithStartForm.hasStartForm); expect(component.selectedProcessDef.hasStartForm).toEqual(processDefWithStartForm.hasStartForm);
getDefinitionsSpy.and.returnValues(of(testMultipleProcessDefs)); getDefinitionsSpy.and.returnValues(of(testMultipleProcessDefs));
component.onAppSelectionChange(<MatSelectChange> { value: application2 }); component.onAppSelectionChange({ value: application2 } as MatSelectChange);
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -902,7 +902,7 @@ describe('StartFormComponent', () => {
const processDefWithNoStartForm = testMultipleProcessDefs[0]; const processDefWithNoStartForm = testMultipleProcessDefs[0];
getDefinitionsSpy.and.returnValues(of([processDefWithNoStartForm])); getDefinitionsSpy.and.returnValues(of([processDefWithNoStartForm]));
component.onAppSelectionChange(<MatSelectChange> { value: application3 }); component.onAppSelectionChange({ value: application3 } as MatSelectChange);
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();

View File

@@ -40,6 +40,7 @@ import { MinimalNode, RelatedContentRepresentation } from '@alfresco/js-api';
import { AppDefinitionRepresentationModel } from '../../task-list'; import { AppDefinitionRepresentationModel } from '../../task-list';
import { ProcessNamePipe } from '../../pipes/process-name.pipe'; import { ProcessNamePipe } from '../../pipes/process-name.pipe';
const MAX_LENGTH = 255;
@Component({ @Component({
selector: 'adf-start-process', selector: 'adf-start-process',
templateUrl: './start-process.component.html', templateUrl: './start-process.component.html',
@@ -48,8 +49,6 @@ import { ProcessNamePipe } from '../../pipes/process-name.pipe';
}) })
export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestroy { export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestroy {
MAX_LENGTH: number = 255;
/** (optional) Limit the list of processes that can be started to those /** (optional) Limit the list of processes that can be started to those
* contained in the specified app. * contained in the specified app.
*/ */
@@ -92,7 +91,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
/** Emitted when the process starts. */ /** Emitted when the process starts. */
@Output() @Output()
start: EventEmitter<ProcessInstance> = new EventEmitter<ProcessInstance>(); start = new EventEmitter<ProcessInstance>();
/** Emitted when the process is canceled. */ /** Emitted when the process is canceled. */
@Output() @Output()
@@ -100,15 +99,15 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
/** Emitted when an error occurs. */ /** Emitted when an error occurs. */
@Output() @Output()
error: EventEmitter<any> = new EventEmitter<any>(); error = new EventEmitter<any>();
/** Emitted when process definition selection changes. */ /** Emitted when process definition selection changes. */
@Output() @Output()
processDefinitionSelection: EventEmitter<ProcessDefinitionRepresentation> = new EventEmitter<ProcessDefinitionRepresentation>(); processDefinitionSelection = new EventEmitter<ProcessDefinitionRepresentation>();
/** Emitted when application selection changes. */ /** Emitted when application selection changes. */
@Output() @Output()
applicationSelection: EventEmitter<AppDefinitionRepresentationModel> = new EventEmitter<AppDefinitionRepresentationModel>(); applicationSelection = new EventEmitter<AppDefinitionRepresentationModel>();
@ViewChild('startForm') @ViewChild('startForm')
startForm: StartFormComponent; startForm: StartFormComponent;
@@ -121,7 +120,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
processNameInput: FormControl; processNameInput: FormControl;
processDefinitionInput: FormControl; processDefinitionInput: FormControl;
filteredProcessesDefinitions$: Observable<ProcessDefinitionRepresentation[]>; filteredProcessesDefinitions$: Observable<ProcessDefinitionRepresentation[]>;
maxProcessNameLength: number = this.MAX_LENGTH; maxProcessNameLength: number = MAX_LENGTH;
alfrescoRepositoryName: string; alfrescoRepositoryName: string;
applications: AppDefinitionRepresentationModel[] = []; applications: AppDefinitionRepresentationModel[] = [];
selectedApplication: AppDefinitionRepresentationModel; selectedApplication: AppDefinitionRepresentationModel;
@@ -179,29 +178,6 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
} }
} }
private isAppIdChanged(changes: SimpleChanges) {
return changes['appId'] && changes['appId'].currentValue && changes['appId'].currentValue !== changes['appId'].previousValue;
}
private isProcessDefinitionChanged(changes: SimpleChanges) {
return changes['processDefinitionName'] && changes['processDefinitionName'].currentValue &&
changes['processDefinitionName'].currentValue !== changes['processDefinitionName'].previousValue;
}
private _filter(value: string): ProcessDefinitionRepresentation[] {
if (value !== null && value !== undefined) {
const filterValue = value.toLowerCase();
const filteredProcess = this.processDefinitions.filter((option) => option.name.toLowerCase().includes(filterValue));
if (this.processFilterSelector) {
this.selectedProcessDef = this.getSelectedProcess(filterValue);
}
return filteredProcess;
}
return [];
}
getSelectedProcess(selectedProcess: string): ProcessDefinitionRepresentation { getSelectedProcess(selectedProcess: string): ProcessDefinitionRepresentation {
let processSelected = this.processDefinitions.find((process) => process.name.toLowerCase() === selectedProcess); let processSelected = this.processDefinitions.find((process) => process.name.toLowerCase() === selectedProcess);
@@ -232,9 +208,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
} }
if (this.processDefinitionName) { if (this.processDefinitionName) {
const filteredProcessDefinition = processDefinitionRepresentations.find((processDefinition) => { const filteredProcessDefinition = processDefinitionRepresentations.find((processDefinition) => processDefinition.name === this.processDefinitionName);
return processDefinition.name === this.processDefinitionName;
});
if (filteredProcessDefinition) { if (filteredProcessDefinition) {
currentProcessDef = filteredProcessDefinition; currentProcessDef = filteredProcessDefinition;
} }
@@ -257,9 +231,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
filterProcessDefinitionByName() { filterProcessDefinitionByName() {
if (this.processDefinitionName) { if (this.processDefinitionName) {
const filteredProcessDef = this.processDefinitions.find((processDefinition) => { const filteredProcessDef = this.processDefinitions.find((processDefinition) => processDefinition.name === this.processDefinitionName);
return processDefinition.name === this.processDefinitionName;
});
if (filteredProcessDef) { if (filteredProcessDef) {
this.processDefinitionSelectionChanged(filteredProcessDef); this.processDefinitionSelectionChanged(filteredProcessDef);
@@ -322,14 +294,6 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
this.loadProcessDefinitionsBasedOnSelectedApp(); this.loadProcessDefinitionsBasedOnSelectedApp();
} }
private isAppSelected(): boolean {
return !!(this.selectedApplication && this.selectedApplication.id);
}
private removeDefaultApps(apps: AppDefinitionRepresentationModel []): AppDefinitionRepresentationModel[] {
return apps.filter((app) => app.id);
}
hasApplications(): boolean { hasApplications(): boolean {
return this.applications && this.applications.length > 0; return this.applications && this.applications.length > 0;
} }
@@ -408,19 +372,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
return this.selectedProcessDef && this.selectedProcessDef.id && this.processNameInput.valid && this.isStartFormMissingOrValid(); return this.selectedProcessDef && this.selectedProcessDef.id && this.processNameInput.valid && this.isStartFormMissingOrValid();
} }
private resetSelectedProcessDefinition() { onOutcomeClick(outcome: string) {
this.selectedProcessDef = undefined;
if (this.processDefinitionInput) {
this.processDefinitionInput.setValue('');
}
}
private resetProcessDefinitions() {
this.processDefinitions = [];
this.resetSelectedProcessDefinition();
}
public onOutcomeClick(outcome: string) {
this.startProcess(outcome); this.startProcess(outcome);
} }
@@ -461,16 +413,6 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
return this.processDefinitionInput; return this.processDefinitionInput;
} }
private toggleProcessNameAndDefinitionsDropdown() {
if (!this.isAppSelected()) {
this.processDefinitionController.disable();
this.nameController.disable();
} else {
this.processDefinitionController.enable();
this.nameController.enable();
}
}
processDefinitionSelectionChanged(processDefinition: ProcessDefinitionRepresentation) { processDefinitionSelectionChanged(processDefinition: ProcessDefinitionRepresentation) {
if (processDefinition) { if (processDefinition) {
const processInstanceDetails = new ProcessInstance({ processDefinitionName: processDefinition.name }); const processInstanceDetails = new ProcessInstance({ processDefinitionName: processDefinition.name });
@@ -488,4 +430,57 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
isLoading(): boolean { isLoading(): boolean {
return this.showSelectApplicationDropdown ? this.isAppsLoading : false; return this.showSelectApplicationDropdown ? this.isAppsLoading : false;
} }
private isAppSelected(): boolean {
return !!(this.selectedApplication && this.selectedApplication.id);
}
private removeDefaultApps(apps: AppDefinitionRepresentationModel []): AppDefinitionRepresentationModel[] {
return apps.filter((app) => app.id);
}
private resetSelectedProcessDefinition() {
this.selectedProcessDef = undefined;
if (this.processDefinitionInput) {
this.processDefinitionInput.setValue('');
}
}
private resetProcessDefinitions() {
this.processDefinitions = [];
this.resetSelectedProcessDefinition();
}
private toggleProcessNameAndDefinitionsDropdown() {
if (!this.isAppSelected()) {
this.processDefinitionController.disable();
this.nameController.disable();
} else {
this.processDefinitionController.enable();
this.nameController.enable();
}
}
private isAppIdChanged(changes: SimpleChanges) {
return changes['appId'] && changes['appId'].currentValue && changes['appId'].currentValue !== changes['appId'].previousValue;
}
private isProcessDefinitionChanged(changes: SimpleChanges) {
return changes['processDefinitionName'] && changes['processDefinitionName'].currentValue &&
changes['processDefinitionName'].currentValue !== changes['processDefinitionName'].previousValue;
}
private _filter(value: string): ProcessDefinitionRepresentation[] {
if (value !== null && value !== undefined) {
const filterValue = value.toLowerCase();
const filteredProcess = this.processDefinitions.filter((option) => option.name.toLowerCase().includes(filterValue));
if (this.processFilterSelector) {
this.selectedProcessDef = this.getSelectedProcess(filterValue);
}
return filteredProcess;
}
return [];
}
} }

View File

@@ -15,20 +15,20 @@
* limitations under the License. * limitations under the License.
*/ */
export let processPresetsDefaultModel = { export const processPresetsDefaultModel = {
'default': [ default: [
{ {
'key': 'name', key: 'name',
'type': 'text', type: 'text',
'title': 'ADF_PROCESS_LIST.PROPERTIES.NAME', title: 'ADF_PROCESS_LIST.PROPERTIES.NAME',
'sortable': true sortable: true
}, },
{ {
'key': 'created', key: 'created',
'type': 'text', type: 'text',
'title': 'ADF_PROCESS_LIST.PROPERTIES.CREATED', title: 'ADF_PROCESS_LIST.PROPERTIES.CREATED',
'cssClass': 'hidden', cssClass: 'hidden',
'sortable': true sortable: true
} }
] ]
}; };

View File

@@ -106,7 +106,7 @@ describe('Process filter', () => {
}); });
jasmine.Ajax.requests.at(0).respondWith({ jasmine.Ajax.requests.at(0).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
appId: 1001, id: 111, name: 'Running', icon: 'fake-icon', recent: false appId: 1001, id: 111, name: 'Running', icon: 'fake-icon', recent: false
@@ -114,7 +114,7 @@ describe('Process filter', () => {
}); });
jasmine.Ajax.requests.at(1).respondWith({ jasmine.Ajax.requests.at(1).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
appId: 1001, id: 222, name: 'Completed', icon: 'fake-icon', recent: false appId: 1001, id: 222, name: 'Completed', icon: 'fake-icon', recent: false
@@ -122,7 +122,7 @@ describe('Process filter', () => {
}); });
jasmine.Ajax.requests.at(2).respondWith({ jasmine.Ajax.requests.at(2).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
appId: 1001, id: 333, name: 'All', icon: 'fake-icon', recent: false appId: 1001, id: 333, name: 'All', icon: 'fake-icon', recent: false
@@ -149,7 +149,7 @@ describe('Process filter', () => {
}); });
jasmine.Ajax.requests.at(0).respondWith({ jasmine.Ajax.requests.at(0).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
appId: 1001, id: 111, name: 'Running', icon: 'fake-icon', recent: false appId: 1001, id: 111, name: 'Running', icon: 'fake-icon', recent: false
@@ -157,7 +157,7 @@ describe('Process filter', () => {
}); });
jasmine.Ajax.requests.at(1).respondWith({ jasmine.Ajax.requests.at(1).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
appId: 1001, id: 222, name: 'Completed', icon: 'fake-icon', recent: false appId: 1001, id: 222, name: 'Completed', icon: 'fake-icon', recent: false
@@ -165,7 +165,7 @@ describe('Process filter', () => {
}); });
jasmine.Ajax.requests.at(2).respondWith({ jasmine.Ajax.requests.at(2).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
appId: 1001, id: 333, name: 'All', icon: 'fake-icon', recent: false appId: 1001, id: 333, name: 'All', icon: 'fake-icon', recent: false

View File

@@ -30,7 +30,7 @@ import {
}) })
export class ProcessFilterService { export class ProcessFilterService {
private _userFiltersApi; private _userFiltersApi: UserFiltersApi;
get userFiltersApi(): UserFiltersApi { get userFiltersApi(): UserFiltersApi {
this._userFiltersApi = this._userFiltersApi ?? new UserFiltersApi(this.alfrescoApiService.getInstance()); this._userFiltersApi = this._userFiltersApi ?? new UserFiltersApi(this.alfrescoApiService.getInstance());
return this._userFiltersApi; return this._userFiltersApi;
@@ -41,6 +41,7 @@ export class ProcessFilterService {
/** /**
* Gets all filters defined for a Process App. * Gets all filters defined for a Process App.
*
* @param appId ID of the target app * @param appId ID of the target app
* @returns Array of filter details * @returns Array of filter details
*/ */
@@ -61,6 +62,7 @@ export class ProcessFilterService {
/** /**
* Retrieves the process filter by ID. * Retrieves the process filter by ID.
*
* @param filterId ID of the filter * @param filterId ID of the filter
* @param appId ID of the target app * @param appId ID of the target app
* @returns Details of the filter * @returns Details of the filter
@@ -68,15 +70,14 @@ export class ProcessFilterService {
getProcessFilterById(filterId: number, appId?: number): Observable<FilterProcessRepresentationModel> { getProcessFilterById(filterId: number, appId?: number): Observable<FilterProcessRepresentationModel> {
return from(this.callApiProcessFilters(appId)) return from(this.callApiProcessFilters(appId))
.pipe( .pipe(
map((response: any) => { map((response: any) => response.data.find((filter) => filter.id === filterId)),
return response.data.find((filter) => filter.id === filterId);
}),
catchError((err) => this.handleProcessError(err)) catchError((err) => this.handleProcessError(err))
); );
} }
/** /**
* Retrieves the process filter by name. * Retrieves the process filter by name.
*
* @param filterName Name of the filter * @param filterName Name of the filter
* @param appId ID of the target app * @param appId ID of the target app
* @returns Details of the filter * @returns Details of the filter
@@ -84,19 +85,18 @@ export class ProcessFilterService {
getProcessFilterByName(filterName: string, appId?: number): Observable<FilterProcessRepresentationModel> { getProcessFilterByName(filterName: string, appId?: number): Observable<FilterProcessRepresentationModel> {
return from(this.callApiProcessFilters(appId)) return from(this.callApiProcessFilters(appId))
.pipe( .pipe(
map((response: any) => { map((response: any) => response.data.find((filter) => filter.name === filterName)),
return response.data.find((filter) => filter.name === filterName);
}),
catchError((err) => this.handleProcessError(err)) catchError((err) => this.handleProcessError(err))
); );
} }
/** /**
* Creates and returns the default filters for an app. * Creates and returns the default filters for an app.
*
* @param appId ID of the target app * @param appId ID of the target app
* @returns Default filters just created * @returns Default filters just created
*/ */
public createDefaultFilters(appId: number): Observable<FilterProcessRepresentationModel[]> { createDefaultFilters(appId: number): Observable<FilterProcessRepresentationModel[]> {
const runningFilter = this.getRunningFilterInstance(appId, 0); const runningFilter = this.getRunningFilterInstance(appId, 0);
const runningObservable = this.addProcessFilter(runningFilter); const runningObservable = this.addProcessFilter(runningFilter);
@@ -135,83 +135,72 @@ export class ProcessFilterService {
/** /**
* Creates and returns a filter that matches "running" process instances. * Creates and returns a filter that matches "running" process instances.
*
* @param appId ID of the target app * @param appId ID of the target app
* @param index of the filter (optional) * @param index of the filter (optional)
* @returns Filter just created * @returns Filter just created
*/ */
public getRunningFilterInstance(appId: number, index?: number): FilterProcessRepresentationModel { getRunningFilterInstance(appId: number, index?: number): FilterProcessRepresentationModel {
return new FilterProcessRepresentationModel({ return new FilterProcessRepresentationModel({
'name': 'Running', name: 'Running',
'appId': appId, appId,
'recent': true, recent: true,
'icon': 'glyphicon-random', icon: 'glyphicon-random',
'filter': { 'sort': 'created-desc', 'name': '', 'state': 'running' }, filter: { sort: 'created-desc', name: '', state: 'running' },
index
});
}
/**
* Returns a static Completed filter instance.
* @param appId ID of the target app
* @param index of the filter (optional)
* @returns Details of the filter
*/
private getCompletedFilterInstance(appId: number, index?: number): FilterProcessRepresentationModel {
return new FilterProcessRepresentationModel({
'name': 'Completed',
'appId': appId,
'recent': false,
'icon': 'glyphicon-ok-sign',
'filter': { 'sort': 'created-desc', 'name': '', 'state': 'completed' },
index
});
}
/**
* Returns a static All filter instance.
* @param appId ID of the target app
* @param index of the filter (optional)
* @returns Details of the filter
*/
private getAllFilterInstance(appId: number, index?: number): FilterProcessRepresentationModel {
return new FilterProcessRepresentationModel({
'name': 'All',
'appId': appId,
'recent': true,
'icon': 'glyphicon-th',
'filter': { 'sort': 'created-desc', 'name': '', 'state': 'all' },
index index
}); });
} }
/** /**
* Adds a filter. * Adds a filter.
*
* @param filter The filter to add * @param filter The filter to add
* @returns The filter just added * @returns The filter just added
*/ */
addProcessFilter(filter: FilterProcessRepresentationModel): Observable<FilterProcessRepresentationModel> { addProcessFilter(filter: FilterProcessRepresentationModel): Observable<FilterProcessRepresentationModel> {
return from(this.userFiltersApi.createUserProcessInstanceFilter(filter)) return from(this.userFiltersApi.createUserProcessInstanceFilter(filter))
.pipe( .pipe(
map((response: FilterProcessRepresentationModel) => { map((response: FilterProcessRepresentationModel) => response),
return response;
}),
catchError((err) => this.handleProcessError(err)) catchError((err) => this.handleProcessError(err))
); );
} }
/** /**
* Calls `getUserProcessInstanceFilters` from the Alfresco JS API. * Calls `getUserProcessInstanceFilters` from the Alfresco JS API.
*
* @param appId ID of the target app * @param appId ID of the target app
* @returns List of filter details * @returns List of filter details
*/ */
callApiProcessFilters(appId?: number): Promise<ResultListDataRepresentationUserProcessInstanceFilterRepresentation> { callApiProcessFilters(appId?: number): Promise<ResultListDataRepresentationUserProcessInstanceFilterRepresentation> {
if (appId) { if (appId) {
return this.userFiltersApi.getUserProcessInstanceFilters({ appId: appId }); return this.userFiltersApi.getUserProcessInstanceFilters({ appId });
} else { } else {
return this.userFiltersApi.getUserProcessInstanceFilters(); return this.userFiltersApi.getUserProcessInstanceFilters();
} }
} }
private getCompletedFilterInstance(appId: number, index?: number): FilterProcessRepresentationModel {
return new FilterProcessRepresentationModel({
name: 'Completed',
appId,
recent: false,
icon: 'glyphicon-ok-sign',
filter: { sort: 'created-desc', name: '', state: 'completed' },
index
});
}
private getAllFilterInstance(appId: number, index?: number): FilterProcessRepresentationModel {
return new FilterProcessRepresentationModel({
name: 'All',
appId,
recent: true,
icon: 'glyphicon-th',
filter: { sort: 'created-desc', name: '', state: 'all' },
index
});
}
private handleProcessError(error: any) { private handleProcessError(error: any) {
return throwError(error || 'Server error'); return throwError(error || 'Server error');
} }

View File

@@ -42,25 +42,25 @@ declare let moment: any;
}) })
export class ProcessService { export class ProcessService {
private _tasksApi; private _tasksApi: TasksApi;
get tasksApi(): TasksApi { get tasksApi(): TasksApi {
this._tasksApi = this._tasksApi ?? new TasksApi(this.alfrescoApiService.getInstance()); this._tasksApi = this._tasksApi ?? new TasksApi(this.alfrescoApiService.getInstance());
return this._tasksApi; return this._tasksApi;
} }
private _processDefinitionsApi; private _processDefinitionsApi: ProcessDefinitionsApi;
get processDefinitionsApi(): ProcessDefinitionsApi { get processDefinitionsApi(): ProcessDefinitionsApi {
this._processDefinitionsApi = this._processDefinitionsApi ?? new ProcessDefinitionsApi(this.alfrescoApiService.getInstance()); this._processDefinitionsApi = this._processDefinitionsApi ?? new ProcessDefinitionsApi(this.alfrescoApiService.getInstance());
return this._processDefinitionsApi; return this._processDefinitionsApi;
} }
private _processInstancesApi; private _processInstancesApi: ProcessInstancesApi;
get processInstancesApi(): ProcessInstancesApi { get processInstancesApi(): ProcessInstancesApi {
this._processInstancesApi = this._processInstancesApi ?? new ProcessInstancesApi(this.alfrescoApiService.getInstance()); this._processInstancesApi = this._processInstancesApi ?? new ProcessInstancesApi(this.alfrescoApiService.getInstance());
return this._processInstancesApi; return this._processInstancesApi;
} }
private _processInstanceVariablesApi; private _processInstanceVariablesApi: ProcessInstanceVariablesApi;
get processInstanceVariablesApi(): ProcessInstanceVariablesApi { get processInstanceVariablesApi(): ProcessInstanceVariablesApi {
this._processInstanceVariablesApi = this._processInstanceVariablesApi ?? new ProcessInstanceVariablesApi(this.alfrescoApiService.getInstance()); this._processInstanceVariablesApi = this._processInstanceVariablesApi ?? new ProcessInstanceVariablesApi(this.alfrescoApiService.getInstance());
return this._processInstanceVariablesApi; return this._processInstanceVariablesApi;
@@ -71,6 +71,7 @@ export class ProcessService {
/** /**
* Gets process instances for a filter and optionally a process definition. * Gets process instances for a filter and optionally a process definition.
*
* @param requestNode Filter for instances * @param requestNode Filter for instances
* @param processDefinitionKey Limits returned instances to a process definition * @param processDefinitionKey Limits returned instances to a process definition
* @returns List of process instances * @returns List of process instances
@@ -93,6 +94,7 @@ export class ProcessService {
/** /**
* Gets processes for a filter and optionally a process definition. * Gets processes for a filter and optionally a process definition.
*
* @param requestNode Filter for instances * @param requestNode Filter for instances
* @param processDefinitionKey Limits returned instances to a process definition * @param processDefinitionKey Limits returned instances to a process definition
* @returns List of processes * @returns List of processes
@@ -100,42 +102,20 @@ export class ProcessService {
getProcesses(requestNode: ProcessFilterParamRepresentationModel, processDefinitionKey?: string): Observable<ProcessListModel> { getProcesses(requestNode: ProcessFilterParamRepresentationModel, processDefinitionKey?: string): Observable<ProcessListModel> {
return this.getProcessInstances(requestNode, processDefinitionKey) return this.getProcessInstances(requestNode, processDefinitionKey)
.pipe( .pipe(
map(response => { map(response => ({
return {
...response, ...response,
data: (response.data || []).map(instance => { data: (response.data || []).map(instance => {
instance.name = this.getProcessNameOrDescription(instance, 'medium'); instance.name = this.getProcessNameOrDescription(instance, 'medium');
return instance; return instance;
}) })
}; })),
}),
catchError(() => of(new ProcessListModel({}))) catchError(() => of(new ProcessListModel({})))
); );
} }
private getProcessNameOrDescription(processInstance: ProcessInstanceRepresentation, dateFormat: string): string {
let name = '';
if (processInstance) {
name = processInstance.name ||
processInstance.processDefinitionName + ' - ' + this.getFormatDate(processInstance.started, dateFormat);
}
return name;
}
private getFormatDate(value: Date, format: string) {
const datePipe = new DatePipe('en-US');
try {
return datePipe.transform(value, format);
} catch (err) {
return '';
}
}
/** /**
* Fetches the Process Audit information as a PDF. * Fetches the Process Audit information as a PDF.
*
* @param processId ID of the target process * @param processId ID of the target process
* @returns Binary PDF data * @returns Binary PDF data
*/ */
@@ -148,6 +128,7 @@ export class ProcessService {
/** /**
* Fetches the Process Audit information in a JSON format. * Fetches the Process Audit information in a JSON format.
*
* @param processId ID of the target process * @param processId ID of the target process
* @returns JSON data * @returns JSON data
*/ */
@@ -160,6 +141,7 @@ export class ProcessService {
/** /**
* Gets Process Instance metadata. * Gets Process Instance metadata.
*
* @param processInstanceId ID of the target process * @param processInstanceId ID of the target process
* @returns Metadata for the instance * @returns Metadata for the instance
*/ */
@@ -172,16 +154,17 @@ export class ProcessService {
/** /**
* Gets task instances for a process instance. * Gets task instances for a process instance.
*
* @param processInstanceId ID of the process instance * @param processInstanceId ID of the process instance
* @param state Task state filter (can be "active" or "completed") * @param state Task state filter (can be "active" or "completed")
* @returns Array of task instance details * @returns Array of task instance details
*/ */
getProcessTasks(processInstanceId: string, state?: string): Observable<TaskDetailsModel[]> { getProcessTasks(processInstanceId: string, state?: string): Observable<TaskDetailsModel[]> {
const taskOpts = state ? { const taskOpts = state ? {
processInstanceId: processInstanceId, processInstanceId,
state: state state
} : { } : {
processInstanceId: processInstanceId processInstanceId
}; };
return from(this.tasksApi.listTasks(taskOpts)) return from(this.tasksApi.listTasks(taskOpts))
.pipe( .pipe(
@@ -196,6 +179,7 @@ export class ProcessService {
/** /**
* Gets process definitions associated with an app. * Gets process definitions associated with an app.
*
* @param appId ID of a target app * @param appId ID of a target app
* @returns Array of process definitions * @returns Array of process definitions
*/ */
@@ -218,6 +202,7 @@ export class ProcessService {
/** /**
* Starts a process based on a process definition, name, form values or variables. * Starts a process based on a process definition, name, form values or variables.
*
* @param processDefinitionId Process definition ID * @param processDefinitionId Process definition ID
* @param name Process name * @param name Process name
* @param outcome Process outcome * @param outcome Process outcome
@@ -227,8 +212,8 @@ export class ProcessService {
*/ */
startProcess(processDefinitionId: string, name: string, outcome?: string, startFormValues?: FormValues, variables?: ProcessInstanceVariable[]): Observable<ProcessInstance> { startProcess(processDefinitionId: string, name: string, outcome?: string, startFormValues?: FormValues, variables?: ProcessInstanceVariable[]): Observable<ProcessInstance> {
const startRequest: any = { const startRequest: any = {
name: name, name,
processDefinitionId: processDefinitionId processDefinitionId
}; };
if (outcome) { if (outcome) {
startRequest.outcome = outcome; startRequest.outcome = outcome;
@@ -250,6 +235,7 @@ export class ProcessService {
/** /**
* Cancels a process instance. * Cancels a process instance.
*
* @param processInstanceId ID of process to cancel * @param processInstanceId ID of process to cancel
* @returns Null response notifying when the operation is complete * @returns Null response notifying when the operation is complete
*/ */
@@ -264,6 +250,7 @@ export class ProcessService {
/** /**
* Gets the variables for a process instance. * Gets the variables for a process instance.
*
* @param processInstanceId ID of the target process * @param processInstanceId ID of the target process
* @returns Array of instance variable info * @returns Array of instance variable info
*/ */
@@ -279,6 +266,7 @@ export class ProcessService {
/** /**
* Creates or updates variables for a process instance. * Creates or updates variables for a process instance.
*
* @param processInstanceId ID of the target process * @param processInstanceId ID of the target process
* @param variables Variables to update * @param variables Variables to update
* @returns Array of instance variable info * @returns Array of instance variable info
@@ -293,6 +281,7 @@ export class ProcessService {
/** /**
* Deletes a variable for a process instance. * Deletes a variable for a process instance.
*
* @param processInstanceId ID of the target process * @param processInstanceId ID of the target process
* @param variableName Name of the variable to delete * @param variableName Name of the variable to delete
* @returns Null response notifying when the operation is complete * @returns Null response notifying when the operation is complete
@@ -313,4 +302,25 @@ export class ProcessService {
private handleProcessError(error: any) { private handleProcessError(error: any) {
return throwError(error || 'Server error'); return throwError(error || 'Server error');
} }
private getProcessNameOrDescription(processInstance: ProcessInstanceRepresentation, dateFormat: string): string {
let name = '';
if (processInstance) {
name = processInstance.name ||
processInstance.processDefinitionName + ' - ' + this.getFormatDate(processInstance.started, dateFormat);
}
return name;
}
private getFormatDate(value: Date, format: string) {
const datePipe = new DatePipe('en-US');
try {
return datePipe.transform(value, format);
} catch (err) {
return '';
}
}
} }

View File

@@ -28,29 +28,26 @@ import { FormControl, Validators } from '@angular/forms';
}) })
export class AttachFormComponent implements OnInit, OnChanges { export class AttachFormComponent implements OnInit, OnChanges {
constructor(private taskService: TaskListService,
private logService: LogService,
private formService: FormService) { }
/** Id of the task. */ /** Id of the task. */
@Input() @Input()
taskId; taskId: any;
/** Identifier of the form to attach. */ /** Identifier of the form to attach. */
@Input() @Input()
formKey; formKey: any;
/** Emitted when the "Cancel" button is clicked. */ /** Emitted when the "Cancel" button is clicked. */
@Output() @Output()
cancelAttachForm: EventEmitter<void> = new EventEmitter<void>(); cancelAttachForm = new EventEmitter<void>();
/** Emitted when the form is attached successfully. */ /** Emitted when the form is attached successfully. */
@Output() @Output()
success: EventEmitter<void> = new EventEmitter<void>(); success = new EventEmitter<void>();
/** Emitted when an error occurs. */ /** Emitted when an error occurs. */
@Output() @Output()
error: EventEmitter<any> = new EventEmitter<any>(); error = new EventEmitter<any>();
forms: Form[]; forms: Form[];
@@ -60,6 +57,10 @@ export class AttachFormComponent implements OnInit, OnChanges {
attachFormControl: FormControl; attachFormControl: FormControl;
constructor(private taskService: TaskListService,
private logService: LogService,
private formService: FormService) { }
ngOnInit() { ngOnInit() {
this.attachFormControl = new FormControl('', Validators.required); this.attachFormControl = new FormControl('', Validators.required);
this.attachFormControl.valueChanges.subscribe( (currentValue) => { this.attachFormControl.valueChanges.subscribe( (currentValue) => {

View File

@@ -75,7 +75,7 @@ describe('ChecklistComponent', () => {
checklistComponent.readOnly = true; checklistComponent.readOnly = true;
fixture.detectChanges(); fixture.detectChanges();
showChecklistDialog = <HTMLElement> element.querySelector('#add-checklist'); showChecklistDialog = element.querySelector<HTMLElement>('#add-checklist');
}); });
it('should NOT show add checklist button', () => { it('should NOT show add checklist button', () => {
@@ -98,7 +98,7 @@ describe('ChecklistComponent', () => {
})); }));
fixture.detectChanges(); fixture.detectChanges();
showChecklistDialog = <HTMLElement> element.querySelector('#add-checklist'); showChecklistDialog = element.querySelector<HTMLElement>('#add-checklist');
}); });
it('should show add checklist button', () => { it('should show add checklist button', () => {
@@ -117,7 +117,7 @@ describe('ChecklistComponent', () => {
checklistComponent.checklist = []; checklistComponent.checklist = [];
fixture.detectChanges(); fixture.detectChanges();
showChecklistDialog = <HTMLElement> element.querySelector('#add-checklist'); showChecklistDialog = element.querySelector<HTMLElement>('#add-checklist');
}); });
it('should show dialog when clicked on add', (done) => { it('should show dialog when clicked on add', (done) => {
@@ -139,11 +139,11 @@ describe('ChecklistComponent', () => {
checklistComponent.taskId = 'fake-task-id'; checklistComponent.taskId = 'fake-task-id';
checklistComponent.checklist = []; checklistComponent.checklist = [];
fixture.detectChanges(); fixture.detectChanges();
showChecklistDialog = <HTMLElement> element.querySelector('#add-checklist'); showChecklistDialog = element.querySelector<HTMLElement>('#add-checklist');
}); });
afterEach(() => { afterEach(() => {
const overlayContainers = <any> window.document.querySelectorAll('.cdk-overlay-container'); const overlayContainers = window.document.querySelectorAll('.cdk-overlay-container');
overlayContainers.forEach((overlayContainer) => { overlayContainers.forEach((overlayContainer) => {
overlayContainer.innerHTML = ''; overlayContainer.innerHTML = '';
}); });
@@ -182,7 +182,7 @@ describe('ChecklistComponent', () => {
}))); })));
showChecklistDialog.click(); showChecklistDialog.click();
const addButtonDialog = <HTMLElement> window.document.querySelector('#add-check'); const addButtonDialog = window.document.querySelector<HTMLElement>('#add-check');
addButtonDialog.click(); addButtonDialog.click();
fixture.detectChanges(); fixture.detectChanges();
@@ -204,7 +204,7 @@ describe('ChecklistComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const checklistElementRemove = <HTMLElement> element.querySelector('#remove-fake-check-id'); const checklistElementRemove = element.querySelector<HTMLElement>('#remove-fake-check-id');
expect(checklistElementRemove).toBeDefined(); expect(checklistElementRemove).toBeDefined();
expect(checklistElementRemove).not.toBeNull(); expect(checklistElementRemove).not.toBeNull();
checklistElementRemove.click(); checklistElementRemove.click();
@@ -227,7 +227,7 @@ describe('ChecklistComponent', () => {
await fixture.whenStable(); await fixture.whenStable();
expect(checklistComponent.checklist.length).toBe(1); expect(checklistComponent.checklist.length).toBe(1);
const checklistElementRemove = <HTMLElement> element.querySelector('#remove-fake-check-id'); const checklistElementRemove = element.querySelector<HTMLElement>('#remove-fake-check-id');
expect(checklistElementRemove).toBeDefined(); expect(checklistElementRemove).toBeDefined();
expect(checklistElementRemove).not.toBeNull(); expect(checklistElementRemove).not.toBeNull();
checklistElementRemove.click(); checklistElementRemove.click();
@@ -290,7 +290,7 @@ describe('ChecklistComponent', () => {
done(); done();
}); });
showChecklistDialog.click(); showChecklistDialog.click();
const addButtonDialog = <HTMLElement> window.document.querySelector('#add-check'); const addButtonDialog = window.document.querySelector<HTMLElement>('#add-check');
addButtonDialog.click(); addButtonDialog.click();
}); });
}); });

View File

@@ -45,7 +45,7 @@ export class ChecklistComponent implements OnChanges {
/** Emitted when a new checklist task is created. */ /** Emitted when a new checklist task is created. */
@Output() @Output()
checklistTaskCreated: EventEmitter<TaskDetailsModel> = new EventEmitter<TaskDetailsModel>(); checklistTaskCreated = new EventEmitter<TaskDetailsModel>();
/** Emitted when a checklist task is deleted. */ /** Emitted when a checklist task is deleted. */
@Output() @Output()
@@ -53,7 +53,7 @@ export class ChecklistComponent implements OnChanges {
/** Emitted when an error occurs. */ /** Emitted when an error occurs. */
@Output() @Output()
error: EventEmitter<any> = new EventEmitter<any>(); error = new EventEmitter<any>();
@ViewChild('dialog', { static: true }) @ViewChild('dialog', { static: true })
addNewDialog: any; addNewDialog: any;
@@ -62,11 +62,6 @@ export class ChecklistComponent implements OnChanges {
checklist: TaskDetailsModel [] = []; checklist: TaskDetailsModel [] = [];
/**
* Constructor
* @param auth
* @param translate
*/
constructor(private activitiTaskList: TaskListService, constructor(private activitiTaskList: TaskListService,
private dialog: MatDialog) { private dialog: MatDialog) {
} }

View File

@@ -98,7 +98,7 @@ describe('StartTaskComponent', () => {
const successSpy = spyOn(component.success, 'emit'); const successSpy = spyOn(component.success, 'emit');
component.taskForm.controls['name'].setValue('task'); component.taskForm.controls['name'].setValue('task');
fixture.detectChanges(); fixture.detectChanges();
const createTaskButton = <HTMLElement> element.querySelector('#button-start'); const createTaskButton = element.querySelector<HTMLElement>('#button-start');
createTaskButton.click(); createTaskButton.click();
expect(successSpy).toHaveBeenCalled(); expect(successSpy).toHaveBeenCalled();
}); });
@@ -108,7 +108,7 @@ describe('StartTaskComponent', () => {
component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock); component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock);
component.taskForm.controls['name'].setValue('fakeName'); component.taskForm.controls['name'].setValue('fakeName');
fixture.detectChanges(); fixture.detectChanges();
const createTaskButton = <HTMLElement> element.querySelector('#button-start'); const createTaskButton = element.querySelector<HTMLElement>('#button-start');
createTaskButton.click(); createTaskButton.click();
expect(successSpy).toHaveBeenCalledWith({ expect(successSpy).toHaveBeenCalledWith({
id: 91, id: 91,
@@ -123,7 +123,7 @@ describe('StartTaskComponent', () => {
component.appId = 42; component.appId = 42;
component.taskForm.controls['name'].setValue('fakeName'); component.taskForm.controls['name'].setValue('fakeName');
fixture.detectChanges(); fixture.detectChanges();
const createTaskButton = <HTMLElement> element.querySelector('#button-start'); const createTaskButton = element.querySelector<HTMLElement>('#button-start');
createTaskButton.click(); createTaskButton.click();
expect(successSpy).toHaveBeenCalled(); expect(successSpy).toHaveBeenCalled();
}); });
@@ -132,7 +132,7 @@ describe('StartTaskComponent', () => {
const successSpy = spyOn(component.success, 'emit'); const successSpy = spyOn(component.success, 'emit');
component.taskDetailsModel = new TaskDetailsModel(null); component.taskDetailsModel = new TaskDetailsModel(null);
fixture.detectChanges(); fixture.detectChanges();
const createTaskButton = <HTMLElement> element.querySelector('#button-start'); const createTaskButton = element.querySelector<HTMLElement>('#button-start');
createTaskButton.click(); createTaskButton.click();
expect(createNewTaskSpy).not.toHaveBeenCalled(); expect(createNewTaskSpy).not.toHaveBeenCalled();
expect(successSpy).not.toHaveBeenCalled(); expect(successSpy).not.toHaveBeenCalled();
@@ -166,7 +166,7 @@ describe('StartTaskComponent', () => {
component.appId = 42; component.appId = 42;
component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock); component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock);
fixture.detectChanges(); fixture.detectChanges();
const createTaskButton = <HTMLElement> element.querySelector('#button-start'); const createTaskButton = element.querySelector<HTMLElement>('#button-start');
createTaskButton.click(); createTaskButton.click();
expect(successSpy).toHaveBeenCalledWith({ expect(successSpy).toHaveBeenCalledWith({
id: 91, id: 91,
@@ -191,7 +191,7 @@ describe('StartTaskComponent', () => {
component.appId = 42; component.appId = 42;
component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock); component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock);
fixture.detectChanges(); fixture.detectChanges();
const createTaskButton = <HTMLElement> element.querySelector('#button-start'); const createTaskButton = element.querySelector<HTMLElement>('#button-start');
createTaskButton.click(); createTaskButton.click();
expect(successSpy).toHaveBeenCalledWith({ expect(successSpy).toHaveBeenCalledWith({
id: 91, id: 91,
@@ -237,7 +237,7 @@ describe('StartTaskComponent', () => {
component.appId = 42; component.appId = 42;
component.assigneeId = testUser.id; component.assigneeId = testUser.id;
fixture.detectChanges(); fixture.detectChanges();
const createTaskButton = <HTMLElement> element.querySelector('#button-start'); const createTaskButton = element.querySelector<HTMLElement>('#button-start');
createTaskButton.click(); createTaskButton.click();
expect(successSpy).toHaveBeenCalledWith({ expect(successSpy).toHaveBeenCalledWith({
id: 91, id: 91,
@@ -255,7 +255,7 @@ describe('StartTaskComponent', () => {
component.appId = 42; component.appId = 42;
component.getAssigneeId(testUser.id); component.getAssigneeId(testUser.id);
fixture.detectChanges(); fixture.detectChanges();
const createTaskButton = <HTMLElement> element.querySelector('#button-start'); const createTaskButton = element.querySelector<HTMLElement>('#button-start');
createTaskButton.click(); createTaskButton.click();
expect(successSpy).toHaveBeenCalledWith({ expect(successSpy).toHaveBeenCalledWith({
id: 91, id: 91,
@@ -273,7 +273,7 @@ describe('StartTaskComponent', () => {
component.assigneeId = null; component.assigneeId = null;
component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock); component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock);
fixture.detectChanges(); fixture.detectChanges();
const createTaskButton = <HTMLElement> element.querySelector('#button-start'); const createTaskButton = element.querySelector<HTMLElement>('#button-start');
createTaskButton.click(); createTaskButton.click();
expect(successSpy).toHaveBeenCalledWith({ expect(successSpy).toHaveBeenCalledWith({
id: 91, id: 91,
@@ -289,7 +289,7 @@ describe('StartTaskComponent', () => {
spyOn(service, 'createNewTask').and.returnValue(of(new TaskDetailsModel({ id: 'task-id'}))); spyOn(service, 'createNewTask').and.returnValue(of(new TaskDetailsModel({ id: 'task-id'})));
component.taskForm.controls['name'].setValue('fakeName'); component.taskForm.controls['name'].setValue('fakeName');
fixture.detectChanges(); fixture.detectChanges();
const createTaskButton = <HTMLElement> element.querySelector('#button-start'); const createTaskButton = element.querySelector<HTMLElement>('#button-start');
fixture.detectChanges(); fixture.detectChanges();
createTaskButton.click(); createTaskButton.click();
expect(attachFormToATask).not.toHaveBeenCalled(); expect(attachFormToATask).not.toHaveBeenCalled();
@@ -333,7 +333,7 @@ describe('StartTaskComponent', () => {
it('should cancel start task on cancel button click', () => { it('should cancel start task on cancel button click', () => {
const emitSpy = spyOn(component.cancel, 'emit'); const emitSpy = spyOn(component.cancel, 'emit');
const cancelTaskButton = <HTMLElement> element.querySelector('#button-cancel'); const cancelTaskButton = element.querySelector<HTMLElement>('#button-cancel');
fixture.detectChanges(); fixture.detectChanges();
cancelTaskButton.click(); cancelTaskButton.click();
expect(emitSpy).not.toBeNull(); expect(emitSpy).not.toBeNull();
@@ -355,10 +355,10 @@ describe('StartTaskComponent', () => {
}); });
it('should get formatted fullname', () => { it('should get formatted fullname', () => {
const testUser1 = { 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' }; const testUser1 = { id: 1001, firstName: 'Wilbur', lastName: 'Adams', email: 'wilbur@app.activiti.com' };
const testUser2 = { 'id': 1002, 'firstName': '', 'lastName': 'Adams', 'email': 'adams@app.activiti.com' }; const testUser2 = { id: 1002, firstName: '', lastName: 'Adams', email: 'adams@app.activiti.com' };
const testUser3 = { 'id': 1003, 'firstName': 'Wilbur', 'lastName': '', 'email': 'wilbur@app.activiti.com' }; const testUser3 = { id: 1003, firstName: 'Wilbur', lastName: '', email: 'wilbur@app.activiti.com' };
const testUser4 = { 'id': 1004, 'firstName': '', 'lastName': '', 'email': 'test@app.activiti.com' }; const testUser4 = { id: 1004, firstName: '', lastName: '', email: 'test@app.activiti.com' };
const testFullName1 = component.getDisplayUser(testUser1.firstName, testUser1.lastName, ' '); const testFullName1 = component.getDisplayUser(testUser1.firstName, testUser1.lastName, ' ');
const testFullName2 = component.getDisplayUser(testUser2.firstName, testUser2.lastName, ' '); const testFullName2 = component.getDisplayUser(testUser2.firstName, testUser2.lastName, ' ');
@@ -375,7 +375,7 @@ describe('StartTaskComponent', () => {
component.taskForm.controls['name'].setValue('fakeName'); component.taskForm.controls['name'].setValue('fakeName');
const errorSpy = spyOn(component.error, 'emit'); const errorSpy = spyOn(component.error, 'emit');
spyOn(service, 'createNewTask').and.returnValue(throwError({})); spyOn(service, 'createNewTask').and.returnValue(throwError({}));
const createTaskButton = <HTMLElement> element.querySelector('#button-start'); const createTaskButton = element.querySelector<HTMLElement>('#button-start');
fixture.detectChanges(); fixture.detectChanges();
createTaskButton.click(); createTaskButton.click();
expect(errorSpy).toHaveBeenCalled(); expect(errorSpy).toHaveBeenCalled();

View File

@@ -30,6 +30,9 @@ import { TaskListService } from './../services/tasklist.service';
import { switchMap, defaultIfEmpty, takeUntil } from 'rxjs/operators'; import { switchMap, defaultIfEmpty, takeUntil } from 'rxjs/operators';
import { FormBuilder, AbstractControl, Validators, FormGroup, FormControl } from '@angular/forms'; import { FormBuilder, AbstractControl, Validators, FormGroup, FormControl } from '@angular/forms';
const FORMAT_DATE = 'DD/MM/YYYY';
const MAX_LENGTH = 255;
@Component({ @Component({
selector: 'adf-start-task', selector: 'adf-start-task',
templateUrl: './start-task.component.html', templateUrl: './start-task.component.html',
@@ -40,10 +43,6 @@ import { FormBuilder, AbstractControl, Validators, FormGroup, FormControl } from
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class StartTaskComponent implements OnInit, OnDestroy { export class StartTaskComponent implements OnInit, OnDestroy {
public FORMAT_DATE: string = 'DD/MM/YYYY';
MAX_LENGTH: number = 255;
/** (required) The id of the app. */ /** (required) The id of the app. */
@Input() @Input()
appId: number; appId: number;
@@ -54,15 +53,15 @@ export class StartTaskComponent implements OnInit, OnDestroy {
/** Emitted when the task is successfully created. */ /** Emitted when the task is successfully created. */
@Output() @Output()
success: EventEmitter<any> = new EventEmitter<any>(); success = new EventEmitter<any>();
/** Emitted when the cancel button is clicked by the user. */ /** Emitted when the cancel button is clicked by the user. */
@Output() @Output()
cancel: EventEmitter<void> = new EventEmitter<void>(); cancel = new EventEmitter<void>();
/** Emitted when an error occurs. */ /** Emitted when an error occurs. */
@Output() @Output()
error: EventEmitter<any> = new EventEmitter<any>(); error = new EventEmitter<any>();
taskDetailsModel: TaskDetailsModel = new TaskDetailsModel(); taskDetailsModel: TaskDetailsModel = new TaskDetailsModel();
forms$: Observable<Form[]>; forms$: Observable<Form[]>;
@@ -70,17 +69,11 @@ export class StartTaskComponent implements OnInit, OnDestroy {
field: FormFieldModel; field: FormFieldModel;
taskForm: FormGroup; taskForm: FormGroup;
dateError: boolean = false; dateError: boolean = false;
maxTaskNameLength: number = this.MAX_LENGTH; maxTaskNameLength: number = MAX_LENGTH;
loading = false; loading = false;
private onDestroy$ = new Subject<boolean>(); private onDestroy$ = new Subject<boolean>();
/**
* Constructor
* @param auth
* @param translate
* @param taskService
*/
constructor(private taskService: TaskListService, constructor(private taskService: TaskListService,
private dateAdapter: DateAdapter<Moment>, private dateAdapter: DateAdapter<Moment>,
private userPreferencesService: UserPreferencesService, private userPreferencesService: UserPreferencesService,
@@ -127,7 +120,7 @@ export class StartTaskComponent implements OnInit, OnDestroy {
if (control.value) { if (control.value) {
const isWhitespace = (control.value || '').trim().length === 0; const isWhitespace = (control.value || '').trim().length === 0;
const isValid = control.value.length === 0 || !isWhitespace; const isValid = control.value.length === 0 || !isWhitespace;
return isValid ? null : { 'whitespace': true }; return isValid ? null : { whitespace: true };
} }
return null; return null;
} }
@@ -176,38 +169,14 @@ export class StartTaskComponent implements OnInit, OnDestroy {
this.assigneeId = userId; this.assigneeId = userId;
} }
private attachForm(taskId: string, formKey: string): Observable<any> {
let response = of();
if (taskId && formKey) {
response = this.taskService.attachFormToATask(taskId, parseInt(formKey, 10));
}
return response;
}
private assignTaskByUserId(taskId: string, userId: any): Observable<any> {
let response = of();
if (taskId && userId) {
response = this.taskService.assignTaskByUserId(taskId, userId);
}
return response;
}
onCancel(): void { onCancel(): void {
this.cancel.emit(); this.cancel.emit();
} }
private loadFormsTask(): void {
this.forms$ = this.taskService.getFormList();
}
isUserNameEmpty(user: UserProcessModel): boolean { isUserNameEmpty(user: UserProcessModel): boolean {
return !user || (this.isEmpty(user.firstName) && this.isEmpty(user.lastName)); return !user || (this.isEmpty(user.firstName) && this.isEmpty(user.lastName));
} }
private isEmpty(data: string): boolean {
return data === undefined || data === null || data.trim().length === 0;
}
getDisplayUser(firstName: string, lastName: string, delimiter: string = '-'): string { getDisplayUser(firstName: string, lastName: string, delimiter: string = '-'): string {
firstName = (firstName !== null ? firstName : ''); firstName = (firstName !== null ? firstName : '');
lastName = (lastName !== null ? lastName : ''); lastName = (lastName !== null ? lastName : '');
@@ -221,7 +190,7 @@ export class StartTaskComponent implements OnInit, OnDestroy {
let momentDate: moment.Moment; let momentDate: moment.Moment;
if (typeof newDateValue === 'string') { if (typeof newDateValue === 'string') {
momentDate = moment(newDateValue, this.FORMAT_DATE, true); momentDate = moment(newDateValue, FORMAT_DATE, true);
} else { } else {
momentDate = newDateValue; momentDate = newDateValue;
} }
@@ -238,9 +207,9 @@ export class StartTaskComponent implements OnInit, OnDestroy {
} }
private validateMaxTaskNameLength() { private validateMaxTaskNameLength() {
if (this.maxTaskNameLength > this.MAX_LENGTH) { if (this.maxTaskNameLength > MAX_LENGTH) {
this.maxTaskNameLength = this.MAX_LENGTH; this.maxTaskNameLength = MAX_LENGTH;
this.logService.log(`the task name length cannot be greater than ${this.MAX_LENGTH}`); this.logService.log(`the task name length cannot be greater than ${MAX_LENGTH}`);
} }
} }
@@ -255,4 +224,28 @@ export class StartTaskComponent implements OnInit, OnDestroy {
get formKeyController(): AbstractControl { get formKeyController(): AbstractControl {
return this.taskForm.get('formKey'); return this.taskForm.get('formKey');
} }
private attachForm(taskId: string, formKey: string): Observable<any> {
let response = of();
if (taskId && formKey) {
response = this.taskService.attachFormToATask(taskId, parseInt(formKey, 10));
}
return response;
}
private assignTaskByUserId(taskId: string, userId: any): Observable<any> {
let response = of();
if (taskId && userId) {
response = this.taskService.assignTaskByUserId(taskId, userId);
}
return response;
}
private loadFormsTask(): void {
this.forms$ = this.taskService.getFormList();
}
private isEmpty(data: string): boolean {
return data === undefined || data === null || data.trim().length === 0;
}
} }

View File

@@ -52,7 +52,7 @@ describe('TaskAuditDirective', () => {
let component: BasicButtonComponent; let component: BasicButtonComponent;
let service: TaskListService; let service: TaskListService;
function createFakePdfBlob(): Blob { const createFakePdfBlob = (): Blob => {
const pdfData = atob( const pdfData = atob(
'JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwog' + 'JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwog' +
'IC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAv' + 'IC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAv' +
@@ -68,7 +68,7 @@ describe('TaskAuditDirective', () => {
'MDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9v' + 'MDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9v' +
'dCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G'); 'dCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G');
return new Blob([pdfData], {type: 'application/pdf'}); return new Blob([pdfData], {type: 'application/pdf'});
} };
setupTestBed({ setupTestBed({
imports: [ imports: [

View File

@@ -28,7 +28,7 @@ const PDF_FORMAT: string = 'pdf';
// eslint-disable-next-line @angular-eslint/directive-selector // eslint-disable-next-line @angular-eslint/directive-selector
selector: 'button[adf-task-audit]', selector: 'button[adf-task-audit]',
host: { host: {
'role': 'button', role: 'button',
'(click)': 'onClickAudit()' '(click)': 'onClickAudit()'
} }
}) })

View File

@@ -208,7 +208,7 @@ describe('TaskDetailsComponent', () => {
}); });
it('should fetch new task details when taskId changed', () => { it('should fetch new task details when taskId changed', () => {
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
expect(getTaskDetailsSpy).toHaveBeenCalledWith('456'); expect(getTaskDetailsSpy).toHaveBeenCalledWith('456');
}); });
@@ -223,13 +223,13 @@ describe('TaskDetailsComponent', () => {
it('should NOT fetch new task details when taskId changed to null', fakeAsync(() => { it('should NOT fetch new task details when taskId changed to null', fakeAsync(() => {
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
component.ngOnChanges({ 'taskId': nullChange }); component.ngOnChanges({ taskId: nullChange });
expect(getTaskDetailsSpy).not.toHaveBeenCalled(); expect(getTaskDetailsSpy).not.toHaveBeenCalled();
}); });
})); }));
it('should set a placeholder message when taskId changed to null', () => { it('should set a placeholder message when taskId changed to null', () => {
component.ngOnChanges({ 'taskId': nullChange }); component.ngOnChanges({ taskId: nullChange });
fixture.detectChanges(); fixture.detectChanges();
expect(fixture.nativeElement.innerText).toBe('ADF_TASK_LIST.DETAILS.MESSAGES.NONE'); expect(fixture.nativeElement.innerText).toBe('ADF_TASK_LIST.DETAILS.MESSAGES.NONE');
}); });
@@ -243,7 +243,7 @@ describe('TaskDetailsComponent', () => {
}); });
afterEach(() => { afterEach(() => {
const overlayContainers = <any> window.document.querySelectorAll('.cdk-overlay-container'); const overlayContainers = window.document.querySelectorAll('.cdk-overlay-container');
overlayContainers.forEach((overlayContainer) => { overlayContainers.forEach((overlayContainer) => {
overlayContainer.innerHTML = ''; overlayContainer.innerHTML = '';
@@ -340,7 +340,7 @@ describe('TaskDetailsComponent', () => {
it('should comments be readonly if the task is complete and no user are involved', () => { it('should comments be readonly if the task is complete and no user are involved', () => {
component.showComments = true; component.showComments = true;
component.showHeaderContent = true; component.showHeaderContent = true;
component.ngOnChanges({ 'taskId': new SimpleChange('123', '456', true) }); component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) });
component.taskPeople = []; component.taskPeople = [];
component.taskDetails = new TaskDetailsModel(taskDetailsMock); component.taskDetails = new TaskDetailsModel(taskDetailsMock);
component.taskDetails.endDate = new Date('2017-10-03T17:03:57.311+0000'); component.taskDetails.endDate = new Date('2017-10-03T17:03:57.311+0000');
@@ -352,7 +352,7 @@ describe('TaskDetailsComponent', () => {
it('should comments be readonly if the task is complete and user are NOT involved', () => { it('should comments be readonly if the task is complete and user are NOT involved', () => {
component.showComments = true; component.showComments = true;
component.showHeaderContent = true; component.showHeaderContent = true;
component.ngOnChanges({ 'taskId': new SimpleChange('123', '456', true) }); component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) });
component.taskPeople = []; component.taskPeople = [];
component.taskDetails = new TaskDetailsModel(taskDetailsMock); component.taskDetails = new TaskDetailsModel(taskDetailsMock);
component.taskDetails.endDate = new Date('2017-10-03T17:03:57.311+0000'); component.taskDetails.endDate = new Date('2017-10-03T17:03:57.311+0000');
@@ -364,7 +364,7 @@ describe('TaskDetailsComponent', () => {
it('should comments NOT be readonly if the task is NOT complete and user are NOT involved', () => { it('should comments NOT be readonly if the task is NOT complete and user are NOT involved', () => {
component.showComments = true; component.showComments = true;
component.showHeaderContent = true; component.showHeaderContent = true;
component.ngOnChanges({ 'taskId': new SimpleChange('123', '456', true) }); component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) });
component.taskPeople = [fakeUser]; component.taskPeople = [fakeUser];
component.taskDetails = new TaskDetailsModel(taskDetailsMock); component.taskDetails = new TaskDetailsModel(taskDetailsMock);
component.taskDetails.endDate = null; component.taskDetails.endDate = null;
@@ -376,7 +376,7 @@ describe('TaskDetailsComponent', () => {
it('should comments NOT be readonly if the task is complete and user are involved', () => { it('should comments NOT be readonly if the task is complete and user are involved', () => {
component.showComments = true; component.showComments = true;
component.showHeaderContent = true; component.showHeaderContent = true;
component.ngOnChanges({ 'taskId': new SimpleChange('123', '456', true) }); component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) });
component.taskPeople = [fakeUser]; component.taskPeople = [fakeUser];
component.taskDetails = new TaskDetailsModel(taskDetailsMock); component.taskDetails = new TaskDetailsModel(taskDetailsMock);
component.taskDetails.endDate = new Date('2017-10-03T17:03:57.311+0000'); component.taskDetails.endDate = new Date('2017-10-03T17:03:57.311+0000');
@@ -388,7 +388,7 @@ describe('TaskDetailsComponent', () => {
it('should comments be present if showComments is true', () => { it('should comments be present if showComments is true', () => {
component.showComments = true; component.showComments = true;
component.showHeaderContent = true; component.showHeaderContent = true;
component.ngOnChanges({ 'taskId': new SimpleChange('123', '456', true) }); component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) });
component.taskPeople = []; component.taskPeople = [];
component.taskDetails = new TaskDetailsModel(taskDetailsMock); component.taskDetails = new TaskDetailsModel(taskDetailsMock);
@@ -398,7 +398,7 @@ describe('TaskDetailsComponent', () => {
it('should comments NOT be present if showComments is false', () => { it('should comments NOT be present if showComments is false', () => {
component.showComments = false; component.showComments = false;
component.ngOnChanges({ 'taskId': new SimpleChange('123', '456', true) }); component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) });
component.taskPeople = []; component.taskPeople = [];
component.taskDetails = new TaskDetailsModel(taskDetailsMock); component.taskDetails = new TaskDetailsModel(taskDetailsMock);

View File

@@ -123,23 +123,23 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy {
/** Emitted when the form is submitted with the `Save` or custom outcomes. */ /** Emitted when the form is submitted with the `Save` or custom outcomes. */
@Output() @Output()
formSaved: EventEmitter<FormModel> = new EventEmitter<FormModel>(); formSaved = new EventEmitter<FormModel>();
/** Emitted when the form is submitted with the `Complete` outcome. */ /** Emitted when the form is submitted with the `Complete` outcome. */
@Output() @Output()
formCompleted: EventEmitter<FormModel> = new EventEmitter<FormModel>(); formCompleted = new EventEmitter<FormModel>();
/** Emitted when the form field content is clicked. */ /** Emitted when the form field content is clicked. */
@Output() @Output()
formContentClicked: EventEmitter<ContentLinkModel> = new EventEmitter<ContentLinkModel>(); formContentClicked = new EventEmitter<ContentLinkModel>();
/** Emitted when the form is loaded or reloaded. */ /** Emitted when the form is loaded or reloaded. */
@Output() @Output()
formLoaded: EventEmitter<FormModel> = new EventEmitter<FormModel>(); formLoaded = new EventEmitter<FormModel>();
/** Emitted when a checklist task is created. */ /** Emitted when a checklist task is created. */
@Output() @Output()
taskCreated: EventEmitter<TaskDetailsModel> = new EventEmitter<TaskDetailsModel>(); taskCreated = new EventEmitter<TaskDetailsModel>();
/** Emitted when a checklist task is deleted. */ /** Emitted when a checklist task is deleted. */
@Output() @Output()
@@ -147,13 +147,13 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy {
/** Emitted when an error occurs. */ /** Emitted when an error occurs. */
@Output() @Output()
error: EventEmitter<any> = new EventEmitter<any>(); error = new EventEmitter<any>();
/** Emitted when any outcome is executed. Default behaviour can be prevented /** Emitted when any outcome is executed. Default behaviour can be prevented
* via `event.preventDefault()`. * via `event.preventDefault()`.
*/ */
@Output() @Output()
executeOutcome: EventEmitter<FormOutcomeEvent> = new EventEmitter<FormOutcomeEvent>(); executeOutcome = new EventEmitter<FormOutcomeEvent>();
/** Emitted when a task is assigned. */ /** Emitted when a task is assigned. */
@Output() @Output()
@@ -161,11 +161,11 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy {
/** Emitted when a task is claimed. */ /** Emitted when a task is claimed. */
@Output() @Output()
claimedTask: EventEmitter<string> = new EventEmitter<string>(); claimedTask = new EventEmitter<string>();
/** Emitted when a task is unclaimed. */ /** Emitted when a task is unclaimed. */
@Output() @Output()
unClaimedTask: EventEmitter<string> = new EventEmitter<string>(); unClaimedTask = new EventEmitter<string>();
taskDetails: TaskDetailsModel; taskDetails: TaskDetailsModel;
taskFormName: string = null; taskFormName: string = null;
@@ -174,15 +174,13 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy {
showAssignee: boolean = false; showAssignee: boolean = false;
showAttachForm: boolean = false; showAttachForm: boolean = false;
internalReadOnlyForm: boolean = false; internalReadOnlyForm: boolean = false;
errorDialogRef: MatDialogRef<TemplateRef<any>>;
peopleSearch: Observable<UserProcessModel[]>;
data: any;
private peopleSearchObserver: Observer<UserProcessModel[]>; private peopleSearchObserver: Observer<UserProcessModel[]>;
public errorDialogRef: MatDialogRef<TemplateRef<any>>;
private onDestroy$ = new Subject<boolean>(); private onDestroy$ = new Subject<boolean>();
peopleSearch: Observable<UserProcessModel[]>;
data: any;
constructor(private taskListService: TaskListService, constructor(private taskListService: TaskListService,
private peopleProcessService: PeopleProcessService, private peopleProcessService: PeopleProcessService,
private logService: LogService, private logService: LogService,
@@ -226,102 +224,14 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy {
return this.showAttachForm; return this.showAttachForm;
} }
/**
* Reset the task details
*/
private reset() {
this.taskDetails = null;
}
isTaskActive() { isTaskActive() {
return this.taskDetails && this.taskDetails.duration === null; return this.taskDetails && this.taskDetails.duration === null;
} }
/**
* Save a task detail and update it after a successful response
*
* @param updateNotification
*/
private updateTaskDetails(updateNotification: UpdateNotification) {
this.taskListService
.updateTask(this.taskId, updateNotification.changed)
.pipe(catchError(() => {
this.cardViewUpdateService.updateElement(updateNotification.target);
return of(null);
}))
.subscribe(() => this.loadDetails(this.taskId));
}
private clickTaskDetails(clickNotification: ClickNotification) {
if (clickNotification.target.key === 'assignee') {
this.showAssignee = true;
}
if (clickNotification.target.key === 'formName') {
this.showAttachForm = true;
}
}
/**
* Load the activiti task details
* @param taskId
*/
private loadDetails(taskId: string) {
this.taskPeople = [];
if (taskId) {
this.taskListService.getTaskDetails(taskId).subscribe(
(res: TaskDetailsModel) => {
this.showAttachForm = false;
this.taskDetails = res;
if (this.taskDetails.name === 'null') {
this.taskDetails.name = 'No name';
}
const endDate: any = res.endDate;
if (endDate && !isNaN(endDate.getTime())) {
this.internalReadOnlyForm = true;
} else {
this.internalReadOnlyForm = this.readOnlyForm;
}
if (this.taskDetails && this.taskDetails.involvedPeople) {
this.taskDetails.involvedPeople.forEach((user) => {
this.taskPeople.push(new UserProcessModel(user));
});
}
});
}
}
isAssigned(): boolean { isAssigned(): boolean {
return !!this.taskDetails.assignee; return !!this.taskDetails.assignee;
} }
/**
* Retrieve the next open task
* @param processInstanceId
* @param processDefinitionId
*/
private loadNextTask(processInstanceId: string, processDefinitionId: string): void {
const requestNode = new TaskQueryRequestRepresentationModel(
{
processInstanceId: processInstanceId,
processDefinitionId: processDefinitionId
}
);
this.taskListService.getTasks(requestNode).subscribe(
(response) => {
if (response && response.length > 0) {
this.taskDetails = new TaskDetailsModel(response[0]);
} else {
this.reset();
}
}, (error) => {
this.error.emit(error);
});
}
/** /**
* Complete button clicked * Complete button clicked
*/ */
@@ -431,4 +341,75 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy {
isReadOnlyComment(): boolean { isReadOnlyComment(): boolean {
return (this.taskDetails && this.taskDetails.isCompleted()) && (this.taskPeople && this.taskPeople.length === 0); return (this.taskDetails && this.taskDetails.isCompleted()) && (this.taskPeople && this.taskPeople.length === 0);
} }
private reset() {
this.taskDetails = null;
}
private updateTaskDetails(updateNotification: UpdateNotification) {
this.taskListService
.updateTask(this.taskId, updateNotification.changed)
.pipe(catchError(() => {
this.cardViewUpdateService.updateElement(updateNotification.target);
return of(null);
}))
.subscribe(() => this.loadDetails(this.taskId));
}
private clickTaskDetails(clickNotification: ClickNotification) {
if (clickNotification.target.key === 'assignee') {
this.showAssignee = true;
}
if (clickNotification.target.key === 'formName') {
this.showAttachForm = true;
}
}
private loadDetails(taskId: string) {
this.taskPeople = [];
if (taskId) {
this.taskListService.getTaskDetails(taskId).subscribe(
(res: TaskDetailsModel) => {
this.showAttachForm = false;
this.taskDetails = res;
if (this.taskDetails.name === 'null') {
this.taskDetails.name = 'No name';
}
const endDate: any = res.endDate;
if (endDate && !isNaN(endDate.getTime())) {
this.internalReadOnlyForm = true;
} else {
this.internalReadOnlyForm = this.readOnlyForm;
}
if (this.taskDetails && this.taskDetails.involvedPeople) {
this.taskDetails.involvedPeople.forEach((user) => {
this.taskPeople.push(new UserProcessModel(user));
});
}
});
}
}
private loadNextTask(processInstanceId: string, processDefinitionId: string): void {
const requestNode = new TaskQueryRequestRepresentationModel(
{
processInstanceId,
processDefinitionId
}
);
this.taskListService.getTasks(requestNode).subscribe(
(response) => {
if (response && response.length > 0) {
this.taskDetails = new TaskDetailsModel(response[0]);
} else {
this.reset();
}
}, (error) => {
this.error.emit(error);
});
}
} }

View File

@@ -64,7 +64,7 @@ describe('TaskFiltersComponent', () => {
const appId = '1'; const appId = '1';
const change = new SimpleChange(null, appId, true); const change = new SimpleChange(null, appId, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
component.error.subscribe((err) => { component.error.subscribe((err) => {
expect(err).toBeDefined(); expect(err).toBeDefined();
@@ -88,7 +88,7 @@ describe('TaskFiltersComponent', () => {
}); });
component.ngOnInit(); component.ngOnInit();
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -100,7 +100,7 @@ describe('TaskFiltersComponent', () => {
const createDefaultFiltersSpy = spyOn(taskFilterService, 'createDefaultFilters').and.returnValue(of(filtersMock)); const createDefaultFiltersSpy = spyOn(taskFilterService, 'createDefaultFilters').and.returnValue(of(filtersMock));
const appId = '2'; const appId = '2';
const change = new SimpleChange(null, appId, true); const change = new SimpleChange(null, appId, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
expect(createDefaultFiltersSpy).toHaveBeenCalledWith(appId); expect(createDefaultFiltersSpy).toHaveBeenCalledWith(appId);
@@ -120,7 +120,7 @@ describe('TaskFiltersComponent', () => {
}); });
component.ngOnInit(); component.ngOnInit();
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -142,7 +142,7 @@ describe('TaskFiltersComponent', () => {
done(); done();
}); });
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
}); });
@@ -161,7 +161,7 @@ describe('TaskFiltersComponent', () => {
done(); done();
}); });
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
}); });
@@ -181,7 +181,7 @@ describe('TaskFiltersComponent', () => {
done(); done();
}); });
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
}); });
@@ -201,7 +201,7 @@ describe('TaskFiltersComponent', () => {
done(); done();
}); });
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
}); });
@@ -214,7 +214,7 @@ describe('TaskFiltersComponent', () => {
const change = new SimpleChange(null, filterParam, true); const change = new SimpleChange(null, filterParam, true);
component.filterParam = filterParam; component.filterParam = filterParam;
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
fixture.detectChanges(); fixture.detectChanges();
expect(component.filterSelected.emit).toHaveBeenCalledWith(fakeTaskFilters[0]); expect(component.filterSelected.emit).toHaveBeenCalledWith(fakeTaskFilters[0]);
@@ -238,7 +238,7 @@ describe('TaskFiltersComponent', () => {
const appId = '1'; const appId = '1';
const change = new SimpleChange(null, appId, true); const change = new SimpleChange(null, appId, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
expect(component.getFiltersByAppId).toHaveBeenCalledWith(appId); expect(component.getFiltersByAppId).toHaveBeenCalledWith(appId);
}); });
@@ -248,7 +248,7 @@ describe('TaskFiltersComponent', () => {
const appId = null; const appId = null;
const change = new SimpleChange(undefined, appId, true); const change = new SimpleChange(undefined, appId, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
expect(component.getFiltersByAppId).toHaveBeenCalledWith(appId); expect(component.getFiltersByAppId).toHaveBeenCalledWith(appId);
}); });
@@ -261,7 +261,7 @@ describe('TaskFiltersComponent', () => {
expect(component.currentFilter.id).toEqual(fakeTaskFilters[2].id); expect(component.currentFilter.id).toEqual(fakeTaskFilters[2].id);
}); });
const change = new SimpleChange(null, { id: fakeTaskFilters[2].id }, true); const change = new SimpleChange(null, { id: fakeTaskFilters[2].id }, true);
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
}); });
it('should change current filter when filterParam (name) changes', async () => { it('should change current filter when filterParam (name) changes', async () => {
@@ -273,7 +273,7 @@ describe('TaskFiltersComponent', () => {
}); });
const change = new SimpleChange(null, { name: fakeTaskFilters[2].name }, true); const change = new SimpleChange(null, { name: fakeTaskFilters[2].name }, true);
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
}); });
it('should reload filters by app name on binding changes', () => { it('should reload filters by app name on binding changes', () => {
@@ -281,7 +281,7 @@ describe('TaskFiltersComponent', () => {
const appName = 'fake-app-name'; const appName = 'fake-app-name';
const change = new SimpleChange(null, appName, true); const change = new SimpleChange(null, appName, true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
expect(component.getFiltersByAppName).toHaveBeenCalledWith(appName); expect(component.getFiltersByAppName).toHaveBeenCalledWith(appName);
}); });
@@ -298,7 +298,7 @@ describe('TaskFiltersComponent', () => {
spyOn(component, 'getFiltersByAppId').and.stub(); spyOn(component, 'getFiltersByAppId').and.stub();
const change = new SimpleChange(undefined, null, true); const change = new SimpleChange(undefined, null, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
expect(component.getFiltersByAppId).toHaveBeenCalled(); expect(component.getFiltersByAppId).toHaveBeenCalled();
}); });
@@ -320,7 +320,7 @@ describe('TaskFiltersComponent', () => {
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters)); spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
component.showIcon = true; component.showIcon = true;
const change = new SimpleChange(undefined, 1, true); const change = new SimpleChange(undefined, 1, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
fixture.detectChanges(); fixture.detectChanges();
@@ -338,7 +338,7 @@ describe('TaskFiltersComponent', () => {
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters)); spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
component.showIcon = false; component.showIcon = false;
const change = new SimpleChange(undefined, 1, true); const change = new SimpleChange(undefined, 1, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
fixture.detectChanges(); fixture.detectChanges();
@@ -354,7 +354,7 @@ describe('TaskFiltersComponent', () => {
component.filterParam = new FilterRepresentationModel( {name: 'non-existing-filter'}); component.filterParam = new FilterRepresentationModel( {name: 'non-existing-filter'});
const appId = '1'; const appId = '1';
const change = new SimpleChange(null, appId, true); const change = new SimpleChange(null, appId, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
expect(component.currentFilter).toBe(undefined); expect(component.currentFilter).toBe(undefined);
@@ -372,7 +372,7 @@ describe('TaskFiltersComponent', () => {
spyOn(taskFilterService, 'createDefaultFilters').and.returnValue(of(defaultTaskFiltersMock)); spyOn(taskFilterService, 'createDefaultFilters').and.returnValue(of(defaultTaskFiltersMock));
const appId = '2'; const appId = '2';
const change = new SimpleChange(null, appId, true); const change = new SimpleChange(null, appId, true);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
fixture.detectChanges(); fixture.detectChanges();

View File

@@ -240,6 +240,13 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
return this.filters === undefined || (this.filters && this.filters.length === 0); return this.filters === undefined || (this.filters && this.filters.length === 0);
} }
/**
* Return current filter icon
*/
getFilterIcon(icon): string {
return this.iconsMDL.mapGlyphiconToMaterialDesignIcons(icon);
}
/** /**
* Reset the filters properties * Reset the filters properties
*/ */
@@ -247,11 +254,4 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
this.filters = []; this.filters = [];
this.currentFilter = undefined; this.currentFilter = undefined;
} }
/**
* Return current filter icon
*/
getFilterIcon(icon): string {
return this.iconsMDL.mapGlyphiconToMaterialDesignIcons(icon);
}
} }

View File

@@ -29,9 +29,10 @@ describe('ClaimTaskDirective', () => {
template: '<button adf-claim-task [taskId]="taskId" (success)="onClaim($event)">Claim</button>' template: '<button adf-claim-task [taskId]="taskId" (success)="onClaim($event)">Claim</button>'
}) })
class TestComponent { class TestComponent {
taskId = 'test1234';
@Output() @Output()
claim: EventEmitter<any> = new EventEmitter<any>(); claim = new EventEmitter<any>();
taskId = 'test1234';
onClaim(event) { onClaim(event) {
this.claim.emit(event); this.claim.emit(event);

View File

@@ -49,6 +49,15 @@ export class ClaimTaskDirective implements OnInit {
private taskListService: TaskListService, private taskListService: TaskListService,
private logService: LogService) {} private logService: LogService) {}
@HostListener('click')
onClick() {
try {
this.claimTask();
} catch (error) {
this.error.emit(error);
}
}
ngOnInit() { ngOnInit() {
this.validateInputs(); this.validateInputs();
} }
@@ -69,15 +78,6 @@ export class ClaimTaskDirective implements OnInit {
return this.taskId && this.taskId.length > 0; return this.taskId && this.taskId.length > 0;
} }
@HostListener('click')
onClick() {
try {
this.claimTask();
} catch (error) {
this.error.emit(error);
}
}
private claimTask() { private claimTask() {
this.taskListService.claimTask(this.taskId).subscribe( this.taskListService.claimTask(this.taskId).subscribe(
() => { () => {

View File

@@ -163,14 +163,14 @@ describe('TaskFormComponent', () => {
it('should fetch new task details when taskId changed', () => { it('should fetch new task details when taskId changed', () => {
const change = new SimpleChange('123', '456', true); const change = new SimpleChange('123', '456', true);
component.ngOnChanges({ 'taskId': change }); component.ngOnChanges({ taskId: change });
fixture.detectChanges(); fixture.detectChanges();
expect(getTaskDetailsSpy).toHaveBeenCalledWith('123'); expect(getTaskDetailsSpy).toHaveBeenCalledWith('123');
}); });
it('should NOT fetch new task details when taskId changed to null', async () => { it('should NOT fetch new task details when taskId changed to null', async () => {
const nullChange = new SimpleChange('123', null, true); const nullChange = new SimpleChange('123', null, true);
component.ngOnChanges({ 'taskId': nullChange }); component.ngOnChanges({ taskId: nullChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
expect(getTaskDetailsSpy).not.toHaveBeenCalled(); expect(getTaskDetailsSpy).not.toHaveBeenCalled();

View File

@@ -94,7 +94,7 @@ export class TaskFormComponent implements OnInit, OnChanges {
/** Emitted when the form associated with the form task is attached. */ /** Emitted when the form associated with the form task is attached. */
@Output() @Output()
showAttachForm: EventEmitter<void> = new EventEmitter<void>(); showAttachForm = new EventEmitter<void>();
/** Emitted when any outcome is executed. Default behaviour can be prevented /** Emitted when any outcome is executed. Default behaviour can be prevented
* via `event.preventDefault()`. * via `event.preventDefault()`.
@@ -108,7 +108,7 @@ export class TaskFormComponent implements OnInit, OnChanges {
/** Emitted when the supplied form values have a validation error. */ /** Emitted when the supplied form values have a validation error. */
@Output() @Output()
formError: EventEmitter<FormFieldModel[]> = new EventEmitter<FormFieldModel[]>(); formError = new EventEmitter<FormFieldModel[]>();
/** Emitted when an error occurs. */ /** Emitted when an error occurs. */
@Output() @Output()
@@ -246,24 +246,12 @@ export class TaskFormComponent implements OnInit, OnChanges {
return !!this.taskDetails.assignee; return !!this.taskDetails.assignee;
} }
private hasEmailAddress(): boolean {
return this.taskDetails.assignee.email ? true : false;
}
isAssignedToMe(): boolean { isAssignedToMe(): boolean {
return this.isAssigned() && this.hasEmailAddress() ? return this.isAssigned() && this.hasEmailAddress() ?
this.isEmailEqual() : this.isEmailEqual() :
this.isExternalIdEqual(); this.isExternalIdEqual();
} }
private isEmailEqual(): boolean {
return (this.taskDetails.assignee && this.currentLoggedUser) && ( this.taskDetails.assignee.email.toLocaleLowerCase() === this.currentLoggedUser.email.toLocaleLowerCase());
}
private isExternalIdEqual(): boolean {
return (this.taskDetails.assignee && this.currentLoggedUser) && (this.taskDetails.assignee.externalId === this.currentLoggedUser.externalId);
}
isCompleteButtonEnabled(): boolean { isCompleteButtonEnabled(): boolean {
return this.isAssignedToMe() || this.canInitiatorComplete(); return this.isAssignedToMe() || this.canInitiatorComplete();
} }
@@ -357,4 +345,16 @@ export class TaskFormComponent implements OnInit, OnChanges {
onUnclaimTaskError(error: any) { onUnclaimTaskError(error: any) {
this.error.emit(error); this.error.emit(error);
} }
private hasEmailAddress(): boolean {
return this.taskDetails.assignee.email ? true : false;
}
private isEmailEqual(): boolean {
return (this.taskDetails.assignee && this.currentLoggedUser) && ( this.taskDetails.assignee.email.toLocaleLowerCase() === this.currentLoggedUser.email.toLocaleLowerCase());
}
private isExternalIdEqual(): boolean {
return (this.taskDetails.assignee && this.currentLoggedUser) && (this.taskDetails.assignee.externalId === this.currentLoggedUser.externalId);
}
} }

View File

@@ -29,9 +29,10 @@ describe('UnclaimTaskDirective', () => {
template: '<button adf-unclaim-task [taskId]="taskId" (success)="onUnclaim($event)">Unclaim</button>' template: '<button adf-unclaim-task [taskId]="taskId" (success)="onUnclaim($event)">Unclaim</button>'
}) })
class TestComponent { class TestComponent {
taskId = 'test1234';
@Output() @Output()
unclaim: EventEmitter<any> = new EventEmitter<any>(); unclaim = new EventEmitter<any>();
taskId = 'test1234';
onUnclaim(event) { onUnclaim(event) {
this.unclaim.emit(event); this.unclaim.emit(event);

View File

@@ -37,11 +37,11 @@ export class UnclaimTaskDirective implements OnInit {
/** Emitted when the task is released. */ /** Emitted when the task is released. */
@Output() @Output()
success: EventEmitter<any> = new EventEmitter<any>(); success = new EventEmitter<any>();
/** Emitted when the task cannot be released. */ /** Emitted when the task cannot be released. */
@Output() @Output()
error: EventEmitter<any> = new EventEmitter<any>(); error = new EventEmitter<any>();
invalidParams: string[] = []; invalidParams: string[] = [];
@@ -49,6 +49,15 @@ export class UnclaimTaskDirective implements OnInit {
private taskListService: TaskListService, private taskListService: TaskListService,
private logService: LogService) {} private logService: LogService) {}
@HostListener('click')
onClick() {
try {
this.unclaimTask();
} catch (error) {
this.error.emit(error);
}
}
ngOnInit() { ngOnInit() {
this.validateInputs(); this.validateInputs();
} }
@@ -68,15 +77,6 @@ export class UnclaimTaskDirective implements OnInit {
return this.taskId && this.taskId.length > 0; return this.taskId && this.taskId.length > 0;
} }
@HostListener('click')
onClick() {
try {
this.unclaimTask();
} catch (error) {
this.error.emit(error);
}
}
private unclaimTask() { private unclaimTask() {
this.taskListService.unclaimTask(this.taskId).subscribe( this.taskListService.unclaimTask(this.taskId).subscribe(
() => { () => {

View File

@@ -58,14 +58,14 @@ export class TaskHeaderComponent implements OnChanges, OnInit {
@Output() @Output()
unclaim: EventEmitter<any> = new EventEmitter<any>(); unclaim: EventEmitter<any> = new EventEmitter<any>();
private currentUserId: number;
properties: any [] = []; properties: any [] = [];
inEdit: boolean = false; inEdit: boolean = false;
displayDateClearAction = false; displayDateClearAction = false;
dateFormat: string; dateFormat: string;
dateLocale: string; dateLocale: string;
private currentUserId: number;
constructor(private bpmUserService: BpmUserService, constructor(private bpmUserService: BpmUserService,
private translationService: TranslationService, private translationService: TranslationService,
private appConfig: AppConfigService) { private appConfig: AppConfigService) {
@@ -87,6 +87,120 @@ export class TaskHeaderComponent implements OnChanges, OnInit {
} }
} }
/**
* Refresh the card data
*/
initData() {
if (this.taskDetails) {
const parentInfoMap = this.getParentInfo();
const defaultProperties = this.initDefaultProperties(parentInfoMap);
const filteredProperties: string[] = this.appConfig.get('adf-task-header.presets.properties');
this.properties = defaultProperties.filter((cardItem) => this.isValidSelection(filteredProperties, cardItem));
}
}
/**
* Refresh the card data
*/
refreshData() {
this.properties = this.properties.map((cardItem) => {
if (cardItem.key === 'formName' && cardItem.value !== this.formName) {
return new CardViewTextItemModel({
label: 'ADF_TASK_LIST.PROPERTIES.FORM_NAME',
value: this.formName,
key: 'formName',
default: this.translationService.instant('ADF_TASK_LIST.PROPERTIES.FORM_NAME_DEFAULT'),
clickable: this.isFormClickable(),
icon: 'create'
});
} else {
return cardItem;
}
});
}
/**
* Return the process parent information
*/
getParentInfo(): Map<string, string> {
if (this.taskDetails.processInstanceId && this.taskDetails.processDefinitionName) {
return new Map([[this.taskDetails.processInstanceId, this.taskDetails.processDefinitionName]]);
}
return new Map();
}
/**
* Does the task have an assignee
*/
hasAssignee(): boolean {
return !!this.taskDetails.assignee;
}
/**
* Returns true if the task is assigned to logged in user
*/
isAssignedTo(userId: number): boolean {
return this.hasAssignee() ? this.taskDetails.assignee.id === userId : false;
}
/**
* Return true if the task assigned
*/
isAssignedToCurrentUser(): boolean {
return this.hasAssignee() && this.isAssignedTo(this.currentUserId);
}
/**
* Return true if the user is a candidate member
*/
isCandidateMember(): boolean {
return this.taskDetails.managerOfCandidateGroup || this.taskDetails.memberOfCandidateGroup || this.taskDetails.memberOfCandidateUsers;
}
/**
* Return true if the task claimable
*/
isTaskClaimable(): boolean {
return !this.hasAssignee() && this.isCandidateMember();
}
/**
* Return true if the task claimed by candidate member.
*/
isTaskClaimedByCandidateMember(): boolean {
return this.isCandidateMember() && this.isAssignedToCurrentUser() && !this.isCompleted();
}
/**
* Returns task's status
*/
getTaskStatus(): string {
return (this.taskDetails && this.taskDetails.isCompleted()) ? 'Completed' : 'Running';
}
onClaimTask(taskId: string) {
this.claim.emit(taskId);
}
onUnclaimTask(taskId: string) {
this.unclaim.emit(taskId);
}
/**
* Returns true if the task is completed
*/
isCompleted(): boolean {
return this.taskDetails && !!this.taskDetails.endDate;
}
isFormClickable(): boolean {
return !!this.formName && !this.isCompleted();
}
getTaskDuration(): string {
return this.taskDetails.duration ? `${this.taskDetails.duration} ms` : '';
}
private initDefaultProperties(parentInfoMap): any[] { private initDefaultProperties(parentInfoMap): any[] {
return [ return [
new CardViewTextItemModel( new CardViewTextItemModel(
@@ -206,38 +320,6 @@ export class TaskHeaderComponent implements OnChanges, OnInit {
]; ];
} }
/**
* Refresh the card data
*/
initData() {
if (this.taskDetails) {
const parentInfoMap = this.getParentInfo();
const defaultProperties = this.initDefaultProperties(parentInfoMap);
const filteredProperties: string[] = this.appConfig.get('adf-task-header.presets.properties');
this.properties = defaultProperties.filter((cardItem) => this.isValidSelection(filteredProperties, cardItem));
}
}
/**
* Refresh the card data
*/
refreshData() {
this.properties = this.properties.map((cardItem) => {
if (cardItem.key === 'formName' && cardItem.value !== this.formName) {
return new CardViewTextItemModel({
label: 'ADF_TASK_LIST.PROPERTIES.FORM_NAME',
value: this.formName,
key: 'formName',
default: this.translationService.instant('ADF_TASK_LIST.PROPERTIES.FORM_NAME_DEFAULT'),
clickable: this.isFormClickable(),
icon: 'create'
});
} else {
return cardItem;
}
});
}
private isValidSelection(filteredProperties: string[], cardItem: CardViewBaseItemModel): boolean { private isValidSelection(filteredProperties: string[], cardItem: CardViewBaseItemModel): boolean {
return filteredProperties ? filteredProperties.indexOf(cardItem.key) >= 0 : true; return filteredProperties ? filteredProperties.indexOf(cardItem.key) >= 0 : true;
} }
@@ -250,86 +332,4 @@ export class TaskHeaderComponent implements OnChanges, OnInit {
this.currentUserId = res ? +res.id : null; this.currentUserId = res ? +res.id : null;
}); });
} }
/**
* Return the process parent information
*/
getParentInfo(): Map<string, string> {
if (this.taskDetails.processInstanceId && this.taskDetails.processDefinitionName) {
return new Map([[this.taskDetails.processInstanceId, this.taskDetails.processDefinitionName]]);
}
return new Map();
}
/**
* Does the task have an assignee
*/
public hasAssignee(): boolean {
return !!this.taskDetails.assignee;
}
/**
* Returns true if the task is assigned to logged in user
*/
public isAssignedTo(userId: number): boolean {
return this.hasAssignee() ? this.taskDetails.assignee.id === userId : false;
}
/**
* Return true if the task assigned
*/
public isAssignedToCurrentUser(): boolean {
return this.hasAssignee() && this.isAssignedTo(this.currentUserId);
}
/**
* Return true if the user is a candidate member
*/
isCandidateMember(): boolean {
return this.taskDetails.managerOfCandidateGroup || this.taskDetails.memberOfCandidateGroup || this.taskDetails.memberOfCandidateUsers;
}
/**
* Return true if the task claimable
*/
public isTaskClaimable(): boolean {
return !this.hasAssignee() && this.isCandidateMember();
}
/**
* Return true if the task claimed by candidate member.
*/
public isTaskClaimedByCandidateMember(): boolean {
return this.isCandidateMember() && this.isAssignedToCurrentUser() && !this.isCompleted();
}
/**
* Returns task's status
*/
getTaskStatus(): string {
return (this.taskDetails && this.taskDetails.isCompleted()) ? 'Completed' : 'Running';
}
onClaimTask(taskId: string) {
this.claim.emit(taskId);
}
onUnclaimTask(taskId: string) {
this.unclaim.emit(taskId);
}
/**
* Returns true if the task is completed
*/
isCompleted(): boolean {
return this.taskDetails && !!this.taskDetails.endDate;
}
isFormClickable(): boolean {
return !!this.formName && !this.isCompleted();
}
getTaskDuration(): string {
return this.taskDetails.duration ? `${this.taskDetails.duration} ms` : '';
}
} }

View File

@@ -56,7 +56,7 @@ describe('TaskListComponent', () => {
appConfig.config = Object.assign(appConfig.config, { appConfig.config = Object.assign(appConfig.config, {
'adf-task-list': { 'adf-task-list': {
'presets': { presets: {
fakeCustomSchema fakeCustomSchema
} }
} }
@@ -158,11 +158,11 @@ describe('TaskListComponent', () => {
done(); done();
}); });
component.ngAfterContentInit(); component.ngAfterContentInit();
component.ngOnChanges({ 'state': state, 'processDefinitionKey': processDefinitionKey, 'assignment': assignment }); component.ngOnChanges({ state, processDefinitionKey, assignment });
fixture.detectChanges(); fixture.detectChanges();
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeGlobalTask) responseText: JSON.stringify(fakeGlobalTask)
}); });
@@ -184,11 +184,11 @@ describe('TaskListComponent', () => {
}); });
component.ngAfterContentInit(); component.ngAfterContentInit();
component.ngOnChanges({ 'state': state, 'processDefinitionKey': processDefinitionKey, 'assignment': assignment }); component.ngOnChanges({ state, processDefinitionKey, assignment });
fixture.detectChanges(); fixture.detectChanges();
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeGlobalTask) responseText: JSON.stringify(fakeGlobalTask)
}); });
@@ -210,11 +210,11 @@ describe('TaskListComponent', () => {
}); });
component.ngAfterContentInit(); component.ngAfterContentInit();
component.ngOnChanges({ 'state': state, 'processInstanceId': processInstanceId, 'assignment': assignment }); component.ngOnChanges({ state, processInstanceId, assignment });
fixture.detectChanges(); fixture.detectChanges();
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeGlobalTask) responseText: JSON.stringify(fakeGlobalTask)
}); });
@@ -236,11 +236,11 @@ describe('TaskListComponent', () => {
}); });
component.ngAfterContentInit(); component.ngAfterContentInit();
component.ngOnChanges({ 'state': state, 'processDefinitionId': processDefinitionId, 'assignment': assignment }); component.ngOnChanges({ state, processDefinitionId, assignment });
fixture.detectChanges(); fixture.detectChanges();
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeGlobalTask) responseText: JSON.stringify(fakeGlobalTask)
}); });
@@ -259,10 +259,10 @@ describe('TaskListComponent', () => {
done(); done();
}); });
component.ngAfterContentInit(); component.ngAfterContentInit();
component.ngOnChanges({ 'state': state, 'afterDate': afterDate }); component.ngOnChanges({ state, afterDate });
fixture.detectChanges(); fixture.detectChanges();
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeGlobalTask) responseText: JSON.stringify(fakeGlobalTask)
}); });
@@ -287,11 +287,11 @@ describe('TaskListComponent', () => {
}); });
component.ngAfterContentInit(); component.ngAfterContentInit();
component.ngOnChanges({ 'state': state, 'processInstanceId': processInstanceId }); component.ngOnChanges({ state, processInstanceId });
fixture.detectChanges(); fixture.detectChanges();
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeGlobalTask) responseText: JSON.stringify(fakeGlobalTask)
}); });
@@ -328,7 +328,7 @@ describe('TaskListComponent', () => {
component.reload(); component.reload();
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeGlobalTask) responseText: JSON.stringify(fakeGlobalTask)
}); });
@@ -363,7 +363,7 @@ describe('TaskListComponent', () => {
component.rows = [{ id: '999', name: 'Fake-name' }]; component.rows = [{ id: '999', name: 'Fake-name' }];
const landingTaskId = '999'; const landingTaskId = '999';
const change = new SimpleChange(null, landingTaskId, true); const change = new SimpleChange(null, landingTaskId, true);
component.ngOnChanges({ 'landingTaskId': change }); component.ngOnChanges({ landingTaskId: change });
expect(component.reload).not.toHaveBeenCalled(); expect(component.reload).not.toHaveBeenCalled();
expect(component.rows.length).toEqual(1); expect(component.rows.length).toEqual(1);
}); });
@@ -381,10 +381,10 @@ describe('TaskListComponent', () => {
done(); done();
}); });
component.ngOnChanges({ 'landingTaskId': change }); component.ngOnChanges({ landingTaskId: change });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeGlobalTask) responseText: JSON.stringify(fakeGlobalTask)
}); });
@@ -409,10 +409,10 @@ describe('TaskListComponent', () => {
expect(component.rows[1]['name']).toEqual('No name'); expect(component.rows[1]['name']).toEqual('No name');
done(); done();
}); });
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ appId: change });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeGlobalTask) responseText: JSON.stringify(fakeGlobalTask)
}); });
@@ -431,10 +431,10 @@ describe('TaskListComponent', () => {
done(); done();
}); });
component.ngOnChanges({ 'processDefinitionKey': change }); component.ngOnChanges({ processDefinitionKey: change });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeGlobalTask) responseText: JSON.stringify(fakeGlobalTask)
}); });
@@ -453,10 +453,10 @@ describe('TaskListComponent', () => {
done(); done();
}); });
component.ngOnChanges({ 'state': change }); component.ngOnChanges({ state: change });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeGlobalTask) responseText: JSON.stringify(fakeGlobalTask)
}); });
@@ -475,10 +475,10 @@ describe('TaskListComponent', () => {
done(); done();
}); });
component.ngOnChanges({ 'sort': change }); component.ngOnChanges({ sort: change });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeGlobalTask) responseText: JSON.stringify(fakeGlobalTask)
}); });
@@ -497,10 +497,10 @@ describe('TaskListComponent', () => {
done(); done();
}); });
component.ngOnChanges({ 'name': change }); component.ngOnChanges({ name: change });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeGlobalTask) responseText: JSON.stringify(fakeGlobalTask)
}); });
@@ -519,10 +519,10 @@ describe('TaskListComponent', () => {
done(); done();
}); });
component.ngOnChanges({ 'assignment': change }); component.ngOnChanges({ assignment: change });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeGlobalTask) responseText: JSON.stringify(fakeGlobalTask)
}); });
@@ -532,7 +532,7 @@ describe('TaskListComponent', () => {
it('should update the columns when presetColumn schema changes', () => { it('should update the columns when presetColumn schema changes', () => {
appConfig.config = Object.assign(appConfig.config, { appConfig.config = Object.assign(appConfig.config, {
'adf-task-list': { 'adf-task-list': {
'presets': fakeColumnSchema presets: fakeColumnSchema
} }
}); });
@@ -543,7 +543,7 @@ describe('TaskListComponent', () => {
component.presetColumn = 'fakeMyTasksSchema'; component.presetColumn = 'fakeMyTasksSchema';
const presetColumnChange = new SimpleChange(null, 'fakeMyTasksSchema', false); const presetColumnChange = new SimpleChange(null, 'fakeMyTasksSchema', false);
component.ngOnChanges({ 'presetColumn': presetColumnChange }); component.ngOnChanges({ presetColumn: presetColumnChange });
const newColumnSchema = component.mergeJsonAndHtmlSchema(); const newColumnSchema = component.mergeJsonAndHtmlSchema();
const expectedColumn1 = new ObjectDataColumn(fakeColumnSchema.fakeMyTasksSchema[0]); const expectedColumn1 = new ObjectDataColumn(fakeColumnSchema.fakeMyTasksSchema[0]);
@@ -562,7 +562,7 @@ describe('TaskListComponent', () => {
const processDefinitionKey = new SimpleChange(null, null, true); const processDefinitionKey = new SimpleChange(null, null, true);
const assignment = new SimpleChange(null, 'fake-assignee', true); const assignment = new SimpleChange(null, 'fake-assignee', true);
component.ngAfterContentInit(); component.ngAfterContentInit();
component.ngOnChanges({ 'state': state, 'processDefinitionKey': processDefinitionKey, 'assignment': assignment }); component.ngOnChanges({ state, processDefinitionKey, assignment });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -584,7 +584,7 @@ describe('TaskListComponent', () => {
const state = new SimpleChange(null, 'open', true); const state = new SimpleChange(null, 'open', true);
component.multiselect = true; component.multiselect = true;
component.ngOnChanges({ 'sort': state }); component.ngOnChanges({ sort: state });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -612,7 +612,7 @@ describe('TaskListComponent', () => {
const state = new SimpleChange(null, 'open', true); const state = new SimpleChange(null, 'open', true);
component.multiselect = true; component.multiselect = true;
component.ngOnChanges({ 'sort': state }); component.ngOnChanges({ sort: state });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -650,7 +650,7 @@ describe('TaskListComponent', () => {
component.multiselect = true; component.multiselect = true;
component.selectionMode = 'none'; component.selectionMode = 'none';
component.ngOnChanges({ 'sort': state }); component.ngOnChanges({ sort: state });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -695,7 +695,7 @@ describe('TaskListComponent', () => {
component.multiselect = true; component.multiselect = true;
component.selectionMode = 'single'; component.selectionMode = 'single';
component.ngOnChanges({ 'sort': state }); component.ngOnChanges({ sort: state });
fixture.detectChanges(); fixture.detectChanges();
const selectTask1 = fixture.nativeElement.querySelector('[data-automation-id="datatable-row-0"] .mat-checkbox-inner-container'); const selectTask1 = fixture.nativeElement.querySelector('[data-automation-id="datatable-row-0"] .mat-checkbox-inner-container');
@@ -726,7 +726,7 @@ describe('TaskListComponent', () => {
spyOn(taskListService, 'findTasksByState').and.returnValues(of(fakeGlobalTask)); spyOn(taskListService, 'findTasksByState').and.returnValues(of(fakeGlobalTask));
const state = new SimpleChange(null, 'open', true); const state = new SimpleChange(null, 'open', true);
component.ngOnChanges({ 'sort': state }); component.ngOnChanges({ sort: state });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -827,9 +827,7 @@ describe('Task List: Custom EmptyTemplateComponent', () => {
beforeEach(() => { beforeEach(() => {
translateService = TestBed.inject(TranslateService); translateService = TestBed.inject(TranslateService);
taskListService = TestBed.inject(TaskListService); taskListService = TestBed.inject(TaskListService);
spyOn(translateService, 'get').and.callFake((key) => { spyOn(translateService, 'get').and.callFake((key: string) => of(key));
return of(key);
});
spyOn(taskListService, 'findTasksByState').and.returnValue(of(fakeEmptyTask)); spyOn(taskListService, 'findTasksByState').and.returnValue(of(fakeEmptyTask));
fixture = TestBed.createComponent(EmptyTemplateComponent); fixture = TestBed.createComponent(EmptyTemplateComponent);
fixture.detectChanges(); fixture.detectChanges();

View File

@@ -32,6 +32,8 @@ import moment from 'moment-es6';
import { takeUntil, finalize } from 'rxjs/operators'; import { takeUntil, finalize } from 'rxjs/operators';
import { TaskDetailsModel } from '../models/task-details.model'; import { TaskDetailsModel } from '../models/task-details.model';
export const PRESET_KEY = 'adf-task-list.presets';
@Component({ @Component({
selector: 'adf-tasklist', selector: 'adf-tasklist',
templateUrl: './task-list.component.html', templateUrl: './task-list.component.html',
@@ -39,16 +41,12 @@ import { TaskDetailsModel } from '../models/task-details.model';
}) })
export class TaskListComponent extends DataTableSchema implements OnChanges, AfterContentInit, PaginatedComponent, OnDestroy, OnInit { export class TaskListComponent extends DataTableSchema implements OnChanges, AfterContentInit, PaginatedComponent, OnDestroy, OnInit {
static PRESET_KEY = 'adf-task-list.presets';
@ContentChild(CustomEmptyContentTemplateDirective) @ContentChild(CustomEmptyContentTemplateDirective)
customEmptyContent: CustomEmptyContentTemplateDirective; customEmptyContent: CustomEmptyContentTemplateDirective;
@ContentChild(CustomLoadingContentTemplateDirective) @ContentChild(CustomLoadingContentTemplateDirective)
customLoadingContent: CustomLoadingContentTemplateDirective; customLoadingContent: CustomLoadingContentTemplateDirective;
requestNode: TaskQueryRequestRepresentationModel;
/** The id of the app. */ /** The id of the app. */
@Input() @Input()
appId: number; appId: number;
@@ -151,10 +149,6 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
@Output() @Output()
error = new EventEmitter<any>(); error = new EventEmitter<any>();
currentInstanceId: string;
selectedInstances: any[];
pagination: BehaviorSubject<PaginationModel>;
/** The page number of the tasks to fetch. */ /** The page number of the tasks to fetch. */
@Input() @Input()
page: number = 0; page: number = 0;
@@ -171,6 +165,10 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
@Input() @Input()
dueBefore: string; dueBefore: string;
requestNode: TaskQueryRequestRepresentationModel;
currentInstanceId: string;
selectedInstances: any[];
pagination: BehaviorSubject<PaginationModel>;
rows: any[] = []; rows: any[] = [];
isLoading: boolean = true; isLoading: boolean = true;
sorting: any[] = ['created', 'desc']; sorting: any[] = ['created', 'desc'];
@@ -189,9 +187,9 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
constructor(private taskListService: TaskListService, constructor(private taskListService: TaskListService,
appConfigService: AppConfigService, appConfigService: AppConfigService,
private userPreferences: UserPreferencesService) { private userPreferences: UserPreferencesService) {
super(appConfigService, TaskListComponent.PRESET_KEY, taskPresetsDefaultModel); super(appConfigService, PRESET_KEY, taskPresetsDefaultModel);
this.pagination = new BehaviorSubject<PaginationModel>(<PaginationModel> { this.pagination = new BehaviorSubject<PaginationModel>({
maxItems: this.size, maxItems: this.size,
skipCount: 0, skipCount: 0,
totalItems: 0 totalItems: 0
@@ -242,28 +240,6 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
} }
} }
private isSortChanged(changes: SimpleChanges): boolean {
const actualSort = changes['sort'];
return actualSort && actualSort.currentValue && actualSort.currentValue !== actualSort.previousValue;
}
private isPropertyChanged(changes: SimpleChanges): boolean {
let changed: boolean = true;
const landingTaskId = changes['landingTaskId'];
const page = changes['page'];
const size = changes['size'];
if (landingTaskId && landingTaskId.currentValue && this.isEqualToCurrentId(landingTaskId.currentValue)) {
changed = false;
} else if (page && page.currentValue !== page.previousValue) {
changed = true;
} else if (size && size.currentValue !== size.previousValue) {
changed = true;
}
return changed;
}
reload(): void { reload(): void {
if (!this.hasCustomDataSource) { if (!this.hasCustomDataSource) {
this.requestNode = this.createRequestNode(); this.requestNode = this.createRequestNode();
@@ -273,34 +249,6 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
} }
} }
private load() {
this.isLoading = true;
this.loadTasksByState()
.pipe(finalize(() => this.isLoading = false))
.subscribe(
tasks => {
this.rows = this.optimizeTaskDetails(tasks.data);
this.selectTask(this.landingTaskId);
this.success.emit(tasks);
this.pagination.next({
count: tasks.data.length,
maxItems: this.size,
skipCount: this.page * this.size,
totalItems: tasks.total
});
},
error => {
this.error.emit(error);
});
}
private loadTasksByState(): Observable<TaskListModel> {
return this.requestNode.state === 'all'
? this.taskListService.findAllTasksWithoutState(this.requestNode)
: this.taskListService.findTasksByState(this.requestNode);
}
/** /**
* Select the task given in input if present * Select the task given in input if present
*/ */
@@ -309,9 +257,7 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
let dataRow = null; let dataRow = null;
if (taskIdSelected) { if (taskIdSelected) {
dataRow = this.rows.find((currentRow: any) => { dataRow = this.rows.find((currentRow: any) => currentRow['id'] === taskIdSelected);
return currentRow['id'] === taskIdSelected;
});
} }
if (!dataRow && this.selectFirstRow) { if (!dataRow && this.selectFirstRow) {
@@ -336,6 +282,7 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
/** /**
* Check if the taskId is the same of the selected task * Check if the taskId is the same of the selected task
*
* @param taskId * @param taskId
*/ */
isEqualToCurrentId(taskId: string): boolean { isEqualToCurrentId(taskId: string): boolean {
@@ -377,8 +324,74 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
this.showRowContextMenu.emit(event); this.showRowContextMenu.emit(event);
} }
updatePagination(params: PaginationModel) {
const needsReload = params.maxItems || params.skipCount;
this.size = params.maxItems;
this.page = this.currentPage(params.skipCount, params.maxItems);
if (needsReload) {
this.reload();
}
}
currentPage(skipCount: number, maxItems: number): number {
return (skipCount && maxItems) ? Math.floor(skipCount / maxItems) : 0;
}
private isSortChanged(changes: SimpleChanges): boolean {
const actualSort = changes['sort'];
return actualSort && actualSort.currentValue && actualSort.currentValue !== actualSort.previousValue;
}
private isPropertyChanged(changes: SimpleChanges): boolean {
let changed: boolean = true;
const landingTaskId = changes['landingTaskId'];
const page = changes['page'];
const size = changes['size'];
if (landingTaskId && landingTaskId.currentValue && this.isEqualToCurrentId(landingTaskId.currentValue)) {
changed = false;
} else if (page && page.currentValue !== page.previousValue) {
changed = true;
} else if (size && size.currentValue !== size.previousValue) {
changed = true;
}
return changed;
}
private load() {
this.isLoading = true;
this.loadTasksByState()
.pipe(finalize(() => this.isLoading = false))
.subscribe(
tasks => {
this.rows = this.optimizeTaskDetails(tasks.data);
this.selectTask(this.landingTaskId);
this.success.emit(tasks);
this.pagination.next({
count: tasks.data.length,
maxItems: this.size,
skipCount: this.page * this.size,
totalItems: tasks.total
});
},
error => {
this.error.emit(error);
});
}
private loadTasksByState(): Observable<TaskListModel> {
return this.requestNode.state === 'all'
? this.taskListService.findAllTasksWithoutState(this.requestNode)
: this.taskListService.findTasksByState(this.requestNode);
}
/** /**
* Optimize name field * Optimize name field
*
* @param instances * @param instances
*/ */
private optimizeTaskDetails(instances: TaskDetailsModel[]): TaskDetailsModel[] { private optimizeTaskDetails(instances: TaskDetailsModel[]): TaskDetailsModel[] {
@@ -410,19 +423,4 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
}; };
return new TaskQueryRequestRepresentationModel(requestNode); return new TaskQueryRequestRepresentationModel(requestNode);
} }
updatePagination(params: PaginationModel) {
const needsReload = params.maxItems || params.skipCount;
this.size = params.maxItems;
this.page = this.currentPage(params.skipCount, params.maxItems);
if (needsReload) {
this.reload();
}
}
currentPage(skipCount: number, maxItems: number): number {
return (skipCount && maxItems) ? Math.floor(skipCount / maxItems) : 0;
}
} }

View File

@@ -49,15 +49,15 @@ export class TaskStandaloneComponent {
/** Emitted when the "Cancel" button is clicked. */ /** Emitted when the "Cancel" button is clicked. */
@Output() @Output()
cancel: EventEmitter<void> = new EventEmitter<void>(); cancel = new EventEmitter<void>();
/** Emitted when the form associated with the task is completed. */ /** Emitted when the form associated with the task is completed. */
@Output() @Output()
complete: EventEmitter<void> = new EventEmitter<void>(); complete = new EventEmitter<void>();
/** Emitted when the form associated with the form task is attached. */ /** Emitted when the form associated with the form task is attached. */
@Output() @Output()
showAttachForm: EventEmitter<void> = new EventEmitter<void>(); showAttachForm = new EventEmitter<void>();
constructor() { } constructor() { }

View File

@@ -27,10 +27,9 @@ export class TaskListModel {
constructor(input?: any) { constructor(input?: any) {
if (input) { if (input) {
Object.assign(this, input); Object.assign(this, input);
if (input.data) { if (input.data) {
this.data = input.data.map((item: any) => { this.data = input.data.map((item: any) => new TaskDetailsModel(item));
return new TaskDetailsModel(item);
});
} }
} }
} }

View File

@@ -15,27 +15,27 @@
* limitations under the License. * limitations under the License.
*/ */
export let taskPresetsDefaultModel = { export const taskPresetsDefaultModel = {
'default': [ default: [
{ {
'key': 'name', key: 'name',
'type': 'text', type: 'text',
'title': 'ADF_TASK_LIST.PROPERTIES.NAME', title: 'ADF_TASK_LIST.PROPERTIES.NAME',
'sortable': true sortable: true
}, },
{ {
'key': 'created', key: 'created',
'type': 'text', type: 'text',
'title': 'ADF_TASK_LIST.PROPERTIES.CREATED', title: 'ADF_TASK_LIST.PROPERTIES.CREATED',
'cssClass': 'hidden', cssClass: 'hidden',
'sortable': true sortable: true
}, },
{ {
'key': 'assignee', key: 'assignee',
'type': 'text', type: 'text',
'title': 'ADF_TASK_LIST.PROPERTIES.ASSIGNEE', title: 'ADF_TASK_LIST.PROPERTIES.ASSIGNEE',
'cssClass': 'hidden', cssClass: 'hidden',
'sortable': true sortable: true
} }
] ]
}; };

View File

@@ -57,7 +57,7 @@ describe('Activiti Task filter Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeFiltersResponse) responseText: JSON.stringify(fakeFiltersResponse)
}); });
@@ -75,7 +75,7 @@ describe('Activiti Task filter Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeFiltersResponse) responseText: JSON.stringify(fakeFiltersResponse)
}); });
@@ -94,7 +94,7 @@ describe('Activiti Task filter Service', () => {
); );
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeFiltersResponse) responseText: JSON.stringify(fakeFiltersResponse)
}); });
@@ -120,7 +120,7 @@ describe('Activiti Task filter Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeAppFilter) responseText: JSON.stringify(fakeAppFilter)
}); });
@@ -142,7 +142,7 @@ describe('Activiti Task filter Service', () => {
}); });
jasmine.Ajax.requests.at(0).respondWith({ jasmine.Ajax.requests.at(0).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
appId: 1001, id: 111, name: 'My Tasks', icon: 'fake-icon', recent: false appId: 1001, id: 111, name: 'My Tasks', icon: 'fake-icon', recent: false
@@ -150,7 +150,7 @@ describe('Activiti Task filter Service', () => {
}); });
jasmine.Ajax.requests.at(1).respondWith({ jasmine.Ajax.requests.at(1).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
appId: 1001, id: 222, name: 'Involved Tasks', icon: 'fake-icon', recent: false appId: 1001, id: 222, name: 'Involved Tasks', icon: 'fake-icon', recent: false
@@ -158,7 +158,7 @@ describe('Activiti Task filter Service', () => {
}); });
jasmine.Ajax.requests.at(2).respondWith({ jasmine.Ajax.requests.at(2).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
appId: 1001, id: 333, name: 'Queued Tasks', icon: 'fake-icon', recent: false appId: 1001, id: 333, name: 'Queued Tasks', icon: 'fake-icon', recent: false
@@ -166,7 +166,7 @@ describe('Activiti Task filter Service', () => {
}); });
jasmine.Ajax.requests.at(3).respondWith({ jasmine.Ajax.requests.at(3).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
appId: 1001, id: 444, name: 'Completed Tasks', icon: 'fake-icon', recent: false appId: 1001, id: 444, name: 'Completed Tasks', icon: 'fake-icon', recent: false
@@ -197,7 +197,7 @@ describe('Activiti Task filter Service', () => {
}); });
jasmine.Ajax.requests.at(0).respondWith({ jasmine.Ajax.requests.at(0).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
appId: 1001, id: 111, name: 'My Tasks', icon: 'fake-icon', recent: false appId: 1001, id: 111, name: 'My Tasks', icon: 'fake-icon', recent: false
@@ -205,7 +205,7 @@ describe('Activiti Task filter Service', () => {
}); });
jasmine.Ajax.requests.at(1).respondWith({ jasmine.Ajax.requests.at(1).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
appId: 1001, id: 222, name: 'Involved Tasks', icon: 'fake-icon', recent: false appId: 1001, id: 222, name: 'Involved Tasks', icon: 'fake-icon', recent: false
@@ -213,7 +213,7 @@ describe('Activiti Task filter Service', () => {
}); });
jasmine.Ajax.requests.at(2).respondWith({ jasmine.Ajax.requests.at(2).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
appId: 1001, id: 333, name: 'Queued Tasks', icon: 'fake-icon', recent: false appId: 1001, id: 333, name: 'Queued Tasks', icon: 'fake-icon', recent: false
@@ -221,7 +221,7 @@ describe('Activiti Task filter Service', () => {
}); });
jasmine.Ajax.requests.at(3).respondWith({ jasmine.Ajax.requests.at(3).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
appId: 1001, id: 444, name: 'Completed Tasks', icon: 'fake-icon', recent: false appId: 1001, id: 444, name: 'Completed Tasks', icon: 'fake-icon', recent: false
@@ -244,7 +244,7 @@ describe('Activiti Task filter Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
id: '2233', name: 'FakeNameFilter', filter: { assignment: 'fake-assignment' } id: '2233', name: 'FakeNameFilter', filter: { assignment: 'fake-assignment' }

View File

@@ -27,7 +27,7 @@ import { UserFiltersApi } from '@alfresco/js-api';
}) })
export class TaskFilterService { export class TaskFilterService {
private _userFiltersApi; private _userFiltersApi: UserFiltersApi;
get userFiltersApi(): UserFiltersApi { get userFiltersApi(): UserFiltersApi {
this._userFiltersApi = this._userFiltersApi ?? new UserFiltersApi(this.apiService.getInstance()); this._userFiltersApi = this._userFiltersApi ?? new UserFiltersApi(this.apiService.getInstance());
return this._userFiltersApi; return this._userFiltersApi;
@@ -39,6 +39,7 @@ export class TaskFilterService {
/** /**
* Creates and returns the default filters for a process app. * Creates and returns the default filters for a process app.
*
* @param appId ID of the target app * @param appId ID of the target app
* @returns Array of default filters just created * @returns Array of default filters just created
*/ */
@@ -103,6 +104,7 @@ export class TaskFilterService {
/** /**
* Gets all task filters for a process app. * Gets all task filters for a process app.
*
* @param appId Optional ID for a specific app * @param appId Optional ID for a specific app
* @returns Array of task filter details * @returns Array of task filter details
*/ */
@@ -123,6 +125,7 @@ export class TaskFilterService {
/** /**
* Gets a task filter by ID. * Gets a task filter by ID.
*
* @param filterId ID of the filter * @param filterId ID of the filter
* @param appId ID of the app for the filter * @param appId ID of the app for the filter
* @returns Details of task filter * @returns Details of task filter
@@ -136,6 +139,7 @@ export class TaskFilterService {
/** /**
* Gets a task filter by name. * Gets a task filter by name.
*
* @param taskName Name of the filter * @param taskName Name of the filter
* @param appId ID of the app for the filter * @param appId ID of the app for the filter
* @returns Details of task filter * @returns Details of task filter
@@ -149,27 +153,27 @@ export class TaskFilterService {
/** /**
* Adds a new task filter * Adds a new task filter
*
* @param filter The new filter to add * @param filter The new filter to add
* @returns Details of task filter just added * @returns Details of task filter just added
*/ */
addFilter(filter: FilterRepresentationModel): Observable<FilterRepresentationModel> { addFilter(filter: FilterRepresentationModel): Observable<FilterRepresentationModel> {
return from(this.userFiltersApi.createUserTaskFilter(filter)) return from(this.userFiltersApi.createUserTaskFilter(filter))
.pipe( .pipe(
map((response: FilterRepresentationModel) => { map((response: FilterRepresentationModel) => response),
return response;
}),
catchError((err) => this.handleError(err)) catchError((err) => this.handleError(err))
); );
} }
/** /**
* Calls `getUserTaskFilters` from the Alfresco JS API. * Calls `getUserTaskFilters` from the Alfresco JS API.
*
* @param appId ID of the target app * @param appId ID of the target app
* @returns List of task filters * @returns List of task filters
*/ */
callApiTaskFilters(appId?: number): Promise<any> { callApiTaskFilters(appId?: number): Promise<any> {
if (appId) { if (appId) {
return this.userFiltersApi.getUserTaskFilters({ appId: appId }); return this.userFiltersApi.getUserTaskFilters({ appId });
} else { } else {
return this.userFiltersApi.getUserTaskFilters(); return this.userFiltersApi.getUserTaskFilters();
} }
@@ -177,68 +181,77 @@ export class TaskFilterService {
/** /**
* Creates and returns a filter for "My Tasks" task instances. * Creates and returns a filter for "My Tasks" task instances.
*
* @param appId ID of the target app * @param appId ID of the target app
* @param index of the filter (optional) * @param index of the filter (optional)
* @returns The newly created filter * @returns The newly created filter
*/ */
getMyTasksFilterInstance(appId: number, index?: number): FilterRepresentationModel { getMyTasksFilterInstance(appId: number, index?: number): FilterRepresentationModel {
return new FilterRepresentationModel({ return new FilterRepresentationModel({
'name': 'My Tasks', name: 'My Tasks',
'appId': appId, appId,
'recent': false, recent: false,
'icon': 'glyphicon-inbox', icon: 'glyphicon-inbox',
'filter': { 'sort': 'created-desc', 'name': '', 'state': 'open', 'assignment': 'assignee' }, filter: {
sort: 'created-desc',
name: '',
state: 'open',
assignment: 'assignee'
},
index index
}); });
} }
/** /**
* Creates and returns a filter for "Involved" task instances. * Creates and returns a filter for "Involved" task instances.
*
* @param appId ID of the target app * @param appId ID of the target app
* @param index of the filter (optional) * @param index of the filter (optional)
* @returns The newly created filter * @returns The newly created filter
*/ */
getInvolvedTasksFilterInstance(appId: number, index?: number): FilterRepresentationModel { getInvolvedTasksFilterInstance(appId: number, index?: number): FilterRepresentationModel {
return new FilterRepresentationModel({ return new FilterRepresentationModel({
'name': 'Involved Tasks', name: 'Involved Tasks',
'appId': appId, appId,
'recent': false, recent: false,
'icon': 'glyphicon-align-left', icon: 'glyphicon-align-left',
'filter': { 'sort': 'created-desc', 'name': '', 'state': 'open', 'assignment': 'involved' }, filter: { sort: 'created-desc', name: '', state: 'open', assignment: 'involved' },
index index
}); });
} }
/** /**
* Creates and returns a filter for "Queued Tasks" task instances. * Creates and returns a filter for "Queued Tasks" task instances.
*
* @param appId ID of the target app * @param appId ID of the target app
* @param index of the filter (optional) * @param index of the filter (optional)
* @returns The newly created filter * @returns The newly created filter
*/ */
getQueuedTasksFilterInstance(appId: number, index?: number): FilterRepresentationModel { getQueuedTasksFilterInstance(appId: number, index?: number): FilterRepresentationModel {
return new FilterRepresentationModel({ return new FilterRepresentationModel({
'name': 'Queued Tasks', name: 'Queued Tasks',
'appId': appId, appId,
'recent': false, recent: false,
'icon': 'glyphicon-record', icon: 'glyphicon-record',
'filter': { 'sort': 'created-desc', 'name': '', 'state': 'open', 'assignment': 'candidate' }, filter: { sort: 'created-desc', name: '', state: 'open', assignment: 'candidate' },
index index
}); });
} }
/** /**
* Creates and returns a filter for "Completed" task instances. * Creates and returns a filter for "Completed" task instances.
*
* @param appId ID of the target app * @param appId ID of the target app
* @param index of the filter (optional) * @param index of the filter (optional)
* @returns The newly created filter * @returns The newly created filter
*/ */
getCompletedTasksFilterInstance(appId: number, index?: number): FilterRepresentationModel { getCompletedTasksFilterInstance(appId: number, index?: number): FilterRepresentationModel {
return new FilterRepresentationModel({ return new FilterRepresentationModel({
'name': 'Completed Tasks', name: 'Completed Tasks',
'appId': appId, appId,
'recent': true, recent: true,
'icon': 'glyphicon-ok-sign', icon: 'glyphicon-ok-sign',
'filter': { 'sort': 'created-desc', 'name': '', 'state': 'completed', 'assignment': 'involved' }, filter: { sort: 'created-desc', name: '', state: 'completed', assignment: 'involved' },
index index
}); });
} }
@@ -247,5 +260,4 @@ export class TaskFilterService {
this.logService.error(error); this.logService.error(error);
return throwError(error || 'Server error'); return throwError(error || 'Server error');
} }
} }

View File

@@ -29,8 +29,8 @@ import {
fakeUser2, fakeUser2,
secondFakeTaskList secondFakeTaskList
} from '../../mock'; } from '../../mock';
import { fakeRepresentationFilter1, fakeRepresentationFilter2, fakeFilter } from '../../mock/task/task-filters.mock'; import { fakeFilter, fakeRepresentationFilter1, fakeRepresentationFilter2 } from '../../mock/task/task-filters.mock';
import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model'; import { FilterRepresentationModel } from '../models/filter.model';
import { TaskDetailsModel } from '../models/task-details.model'; import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListService } from './tasklist.service'; import { TaskListService } from './tasklist.service';
import { TaskUpdateRepresentation } from '@alfresco/js-api'; import { TaskUpdateRepresentation } from '@alfresco/js-api';
@@ -61,7 +61,7 @@ describe('Activiti TaskList Service', () => {
describe('Content tests', () => { describe('Content tests', () => {
it('should return the task list filtered', (done) => { it('should return the task list filtered', (done) => {
service.getTasks(<TaskQueryRequestRepresentationModel> fakeFilter).subscribe((res) => { service.getTasks(fakeFilter).subscribe((res) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
expect(res.size).toEqual(1); expect(res.size).toEqual(1);
expect(res.start).toEqual(0); expect(res.start).toEqual(0);
@@ -75,7 +75,7 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeTaskList) responseText: JSON.stringify(fakeTaskList)
}); });
@@ -85,7 +85,7 @@ describe('Activiti TaskList Service', () => {
spyOn(service, 'getTasks').and.returnValue(of(fakeTaskList)); spyOn(service, 'getTasks').and.returnValue(of(fakeTaskList));
spyOn(service, 'getTotalTasks').and.returnValue(of(fakeTaskList)); spyOn(service, 'getTotalTasks').and.returnValue(of(fakeTaskList));
service.findAllTaskByState(<TaskQueryRequestRepresentationModel> fakeFilter, 'open').subscribe((res) => { service.findAllTaskByState(fakeFilter, 'open').subscribe((res) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
expect(res.size).toEqual(1); expect(res.size).toEqual(1);
@@ -104,7 +104,7 @@ describe('Activiti TaskList Service', () => {
spyOn(service, 'getTasks').and.returnValue(of(fakeTaskList)); spyOn(service, 'getTasks').and.returnValue(of(fakeTaskList));
spyOn(service, 'getTotalTasks').and.returnValue(of(fakeTaskList)); spyOn(service, 'getTotalTasks').and.returnValue(of(fakeTaskList));
service.findAllTaskByState(<TaskQueryRequestRepresentationModel> fakeFilter).subscribe((res) => { service.findAllTaskByState(fakeFilter).subscribe((res) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
expect(res.size).toEqual(1); expect(res.size).toEqual(1);
expect(res.start).toEqual(0); expect(res.start).toEqual(0);
@@ -119,7 +119,7 @@ describe('Activiti TaskList Service', () => {
}); });
it('should return the task list filtered by state', (done) => { it('should return the task list filtered by state', (done) => {
service.findTasksByState(<TaskQueryRequestRepresentationModel> fakeFilter, 'open').subscribe((res) => { service.findTasksByState(fakeFilter, 'open').subscribe((res) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
expect(res.size).toEqual(1); expect(res.size).toEqual(1);
expect(res.start).toEqual(0); expect(res.start).toEqual(0);
@@ -133,14 +133,14 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeTaskList) responseText: JSON.stringify(fakeTaskList)
}); });
}); });
it('should return the task list filtered', (done) => { it('should return the task list filtered', (done) => {
service.findTasksByState(<TaskQueryRequestRepresentationModel> fakeFilter).subscribe((res) => { service.findTasksByState(fakeFilter).subscribe((res) => {
expect(res.size).toEqual(1); expect(res.size).toEqual(1);
expect(res.start).toEqual(0); expect(res.start).toEqual(0);
expect(res.data).toBeDefined(); expect(res.data).toBeDefined();
@@ -153,7 +153,7 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeTaskList) responseText: JSON.stringify(fakeTaskList)
}); });
@@ -163,7 +163,7 @@ describe('Activiti TaskList Service', () => {
spyOn(service, 'getTasks').and.returnValue(of(fakeTaskList)); spyOn(service, 'getTasks').and.returnValue(of(fakeTaskList));
spyOn(service, 'getTotalTasks').and.returnValue(of(fakeTaskList)); spyOn(service, 'getTotalTasks').and.returnValue(of(fakeTaskList));
service.findAllTasksWithoutState(<TaskQueryRequestRepresentationModel> fakeFilter).subscribe((res) => { service.findAllTasksWithoutState(fakeFilter).subscribe((res) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
expect(res.data).toBeDefined(); expect(res.data).toBeDefined();
expect(res.data.length).toEqual(2); expect(res.data.length).toEqual(2);
@@ -183,7 +183,7 @@ describe('Activiti TaskList Service', () => {
it('Should return both open and completed task', (done) => { it('Should return both open and completed task', (done) => {
spyOn(service, 'findTasksByState').and.returnValue(of(fakeOpenTaskList)); spyOn(service, 'findTasksByState').and.returnValue(of(fakeOpenTaskList));
spyOn(service, 'findAllTaskByState').and.returnValue(of(fakeCompletedTaskList)); spyOn(service, 'findAllTaskByState').and.returnValue(of(fakeCompletedTaskList));
service.findAllTasksWithoutState(<TaskQueryRequestRepresentationModel> fakeFilter).subscribe((res) => { service.findAllTasksWithoutState(fakeFilter).subscribe((res) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
expect(res.data).toBeDefined(); expect(res.data).toBeDefined();
expect(res.data.length).toEqual(4); expect(res.data.length).toEqual(4);
@@ -200,7 +200,7 @@ describe('Activiti TaskList Service', () => {
spyOn(service, 'getTasks').and.returnValue(of(fakeTaskList)); spyOn(service, 'getTasks').and.returnValue(of(fakeTaskList));
spyOn(service, 'getTotalTasks').and.returnValue(of(fakeTaskList)); spyOn(service, 'getTotalTasks').and.returnValue(of(fakeTaskList));
service.findAllTasksWithoutState(<TaskQueryRequestRepresentationModel> fakeFilter).subscribe((res) => { service.findAllTasksWithoutState(fakeFilter).subscribe((res) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
expect(res.data).toBeDefined(); expect(res.data).toBeDefined();
expect(res.data.length).toEqual(2); expect(res.data.length).toEqual(2);
@@ -226,7 +226,7 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeTaskDetails) responseText: JSON.stringify(fakeTaskDetails)
}); });
@@ -248,7 +248,7 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeTasksChecklist) responseText: JSON.stringify(fakeTasksChecklist)
}); });
@@ -274,7 +274,7 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
id: '777', name: 'FakeNameTask', description: null, category: null, id: '777', name: 'FakeNameTask', description: null, category: null,
@@ -290,7 +290,7 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json' contentType: 'application/json'
}); });
}); });
@@ -302,14 +302,14 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({}) responseText: JSON.stringify({})
}); });
}); });
it('should return the total number of tasks', (done) => { it('should return the total number of tasks', (done) => {
service.getTotalTasks(<TaskQueryRequestRepresentationModel> fakeFilter).subscribe((res: any) => { service.getTotalTasks(fakeFilter).subscribe((res: any) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
expect(res.size).toEqual(1); expect(res.size).toEqual(1);
expect(res.total).toEqual(1); expect(res.total).toEqual(1);
@@ -317,7 +317,7 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeTaskList) responseText: JSON.stringify(fakeTaskList)
}); });
@@ -341,7 +341,7 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
id: '777', id: '777',
@@ -373,7 +373,7 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
id: testTaskId, id: testTaskId,
@@ -405,7 +405,7 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({ responseText: JSON.stringify({
id: testTaskId, id: testTaskId,
@@ -428,7 +428,7 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({}) responseText: JSON.stringify({})
}); });
@@ -442,7 +442,7 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({}) responseText: JSON.stringify({})
}); });
@@ -459,7 +459,7 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify({}) responseText: JSON.stringify({})
}); });
@@ -485,7 +485,7 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeTaskList) responseText: JSON.stringify(fakeTaskList)
}); });
@@ -508,13 +508,13 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.at(0).respondWith({ jasmine.Ajax.requests.at(0).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeTaskList) responseText: JSON.stringify(fakeTaskList)
}); });
jasmine.Ajax.requests.at(1).respondWith({ jasmine.Ajax.requests.at(1).respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(secondFakeTaskList) responseText: JSON.stringify(secondFakeTaskList)
}); });
@@ -532,7 +532,7 @@ describe('Activiti TaskList Service', () => {
}); });
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
responseText: JSON.stringify(fakeFormList) responseText: JSON.stringify(fakeFormList)
}); });

View File

@@ -33,26 +33,25 @@ import {
providedIn: 'root' providedIn: 'root'
}) })
export class TaskListService { export class TaskListService {
private _modelsApi: ModelsApi;
private _modelsApi;
get modelsApi(): ModelsApi { get modelsApi(): ModelsApi {
this._modelsApi = this._modelsApi ?? new ModelsApi(this.apiService.getInstance()); this._modelsApi = this._modelsApi ?? new ModelsApi(this.apiService.getInstance());
return this._modelsApi; return this._modelsApi;
} }
private _tasksApi; private _tasksApi: TasksApi;
get tasksApi(): TasksApi { get tasksApi(): TasksApi {
this._tasksApi = this._tasksApi ?? new TasksApi(this.apiService.getInstance()); this._tasksApi = this._tasksApi ?? new TasksApi(this.apiService.getInstance());
return this._tasksApi; return this._tasksApi;
} }
private _taskActionsApi; private _taskActionsApi: TaskActionsApi;
get taskActionsApi(): TaskActionsApi { get taskActionsApi(): TaskActionsApi {
this._taskActionsApi = this._taskActionsApi ?? new TaskActionsApi(this.apiService.getInstance()); this._taskActionsApi = this._taskActionsApi ?? new TaskActionsApi(this.apiService.getInstance());
return this._taskActionsApi; return this._taskActionsApi;
} }
private _checklistsApi; private _checklistsApi: ChecklistsApi;
get checklistsApi(): ChecklistsApi { get checklistsApi(): ChecklistsApi {
this._checklistsApi = this._checklistsApi ?? new ChecklistsApi(this.apiService.getInstance()); this._checklistsApi = this._checklistsApi ?? new ChecklistsApi(this.apiService.getInstance());
return this._checklistsApi; return this._checklistsApi;
@@ -64,6 +63,7 @@ export class TaskListService {
/** /**
* Gets all the filters in the list that belong to a task. * Gets all the filters in the list that belong to a task.
*
* @param taskId ID of the target task * @param taskId ID of the target task
* @param filterList List of filters to search through * @param filterList List of filters to search through
* @returns Filters belonging to the task * @returns Filters belonging to the task
@@ -76,23 +76,9 @@ export class TaskListService {
); );
} }
/**
* Gets the search query for a task based on the supplied filter.
* @param filter The filter to use
* @returns The search query
*/
private generateTaskRequestNodeFromFilter(filterModel: FilterRepresentationModel): TaskQueryRequestRepresentationModel {
const requestNode = {
appDefinitionId: filterModel.appId,
assignment: filterModel.filter.assignment,
state: filterModel.filter.state,
sort: filterModel.filter.sort
};
return new TaskQueryRequestRepresentationModel(requestNode);
}
/** /**
* Checks if a taskId is filtered with the given filter. * Checks if a taskId is filtered with the given filter.
*
* @param taskId ID of the target task * @param taskId ID of the target task
* @param filterModel The filter you want to check * @param filterModel The filter you want to check
* @returns The filter if it is related or null otherwise * @returns The filter if it is related or null otherwise
@@ -101,15 +87,14 @@ export class TaskListService {
const requestNodeForFilter = this.generateTaskRequestNodeFromFilter(filterModel); const requestNodeForFilter = this.generateTaskRequestNodeFromFilter(filterModel);
return from(this.callApiTasksFiltered(requestNodeForFilter)) return from(this.callApiTasksFiltered(requestNodeForFilter))
.pipe( .pipe(
map(res => { map(res => res.data.find((element) => element.id === taskId) ? filterModel : null),
return res.data.find((element) => element.id === taskId) ? filterModel : null;
}),
catchError((err) => this.handleError(err)) catchError((err) => this.handleError(err))
); );
} }
/** /**
* Gets all the tasks matching the supplied query. * Gets all the tasks matching the supplied query.
*
* @param requestNode Query to search for tasks * @param requestNode Query to search for tasks
* @returns List of tasks * @returns List of tasks
*/ */
@@ -122,6 +107,7 @@ export class TaskListService {
/** /**
* Gets tasks matching a query and state value. * Gets tasks matching a query and state value.
*
* @param requestNode Query to search for tasks * @param requestNode Query to search for tasks
* @param state Task state. Can be "open" or "completed". * @param state Task state. Can be "open" or "completed".
* @returns List of tasks * @returns List of tasks
@@ -136,6 +122,7 @@ export class TaskListService {
/** /**
* Gets all tasks matching a query and state value. * Gets all tasks matching a query and state value.
*
* @param requestNode Query to search for tasks. * @param requestNode Query to search for tasks.
* @param state Task state. Can be "open" or "completed". * @param state Task state. Can be "open" or "completed".
* @returns List of tasks * @returns List of tasks
@@ -155,6 +142,7 @@ export class TaskListService {
/** /**
* Gets all tasks matching the supplied query but ignoring the task state. * Gets all tasks matching the supplied query but ignoring the task state.
*
* @param requestNode Query to search for tasks * @param requestNode Query to search for tasks
* @returns List of tasks * @returns List of tasks
*/ */
@@ -173,21 +161,21 @@ export class TaskListService {
/** /**
* Gets details for a task. * Gets details for a task.
*
* @param taskId ID of the target task. * @param taskId ID of the target task.
* @returns Task details * @returns Task details
*/ */
getTaskDetails(taskId: string): Observable<TaskDetailsModel> { getTaskDetails(taskId: string): Observable<TaskDetailsModel> {
return from(this.callApiTaskDetails(taskId)) return from(this.callApiTaskDetails(taskId))
.pipe( .pipe(
map(details => { map(details => new TaskDetailsModel(details)),
return new TaskDetailsModel(details);
}),
catchError((err) => this.handleError(err)) catchError((err) => this.handleError(err))
); );
} }
/** /**
* Gets the checklist for a task. * Gets the checklist for a task.
*
* @param id ID of the target task * @param id ID of the target task
* @returns Array of checklist task details * @returns Array of checklist task details
*/ */
@@ -207,13 +195,14 @@ export class TaskListService {
/** /**
* Gets all available reusable forms. * Gets all available reusable forms.
*
* @returns Array of form details * @returns Array of form details
*/ */
getFormList(): Observable<Form[]> { getFormList(): Observable<Form[]> {
const opts = { const opts = {
'filter': 'myReusableForms', // String | filter filter: 'myReusableForms', // String | filter
'sort': 'modifiedDesc', // String | sort sort: 'modifiedDesc', // String | sort
'modelType': 2 // Integer | modelType modelType: 2 // Integer | modelType
}; };
return from(this.modelsApi.getModels(opts)) return from(this.modelsApi.getModels(opts))
@@ -231,12 +220,13 @@ export class TaskListService {
/** /**
* Attaches a form to a task. * Attaches a form to a task.
*
* @param taskId ID of the target task * @param taskId ID of the target task
* @param formId ID of the form to add * @param formId ID of the form to add
* @returns Null response notifying when the operation is complete * @returns Null response notifying when the operation is complete
*/ */
attachFormToATask(taskId: string, formId: number): Observable<any> { attachFormToATask(taskId: string, formId: number): Observable<any> {
return from(this.taskActionsApi.attachForm(taskId, { 'formId': formId })) return from(this.taskActionsApi.attachForm(taskId, { formId }))
.pipe( .pipe(
catchError((err) => this.handleError(err)) catchError((err) => this.handleError(err))
); );
@@ -244,21 +234,21 @@ export class TaskListService {
/** /**
* Adds a subtask (ie, a checklist task) to a parent task. * Adds a subtask (ie, a checklist task) to a parent task.
*
* @param task The task to add * @param task The task to add
* @returns The subtask that was added * @returns The subtask that was added
*/ */
addTask(task: TaskDetailsModel): Observable<TaskDetailsModel> { addTask(task: TaskDetailsModel): Observable<TaskDetailsModel> {
return from(this.callApiAddTask(task)) return from(this.callApiAddTask(task))
.pipe( .pipe(
map((response: TaskDetailsModel) => { map((response) => new TaskDetailsModel(response)),
return new TaskDetailsModel(response);
}),
catchError((err) => this.handleError(err)) catchError((err) => this.handleError(err))
); );
} }
/** /**
* Deletes a subtask (ie, a checklist task) from a parent task. * Deletes a subtask (ie, a checklist task) from a parent task.
*
* @param taskId The task to delete * @param taskId The task to delete
* @returns Null response notifying when the operation is complete * @returns Null response notifying when the operation is complete
*/ */
@@ -271,6 +261,7 @@ export class TaskListService {
/** /**
* Deletes a form from a task. * Deletes a form from a task.
*
* @param taskId Task id related to form * @param taskId Task id related to form
* @returns Null response notifying when the operation is complete * @returns Null response notifying when the operation is complete
*/ */
@@ -283,6 +274,7 @@ export class TaskListService {
/** /**
* Gives completed status to a task. * Gives completed status to a task.
*
* @param taskId ID of the target task * @param taskId ID of the target task
* @returns Null response notifying when the operation is complete * @returns Null response notifying when the operation is complete
*/ */
@@ -295,6 +287,7 @@ export class TaskListService {
/** /**
* Gets the total number of the tasks found by a query. * Gets the total number of the tasks found by a query.
*
* @param requestNode Query to search for tasks * @param requestNode Query to search for tasks
* @returns Number of tasks * @returns Number of tasks
*/ */
@@ -308,21 +301,21 @@ export class TaskListService {
/** /**
* Creates a new standalone task. * Creates a new standalone task.
*
* @param task Details of the new task * @param task Details of the new task
* @returns Details of the newly created task * @returns Details of the newly created task
*/ */
createNewTask(task: TaskDetailsModel): Observable<TaskDetailsModel> { createNewTask(task: TaskDetailsModel): Observable<TaskDetailsModel> {
return from(this.callApiCreateTask(task)) return from(this.callApiCreateTask(task))
.pipe( .pipe(
map((response: TaskDetailsModel) => { map((response) => new TaskDetailsModel(response)),
return new TaskDetailsModel(response);
}),
catchError((err) => this.handleError(err)) catchError((err) => this.handleError(err))
); );
} }
/** /**
* Assigns a task to a user or group. * Assigns a task to a user or group.
*
* @param taskId The task to assign * @param taskId The task to assign
* @param requestNode User or group to assign the task to * @param requestNode User or group to assign the task to
* @returns Details of the assigned task * @returns Details of the assigned task
@@ -331,32 +324,31 @@ export class TaskListService {
const assignee = { assignee: requestNode.id }; const assignee = { assignee: requestNode.id };
return from(this.callApiAssignTask(taskId, assignee)) return from(this.callApiAssignTask(taskId, assignee))
.pipe( .pipe(
map((response: TaskDetailsModel) => { map((response) => new TaskDetailsModel(response)),
return new TaskDetailsModel(response);
}),
catchError((err) => this.handleError(err)) catchError((err) => this.handleError(err))
); );
} }
/** /**
* Assigns a task to a user. * Assigns a task to a user.
*
* @param taskId ID of the task to assign * @param taskId ID of the task to assign
* @param userId ID of the user to assign the task to * @param userId ID of the user to assign the task to
* @returns Details of the assigned task * @returns Details of the assigned task
*/ */
assignTaskByUserId(taskId: string, userId: string): Observable<TaskDetailsModel> { assignTaskByUserId(taskId: string, userId: string): Observable<TaskDetailsModel> {
const assignee = <AssigneeIdentifierRepresentation> { assignee: userId }; const assignee = { assignee: userId };
return from(this.callApiAssignTask(taskId, assignee)) return from(this.callApiAssignTask(taskId, assignee))
.pipe( .pipe(
map((response: TaskDetailsModel) => { map((response) => new TaskDetailsModel(response)),
return new TaskDetailsModel(response);
}),
catchError((err) => this.handleError(err)) catchError((err) => this.handleError(err))
); );
} }
/** /**
* Claims a task for the current user. * Claims a task for the current user.
*
* @param taskId ID of the task to claim * @param taskId ID of the task to claim
* @returns Details of the claimed task * @returns Details of the claimed task
*/ */
@@ -369,6 +361,7 @@ export class TaskListService {
/** /**
* Un-claims a task for the current user. * Un-claims a task for the current user.
*
* @param taskId ID of the task to unclaim * @param taskId ID of the task to unclaim
* @returns Null response notifying when the operation is complete * @returns Null response notifying when the operation is complete
*/ */
@@ -381,6 +374,7 @@ export class TaskListService {
/** /**
* Updates the details (name, description, due date) for a task. * Updates the details (name, description, due date) for a task.
*
* @param taskId ID of the task to update * @param taskId ID of the task to update
* @param updated Data to update the task (as a `TaskUpdateRepresentation` instance). * @param updated Data to update the task (as a `TaskUpdateRepresentation` instance).
* @returns Updated task details * @returns Updated task details
@@ -388,26 +382,28 @@ export class TaskListService {
updateTask(taskId: string, updated: TaskUpdateRepresentation): Observable<TaskDetailsModel> { updateTask(taskId: string, updated: TaskUpdateRepresentation): Observable<TaskDetailsModel> {
return from(this.tasksApi.updateTask(taskId, updated)) return from(this.tasksApi.updateTask(taskId, updated))
.pipe( .pipe(
map((result) => <TaskDetailsModel> result), map((result) => result as TaskDetailsModel),
catchError((err) => this.handleError(err)) catchError((err) => this.handleError(err))
); );
} }
/** /**
* Fetches the Task Audit information in PDF format. * Fetches the Task Audit information in PDF format.
*
* @param taskId ID of the target task * @param taskId ID of the target task
* @returns Binary PDF data * @returns Binary PDF data
*/ */
fetchTaskAuditPdfById(taskId: string): Observable<Blob> { fetchTaskAuditPdfById(taskId: string): Observable<Blob> {
return from(this.tasksApi.getTaskAuditPdf(taskId)) return from(this.tasksApi.getTaskAuditPdf(taskId))
.pipe( .pipe(
map((data) => <Blob> data), map((data) => data as Blob),
catchError((err) => this.handleError(err)) catchError((err) => this.handleError(err))
); );
} }
/** /**
* Fetch the Task Audit information in JSON format * Fetch the Task Audit information in JSON format
*
* @param taskId ID of the target task * @param taskId ID of the target task
* @returns JSON data * @returns JSON data
*/ */
@@ -418,6 +414,22 @@ export class TaskListService {
); );
} }
/**
* Gets the search query for a task based on the supplied filter.
*
* @param filter The filter to use
* @returns The search query
*/
private generateTaskRequestNodeFromFilter(filterModel: FilterRepresentationModel): TaskQueryRequestRepresentationModel {
const requestNode = {
appDefinitionId: filterModel.appId,
assignment: filterModel.filter.assignment,
state: filterModel.filter.state,
sort: filterModel.filter.sort
};
return new TaskQueryRequestRepresentationModel(requestNode);
}
private callApiTasksFiltered(requestNode: TaskQueryRepresentation): Promise<TaskListModel> { private callApiTasksFiltered(requestNode: TaskQueryRepresentation): Promise<TaskListModel> {
return this.tasksApi.listTasks(requestNode); return this.tasksApi.listTasks(requestNode);
} }