public inbox for [email protected]
help / color / mirror / Atom feedFrom: Khushboo Vashi <[email protected]>
To: Ashesh Vashi <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin4][Patch]: Backgrid StringDepsCell
Date: Tue, 5 Apr 2016 10:59:14 +0530
Message-ID: <CAFOhELcYc3OAX+Wr-C0hQpthWPx7O9G7ebAdR839L-7v9GJXew@mail.gmail.com> (raw)
In-Reply-To: <CAFOhELcZpPHsuV9KgCmwSypp=Q9Qr0kXb=cs4=8eU=h20YGVZg@mail.gmail.com>
References: <CAFOhELcoJTEm=V=buZKdt_Eoc1ur4jGySg6J3BdKpNn5aVVhuw@mail.gmail.com>
<CAG7mmozs_bVt0qRqQZiD42HjAAFFZ6LT6j5tn_UbZ=aWvfptGA@mail.gmail.com>
<CAFOhELcZpPHsuV9KgCmwSypp=Q9Qr0kXb=cs4=8eU=h20YGVZg@mail.gmail.com>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgadmin-hackers>
Hi Ashesh,
I have changed the function name (from *render_deps* to *updateUIDeps*),
which will be called on the dependent field change, as per your suggestion.
Please find attached patch for the same.
Thanks,
Khushboo
On Fri, Apr 1, 2016 at 3:56 PM, Khushboo Vashi <
[email protected]> wrote:
> Hi Ashesh,
>
> Yes, agreed. This implementation limits us to use only String Cell.
> So, I have modified the patch as you suggested.
>
> Please find the attachment for the same.
>
> Thanks,
> Khushboo
>
> On Fri, Apr 1, 2016 at 2:59 PM, Ashesh Vashi <
> [email protected]> wrote:
>
>> Hi Khushboo,
>>
>> I am reluctant to use this code as it is.
>> I would prefer you create just helper functions (i.e. initialize, remove)
>> for the dependents in Backgrid.Cell, and then use them directly from the
>> different cell itself.
>> Because - this functionality limits us to us only with the string type.
>>
>> Anyway - we will be using the dependent functionality for very attributes.
>>
>>
>> You can extend them directly in the Node's model (schema).
>>
>> --
>>
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> <http://www.enterprisedb.com;
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> <http://www.linkedin.com/in/asheshvashi;
>>
>> On Wed, Mar 30, 2016 at 6:39 PM, Khushboo Vashi <
>> [email protected]> wrote:
>>
>>> Hi,
>>>
>>> Please find the attached patch for the Backgrid *StringDepsCell.*
>>>
>>> The *StringDepsCell* displays HTML escaped strings and accepts anything typed in.
>>> Also, Listen to the dependent fields.
>>>
>>>
>>> Usage of the Backgrid Cell:
>>>
>>> If the Precision cell is dependent on the Datatype then:
>>>
>>> {
>>> id: 'precision', label:'{{ _('Precision') }}', type: 'test'
>>> cell: *Backgrid.Extension.StringDepsCell*, deps: ['datatype']
>>>
>>> }
>>>
>>>
>>> Thanks,
>>> Khushboo
>>>
>>>
>>>
>>> --
>>> Sent via pgadmin-hackers mailing list ([email protected])
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>
>>>
>>
>
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[text/x-patch] pgAdmin4_Backgrid_Depscell_ver1.patch (1.7K, 3-pgAdmin4_Backgrid_Depscell_ver1.patch)
download | inline diff:
diff --git a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
index 4b233d2..9de19fa 100644
--- a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
+++ b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
@@ -447,6 +447,46 @@
editor: TextareaCellEditor
});
+ /**
+ DependentCell can be used as a base class for any backgrid cell which is
+ dependent on another cell. It will listen to the dependent fields/cells.
+
+ Need to Extend this cell whenever required and has to implement updateUIDeps
+ function to listen to the dependent fields change event.
+
+ @class Backgrid.Extension.DependentCell
+ @extends Backgrid.DependentCell
+ */
+ var DependentCell = Backgrid.Extension.DependentCell = Backgrid.Cell.extend({
+ initialize: function(){
+ // Listen to the dependent fields in the model for any change
+ var deps = this.column.get('deps');
+ var self = this;
+
+ if (deps && _.isArray(deps)) {
+ _.each(deps, function(d) {
+ attrArr = d.split('.');
+ name = attrArr.shift();
+ self.listenTo(self.model, "change:" + name, self.updateUIDeps);
+ });
+ }
+ },
+ remove: function() {
+ // Remove the events for the dependent fields in the model
+ var self = this,
+ deps = self.column.get('deps');
+
+ if (deps && _.isArray(deps)) {
+ _.each(deps, function(d) {
+ attrArr = d.split('.');
+ name = attrArr.shift();
+ self.stopListening(self.model, "change:" + name, self.updateUIDeps);
+ });
+ }
+ Backbone.View.prototype.remove.apply(self, arguments);
+ }
+ });
+
return Backgrid;
}));
view thread (7+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: [pgAdmin4][Patch]: Backgrid StringDepsCell
In-Reply-To: <CAFOhELcYc3OAX+Wr-C0hQpthWPx7O9G7ebAdR839L-7v9GJXew@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox