[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>
<analytics-report-list
[appId]="appId"
[selectFirst]="selectFirstReport"
(reportClick)="onReportClick($event)"
#analyticsreportlist>
</analytics-report-list>

View File

@ -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() {

View File

@ -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

View File

@ -37,6 +37,9 @@ export class AnalyticsReportListComponent implements OnInit {
@Input()
appId: string;
@Input()
selectFirst: boolean = false;
@Output()
reportClick: EventEmitter<ReportParametersModel> = new EventEmitter<ReportParametersModel>();
@ -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;
}