mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 09:35:39 -05:00
Clean up dialog event hide reasons (#14566)
* Clean up dialog event hide reasons * Remove done
This commit is contained in:
@@ -51,7 +51,7 @@ export abstract class CalloutDialog<T> extends Modal {
|
||||
public abstract open(): Promise<T>;
|
||||
|
||||
public cancel(): void {
|
||||
this.hide();
|
||||
this.hide('cancel');
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +104,8 @@ const defaultOptions: IModalOptions = {
|
||||
|
||||
const tabbableElementsQuerySelector = 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]';
|
||||
|
||||
export type HideReason = 'close' | 'cancel' | 'ok';
|
||||
|
||||
export abstract class Modal extends Disposable implements IThemable {
|
||||
protected _useDefaultMessageBoxLocation: boolean = true;
|
||||
protected _messageElement?: HTMLElement;
|
||||
@@ -317,7 +319,7 @@ export abstract class Modal extends Disposable implements IThemable {
|
||||
* Overridable to change behavior of escape key
|
||||
*/
|
||||
protected onClose(e?: StandardKeyboardEvent) {
|
||||
this.hide();
|
||||
this.hide('close');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,7 +332,7 @@ export abstract class Modal extends Disposable implements IThemable {
|
||||
if (target.closest('.modal-content')) {
|
||||
return;
|
||||
} else {
|
||||
this.hide();
|
||||
this.hide('close');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,7 +340,7 @@ export abstract class Modal extends Disposable implements IThemable {
|
||||
* Overridable to change behavior of enter key
|
||||
*/
|
||||
protected onAccept(e?: StandardKeyboardEvent) {
|
||||
this.hide();
|
||||
this.hide('ok');
|
||||
}
|
||||
|
||||
private handleBackwardTab(e: KeyboardEvent) {
|
||||
@@ -499,7 +501,7 @@ export abstract class Modal extends Disposable implements IThemable {
|
||||
/**
|
||||
* Hides the modal and removes key listeners
|
||||
*/
|
||||
protected hide(reason?: string, currentPageName?: string): void {
|
||||
protected hide(reason?: HideReason, currentPageName?: string): void {
|
||||
this._modalShowingContext.get()!.pop();
|
||||
this._bodyContainer!.remove();
|
||||
this.disposableStore.clear();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import 'vs/css!./media/optionsDialog';
|
||||
import * as DialogHelper from './dialogHelper';
|
||||
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
|
||||
import { IModalOptions, Modal } from './modal';
|
||||
import { HideReason, IModalOptions, Modal } from './modal';
|
||||
import * as OptionsDialogHelper from './optionsDialogHelper';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
@@ -176,16 +176,16 @@ export class OptionsDialog extends Modal {
|
||||
if (OptionsDialogHelper.validateInputs(this._optionElements)) {
|
||||
OptionsDialogHelper.updateOptions(this._optionValues, this._optionElements);
|
||||
this._onOk.fire();
|
||||
this.close();
|
||||
this.close('ok');
|
||||
}
|
||||
}
|
||||
|
||||
public cancel() {
|
||||
this.close();
|
||||
this.close('cancel');
|
||||
}
|
||||
|
||||
public close() {
|
||||
this.hide();
|
||||
public close(hideReason: HideReason = 'close') {
|
||||
this.hide(hideReason);
|
||||
this._optionElements = {};
|
||||
this._onCloseEvent.fire();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user