[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
This commit is contained in:
Maurizio Vitale 2017-05-09 15:46:58 +02:00 committed by Eugenio Romano
parent 22bbffdb21
commit e09d317d1e
4 changed files with 19 additions and 10 deletions

View File

@ -149,6 +149,7 @@
<hr> <hr>
<analytics-report-list <analytics-report-list
[appId]="appId" [appId]="appId"
[selectFirst]="selectFirstReport"
(reportClick)="onReportClick($event)" (reportClick)="onReportClick($event)"
#analyticsreportlist> #analyticsreportlist>
</analytics-report-list> </analytics-report-list>

View File

@ -79,6 +79,7 @@ export class ActivitiDemoComponent implements AfterViewInit {
appId: number = null; appId: number = null;
fileShowed: boolean = false; fileShowed: boolean = false;
selectFirstReport: boolean = false;
content: Blob; content: Blob;
contentName: string; contentName: string;
@ -213,14 +214,8 @@ export class ActivitiDemoComponent implements AfterViewInit {
} }
onReportDeleted() { onReportDeleted() {
this.selectFirstReport = true;
this.analyticsreportlist.reload(); this.analyticsreportlist.reload();
this.selectFirstElementInReportList();
}
selectFirstElementInReportList() {
if (!this.analyticsreportlist.isReportsEmpty()) {
this.analyticsreportlist.selectReport(this.analyticsreportlist.reports[0]);
}
} }
navigateStartProcess() { navigateStartProcess() {

View File

@ -178,9 +178,11 @@ platformBrowserDynamic().bootstrapModule(AppModule);
#### Options #### Options
| Name | Type | Required | Description | | Name | Type | Required | Default | Description |
| --- | --- | --- | --- | | --- | --- | --- | --- | --- |
| `layoutType` | {string} | required | Define the layout of the apps. There are two possible values: GRID or LIST. LIST is the default value| | `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 ## Basic usage example Activiti Analytics

View File

@ -37,6 +37,9 @@ export class AnalyticsReportListComponent implements OnInit {
@Input() @Input()
appId: string; appId: string;
@Input()
selectFirst: boolean = false;
@Output() @Output()
reportClick: EventEmitter<ReportParametersModel> = new EventEmitter<ReportParametersModel>(); reportClick: EventEmitter<ReportParametersModel> = new EventEmitter<ReportParametersModel>();
@ -90,6 +93,9 @@ export class AnalyticsReportListComponent implements OnInit {
res.forEach((report) => { res.forEach((report) => {
this.reportObserver.next(report); this.reportObserver.next(report);
}); });
if (this.selectFirst) {
this.selectFirstReport();
}
this.onSuccess.emit(res); this.onSuccess.emit(res);
} }
}, },
@ -143,6 +149,11 @@ export class AnalyticsReportListComponent implements OnInit {
this.reportClick.emit(report); this.reportClick.emit(report);
} }
selectFirstReport() {
this.selectReport(this.reports[0]);
this.selectFirst = false;
}
isSelected(report: any) { isSelected(report: any) {
return this.currentReport === report ? true : false; return this.currentReport === report ? true : false;
} }