diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js index 369243dc..55fb33f7 100644 --- a/web/pgadmin/static/js/backform.pgadmin.js +++ b/web/pgadmin/static/js/backform.pgadmin.js @@ -439,15 +439,11 @@ define([ }, template: _.template([ '', - '
', - '
', - ' ', - '
', - ' <% if (helpMessage && helpMessage.length) { %>', - ' <%=helpMessage%>', - ' <% } %>', + '
', + ' <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%>>', + ' ', '
', ].join('\n')), getValueFromDOM: function() { @@ -466,23 +462,44 @@ define([ name = attrArr.shift(), path = attrArr.join('.'), rawValue = this.keyPathAccessor(attributes[name], path), + data = _.extend(field, { + rawValue: rawValue, + value: this.formatter.fromRaw(rawValue, this.model), + attributes: attributes, + formatter: this.formatter, + }), evalF = function(f, d, m) { return (_.isFunction(f) ? !!f.apply(d, [m]) : !!f); - }, - options = _.defaults({ - disabled: evalF(field.disabled, field, this.model), - }, this.field.get('options'), this.defaults.options, - $.fn.bootstrapSwitch.defaults); - - Backform.InputControl.prototype.render.apply(this, arguments); - this.$input = this.$el.find('input[type=checkbox]').first(); - - //Check & set additional properties - this.$input.bootstrapSwitch( - _.extend(options, { - 'state': rawValue, - }) - ); + }; + + // Evaluate the disabled, visible, and required option + _.extend(data, { + disabled: evalF(field.disabled, field, this.model), + visible: evalF(data.visible, field, this.model), + required: evalF(data.required, field, this.model), + }); + + // Clean up first + this.$el.removeClass(Backform.hiddenClassName); + + if (!data.visible) + this.$el.addClass(Backform.hiddenClassName); + + if(Backform.requiredInputClassName) { + this.$el.removeClass(Backform.requiredInputClassName); + } + + if (data.required) { + this.$el.addClass(Backform.requiredInputClassName); + } + + data.options = _.defaults({ + disabled: evalF(field.disabled, field, this.model), + id: 'id-' + Math.random().toString(36).substr(2, 16), + }, this.field.get('options'), this.defaults.options); + + this.$el.html(this.template(data)).addClass(field.name); + this.updateInvalid(); return this; }, diff --git a/web/pgadmin/static/js/backgrid.pgadmin.js b/web/pgadmin/static/js/backgrid.pgadmin.js index 9ea4ad43..7dd5123c 100644 --- a/web/pgadmin/static/js/backgrid.pgadmin.js +++ b/web/pgadmin/static/js/backgrid.pgadmin.js @@ -509,21 +509,41 @@ define([ this.$el.empty(); + let temp_id = 'id-' + Math.random().toString(36).substr(2, 16); + + this.$el.append( + $('
', { + class: 'can-toggle can-toggle--size-small', + })); + + + let tmp_label = $('