ADF-2974] New Buttons Menu component version (#3429)

* [ADF-2974] Buttons injected from parent html component

* [ADF-2974] New version of buttons menu component

* [ADF-2974] Updated unit tests

* [ADF-2974] Updated documentation

* [ADF-2974] Removed unused variable

* [ADF-2974] Fixed failing test at analytics report parameters

* [ADF-2974] Removed fdescribe

* [ADF-2974] Moved mock inside testing file for buttons menu component
This commit is contained in:
davidcanonieto
2018-06-06 23:07:54 +01:00
committed by Eugenio Romano
parent 1838818295
commit 3759a7967c
11 changed files with 226 additions and 236 deletions

View File

@@ -25,8 +25,21 @@
<h4>{{reportParameters.name}}</h4>
</div>
</adf-toolbar-title>
<adf-buttons-action-menu *ngIf="!isEditable"
[buttons]="buttons">
<adf-buttons-action-menu *ngIf="!isEditable">
<button mat-menu-item (click)="toggleParameters()" id="">
<mat-icon>settings</mat-icon><span>{{ 'ANALYTICS.MESSAGES.ICON-SETTING' | translate }}</span>
</button>
<button mat-menu-item (click)="deleteReport(reportId)" id="delete-button">
<mat-icon>delete</mat-icon><span>{{ 'ANALYTICS.MESSAGES.ICON-DELETE' | translate }}</span>
</button>
<div *ngIf="isFormValid()">
<button mat-menu-item (click)="showDialog('Export')" id="export-button">
<mat-icon>file_download</mat-icon><span>{{ 'ANALYTICS.MESSAGES.ICON-EXPORT-CSV' | translate }}</span>
</button>
<button mat-menu-item (click)="showDialog('Save')" id="save-button">
<mat-icon>save</mat-icon><span>{{ 'ANALYTICS.MESSAGES.ICON-SAVE' | translate }}</span>
</button>
</div>
</adf-buttons-action-menu>
</adf-toolbar>
<div *ngFor="let field of reportParameters.definition.parameters"

View File

@@ -561,19 +561,15 @@ describe('AnalyticsReportParametersComponent', () => {
it('Should raise an event for report deleted', async(() => {
fixture.detectChanges();
fixture.whenStable().then(() => {
let deleteButton = fixture.debugElement.nativeElement.querySelector('#delete-button');
expect(deleteButton).toBeDefined();
expect(deleteButton).not.toBeNull();
component.deleteReportSuccess.subscribe((reportId) => {
expect(reportId).not.toBeNull();
});
deleteButton.click();
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
contentType: 'json'
});
spyOn(component, 'deleteReport');
let deleteButton = fixture.debugElement.nativeElement.querySelector('#delete-button');
expect(deleteButton).toBeDefined();
expect(deleteButton).not.toBeNull();
component.deleteReportSuccess.subscribe((reportId) => {
expect(reportId).not.toBeNull();
});
deleteButton.click();
expect(component.deleteReport).toHaveBeenCalled();
}));
it('Should hide export button if the form is not valid', async(() => {

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { ContentService, LogService, MenuButton } from '@alfresco/adf-core';
import { ContentService, LogService } from '@alfresco/adf-core';
import {
AfterContentChecked,
Component,
@@ -95,8 +95,6 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
reportName: string;
buttons: MenuButton[] = [];
private dropDownSub;
private reportParamsSub;
private paramOpts;
@@ -138,7 +136,6 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
if (reportId && reportId.currentValue) {
this.reportId = reportId.currentValue;
this.getReportParams(reportId.currentValue);
this.setButtons();
}
let appId = changes['appId'];
@@ -391,34 +388,4 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
isFormValid() {
return this.reportForm && this.reportForm.dirty && this.reportForm.valid;
}
setButtons() {
this.buttons = [
new MenuButton({
label: 'ANALYTICS.MESSAGES.ICON-SETTING',
icon: 'settings',
handler: this.toggleParameters.bind(this)
}),
new MenuButton({
label: 'ANALYTICS.MESSAGES.ICON-DELETE',
icon: 'delete',
handler: this.deleteReport.bind(this, this.reportId),
id: 'delete-button'
}),
new MenuButton({
label: 'ANALYTICS.MESSAGES.ICON-EXPORT-CSV',
icon: 'file_download',
handler: this.showDialog.bind(this, 'Export'),
id: 'export-button',
isVisible: this.isFormValid.bind(this)
}),
new MenuButton({
label: 'ANALYTICS.MESSAGES.ICON-SAVE',
icon: 'save',
handler: this.showDialog.bind(this, 'Save'),
id: 'save-button',
isVisible: this.isFormValid.bind(this)
})
];
}
}