Improve the display of role membership on both the properties panel and role dialogue. Fixes #1730

pull/3/head
Khushboo Vashi 2017-01-16 14:48:25 +00:00 committed by Dave Page
parent a85861ca57
commit 024b664c21
2 changed files with 23 additions and 14 deletions

View File

@ -105,16 +105,18 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Backform) {
} }
}, },
template: _.template([ template: _.template([
'<label class="control-label col-xs-12"><%=label%></label>', '<label class="<%=Backform.controlLabelClassName%>"><%=label%></label>',
'<div class="pgadmin-controls col-xs-12">', '<div class="<%=Backform.controlsClassName%>">',
' <select multiple="multiple" style="width:100%;" class="pgadmin-controls <%=extraClasses.join(\' \')%>" name="<%=name%>" value="<%-JSON.stringify(value)%>" <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%>>', ' <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++) { %>', ' <% for (var i=0; i < options.length; i++) { %>',
' <% var option = options[i]; %>', ' <% var option = options[i]; %>',
' <option value=<%-option.value%> data-icon=<%-option.image%> <%=value != null && _.indexOf(value, option.value) != -1 ? "selected" : ""%> <%=option.disabled ? "disabled=\'disabled\'" : ""%>><%-option.label%></option>', ' <option value=<%-option.value%> data-icon=<%-option.image%> <%=value != null && _.indexOf(value, option.value) != -1 ? "selected" : ""%> <%=option.disabled ? "disabled=\'disabled\'" : ""%>><%-option.label%></option>',
' <% } %>', ' <% } %>',
' </select>', ' </select>',
' <% if (helpMessage && helpMessage.length) { %>',
' <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
' <% } %>',
'</div>', '</div>',
'<div class="note <%=Backform.helpMessageClassName%> col-xs-12"></div>',
].join("\n")), ].join("\n")),
selectionTemplate: _.template([ selectionTemplate: _.template([
'<span>', '<span>',
@ -150,13 +152,17 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Backform) {
}), }),
evalF = function(f, d, m) { evalF = function(f, d, m) {
return (_.isFunction(f) ? !!f.apply(d, [m]) : !!f); return (_.isFunction(f) ? !!f.apply(d, [m]) : !!f);
},
evalASFunc = function(f, d, m) {
return (_.isFunction(f) ? f.apply(d, [m]) : f);
}; };
// Evaluate the disabled, visible, and required option // Evaluate the disabled, visible, and required option
_.extend(data, { _.extend(data, {
disabled: evalF(data.disabled, data, this.model), disabled: evalF(data.disabled, data, this.model),
visible: evalF(data.visible, data, this.model), visible: evalF(data.visible, data, this.model),
required: evalF(data.required, data, this.model) required: evalF(data.required, data, this.model),
helpMessage: evalASFunc(data.helpMessage, data, this.model)
}); });
// Evaluation the options // Evaluation the options
if (_.isFunction(data.options)) { if (_.isFunction(data.options)) {
@ -245,16 +251,13 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Backform) {
templateSelection: formatSelection, templateSelection: formatSelection,
multiple: true, multiple: true,
tags: true, tags: true,
allowClear: true, allowClear: data.disabled ? false : true,
placeholder: "Select members", placeholder: data.disabled ? "" : "Select members",
width: 'style' width: 'style'
}).on("change", function(e) { }).on("change", function(e) {
$(e.target).find(':selected').each(function() { $(e.target).find(':selected').each(function() {
}); });
}); });
var msg = '{{ _('Select the checkbox for roles to include WITH ADMIN OPTION.') }}';
this.$el.find('div.note').html("<span>NOTE: " + msg + "</span>");
return this; return this;
}, },
@ -491,6 +494,13 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Backform) {
}), }),
filter: function(d) { filter: function(d) {
return this.model.isNew() || (this.model.get('rolname') != d.label); return this.model.isNew() || (this.model.get('rolname') != d.label);
},
helpMessage: function(m) {
if (m.has('read_only') && m.get('read_only') == false) {
return '{{ _('Select the checkbox for roles to include WITH ADMIN OPTION.') }}';
} else {
return '{{ _('Roles shown with a check mark have the WITH ADMIN OPTION set.') }}';
}
} }
},{ },{
id: 'variables', label: '{{ _('Parameters') }}', type: 'collection', id: 'variables', label: '{{ _('Parameters') }}', type: 'collection',

View File

@ -752,7 +752,6 @@ td.switch-cell > div.bootstrap-switch {
} }
div.rolmembership { div.rolmembership {
border: 1.5px solid #faebd7;
margin-top: 15px; margin-top: 15px;
} }