From 8d619da66748bf0f346511ee9c1ac8acf477820c Mon Sep 17 00:00:00 2001 From: Mario Romano Date: Tue, 13 Dec 2016 22:53:49 +0000 Subject: [PATCH] #1146 load right filter on create task (#1250) --- .../activiti/activiti-demo.component.ts | 22 ++++++++++++++----- .../components/activiti-filters.component.ts | 2 +- .../components/activiti-filters.component.ts | 2 +- .../activiti-task-details.component.ts | 21 +++++++++++++++--- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts b/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts index 307e4207bd..7936e77575 100644 --- a/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts +++ b/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts @@ -36,7 +36,7 @@ import { ObjectDataTableAdapter, DataSorting } from 'ng2-alfresco-datatable'; - +import { AlfrescoApiService } from 'ng2-alfresco-core'; import { FormRenderingService } from 'ng2-activiti-form'; import { /*CustomEditorComponent*/ CustomStencil01 } from './custom-editor/custom-editor.component'; @@ -96,6 +96,7 @@ export class ActivitiDemoComponent implements AfterViewInit { constructor(private elementRef: ElementRef, private route: ActivatedRoute, + private apiService: AlfrescoApiService, private formRenderingService: FormRenderingService) { this.dataTasks = new ObjectDataTableAdapter( [], @@ -153,6 +154,8 @@ export class ActivitiDemoComponent implements AfterViewInit { } onStartTaskSuccess(event: any) { + this.activitifilter.selectFirstFilter(); + this.taskFilter = this.activitifilter.getCurrentFilter(); this.activititasklist.reload(); } @@ -218,11 +221,18 @@ export class ActivitiDemoComponent implements AfterViewInit { componentHandler.upgradeAllRegistered(); } - // Load Activiti stencil controllers - let s = document.createElement('script'); - s.type = 'text/javascript'; - s.src = 'http://localhost:9999/activiti-app/app/rest/script-files/controllers'; - this.elementRef.nativeElement.appendChild(s); + this.loadStencilScriptsInPageFromActiviti(); + } + + loadStencilScriptsInPageFromActiviti() { + this.apiService.getInstance().activiti.scriptFileApi.getControllers().then(function (response) { + if (response) { + let s = document.createElement('script'); + s.type = 'text/javascript'; + s.src = response; + this.elementRef.nativeElement.appendChild(s); + } + }); } } diff --git a/ng2-components/ng2-activiti-processlist/src/components/activiti-filters.component.ts b/ng2-components/ng2-activiti-processlist/src/components/activiti-filters.component.ts index 97025c5902..d19c9fae93 100644 --- a/ng2-components/ng2-activiti-processlist/src/components/activiti-filters.component.ts +++ b/ng2-components/ng2-activiti-processlist/src/components/activiti-filters.component.ts @@ -145,7 +145,7 @@ export class ActivitiProcessFilters implements OnInit, OnChanges { /** * Select the first filter of a list if present */ - private selectFirstFilter() { + public selectFirstFilter() { if (!this.isFilterListEmpty()) { this.currentFilter = this.filters[0]; } else { diff --git a/ng2-components/ng2-activiti-tasklist/src/components/activiti-filters.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/activiti-filters.component.ts index 845f100ae2..a5ae731ce0 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/activiti-filters.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/activiti-filters.component.ts @@ -154,7 +154,7 @@ export class ActivitiFilters implements OnInit, OnChanges { /** * Select the first filter of a list if present */ - private selectFirstFilter() { + public selectFirstFilter() { if (!this.isFilterListEmpty()) { this.currentFilter = this.filters[0]; } else { diff --git a/ng2-components/ng2-activiti-tasklist/src/components/activiti-task-details.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/activiti-task-details.component.ts index d741b37ce7..54b1aeb9d2 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/activiti-task-details.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/activiti-task-details.component.ts @@ -15,7 +15,18 @@ * limitations under the License. */ -import { Component, Input, OnInit, ViewChild, Output, EventEmitter, TemplateRef, OnChanges, SimpleChanges, DebugElement } from '@angular/core'; +import { + Component, + Input, + OnInit, + ViewChild, + Output, + EventEmitter, + TemplateRef, + OnChanges, + SimpleChanges, + DebugElement +} from '@angular/core'; import { AlfrescoTranslationService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; import { ActivitiTaskListService } from './../services/activiti-tasklist.service'; import { TaskDetailsModel } from '../models/task-details.model'; @@ -131,8 +142,8 @@ export class ActivitiTaskDetails implements OnInit, OnChanges { */ hasFormKey() { return (this.taskDetails - && this.taskDetails.formKey - && this.taskDetails.formKey !== 'null'); + && this.taskDetails.formKey + && this.taskDetails.formKey !== 'null'); } isTaskActive() { @@ -151,6 +162,10 @@ export class ActivitiTaskDetails implements OnInit, OnChanges { (res: TaskDetailsModel) => { this.taskDetails = res; + if (this.taskDetails.name === 'null') { + this.taskDetails.name = 'No name'; + } + let endDate: any = res.endDate; this.readOnlyForm = !!(endDate && !isNaN(endDate.getTime()));