public inbox for [email protected]  
help / color / mirror / Atom feed
From: Harshal Dhumal <[email protected]>
To: Ashesh Vashi <[email protected]>
Cc: [email protected]
Subject: Re: backform select2 control
Date: Thu, 7 Jan 2016 10:02:20 +0530
Message-ID: <CAFiP3vxrPh1vU2TQPJSBi+C-3igcJbGCYuu03L=fPfdEXK6GcA@mail.gmail.com> (raw)
In-Reply-To: <CAFiP3vzzK6bGBF8eBHRqjUQNYc_GMkzqGc_eHzttUse-Ag83mA@mail.gmail.com>
References: <CAFiP3vzzK6bGBF8eBHRqjUQNYc_GMkzqGc_eHzttUse-Ag83mA@mail.gmail.com>
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Hi,

Updated patch. As yesterdays patch for backform select2 and
select2ajaxoptoins controls was throwing malformed patch error.

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com;

On Wed, Jan 6, 2016 at 12:01 PM, Harshal Dhumal <
[email protected]> wrote:

> Hi,
>
> Please find patch for backform select2 and select2ajaxoptoins controls
>
> Usage:
>
> schema: [{
>   id: 'name', label: '{{ _('Name') }}', cell: 'string',
>   type: 'select2', select2:{tags: "true", placeholder: "Select an option", allowClear: true}
> }
> .
> .
> .
>
>
>
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com;
>


-- 
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] select2_backform_controls_7_Jan_updated.patch (2.7K, 3-select2_backform_controls_7_Jan_updated.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js
index a251200..c9729a8 100644
--- a/web/pgadmin/browser/static/js/node.ui.js
+++ b/web/pgadmin/browser/static/js/node.ui.js
@@ -174,5 +174,53 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) {
     })
   });
 
+
+  /*
+   *  Backform Select2AjaxOptions control.
+   */
+  var Select2AjaxOptionsControl = Backform.Select2AjaxOptionsControl = Backform.NodeAjaxOptionsControl.extend({
+    render: function() {
+
+      var options = this.field.get('options') || [];
+
+      /* Add empty option as Select2 requires any empty '<option><option>' for
+       * some of its functionality to work.
+       */
+      options.unshift({label: undefined, value: undefined});
+
+      Backform.NodeAjaxOptionsControl.prototype.render.apply(this, arguments);
+
+      var col = _.defaults(this.field.toJSON(), this.defaults)
+      // Initialize select2 control.
+      this.$el.find("select").select2(col.select2);
+      return this;
+    }
+  });
   return Backform.NodeListControl;
 });

diff --git a/web/pgadmin/static/css/overrides.css b/web/pgadmin/static/css/overrides.css
index 6d0f662..3ec4d6f 100755
--- a/web/pgadmin/static/css/overrides.css
+++ b/web/pgadmin/static/css/overrides.css
@@ -611,3 +611,20 @@ table.backgrid tr.new {
     right: 0px;
     bottom :0;
 }
+.select2 {
+  width: 100% !important;
+}
+.select2-search__field, select{
+  background:inherit !important;
+}
\ No newline at end of file
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 7423909..86b9416 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -74,7 +74,8 @@
     'multiline': ['textarea', 'textarea', 'string'],
     'collection': ['sub-node-collection', 'sub-node-collection', 'string'],
     'uniqueColCollection': ['unique-col-collection', 'unique-col-collection', 'string'],
-    'switch' : 'switch'
+    'switch' : 'switch',
+    'select2': 'select2',
   };
@@ -1174,5 +1210,25 @@
     return groups;
   }
+  /*
+   *  Backform Select2 control.
+   */
+  var Select2Control = Backform.Select2Control = Backform.SelectControl.extend({
+    render: function() {
+      var options = this.field.get('options') || [];
+      /* Add empty option as Select2 requires any empty '<option><option>' for
+       * some of its functionality to work.
+       */
+
+      options.unshift({label: undefined, value: undefined});
+
+      Backform.SelectControl.prototype.render.apply(this, arguments);
+
+      var col = _.defaults(this.field.toJSON(), this.defaults)
+      // Initialize select2 control.
+      this.$el.find("select").select2(col.select2);
+      return this;
+    }
+  });
   return Backform;
 }));


view thread (2+ messages)

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: backform select2 control
  In-Reply-To: <CAFiP3vxrPh1vU2TQPJSBi+C-3igcJbGCYuu03L=fPfdEXK6GcA@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