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 < harshal.dhu...@enterprisedb.com> 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> >
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; }));
-- Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers