///////////////////////////////////////////////////////////// // // pgAdmin 4 - PostgreSQL Tools // // Copyright (C) 2013 - 2021, The pgAdmin Development Team // This software is released under the PostgreSQL Licence // ////////////////////////////////////////////////////////////// import gettext from 'sources/gettext'; import url_for from 'sources/url_for'; import $ from 'jquery'; import _ from 'underscore'; import Alertify from 'pgadmin.alertifyjs'; import pgAdmin from 'sources/pgadmin'; import Backform from 'pgadmin.backform'; import macroModel from 'sources/sqleditor/macro_model'; import axios from 'axios'; let MacroDialog = { 'dialog': function(handler) { let title = gettext('Manage Macros'); // Check the alertify dialog already loaded then delete it to clear // the cache if (Alertify.macroDialog) { delete Alertify.macroDialog; } // Create Dialog Alertify.dialog('macroDialog', function factory() { let $container = $('
'); return { main: function() { this.set('title', ' ' + gettext('Manage Macros')); }, build: function() { this.elements.content.appendChild($container.get(0)); Alertify.pgDialogBuild.apply(this); }, setup: function() { return { buttons: [{ text: '', key: 112, className: 'btn btn-primary-icon pull-left fa fa-question pg-alertify-icon-button', attrs: { name: 'dialog_help', type: 'button', label: gettext('Help'), 'aria-label': gettext('Help'), url: url_for('help.static', { 'filename': 'query_tool.html', }), }, }, { text: gettext('Cancel'), key: 27, className: 'btn btn-secondary fa fa-times pg-alertify-button', 'data-btn-name': 'cancel', }, { text: gettext('Save'), className: 'btn btn-primary fa fa-save pg-alertify-button', 'data-btn-name': 'ok', }], // Set options for dialog options: { title: title, //disable both padding and overflow control. padding: !1, overflow: !1, model: 0, resizable: true, maximizable: true, pinnable: false, closableByDimmer: false, modal: false, autoReset: false, }, }; }, hooks: { // triggered when the dialog is closed onclose: function() { if (this.view) { this.macroCollectionModel.stopSession(); this.view.model.stopSession(); this.view.remove({ data: true, internal: true, silent: true, }); } }, }, prepare: function() { let self = this; $container.html(''); // Status bar this.statusBar = $( ' ').appendTo($container); // To show progress on filter Saving/Updating on AJAX this.showFilterProgress = $( `