@asoftwareworld/form-builder
Version:
ASW Form Builder helps you with rapid development and designed web forms which includes several controls. The key feature of Form Builder is to make your content attractive and effective. We can customize our control at run time and preview the same befor
188 lines (182 loc) • 13.5 kB
JavaScript
import * as i0 from '@angular/core';
import { EventEmitter, Component, Input, Output, NgModule } from '@angular/core';
import { AswConfirmDialog, AswConfirmDialogModule } from '@asoftwareworld/form-builder/form-control/confirm-dialog';
import { Constants, AswSingleSelectDialog, AswSharedDialogModule } from '@asoftwareworld/form-builder/form-control/core';
import * as i1 from '@angular/material/dialog';
import { MatDialogModule } from '@angular/material/dialog';
import * as i2 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i3 from '@angular/forms';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import * as i4 from '@angular/material/radio';
import { MatRadioModule } from '@angular/material/radio';
import * as i5 from '@angular/material/icon';
import { MatIconModule } from '@angular/material/icon';
import * as i6 from '@angular/material/tooltip';
import { MatTooltipModule } from '@angular/material/tooltip';
import * as i7 from '@angular/material/button';
import { MatButtonModule } from '@angular/material/button';
import { MatDividerModule } from '@angular/material/divider';
import { MatInputModule } from '@angular/material/input';
import { MatSelectModule } from '@angular/material/select';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
/**
* @license
* Copyright ASW (A Software World) All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file
*/
class AswRadioButton {
dialog;
constants = Constants;
/**
* RadioButton control
*/
control = null;
/**
* RadioButton control index to help update or delete button from drop area
*/
controlIndex;
isPreviewTemplate = false;
radioButtonUpdateEvent = new EventEmitter();
radioButtonDeleteEvent = new EventEmitter();
selectionChange = new EventEmitter();
duplicateControl = new EventEmitter();
constructor(dialog) {
this.dialog = dialog;
}
deleteRadioButtonDialog(control, controlIndex) {
const dialogRef = this.dialog.open(AswConfirmDialog, {
width: '350px',
data: { name: control.controlType, message: this.constants.messages.waringMessage }
});
dialogRef.afterClosed().subscribe(result => {
if (result !== undefined) {
this.radioButtonDeleteEvent.emit(controlIndex);
}
});
}
editRadioButtonDialog(control, controlIndex) {
control.options.forEach(element => {
element.isChecked = control.value === element.key ? true : false;
});
const dialogRef = this.dialog.open(AswSingleSelectDialog, {
disableClose: true,
width: '80%',
minWidth: '70vw',
data: control
});
dialogRef.afterClosed().subscribe(result => {
if (result !== undefined) {
this.radioButtonUpdateEvent.emit({ control: result, index: controlIndex });
}
});
}
onSelectionChange(control) {
control.options.forEach(element => {
element.isChecked = control.value === element.key ? true : false;
});
this.selectionChange.emit(control);
}
duplicateRadioButtonControl(control) {
this.duplicateControl.emit(control);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AswRadioButton, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.11", type: AswRadioButton, selector: "asw-radio-button", inputs: { control: "control", controlIndex: "controlIndex", isPreviewTemplate: "isPreviewTemplate" }, outputs: { radioButtonUpdateEvent: "radioButtonUpdateEvent", radioButtonDeleteEvent: "radioButtonDeleteEvent", selectionChange: "selectionChange", duplicateControl: "duplicateControl" }, ngImport: i0, template: "<ng-container *ngIf=\"control as control\">\r\n <label id=\"example-radio-group-label\">{{control.label}}</label>\r\n <mat-radio-group class=\"asw-radio-group {{control.customClass}}\"\r\n [id]=\"control.id\"\r\n [matTooltip]=\"control.tooltip\"\r\n [(ngModel)]=\"control.value\"\r\n (change)=\"onSelectionChange(control)\"\r\n [disabled]=\"control.isDisabled ? true : false\">\r\n <mat-radio-button *ngFor=\"let option of control.options\" \r\n [value]=\"option.key\">\r\n {{ option.value }}\r\n </mat-radio-button>\r\n </mat-radio-group>\r\n <ng-template [ngIf]=\"isPreviewTemplate\">\r\n <div class=\"row\">\r\n <div class=\"col-md-12\">\r\n <button mat-icon-button \r\n type=\"button\" \r\n matTooltip=\"Duplicate\" \r\n [matTooltipPosition]=\"'below'\" \r\n (click)=\"duplicateRadioButtonControl(control)\">\r\n <mat-icon>content_copy</mat-icon>\r\n </button>\r\n <button mat-icon-button \r\n type=\"button\" \r\n matTooltip=\"Edit\" \r\n [matTooltipPosition]=\"'below'\" \r\n (click)=\"editRadioButtonDialog(control, controlIndex)\">\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n <button mat-icon-button \r\n type=\"button\" \r\n matTooltip=\"Delete\" \r\n [matTooltipPosition]=\"'below'\" \r\n (click)=\"deleteRadioButtonDialog(control, controlIndex)\">\r\n <mat-icon>delete</mat-icon>\r\n </button>\r\n </div> \r\n </div>\r\n </ng-template> \r\n</ng-container>\r\n", dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i4.MatRadioGroup, selector: "mat-radio-group", inputs: ["color", "name", "labelPosition", "value", "selected", "disabled", "required", "disabledInteractive"], outputs: ["change"], exportAs: ["matRadioGroup"] }, { kind: "component", type: i4.MatRadioButton, selector: "mat-radio-button", inputs: ["id", "name", "aria-label", "aria-labelledby", "aria-describedby", "disableRipple", "tabIndex", "checked", "value", "labelPosition", "disabled", "required", "color", "disabledInteractive"], outputs: ["change"], exportAs: ["matRadioButton"] }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i6.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "component", type: i7.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AswRadioButton, decorators: [{
type: Component,
args: [{ selector: 'asw-radio-button', template: "<ng-container *ngIf=\"control as control\">\r\n <label id=\"example-radio-group-label\">{{control.label}}</label>\r\n <mat-radio-group class=\"asw-radio-group {{control.customClass}}\"\r\n [id]=\"control.id\"\r\n [matTooltip]=\"control.tooltip\"\r\n [(ngModel)]=\"control.value\"\r\n (change)=\"onSelectionChange(control)\"\r\n [disabled]=\"control.isDisabled ? true : false\">\r\n <mat-radio-button *ngFor=\"let option of control.options\" \r\n [value]=\"option.key\">\r\n {{ option.value }}\r\n </mat-radio-button>\r\n </mat-radio-group>\r\n <ng-template [ngIf]=\"isPreviewTemplate\">\r\n <div class=\"row\">\r\n <div class=\"col-md-12\">\r\n <button mat-icon-button \r\n type=\"button\" \r\n matTooltip=\"Duplicate\" \r\n [matTooltipPosition]=\"'below'\" \r\n (click)=\"duplicateRadioButtonControl(control)\">\r\n <mat-icon>content_copy</mat-icon>\r\n </button>\r\n <button mat-icon-button \r\n type=\"button\" \r\n matTooltip=\"Edit\" \r\n [matTooltipPosition]=\"'below'\" \r\n (click)=\"editRadioButtonDialog(control, controlIndex)\">\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n <button mat-icon-button \r\n type=\"button\" \r\n matTooltip=\"Delete\" \r\n [matTooltipPosition]=\"'below'\" \r\n (click)=\"deleteRadioButtonDialog(control, controlIndex)\">\r\n <mat-icon>delete</mat-icon>\r\n </button>\r\n </div> \r\n </div>\r\n </ng-template> \r\n</ng-container>\r\n" }]
}], ctorParameters: () => [{ type: i1.MatDialog }], propDecorators: { control: [{
type: Input
}], controlIndex: [{
type: Input
}], isPreviewTemplate: [{
type: Input
}], radioButtonUpdateEvent: [{
type: Output
}], radioButtonDeleteEvent: [{
type: Output
}], selectionChange: [{
type: Output
}], duplicateControl: [{
type: Output
}] } });
/**
* @license
* Copyright ASW (A Software World) All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file
*/
class AswRadioButtonModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AswRadioButtonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: AswRadioButtonModule, declarations: [AswRadioButton], imports: [CommonModule,
FormsModule,
ReactiveFormsModule,
MatInputModule,
MatSelectModule,
MatDialogModule,
MatSlideToggleModule,
MatDividerModule,
MatRadioModule,
MatIconModule,
MatTooltipModule,
AswConfirmDialogModule,
MatButtonModule,
AswSharedDialogModule], exports: [AswRadioButton] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AswRadioButtonModule, imports: [CommonModule,
FormsModule,
ReactiveFormsModule,
MatInputModule,
MatSelectModule,
MatDialogModule,
MatSlideToggleModule,
MatDividerModule,
MatRadioModule,
MatIconModule,
MatTooltipModule,
AswConfirmDialogModule,
MatButtonModule,
AswSharedDialogModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AswRadioButtonModule, decorators: [{
type: NgModule,
args: [{
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
MatInputModule,
MatSelectModule,
MatDialogModule,
MatSlideToggleModule,
MatDividerModule,
MatRadioModule,
MatIconModule,
MatTooltipModule,
AswConfirmDialogModule,
MatButtonModule,
AswSharedDialogModule
],
declarations: [
AswRadioButton
],
exports: [
AswRadioButton
]
}]
}] });
/**
* @license
* Copyright ASW (A Software World) All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file
*/
/**
* Generated bundle index. Do not edit.
*/
export { AswRadioButton, AswRadioButtonModule };
//# sourceMappingURL=asoftwareworld-form-builder-form-control-radio-button.mjs.map