From dead0087f4679857722eadc71b14fbe593fd0428 Mon Sep 17 00:00:00 2001 From: davidcanonieto Date: Wed, 18 Dec 2019 17:33:50 +0000 Subject: [PATCH] [AAE-1022] Fix components to work on Community environments (#5296) * [AAE-1022] Fix components to work on Community environments * Remove appName input --- demo-shell/src/app/app.module.ts | 7 +------ .../cloud/community/community-cloud.component.ts | 2 -- .../community/community-filters.component.html | 2 -- .../cloud/community/community-filters.component.ts | 5 +---- .../community-process-details-cloud.component.html | 4 +--- .../community-process-details-cloud.component.ts | 5 ----- .../community-processes-cloud.component.html | 2 -- .../community-processes-cloud.component.ts | 6 ------ .../community-start-process-cloud.component.html | 1 - .../community-start-task-cloud.component.html | 1 - .../community/community-task-cloud.component.html | 2 -- .../community-task-details-cloud.component.html | 4 +--- .../community-task-details-cloud.component.ts | 6 +----- .../lib/form/components/form-cloud.component.ts | 4 ++-- .../form-definition-selector-cloud.component.ts | 2 +- .../edit-process-filter-cloud.component.ts | 2 +- .../components/process-filters-cloud.component.ts | 12 +++++++++--- .../models/process-filter-cloud.model.ts | 2 +- .../components/process-header-cloud.component.ts | 4 ++-- .../services/process-header-cloud.service.ts | 2 +- .../components/process-list-cloud.component.ts | 4 ++-- .../services/process-list-cloud.service.ts | 2 +- .../components/start-process-cloud.component.ts | 5 ++++- .../services/start-process-cloud.service.ts | 2 +- .../lib/task/directives/claim-task.directive.ts | 4 ++-- .../lib/task/directives/complete-task.directive.ts | 4 ++-- .../lib/task/directives/unclaim-task.directive.ts | 4 ++-- .../src/lib/task/services/task-cloud.service.ts | 14 +++++++------- .../components/start-task-cloud.component.html | 3 ++- .../components/start-task-cloud.component.ts | 2 +- .../components/edit-task-filter-cloud.component.ts | 2 +- .../components/task-filters-cloud.component.ts | 10 +++++++--- .../task/task-filters/models/filter-cloud.model.ts | 2 +- .../components/task-form-cloud.component.ts | 14 ++++++++++---- .../components/task-header-cloud.component.ts | 6 +++--- .../components/task-list-cloud.component.ts | 2 +- .../task-list/services/task-list-cloud.service.ts | 2 +- 37 files changed, 70 insertions(+), 87 deletions(-) diff --git a/demo-shell/src/app/app.module.ts b/demo-shell/src/app/app.module.ts index a53a2bc8ba..ea808c5f2e 100644 --- a/demo-shell/src/app/app.module.ts +++ b/demo-shell/src/app/app.module.ts @@ -84,10 +84,7 @@ import { environment } from '../environments/environment'; import { AppCloudSharedModule } from './components/cloud/shared/cloud.shared.module'; import { DemoErrorComponent } from './components/error/demo-error.component'; import { - ProcessServicesCloudModule, - UserPreferenceCloudService, - PROCESS_FILTERS_SERVICE_TOKEN, - TASK_FILTERS_SERVICE_TOKEN + ProcessServicesCloudModule } from '@alfresco/adf-process-services-cloud'; import { registerLocaleData } from '@angular/common'; @@ -199,8 +196,6 @@ registerLocaleData(localeSv); provide: HTTP_INTERCEPTORS, useClass: AuthBearerInterceptor, multi: true }, - { provide: PROCESS_FILTERS_SERVICE_TOKEN, useClass: UserPreferenceCloudService }, - { provide: TASK_FILTERS_SERVICE_TOKEN, useClass: UserPreferenceCloudService }, { provide: AppConfigService, useClass: DebugAppConfigService }, // not use this service in production { provide: TRANSLATION_PROVIDER, diff --git a/demo-shell/src/app/components/cloud/community/community-cloud.component.ts b/demo-shell/src/app/components/cloud/community/community-cloud.component.ts index 52c434b18d..1f74a04ec6 100644 --- a/demo-shell/src/app/components/cloud/community/community-cloud.component.ts +++ b/demo-shell/src/app/components/cloud/community/community-cloud.component.ts @@ -33,8 +33,6 @@ import { CloudLayoutService } from '../services/cloud-layout.service'; }) export class CommunityCloudComponent { - appName: string = ''; - constructor( private router: Router, private route: ActivatedRoute, diff --git a/demo-shell/src/app/components/cloud/community/community-filters.component.html b/demo-shell/src/app/components/cloud/community/community-filters.component.html index 7daa8b33ac..510c7e3ac9 100644 --- a/demo-shell/src/app/components/cloud/community/community-filters.component.html +++ b/demo-shell/src/app/components/cloud/community/community-filters.component.html @@ -7,7 +7,6 @@ @@ -22,7 +21,6 @@ diff --git a/demo-shell/src/app/components/cloud/community/community-filters.component.ts b/demo-shell/src/app/components/cloud/community/community-filters.component.ts index f3cf42d129..ea998d5703 100644 --- a/demo-shell/src/app/components/cloud/community/community-filters.component.ts +++ b/demo-shell/src/app/components/cloud/community/community-filters.component.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { Component, ViewEncapsulation, Input, OnInit } from '@angular/core'; +import { Component, ViewEncapsulation, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { Router, ActivatedRoute } from '@angular/router'; import { CloudLayoutService } from '../services/cloud-layout.service'; @@ -26,9 +26,6 @@ import { CloudLayoutService } from '../services/cloud-layout.service'; }) export class CommunityCloudFiltersDemoComponent implements OnInit { - @Input() - appName: string = 'community'; - currentTaskFilter$: Observable; currentProcessFilter$: Observable; diff --git a/demo-shell/src/app/components/cloud/community/community-process-details-cloud.component.html b/demo-shell/src/app/components/cloud/community/community-process-details-cloud.component.html index 018bc50c78..2070566105 100644 --- a/demo-shell/src/app/components/cloud/community/community-process-details-cloud.component.html +++ b/demo-shell/src/app/components/cloud/community/community-process-details-cloud.component.html @@ -3,14 +3,13 @@ arrow_back Go Back -

Simple page to show the process instance: {{ processInstanceId }} of the app: {{ appName }}

+

Simple page to show the process instance: {{ processInstanceId }}

@@ -18,7 +17,6 @@
diff --git a/demo-shell/src/app/components/cloud/community/community-process-details-cloud.component.ts b/demo-shell/src/app/components/cloud/community/community-process-details-cloud.component.ts index aa959a46e9..d8b1ccc56a 100644 --- a/demo-shell/src/app/components/cloud/community/community-process-details-cloud.component.ts +++ b/demo-shell/src/app/components/cloud/community/community-process-details-cloud.component.ts @@ -25,16 +25,11 @@ import { ActivatedRoute, Router } from '@angular/router'; export class CommunityProcessDetailsCloudDemoComponent { processInstanceId: string; - appName: string; constructor(private route: ActivatedRoute, private router: Router) { this.route.params.subscribe((params) => { this.processInstanceId = params.processInstanceId; }); - - this.route.parent.params.subscribe((params) => { - this.appName = params.appName; - }); } onGoBack() { diff --git a/demo-shell/src/app/components/cloud/community/community-processes-cloud.component.html b/demo-shell/src/app/components/cloud/community/community-processes-cloud.component.html index 17c46f9942..1e2f6bfeec 100644 --- a/demo-shell/src/app/components/cloud/community/community-processes-cloud.component.html +++ b/demo-shell/src/app/components/cloud/community/community-processes-cloud.component.html @@ -1,7 +1,6 @@
{ - this.appName = params.appName; - }); - this.route.queryParams.subscribe((params) => { if (Object.keys(params).length > 0) { this.isFilterLoaded = true; diff --git a/demo-shell/src/app/components/cloud/community/community-start-process-cloud.component.html b/demo-shell/src/app/components/cloud/community/community-start-process-cloud.component.html index df2ca1cb8b..d5aeaec39d 100644 --- a/demo-shell/src/app/components/cloud/community/community-start-process-cloud.component.html +++ b/demo-shell/src/app/components/cloud/community/community-start-process-cloud.component.html @@ -1,6 +1,5 @@ diff --git a/demo-shell/src/app/components/cloud/community/community-start-task-cloud.component.html b/demo-shell/src/app/components/cloud/community/community-start-task-cloud.component.html index 2a305e9ba5..9975b99cc6 100644 --- a/demo-shell/src/app/components/cloud/community/community-start-task-cloud.component.html +++ b/demo-shell/src/app/components/cloud/community/community-start-task-cloud.component.html @@ -1,5 +1,4 @@ diff --git a/demo-shell/src/app/components/cloud/community/community-task-cloud.component.html b/demo-shell/src/app/components/cloud/community/community-task-cloud.component.html index 74eae4b803..b1cde80f9b 100644 --- a/demo-shell/src/app/components/cloud/community/community-task-cloud.component.html +++ b/demo-shell/src/app/components/cloud/community/community-task-cloud.component.html @@ -1,7 +1,6 @@
Simple page to show the taskId: {{ taskId }} of the app: {{ appName }} +

Simple page to show the taskId: {{ taskId }}

diff --git a/demo-shell/src/app/components/cloud/community/community-task-details-cloud.component.ts b/demo-shell/src/app/components/cloud/community/community-task-details-cloud.component.ts index 91ffdf593f..716c755860 100644 --- a/demo-shell/src/app/components/cloud/community/community-task-details-cloud.component.ts +++ b/demo-shell/src/app/components/cloud/community/community-task-details-cloud.component.ts @@ -26,7 +26,6 @@ import { NotificationService } from '@alfresco/adf-core'; export class CommunityTaskDetailsCloudDemoComponent { taskId: string; - appName: string; constructor( private route: ActivatedRoute, @@ -36,13 +35,10 @@ export class CommunityTaskDetailsCloudDemoComponent { this.route.params.subscribe((params) => { this.taskId = params.taskId; }); - this.route.parent.params.subscribe((params) => { - this.appName = params.appName; - }); } isTaskValid(): boolean { - return this.appName !== undefined && this.taskId !== undefined; + return this.taskId !== undefined; } goBack() { diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts index 3f7341d5c5..bfd06e4942 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts @@ -51,9 +51,9 @@ import { TaskDetailsCloudModel } from '../../task/start-task/models/task-details }) export class FormCloudComponent extends FormBaseComponent implements OnChanges, OnDestroy { - /** App id to fetch corresponding form and values. */ + /** App name to fetch corresponding form and values. */ @Input() - appName: string; + appName: string = ''; /** The application version to use when fetching data */ @Input() diff --git a/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.ts b/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.ts index 26f74c15bb..2f4cdeae63 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-definition-selector-cloud.component.ts @@ -31,7 +31,7 @@ export class FormDefinitionSelectorCloudComponent implements OnInit { /** Name of the application. If specified, this shows the users who have access to the app. */ @Input() - appName: string; + appName: string = ''; /** Emitted when a form is selected. */ @Output() diff --git a/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts b/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts index 7d9770c4d0..79d12f69e8 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts @@ -51,7 +51,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes /** The name of the application. */ @Input() - appName: string; + appName: string = ''; /** Id of the process instance filter. */ @Input() diff --git a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts index 7b0a50a134..ab4f3d9f4d 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, OnDestroy } from '@angular/core'; +import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, OnDestroy, OnInit } from '@angular/core'; import { Observable, Subject } from 'rxjs'; import { ProcessFilterCloudService } from '../services/process-filter-cloud.service'; import { ProcessFilterCloudModel } from '../models/process-filter-cloud.model'; @@ -28,11 +28,11 @@ import { takeUntil } from 'rxjs/operators'; templateUrl: './process-filters-cloud.component.html', styleUrls: ['process-filters-cloud.component.scss'] }) -export class ProcessFiltersCloudComponent implements OnChanges, OnDestroy { +export class ProcessFiltersCloudComponent implements OnInit, OnChanges, OnDestroy { /** (required) The application name */ @Input() - appName: string; + appName: string = ''; /** (optional) The filter to be selected by default */ @Input() @@ -66,6 +66,12 @@ export class ProcessFiltersCloudComponent implements OnChanges, OnDestroy { private processFilterCloudService: ProcessFilterCloudService, private translationService: TranslationService ) { } + ngOnInit() { + if (this.appName === '') { + this.getFilters(this.appName); + } + } + ngOnChanges(changes: SimpleChanges) { const appName = changes['appName']; const filter = changes['filterParam']; diff --git a/lib/process-services-cloud/src/lib/process/process-filters/models/process-filter-cloud.model.ts b/lib/process-services-cloud/src/lib/process/process-filters/models/process-filter-cloud.model.ts index 0a580d0ee9..dad5c91254 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/models/process-filter-cloud.model.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/models/process-filter-cloud.model.ts @@ -41,7 +41,7 @@ export class ProcessFilterCloudModel { this.key = obj.key || null; this.icon = obj.icon || null; this.index = obj.index || null; - this.appName = obj.appName || null; + this.appName = obj.appName || obj.appName === '' ? obj.appName : null; this.processInstanceId = obj.processInstanceId || null; this.processName = obj.processName || null; this.initiator = obj.initiator || null; diff --git a/lib/process-services-cloud/src/lib/process/process-header/components/process-header-cloud.component.ts b/lib/process-services-cloud/src/lib/process/process-header/components/process-header-cloud.component.ts index c5a9eddd18..5cd21102a0 100644 --- a/lib/process-services-cloud/src/lib/process/process-header/components/process-header-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/process/process-header/components/process-header-cloud.component.ts @@ -30,7 +30,7 @@ export class ProcessHeaderCloudComponent implements OnChanges { /** (Required) The name of the application. */ @Input() - appName: string; + appName: string = ''; /** (Required) The id of the process instance. */ @Input() @@ -50,7 +50,7 @@ export class ProcessHeaderCloudComponent implements OnChanges { } ngOnChanges() { - if (this.appName && this.processInstanceId) { + if ((this.appName || this.appName === '') && this.processInstanceId) { this.loadProcessInstanceDetails(this.appName, this.processInstanceId); } } diff --git a/lib/process-services-cloud/src/lib/process/process-header/services/process-header-cloud.service.ts b/lib/process-services-cloud/src/lib/process/process-header/services/process-header-cloud.service.ts index 99ddd05c97..2af94ec53e 100644 --- a/lib/process-services-cloud/src/lib/process/process-header/services/process-header-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/process/process-header/services/process-header-cloud.service.ts @@ -41,7 +41,7 @@ export class ProcessHeaderCloudService extends BaseCloudService { * @returns Process instance details */ getProcessInstanceById(appName: string, processInstanceId: string): Observable { - if (appName && processInstanceId) { + if ((appName || appName === '') && processInstanceId) { const url = `${this.getBasePath(appName)}/query/v1/process-instances/${processInstanceId}`; return this.get(url).pipe( diff --git a/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.ts b/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.ts index 179256ae74..743160dc47 100644 --- a/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.ts @@ -44,7 +44,7 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan /** The name of the application. */ @Input() - appName: string; + appName: string = ''; /** Name of the initiator of the process. */ @Input() @@ -185,7 +185,7 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan reload() { this.requestNode = this.createRequestNode(); - if (this.requestNode.appName) { + if (this.requestNode.appName || this.requestNode.appName === '') { this.load(this.requestNode); } else { this.rows = []; diff --git a/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.ts b/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.ts index e6577ddc09..3bd71fee57 100644 --- a/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.ts @@ -37,7 +37,7 @@ export class ProcessListCloudService extends BaseCloudService { * @returns Process information */ getProcessByRequest(requestNode: ProcessQueryCloudRequestModel): Observable { - if (requestNode.appName) { + if (requestNode.appName || requestNode.appName === '') { const queryUrl = `${this.getBasePath(requestNode.appName)}/query/v1/process-instances`; const queryParams = this.buildQueryParams(requestNode); const sortingParams = this.buildSortingParam(requestNode.sorting); diff --git a/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.ts b/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.ts index 8a1c788a7e..9016563923 100755 --- a/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.ts @@ -46,7 +46,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy /** (required) Name of the app. */ @Input() - appName: string; + appName: string = ''; /** Maximum length of the process name. */ @Input() @@ -120,6 +120,9 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy ngOnChanges(changes: SimpleChanges) { if (changes['appName'] && changes['appName'].currentValue !== changes['appName'].previousValue) { this.appName = changes['appName'].currentValue; + } + + if (this.appName || this.appName === '') { this.loadProcessDefinitions(); } } diff --git a/lib/process-services-cloud/src/lib/process/start-process/services/start-process-cloud.service.ts b/lib/process-services-cloud/src/lib/process/start-process/services/start-process-cloud.service.ts index 3e8143209e..8c966e1359 100755 --- a/lib/process-services-cloud/src/lib/process/start-process/services/start-process-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/process/start-process/services/start-process-cloud.service.ts @@ -42,7 +42,7 @@ export class StartProcessCloudService extends BaseCloudService { * @returns Array of process definitions */ getProcessDefinitions(appName: string): Observable { - if (appName) { + if (appName || appName === '') { const url = `${this.getBasePath(appName)}/rb/v1/process-definitions`; return this.get(url).pipe( diff --git a/lib/process-services-cloud/src/lib/task/directives/claim-task.directive.ts b/lib/process-services-cloud/src/lib/task/directives/claim-task.directive.ts index 0f80194dd4..c106285f7c 100644 --- a/lib/process-services-cloud/src/lib/task/directives/claim-task.directive.ts +++ b/lib/process-services-cloud/src/lib/task/directives/claim-task.directive.ts @@ -30,7 +30,7 @@ export class ClaimTaskDirective implements OnInit { /** (Required) The name of the application. */ @Input() - appName: string; + appName: string = ''; /** Emitted when the task is completed. */ @Output() @@ -68,7 +68,7 @@ export class ClaimTaskDirective implements OnInit { } isAppValid(): boolean { - return (this.appName && this.appName.length > 0); + return !!this.appName || this.appName === ''; } @HostListener('click') diff --git a/lib/process-services-cloud/src/lib/task/directives/complete-task.directive.ts b/lib/process-services-cloud/src/lib/task/directives/complete-task.directive.ts index 378bd9d60e..a80c3b883c 100644 --- a/lib/process-services-cloud/src/lib/task/directives/complete-task.directive.ts +++ b/lib/process-services-cloud/src/lib/task/directives/complete-task.directive.ts @@ -29,7 +29,7 @@ export class CompleteTaskDirective implements OnInit { /** (Required) The name of the application. */ @Input() - appName: string; + appName: string = ''; /** Emitted when the task is completed. */ @Output() @@ -65,7 +65,7 @@ export class CompleteTaskDirective implements OnInit { } isAppValid(): boolean { - return (this.appName && this.appName.length > 0); + return !!this.appName || this.appName === ''; } @HostListener('click') diff --git a/lib/process-services-cloud/src/lib/task/directives/unclaim-task.directive.ts b/lib/process-services-cloud/src/lib/task/directives/unclaim-task.directive.ts index 50a7bde7c3..0e5ffc68f4 100644 --- a/lib/process-services-cloud/src/lib/task/directives/unclaim-task.directive.ts +++ b/lib/process-services-cloud/src/lib/task/directives/unclaim-task.directive.ts @@ -29,7 +29,7 @@ export class UnClaimTaskDirective implements OnInit { /** (Required) The name of the application. */ @Input() - appName: string; + appName: string = ''; /** Emitted when the task is completed. */ @Output() @@ -66,7 +66,7 @@ export class UnClaimTaskDirective implements OnInit { } isAppValid(): boolean { - return (this.appName && this.appName.length > 0); + return !!this.appName || this.appName === ''; } @HostListener('click') diff --git a/lib/process-services-cloud/src/lib/task/services/task-cloud.service.ts b/lib/process-services-cloud/src/lib/task/services/task-cloud.service.ts index cf8ba45ce9..81c52631ca 100644 --- a/lib/process-services-cloud/src/lib/task/services/task-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/task/services/task-cloud.service.ts @@ -47,7 +47,7 @@ export class TaskCloudService extends BaseCloudService { * @returns Details of the task that was completed */ completeTask(appName: string, taskId: string): Observable { - if (appName && taskId) { + if ((appName || appName === '') && taskId) { const url = `${this.getBasePath(appName)}/rb/v1/tasks/${taskId}/complete`; const payload = { 'payloadType': 'CompleteTaskPayload' }; @@ -103,7 +103,7 @@ export class TaskCloudService extends BaseCloudService { * @returns Details of the claimed task */ claimTask(appName: string, taskId: string, assignee: string): Observable { - if (appName && taskId) { + if ((appName || appName === '') && taskId) { const queryUrl = `${this.getBasePath(appName)}/rb/v1/tasks/${taskId}/claim?assignee=${assignee}`; return this.post(queryUrl).pipe( @@ -125,7 +125,7 @@ export class TaskCloudService extends BaseCloudService { * @returns Details of the task that was unclaimed */ unclaimTask(appName: string, taskId: string): Observable { - if (appName && taskId) { + if ((appName || appName === '') && taskId) { const queryUrl = `${this.getBasePath(appName)}/rb/v1/tasks/${taskId}/release`; return this.post(queryUrl).pipe( @@ -147,7 +147,7 @@ export class TaskCloudService extends BaseCloudService { * @returns Task details */ getTaskById(appName: string, taskId: string): Observable { - if (appName && taskId) { + if ((appName || appName === '') && taskId) { const queryUrl = `${this.getBasePath(appName)}/query/v1/tasks/${taskId}`; return this.get(queryUrl).pipe( @@ -182,7 +182,7 @@ export class TaskCloudService extends BaseCloudService { * @returns Updated task details */ updateTask(appName: string, taskId: string, payload: any): Observable { - if (appName && taskId) { + if ((appName || appName === '') && taskId) { payload.payloadType = 'UpdateTaskPayload'; const queryUrl = `${this.getBasePath(appName)}/rb/v1/tasks/${taskId}`; @@ -202,7 +202,7 @@ export class TaskCloudService extends BaseCloudService { * @returns Candidate users */ getCandidateUsers(appName: string, taskId: string): Observable { - if (appName && taskId) { + if ((appName || appName === '') && taskId) { const queryUrl = `${this.getBasePath(appName)}/query/v1/tasks/${taskId}/candidate-users`; return this.get(queryUrl); } else { @@ -218,7 +218,7 @@ export class TaskCloudService extends BaseCloudService { * @returns Candidate groups */ getCandidateGroups(appName: string, taskId: string): Observable { - if (appName && taskId) { + if ((appName || appName === '') && taskId) { const queryUrl = `${this.getBasePath(appName)}/query/v1/tasks/${taskId}/candidate-groups`; return this.get(queryUrl); } else { diff --git a/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.html b/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.html index 3ffb1f54a5..6e5f77a69f 100644 --- a/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.html +++ b/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.html @@ -79,7 +79,8 @@ (selectGroup)="onCandidateGroupSelect($event)" (removeGroup)="onCandidateGroupRemove($event)"> - diff --git a/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.ts b/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.ts index 2a93253aee..67708c78d1 100644 --- a/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.ts @@ -52,7 +52,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy { /** (required) Name of the app. */ @Input() - appName: string; + appName: string = ''; /** Maximum length of the task name. */ @Input() diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.ts index f760481c4e..d4dc2e5d9d 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.ts @@ -52,7 +52,7 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro /** (required) Name of the app. */ @Input() - appName: string; + appName: string = ''; /** (required) ID of the task filter. */ @Input() diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.ts index 4e09b917b5..16cf441648 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, OnDestroy } from '@angular/core'; +import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, OnDestroy, OnInit } from '@angular/core'; import { Observable, Subject } from 'rxjs'; import { TaskFilterCloudService } from '../services/task-filter-cloud.service'; import { TaskFilterCloudModel, FilterParamsModel } from '../models/filter-cloud.model'; @@ -27,10 +27,10 @@ import { takeUntil } from 'rxjs/operators'; templateUrl: './task-filters-cloud.component.html', styleUrls: ['task-filters-cloud.component.scss'] }) -export class TaskFiltersCloudComponent implements OnChanges, OnDestroy { +export class TaskFiltersCloudComponent implements OnInit, OnChanges, OnDestroy { /** Display filters available to the current user for the application with the specified name. */ @Input() - appName: string; + appName: string = ''; /** * Parameters to use for the task filter cloud. If there is no match then the default filter @@ -66,6 +66,10 @@ export class TaskFiltersCloudComponent implements OnChanges, OnDestroy { constructor(private taskFilterCloudService: TaskFilterCloudService, private translationService: TranslationService) { } + ngOnInit() { + this.getFilters(this.appName); + } + ngOnChanges(changes: SimpleChanges) { const appName = changes['appName']; const filter = changes['filterParam']; diff --git a/lib/process-services-cloud/src/lib/task/task-filters/models/filter-cloud.model.ts b/lib/process-services-cloud/src/lib/task/task-filters/models/filter-cloud.model.ts index dfe8d5ffe8..0f708ae224 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/models/filter-cloud.model.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/models/filter-cloud.model.ts @@ -46,7 +46,7 @@ export class TaskFilterCloudModel { this.key = obj.key || null; this.icon = obj.icon || null; this.index = obj.index || null; - this.appName = obj.appName || null; + this.appName = obj.appName || obj.appName === '' ? obj.appName : null; this.status = obj.status || null; this.sort = obj.sort || null; this.assignee = obj.assignee || null; diff --git a/lib/process-services-cloud/src/lib/task/task-form/components/task-form-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-form/components/task-form-cloud.component.ts index 72b47b9655..05db0aa2fa 100644 --- a/lib/process-services-cloud/src/lib/task/task-form/components/task-form-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-form/components/task-form-cloud.component.ts @@ -17,7 +17,7 @@ import { Component, EventEmitter, Input, OnChanges, - Output, SimpleChanges + Output, SimpleChanges, OnInit } from '@angular/core'; import { TaskDetailsCloudModel } from '../../start-task/models/task-details-cloud.model'; import { TaskCloudService } from '../../services/task-cloud.service'; @@ -31,11 +31,11 @@ import { DateCloudWidgetComponent } from '../../../form/components/widgets/date/ templateUrl: './task-form-cloud.component.html', styleUrls: ['./task-form-cloud.component.scss'] }) -export class TaskFormCloudComponent implements OnChanges { +export class TaskFormCloudComponent implements OnInit, OnChanges { /** App id to fetch corresponding form and values. */ @Input() - appName: string; + appName: string = ''; /** Task id to fetch corresponding form and values. */ @Input() @@ -108,9 +108,15 @@ export class TaskFormCloudComponent implements OnChanges { this.formRenderingService.setComponentTypeResolver('date', () => DateCloudWidgetComponent, true); } + ngOnInit() { + if (this.appName === '' && this.taskId) { + this.loadTask(); + } + } + ngOnChanges(changes: SimpleChanges) { const appName = changes['appName']; - if (appName && (appName.currentValue || appName.currentValue === '') && this.taskId) { + if (appName && (appName.currentValue !== appName.previousValue) && this.taskId) { this.loadTask(); return; } diff --git a/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.ts index 8c7e2245f2..c90cf50571 100644 --- a/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.ts @@ -45,7 +45,7 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy, OnChanges { /** (Required) The name of the application. */ @Input() - appName: string; + appName: string = ''; /** (Required) The id of the task. */ @Input() @@ -103,7 +103,7 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy, OnChanges { ngOnChanges() { this.taskDetails = {}; - if (this.appName && this.taskId) { + if ((this.appName || this.appName === '') && this.taskId) { this.loadTaskDetailsById(this.appName, this.taskId); } else { this.error.emit('App Name and Task Id are mandatory'); @@ -301,7 +301,7 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy, OnChanges { } isTaskValid(): boolean { - return (this.appName) && !!this.taskId; + return (this.appName || this.appName === '') && !!this.taskId; } isTaskAssigned(): boolean { diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts index 39bb584430..b163063cdc 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts @@ -233,7 +233,7 @@ export class TaskListCloudComponent extends DataTableSchema implements OnChanges reload() { this.requestNode = this.createRequestNode(); - if (this.requestNode.appName) { + if (this.requestNode.appName || this.requestNode.appName === '') { this.load(this.requestNode); } else { this.rows = []; diff --git a/lib/process-services-cloud/src/lib/task/task-list/services/task-list-cloud.service.ts b/lib/process-services-cloud/src/lib/task/task-list/services/task-list-cloud.service.ts index 4d461e4d9a..f80ac6b4c3 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/services/task-list-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/services/task-list-cloud.service.ts @@ -38,7 +38,7 @@ export class TaskListCloudService extends BaseCloudService { * @returns Task information */ getTaskByRequest(requestNode: TaskQueryCloudRequestModel): Observable { - if (requestNode.appName) { + if (requestNode.appName || requestNode.appName === '') { const queryUrl = `${this.getBasePath(requestNode.appName)}/query/v1/tasks`; const queryParams = this.buildQueryParams(requestNode); const sortingParams = this.buildSortingParam(requestNode.sorting);