mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-242] Fixed behaviour for saving/deleting reports (#1905)
* [ADF-242] - fix for deleting - saving a report * [ADF - 242] added test for fixed feature on reports save - delete * Added translation key
This commit is contained in:
@@ -167,9 +167,12 @@
|
||||
[reportId]="report.id"
|
||||
[hideParameters]="false"
|
||||
(editReport)="onEditReport($event)"
|
||||
(reportSaved)="onReportSaved()"
|
||||
(reportSaved)="onReportSaved($event)"
|
||||
(reportDeleted)="onReportDeleted()">
|
||||
</activiti-analytics>
|
||||
<div *ngIf="!report">
|
||||
<span>{{'ANALYTICS_REPORT.NO_REPORT_MESSAGE' | translate}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -115,8 +115,8 @@ export class ActivitiDemoComponent implements AfterViewInit {
|
||||
this.dataProcesses = new ObjectDataTableAdapter(
|
||||
[],
|
||||
[
|
||||
{type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true},
|
||||
{type: 'text', key: 'started', title: 'Started', cssClass: 'hidden', sortable: true}
|
||||
{ type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true },
|
||||
{ type: 'text', key: 'started', title: 'Started', cssClass: 'hidden', sortable: true }
|
||||
]
|
||||
);
|
||||
this.dataProcesses.setSorting(new DataSorting('started', 'desc'));
|
||||
@@ -209,13 +209,13 @@ export class ActivitiDemoComponent implements AfterViewInit {
|
||||
this.analyticsreportlist.reload();
|
||||
}
|
||||
|
||||
onReportSaved() {
|
||||
this.analyticsreportlist.reload();
|
||||
onReportSaved(reportId) {
|
||||
this.analyticsreportlist.reload(reportId);
|
||||
}
|
||||
|
||||
onReportDeleted() {
|
||||
this.selectFirstReport = true;
|
||||
this.analyticsreportlist.reload();
|
||||
this.analyticsreportlist.selectReport(null);
|
||||
}
|
||||
|
||||
navigateStartProcess() {
|
||||
|
@@ -21,5 +21,8 @@
|
||||
"CUSTOM": "Custom action"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ANALYTICS_REPORT":{
|
||||
"NO_REPORT_MESSAGE":"No report selected. Choose a report from the list"
|
||||
}
|
||||
}
|
||||
|
@@ -28,14 +28,14 @@ declare let jasmine: any;
|
||||
describe('AnalyticsReportListComponent', () => {
|
||||
|
||||
let reportList = [
|
||||
{'id': 2002, 'name': 'Fake Test Process definition heat map'},
|
||||
{'id': 2003, 'name': 'Fake Test Process definition overview'},
|
||||
{'id': 2004, 'name': 'Fake Test Process instances overview'},
|
||||
{'id': 2005, 'name': 'Fake Test Task overview'},
|
||||
{'id': 2006, 'name': 'Fake Test Task service level agreement'}
|
||||
{ 'id': 2002, 'name': 'Fake Test Process definition heat map' },
|
||||
{ 'id': 2003, 'name': 'Fake Test Process definition overview' },
|
||||
{ 'id': 2004, 'name': 'Fake Test Process instances overview' },
|
||||
{ 'id': 2005, 'name': 'Fake Test Task overview' },
|
||||
{ 'id': 2006, 'name': 'Fake Test Task service level agreement' }
|
||||
];
|
||||
|
||||
let reportSelected = {'id': 2003, 'name': 'Fake Test Process definition overview'};
|
||||
let reportSelected = { 'id': 2003, 'name': 'Fake Test Process definition overview' };
|
||||
|
||||
let component: AnalyticsReportListComponent;
|
||||
let fixture: ComponentFixture<AnalyticsReportListComponent>;
|
||||
@@ -57,7 +57,9 @@ describe('AnalyticsReportListComponent', () => {
|
||||
|
||||
let translateService = TestBed.get(AlfrescoTranslationService);
|
||||
spyOn(translateService, 'addTranslationFolder').and.stub();
|
||||
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
|
||||
spyOn(translateService, 'get').and.callFake((key) => {
|
||||
return Observable.of(key);
|
||||
});
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -174,13 +176,13 @@ describe('AnalyticsReportListComponent', () => {
|
||||
|
||||
it('Should return false if the current report is different', () => {
|
||||
component.selectReport(reportSelected);
|
||||
let anotherReport = {'id': 111, 'name': 'Another Fake Test Process definition overview'};
|
||||
let anotherReport = { 'id': 111, 'name': 'Another Fake Test Process definition overview' };
|
||||
expect(component.isSelected(anotherReport)).toBe(false);
|
||||
});
|
||||
|
||||
it('Should reload the report list', (done) => {
|
||||
component.initObserver();
|
||||
let report = new ReportParametersModel({'id': 2002, 'name': 'Fake Test Process definition heat map'});
|
||||
let report = new ReportParametersModel({ 'id': 2002, 'name': 'Fake Test Process definition heat map' });
|
||||
component.reports = [report];
|
||||
expect(component.reports.length).toEqual(1);
|
||||
component.reload();
|
||||
@@ -197,6 +199,27 @@ describe('AnalyticsReportListComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('Should reload the report list and select the report with the given id', (done) => {
|
||||
component.initObserver();
|
||||
expect(component.reports.length).toEqual(0);
|
||||
|
||||
component.reload(2002);
|
||||
|
||||
component.onSuccess.subscribe(() => {
|
||||
expect(component.reports.length).toEqual(5);
|
||||
expect(component.currentReport).toBeDefined();
|
||||
expect(component.currentReport).not.toBeNull();
|
||||
expect(component.currentReport.id).toEqual(2002);
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: reportList
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('layout', () => {
|
||||
|
@@ -26,7 +26,7 @@ import { ReportParametersModel } from '../models/report.model';
|
||||
templateUrl: './analytics-report-list.component.html',
|
||||
styleUrls: ['./analytics-report-list.component.css']
|
||||
})
|
||||
export class AnalyticsReportListComponent implements OnInit {
|
||||
export class AnalyticsReportListComponent implements OnInit {
|
||||
|
||||
public static LAYOUT_LIST: string = 'LIST';
|
||||
public static LAYOUT_GRID: string = 'GRID';
|
||||
@@ -76,15 +76,15 @@ export class AnalyticsReportListComponent implements OnInit {
|
||||
/**
|
||||
* Reload the component
|
||||
*/
|
||||
reload() {
|
||||
reload(reportId?) {
|
||||
this.reset();
|
||||
this.getReportList(this.appId);
|
||||
this.getReportList(this.appId, reportId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the report list
|
||||
*/
|
||||
getReportList(appId: string) {
|
||||
getReportList(appId: string, reportId?: string) {
|
||||
this.analyticsService.getReportList(appId).subscribe(
|
||||
(res: ReportParametersModel[]) => {
|
||||
if (res && res.length === 0) {
|
||||
@@ -93,6 +93,10 @@ export class AnalyticsReportListComponent implements OnInit {
|
||||
res.forEach((report) => {
|
||||
this.reportObserver.next(report);
|
||||
});
|
||||
if (reportId) {
|
||||
console.log('SELEZIONO IL REPORT!');
|
||||
this.selectReportByReportId(reportId);
|
||||
}
|
||||
if (this.selectFirst) {
|
||||
this.selectFirstReport();
|
||||
}
|
||||
@@ -149,6 +153,14 @@ export class AnalyticsReportListComponent implements OnInit {
|
||||
this.reportClick.emit(report);
|
||||
}
|
||||
|
||||
public selectReportByReportId(reportId) {
|
||||
let reportFound = this.reports.find(report => report.id === reportId);
|
||||
if (reportFound) {
|
||||
this.currentReport = reportFound;
|
||||
this.reportClick.emit(reportFound);
|
||||
}
|
||||
}
|
||||
|
||||
selectFirstReport() {
|
||||
this.selectReport(this.reports[0]);
|
||||
this.selectFirst = false;
|
||||
|
@@ -483,7 +483,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
validForm = true;
|
||||
});
|
||||
|
||||
xit('Should be able to change the report title', (done) => {
|
||||
it('Should be able to change the report title', (done) => {
|
||||
|
||||
let title: HTMLElement = element.querySelector('h4');
|
||||
title.click();
|
||||
@@ -514,9 +514,10 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
});
|
||||
|
||||
it('Should show a dialog to allowing report save', async(() => {
|
||||
component.saveReportSuccess.subscribe(() => {
|
||||
component.saveReportSuccess.subscribe((repId) => {
|
||||
let reportDialogTitle: HTMLElement = <HTMLElement>element.querySelector('#report-dialog');
|
||||
expect(reportDialogTitle.getAttribute('open')).toBeNull();
|
||||
expect(repId).toBe('1');
|
||||
});
|
||||
|
||||
component.submit(values);
|
||||
|
@@ -372,7 +372,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
|
||||
|
||||
doSave(paramQuery: ReportQuery) {
|
||||
this.analyticsService.saveReport(this.reportId, paramQuery).subscribe(() => {
|
||||
this.saveReportSuccess.emit();
|
||||
this.saveReportSuccess.emit(this.reportId);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
[hideComponent]="hideParameters"
|
||||
(onFormValueChanged)="reset()"
|
||||
(onSuccess)="showReport($event)"
|
||||
(saveReportSuccess)="onSaveReportSuccess()"
|
||||
(saveReportSuccess)="onSaveReportSuccess($event)"
|
||||
(deleteReportSuccess)="onDeleteReportSuccess()"
|
||||
(onEdit)="onEditReport($event)">
|
||||
</analytics-report-parameters>
|
||||
|
@@ -79,8 +79,8 @@ export class AnalyticsComponent implements OnChanges {
|
||||
this.editReport.emit(name);
|
||||
}
|
||||
|
||||
public onSaveReportSuccess() {
|
||||
this.reportSaved.emit();
|
||||
public onSaveReportSuccess(reportId) {
|
||||
this.reportSaved.emit(reportId);
|
||||
}
|
||||
|
||||
public onDeleteReportSuccess() {
|
||||
|
Reference in New Issue
Block a user