import { PickerController } from '../picker/pickercontroller' ; import { ServerWrapper } from '../server/serverwrapper' ; export class PrivelegedCopyDialog { private server_ : ServerWrapper ; private pickerController_ : PickerController ; private dialogEl_ : HTMLElement ; private inputEl_ : HTMLInputElement ; constructor ( server , pickerController , dialogEl , inputEl ) { this . server_ = server ; this . pickerController_ = pickerController ; this . dialogEl_ = dialogEl ; this . inputEl_ = inputEl ; } bindButtons ( okButton , cancelButton ) { okButton . onclick = ( ) => this . onOkClick_ ( ) ; cancelButton . onclick = ( ) => this . hide ( ) ; } show ( ) { this . dialogEl_ . classList . remove ( 'hidden' ) ; } hide ( ) { this . dialogEl_ . classList . add ( 'hidden' ) ; } isVisible ( ) { return ! this . dialogEl_ . classList . contains ( 'hidden' ) ; } onKeyDown ( e ) { if ( e . keyCode == 13 ) { this . onOkClick_ ( ) ; } else if ( e . keyCode == 27 ) { this . hide ( ) ; } } private onOkClick_ ( ) { this . server_ . copyRepertoireAsPrivelegedUser ( this . inputEl_ . value ) . then ( ( ) => { this . hide ( ) ; this . pickerController_ . updatePicker ( ) ; } ) ; } }