Subject: [pgAdmin4][PATCH] To fix the issue with NodeAjaxControl data caching

From: Murtuza Zabuawala <[email-masked]>
Date: Wed, 3 May 2017 18:35:24 +0530

Hi,

PFA patch to fix the issue in NodeAjaxControl caching with cache-node field
and I've also added cache-node field in Trigger & Event trigger node so
that whenever user creates new Trigger Function we get new data from server
in NodeAjaxControl.
RM#2242

Please review.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/js/event_trigger.js b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/js/event_trigger.js
index 3a5a259..d2b6923 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/js/event_trigger.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/js/event_trigger.js
@@ -67,7 +67,6 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
           source: undefined,
           language: undefined
         },
-        
         // Default values!
         initialize: function(attrs, args) {
           var isNew = (_.size(attrs) === 0);
@@ -79,7 +78,6 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
           }
           pgAdmin.Browser.Node.Model.prototype.initialize.apply(this, arguments);
         },
-        
         // Define the schema for the event trigger node
         schema: [{
           id: 'name', label: '{{ _('Name') }}', cell: 'string',
@@ -105,7 +103,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
         },{
           id: 'eventfunname', label:'{{ _('Trigger function') }}',
           type: 'text', control: 'node-ajax-options', group: "Definition",
-          url:'fopts'
+          url:'fopts', cache_node: 'trigger_function'
         },{
           id: 'eventname', label:'{{ _('Events') }}',
           type:"radio", group: "Definition", cell: 'string',
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/templates/trigger/js/trigger.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/templates/trigger/js/trigger.js
index 42ace44..3f44e7e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/templates/trigger/js/trigger.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/templates/trigger/js/trigger.js
@@ -283,7 +283,8 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
           id: 'tfunction', label:'{{ _('Trigger Function') }}',
           type: 'text', disabled: 'inSchemaWithModelCheck',
           mode: ['create','edit', 'properties'], group: '{{ _('Definition') }}',
-          control: 'node-ajax-options', url: 'get_triggerfunctions'
+          control: 'node-ajax-options', url: 'get_triggerfunctions',
+          cache_node: 'trigger_function'
         },{
           id: 'tgargs', label:'{{ _('Arguments') }}', cell: 'string',
           group: '{{ _('Definition') }}',
diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js
index 695e413..8e9ffce 100644
--- a/web/pgadmin/browser/static/js/node.ui.js
+++ b/web/pgadmin/browser/static/js/node.ui.js
@@ -126,7 +126,7 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) {
             cache_level,
             cache_node = this.field.get('cache_node');
 
-        cache_node = (cache_node && pgAdmin.Browser.Nodes['cache_node']) || node;
+        cache_node = (cache_node && pgAdmin.Browser.Nodes[cache_node]) || node;
 
         if (this.field.has('cache_level')) {
           cache_level = this.field.get('cache_level');

-- 
Sent via pgadmin-hackers mailing list ([email-masked])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

---

From: Dave Page <[email-masked]>
Date: Thu, 4 May 2017 16:02:36 +0100

Thanks, applied.

On Wed, May 3, 2017 at 2:05 PM, Murtuza Zabuawala <
[email-masked]> wrote:

> Hi,
>
> PFA patch to fix the issue in NodeAjaxControl caching with cache-node
> field and I've also added cache-node field in Trigger & Event trigger node
> so that whenever user creates new Trigger Function we get new data from
> server in NodeAjaxControl.
> RM#2242
>
> Please review.
>
> --
> Regards,
> Murtuza Zabuawala

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company