From e09d317d1e5b81e0156ab04550aa63971138acda Mon Sep 17 00:00:00 2001 From: Maurizio Vitale Date: Tue, 9 May 2017 15:46:58 +0200 Subject: [PATCH] [ADF-242] Select the first in the list when the report is deleted (#1862) * ADF-242 Select the first in the list when the report is deleted * Update README.md --- .../components/activiti/activiti-demo.component.html | 1 + .../components/activiti/activiti-demo.component.ts | 9 ++------- ng2-components/ng2-activiti-analytics/README.md | 8 +++++--- .../src/components/analytics-report-list.component.ts | 11 +++++++++++ 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/demo-shell-ng2/app/components/activiti/activiti-demo.component.html b/demo-shell-ng2/app/components/activiti/activiti-demo.component.html index 9599799d10..1280bc92eb 100644 --- a/demo-shell-ng2/app/components/activiti/activiti-demo.component.html +++ b/demo-shell-ng2/app/components/activiti/activiti-demo.component.html @@ -149,6 +149,7 @@
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 e74a6390d2..ff2b792bc2 100644 --- a/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts +++ b/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts @@ -79,6 +79,7 @@ export class ActivitiDemoComponent implements AfterViewInit { appId: number = null; fileShowed: boolean = false; + selectFirstReport: boolean = false; content: Blob; contentName: string; @@ -213,14 +214,8 @@ export class ActivitiDemoComponent implements AfterViewInit { } onReportDeleted() { + this.selectFirstReport = true; this.analyticsreportlist.reload(); - this.selectFirstElementInReportList(); - } - - selectFirstElementInReportList() { - if (!this.analyticsreportlist.isReportsEmpty()) { - this.analyticsreportlist.selectReport(this.analyticsreportlist.reports[0]); - } } navigateStartProcess() { diff --git a/ng2-components/ng2-activiti-analytics/README.md b/ng2-components/ng2-activiti-analytics/README.md index b29f2e6ffc..9bd99044bc 100644 --- a/ng2-components/ng2-activiti-analytics/README.md +++ b/ng2-components/ng2-activiti-analytics/README.md @@ -178,9 +178,11 @@ platformBrowserDynamic().bootstrapModule(AppModule); #### Options -| Name | Type | Required | Description | -| --- | --- | --- | --- | -| `layoutType` | {string} | required | Define the layout of the apps. There are two possible values: GRID or LIST. LIST is the default value| +| Name | Type | Required | Default | Description | +| --- | --- | --- | --- | --- | +| `appId` | {string} | optional | | The application id | +| `layoutType` | {string} | required | | Define the layout of the apps. There are two possible values: GRID or LIST. LIST is the default value| +| `selectFirst` | {boolean} | optional | false | Change the value to true if you want select the first item in the list as default| ## Basic usage example Activiti Analytics diff --git a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.ts b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.ts index b6d7b4014b..7b726035ec 100644 --- a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.ts +++ b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.ts @@ -37,6 +37,9 @@ export class AnalyticsReportListComponent implements OnInit { @Input() appId: string; + @Input() + selectFirst: boolean = false; + @Output() reportClick: EventEmitter = new EventEmitter(); @@ -90,6 +93,9 @@ export class AnalyticsReportListComponent implements OnInit { res.forEach((report) => { this.reportObserver.next(report); }); + if (this.selectFirst) { + this.selectFirstReport(); + } this.onSuccess.emit(res); } }, @@ -143,6 +149,11 @@ export class AnalyticsReportListComponent implements OnInit { this.reportClick.emit(report); } + selectFirstReport() { + this.selectReport(this.reports[0]); + this.selectFirst = false; + } + isSelected(report: any) { return this.currentReport === report ? true : false; }