import { PickerController } from './pickercontroller' ; export class ConfirmDeleteDialog { private pickerController_ : PickerController ; private dialogEl_ : HTMLElement ; private dialogNameEl_ : HTMLElement ; private okButton_ : HTMLElement ; private repertoireIdToDelete_ : string ; constructor ( pickerController , dialogEl , dialogNameEl , okButton , cancelButton ) { this . pickerController_ = pickerController ; this . dialogEl_ = dialogEl ; this . dialogNameEl_ = dialogNameEl ; this . okButton_ = okButton ; this . repertoireIdToDelete_ = '' ; cancelButton . onclick = ( ) => this . hide_ ( ) ; } isVisible ( ) { return ! this . dialogEl_ . classList . contains ( 'hidden' ) ; } showForRepertoire ( repertoireId , repertoireName ) { this . dialogNameEl_ . innerText = repertoireName ; this . dialogEl_ . classList . remove ( 'hidden' ) ; this . repertoireIdToDelete_ = repertoireId ; this . okButton_ . onclick = ( ) => this . onOkClick_ ( ) ; } onKeyDown ( e ) { if ( e . keyCode == 27 ) { this . hide_ ( ) ; } } private onOkClick_ ( ) { this . pickerController_ . deleteMetadataId ( this . repertoireIdToDelete_ ) . then ( ( ) => this . hide_ ( ) ) ; } private hide_ ( ) { this . dialogEl_ . classList . add ( 'hidden' ) ; } }