tab renaming (fixes #19)

This commit is contained in:
Eugene Pankov 2017-07-15 19:11:49 +02:00
parent e64126af37
commit 60ce10d1e3
4 changed files with 32 additions and 1 deletions

View file

@ -0,0 +1,6 @@
.modal-body
input.form-control(type='text', [(ngModel)]='value', (keyup.enter)='save()', autofocus)
.modal-footer
button.btn.btn-outline-primary((click)='save()') Save
button.btn.btn-outline-secondary((click)='close()') Cancel

View file

@ -0,0 +1,22 @@
import { Component, Input } from '@angular/core'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
@Component({
selector: 'rename-tab-modal',
template: require('./renameTabModal.component.pug'),
})
export class RenameTabModalComponent {
@Input() value: string
constructor (
private modalInstance: NgbActiveModal
) { }
save () {
this.modalInstance.close(this.value)
}
close () {
this.modalInstance.dismiss()
}
}

View file

@ -1,3 +1,3 @@
.index {{index + 1}}
.name {{tab.title || tab.customTitle}}
.name {{tab.customTitle || tab.title}}
button((click)='closeClicked.emit()') ×

View file

@ -22,6 +22,9 @@ export class TabHeaderComponent {
@HostListener('dblclick') onDoubleClick (): void {
let modal = this.ngbModal.open(RenameTabModalComponent)
modal.componentInstance.value = this.tab.customTitle || this.tab.title
modal.result.then(result => {
this.tab.customTitle = result
}).catch(() => null)
}
@HostListener('auxclick', ['$event']) onAuxClick ($event: MouseEvent): void {