Replace Bootstrap switch with Bootstrap4 toggle to improve the performance. Fixes #3051

This commit is contained in:
Khushboo Vashi 2019-02-04 11:31:48 +05:30 committed by Akshay Joshi
parent 93234c86b7
commit dae8186c2a
29 changed files with 1672 additions and 173 deletions

View File

@ -14,6 +14,7 @@ Features
Bug fixes
*********
| `Bug #3051 <https://redmine.postgresql.org/issues/3051>`_ - Replace Bootstrap switch with Bootstrap4 toggle to improve the performance.
| `Bug #3272 <https://redmine.postgresql.org/issues/3272>`_ - Replace the PyCrypto module with the cryptography module.
| `Bug #3453 <https://redmine.postgresql.org/issues/3453>`_ - Fixed SQL for foreign table options.
| `Bug #3475 <https://redmine.postgresql.org/issues/3475>`_ - Fixed execution time to show Hours part for long running queries in Query Tool.

View File

@ -21,7 +21,6 @@ font-Awesome 4.5 SIL OFL http://fortawesome.github.io/Fon
font-mfizz 2.4.1 MIT http://fizzed.com/oss/font-mfizz
backgrid.js 0.3.5 MIT http://backgridjs.com/
backbone.undo 0.2 MIT http://backbone.undojs.com/
bootstrap-switch 3.3.2 MIT http://www.bootstrap-switch.org/
select2 4.0.1 MIT https://select2.github.io/
backgrid-filter 01b2b21 MIT https://github.com/wyuenho/backgrid-filter
backbone.paginator 2.0.3 MIT http://github.com/backbone-paginator/backbone.paginator

View File

