-import {Component, Input, Output, EventEmitter, Host} from '@angular/core';
+import {Component, Input, Output, EventEmitter, Host, OnInit} from '@angular/core';
import {FmRecordEditorComponent} from './fm-editor.component';
@Component({
template: '<ng-template></ng-template>' // no-op
})
-export class FmRecordEditorActionComponent {
+export class FmRecordEditorActionComponent implements OnInit {
// unique identifier
@Input() key: string;
@Input() label: string;
+ @Input() buttonCss: string = 'btn-outline-dark';
+
// Emits the 'key' of the clicked action.
@Output() actionClick: EventEmitter<string>;
constructor(@Host() private editor: FmRecordEditorComponent) {
this.actionClick = new EventEmitter<string>();
+ }
+
+ ngOnInit() {
this.editor.actions.push(this);
}
}
</form>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-outline-dark"
+ <button type="button" class="btn {{action.buttonCss}}"
*ngFor="let action of actions" [disabled]="action.disabled"
- (click)="action.actionClick.emit(action.key)">
+ (click)="action.actionClick.emit({action: action.key, record: record})">
{{action.label}}
</button>
<ng-container *ngIf="isDialog()">
</ng-container>
<ng-container *ngIf="showDelete && mode != 'view'">
- <button type="button" class="btn btn-warning" (click)="remove()"
- [disabled]="record && record.isnew()" i18n>Delete</button>
+ <button type="button" class="btn btn-warning" (click)="remove()"
+ [disabled]="record && record.isnew()" i18n>Delete</button>
</ng-container>
<button type="button" class="btn btn-info"