Remove some dead code.
parent
5e6c29d5db
commit
28deb34283
|
@ -49,74 +49,6 @@ define(
|
|||
|
||||
var is_query_running = false;
|
||||
|
||||
// Defining the backbone model for the sql grid
|
||||
var sqlEditorViewModel = Backbone.Model.extend({
|
||||
|
||||
/* Keep track of values for the original primary keys for later reference,
|
||||
* to allow to change the value of primary keys in the model, which will be
|
||||
* required to identify the value of any row in the datagrid for the relation.
|
||||
*/
|
||||
parse: function(data) {
|
||||
var self = this;
|
||||
self.grid_keys = {};
|
||||
self.changed_data = false;
|
||||
|
||||
if (data && 'primary_keys' in self && self.primary_keys && _.size(self.primary_keys) > 0) {
|
||||
_.each(self.primary_keys, function (value, key) {
|
||||
// Assumption - the data, which are coming will always have data for primary_keys
|
||||
self.grid_keys[key] = data[key];
|
||||
});
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
/* We also need primary key along with the original data,
|
||||
* which is required to identify this row in the database for modification.
|
||||
*/
|
||||
toJSON: function(overridden, keys_only) {
|
||||
var res = Backbone.Model.prototype.toJSON.apply(this, arguments);
|
||||
if (!overridden) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if (keys_only)
|
||||
return this.grid_keys;
|
||||
|
||||
return {
|
||||
'keys': this.grid_keys,
|
||||
'data': res
|
||||
};
|
||||
},
|
||||
|
||||
// This function updates the primary key if changed.
|
||||
update_keys: function() {
|
||||
var self = this;
|
||||
|
||||
/* If 'grid_keys' present in the changed object
|
||||
* then it is an update else insert.
|
||||
*/
|
||||
if ('grid_keys' in self) {
|
||||
/* Iterate through primary keys and check if the key
|
||||
* is updated or not. If it is updated we need to update
|
||||
* the grid_keys of the model as well.
|
||||
*/
|
||||
_.each(self.primary_keys, function (value, key) {
|
||||
if (self.grid_keys[key] != self.attributes[key])
|
||||
self.grid_keys[key] = self.attributes[key]
|
||||
});
|
||||
}
|
||||
else {
|
||||
self.grid_keys = {};
|
||||
/* Iterate through primary keys and insert
|
||||
* the values in models grid_keys.
|
||||
*/
|
||||
_.each(self.primary_keys, function (value, key) {
|
||||
self.grid_keys[key] = self.attributes[key]
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Defining Backbone view for the sql grid.
|
||||
var SQLEditorView = Backbone.View.extend({
|
||||
initialize: function(opts) {
|
||||
|
|
Loading…
Reference in New Issue