From e9766a6090bb816899d838fa484d92c925711903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Popovics=20Andr=C3=A1s?= Date: Thu, 28 Sep 2017 19:17:00 +0100 Subject: [PATCH] Fix running process issue (#2391) --- .../activiti/activiti-demo.component.ts | 3 ++- .../ng2-activiti-processlist/package.json | 1 + .../process-filters.component.spec.ts | 25 ++++++++++++++++++- .../components/process-filters.component.ts | 7 ++++++ .../src/services/process.service.ts | 2 +- ng2-components/package.json | 9 ++++--- 6 files changed, 40 insertions(+), 7 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 d312a8f443..131b87d4af 100644 --- a/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts +++ b/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts @@ -25,6 +25,7 @@ import { FormService, ValidateDynamicTableRowEvent } from 'ng2-activiti-form'; import { + FilterParamsModel, FilterProcessRepresentationModel, ProcessFiltersComponent, ProcessInstance, @@ -322,7 +323,7 @@ export class ActivitiDemoComponent implements AfterViewInit, OnDestroy, OnInit { onStartProcessInstance(instance: ProcessInstance): void { this.currentProcessInstanceId = instance.id; this.activitiStartProcess.reset(); - this.reloadProcessFilters(); + this.activitiprocessfilter.selectRunningFilter(); } onCancelProcessInstance() { diff --git a/ng2-components/ng2-activiti-processlist/package.json b/ng2-components/ng2-activiti-processlist/package.json index bf20d2b1b8..518f6c1457 100644 --- a/ng2-components/ng2-activiti-processlist/package.json +++ b/ng2-components/ng2-activiti-processlist/package.json @@ -42,6 +42,7 @@ "@angular/forms": "4.3.6", "@angular/http": "4.3.6", "@angular/material": "2.0.0-beta.10", + "@angular/flex-layout": "2.0.0-beta.9", "@angular/platform-browser": "4.3.6", "@angular/platform-browser-dynamic": "4.3.6", "@angular/router": "4.3.6", diff --git a/ng2-components/ng2-activiti-processlist/src/components/process-filters.component.spec.ts b/ng2-components/ng2-activiti-processlist/src/components/process-filters.component.spec.ts index 697768312d..031886487c 100644 --- a/ng2-components/ng2-activiti-processlist/src/components/process-filters.component.spec.ts +++ b/ng2-components/ng2-activiti-processlist/src/components/process-filters.component.spec.ts @@ -38,6 +38,11 @@ describe('ActivitiFilters', () => { filter: { state: 'open', assignment: 'fake-assignee' } })); + fakeGlobalFilter.push(new FilterProcessRepresentationModel({ + name: 'Running', + filter: { state: 'open', assignment: 'fake-running' } + })); + let fakeGlobalFilterPromise = new Promise(function (resolve, reject) { resolve(fakeGlobalFilter); }); @@ -65,9 +70,27 @@ describe('ActivitiFilters', () => { filterList.onSuccess.subscribe((res) => { expect(res).toBeDefined(); expect(filterList.filters).toBeDefined(); - expect(filterList.filters.length).toEqual(2); + expect(filterList.filters.length).toEqual(3); expect(filterList.filters[0].name).toEqual('FakeInvolvedTasks'); expect(filterList.filters[1].name).toEqual('FakeMyTasks'); + expect(filterList.filters[2].name).toEqual('Running'); + done(); + }); + + filterList.ngOnInit(); + }); + + it('should select the Running process filter', (done) => { + spyOn(activitiService, 'getProcessFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise)); + const appId = '1'; + let change = new SimpleChange(null, appId, true); + filterList.ngOnChanges({ 'appId': change }); + + expect(filterList.currentFilter).toBeUndefined(); + + filterList.onSuccess.subscribe((res) => { + filterList.selectRunningFilter(); + expect(filterList.currentFilter.name).toEqual('Running'); done(); }); diff --git a/ng2-components/ng2-activiti-processlist/src/components/process-filters.component.ts b/ng2-components/ng2-activiti-processlist/src/components/process-filters.component.ts index f00b0e2e48..8935fc9ac9 100644 --- a/ng2-components/ng2-activiti-processlist/src/components/process-filters.component.ts +++ b/ng2-components/ng2-activiti-processlist/src/components/process-filters.component.ts @@ -157,6 +157,13 @@ export class ProcessFiltersComponent implements OnInit, OnChanges { } } + /** + * Select the Running filter + */ + public selectRunningFilter() { + this.selectTaskFilter(this.activiti.getRunningFilterInstance(null)); + } + /** * Select as default task filter the first in the list */ diff --git a/ng2-components/ng2-activiti-processlist/src/services/process.service.ts b/ng2-components/ng2-activiti-processlist/src/services/process.service.ts index 13714ca0e0..9107596f96 100644 --- a/ng2-components/ng2-activiti-processlist/src/services/process.service.ts +++ b/ng2-components/ng2-activiti-processlist/src/services/process.service.ts @@ -149,7 +149,7 @@ export class ProcessService extends TaskListService { }); } - private getRunningFilterInstance(appId: string): FilterProcessRepresentationModel { + public getRunningFilterInstance(appId: string): FilterProcessRepresentationModel { return new FilterProcessRepresentationModel({ 'name': 'Running', 'appId': appId, diff --git a/ng2-components/package.json b/ng2-components/package.json index edfe4271c9..4144a2b6d0 100644 --- a/ng2-components/package.json +++ b/ng2-components/package.json @@ -7,7 +7,7 @@ "clean": "rimraf node_modules", "clean-lock": "rimraf package-lock.json", "rimraf": "rimraf", - "build": "npm run toc && npm run markdownlint && npm run webpack -- --config config/webpack.build.js --progress --profile --bail && npm run build-style", + "build": "npm run pkg-build && npm run toc && npm run markdownlint && npm run webpack -- --config config/webpack.build.js --progress --profile --bail && npm run build-style", "test": "node node_modules/karma/bin/karma start --reporters mocha,coverage --single-run --component .", "test-browser": "node node_modules/karma/bin/karma start karma.conf.js --reporters kjhtml", "coverage": "", @@ -17,6 +17,7 @@ "toc": "markdown-toc -i ng2-alfresco-core/README.md && markdown-toc -i ng2-alfresco-datatable/README.md && markdown-toc -i ng2-activiti-diagrams/README.md && markdown-toc -i ng2-activiti-analytics/README.md && markdown-toc -i ng2-activiti-form/README.md && markdown-toc -i ng2-activiti-tasklist/README.md && markdown-toc -i ng2-activiti-processlist/README.md && markdown-toc -i ng2-alfresco-documentlist/README.md && markdown-toc -i ng2-alfresco-login/README.md && markdown-toc -i ng2-alfresco-search/README.md && markdown-toc -i ng2-alfresco-tag/README.md && markdown-toc -i ng2-alfresco-upload/README.md && markdown-toc -i ng2-alfresco-viewer/README.md && markdown-toc -i ng2-alfresco-webscript/README.md && markdown-toc -i ng2-alfresco-webscript/README.md && markdown-toc -i ng2-alfresco-userinfo/README.md && markdown-toc -i ng2-alfresco-social/README.md && markdown-toc -i README.md", "markdownlint": "markdownlint ng2-alfresco-core/README.md && markdownlint ng2-alfresco-datatable/README.md && markdownlint ng2-activiti-diagrams/README.md && markdownlint ng2-activiti-analytics/README.md && markdownlint ng2-activiti-form/README.md && markdownlint ng2-activiti-tasklist/README.md && markdownlint ng2-activiti-processlist/README.md && markdownlint ng2-alfresco-documentlist/README.md && markdownlint ng2-alfresco-login/README.md && markdownlint ng2-alfresco-search/README.md && markdownlint ng2-alfresco-tag/README.md && markdownlint ng2-alfresco-upload/README.md && markdownlint ng2-alfresco-viewer/README.md && markdownlint ng2-alfresco-webscript/README.md && markdownlint ng2-alfresco-webscript/README.md && markdownlint ng2-alfresco-userinfo/README.md && markdownlint ng2-alfresco-social/README.md && markdownlint README.md", "doc": "npm run toc && npm run markdownlint && npm run webpack -- --config config/webpack.doc.js --progress --profile --bail", + "docindex": "node config/buildFullDocIndex.js", "tslint": "", "prepublish": "", "tsc": "", @@ -129,8 +130,6 @@ "karma-systemjs": "0.16.0", "karma-webpack": "2.0.3", "loader-utils": "1.1.0", - "markdown-toc": "1.1.0", - "markdownlint-cli": "^0.3.1", "merge-stream": "1.0.1", "node-sass": "4.5.3", "null-loader": "0.1.1", @@ -154,7 +153,9 @@ "webpack": "2.2.1", "webpack-dev-server": "2.3.0", "webpack-merge": "2.6.1", - "wsrv": "0.1.7" + "wsrv": "0.1.7", + "markdown-toc": "1.1.0", + "markdownlint-cli": "^0.3.1" }, "license": "Apache-2.0", "module": "./index.js",