import { Component, OnInit, Input, Output, ElementRef, EventEmitter, HostBinding } from '@angular/core'; import { CfCoreComponent } from '../core/core.component'; import { ButtonMenuModel } from '../../models/button-menu/button-menu.model'; import { ButtonMenuStylingModel } from '../../models/button-menu/button-menu-styling.model'; import { ButtonMenuTemplates } from '../../templates/button-menu.template'; /** *
GC ButtonMenu is created based on the ButtonMenuModel class (see /models/button-menu).
*Example of using the component:
***/ @Component({ selector: 'cf-button-menu', template: "<cf-button [settings]="button" (onClick)="function() "></cf-button>*
The type of the needed button.
*Type can be: mat-button, mat-raised-button.
*/ buttonType: string; /** *It is cf-button-menu html attribute [settings] with json ButtonMenu object.
*ButtonMenu is assembly of Button component and Menu component.
*/ @Input() public properties: ButtonMenuModel; @Input() public styling: ButtonMenuStylingModel; /** *It is cf-button-menu html attribute [disabled] to set disabled status of component. Default is false.
*/ @Input() disabled: boolean = false; /** *The event will be emitted when the button is clicked (left part of button).
*Click on right part of the button (with arrow down icon) is just opening dropdown menu.
*/ @Output() onClick = new EventEmitter(); notificationAction: any; constructor(public elementRef: ElementRef) { super(elementRef); } /** *On initialization:
*Check to see if any of the angular material button types are needed to be passed to the child button.
*Types are: md-button, md-raised-button.
*Then initialize the button element.
*/ ngOnInit() { super.ngOnInit(); if(this.properties==null) this.properties = new ButtonMenuModel(ButtonMenuTemplates.defaultTemplate.property); if(this.styling==null) this.styling = new ButtonMenuStylingModel(ButtonMenuTemplates.defaultTemplate.style); if(this.notificationAction.observers.length>0) this.notifacationClickable = 'notification-clickable'; this.cfButtonMenu = this.properties; } /** *The method will emit event when the button is clicked
*/ buttonClicked() { this.onClick.emit(); } /** * It is function for creating Notification click events by using Core Component notificationAction event emmiter. * @param notification it is json notification object */ cfNotificationAction(notification) { this.notificationAction.emit(notification); } }