Hi, PFA generalized updated patch for backform multiSelectControl.
-- *Harshal Dhumal* *Software Engineer * EenterpriseDB <http://www.enterprisedb.com> On Tue, Mar 8, 2016 at 1:04 PM, Harshal Dhumal < harshal.dhu...@enterprisedb.com> wrote: > Hi, > > PFA backform control for selecting multiple columns.(This control depends > on column node.) > > Usage: > > { > id: 'columns', label: '{{ _('Columns') }}', > type: 'collection', group: '{{ _('Definition') }}', editable:true, > canDelete: true, canAdd: true, control: Backform.MultiColumnSelectControl, > deps: ['index'], node: 'column', > model: pgBrowser.Node.Model.extend({ > keys: ['column'], > defaults: { > column: undefined > } > }) > } > > > Note: When using this control model should have *column* attribute. And > node property should be *column*. > > > > > -- > *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 b84b6ee..1202580 100644 --- a/web/pgadmin/browser/static/js/node.ui.js +++ b/web/pgadmin/browser/static/js/node.ui.js @@ -558,6 +558,46 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) { }) }); + /* + * Control to select multiple columns. + */ + var MultiSelectAjaxControl = Backform.MultiSelectAjaxControl = NodeAjaxOptionsControl.extend({ + formatter: { + fromRaw: function (rawData, model) { + return _.isObject(rawData) ? rawData : JSON.parse(rawData); + }, + toRaw: function (formattedData, model) { + return formattedData; + } + }, + template: _.template([ + '<label class="control-label col-xs-12"><%=label%></label>', + '<div class="pgadmin-controls col-xs-12">', + ' <select multiple="multiple" style="width:100%;" class="pgadmin-controls <%=extraClasses.join(\' \')%>" name="<%=name%>" value="<%-JSON.stringify(value)%>" <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%>>', + ' <% for (var i=0; i < options.length; i++) { %>', + ' <% var option = options[i]; %>', + ' <option value=<%-option.value%> <%=value != null && _.indexOf(value, option.value) != -1 ? "selected" : ""%> <%=option.disabled ? "disabled=\'disabled\'" : ""%>><%-option.label%></option>', + ' <% } %>', + ' </select>', + '</div>' + ].join("\n")), + getValueFromDOM: function() { + var res = []; + + this.$el.find("select").find(':selected').each(function() { + res.push($(this).attr('value')); + }); + + return res; + }, + defaults: _.extend({}, NodeAjaxOptionsControl.prototype.defaults, { + select2: { + multiple: true, + allowClear: true, + width: 'style' + } + }) + }); 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