From 2b5c90e379d4a94bac5e9359cbe2f5e9ca8d9c45 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Thu, 23 Apr 2020 17:14:01 +0530 Subject: [PATCH] =?UTF-8?q?A=20warning=20message=20will=20be=20displayed?= =?UTF-8?q?=20only=20when=20the=C2=A0package=C2=A0header=20is=20changed=20?= =?UTF-8?q?for=20EPAS=20packages.=C2=A0Fixes=20#5410?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schemas/packages/static/js/package.js | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.js index 50d8f4554..0d7602bf8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.js @@ -97,6 +97,7 @@ define('pgadmin.node.package', [ pkgbodysrc: undefined, acl: undefined, pkgacl: [], + warn_text: undefined, }, initialize: function(attrs, args) { if (_.size(attrs) === 0) { @@ -146,12 +147,46 @@ define('pgadmin.node.package', [ id: 'pkgheadsrc', label: gettext('Header'), cell: 'string', type: 'text', mode: ['properties', 'create', 'edit'], group: gettext('Header'), tabPanelCodeClass: 'sql-code-control', - control: Backform.SqlCodeControl, + control: Backform.SqlCodeControl.extend({ + onChange: function() { + Backform.SqlCodeControl.prototype.onChange.apply(this, arguments); + if(this.model && this.model.changed) { + if(this.model.origSessAttrs && (this.model.changed.pkgheadsrc != this.model.origSessAttrs.pkgheadsrc)) { + this.model.warn_text = gettext( + 'Updating the package header definition may remove its existing body.' + ) + '

' + gettext('Do you want to continue?') + + ''; + } + else { + this.model.warn_text = undefined; + } + } + else { + this.model.warn_text = undefined; + } + }, + }), },{ id: 'pkgbodysrc', label: gettext('Body'), cell: 'string', type: 'text', mode: ['properties', 'create', 'edit'], group: gettext('Body'), tabPanelCodeClass: 'sql-code-control', - control: Backform.SqlCodeControl, + control: Backform.SqlCodeControl.extend({ + onChange: function() { + Backform.SqlCodeControl.prototype.onChange.apply(this, arguments); + if(this.model && this.model.changed) { + if (this.model.origSessAttrs && (this.model.changed.pkgbodysrc != this.model.origSessAttrs.pkgbodysrc)) { + this.model.warn_text = undefined; + } else if(this.model.origSessAttrs && !_.isUndefined(this.model.origSessAttrs.pkgheadsrc) && + this.model.sessAttrs && !_.isUndefined(this.model.sessAttrs.pkgheadsrc) && + (this.model.origSessAttrs.pkgheadsrc != this.model.sessAttrs.pkgheadsrc)){ + this.model.warn_text = gettext( + 'Updating the package header definition may remove its existing body.' + ) + '

' + gettext('Do you want to continue?') + + ''; + } + } + }, + }), },{ id: 'acl', label: gettext('Privileges'), type: 'text', group: gettext('Security'), mode: ['properties'],