73 lines
1.5 KiB
TypeScript
Raw Normal View History

2020-02-04 17:13:09 +09:00
import {
Component,
OnInit,
Inject,
AfterViewInit,
ViewChild
} from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA, MatCheckbox } from '@angular/material';
export interface ClipboardDialogData {
content: {
text?: string;
rtf?: string;
html?: string;
image?: Buffer;
imageDataUrl?: string;
};
}
export interface ClipboardDialogResult {
selected?: {
text?: boolean;
rtf?: boolean;
html?: boolean;
image?: boolean;
};
}
@Component({
selector: 'app-layout-messenger-clipboard',
templateUrl: './clipboard.dialog.component.html',
styleUrls: ['./clipboard.dialog.component.scss']
})
export class ClipboardDialogComponent implements OnInit, AfterViewInit {
@ViewChild('chkText', { static: false })
chkText: MatCheckbox;
2020-02-04 17:59:27 +09:00
@ViewChild('chkHtml', { static: false })
chkHtml: MatCheckbox;
2020-02-04 17:13:09 +09:00
@ViewChild('chkImage', { static: false })
chkImage: MatCheckbox;
constructor(
public dialogRef: MatDialogRef<ClipboardDialogData, ClipboardDialogResult>,
@Inject(MAT_DIALOG_DATA) public data: ClipboardDialogData
) {}
ngOnInit() {}
ngAfterViewInit(): void {}
onClickChoice(choice: boolean): void {
let selected: {
text?: boolean;
rtf?: boolean;
html?: boolean;
image?: boolean;
};
if (choice) {
selected = {
text: !!this.chkText && this.chkText.checked,
2020-02-04 17:59:27 +09:00
html: !!this.chkHtml && this.chkHtml.checked,
2020-02-04 17:13:09 +09:00
image: !!this.chkImage && this.chkImage.checked
};
} else {
}
this.dialogRef.close({ selected });
}
}