@ -59,7 +59,6 @@
"bignumber.js": "^6.0.0",
"bootstrap": "^4.1.3",
"bootstrap-datepicker": "^1.7.0",
"bootstrap-switch": "3.3.4",
"bowser": "1.6.1",
"browserify": "~14.1.0",
"codemirror": "^5.29.0",
@ -98,7 +97,8 @@
"underscore.string": "^3.3.4",
"watchify": "~3.9.0",
"webcabin-docker": "git+https://github.com/EnterpriseDB/wcDocker/#9cf81f03bb350b76b77a264f1db5d55391d5e424",
"wkx": "^0.4.5"
"wkx": "^0.4.5",
"bootstrap4-toggle": "3.4.0"
},
"scripts": {
"linter": "yarn eslint --no-eslintrc -c .eslintrc.js --ext .js --ext .jsx .",

View File

@ -234,7 +234,7 @@ define('pgadmin.node.cast', [
group: gettext('Definition'), disabled: true, mode:['properties','edit'],
},{
id: 'castcontext', label: gettext('Context'),
options:{'onText':'IMPLICIT','offText':'EXPLICIT'},
options:{'onText':'IMPLICIT','offText':'EXPLICIT', width: '90'},
editable: false, type: 'string', group: gettext('Definition'),
mode:['create'],
control: Backform.SwitchControl.extend({

View File

@ -138,7 +138,6 @@ define('pgadmin.node.language', [
options: {
'onText': gettext('Yes'), 'offText': gettext('No'),
'onColor': 'success', 'offColor': 'primary',
'size': 'small',
},
group: gettext('Definition'), mode: ['edit', 'properties', 'create'], deps: ['name'],
disabled: function(m) {

View File

@ -264,7 +264,6 @@ define('pgadmin.node.domain', [
options: {
'onText': gettext('Yes'), 'offText': gettext('No'),
'onColor': 'success', 'offColor': 'primary',
'size': 'small',
},
},{
id: 'collname', label: gettext('Collation'), cell: 'string',

View File

@ -286,7 +286,6 @@ define('pgadmin.node.function', [
options: {
'onText': gettext('Yes'), 'offText': gettext('No'),
'onColor': 'success', 'offColor': 'primary',
'size': 'small',
},
},{
id: 'prosecdef', label: gettext('Security of definer?'),

View File

@ -220,7 +220,6 @@ define('pgadmin.node.trigger_function', [
options: {
'onText': gettext('Yes'), 'offText': gettext('No'),
'onColor': 'success', 'offColor': 'primary',
'size': 'small',
},
},{
id: 'prosecdef', label: gettext('Security of definer?'),

View File

@ -160,7 +160,6 @@ define('pgadmin.node.sequence', [
options: {
'onText': gettext('Yes'), 'offText': gettext('No'),
'onColor': 'success', 'offColor': 'primary',
'size': 'small',
},
}, pgBrowser.SecurityGroupSchema,{
id: 'acl', label: gettext('Privileges'), type: 'text',

View File

@ -463,10 +463,10 @@ define('pgadmin.node.schema', [
is_editable = _.isFunction(editable) ? !!editable.apply(column, [model]) : !!editable;
if (is_editable) {
this.$el.addClass('editable');
input.bootstrapSwitch('disabled',false);
input.bootstrapToggle('disabled',false);
} else {
this.$el.removeClass('editable');
input.bootstrapSwitch('disabled',true);
input.bootstrapToggle('disabled',true);
// Set self value into model to false
setTimeout(function() { model.set(self_name, false); }, 10);
}

View File

@ -771,6 +771,7 @@ define('pgadmin.node.foreign_key', [
options: {
onText: 'FULL',
offText: 'SIMPLE',
width: '80',
},disabled: function(m) {
// If we are in table edit mode then
if (_.has(m, 'handler') && !_.isUndefined(m.handler)) {

View File

@ -18,21 +18,21 @@ define('pgadmin.node.trigger', [
SchemaChildTreeNode
) {
Backform.CustomSwitchControl = Backform.SwitchControl.extend({
template: _.template([
'<label class="control-label pg-el-sm-6 pg-el-12"><%=label%></label>',
'<div class="pgadmin-controls pg-el-sm-6 pg-el-12">',
' <div class="checkbox">',
' <label>',
' <input type="checkbox" class="<%=extraClasses.join(\' \')%>"',
' name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%>',
' <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',
' </label>',
' </div>',
'</div>',
'<% if (helpMessage && helpMessage.length) { %>',
' <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
'<% } %>',
].join('\n')),
defaults: {
label: '',
options: {
onText: gettext('Yes'),
offText: gettext('No'),
onColor: 'success',
offColor: 'primary',
width: null,
height: null,
},
controlLabelClassName: 'control-label pg-el-sm-5 pg-el-12',
controlsClassName: 'pgadmin-controls pg-el-sm-7 pg-el-12',
extraClasses: [],
helpMessage: null,
},
className: 'pgadmin-control-group form-group col-6 row',
});

View File

@ -388,7 +388,6 @@ define('pgadmin.node.database', [
options: {
'onText': gettext('Yes'), 'offText': gettext('No'),
'onColor': 'success', 'offColor': 'primary',
'size': 'small',
},
},{
id: 'datallowconn', label: gettext('Allow connections?'),
@ -397,7 +396,6 @@ define('pgadmin.node.database', [
options: {
'onText': gettext('Yes'), 'offText': gettext('No'),
'onColor': 'success', 'offColor': 'primary',
'size': 'small',
},
},{
id: 'datacl', label: gettext('Privileges'), type: 'collection',

View File

@ -72,23 +72,27 @@ define('pgadmin.node.role', [
var switchOptions = {
'onText': gettext('Yes'), 'offText': gettext('No'),
'size': 'mini',
'size': 'mini', onColor: 'success',
offColor: 'primary',
};
var RoleCustomSwitchControl = Backform.SwitchControl.extend({
template: _.template([
'<label class="control-label pg-el-sm-10 pg-el-12"><%=label%></label>',
'<div class="pgadmin-controls pg-el-sm-2 pg-el-12">',
' <div class="checkbox">',
' <label>',
' <input type="checkbox" class="<%=extraClasses.join(\' \')%>" name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%> <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',
' </label>',
' </div>',
'</div>',
'<% if (helpMessage && helpMessage.length) { %>',
' <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
'<% } %>',
].join('\n')),
defaults: {
label: '',
options: {
onText: gettext('Yes'),
offText: gettext('No'),
onColor: 'success',
offColor: 'primary',
size: 'mini',
width: null,
height: null,
},
controlLabelClassName: 'control-label pg-el-sm-4 pg-el-12',
controlsClassName: 'pgadmin-controls pg-el-sm-8 pg-el-12',
extraClasses: [],
helpMessage: null,
},
className: 'pgadmin-control-group form-group pg-el-12 row',
});

View File

@ -768,7 +768,7 @@ define('pgadmin.node.server', [
},{
id: 'connected', label: gettext('Connected?'), type: 'switch',
mode: ['properties'], group: gettext('Connection'), 'options': {
'onText': gettext('True'), 'offText': gettext('False'), 'size': 'small',
'onText': gettext('True'), 'offText': gettext('False'), 'size': 'mini',
},
},{
id: 'version', label: gettext('Version'), type: 'text', group: null,
@ -857,7 +857,7 @@ define('pgadmin.node.server', [
},{
id: 'sslcompression', label: gettext('SSL compression?'), type: 'switch',
mode: ['edit', 'create'], group: gettext('SSL'),
'options': {'size': 'small'},
'options': {'size': 'mini'},
deps: ['sslmode'], disabled: 'isSSL',
},{
id: 'sslcert', label: gettext('Client certificate'), type: 'text',
@ -894,7 +894,7 @@ define('pgadmin.node.server', [
},{
id: 'sslcompression', label: gettext('SSL compression?'), type: 'switch',
mode: ['properties'], group: gettext('SSL'),
'options': {'size': 'small'},
'options': {'size': 'mini'},
deps: ['sslmode'], visible: function(model) {
var sslmode = model.get('sslmode');
return _.indexOf(SSL_MODES, sslmode) != -1;
@ -902,7 +902,7 @@ define('pgadmin.node.server', [
},{
id: 'use_ssh_tunnel', label: gettext('Use SSH tunneling'), type: 'switch',
mode: ['properties', 'edit', 'create'], group: gettext('SSH Tunnel'),
'options': {'size': 'small'},
'options': {'size': 'mini'},
disabled: function(model) {
if (!pgAdmin.Browser.utils.support_ssh_tunnel) {
setTimeout(function() {
@ -936,7 +936,7 @@ define('pgadmin.node.server', [
id: 'tunnel_authentication', label: gettext('Authentication'), type: 'switch',
mode: ['properties', 'edit', 'create'], group: gettext('SSH Tunnel'),
'options': {'onText': gettext('Identity file'),
'offText': gettext('Password'), 'size': 'small'},
'offText': gettext('Password'), 'size': 'mini', width: '90'},
deps: ['use_ssh_tunnel'],
disabled: function(model) {
return !model.get('use_ssh_tunnel');

View File

@ -102,10 +102,10 @@ class PGDataypeFeatureTest(BaseFeatureTest):
)
switch_btn = insert_bracket_pairs_control.\
find_element_by_class_name('bootstrap-switch')
find_element_by_class_name('toggle')
# check if switch is on then only toggle.
if 'bootstrap-switch-on' in switch_btn.get_attribute('class'):
if 'off' not in switch_btn.get_attribute('class'):
switch_btn.click()
# save and close the preference dialog.

View File

@ -214,7 +214,7 @@ define('pgadmin.preferences', [
onText: gettext('True'),
offText: gettext('False'),
onColor: 'success',
offColor: 'default',
offColor: 'primary',
size: 'mini',
};
return 'switch';
@ -223,8 +223,9 @@ define('pgadmin.preferences', [
onText: gettext('Show'),
offText: gettext('Hide'),
onColor: 'success',
offColor: 'default',
offColor: 'primary',
size: 'mini',
width: '56',
};
return 'switch';
case 'integer':

View File

@ -3,7 +3,7 @@
@import '~font-awesome/css/font-awesome.css';
@import '~bootstrap-datepicker/dist/css/bootstrap-datepicker3.css';
@import '~tempusdominus-bootstrap-4/build/css/tempusdominus-bootstrap-4.css';
@import '~bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.css';
@import '~bootstrap4-toggle/css/bootstrap4-toggle.css';
@import '~backgrid-select-all/backgrid-select-all.css';
@import '~backgrid-filter/backgrid-filter.css';
@import '~backgrid-sizeable-columns/backgrid-sizeable-columns.css';

View File

@ -10,7 +10,7 @@
define([
'sources/gettext', 'underscore', 'underscore.string', 'jquery',
'backbone', 'backform', 'backgrid', 'codemirror', 'sources/sqleditor_utils',
'spectrum', 'pgadmin.backgrid', 'select2',
'spectrum', 'pgadmin.backgrid', 'select2', 'bootstrap.toggle',
], function(gettext, _, S, $, Backbone, Backform, Backgrid, CodeMirror, SqlEditorUtils) {
var pgAdmin = (window.pgAdmin = window.pgAdmin || {}),
@ -431,7 +431,9 @@ define([
offText: gettext('No'),
onColor: 'success',
offColor: 'primary',
size: 'small',
size: 'mini',
width: null,
height: null,
},
controlLabelClassName: Backform.controlLabelClassName,
controlsClassName: Backform.controlsClassName,
@ -441,11 +443,11 @@ define([
template: _.template([
'<label class="<%=controlLabelClassName%>"><%=label%></label>',
'<div class="<%=controlsClassName%>">',
' <div class="checkbox">',
' <label>',
' <input type="checkbox" class="<%=extraClasses.join(\' \')%>" name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%> <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',
' </label>',
' </div>',
' <input tabindex="0" type="checkbox" data-style="quick" data-toggle="toggle"',
' data-size="<%=options.size%>" data-height="<%=options.height%>" ',
' data-on="<%=options.onText%>" data-off="<%=options.offText%>" ',
' data-onstyle="<%=options.onColor%>" data-offstyle="<%=options.offColor%>" data-width="<%=options.width%>" ',
' name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%> <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',
' <% if (helpMessage && helpMessage.length) { %>',
' <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
' <% } %>',
@ -458,7 +460,14 @@ define([
);
},
events: {
'switchChange.bootstrapSwitch': 'onChange',
'change input': 'onChange',
'keyup': 'toggleSwitch',
},
toggleSwitch: function(e) {
if (e.keyCode == 32) {
this.$el.find('input[type=checkbox]').bootstrapToggle('toggle');
e.preventDefault();
}
},
render: function() {
var field = _.defaults(this.field.toJSON(), this.defaults),
@ -467,23 +476,46 @@ 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);
// 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),
}, this.field.get('options'), this.defaults.options,
$.fn.bootstrapToggle.defaults);
this.$el.html(this.template(data)).addClass(field.name);
this.$input = this.$el.find('input[type=checkbox]').first();
//Check & set additional properties
this.$input.bootstrapSwitch(
_.extend(options, {
'state': rawValue,
})
);
this.$input.bootstrapToggle();
this.updateInvalid();
return this;
},

View File

@ -9,7 +9,8 @@
define([
'sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', 'backgrid', 'alertify',
'moment', 'bignumber', 'bootstrap.datetimepicker', 'bootstrap.switch', 'backgrid.filter',
'moment', 'bignumber', 'bootstrap.datetimepicker', 'backgrid.filter',
'bootstrap.toggle',
], function(
gettext, _, $, Backbone, Backform, Backgrid, Alertify, moment, BigNumber
) {
@ -451,18 +452,20 @@ define([
/**
SwitchCell renders a Bootstrap Switch in backgrid cell
*/
if (window.jQuery && window.jQuery.fn.bootstrapSwitch)
$.fn.bootstrapSwitch = window.jQuery.fn.bootstrapSwitch;
if (window.jQuery && window.jQuery.fn.bootstrapToggle)
$.fn.bootstrapToggle = window.jQuery.fn.bootstrapToggle;
Backgrid.Extension.SwitchCell = Backgrid.BooleanCell.extend({
defaults: {
options: _.defaults({
onText: gettext('True'),
offText: gettext('False'),
onText: gettext('Yes'),
offText: gettext('No'),
onColor: 'success',
offColor: 'default',
offColor: 'primary',
size: 'mini',
}, $.fn.bootstrapSwitch.defaults),
width: null,
height: null,
}, $.fn.bootstrapToggle.defaults),
},
className: 'switch-cell',
@ -474,7 +477,7 @@ define([
enterEditMode: function() {
this.$el.addClass('editor');
$(this.$el.find('input')).trigger('focus');
$(this.$el.find('input[type=checkbox]')).trigger('focus');
},
exitEditMode: function() {
@ -482,7 +485,16 @@ define([
},
events: {
'switchChange.bootstrapSwitch': 'onChange',
'change input': 'onChange',
'keyup': 'toggleSwitch',
'blur input': 'exitEditMode',
},
toggleSwitch: function(e) {
if (e.keyCode == 32) {
this.$el.find('input[type=checkbox]').bootstrapToggle('toggle');
e.preventDefault();
}
},
onChange: function() {
@ -503,7 +515,8 @@ define([
rawValue = this.formatter.fromRaw(
model.get(column.get('name')), model
),
editable = Backgrid.callByNeed(col.editable, column, model);
editable = Backgrid.callByNeed(col.editable, column, model),
options = _.defaults({}, col.options, this.defaults.options);
this.undelegateEvents();
@ -513,17 +526,14 @@ define([
$('<input>', {
tabIndex: -1,
type: 'checkbox',
}).prop('checked', rawValue).prop('disabled', !editable));
}).prop('checked', rawValue).prop('disabled', !editable).attr('data-toggle', 'toggle')
.attr('data-size', options.size).attr('data-on', options.onText).attr('data-off', options.offText)
.attr('data-onstyle', options.onColor).attr('data-offstyle', options.offColor));
this.$input = this.$el.find('input[type=checkbox]').first();
// Override BooleanCell checkbox with Bootstrapswitch
this.$input.bootstrapSwitch(
_.defaults({
'state': rawValue,
'disabled': !editable,
}, col.options,
this.defaults.options
));
// Override BooleanCell checkbox with Bootstraptoggle
this.$input.bootstrapToggle();
// Listen for Tab key
this.$el.on('keydown', function(e) {
@ -546,6 +556,7 @@ define([
});
self.model.trigger('backgrid:edited', self.model,
self.column, command);
this.exitEditMode();
gotoCell.trigger('focus');
}
}, 20);

View File

@ -228,30 +228,13 @@ legend {
font-size: 13px;
}
/* Remove default left padding from checkbox for bootstrap-switch */
.checkbox {
margin-bottom: 0px !important;
margin-top: 0px !important;
}
.checkbox label {
padding-left: 0px !important;
margin-bottom: 0px !important;
}
.bootstrap-switch > .bootstrap-switch-container > input {
border: 0px solid $color-fg;
height: 0px;
margin: 0px;
padding: 0px;
width: 0px;
}
.switch-cell {
height: 0px;
width: 0px;
}
/* Center align the switch in backgrid */
td.switch-cell > div.bootstrap-switch {
td.switch-cell > div.toggle {
display: block;
margin: auto;
}
@ -309,13 +292,6 @@ td.switch-cell > div.bootstrap-switch {
line-height: 0.7rem;
}
.bootstrap-switch.bootstrap-switch-disabled, .bootstrap-switch.bootstrap-switch-readonly {
background-color: $input-disabled-bg !important;
opacity: 1;
}
.btn-toolbar {
min-width: 100%;
}
@ -330,10 +306,6 @@ td.switch-cell > div.bootstrap-switch {
}
}
/* bootstrap-switch */
.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-primary, .bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-primary {
background: $color-primary;
}
.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-success, .bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-success {
background: $color-success;
.btn.disabled, .btn:disabled, .btn[disabled] {
opacity: $btn-disabled-opacity;
}

View File

@ -0,0 +1,28 @@
.toggle.btn-xs {
min-width: 3rem; min-height: 1.5rem;
}
.toggle-on.btn-xs {
padding-right: .8rem;
}
.toggle-off.btn-xs {
padding-left: .8rem;
}
.btn-xs, .btn-group-xs > .btn, .btn-xs-sq {
padding: 0.05rem 0.4rem;
font-size: 0.76562rem;
line-height: 1.5;
border-radius: 0.2rem;
}
.toggle input[type="checkbox"] {
display: block;
opacity: 0;
}
.toggle:focus-within {
border-color: $input-focus-border-color !important;
outline: 0;
-webkit-box-shadow: $input-focus-box-shadow;
box-shadow: $input-focus-box-shadow;
}

View File

@ -21,3 +21,4 @@ $theme-colors: (
@import 'backform.overrides';
@import 'pgadmin.grid';
@import 'pgadmin.style';
@import 'bootstrap4-toggle.overrides';

View File

@ -44,21 +44,6 @@ define([
*/
Backform.CustomSwitchControl = Backform.SwitchControl.extend({
template: _.template([
'<label class="<%=controlLabelClassName%> custom_switch_label_class"><%=label%></label>',
'<div class="<%=controlsClassName%> custom_switch_control_class">',
' <div class="checkbox">',
' <label>',
' <input type="checkbox" class="<%=extraClasses.join(\' \')%>"',
' name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%>',
' <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',
' </label>',
' </div>',
'</div>',
'<% if (helpMessage && helpMessage.length) { %>',
' <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
'<% } %>',
].join('\n')),
className: 'pgadmin-control-group form-group pg-el-md-6 pg-el-12 row',
});

View File

@ -30,19 +30,6 @@ define([
return pgAdmin.Tools.maintenance;
Backform.CustomSwitchControl = Backform.SwitchControl.extend({
template: _.template([
'<label class="<%=Backform.controlLabelClassName%> custom_switch_label_class"><%=label%></label>',
'<div class="<%=Backform.controlsClassName%> custom_switch_control_class">',
' <div class="checkbox">',
' <label>',
' <input type="checkbox" class="<%=extraClasses.join(\' \')%>" name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%> <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',
' </label>',
' </div>',
'</div>',
'<% if (helpMessage && helpMessage.length) { %>',
' <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
'<% } %>',
].join('\n')),
className: 'pgadmin-control-group form-group pg-el-md-6 pg-el-12 row',
});

View File

@ -25,19 +25,6 @@ commonUtils, menuUtils, supportedNodes, restoreDialog
}
Backform.CustomSwitchControl = Backform.SwitchControl.extend({
template: _.template([
'<label class="<%=Backform.controlLabelClassName%> custom_switch_label_class"><%=label%></label>',
'<div class="<%=Backform.controlsClassName%> custom_switch_control_class">',
' <div class="checkbox">',
' <label>',
' <input type="checkbox" class="<%=extraClasses.join(\' \')%>" name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%> <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',
' </label>',
' </div>',
'</div>',
'<% if (helpMessage && helpMessage.length) { %>',
' <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
'<% } %>',
].join('\n')),
className: 'pgadmin-control-group form-group pg-el-md-6 row',
});

View File

@ -37,9 +37,9 @@ var webpackShimConfig = {
'deps': ['moment'],
'exports': 'jQuery.fn.datetimepicker',
},
'bootstrap.switch': {
'bootstrap.toggle': {
deps: ['jquery', 'bootstrap'],
'exports': '$.fn.bootstrapSwitch',
'exports': '$.fn.bootstrapToggle',
},
'backbone': {
exports: 'Backbone', // Once loaded, use the global 'Backbone' as the module value.
@ -53,10 +53,10 @@ var webpackShimConfig = {
'exports': 'Backgrid',
},
'pgadmin.backform': {
'deps': ['backform', 'pgadmin.backgrid', 'select2'],
'deps': ['backform', 'pgadmin.backgrid', 'select2', 'bootstrap.toggle'],
},
'pgadmin.backgrid': {
'deps': ['backgrid', 'bootstrap.datetimepicker', 'bootstrap.switch'],
'deps': ['backgrid', 'bootstrap.datetimepicker', 'bootstrap.toggle'],
},
'backgrid.select.all': {
@ -172,7 +172,7 @@ var webpackShimConfig = {
'backform': path.join(__dirname, './pgadmin/static/vendor/backform/backform'),
'backgrid': path.join(__dirname, './node_modules/backgrid/lib/backgrid'),
'bootstrap.datetimepicker': path.join(__dirname, './node_modules/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.min'),
'bootstrap.switch': path.join(__dirname, './node_modules/bootstrap-switch/dist/js/bootstrap-switch'),
'bootstrap.toggle': path.join(__dirname, './node_modules/bootstrap4-toggle/js/bootstrap4-toggle'),
'select2': path.join(__dirname, './node_modules/select2/dist/js/select2.full'),
'backgrid.filter': path.join(__dirname, './node_modules/backgrid-filter/backgrid-filter'),
'backgrid.sizeable.columns': path.join(__dirname, './node_modules/backgrid-sizeable-columns/backgrid-sizeable-columns'),

View File

@ -77,7 +77,7 @@ module.exports = {
'spectrum': path.join(__dirname, './node_modules/spectrum-colorpicker/spectrum'),
'bignumber': path.join(__dirname, './node_modules/bignumber.js/bignumber'),
'bootstrap.datetimepicker': path.join(__dirname, './node_modules/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.min'),
'bootstrap.switch': path.join(__dirname, './node_modules/bootstrap-switch/dist/js/bootstrap-switch'),
'bootstrap.toggle': path.join(__dirname, './node_modules/bootstrap4-toggle/js/bootstrap4-toggle'),
'backbone': path.join(__dirname, './node_modules/backbone/backbone'),
'backform': path.join(__dirname, './node_modules/backform/src/backform'),
'backgrid': path.join(__dirname, './node_modules/backgrid/lib/backgrid'),

File diff suppressed because it is too large Load Diff