2019-01-02 10:24:12 +00:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
|
|
|
// Copyright (C) 2013 - 2019, The pgAdmin Development Team
|
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
define([
|
|
|
|
'sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', 'backgrid', 'alertify',
|
Improvement in the look and feel of the whole application
Changed the SCSS/CSS for the below third party libraries to adopt the
new look 'n' feel:
- wcDocker
- Alertify dialogs, and notifications
- AciTree
- Bootstrap Navbar
- Bootstrap Tabs
- Bootstrap Drop-Down menu
- Backgrid
- Select2
Adopated the new the look 'n' feel for the dialogs, wizard, properties,
tab panels, tabs, fieldset, subnode control, spinner control, HTML
table, and other form controls.
- Font is changed to Roboto
- Using SCSS variables to define the look 'n' feel
- Designer background images for the Login, and Forget password pages in
'web' mode
- Improved the look 'n' feel for the key selection in the preferences
dialog
- Table classes consistency changes across the application
- File Open and Save dialog list view changes
Author(s): Aditya Toshniwal & Khushboo Vashi
2018-12-21 11:44:55 +00:00
|
|
|
'moment', 'bignumber', 'bootstrap.datetimepicker', 'bootstrap.switch', 'backgrid.filter',
|
2018-01-12 07:29:51 +00:00
|
|
|
], function(
|
|
|
|
gettext, _, $, Backbone, Backform, Backgrid, Alertify, moment, BigNumber
|
|
|
|
) {
|
2016-02-05 09:05:49 +00:00
|
|
|
/*
|
2018-01-12 07:29:51 +00:00
|
|
|
* Add mechanism in backgrid to render different types of cells in
|
|
|
|
* same column;
|
2016-02-05 09:05:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
// Add new property cellFunction in Backgrid.Column.
|
2018-01-12 07:29:51 +00:00
|
|
|
_.extend(Backgrid.Column.prototype.defaults, {
|
|
|
|
cellFunction: undefined,
|
|
|
|
});
|
2016-02-05 09:05:49 +00:00
|
|
|
|
2016-08-19 09:54:13 +00:00
|
|
|
// Add tooltip to cell if cell content is larger than
|
|
|
|
// cell width
|
|
|
|
_.extend(Backgrid.Cell.prototype.events, {
|
2018-01-12 07:29:51 +00:00
|
|
|
'mouseover': function() {
|
2016-08-19 09:54:13 +00:00
|
|
|
var $el = $(this.el);
|
2018-01-12 07:29:51 +00:00
|
|
|
if ($el.text().length > 0 && !$el.attr('title') &&
|
2016-08-19 09:54:13 +00:00
|
|
|
($el.innerWidth() + 1) < $el[0].scrollWidth
|
|
|
|
) {
|
|
|
|
$el.attr('title', $.trim($el.text()));
|
|
|
|
}
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2016-08-19 09:54:13 +00:00
|
|
|
});
|
|
|
|
|
2017-01-09 10:25:38 +00:00
|
|
|
/* Overriding backgrid sort method.
|
|
|
|
* As we are getting numeric, integer values as string
|
|
|
|
* from server side, but on client side javascript truncates
|
|
|
|
* large numbers automatically due to which backgrid was unable
|
|
|
|
* to sort numeric values properly in the grid.
|
|
|
|
* To fix this issue, now we check if cell type is integer/number
|
|
|
|
* convert it into BigNumber object and make comparison to perform sorting.
|
|
|
|
*/
|
|
|
|
|
|
|
|
_.extend(Backgrid.Body.prototype, {
|
2018-01-12 07:29:51 +00:00
|
|
|
sort: function(column, direction) {
|
2017-01-09 10:25:38 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
if (!_.contains(['ascending', 'descending', null], direction)) {
|
2017-01-09 10:25:38 +00:00
|
|
|
throw new RangeError('direction must be one of "ascending", "descending" or `null`');
|
|
|
|
}
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
if (_.isString(column)) column = this.columns.findWhere({
|
|
|
|
name: column,
|
|
|
|
});
|
2017-01-09 10:25:38 +00:00
|
|
|
|
|
|
|
var collection = this.collection;
|
|
|
|
|
|
|
|
var order;
|
2018-01-12 07:29:51 +00:00
|
|
|
if (direction === 'ascending') order = -1;
|
|
|
|
else if (direction === 'descending') order = 1;
|
2017-01-09 10:25:38 +00:00
|
|
|
else order = null;
|
|
|
|
|
|
|
|
// Get column type and pass it to comparator.
|
|
|
|
var col_type = column.get('cell').prototype.className || 'string-cell',
|
2018-01-12 07:29:51 +00:00
|
|
|
comparator = this.makeComparator(column.get('name'), order,
|
|
|
|
order ?
|
|
|
|
column.sortValue() :
|
|
|
|
function(model) {
|
|
|
|
return model.cid.replace('c', '') * 1;
|
|
|
|
}, col_type);
|
2017-01-09 10:25:38 +00:00
|
|
|
|
|
|
|
if (Backbone.PageableCollection &&
|
2018-01-12 07:29:51 +00:00
|
|
|
collection instanceof Backbone.PageableCollection) {
|
2017-01-09 10:25:38 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
collection.setSorting(order && column.get('name'), order, {
|
|
|
|
sortValue: column.sortValue(),
|
|
|
|
});
|
2017-01-09 10:25:38 +00:00
|
|
|
|
|
|
|
if (collection.fullCollection) {
|
|
|
|
// If order is null, pageable will remove the comparator on both sides,
|
|
|
|
// in this case the default insertion order comparator needs to be
|
|
|
|
// attached to get back to the order before sorting.
|
|
|
|
if (collection.fullCollection.comparator == null) {
|
|
|
|
collection.fullCollection.comparator = comparator;
|
|
|
|
}
|
|
|
|
collection.fullCollection.sort();
|
2018-01-12 07:29:51 +00:00
|
|
|
collection.trigger('backgrid:sorted', column, direction, collection);
|
|
|
|
} else collection.fetch({
|
|
|
|
reset: true,
|
|
|
|
success: function() {
|
|
|
|
collection.trigger('backgrid:sorted', column, direction, collection);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
} else {
|
2017-01-09 10:25:38 +00:00
|
|
|
collection.comparator = comparator;
|
|
|
|
collection.sort();
|
2018-01-12 07:29:51 +00:00
|
|
|
collection.trigger('backgrid:sorted', column, direction, collection);
|
2017-01-09 10:25:38 +00:00
|
|
|
}
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
column.set('direction', direction);
|
2017-01-09 10:25:38 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
2018-01-12 07:29:51 +00:00
|
|
|
makeComparator: function(attr, order, func, type) {
|
2017-01-09 10:25:38 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
return function(left, right) {
|
2017-01-09 10:25:38 +00:00
|
|
|
// extract the values from the models
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
var l = func(left, attr),
|
|
|
|
r = func(right, attr),
|
|
|
|
t;
|
2017-07-18 15:31:05 +00:00
|
|
|
if (_.isUndefined(l) || _.isUndefined(r)) return;
|
2017-01-09 10:25:38 +00:00
|
|
|
|
|
|
|
var types = ['number-cell', 'integer-cell'];
|
|
|
|
if (_.include(types, type)) {
|
|
|
|
var _l, _r;
|
|
|
|
// NaN if invalid number
|
|
|
|
try {
|
|
|
|
_l = new BigNumber(l);
|
2018-01-12 07:29:51 +00:00
|
|
|
} catch (err) {
|
2017-01-09 10:25:38 +00:00
|
|
|
_l = NaN;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
_r = new BigNumber(r);
|
2018-01-12 07:29:51 +00:00
|
|
|
} catch (err) {
|
2017-01-09 10:25:38 +00:00
|
|
|
_r = NaN;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if descending order, swap left and right
|
|
|
|
if (order === 1) t = _l, _l = _r, _r = t;
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
if (_l.eq(_r)) // If both are equals
|
2017-01-09 10:25:38 +00:00
|
|
|
return 0;
|
|
|
|
else if (_l.lt(_r)) // If left is less than right
|
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
return 1;
|
2018-01-12 07:29:51 +00:00
|
|
|
} else {
|
2017-03-28 13:19:24 +00:00
|
|
|
// if descending order, swap left and right
|
|
|
|
if (order === 1) t = l, l = r, r = t;
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
// compare as usual
|
2017-03-28 13:19:24 +00:00
|
|
|
if (l === r) return 0;
|
|
|
|
else if (l < r) return -1;
|
|
|
|
return 1;
|
|
|
|
}
|
2017-01-09 10:25:38 +00:00
|
|
|
};
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2017-01-09 10:25:38 +00:00
|
|
|
});
|
|
|
|
|
2016-02-05 09:05:49 +00:00
|
|
|
_.extend(Backgrid.Row.prototype, {
|
2018-01-12 07:29:51 +00:00
|
|
|
makeCell: function(column) {
|
|
|
|
return new(this.getCell(column))({
|
2016-02-05 09:05:49 +00:00
|
|
|
column: column,
|
2018-01-12 07:29:51 +00:00
|
|
|
model: this.model,
|
2016-02-05 09:05:49 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
/*
|
|
|
|
* getCell function will check and execute user given cellFunction to get
|
|
|
|
* appropriate cell class for current cell being rendered.
|
|
|
|
* User provided cellFunction must return valid cell class.
|
|
|
|
* cellFunction will be called with context (this) as column and model as
|
|
|
|
* argument.
|
|
|
|
*/
|
2018-01-12 07:29:51 +00:00
|
|
|
getCell: function(column) {
|
|
|
|
var cf = column.get('cellFunction');
|
|
|
|
if (_.isFunction(cf)) {
|
2016-02-05 09:05:49 +00:00
|
|
|
var cell = cf.apply(column, [this.model]);
|
|
|
|
try {
|
2018-01-12 07:29:51 +00:00
|
|
|
return Backgrid.resolveNameToClass(cell, 'Cell');
|
2016-02-05 09:05:49 +00:00
|
|
|
} catch (e) {
|
|
|
|
if (e instanceof ReferenceError) {
|
|
|
|
// Fallback to column cell.
|
2018-01-12 07:29:51 +00:00
|
|
|
return column.get('cell');
|
2016-02-05 09:05:49 +00:00
|
|
|
} else {
|
|
|
|
throw e; // Let other exceptions bubble up
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2018-01-12 07:29:51 +00:00
|
|
|
return column.get('cell');
|
2016-02-05 09:05:49 +00:00
|
|
|
}
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2016-02-05 09:05:49 +00:00
|
|
|
});
|
|
|
|
|
2015-10-28 17:06:09 +00:00
|
|
|
var ObjectCellEditor = Backgrid.Extension.ObjectCellEditor = Backgrid.CellEditor.extend({
|
|
|
|
modalTemplate: _.template([
|
2015-10-29 20:32:40 +00:00
|
|
|
'<div class="subnode-dialog" tabindex="1">',
|
2015-10-28 17:06:09 +00:00
|
|
|
' <div class="subnode-body"></div>',
|
2018-01-12 07:29:51 +00:00
|
|
|
'</div>',
|
|
|
|
].join('\n')),
|
2015-10-28 17:06:09 +00:00
|
|
|
stringTemplate: _.template([
|
|
|
|
'<div class="form-group">',
|
|
|
|
' <label class="control-label col-sm-4"><%=label%></label>',
|
|
|
|
' <div class="col-sm-8">',
|
|
|
|
' <input type="text" class="form-control" name="<%=name%>" value="<%=value%>" placeholder="<%=placeholder%>" />',
|
|
|
|
' </div>',
|
2018-01-12 07:29:51 +00:00
|
|
|
'</div>',
|
|
|
|
].join('\n')),
|
2015-10-28 17:06:09 +00:00
|
|
|
extendWithOptions: function(options) {
|
|
|
|
_.extend(this, options);
|
|
|
|
},
|
2018-01-12 07:29:51 +00:00
|
|
|
render: function() {
|
2015-10-28 17:06:09 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
postRender: function(model, column) {
|
2018-01-12 07:29:51 +00:00
|
|
|
var columns_length = this.columns_length,
|
|
|
|
// To render schema directly from Backgrid cell we use columns schema
|
|
|
|
// attribute.
|
|
|
|
schema = this.schema.length ? this.schema : this.column.get('schema');
|
2015-10-28 17:06:09 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
if (column != null && column.get('name') != this.column.get('name'))
|
2015-10-28 17:06:09 +00:00
|
|
|
return false;
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
if (!_.isArray(schema)) throw new TypeError('schema must be an array');
|
2015-10-28 17:06:09 +00:00
|
|
|
|
|
|
|
// Create a Backbone model from our object if it does not exist
|
|
|
|
var $dialog = this.createDialog(columns_length);
|
|
|
|
|
|
|
|
// Add the Bootstrap form
|
|
|
|
var $form = $('<form class="form-dialog"></form>');
|
|
|
|
$dialog.find('div.subnode-body').append($form);
|
|
|
|
|
|
|
|
// Call Backform to prepare dialog
|
2017-07-18 14:13:16 +00:00
|
|
|
var back_el = $dialog.find('form.form-dialog');
|
2015-10-28 17:06:09 +00:00
|
|
|
|
2015-10-29 20:32:40 +00:00
|
|
|
this.objectView = new Backform.Dialog({
|
2018-01-12 07:29:51 +00:00
|
|
|
el: back_el,
|
|
|
|
model: this.model,
|
|
|
|
schema: schema,
|
2015-10-29 20:32:40 +00:00
|
|
|
tabPanelClassName: function() {
|
|
|
|
return 'sub-node-form col-sm-12';
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2015-10-28 17:06:09 +00:00
|
|
|
});
|
|
|
|
|
2015-10-29 20:32:40 +00:00
|
|
|
this.objectView.render();
|
2015-10-28 17:06:09 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
createDialog: function(noofcol) {
|
2018-01-12 07:29:51 +00:00
|
|
|
noofcol = noofcol || 1;
|
|
|
|
var $dialog = this.$dialog = $(this.modalTemplate({
|
|
|
|
title: '',
|
|
|
|
})),
|
Improvement in the look and feel of the whole application
Changed the SCSS/CSS for the below third party libraries to adopt the
new look 'n' feel:
- wcDocker
- Alertify dialogs, and notifications
- AciTree
- Bootstrap Navbar
- Bootstrap Tabs
- Bootstrap Drop-Down menu
- Backgrid
- Select2
Adopated the new the look 'n' feel for the dialogs, wizard, properties,
tab panels, tabs, fieldset, subnode control, spinner control, HTML
table, and other form controls.
- Font is changed to Roboto
- Using SCSS variables to define the look 'n' feel
- Designer background images for the Login, and Forget password pages in
'web' mode
- Improved the look 'n' feel for the key selection in the preferences
dialog
- Table classes consistency changes across the application
- File Open and Save dialog list view changes
Author(s): Aditya Toshniwal & Khushboo Vashi
2018-12-21 11:44:55 +00:00
|
|
|
tr = $('<tr class="nohover editor-row">'),
|
2018-01-12 07:29:51 +00:00
|
|
|
td = $('<td>', {
|
|
|
|
class: 'editable sortable renderable',
|
|
|
|
style: 'height: auto',
|
|
|
|
colspan: noofcol + 2,
|
|
|
|
}).appendTo(tr);
|
2015-10-28 17:06:09 +00:00
|
|
|
|
2015-10-29 20:32:40 +00:00
|
|
|
this.tr = tr;
|
2015-10-28 17:06:09 +00:00
|
|
|
|
|
|
|
// Show the Bootstrap modal dialog
|
|
|
|
td.append($dialog.css('display', 'block'));
|
|
|
|
this.el.parent('tr').after(tr);
|
|
|
|
|
|
|
|
return $dialog;
|
|
|
|
},
|
2015-10-29 20:32:40 +00:00
|
|
|
save: function() {
|
2015-10-28 17:06:09 +00:00
|
|
|
// Retrieve values from the form, and store inside the object model
|
2018-01-12 07:29:51 +00:00
|
|
|
this.model.trigger('backgrid:edited', this.model, this.column, new Backgrid.Command({
|
|
|
|
keyCode: 13,
|
|
|
|
}));
|
2015-10-29 20:32:40 +00:00
|
|
|
if (this.tr) {
|
|
|
|
this.tr.remove();
|
|
|
|
}
|
2015-10-28 17:06:09 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
remove: function() {
|
2016-05-12 10:17:12 +00:00
|
|
|
this.objectView.remove();
|
2015-10-28 17:06:09 +00:00
|
|
|
Backgrid.CellEditor.prototype.remove.apply(this, arguments);
|
2015-10-29 20:32:40 +00:00
|
|
|
if (this.tr) {
|
|
|
|
this.tr.remove();
|
|
|
|
}
|
2015-10-28 17:06:09 +00:00
|
|
|
return this;
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2015-10-28 17:06:09 +00:00
|
|
|
});
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
Backgrid.Extension.PGSelectCell = Backgrid.SelectCell.extend({
|
2015-10-28 17:06:09 +00:00
|
|
|
// It's possible to render an option group or use a
|
|
|
|
// function to provide option values too.
|
|
|
|
optionValues: function() {
|
2017-07-18 14:13:16 +00:00
|
|
|
var res = [],
|
2018-01-12 07:29:51 +00:00
|
|
|
opts = _.result(this.column.attributes, 'options');
|
2015-10-28 17:06:09 +00:00
|
|
|
_.each(opts, function(o) {
|
|
|
|
res.push([o.label, o.value]);
|
|
|
|
});
|
|
|
|
return res;
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2015-10-28 17:06:09 +00:00
|
|
|
});
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
Backgrid.Extension.ObjectCell = Backgrid.Cell.extend({
|
2015-10-28 17:06:09 +00:00
|
|
|
editorOptionDefaults: {
|
2018-01-12 07:29:51 +00:00
|
|
|
schema: [],
|
2015-10-28 17:06:09 +00:00
|
|
|
},
|
2018-01-12 07:29:51 +00:00
|
|
|
className: 'edit-cell',
|
2015-10-28 17:06:09 +00:00
|
|
|
editor: ObjectCellEditor,
|
|
|
|
initialize: function(options) {
|
|
|
|
Backgrid.Cell.prototype.initialize.apply(this, arguments);
|
|
|
|
|
|
|
|
// Pass on cell options to the editor
|
|
|
|
var cell = this,
|
2018-01-12 07:29:51 +00:00
|
|
|
editorOptions = {};
|
2015-10-28 17:06:09 +00:00
|
|
|
_.each(this.editorOptionDefaults, function(def, opt) {
|
|
|
|
if (!cell[opt]) cell[opt] = def;
|
|
|
|
if (options && options[opt]) cell[opt] = options[opt];
|
|
|
|
editorOptions[opt] = cell[opt];
|
|
|
|
});
|
|
|
|
|
|
|
|
editorOptions['el'] = $(this.el);
|
2015-10-29 20:32:40 +00:00
|
|
|
editorOptions['columns_length'] = this.column.collection.length;
|
2018-01-12 07:29:51 +00:00
|
|
|
editorOptions['el'].attr('tabindex', 1);
|
2015-10-28 17:06:09 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
this.listenTo(this.model, 'backgrid:edit', function(model, column, cell, editor) {
|
|
|
|
if (column.get('name') == this.column.get('name'))
|
2015-10-28 17:06:09 +00:00
|
|
|
editor.extendWithOptions(editorOptions);
|
|
|
|
});
|
|
|
|
},
|
2018-01-12 07:29:51 +00:00
|
|
|
enterEditMode: function() {
|
2016-03-22 17:04:46 +00:00
|
|
|
// Notify that we are about to enter in edit mode for current cell.
|
2018-01-12 07:29:51 +00:00
|
|
|
// We will check if this row is editable first
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
var canEditRow = (!_.isUndefined(this.column.get('canEditRow')) &&
|
2018-01-12 07:29:51 +00:00
|
|
|
_.isFunction(this.column.get('canEditRow'))) ?
|
|
|
|
Backgrid.callByNeed(this.column.get('canEditRow'),
|
|
|
|
this.column, this.model) : true;
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
if (canEditRow) {
|
|
|
|
// Notify that we are about to enter in edit mode for current cell.
|
2018-01-12 07:29:51 +00:00
|
|
|
this.model.trigger('enteringEditMode', [this]);
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
|
|
|
|
Backgrid.Cell.prototype.enterEditMode.apply(this, arguments);
|
|
|
|
/* Make sure - we listen to the click event */
|
|
|
|
this.delegateEvents();
|
|
|
|
var editable = Backgrid.callByNeed(this.column.editable(), this.column, this.model);
|
|
|
|
|
|
|
|
if (editable) {
|
|
|
|
this.$el.html(
|
2018-01-22 10:37:56 +00:00
|
|
|
'<i class=\'fa fa-pencil-square subnode-edit-in-process\' title=\'' + _('Edit row') + '\'></i>'
|
2018-01-12 07:29:51 +00:00
|
|
|
);
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
this.model.trigger(
|
2018-01-12 07:29:51 +00:00
|
|
|
'pg-sub-node:opened', this.model, this
|
|
|
|
);
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
}
|
|
|
|
} else {
|
2018-01-12 07:29:51 +00:00
|
|
|
Alertify.alert(gettext('This object is not user editable.'),
|
|
|
|
function() {
|
|
|
|
return true;
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
});
|
2015-10-29 20:32:40 +00:00
|
|
|
}
|
2015-10-28 17:06:09 +00:00
|
|
|
},
|
2018-01-12 07:29:51 +00:00
|
|
|
render: function() {
|
|
|
|
this.$el.empty();
|
2018-01-22 10:37:56 +00:00
|
|
|
this.$el.html('<i class=\'fa fa-pencil-square-o\' title=\'' + _('Edit row') + '\'></i>');
|
2018-01-12 07:29:51 +00:00
|
|
|
this.delegateEvents();
|
|
|
|
if (this.grabFocus)
|
2018-05-25 15:26:37 +00:00
|
|
|
this.$el.trigger('focus');
|
2018-01-12 07:29:51 +00:00
|
|
|
return this;
|
2015-10-29 20:32:40 +00:00
|
|
|
},
|
|
|
|
exitEditMode: function() {
|
|
|
|
var index = $(this.currentEditor.objectView.el)
|
|
|
|
.find('.nav-tabs > .active > a[data-toggle="tab"]').first()
|
|
|
|
.data('tabIndex');
|
|
|
|
Backgrid.Cell.prototype.exitEditMode.apply(this, arguments);
|
|
|
|
this.model.trigger(
|
2018-01-12 07:29:51 +00:00
|
|
|
'pg-sub-node:closed', this, index
|
|
|
|
);
|
2015-10-30 07:37:09 +00:00
|
|
|
this.grabFocus = true;
|
2015-10-29 20:32:40 +00:00
|
|
|
},
|
|
|
|
events: {
|
|
|
|
'click': function(e) {
|
|
|
|
if (this.$el.find('i').first().hasClass('subnode-edit-in-process')) {
|
|
|
|
// Need to redundantly undelegate events for Firefox
|
|
|
|
this.undelegateEvents();
|
|
|
|
this.currentEditor.save();
|
|
|
|
} else {
|
|
|
|
this.enterEditMode.call(this, []);
|
|
|
|
}
|
|
|
|
e.preventDefault();
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
|
|
|
},
|
2015-10-28 17:06:09 +00:00
|
|
|
});
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
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),
|
2016-08-01 14:18:57 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
/** @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;
|
|
|
|
}
|
|
|
|
);
|
2015-10-28 17:06:09 +00:00
|
|
|
}
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
|
|
|
initialize: function() {
|
|
|
|
Backgrid.Cell.prototype.initialize.apply(this, arguments);
|
|
|
|
},
|
|
|
|
render: function() {
|
|
|
|
this.$el.empty();
|
2018-01-22 10:37:56 +00:00
|
|
|
this.$el.html('<i class=\'fa fa-trash\' title=\'' + _('Delete row') + '\'></i>');
|
2018-01-12 07:29:51 +00:00
|
|
|
this.delegateEvents();
|
|
|
|
return this;
|
|
|
|
},
|
2015-10-28 17:06:09 +00:00
|
|
|
});
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
Backgrid.Extension.CustomHeaderCell = Backgrid.HeaderCell.extend({
|
|
|
|
initialize: function() {
|
2015-12-17 13:48:42 +00:00
|
|
|
// 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);
|
|
|
|
}
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2015-12-17 13:48:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
SwitchCell renders a Bootstrap Switch in backgrid cell
|
|
|
|
*/
|
2018-01-12 07:29:51 +00:00
|
|
|
if (window.jQuery && window.jQuery.fn.bootstrapSwitch)
|
|
|
|
$.fn.bootstrapSwitch = window.jQuery.fn.bootstrapSwitch;
|
|
|
|
|
|
|
|
Backgrid.Extension.SwitchCell = Backgrid.BooleanCell.extend({
|
2015-12-17 13:48:42 +00:00
|
|
|
defaults: {
|
|
|
|
options: _.defaults({
|
2017-11-07 00:49:11 +00:00
|
|
|
onText: gettext('True'),
|
|
|
|
offText: gettext('False'),
|
2015-12-17 13:48:42 +00:00
|
|
|
onColor: 'success',
|
|
|
|
offColor: 'default',
|
2018-01-12 07:29:51 +00:00
|
|
|
size: 'mini',
|
|
|
|
}, $.fn.bootstrapSwitch.defaults),
|
2015-12-17 13:48:42 +00:00
|
|
|
},
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
|
2015-12-17 13:48:42 +00:00
|
|
|
className: 'switch-cell',
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
|
|
|
|
initialize: function() {
|
|
|
|
Backgrid.BooleanCell.prototype.initialize.apply(this, arguments);
|
|
|
|
this.onChange = this.onChange.bind(this);
|
|
|
|
},
|
|
|
|
|
|
|
|
enterEditMode: function() {
|
|
|
|
this.$el.addClass('editor');
|
2018-05-25 15:26:37 +00:00
|
|
|
$(this.$el.find('input')).trigger('focus');
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
exitEditMode: function() {
|
|
|
|
this.$el.removeClass('editor');
|
|
|
|
},
|
|
|
|
|
2015-12-17 13:48:42 +00:00
|
|
|
events: {
|
2018-01-12 07:29:51 +00:00
|
|
|
'switchChange.bootstrapSwitch': 'onChange',
|
2015-12-17 13:48:42 +00:00
|
|
|
},
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
onChange: function() {
|
2015-12-17 13:48:42 +00:00
|
|
|
var model = this.model,
|
2018-01-12 07:29:51 +00:00
|
|
|
column = this.column,
|
|
|
|
val = this.formatter.toRaw(this.$input.prop('checked'), model);
|
2015-12-17 13:48:42 +00:00
|
|
|
|
2018-01-03 15:32:44 +00:00
|
|
|
this.enterEditMode();
|
2015-12-17 13:48:42 +00:00
|
|
|
// on bootstrap change we also need to change model's value
|
2018-01-12 07:29:51 +00:00
|
|
|
model.set(column.get('name'), val);
|
2015-12-17 13:48:42 +00:00
|
|
|
},
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
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);
|
2015-12-17 13:48:42 +00:00
|
|
|
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
this.undelegateEvents();
|
|
|
|
|
2015-12-17 13:48:42 +00:00
|
|
|
this.$el.empty();
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
|
2015-12-17 13:48:42 +00:00
|
|
|
this.$el.append(
|
2018-01-12 07:29:51 +00:00
|
|
|
$('<input>', {
|
2015-12-17 13:48:42 +00:00
|
|
|
tabIndex: -1,
|
2018-01-12 07:29:51 +00:00
|
|
|
type: 'checkbox',
|
|
|
|
}).prop('checked', rawValue).prop('disabled', !editable));
|
2015-12-17 13:48:42 +00:00
|
|
|
this.$input = this.$el.find('input[type=checkbox]').first();
|
|
|
|
|
|
|
|
// Override BooleanCell checkbox with Bootstrapswitch
|
|
|
|
this.$input.bootstrapSwitch(
|
2018-01-12 07:29:51 +00:00
|
|
|
_.defaults({
|
|
|
|
'state': rawValue,
|
|
|
|
'disabled': !editable,
|
|
|
|
}, col.options,
|
2016-04-04 10:06:28 +00:00
|
|
|
this.defaults.options
|
2018-01-12 07:29:51 +00:00
|
|
|
));
|
2015-12-17 13:48:42 +00:00
|
|
|
|
2017-01-08 04:00:09 +00:00
|
|
|
// Listen for Tab key
|
|
|
|
this.$el.on('keydown', function(e) {
|
|
|
|
var gotoCell;
|
2018-01-12 07:29:51 +00:00
|
|
|
if (e.keyCode == 9) {
|
2017-01-08 04:00:09 +00:00
|
|
|
// go to Next Cell & if Shift is also pressed go to Previous Cell
|
|
|
|
gotoCell = e.shiftKey ? self.$el.prev() : self.$el.next();
|
|
|
|
}
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
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);
|
2018-05-25 15:26:37 +00:00
|
|
|
gotoCell.trigger('focus');
|
2018-01-12 07:29:51 +00:00
|
|
|
}
|
|
|
|
}, 20);
|
2017-01-08 04:00:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-12-17 13:48:42 +00:00
|
|
|
this.delegateEvents();
|
|
|
|
|
|
|
|
return this;
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2015-12-04 10:19:08 +00:00
|
|
|
});
|
|
|
|
|
2016-01-07 03:05:08 +00:00
|
|
|
/*
|
|
|
|
* Select2Cell for backgrid.
|
|
|
|
*/
|
2018-01-12 07:29:51 +00:00
|
|
|
Backgrid.Extension.Select2Cell = Backgrid.SelectCell.extend({
|
|
|
|
className: 'select2-cell',
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
|
2016-04-04 10:06:28 +00:00
|
|
|
/** @property */
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
editor: null,
|
|
|
|
|
2016-01-07 08:00:41 +00:00
|
|
|
defaults: _.defaults({
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
select2: {},
|
|
|
|
opt: {
|
2016-04-15 05:31:11 +00:00
|
|
|
label: null,
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
value: null,
|
2018-01-12 07:29:51 +00:00
|
|
|
selected: false,
|
|
|
|
},
|
|
|
|
}, Backgrid.SelectCell.prototype.defaults),
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
|
|
|
|
enterEditMode: function() {
|
2016-04-15 05:31:11 +00:00
|
|
|
if (!this.$el.hasClass('editor'))
|
|
|
|
this.$el.addClass('editor');
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
this.$select.select2('focus');
|
2016-07-15 09:12:23 +00:00
|
|
|
this.$select.select2('open');
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
this.$select.on('blur', this.exitEditMode);
|
|
|
|
},
|
|
|
|
|
|
|
|
exitEditMode: function() {
|
|
|
|
this.$select.off('blur', this.exitEditMode);
|
2016-07-15 09:12:23 +00:00
|
|
|
this.$select.select2('close');
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
this.$el.removeClass('editor');
|
|
|
|
},
|
|
|
|
|
2019-01-22 11:05:57 +00:00
|
|
|
saveOrCancel: function (e) {
|
|
|
|
var model = this.model;
|
|
|
|
var column = this.column;
|
|
|
|
|
|
|
|
var command = new Backgrid.Command(e);
|
|
|
|
var blurred = e.type === 'blur';
|
|
|
|
|
|
|
|
if (command.moveUp() || command.moveDown() || command.moveLeft() || command.moveRight() ||
|
|
|
|
command.save() || blurred) {
|
|
|
|
|
|
|
|
this.exitEditMode();
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
model.trigger('backgrid:edited', model, column, command);
|
|
|
|
}
|
|
|
|
},
|
2016-01-07 03:05:08 +00:00
|
|
|
events: {
|
2018-01-12 07:29:51 +00:00
|
|
|
'select2:open': 'enterEditMode',
|
|
|
|
'select2:close': 'exitEditMode',
|
|
|
|
'change': 'onSave',
|
|
|
|
'select2:unselect': 'onSave',
|
2019-01-22 11:05:57 +00:00
|
|
|
'blur': 'saveOrCancel',
|
|
|
|
'keydown': 'saveOrCancel',
|
2016-01-07 03:05:08 +00:00
|
|
|
},
|
2016-04-04 10:06:28 +00:00
|
|
|
/** @property {function(Object, ?Object=): string} template */
|
|
|
|
template: _.template([
|
|
|
|
'<option value="<%- value %>" ',
|
|
|
|
'<%= selected ? \'selected="selected"\' : "" %>>',
|
2018-01-12 07:29:51 +00:00
|
|
|
'<%- label %></option>',
|
|
|
|
].join(''),
|
|
|
|
null, {
|
|
|
|
variable: null,
|
2016-04-04 10:06:28 +00:00
|
|
|
}),
|
|
|
|
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
initialize: function() {
|
|
|
|
Backgrid.SelectCell.prototype.initialize.apply(this, arguments);
|
|
|
|
this.onSave = this.onSave.bind(this);
|
2016-04-15 05:31:11 +00:00
|
|
|
this.enterEditMode = this.enterEditMode.bind(this);
|
|
|
|
this.exitEditMode = this.exitEditMode.bind(this);
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
},
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
render: function() {
|
2016-01-07 03:05:08 +00:00
|
|
|
var col = _.defaults(this.column.toJSON(), this.defaults),
|
2018-01-12 07:29:51 +00:00
|
|
|
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')));
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
|
|
|
|
this.undelegateEvents();
|
|
|
|
|
|
|
|
if (this.$select) {
|
2018-01-12 07:29:51 +00:00
|
|
|
if (this.$select.data('select2')) {
|
2016-04-29 10:11:24 +00:00
|
|
|
this.$select.select2('destroy');
|
|
|
|
}
|
|
|
|
delete this.$select;
|
|
|
|
this.$select = null;
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
}
|
2016-01-07 03:05:08 +00:00
|
|
|
|
|
|
|
this.$el.empty();
|
|
|
|
|
2016-04-04 10:06:28 +00:00
|
|
|
if (!_.isArray(optionValues))
|
2018-01-12 07:29:51 +00:00
|
|
|
throw new TypeError('optionValues must be an array');
|
2016-01-07 03:05:08 +00:00
|
|
|
|
2016-01-07 08:00:41 +00:00
|
|
|
/*
|
|
|
|
* Add empty option as Select2 requires any empty '<option><option>' for
|
2016-01-07 03:05:08 +00:00
|
|
|
* some of its functionality to work.
|
|
|
|
*/
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
optionValues.unshift(this.defaults.opt);
|
2016-01-07 03:05:08 +00:00
|
|
|
|
|
|
|
var optionText = null,
|
2018-01-12 07:29:51 +00:00
|
|
|
optionValue = null,
|
|
|
|
self = this,
|
|
|
|
selectedValues = model.get(this.column.get('name')),
|
|
|
|
select2_opts = _.extend({
|
|
|
|
openOnEnter: false,
|
|
|
|
multiple: false,
|
|
|
|
}, self.defaults.select2,
|
|
|
|
(col.select2 || {})
|
|
|
|
),
|
|
|
|
selectTpl = _.template('<select <%=multiple ? "multiple" : "" %>></select>');
|
2016-01-07 03:05:08 +00:00
|
|
|
|
2017-07-18 14:13:16 +00:00
|
|
|
var $select = self.$select = $(selectTpl({
|
2018-01-12 07:29:51 +00:00
|
|
|
multiple: select2_opts.multiple,
|
2016-05-10 08:18:48 +00:00
|
|
|
})).appendTo(self.$el);
|
2016-01-07 03:05:08 +00:00
|
|
|
|
|
|
|
for (var i = 0; i < optionValues.length; i++) {
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
var opt = optionValues[i];
|
|
|
|
|
|
|
|
if (_.isArray(opt)) {
|
2016-04-15 05:31:11 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
optionText = opt[0];
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
optionValue = opt[1];
|
|
|
|
|
|
|
|
$select.append(
|
|
|
|
self.template({
|
2018-01-12 07:29:51 +00:00
|
|
|
label: optionText,
|
|
|
|
value: optionValue,
|
|
|
|
selected: (selectedValues == optionValue) ||
|
|
|
|
(select2_opts.multiple && _.indexOf(selectedValues, optionValue) > -1),
|
2016-01-07 03:05:08 +00:00
|
|
|
}));
|
2018-01-12 07:29:51 +00:00
|
|
|
} else {
|
2016-04-15 05:31:11 +00:00
|
|
|
opt = _.defaults({}, opt, {
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
selected: ((selectedValues == opt.value) ||
|
2018-01-12 07:29:51 +00:00
|
|
|
(select2_opts.multiple && _.indexOf(selectedValues, opt.value) > -1)),
|
|
|
|
}, self.defaults.opt);
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
$select.append(self.template(opt));
|
2016-01-07 03:05:08 +00:00
|
|
|
}
|
|
|
|
}
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
if (col && _.has(col.disabled)) {
|
|
|
|
var evalF = function() {
|
|
|
|
var args = [];
|
|
|
|
Array.prototype.push.apply(args, arguments);
|
|
|
|
var f = args.shift();
|
|
|
|
|
|
|
|
if (typeof(f) === 'function') {
|
|
|
|
return f.apply(self, args);
|
|
|
|
}
|
|
|
|
return f;
|
|
|
|
};
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
_.extend(select2_opts, {
|
2018-01-12 07:29:51 +00:00
|
|
|
disabled: evalF(col.disabled, col, model),
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
});
|
|
|
|
} else {
|
2018-01-12 07:29:51 +00:00
|
|
|
_.extend(select2_opts, {
|
|
|
|
disabled: !editable,
|
|
|
|
});
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
}
|
|
|
|
|
2016-01-07 03:05:08 +00:00
|
|
|
this.delegateEvents();
|
|
|
|
|
2017-01-17 10:25:26 +00:00
|
|
|
// If disabled then no need to show placeholder
|
2018-01-12 07:29:51 +00:00
|
|
|
if (!editable || col.mode === 'properties') {
|
2017-01-17 10:25:26 +00:00
|
|
|
select2_opts['placeholder'] = '';
|
|
|
|
}
|
|
|
|
|
2016-04-15 05:31:11 +00:00
|
|
|
// Initialize select2 control.
|
2016-08-19 15:35:42 +00:00
|
|
|
this.$sel = this.$select.select2(select2_opts);
|
|
|
|
|
|
|
|
// Select the highlighted item on Tab press.
|
|
|
|
if (this.$sel) {
|
2018-01-12 07:29:51 +00:00
|
|
|
this.$sel.data('select2').on('keypress', function(ev) {
|
2016-08-19 15:35:42 +00:00
|
|
|
var self = this;
|
2016-09-22 14:27:59 +00:00
|
|
|
|
|
|
|
// keycode 9 is for TAB key
|
|
|
|
if (ev.which === 9 && self.isOpen()) {
|
2016-08-19 15:35:42 +00:00
|
|
|
self.trigger('results:select', {});
|
|
|
|
ev.preventDefault();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2016-04-15 05:31:11 +00:00
|
|
|
|
2016-01-07 03:05:08 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2018-01-12 07:29:51 +00:00
|
|
|
Saves the value of the selected option to the model attribute.
|
|
|
|
*/
|
|
|
|
onSave: function() {
|
2016-01-07 03:05:08 +00:00
|
|
|
var model = this.model;
|
|
|
|
var column = this.column;
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
model.set(column.get('name'), this.$select.val());
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
remove: function() {
|
|
|
|
this.$select.off('change', this.onSave);
|
2016-04-29 10:11:24 +00:00
|
|
|
if (this.$select.data('select2')) {
|
|
|
|
this.$select.select2('destroy');
|
|
|
|
}
|
Improvised Select2Cell, and SwitchCell.
Removed the use of separate editor for both of these cell types. There
were two instance of select2 were getting created in the Select2Cell,
one in the Select2Cell itself, and another in Select2CellEditor. And,
loosing the focus mysteriously, and making the scrollbar in the property
dialog non-responsive.
Also, modified the NodeAjaxOptionsCell to use the above logic, and
removed its own version of render function to make it consitent across
the system.
This patch [changes sent by Murtuza] also includes improvisation in the
DeleteCell, and ObjectCell, which will honour now 'canRemoveRow', and
''canEditRow' respective properties of Column.
2016-04-12 11:20:43 +00:00
|
|
|
this.$el.empty();
|
|
|
|
Backgrid.SelectCell.prototype.remove.apply(this, arguments);
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2016-01-07 03:05:08 +00:00
|
|
|
});
|
2016-03-16 14:48:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
TextareaCellEditor the cell editor renders a textarea multi-line text input
|
|
|
|
box as its editor.
|
|
|
|
|
|
|
|
@class Backgrid.TextareaCellEditor
|
|
|
|
@extends Backgrid.InputCellEditor
|
|
|
|
*/
|
|
|
|
var TextareaCellEditor = Backgrid.TextareaCellEditor = Backgrid.InputCellEditor.extend({
|
|
|
|
/** @property */
|
2018-01-12 07:29:51 +00:00
|
|
|
tagName: 'textarea',
|
2016-03-16 14:48:09 +00:00
|
|
|
|
|
|
|
events: {
|
2018-01-12 07:29:51 +00:00
|
|
|
'blur': 'saveOrCancel',
|
|
|
|
'keydown': '',
|
|
|
|
},
|
2016-03-16 14:48:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
TextareaCell displays multiline HTML strings.
|
|
|
|
|
|
|
|
@class Backgrid.Extension.TextareaCell
|
|
|
|
@extends Backgrid.Cell
|
|
|
|
*/
|
2018-01-12 07:29:51 +00:00
|
|
|
Backgrid.Extension.TextareaCell = Backgrid.Cell.extend({
|
2016-03-16 14:48:09 +00:00
|
|
|
/** @property */
|
2018-01-12 07:29:51 +00:00
|
|
|
className: 'textarea-cell',
|
2016-03-16 14:48:09 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
editor: TextareaCellEditor,
|
2016-03-16 14:48:09 +00:00
|
|
|
});
|
|
|
|
|
2016-04-14 20:36:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom header icon cell to add the icon in table header.
|
2018-01-12 07:29:51 +00:00
|
|
|
*/
|
|
|
|
Backgrid.Extension.CustomHeaderIconCell = Backgrid.HeaderCell.extend({
|
|
|
|
/** @property */
|
|
|
|
className: 'header-icon-cell',
|
|
|
|
events: {
|
|
|
|
'click': 'addHeaderIcon',
|
|
|
|
},
|
|
|
|
addHeaderIcon: function(e) {
|
|
|
|
this.collection.add(
|
|
|
|
new(this.collection.model)
|
|
|
|
);
|
|
|
|
e.preventDefault();
|
|
|
|
},
|
|
|
|
render: function() {
|
|
|
|
this.$el.empty();
|
Improvement in the look and feel of the whole application
Changed the SCSS/CSS for the below third party libraries to adopt the
new look 'n' feel:
- wcDocker
- Alertify dialogs, and notifications
- AciTree
- Bootstrap Navbar
- Bootstrap Tabs
- Bootstrap Drop-Down menu
- Backgrid
- Select2
Adopated the new the look 'n' feel for the dialogs, wizard, properties,
tab panels, tabs, fieldset, subnode control, spinner control, HTML
table, and other form controls.
- Font is changed to Roboto
- Using SCSS variables to define the look 'n' feel
- Designer background images for the Login, and Forget password pages in
'web' mode
- Improved the look 'n' feel for the key selection in the preferences
dialog
- Table classes consistency changes across the application
- File Open and Save dialog list view changes
Author(s): Aditya Toshniwal & Khushboo Vashi
2018-12-21 11:44:55 +00:00
|
|
|
this.$el.html('<label><a><span style=\'font-weight:normal;\'>Array Values</a></span></label> <button class=\'btn-sm btn-secondary add\'>Add</button>');
|
2018-01-12 07:29:51 +00:00
|
|
|
this.delegateEvents();
|
|
|
|
return this;
|
|
|
|
},
|
2016-04-14 20:36:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var arrayCellModel = Backbone.Model.extend({
|
|
|
|
defaults: {
|
2018-11-27 11:18:47 +00:00
|
|
|
value: null,
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2016-04-14 20:36:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
Custom InputArrayCellEditor for editing user input array for debugger.
|
|
|
|
*/
|
|
|
|
var InputArrayCellEditor = Backgrid.Extension.InputArrayCellEditor =
|
|
|
|
Backgrid.CellEditor.extend({
|
2018-01-12 07:29:51 +00:00
|
|
|
tagName: 'div',
|
2016-04-14 20:36:04 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
events: {
|
|
|
|
'blur': 'lostFocus',
|
|
|
|
},
|
2016-04-14 20:36:04 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
render: function() {
|
2016-04-14 20:36:04 +00:00
|
|
|
var self = this,
|
2018-01-12 07:29:51 +00:00
|
|
|
arrayValuesCol = this.model.get(this.column.get('name')),
|
2018-11-27 11:18:47 +00:00
|
|
|
cell_type = 'string';
|
|
|
|
|
|
|
|
var data_type = this.model.get('type').replace('[]' ,'');
|
|
|
|
switch (data_type) {
|
|
|
|
case 'boolean':
|
|
|
|
cell_type = 'boolean';
|
|
|
|
break;
|
|
|
|
case 'integer':
|
|
|
|
case 'smallint':
|
|
|
|
case 'bigint':
|
|
|
|
case 'serial':
|
|
|
|
case 'smallserial':
|
|
|
|
case 'bigserial':
|
|
|
|
case 'oid':
|
|
|
|
case 'cid':
|
|
|
|
case 'xid':
|
|
|
|
case 'tid':
|
|
|
|
cell_type = 'integer';
|
|
|
|
break;
|
|
|
|
case 'real':
|
|
|
|
case 'numeric':
|
|
|
|
case 'double precision':
|
|
|
|
case 'decimal':
|
|
|
|
cell_type = 'number';
|
|
|
|
break;
|
|
|
|
case 'date':
|
|
|
|
cell_type = 'date';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
var gridCols = [{
|
2018-01-12 07:29:51 +00:00
|
|
|
name: 'value',
|
|
|
|
label: gettext('Array Values'),
|
|
|
|
type: 'text',
|
2018-11-27 11:18:47 +00:00
|
|
|
cell: cell_type,
|
2018-01-12 07:29:51 +00:00
|
|
|
headerCell: Backgrid.Extension.CustomHeaderIconCell,
|
|
|
|
cellHeaderClasses: 'width_percent_100',
|
|
|
|
}],
|
2018-10-10 11:43:26 +00:00
|
|
|
gridBody = $('<div class=\'pgadmin-control-group backgrid form-group col-12 object subnode\'></div>');
|
2016-04-14 20:36:04 +00:00
|
|
|
|
|
|
|
this.$el.attr('tabindex', '1');
|
|
|
|
|
|
|
|
gridCols.unshift({
|
2018-01-12 07:29:51 +00:00
|
|
|
name: 'pg-backform-delete',
|
|
|
|
label: '',
|
2016-04-14 20:36:04 +00:00
|
|
|
cell: Backgrid.Extension.DeleteCell,
|
|
|
|
//headerCell: Backgrid.Extension.CustomHeaderIconCell,
|
2018-01-12 07:29:51 +00:00
|
|
|
editable: false,
|
|
|
|
cell_priority: -1,
|
2016-04-14 20:36:04 +00:00
|
|
|
});
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
this.$el.empty();
|
|
|
|
var grid = self.grid = new Backgrid.Grid({
|
|
|
|
columns: gridCols,
|
|
|
|
collection: arrayValuesCol,
|
|
|
|
});
|
2016-04-14 20:36:04 +00:00
|
|
|
|
2018-11-27 11:18:47 +00:00
|
|
|
this.grid.listenTo(arrayValuesCol, 'backgrid:error',
|
|
|
|
(function(obj) {
|
|
|
|
return function(ev) {
|
|
|
|
obj.model.trigger('backgrid:error', obj.model, obj.column, new Backgrid.Command(ev));
|
|
|
|
};
|
|
|
|
})(this)
|
|
|
|
);
|
|
|
|
|
|
|
|
this.grid.listenTo(arrayValuesCol, 'backgrid:edited',
|
|
|
|
(function(obj) {
|
|
|
|
return function(ev) {
|
|
|
|
obj.model.trigger('backgrid:edited', obj.model, obj.column, new Backgrid.Command(ev));
|
|
|
|
};
|
|
|
|
})(this)
|
|
|
|
);
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
grid.render();
|
2016-04-14 20:36:04 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
gridBody.append(grid.$el);
|
2016-04-14 20:36:04 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
this.$el.html(gridBody);
|
2016-04-14 20:36:04 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
$(self.$el).pgMakeVisible('backform-tab');
|
|
|
|
self.delegateEvents();
|
2016-04-14 20:36:04 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
return this;
|
|
|
|
},
|
2016-04-14 20:36:04 +00:00
|
|
|
|
|
|
|
/*
|
2018-01-12 07:29:51 +00:00
|
|
|
* Call back function when the grid lost the focus
|
2016-04-14 20:36:04 +00:00
|
|
|
*/
|
2018-01-12 07:29:51 +00:00
|
|
|
lostFocus: function(ev) {
|
|
|
|
|
|
|
|
var self = this,
|
|
|
|
/*
|
|
|
|
* Function to determine whether one dom element is descendant of another
|
|
|
|
* dom element.
|
|
|
|
*/
|
|
|
|
isDescendant = function(parent, child) {
|
|
|
|
var node = child.parentNode;
|
|
|
|
while (node != null) {
|
|
|
|
if (node == parent) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
node = node.parentNode;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
/*
|
|
|
|
* Between leaving the old element focus and entering the new element focus the
|
|
|
|
* active element is the document/body itself so add timeout to get the proper
|
|
|
|
* focused active element.
|
|
|
|
*/
|
|
|
|
setTimeout(function() {
|
|
|
|
if (self.$el[0] != document.activeElement && !isDescendant(self.$el[0], document.activeElement)) {
|
|
|
|
var m = self.model,
|
|
|
|
column = self.column;
|
|
|
|
m.trigger('backgrid:edited', m, column, new Backgrid.Command(ev));
|
2016-04-14 20:36:04 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
setTimeout(function() {
|
|
|
|
if (self.grid) {
|
2016-04-14 20:36:04 +00:00
|
|
|
self.grid.remove();
|
|
|
|
self.grid = null;
|
2018-01-12 07:29:51 +00:00
|
|
|
}
|
|
|
|
}, 10);
|
|
|
|
}
|
|
|
|
}, 10);
|
|
|
|
return;
|
|
|
|
},
|
|
|
|
});
|
2016-04-14 20:36:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This will help us transform the user input string array values in proper format to be
|
|
|
|
* displayed in the cell.
|
|
|
|
*/
|
|
|
|
var InputStringArrayCellFormatter = Backgrid.Extension.InputStringArrayCellFormatter =
|
2018-01-12 07:29:51 +00:00
|
|
|
function() {};
|
2016-04-14 20:36:04 +00:00
|
|
|
_.extend(InputStringArrayCellFormatter.prototype, {
|
|
|
|
/**
|
|
|
|
* Takes a raw value from a model and returns an optionally formatted
|
|
|
|
* string for display.
|
|
|
|
*/
|
2018-01-12 07:29:51 +00:00
|
|
|
fromRaw: function(rawData) {
|
|
|
|
var values = [];
|
|
|
|
rawData.each(function(m) {
|
|
|
|
var val = m.get('value');
|
|
|
|
if (_.isUndefined(val)) {
|
|
|
|
values.push('null');
|
|
|
|
} else {
|
|
|
|
values.push(m.get('value'));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return values.toString();
|
2016-04-14 20:36:04 +00:00
|
|
|
},
|
2018-01-12 07:29:51 +00:00
|
|
|
toRaw: function(formattedData) {
|
2016-04-14 20:36:04 +00:00
|
|
|
return formattedData;
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2016-04-14 20:36:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This will help us transform the user input integer array values in proper format to be
|
|
|
|
* displayed in the cell.
|
|
|
|
*/
|
|
|
|
var InputIntegerArrayCellFormatter = Backgrid.Extension.InputIntegerArrayCellFormatter =
|
2018-01-12 07:29:51 +00:00
|
|
|
function() {};
|
2016-04-14 20:36:04 +00:00
|
|
|
_.extend(InputIntegerArrayCellFormatter.prototype, {
|
|
|
|
/**
|
|
|
|
* Takes a raw value from a model and returns an optionally formatted
|
|
|
|
* string for display.
|
|
|
|
*/
|
2018-01-12 07:29:51 +00:00
|
|
|
fromRaw: function(rawData) {
|
|
|
|
var values = [];
|
|
|
|
rawData.each(function(m) {
|
|
|
|
var val = m.get('value');
|
2018-11-27 11:18:47 +00:00
|
|
|
if (_.isUndefined(val) || _.isNull(val)) {
|
|
|
|
values.push('NULL');
|
2018-01-12 07:29:51 +00:00
|
|
|
} else {
|
|
|
|
values.push(m.get('value'));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return values.toString();
|
2016-04-14 20:36:04 +00:00
|
|
|
},
|
2018-01-12 07:29:51 +00:00
|
|
|
toRaw: function(formattedData) {
|
|
|
|
formattedData.each(function(m) {
|
|
|
|
m.set('value', parseInt(m.get('value')), {
|
|
|
|
silent: true,
|
2016-04-14 20:36:04 +00:00
|
|
|
});
|
2018-01-12 07:29:51 +00:00
|
|
|
});
|
2016-04-14 20:36:04 +00:00
|
|
|
|
|
|
|
return formattedData;
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2016-04-14 20:36:04 +00:00
|
|
|
});
|
|
|
|
|
2018-11-27 11:18:47 +00:00
|
|
|
/*
|
|
|
|
* This will help us transform the user input numeric array values in proper format to be
|
|
|
|
* displayed in the cell.
|
|
|
|
*/
|
|
|
|
var InputNumberArrayCellFormatter= Backgrid.Extension.InputNumberArrayCellFormatter =
|
|
|
|
function() {};
|
|
|
|
_.extend(InputNumberArrayCellFormatter.prototype, {
|
|
|
|
/**
|
|
|
|
* Takes a raw value from a model and returns an optionally formatted
|
|
|
|
* string for display.
|
|
|
|
*/
|
|
|
|
fromRaw: function(rawData) {
|
|
|
|
var values = [];
|
|
|
|
rawData.each(function(m) {
|
|
|
|
var val = m.get('value');
|
|
|
|
if (_.isUndefined(val) || _.isNull(val)) {
|
|
|
|
values.push('NULL');
|
|
|
|
} else {
|
|
|
|
values.push(m.get('value'));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return values.toString();
|
|
|
|
},
|
|
|
|
toRaw: function(formattedData) {
|
|
|
|
formattedData.each(function(m) {
|
|
|
|
m.set('value', parseFloat(m.get('value')), {
|
|
|
|
silent: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return formattedData;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2016-04-14 20:36:04 +00:00
|
|
|
/*
|
|
|
|
* InputStringArrayCell for rendering and taking input for string array type in debugger
|
|
|
|
*/
|
2018-01-12 07:29:51 +00:00
|
|
|
Backgrid.Extension.InputStringArrayCell = Backgrid.Cell.extend({
|
|
|
|
className: 'width_percent_25',
|
2016-04-14 20:36:04 +00:00
|
|
|
formatter: InputStringArrayCellFormatter,
|
|
|
|
editor: InputArrayCellEditor,
|
|
|
|
|
|
|
|
initialize: function() {
|
|
|
|
Backgrid.Cell.prototype.initialize.apply(this, arguments);
|
2018-01-12 07:29:51 +00:00
|
|
|
// set value to empty array.
|
|
|
|
var m = arguments[0].model;
|
|
|
|
if (_.isUndefined(this.collection)) {
|
|
|
|
this.collection = new(Backbone.Collection.extend({
|
|
|
|
model: arrayCellModel,
|
|
|
|
}))(m.get('value'));
|
|
|
|
}
|
2016-04-14 20:36:04 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
this.model.set(this.column.get('name'), this.collection);
|
|
|
|
this.listenTo(this.collection, 'remove', this.render);
|
2016-04-14 20:36:04 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
|
|
|
* InputIntegerArrayCell for rendering and taking input for integer array type in debugger
|
|
|
|
*/
|
2018-11-27 11:18:47 +00:00
|
|
|
Backgrid.Extension.InputIntegerArrayCell = Backgrid.IntegerCell.extend({
|
2018-01-12 07:29:51 +00:00
|
|
|
className: 'width_percent_25',
|
2016-04-14 20:36:04 +00:00
|
|
|
formatter: InputIntegerArrayCellFormatter,
|
|
|
|
editor: InputArrayCellEditor,
|
|
|
|
|
|
|
|
initialize: function() {
|
2018-11-27 11:18:47 +00:00
|
|
|
Backgrid.IntegerCell.prototype.initialize.apply(this, arguments);
|
2018-01-12 07:29:51 +00:00
|
|
|
// set value to empty array.
|
|
|
|
var m = arguments[0].model;
|
2018-11-27 11:18:47 +00:00
|
|
|
_.each(m.get('value'), function(arrVal) {
|
|
|
|
if (arrVal.value === 'NULL') {
|
|
|
|
arrVal.value = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
if (_.isUndefined(this.collection)) {
|
|
|
|
this.collection = new(Backbone.Collection.extend({
|
|
|
|
model: arrayCellModel,
|
|
|
|
}))(m.get('value'));
|
|
|
|
}
|
2016-04-14 20:36:04 +00:00
|
|
|
|
2018-11-27 11:18:47 +00:00
|
|
|
this.model.set(this.column.get('name'), this.collection);
|
|
|
|
this.listenTo(this.collection, 'remove', this.render);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
|
|
|
* InputNumberArrayCell for rendering and taking input for numeric array type in debugger
|
|
|
|
*/
|
|
|
|
Backgrid.Extension.InputNumberArrayCell = Backgrid.NumberCell.extend({
|
|
|
|
className: 'width_percent_25',
|
|
|
|
formatter: InputNumberArrayCellFormatter,
|
|
|
|
editor: InputArrayCellEditor,
|
|
|
|
|
|
|
|
initialize: function() {
|
|
|
|
Backgrid.NumberCell.prototype.initialize.apply(this, arguments);
|
|
|
|
// set value to empty array.
|
|
|
|
var m = arguments[0].model;
|
|
|
|
_.each(m.get('value'), function(arrVal) {
|
|
|
|
if (arrVal.value === 'NULL') {
|
|
|
|
arrVal.value = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (_.isUndefined(this.collection)) {
|
|
|
|
this.collection = new(Backbone.Collection.extend({
|
|
|
|
model: arrayCellModel,
|
|
|
|
}))(m.get('value'));
|
|
|
|
}
|
2016-04-14 20:36:04 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
this.model.set(this.column.get('name'), this.collection);
|
2018-11-27 11:18:47 +00:00
|
|
|
this.listenTo(this.collection, 'remove', this.render);
|
|
|
|
},
|
|
|
|
});
|
2016-04-14 20:36:04 +00:00
|
|
|
|
2018-11-27 11:18:47 +00:00
|
|
|
/*
|
|
|
|
* InputBooleanArrayCell for rendering and taking input for boolean array type in debugger
|
|
|
|
*/
|
|
|
|
Backgrid.Extension.InputBooleanArrayCell = Backgrid.BooleanCell.extend({
|
|
|
|
className: 'width_percent_25',
|
|
|
|
editor: InputArrayCellEditor,
|
|
|
|
|
|
|
|
initialize: function() {
|
|
|
|
Backgrid.BooleanCell.prototype.initialize.apply(this, arguments);
|
|
|
|
// set value to empty array.
|
|
|
|
var m = arguments[0].model;
|
|
|
|
if (_.isUndefined(this.collection)) {
|
|
|
|
this.collection = new(Backbone.Collection.extend({
|
|
|
|
model: arrayCellModel,
|
|
|
|
}))(m.get('value'));
|
|
|
|
}
|
|
|
|
|
|
|
|
this.model.set(this.column.get('name'), this.collection);
|
2018-01-12 07:29:51 +00:00
|
|
|
this.listenTo(this.collection, 'remove', this.render);
|
2016-04-14 20:36:04 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2016-05-10 07:10:39 +00:00
|
|
|
/**
|
|
|
|
* DependentCell functions can be used with the different cell type in order
|
|
|
|
* to setup the callback for the depedent attribute change in the model.
|
|
|
|
*
|
|
|
|
* Please implement the 'dependentChanged' as the callback in the used cell.
|
|
|
|
*
|
|
|
|
* @class Backgrid.Extension.DependentCell
|
|
|
|
**/
|
|
|
|
var DependentCell = Backgrid.Extension.DependentCell = function() {};
|
|
|
|
|
|
|
|
_.extend(
|
|
|
|
DependentCell.prototype, {
|
2018-01-12 07:29:51 +00:00
|
|
|
initialize: function() {
|
2016-05-10 07:10:39 +00:00
|
|
|
// Listen to the dependent fields in the model for any change
|
|
|
|
var deps = this.column.get('deps');
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
if (deps && _.isArray(deps)) {
|
|
|
|
_.each(deps, function(d) {
|
2017-07-18 14:13:16 +00:00
|
|
|
var attrArr = d.split('.'),
|
2018-01-12 07:29:51 +00:00
|
|
|
name = attrArr.shift();
|
|
|
|
self.listenTo(self.model, 'change:' + name, self.dependentChanged);
|
2016-05-10 07:10:39 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
remove: function() {
|
|
|
|
// Remove the events for the dependent fields in the model
|
|
|
|
var self = this,
|
|
|
|
deps = self.column.get('deps');
|
|
|
|
|
|
|
|
if (deps && _.isArray(deps)) {
|
|
|
|
_.each(deps, function(d) {
|
2017-07-18 14:13:16 +00:00
|
|
|
var attrArr = d.split('.'),
|
|
|
|
name = attrArr.shift();
|
2016-05-10 07:10:39 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
self.stopListening(self.model, 'change:' + name, self.dependentChanged);
|
2016-05-10 07:10:39 +00:00
|
|
|
});
|
|
|
|
}
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2016-05-10 07:10:39 +00:00
|
|
|
});
|
|
|
|
|
2016-06-03 10:43:42 +00:00
|
|
|
/**
|
|
|
|
Formatter for PasswordCell.
|
|
|
|
|
|
|
|
@class Backgrid.PasswordFormatter
|
|
|
|
@extends Backgrid.CellFormatter
|
|
|
|
@constructor
|
|
|
|
*/
|
2018-01-12 07:29:51 +00:00
|
|
|
var PasswordFormatter = Backgrid.PasswordFormatter = function() {};
|
2016-06-03 10:43:42 +00:00
|
|
|
PasswordFormatter.prototype = new Backgrid.CellFormatter();
|
|
|
|
_.extend(PasswordFormatter.prototype, {
|
2018-01-12 07:29:51 +00:00
|
|
|
fromRaw: function(rawValue) {
|
2016-06-03 10:43:42 +00:00
|
|
|
|
|
|
|
if (_.isUndefined(rawValue) || _.isNull(rawValue)) return '';
|
|
|
|
|
|
|
|
var pass = '';
|
2018-01-12 07:29:51 +00:00
|
|
|
for (var i = 0; i < rawValue.length; i++) {
|
2016-06-03 10:43:42 +00:00
|
|
|
pass += '*';
|
|
|
|
}
|
|
|
|
return pass;
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2016-06-03 10:43:42 +00:00
|
|
|
});
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
Backgrid.Extension.PasswordCell = Backgrid.StringCell.extend({
|
2016-06-03 10:43:42 +00:00
|
|
|
|
|
|
|
formatter: PasswordFormatter,
|
|
|
|
|
|
|
|
editor: Backgrid.InputCellEditor.extend({
|
|
|
|
attributes: {
|
2018-01-12 07:29:51 +00:00
|
|
|
type: 'password',
|
2016-06-03 10:43:42 +00:00
|
|
|
},
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
render: function() {
|
2016-06-03 10:43:42 +00:00
|
|
|
var model = this.model;
|
2018-01-12 07:29:51 +00:00
|
|
|
this.$el.val(model.get(this.column.get('name')));
|
2016-06-03 10:43:42 +00:00
|
|
|
return this;
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
|
|
|
}),
|
2016-06-03 10:43:42 +00:00
|
|
|
});
|
|
|
|
|
2016-06-23 11:46:48 +00:00
|
|
|
/*
|
|
|
|
* Override NumberFormatter to support NaN, Infinity values.
|
|
|
|
* On client side, JSON do not directly support NaN & Infinity,
|
|
|
|
* we explicitly converted it into string format at server side
|
|
|
|
* and we need to parse it again in float at client side.
|
|
|
|
*/
|
|
|
|
_.extend(Backgrid.NumberFormatter.prototype, {
|
2018-01-12 07:29:51 +00:00
|
|
|
fromRaw: function(number) {
|
2016-06-23 11:46:48 +00:00
|
|
|
if (_.isNull(number) || _.isUndefined(number)) return '';
|
|
|
|
|
|
|
|
number = parseFloat(number).toFixed(~~this.decimals);
|
|
|
|
|
|
|
|
var parts = number.split('.');
|
|
|
|
var integerPart = parts[0];
|
|
|
|
var decimalPart = parts[1] ? (this.decimalSeparator || '.') + parts[1] : '';
|
|
|
|
|
|
|
|
return integerPart.replace(this.HUMANIZED_NUM_RE, '$1' + this.orderSeparator) + decimalPart;
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2016-06-23 11:46:48 +00:00
|
|
|
});
|
|
|
|
|
2016-07-04 09:05:59 +00:00
|
|
|
/*
|
|
|
|
* JSONBCell Formatter.
|
|
|
|
*/
|
|
|
|
var JSONBCellFormatter = Backgrid.Extension.JSONBCellFormatter =
|
2018-01-12 07:29:51 +00:00
|
|
|
function() {};
|
2016-07-04 09:05:59 +00:00
|
|
|
_.extend(JSONBCellFormatter.prototype, {
|
2018-01-12 07:29:51 +00:00
|
|
|
fromRaw: function(rawData) {
|
|
|
|
// json data
|
|
|
|
if (_.isArray(rawData)) {
|
|
|
|
var converted_data = '';
|
|
|
|
converted_data = _.map(rawData, function(data) {
|
|
|
|
return JSON.stringify(JSON.stringify(data));
|
|
|
|
});
|
|
|
|
return '{' + converted_data.join() + '}';
|
|
|
|
} else if (_.isObject(rawData)) {
|
|
|
|
return JSON.stringify(rawData);
|
|
|
|
} else {
|
|
|
|
return rawData;
|
|
|
|
}
|
2016-07-04 09:05:59 +00:00
|
|
|
},
|
2018-01-12 07:29:51 +00:00
|
|
|
toRaw: function(formattedData) {
|
2016-07-04 09:05:59 +00:00
|
|
|
return formattedData;
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2016-07-04 09:05:59 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
|
|
|
* JSONBCell for backgrid.
|
|
|
|
*/
|
2018-01-12 07:29:51 +00:00
|
|
|
Backgrid.Extension.JSONBCell =
|
|
|
|
Backgrid.StringCell.extend({
|
|
|
|
className: 'jsonb-cell',
|
|
|
|
formatter: JSONBCellFormatter,
|
|
|
|
});
|
2016-07-04 09:05:59 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
Backgrid.Extension.DatepickerCell = Backgrid.Cell.extend({
|
|
|
|
editor: DatepickerCellEditor,
|
2016-09-22 14:27:59 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var DatepickerCellEditor = Backgrid.InputCellEditor.extend({
|
2018-01-12 07:29:51 +00:00
|
|
|
events: {},
|
|
|
|
initialize: function() {
|
2016-09-22 14:27:59 +00:00
|
|
|
Backgrid.InputCellEditor.prototype.initialize.apply(this, arguments);
|
|
|
|
var input = this;
|
|
|
|
$(this.el).prop('readonly', true);
|
|
|
|
$(this.el).datepicker({
|
2018-01-12 07:29:51 +00:00
|
|
|
onClose: function(newValue) {
|
2016-09-22 14:27:59 +00:00
|
|
|
var command = new Backgrid.Command({});
|
2018-01-12 07:29:51 +00:00
|
|
|
input.model.set(input.column.get('name'), newValue);
|
2016-09-22 14:27:59 +00:00
|
|
|
input.model.trigger(
|
2018-01-12 07:29:51 +00:00
|
|
|
'backgrid:edited', input.model, input.column, command
|
2016-09-22 14:27:59 +00:00
|
|
|
);
|
|
|
|
command = input = null;
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2016-09-22 14:27:59 +00:00
|
|
|
});
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2016-09-22 14:27:59 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Reference:
|
|
|
|
// https://github.com/wyuenho/backgrid-moment-cell/blob/master/backgrid-moment-cell.js
|
|
|
|
/**
|
|
|
|
MomentFormatter converts bi-directionally any datetime values in any format
|
|
|
|
supported by [moment()](http://momentjs.com/docs/#/parsing/) to any
|
|
|
|
datetime format
|
|
|
|
[moment.fn.format()](http://momentjs.com/docs/#/displaying/format/)
|
|
|
|
supports.
|
|
|
|
@class Backgrid.Extension.MomentFormatter
|
|
|
|
@extends Backgrid.CellFormatter
|
|
|
|
@constructor
|
|
|
|
*/
|
2018-01-12 07:29:51 +00:00
|
|
|
var MomentFormatter = Backgrid.Extension.MomentFormatter = function(options) {
|
2016-09-22 14:27:59 +00:00
|
|
|
_.extend(this, this.defaults, options);
|
|
|
|
};
|
|
|
|
|
|
|
|
MomentFormatter.prototype = new Backgrid.CellFormatter;
|
|
|
|
_.extend(MomentFormatter.prototype, {
|
|
|
|
/**
|
|
|
|
@cfg {Object} options
|
|
|
|
@cfg {boolean} [options.modelInUnixOffset=false] Whether the model values
|
|
|
|
should be read/written as the number of milliseconds since UNIX Epoch.
|
|
|
|
@cfg {boolean} [options.modelInUnixTimestamp=false] Whether the model
|
|
|
|
values should be read/written as the number of seconds since UNIX Epoch.
|
|
|
|
@cfg {boolean} [options.modelInUTC=true] Whether the model values should
|
|
|
|
be read/written in UTC mode or local mode.
|
|
|
|
@cfg {string} [options.modelLang=moment.locale() moment>=2.8.0 |
|
|
|
|
moment.lang() moment<2.8.0] The locale the model values should be
|
|
|
|
read/written in.
|
|
|
|
@cfg {string} [options.modelFormat=moment.defaultFormat] The format this
|
|
|
|
moment formatter should use to read/write model values. Only meaningful if
|
|
|
|
the values are strings.
|
|
|
|
@cfg {boolean} [options.displayInUnixOffset=false] Whether the display
|
|
|
|
values should be read/written as the number of milliseconds since UNIX
|
|
|
|
Epoch.
|
|
|
|
@cfg {boolean} [options.displayInUnixTimestamp=false] Whether the display
|
|
|
|
values should be read/written as the number of seconds since UNIX Epoch.
|
|
|
|
@cfg {boolean} [options.displayInUTC=true] Whether the display values
|
|
|
|
should be read/written in UTC mode or local mode.
|
|
|
|
@cfg {string} [options.displayLang=moment.locale() moment>=2.8.0 |
|
|
|
|
moment.lang() moment<2.8.0] The locale the display values should be
|
|
|
|
read/written in.
|
|
|
|
@cfg {string} [options.displayFormat=moment.defaultFormat] The format
|
|
|
|
this moment formatter should use to read/write dislay values.
|
|
|
|
*/
|
|
|
|
defaults: {
|
|
|
|
modelInUnixOffset: false,
|
|
|
|
modelInUnixTimestamp: false,
|
|
|
|
modelInUTC: true,
|
|
|
|
modelLang: moment.locale(),
|
|
|
|
modelFormat: moment.defaultFormat,
|
|
|
|
displayInUnixOffset: false,
|
|
|
|
displayInUnixTimestamp: false,
|
|
|
|
displayInUTC: true,
|
|
|
|
displayLang: moment.locale(),
|
|
|
|
displayFormat: moment.defaultFormat,
|
2018-01-12 07:29:51 +00:00
|
|
|
allowEmpty: false,
|
2016-09-22 14:27:59 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
Converts datetime values from the model for display.
|
|
|
|
@member Backgrid.Extension.MomentFormatter
|
|
|
|
@param {*} rawData
|
|
|
|
@return {string}
|
|
|
|
*/
|
2018-01-12 07:29:51 +00:00
|
|
|
fromRaw: function(rawData) {
|
2016-09-22 14:27:59 +00:00
|
|
|
if (rawData == null) return '';
|
|
|
|
|
|
|
|
var m = this.modelInUnixOffset ? moment(rawData) :
|
|
|
|
this.modelInUnixTimestamp ? moment.unix(rawData) :
|
|
|
|
this.modelInUTC ?
|
|
|
|
moment.utc(rawData, this.modelFormat, this.modelLang) :
|
|
|
|
moment(rawData, this.modelFormat, this.modelLang);
|
|
|
|
|
|
|
|
if (this.displayInUnixOffset) return +m;
|
|
|
|
|
|
|
|
if (this.displayInUnixTimestamp) return m.unix();
|
|
|
|
|
|
|
|
if (this.displayLang) m.locale(this.displayLang);
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
if (this.displayInUTC) m.utc();
|
|
|
|
else m.local();
|
2016-09-22 14:27:59 +00:00
|
|
|
|
|
|
|
if (this.displayFormat != moment.defaultFormat) {
|
|
|
|
return m.format(this.displayFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
return m.format();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
Converts datetime values from user input to model values.
|
|
|
|
@member Backgrid.Extension.MomentFormatter
|
|
|
|
@param {string} formattedData
|
|
|
|
@return {string}
|
|
|
|
*/
|
2018-01-12 07:29:51 +00:00
|
|
|
toRaw: function(formattedData) {
|
2016-09-22 14:27:59 +00:00
|
|
|
|
|
|
|
var m = this.displayInUnixOffset ? moment(+formattedData) :
|
|
|
|
this.displayInUnixTimestamp ? moment.unix(+formattedData) :
|
|
|
|
this.displayInUTC ?
|
|
|
|
moment.utc(formattedData, this.displayFormat, this.displayLang) :
|
|
|
|
moment(formattedData, this.displayFormat, this.displayLang);
|
|
|
|
|
|
|
|
if (!m || !m.isValid()) return (this.allowEmpty && formattedData === '') ? null : undefined;
|
|
|
|
|
|
|
|
if (this.modelInUnixOffset) return +m;
|
|
|
|
|
|
|
|
if (this.modelInUnixTimestamp) return m.unix();
|
|
|
|
|
|
|
|
if (this.modelLang) m.locale(this.modelLang);
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
if (this.modelInUTC) m.utc();
|
|
|
|
else m.local();
|
2016-09-22 14:27:59 +00:00
|
|
|
|
|
|
|
if (this.modelFormat != moment.defaultFormat) {
|
|
|
|
return m.format(this.modelFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
return m.format();
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2016-09-22 14:27:59 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var MomentCell = Backgrid.Extension.MomentCell = Backgrid.Cell.extend({
|
|
|
|
|
|
|
|
editor: Backgrid.InputCellEditor,
|
|
|
|
|
|
|
|
/** @property */
|
2018-01-12 07:29:51 +00:00
|
|
|
className: 'datetime-cell',
|
2016-09-22 14:27:59 +00:00
|
|
|
|
|
|
|
/** @property {Backgrid.CellFormatter} [formatter=Backgrid.Extension.MomentFormatter] */
|
|
|
|
formatter: MomentFormatter,
|
|
|
|
|
|
|
|
/**
|
|
|
|
Initializer. Accept Backgrid.Extension.MomentFormatter.options and
|
|
|
|
Backgrid.Cell.initialize required parameters.
|
|
|
|
*/
|
2018-01-12 07:29:51 +00:00
|
|
|
initialize: function(options) {
|
2016-09-22 14:27:59 +00:00
|
|
|
|
|
|
|
MomentCell.__super__.initialize.apply(this, arguments);
|
|
|
|
|
|
|
|
var formatterDefaults = MomentFormatter.prototype.defaults;
|
|
|
|
var formatterDefaultKeys = _.keys(formatterDefaults);
|
|
|
|
var classAttrs = _.pick(this, formatterDefaultKeys);
|
|
|
|
var formatterOptions = _.pick(options, formatterDefaultKeys);
|
|
|
|
var columnsAttrs = _.pick(this.column.toJSON(), formatterDefaultKeys);
|
|
|
|
|
|
|
|
// Priority of the options for the formatter, from highest to lowerest
|
|
|
|
// 1. MomentCell instance options
|
|
|
|
// 2. MomentCell class attributes
|
|
|
|
// 3. MomentFormatter defaults
|
|
|
|
|
|
|
|
// this.formatter will have been instantiated now
|
|
|
|
_.extend(this.formatter, formatterDefaults, classAttrs, formatterOptions, columnsAttrs);
|
|
|
|
|
|
|
|
this.editor = this.editor.extend({
|
|
|
|
attributes: _.extend({}, this.editor.prototype.attributes || this.editor.attributes || {}, {
|
2018-01-12 07:29:51 +00:00
|
|
|
placeholder: this.formatter.displayFormat,
|
2016-09-22 14:27:59 +00:00
|
|
|
}),
|
2018-01-12 07:29:51 +00:00
|
|
|
options: this.column.get('options'),
|
2016-09-22 14:27:59 +00:00
|
|
|
});
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2016-09-22 14:27:59 +00:00
|
|
|
});
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
Backgrid.Extension.DatetimePickerEditor = Backgrid.InputCellEditor.extend({
|
2016-09-26 09:04:49 +00:00
|
|
|
postRender: function() {
|
|
|
|
var self = this,
|
2018-01-12 07:29:51 +00:00
|
|
|
evalF = function() {
|
|
|
|
var args = [];
|
|
|
|
Array.prototype.push.apply(args, arguments);
|
|
|
|
var f = args.shift();
|
2016-09-26 09:04:49 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
if (typeof(f) === 'function') {
|
|
|
|
return f.apply(self, args);
|
|
|
|
}
|
|
|
|
return f;
|
|
|
|
},
|
|
|
|
options = _.extend({
|
|
|
|
format: 'YYYY-MM-DD HH:mm:ss Z',
|
2018-10-11 12:23:59 +00:00
|
|
|
icons: {
|
|
|
|
clear: 'fa fa-trash',
|
|
|
|
},
|
|
|
|
buttons: {
|
|
|
|
showToday: true,
|
|
|
|
},
|
2018-01-12 07:29:51 +00:00
|
|
|
toolbarPlacement: 'top',
|
2018-10-11 12:23:59 +00:00
|
|
|
keepOpen: false,
|
2018-01-12 07:29:51 +00:00
|
|
|
}, evalF(this.column.get('options')), {
|
|
|
|
keyBinds: {
|
|
|
|
'shift tab': function(widget) {
|
|
|
|
if (widget) {
|
|
|
|
// blur the input
|
|
|
|
setTimeout(
|
|
|
|
function() {
|
|
|
|
self.closeIt({
|
|
|
|
keyCode: 9,
|
|
|
|
shiftKey: true,
|
|
|
|
});
|
|
|
|
}, 10
|
|
|
|
);
|
2016-09-26 09:04:49 +00:00
|
|
|
}
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
|
|
|
tab: function(widget) {
|
|
|
|
if (widget) {
|
|
|
|
// blur the input
|
|
|
|
setTimeout(
|
|
|
|
function() {
|
|
|
|
self.closeIt({
|
|
|
|
keyCode: 9,
|
|
|
|
});
|
|
|
|
}, 10
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2016-09-26 09:04:49 +00:00
|
|
|
this.$el.datetimepicker(options);
|
|
|
|
this.$el.datetimepicker('show');
|
|
|
|
this.picker = this.$el.data('DateTimePicker');
|
|
|
|
},
|
|
|
|
events: {
|
2018-10-12 09:32:38 +00:00
|
|
|
'hide.datetimepicker': 'closeIt',
|
|
|
|
'focusout':'closeIt',
|
2016-09-26 09:04:49 +00:00
|
|
|
},
|
|
|
|
closeIt: function(ev) {
|
|
|
|
var formatter = this.formatter,
|
2018-01-12 07:29:51 +00:00
|
|
|
model = this.model,
|
|
|
|
column = this.column,
|
|
|
|
val = this.$el.val(),
|
|
|
|
newValue = formatter.toRaw(val, model);
|
2016-09-26 09:04:49 +00:00
|
|
|
|
|
|
|
if (this.is_closing)
|
|
|
|
return;
|
|
|
|
this.is_closing = true;
|
|
|
|
this.$el.datetimepicker('destroy');
|
|
|
|
this.is_closing = false;
|
|
|
|
|
|
|
|
var command = new Backgrid.Command(ev);
|
|
|
|
|
|
|
|
if (_.isUndefined(newValue)) {
|
2018-01-12 07:29:51 +00:00
|
|
|
model.trigger('backgrid:error', model, column, val);
|
2016-09-26 09:04:49 +00:00
|
|
|
} else {
|
2018-01-12 07:29:51 +00:00
|
|
|
model.set(column.get('name'), newValue);
|
|
|
|
model.trigger('backgrid:edited', model, column, command);
|
2016-09-26 09:04:49 +00:00
|
|
|
}
|
2018-01-12 07:29:51 +00:00
|
|
|
},
|
2016-09-26 09:04:49 +00:00
|
|
|
});
|
|
|
|
|
2016-09-22 14:27:59 +00:00
|
|
|
_.extend(MomentCell.prototype, MomentFormatter.prototype.defaults);
|
|
|
|
|
2017-06-29 13:31:29 +00:00
|
|
|
|
|
|
|
Backgrid.Extension.StringDepCell = Backgrid.StringCell.extend({
|
2018-01-12 07:29:51 +00:00
|
|
|
initialize: function() {
|
|
|
|
Backgrid.StringCell.prototype.initialize.apply(this, arguments);
|
|
|
|
Backgrid.Extension.DependentCell.prototype.initialize.apply(this, arguments);
|
|
|
|
},
|
|
|
|
dependentChanged: function() {
|
|
|
|
this.$el.empty();
|
2017-06-29 13:31:29 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
var self = this,
|
|
|
|
model = this.model,
|
|
|
|
column = this.column,
|
|
|
|
editable = this.column.get('editable');
|
2017-06-29 13:31:29 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
this.render();
|
2017-06-29 13:31:29 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
var is_editable = _.isFunction(editable) ? !!editable.apply(column, [model]) : !!editable;
|
|
|
|
setTimeout(function() {
|
|
|
|
self.$el.removeClass('editor');
|
|
|
|
if (is_editable) {
|
|
|
|
self.$el.addClass('editable');
|
|
|
|
} else {
|
|
|
|
self.$el.removeClass('editable');
|
|
|
|
}
|
|
|
|
}, 10);
|
2017-06-29 13:31:29 +00:00
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
this.delegateEvents();
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
remove: Backgrid.Extension.DependentCell.prototype.remove,
|
|
|
|
});
|
2017-06-29 13:31:29 +00:00
|
|
|
|
|
|
|
Backgrid.Extension.Select2DepCell = Backgrid.Extension.Select2Cell.extend({
|
|
|
|
initialize: function() {
|
|
|
|
Backgrid.Extension.Select2Cell.prototype.initialize.apply(this, arguments);
|
|
|
|
Backgrid.Extension.DependentCell.prototype.initialize.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
dependentChanged: function() {
|
|
|
|
var model = this.model,
|
|
|
|
column = this.column,
|
|
|
|
editable = this.column.get('editable');
|
2017-06-29 13:31:29 +00:00
|
|
|
|
|
|
|
this.render();
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
if (
|
|
|
|
_.isFunction(editable) ? !!editable.apply(column, [model]) :
|
|
|
|
!!editable
|
|
|
|
) {
|
|
|
|
this.$el.addClass('editable');
|
|
|
|
} else {
|
|
|
|
this.$el.removeClass('editable');
|
|
|
|
}
|
2017-06-29 13:31:29 +00:00
|
|
|
|
|
|
|
this.delegateEvents();
|
|
|
|
return this;
|
|
|
|
},
|
2018-01-12 07:29:51 +00:00
|
|
|
remove: Backgrid.Extension.DependentCell.prototype.remove,
|
2017-06-29 13:31:29 +00:00
|
|
|
});
|
|
|
|
|
Improvement in the look and feel of the whole application
Changed the SCSS/CSS for the below third party libraries to adopt the
new look 'n' feel:
- wcDocker
- Alertify dialogs, and notifications
- AciTree
- Bootstrap Navbar
- Bootstrap Tabs
- Bootstrap Drop-Down menu
- Backgrid
- Select2
Adopated the new the look 'n' feel for the dialogs, wizard, properties,
tab panels, tabs, fieldset, subnode control, spinner control, HTML
table, and other form controls.
- Font is changed to Roboto
- Using SCSS variables to define the look 'n' feel
- Designer background images for the Login, and Forget password pages in
'web' mode
- Improved the look 'n' feel for the key selection in the preferences
dialog
- Table classes consistency changes across the application
- File Open and Save dialog list view changes
Author(s): Aditya Toshniwal & Khushboo Vashi
2018-12-21 11:44:55 +00:00
|
|
|
/* Custom search box was added to give user defined text box for search
|
|
|
|
* instead of backgrid rendered textbox
|
|
|
|
*/
|
|
|
|
Backgrid.Extension.ClientSideFilter = Backgrid.Extension.ClientSideFilter.extend({
|
|
|
|
$customSearchBox: null,
|
|
|
|
|
|
|
|
searchBox: function() {
|
|
|
|
if(this.$customSearchBox) {
|
|
|
|
return this.$customSearchBox;
|
|
|
|
} else {
|
|
|
|
return this.$el.find('input[type=search]');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setCustomSearchBox: function($el) {
|
|
|
|
this.$customSearchBox = $el;
|
|
|
|
this.$customSearchBox.attr('type','search');
|
|
|
|
this.$customSearchBox.on('keydown', this.search.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
unsetCustomSearchBox: function() {
|
|
|
|
this.$customSearchBox.off('keydown', this.search.bind(this));
|
|
|
|
this.$customSearchBox = null;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2018-11-27 11:18:47 +00:00
|
|
|
Backgrid.BooleanCellFormatter = _.extend(Backgrid.CellFormatter.prototype, {
|
|
|
|
fromRaw: function (rawValue) {
|
|
|
|
if (_.isUndefined(rawValue) || _.isNull(rawValue)) {
|
|
|
|
return false;
|
|
|
|
} else if (rawValue === '1' || rawValue === 'True') {
|
|
|
|
return true;
|
|
|
|
} else if (rawValue === '0' || rawValue === 'False') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return rawValue;
|
|
|
|
},
|
|
|
|
toRaw: function (formattedData) {
|
|
|
|
return formattedData;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2015-10-28 17:06:09 +00:00
|
|
|
return Backgrid;
|
|
|
|
|
2018-01-12 07:29:51 +00:00
|
|
|
});
|