Files
pgadmin4/web/pgadmin/static/js/alertify/dialog_wrapper.js
Joao De Almeida Pereira 7dd6372eeb Extract the tests and refactor some of the methods.
Extract some of the ACI Tree functionalities, and decouple it from the
main source. Also - create some abstractions from the repeated code
around the enable/disable the schema children object create/edit/delete
functionalities, and also created the dialog wrappers for backup and
restore dialogs.

Reviewed by: Khushboo and Ashesh
Refactored by: Ashesh
2018-06-05 16:42:59 +05:30

58 lines
1.4 KiB
JavaScript

import * as commonUtils from '../utils';
export class DialogWrapper {
constructor(
dialogContainerSelector, dialogTitle, jquery, pgBrowser,
alertify, dialogModel, backform) {
this.hooks = {
onclose: function () {
if (this.view) {
this.view.remove({
data: true,
internal: true,
silent: true,
});
}
},
};
this.dialogContainerSelector = dialogContainerSelector;
this.dialogTitle = dialogTitle;
this.jquery = jquery;
this.pgBrowser = pgBrowser;
this.alertify = alertify;
this.dialogModel = dialogModel;
this.backform = backform;
}
build() {
this.alertify.pgDialogBuild.apply(this);
}
wasHelpButtonPressed(e) {
return e.button.element.name === 'dialog_help'
|| e.button.element.name === 'object_help';
}
getSelectedNodeData(selectedTreeNode) {
if (!this.isNodeSelected(selectedTreeNode)) {
return undefined;
}
const treeNodeData = selectedTreeNode.getData();
if (treeNodeData) {
return treeNodeData;
}
return undefined;
}
focusOnDialog(dialog) {
dialog.$el.attr('tabindex', -1);
this.pgBrowser.keyboardNavigation.getDialogTabNavigator(dialog);
const container = dialog.$el.find('.tab-content:first > .tab-pane.active:first');
commonUtils.findAndSetFocus(container);
}
isNodeSelected(selectedTreeNode) {
return selectedTreeNode;
}
}