diff --git a/web/pgadmin/static/js/alertify.pgadmin.defaults.js b/web/pgadmin/static/js/alertify.pgadmin.defaults.js
index 81bd7eb5..3129ecc6 100644
--- a/web/pgadmin/static/js/alertify.pgadmin.defaults.js
+++ b/web/pgadmin/static/js/alertify.pgadmin.defaults.js
@@ -1,135 +1,138 @@
-define(
- ['sources/gettext', 'alertify', 'underscore.string'],
-function(gettext, alertify, S) {
- alertify.defaults.transition = "zoom";
- alertify.defaults.theme.ok = "btn btn-primary";
- alertify.defaults.theme.cancel = "btn btn-danger";
- alertify.defaults.theme.input = "form-control";
+define([
+ 'sources/gettext', 'alertify', 'jquery',
+], function(gettext, alertify, $) {
+ alertify.defaults.transition = 'zoom';
+ alertify.defaults.theme.ok = 'btn btn-primary';
+ alertify.defaults.theme.cancel = 'btn btn-danger';
+ alertify.defaults.theme.input = 'form-control';
alertify.pgIframeDialog || alertify.dialog('pgIframeDialog', function() {
var iframe;
return {
- // dialog constructor function, this will be called when the user calls
- // alertify.pgIframeDialog(message)
- main:function(message){
- //set the videoId setting and return current instance for chaining.
- return this.set({
- 'pg_msg': message
- });
- },
- // we only want to override two options (padding and overflow).
- setup: function(){
- return {
- options:{
- //disable both padding and overflow control.
- padding : !1,
- overflow: !1,
- }
- };
- },
- // This will be called once the DOM is ready and will never be invoked
- // again. Here we create the iframe to embed the video.
- build:function() {
- // create the iframe element
- iframe = document.createElement('iframe');
-
- iframe.src = "";
- iframe.frameBorder = "no";
- iframe.width = "100%";
- iframe.height = "100%";
-
- // add it to the dialog
- this.elements.content.appendChild(iframe);
-
- //give the dialog initial height (half the screen height).
- this.elements.body.style.minHeight = screen.height * .5 + 'px';
- },
- // dialog custom settings
- settings:{
- pg_msg: undefined
- },
- // listen and respond to changes in dialog settings.
- settingUpdated: function(key, oldValue, newValue){
- switch(key){
- case 'pg_msg':
- var doc = iframe.contentWindow || iframe.contentDocument;
- if (doc.document) {
- doc = doc.document;
- }
-
- doc.open();
- doc.write(newValue);
- doc.close();
-
- break;
+ // dialog constructor function, this will be called when the user calls
+ // alertify.pgIframeDialog(message)
+ main: function(message) {
+ //set the videoId setting and return current instance for chaining.
+ return this.set({
+ 'pg_msg': message,
+ });
+ },
+ // we only want to override two options (padding and overflow).
+ setup: function() {
+ return {
+ options: {
+ //disable both padding and overflow control.
+ padding: !1,
+ overflow: !1,
+ },
+ };
+ },
+ // This will be called once the DOM is ready and will never be invoked
+ // again. Here we create the iframe to embed the video.
+ build: function() {
+ // create the iframe element
+ iframe = document.createElement('iframe');
+
+ iframe.src = '';
+ iframe.frameBorder = 'no';
+ iframe.width = '100%';
+ iframe.height = '100%';
+
+ // add it to the dialog
+ this.elements.content.appendChild(iframe);
+
+ //give the dialog initial height (half the screen height).
+ this.elements.body.style.minHeight = screen.height * .5 + 'px';
+ },
+ // dialog custom settings
+ settings: {
+ pg_msg: undefined,
+ },
+ // listen and respond to changes in dialog settings.
+ settingUpdated: function(key, oldValue, newValue) {
+ switch (key) {
+ case 'pg_msg':
+ var doc = iframe.contentWindow || iframe.contentDocument;
+ if (doc.document) {
+ doc = doc.document;
+ }
+
+ doc.open();
+ doc.write(newValue);
+ doc.close();
+
+ break;
+ }
+ },
+ // listen to internal dialog events.
+ hooks: {
+ // triggered when a dialog option gets update.
+ // warning! this will not be triggered for settings updates.
+ onupdate: function(option, oldValue, newValue) {
+ switch (option) {
+ case 'resizable':
+ if (newValue) {
+ this.elements.content.removeAttribute('style');
+ iframe && iframe.removeAttribute('style');
+ } else {
+ this.elements.content.style.minHeight = 'inherit';
+ iframe && (iframe.style.minHeight = 'inherit');
}
+ break;
+ }
},
- // listen to internal dialog events.
- hooks: {
- // triggered when a dialog option gets update.
- // warning! this will not be triggered for settings updates.
- onupdate: function(option,oldValue, newValue){
- switch(option){
- case 'resizable':
- if(newValue){
- this.elements.content.removeAttribute('style');
- iframe && iframe.removeAttribute('style');
- }else{
- this.elements.content.style.minHeight = 'inherit';
- iframe && (iframe.style.minHeight = 'inherit');
- }
- break;
- }
- }
- }
+ },
};
});
alertify.pgNotifier = function(type, xhr, promptmsg, onJSONResult) {
- var msg = xhr.responseText,
- contentType = xhr.getResponseHeader('Content-Type');
-
- if (xhr.status == 0) {
- msg = gettext('Connection to the server has been lost.');
- promptmsg = gettext('Connection Lost');
- } else {
- if (contentType) {
- try {
- if (contentType.indexOf('application/json') == 0) {
- var resp = $.parseJSON(msg);
-
- if (resp.result != null && (!resp.errormsg || resp.errormsg == '') &&
- onJSONResult && typeof(onJSONResult) == 'function') {
- return onJSONResult(resp.result);
- }
- msg = _.escape(resp.result) || _.escape(resp.errormsg) || "Unknown error";
+ var msg = xhr.responseText,
+ contentType = xhr.getResponseHeader('Content-Type');
+
+ if (xhr.status == 0) {
+ msg = gettext('Connection to the server has been lost.');
+ promptmsg = gettext('Connection Lost');
+ } else {
+ if (contentType) {
+ try {
+ if (contentType.indexOf('application/json') == 0) {
+ var resp = $.parseJSON(msg);
+
+ if (resp.result != null && (!resp.errormsg || resp.errormsg == '') &&
+ onJSONResult && typeof(onJSONResult) == 'function') {
+ return onJSONResult(resp.result);
}
- if (contentType.indexOf('text/html') == 0) {
- var alertMessage = promptmsg;
- if (type === 'error') {
- alertMessage = '\
+ msg = _.escape(resp.result) || _.escape(resp.errormsg) || 'Unknown error';
+ }
+ if (contentType.indexOf('text/html') == 0) {
+ var alertMessage = promptmsg;
+ if (type === 'error') {
+ alertMessage = '\
\
\
@@ -364,7 +366,7 @@ function(gettext, alertify, S) {
';
var alert = alertify.notify(alertMessage, timeout);
return alert;
- }
+ },
});
return alertify;
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 432cdd7e..4f3b1449 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1,41 +1,15 @@
-(function(root, factory) {
-
- // Set up Backform appropriately for the environment. Start with AMD.
- if (typeof define === 'function' && define.amd) {
- define([
- 'sources/gettext', 'underscore', 'underscore.string', 'jquery',
- 'backbone', 'backform', 'backgrid', 'codemirror', 'spectrum',
- 'pgadmin.backgrid', 'select2'
- ],
- function(gettext, _, S, $, Backbone, Backform, Backgrid, CodeMirror) {
- // Export global even in AMD case in case this script is loaded with
- // others that may still expect a global Backform.
- return factory(root, gettext, _, S, $, Backbone, Backform, Backgrid, CodeMirror);
- });
-
- // Next for Node.js or CommonJS. jQuery may not be needed as a module.
- } else if (typeof exports !== 'undefined') {
- var _ = require('underscore') || root._,
- $ = root.jQuery || root.$ || root.Zepto || root.ender,
- Backbone = require('backbone') || root.Backbone,
- Backform = require('backform') || root.Backform,
- Backgrid = require('backgrid') || root.Backgrid,
- CodeMirror = require('codemirror') || root.CodeMirror,
- S = require('underscore.string'),
- gettext = require('sources/gettext');
- factory(root, gettext, _, S, $, Backbone, Backform, Backgrid, CodeMirror);
- // Finally, as a browser global.
- } else {
- factory(root, root.gettext, root._, root.s, (root.jQuery || root.Zepto || root.ender || root.$), root.Backbone, root.Backform, root.Backgrid, root.CodeMirror);
- }
-}(this, function(root, gettext, _, S, $, Backbone, Backform, Backgrid, CodeMirror) {
+define([
+ 'sources/gettext', 'underscore', 'underscore.string', 'jquery',
+ 'backbone', 'backform', 'backgrid', 'codemirror', 'spectrum',
+ 'pgadmin.backgrid', 'select2',
+], function(gettext, _, S, $, Backbone, Backform, Backgrid, CodeMirror) {
var pgAdmin = (window.pgAdmin = window.pgAdmin || {});
pgAdmin.editableCell = function() {
if (this.attributes && !_.isUndefined(this.attributes.disabled) &&
- !_.isNull(this.attributes.disabled)) {
- if(_.isFunction(this.attributes.disabled)) {
+ !_.isNull(this.attributes.disabled)) {
+ if (_.isFunction(this.attributes.disabled)) {
return !(this.attributes.disabled.apply(this, arguments));
}
if (_.isBoolean(this.attributes.disabled)) {
@@ -47,15 +21,15 @@
// HTML markup global class names. More can be added by individual controls
// using _.extend. Look at RadioControl as an example.
_.extend(Backform, {
- controlLabelClassName: "control-label pg-el-sm-3 pg-el-xs-12",
- controlsClassName: "pgadmin-controls pg-el-sm-9 pg-el-xs-12",
- groupClassName: "pgadmin-control-group form-group pg-el-xs-12",
- setGroupClassName: "set-group pg-el-xs-12",
- tabClassName: "backform-tab pg-el-xs-12",
- setGroupContentClassName: "fieldset-content pg-el-xs-12"
- });
+ controlLabelClassName: 'control-label pg-el-sm-3 pg-el-xs-12',
+ controlsClassName: 'pgadmin-controls pg-el-sm-9 pg-el-xs-12',
+ groupClassName: 'pgadmin-control-group form-group pg-el-xs-12',
+ setGroupClassName: 'set-group pg-el-xs-12',
+ tabClassName: 'backform-tab pg-el-xs-12',
+ setGroupContentClassName: 'fieldset-content pg-el-xs-12',
+ });
- var controlMapper = Backform.controlMapper = {
+ Backform.controlMapper = {
'int': ['uneditable-input', 'numeric', 'integer'],
'text': ['uneditable-input', 'input', 'string'],
'numeric': ['uneditable-input', 'numeric', 'numeric'],
@@ -66,13 +40,13 @@
'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',
'note': 'note',
- 'color': 'color'
+ 'color': 'color',
};
- var getMappedControl = Backform.getMappedControl = function(type, mode) {
+ Backform.getMappedControl = function(type, mode) {
if (type in Backform.controlMapper) {
var m = Backform.controlMapper[type];
@@ -80,39 +54,42 @@
return m;
}
- var idx = 1, len = _.size(m);
+ var idx = 1,
+ len = _.size(m);
switch (mode) {
- case 'properties':
- idx = 0;
- break;
- case 'edit':
- case 'create':
- case 'control':
- idx = 1;
- break;
- case 'cell':
- idx = 2;
- break;
- default:
- idx = 0;
- break;
+ case 'properties':
+ idx = 0;
+ break;
+ case 'edit':
+ case 'create':
+ case 'control':
+ idx = 1;
+ break;
+ case 'cell':
+ idx = 2;
+ break;
+ default:
+ idx = 0;
+ break;
}
return m[idx > len ? 0 : idx];
}
return type;
- }
+ };
var BackformControlInit = Backform.Control.prototype.initialize,
- BackformControlRemove = Backform.Control.prototype.remove;
+ BackformControlRemove = Backform.Control.prototype.remove;
// Override the Backform.Control to allow to track changes in dependencies,
// and rerender the View element
_.extend(Backform.Control.prototype, {
- defaults: _.extend(Backform.Control.prototype.defaults, {helpMessage: null}),
+ defaults: _.extend(Backform.Control.prototype.defaults, {
+ helpMessage: null,
+ }),
initialize: function() {
BackformControlInit.apply(this, arguments);
@@ -125,7 +102,7 @@
_.each(deps, function(d) {
var attrArr = d.split('.');
var name = attrArr.shift();
- self.listenTo(self.model, "change:" + name, self.render);
+ self.listenTo(self.model, 'change:' + name, self.render);
});
}
},
@@ -133,10 +110,10 @@
remove: function() {
// Remove the events for the dependent fields in the model
var self = this,
- deps = self.field.get('deps');
+ deps = self.field.get('deps');
- self.stopListening(self.model, "change:" + name, self.render);
- self.stopListening(self.model.errorModel, "change:" + name, self.updateInvalid);
+ self.stopListening(self.model, 'change:' + name, self.render);
+ self.stopListening(self.model.errorModel, 'change:' + name, self.updateInvalid);
if (deps && _.isArray(deps)) {
_.each(deps, function(d) {
@@ -144,7 +121,7 @@
var attrArr = d.split('.');
var name = attrArr.shift();
- self.stopListening(self.model, "change:" + name, self.render);
+ self.stopListening(self.model, 'change:' + name, self.render);
});
}
@@ -160,42 +137,41 @@
},
template: _.template([
- '
',
- '
',
- ' >',
- ' <%-value%>',
- ' ',
- '
',
- '<% if (helpMessage && helpMessage.length) { %>',
- '
<%=helpMessage%>',
- '<% } %>',
- ].join("\n")),
+ '
',
+ '
',
+ ' >',
+ ' <%-value%>',
+ ' ',
+ '
',
+ '<% if (helpMessage && helpMessage.length) { %>',
+ '
<%=helpMessage%>',
+ '<% } %>',
+ ].join('\n')),
clearInvalid: function() {
this.$el.removeClass(Backform.errorClassName);
- this.$el.find(".pgadmin-control-error-message").remove();
+ this.$el.find('.pgadmin-control-error-message').remove();
return this;
},
updateInvalid: function() {
var self = this,
- errorModel = this.model.errorModel;
+ errorModel = this.model.errorModel;
if (!(errorModel instanceof Backbone.Model)) return this;
this.clearInvalid();
/*
- * Find input which have name attribute.
- */
+ * Find input which have name attribute.
+ */
this.$el.find(':input[name]').not('button').each(function(ix, el) {
- var attrArr = $(el).attr('name').split('.'),
- name = attrArr.shift(),
- path = attrArr.join('.'),
- error = self.keyPathAccessor(errorModel.toJSON(), $(el).attr('name'));
+ var error = self.keyPathAccessor(
+ errorModel.toJSON(), $(el).attr('name')
+ );
- if (_.isEmpty(error)) return;
- self.$el.addClass(Backform.errorClassName);
+ if (_.isEmpty(error)) return;
+ self.$el.addClass(Backform.errorClassName);
});
},
@@ -205,26 +181,26 @@
*/
render: function() {
var field = _.defaults(this.field.toJSON(), this.defaults),
- attributes = this.model.toJSON(),
- attrArr = field.name.split('.'),
- 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);
- };
+ attributes = this.model.toJSON(),
+ attrArr = field.name.split('.'),
+ 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);
+ };
// Evaluate the disabled, visible, and required option
_.extend(data, {
disabled: evalF(data.disabled, data, this.model),
- visible: evalF(data.visible, data, this.model),
- required: evalF(data.required, data, this.model)
+ visible: evalF(data.visible, data, this.model),
+ required: evalF(data.required, data, this.model),
});
// Clean up first
@@ -237,7 +213,7 @@
this.updateInvalid();
return this;
- }
+ },
});
/*
@@ -247,10 +223,10 @@
_.extend(
Backform.InputControl.prototype, {
events: {
- "change input": "onChange",
- "blur input": "onChange",
- "keyup input": "onKeyUp",
- "focus input": "clearInvalid"
+ 'change input': 'onChange',
+ 'blur input': 'onChange',
+ 'keyup input': 'onKeyUp',
+ 'focus input': 'clearInvalid',
},
onKeyUp: function(ev) {
if (this.key_timeout) {
@@ -260,7 +236,7 @@
this.keyup_timeout = setTimeout(function() {
this.onChange(ev);
}.bind(this), 400);
- }
+ },
});
/*
@@ -274,15 +250,18 @@
_.extend(
Backform.TextareaControl.prototype, {
defaults: _.extend(
- Backform.TextareaControl.prototype.defaults,
- {rows: 5, helpMessage: null, maxlength: null}
+ Backform.TextareaControl.prototype.defaults, {
+ rows: 5,
+ helpMessage: null,
+ maxlength: null,
+ }
),
- events : {
- "change textarea": "onChange",
- "keyup textarea": "onKeyUp",
- "paste textarea": "onChange",
- "selectionchange textarea": "onChange",
- "focus textarea": "clearInvalid"
+ events: {
+ 'change textarea': 'onChange',
+ 'keyup textarea': 'onKeyUp',
+ 'paste textarea': 'onChange',
+ 'selectionchange textarea': 'onChange',
+ 'focus textarea': 'clearInvalid',
},
template: _.template([
'
',
@@ -298,8 +277,8 @@
' <% if (helpMessage && helpMessage.length) { %>',
'
<%=helpMessage%>',
' <% } %>',
- '
'
- ].join("\n")),
+ '',
+ ].join('\n')),
onKeyUp: function(ev) {
if (this.key_timeout) {
clearTimeout(this.key_timeout);
@@ -308,7 +287,7 @@
this.keyup_timeout = setTimeout(function() {
this.onChange(ev);
}.bind(this), 400);
- }
+ },
});
/*
@@ -327,7 +306,7 @@
rawValue: rawValue,
value: this.formatter.fromRaw(rawValue, this.model),
attributes: attributes,
- formatter: this.formatter
+ formatter: this.formatter,
}),
evalF = function(f, d, m) {
return (_.isFunction(f) ? !!f.apply(d, [m]) : !!f);
@@ -336,16 +315,16 @@
// Evaluate the disabled, visible, and required option
_.extend(data, {
disabled: evalF(data.disabled, data, this.model),
- visible: evalF(data.visible, data, this.model),
- required: evalF(data.required, data, this.model)
+ visible: evalF(data.visible, data, this.model),
+ required: evalF(data.required, data, this.model),
});
// Evaluation the options
if (_.isFunction(data.options)) {
try {
- data.options = data.options(this)
- } catch(e) {
+ data.options = data.options(this);
+ } catch (e) {
// Do nothing
- data.options = []
+ data.options = [];
this.model.trigger('pgadmin-view:transform:error', this.model, this.field, e);
}
}
@@ -361,9 +340,11 @@
return this;
};
- _.extend(Backform.SelectControl.prototype.defaults, {helpMessage: null});
+ _.extend(Backform.SelectControl.prototype.defaults, {
+ helpMessage: null,
+ });
- var ReadonlyOptionControl = Backform.ReadonlyOptionControl = Backform.SelectControl.extend({
+ Backform.ReadonlyOptionControl = Backform.SelectControl.extend({
template: _.template([
'',
@@ -376,12 +357,12 @@
'<% if (helpMessage && helpMessage.length) { %>',
' <%=helpMessage%>',
'<% } %>',
- '
'
- ].join("\n")),
+ '',
+ ].join('\n')),
events: {},
getValueFromDOM: function() {
- return this.formatter.toRaw(this.$el.find("span").text(), this.model);
- }
+ return this.formatter.toRaw(this.$el.find('span').text(), this.model);
+ },
});
/*
@@ -393,7 +374,7 @@
Backform.RadioControl.prototype, {
updateInvalid: function() {
var self = this,
- errorModel = this.model.errorModel;
+ errorModel = this.model.errorModel;
if (!(errorModel instanceof Backbone.Model)) return this;
@@ -403,38 +384,35 @@
* Find input which have name attribute.
*/
this.$el.find(':input[name]').not('button').each(function(ix, el) {
- var attrArr = $(el).attr('name').split('.'),
- name = attrArr.shift(),
- path = attrArr.join('.'),
- error = self.keyPathAccessor(
- errorModel.toJSON(), $(el).attr('name')
- );
+ var error = self.keyPathAccessor(
+ errorModel.toJSON(), $(el).attr('name')
+ );
if (_.isEmpty(error)) return;
self.$el.addClass(Backform.errorClassName).find(
'[type="radio"]'
).append(
- $("',
@@ -1381,8 +1406,8 @@
' <% if (helpMessage && helpMessage.length) { %>',
' <%=helpMessage%>',
' <% } %>',
- '
'
- ].join("\n")),
+ '',
+ ].join('\n')),
/*
* Initialize the SQL Tab control properly
*/
@@ -1396,7 +1421,7 @@
_.bindAll(this, 'onTabChange', 'onPanelResized');
},
getValueFromDOM: function() {
- return this.formatter.toRaw(this.$el.find("textarea").val(), this.model);
+ return this.formatter.toRaw(this.$el.find('textarea').val(), this.model);
},
render: function() {
if (this.sqlCtrl) {
@@ -1411,17 +1436,16 @@
Backform.Control.prototype.render.apply(this, arguments);
this.sqlCtrl = CodeMirror.fromTextArea(
- (this.$el.find("textarea")[0]), {
- lineNumbers: true,
- lineWrapping: true,
- mode: "text/x-pgsql",
- readOnly: true,
- extraKeys: pgAdmin.Browser.editor_shortcut_keys,
- tabSize: pgAdmin.Browser.editor_options.tabSize,
- lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
- autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
- matchBrackets: pgAdmin.Browser.editor_options.brace_matching
- });
+ (this.$el.find('textarea')[0]), {
+ lineNumbers: true,
+ mode: 'text/x-pgsql',
+ readOnly: true,
+ extraKeys: pgAdmin.Browser.editor_shortcut_keys,
+ tabSize: pgAdmin.Browser.editor_options.tabSize,
+ lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
+ autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
+ matchBrackets: pgAdmin.Browser.editor_options.brace_matching,
+ });
/*
* We will listen to the tab change event to check, if the SQL tab has
@@ -1439,17 +1463,17 @@
// We will send a request to the sever only if something has changed
// in a model and also it does not contain any error.
- if(this.model.sessChanged()) {
+ if (this.model.sessChanged()) {
if (_.size(this.model.errorModel.attributes) == 0) {
var self = this,
- node = self.field.get('schema_node'),
- msql_url = node.generate_url.apply(
- node, [
- null, 'msql', this.field.get('node_data'), !self.model.isNew(),
- this.field.get('node_info')
- ]);
-
- // Fetching the modified SQL
+ node = self.field.get('schema_node'),
+ msql_url = node.generate_url.apply(
+ node, [
+ null, 'msql', this.field.get('node_data'), !self.model.isNew(),
+ this.field.get('node_info'),
+ ]);
+
+ // Fetching the modified SQL
self.model.trigger('pgadmin-view:msql:fetching', self.method, node);
$.ajax({
@@ -1457,8 +1481,8 @@
type: 'GET',
cache: false,
data: self.model.toJSON(true, 'GET'),
- dataType: "json",
- contentType: "application/json"
+ dataType: 'json',
+ contentType: 'application/json',
}).done(function(res) {
self.sqlCtrl.clearHistory();
self.sqlCtrl.setValue(res.data);
@@ -1481,16 +1505,16 @@
onPanelResized: function(o) {
if (o && o.container) {
var $tabContent = o.container.find(
- '.backform-tab > .tab-content'
- ).first(),
- $sqlPane = $tabContent.find(
- 'div[role=tabpanel].tab-pane.SQL'
- );
+ '.backform-tab > .tab-content'
+ ).first(),
+ $sqlPane = $tabContent.find(
+ 'div[role=tabpanel].tab-pane.SQL'
+ );
if ($sqlPane.hasClass('active')) {
$sqlPane.find('.CodeMirror').css(
'cssText',
'height: ' + ($tabContent.height() + 8) + 'px !important;'
- )
+ );
}
}
},
@@ -1506,20 +1530,20 @@
this.model.off('pg-browser-resized', this.onPanelResized, this);
Backform.Control.__super__.remove.apply(this, arguments);
- }
-});
- /*
+ },
+ });
+ /*
* Numeric input Control functionality just like backgrid
*/
- var NumericControl = Backform.NumericControl = Backform.InputControl.extend({
+ Backform.NumericControl = Backform.InputControl.extend({
defaults: {
- type: "number",
- label: "",
+ type: 'number',
+ label: '',
min: undefined,
max: undefined,
maxlength: 255,
extraClasses: [],
- helpMessage: null
+ helpMessage: null,
},
template: _.template([
''),
+ td = $('| ', {
+ class: 'editable sortable renderable',
+ style: 'height: auto',
+ colspan: noofcol + 2,
+ }).appendTo(tr);
this.tr = tr;
@@ -263,7 +253,9 @@
},
save: function() {
// Retrieve values from the form, and store inside the object model
- this.model.trigger("backgrid:edited", this.model, this.column, new Backgrid.Command({keyCode:13}));
+ this.model.trigger('backgrid:edited', this.model, this.column, new Backgrid.Command({
+ keyCode: 13,
+ }));
if (this.tr) {
this.tr.remove();
}
@@ -277,34 +269,34 @@
this.tr.remove();
}
return this;
- }
+ },
});
- var PGSelectCell = Backgrid.Extension.PGSelectCell = Backgrid.SelectCell.extend({
+ Backgrid.Extension.PGSelectCell = Backgrid.SelectCell.extend({
// It's possible to render an option group or use a
// function to provide option values too.
optionValues: function() {
var res = [],
- opts = _.result(this.column.attributes, 'options');
+ opts = _.result(this.column.attributes, 'options');
_.each(opts, function(o) {
res.push([o.label, o.value]);
});
return res;
- }
+ },
});
- var ObjectCell = Backgrid.Extension.ObjectCell = Backgrid.Cell.extend({
+ Backgrid.Extension.ObjectCell = Backgrid.Cell.extend({
editorOptionDefaults: {
- schema: []
+ schema: [],
},
- className: "edit-cell",
+ className: 'edit-cell',
editor: ObjectCellEditor,
initialize: function(options) {
Backgrid.Cell.prototype.initialize.apply(this, arguments);
// Pass on cell options to the editor
var cell = this,
- editorOptions = {};
+ editorOptions = {};
_.each(this.editorOptionDefaults, function(def, opt) {
if (!cell[opt]) cell[opt] = def;
if (options && options[opt]) cell[opt] = options[opt];
@@ -313,23 +305,23 @@
editorOptions['el'] = $(this.el);
editorOptions['columns_length'] = this.column.collection.length;
- editorOptions['el'].attr('tabindex' , 1);
+ editorOptions['el'].attr('tabindex', 1);
- this.listenTo(this.model, "backgrid:edit", function (model, column, cell, editor) {
- if (column.get("name") == this.column.get("name"))
+ this.listenTo(this.model, 'backgrid:edit', function(model, column, cell, editor) {
+ if (column.get('name') == this.column.get('name'))
editor.extendWithOptions(editorOptions);
});
},
- enterEditMode: function () {
+ enterEditMode: function() {
// Notify that we are about to enter in edit mode for current cell.
- // We will check if this row is editable first
+ // We will check if this row is editable first
var canEditRow = (!_.isUndefined(this.column.get('canEditRow')) &&
- _.isFunction(this.column.get('canEditRow'))) ?
- Backgrid.callByNeed(this.column.get('canEditRow'),
- this.column, this.model) : true;
+ _.isFunction(this.column.get('canEditRow'))) ?
+ Backgrid.callByNeed(this.column.get('canEditRow'),
+ this.column, this.model) : true;
if (canEditRow) {
// Notify that we are about to enter in edit mode for current cell.
- this.model.trigger("enteringEditMode", [this]);
+ this.model.trigger('enteringEditMode', [this]);
Backgrid.Cell.prototype.enterEditMode.apply(this, arguments);
/* Make sure - we listen to the click event */
@@ -338,26 +330,26 @@
if (editable) {
this.$el.html(
- ""
- );
+ ''
+ );
this.model.trigger(
- "pg-sub-node:opened", this.model, this
- );
+ 'pg-sub-node:opened', this.model, this
+ );
}
} else {
- Alertify.alert(gettext("This object is not user editable."),
- function(){
- return true;
+ Alertify.alert(gettext('This object is not user editable.'),
+ function() {
+ return true;
});
}
},
- render: function(){
- this.$el.empty();
- this.$el.html("");
- this.delegateEvents();
- if (this.grabFocus)
- this.$el.focus();
- return this;
+ render: function() {
+ this.$el.empty();
+ this.$el.html('');
+ this.delegateEvents();
+ if (this.grabFocus)
+ this.$el.focus();
+ return this;
},
exitEditMode: function() {
var index = $(this.currentEditor.objectView.el)
@@ -365,8 +357,8 @@
.data('tabIndex');
Backgrid.Cell.prototype.exitEditMode.apply(this, arguments);
this.model.trigger(
- "pg-sub-node:closed", this, index
- );
+ 'pg-sub-node:closed', this, index
+ );
this.grabFocus = true;
},
events: {
@@ -379,87 +371,89 @@
this.enterEditMode.call(this, []);
}
e.preventDefault();
- }
- }
+ },
+ },
});
- var DeleteCell = Backgrid.Extension.DeleteCell = Backgrid.Cell.extend({
- defaults: _.defaults({
- defaultDeleteMsg: gettext('Are you sure you wish to delete this row?'),
- defaultDeleteTitle: gettext('Delete Row')
- }, Backgrid.Cell.prototype.defaults),
+ Backgrid.Extension.DeleteCell = Backgrid.Cell.extend({
+ defaults: _.defaults({
+ defaultDeleteMsg: gettext('Are you sure you wish to delete this row?'),
+ defaultDeleteTitle: gettext('Delete Row'),
+ }, Backgrid.Cell.prototype.defaults),
- /** @property */
- className: "delete-cell",
- events: {
- "click": "deleteRow"
- },
- deleteRow: function (e) {
- e.preventDefault();
- var that = this;
- // We will check if row is deletable or not
- var canDeleteRow = (!_.isUndefined(this.column.get('canDeleteRow')) &&
- _.isFunction(this.column.get('canDeleteRow')) ) ?
- Backgrid.callByNeed(this.column.get('canDeleteRow'),
- this.column, this.model) : true;
- if (canDeleteRow) {
- var delete_msg = !_.isUndefined(this.column.get('customDeleteMsg')) ?
- this.column.get('customDeleteMsg'): that.defaults.defaultDeleteMsg;
- var delete_title = !_.isUndefined(this.column.get('customDeleteTitle')) ?
- this.column.get('customDeleteTitle'): that.defaults.defaultDeleteTitle;
- Alertify.confirm(
- delete_title,
- delete_msg,
- function(evt) {
- that.model.collection.remove(that.model);
- },
- function(evt) {
- return true;
- }
- );
- } else {
- Alertify.alert(gettext("This object cannot be deleted."),
- function(){
- return true;
- }
- );
- }
- },
- initialize: function () {
- Backgrid.Cell.prototype.initialize.apply(this, arguments);
- },
- render: function () {
- this.$el.empty();
- this.$el.html("");
- this.delegateEvents();
- return this;
+ /** @property */
+ className: 'delete-cell',
+ events: {
+ 'click': 'deleteRow',
+ },
+ deleteRow: function(e) {
+ e.preventDefault();
+ var that = this;
+ // We will check if row is deletable or not
+ var canDeleteRow = (!_.isUndefined(this.column.get('canDeleteRow')) &&
+ _.isFunction(this.column.get('canDeleteRow'))) ?
+ Backgrid.callByNeed(this.column.get('canDeleteRow'),
+ this.column, this.model) : true;
+ if (canDeleteRow) {
+ var delete_msg = !_.isUndefined(this.column.get('customDeleteMsg')) ?
+ this.column.get('customDeleteMsg') : that.defaults.defaultDeleteMsg;
+ var delete_title = !_.isUndefined(this.column.get('customDeleteTitle')) ?
+ this.column.get('customDeleteTitle') : that.defaults.defaultDeleteTitle;
+ Alertify.confirm(
+ delete_title,
+ delete_msg,
+ function() {
+ that.model.collection.remove(that.model);
+ },
+ function() {
+ return true;
+ }
+ );
+ } else {
+ Alertify.alert(gettext('This object cannot be deleted.'),
+ function() {
+ return true;
+ }
+ );
}
+ },
+ initialize: function() {
+ Backgrid.Cell.prototype.initialize.apply(this, arguments);
+ },
+ render: function() {
+ this.$el.empty();
+ this.$el.html('');
+ this.delegateEvents();
+ return this;
+ },
});
- var CustomHeaderCell = Backgrid.Extension.CustomHeaderCell = Backgrid.HeaderCell.extend({
- initialize: function () {
+ Backgrid.Extension.CustomHeaderCell = Backgrid.HeaderCell.extend({
+ initialize: function() {
// Here, we will add custom classes to header cell
Backgrid.HeaderCell.prototype.initialize.apply(this, arguments);
var getClassName = this.column.get('cellHeaderClasses');
if (getClassName) {
this.$el.addClass(getClassName);
}
- }
+ },
});
/**
SwitchCell renders a Bootstrap Switch in backgrid cell
*/
- $.fn.bootstrapSwitch = jQuery.fn.bootstrapSwitch;
- var SwitchCell = Backgrid.Extension.SwitchCell = Backgrid.BooleanCell.extend({
+ if (window.jQuery && window.jQuery.fn.bootstrapSwitch)
+ $.fn.bootstrapSwitch = window.jQuery.fn.bootstrapSwitch;
+
+ Backgrid.Extension.SwitchCell = Backgrid.BooleanCell.extend({
defaults: {
options: _.defaults({
onText: gettext('True'),
offText: gettext('False'),
onColor: 'success',
offColor: 'default',
- size: 'mini'
- }, $.fn.bootstrapSwitch.defaults)
+ size: 'mini',
+ }, $.fn.bootstrapSwitch.defaults),
},
className: 'switch-cell',
@@ -479,71 +473,73 @@
},
events: {
- 'switchChange.bootstrapSwitch': 'onChange'
+ 'switchChange.bootstrapSwitch': 'onChange',
},
- onChange: function () {
+ onChange: function() {
var model = this.model,
- column = this.column,
- val = this.formatter.toRaw(this.$input.prop('checked'), model);
+ column = this.column,
+ val = this.formatter.toRaw(this.$input.prop('checked'), model);
this.enterEditMode();
// on bootstrap change we also need to change model's value
- model.set(column.get("name"), val);
+ model.set(column.get('name'), val);
},
- render: function () {
- var self = this, col = _.defaults(this.column.toJSON(), this.defaults),
- attributes = this.model.toJSON(),
- attrArr = col.name.split('.'),
- name = attrArr.shift(),
- path = attrArr.join('.'),
- model = this.model, column = this.column,
- rawValue = this.formatter.fromRaw(
- model.get(column.get("name")), model
- ),
- editable = Backgrid.callByNeed(col.editable, column, model);
+ render: function() {
+ var self = this,
+ col = _.defaults(this.column.toJSON(), this.defaults),
+ model = this.model,
+ column = this.column,
+ rawValue = this.formatter.fromRaw(
+ model.get(column.get('name')), model
+ ),
+ editable = Backgrid.callByNeed(col.editable, column, model);
this.undelegateEvents();
this.$el.empty();
this.$el.append(
- $("", {
+ $('', {
tabIndex: -1,
- type: "checkbox"
- }).prop('checked', rawValue).prop('disabled', !editable));
+ type: 'checkbox',
+ }).prop('checked', rawValue).prop('disabled', !editable));
this.$input = this.$el.find('input[type=checkbox]').first();
// Override BooleanCell checkbox with Bootstrapswitch
this.$input.bootstrapSwitch(
- _.defaults(
- {'state': rawValue, 'disabled': !editable}, col.options,
+ _.defaults({
+ 'state': rawValue,
+ 'disabled': !editable,
+ }, col.options,
this.defaults.options
- ));
+ ));
// Listen for Tab key
this.$el.on('keydown', function(e) {
var gotoCell;
- if(e.keyCode == 9) {
+ if (e.keyCode == 9) {
// go to Next Cell & if Shift is also pressed go to Previous Cell
gotoCell = e.shiftKey ? self.$el.prev() : self.$el.next();
}
- if(gotoCell) {
- setTimeout(function() {
- if(gotoCell.hasClass('editable')) {
- e.preventDefault();
- e.stopPropagation();
- var command = new Backgrid.Command({
- key: "Tab", keyCode: 9,
- which: 9, shiftKey: e.shiftKey
- });
- self.model.trigger("backgrid:edited", self.model,
- self.column, command);
- gotoCell.focus();
- }
- }, 20);
+ if (gotoCell) {
+ setTimeout(function() {
+ if (gotoCell.hasClass('editable')) {
+ e.preventDefault();
+ e.stopPropagation();
+ var command = new Backgrid.Command({
+ key: 'Tab',
+ keyCode: 9,
+ which: 9,
+ shiftKey: e.shiftKey,
+ });
+ self.model.trigger('backgrid:edited', self.model,
+ self.column, command);
+ gotoCell.focus();
+ }
+ }, 20);
}
});
@@ -551,15 +547,14 @@
this.delegateEvents();
return this;
- }
+ },
});
/*
* Select2Cell for backgrid.
*/
- var Select2Cell = Backgrid.Extension.Select2Cell =
- Backgrid.SelectCell.extend({
- className: "select2-cell",
+ Backgrid.Extension.Select2Cell = Backgrid.SelectCell.extend({
+ className: 'select2-cell',
/** @property */
editor: null,
@@ -569,9 +564,9 @@
opt: {
label: null,
value: null,
- selected: false
- }
- }, Backgrid.SelectCell.prototype.defaults),
+ selected: false,
+ },
+ }, Backgrid.SelectCell.prototype.defaults),
enterEditMode: function() {
if (!this.$el.hasClass('editor'))
@@ -588,18 +583,19 @@
},
events: {
- "select2:open": "enterEditMode",
- "select2:close": "exitEditMode",
- "change": "onSave",
- "select2:unselect": "onSave"
+ 'select2:open': 'enterEditMode',
+ 'select2:close': 'exitEditMode',
+ 'change': 'onSave',
+ 'select2:unselect': 'onSave',
},
/** @property {function(Object, ?Object=): string} template */
template: _.template([
''].join(''),
- null,{
- variable: null
+ '<%- label %>',
+ ].join(''),
+ null, {
+ variable: null,
}),
initialize: function() {
@@ -609,19 +605,20 @@
this.exitEditMode = this.exitEditMode.bind(this);
},
- render: function () {
+ render: function() {
var col = _.defaults(this.column.toJSON(), this.defaults),
- model = this.model, column = this.column,
- editable = Backgrid.callByNeed(col.editable, column, model),
- optionValues = _.clone(this.optionValues ||
- (_.isFunction(this.column.get('options')) ?
- (this.column.get('options'))(this) :
- this.column.get('options')));
+ model = this.model,
+ column = this.column,
+ editable = Backgrid.callByNeed(col.editable, column, model),
+ optionValues = _.clone(this.optionValues ||
+ (_.isFunction(this.column.get('options')) ?
+ (this.column.get('options'))(this) :
+ this.column.get('options')));
this.undelegateEvents();
if (this.$select) {
- if ( this.$select.data('select2')) {
+ if (this.$select.data('select2')) {
this.$select.select2('destroy');
}
delete this.$select;
@@ -631,7 +628,7 @@
this.$el.empty();
if (!_.isArray(optionValues))
- throw new TypeError("optionValues must be an array");
+ throw new TypeError('optionValues must be an array');
/*
* Add empty option as Select2 requires any empty ' |