Merge branch 'master' of github.com:okfn/recline
This commit is contained in:
commit
1efc110d52
@ -42,6 +42,7 @@
|
||||
-->
|
||||
|
||||
<!-- model and backends -->
|
||||
<script type="text/javascript" src="{{page.root}}src/ecma-fixes.js"></script>
|
||||
<script type="text/javascript" src="{{page.root}}src/model.js"></script>
|
||||
<script type="text/javascript" src="{{page.root}}src/backend.memory.js"></script>
|
||||
<script type="text/javascript" src="{{page.root}}src/backend.dataproxy.js"></script>
|
||||
|
||||
@ -74,21 +74,21 @@ var createExplorer = function(dataset, state) {
|
||||
label: 'Grid',
|
||||
view: new recline.View.SlickGrid({
|
||||
model: dataset
|
||||
}),
|
||||
})
|
||||
},
|
||||
{
|
||||
id: 'graph',
|
||||
label: 'Graph',
|
||||
view: new recline.View.Graph({
|
||||
model: dataset
|
||||
}),
|
||||
})
|
||||
},
|
||||
{
|
||||
id: 'map',
|
||||
label: 'Map',
|
||||
view: new recline.View.Map({
|
||||
model: dataset
|
||||
}),
|
||||
})
|
||||
},
|
||||
{
|
||||
id: 'transform',
|
||||
|
||||
4
dist/recline.dataset.js
vendored
4
dist/recline.dataset.js
vendored
@ -608,7 +608,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
||||
});
|
||||
};
|
||||
|
||||
this.delete = function(doc) {
|
||||
this.remove = function(doc) {
|
||||
var newdocs = _.reject(self.data, function(internalDoc) {
|
||||
return (doc.id === internalDoc.id);
|
||||
});
|
||||
@ -623,7 +623,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
||||
self.update(record);
|
||||
});
|
||||
_.each(changes.deletes, function(record) {
|
||||
self.delete(record);
|
||||
self.remove(record);
|
||||
});
|
||||
dfd.resolve();
|
||||
return dfd.promise();
|
||||
|
||||
89
dist/recline.js
vendored
89
dist/recline.js
vendored
@ -529,7 +529,7 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
|
||||
//
|
||||
// @param {Object} id id of object to delete
|
||||
// @return deferred supporting promise API
|
||||
this.delete = function(id) {
|
||||
this.remove = function(id) {
|
||||
url = this.endpoint;
|
||||
url += '/' + id;
|
||||
return makeRequest({
|
||||
@ -669,7 +669,7 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
|
||||
else if (changes.updates.length >0) {
|
||||
return es.upsert(changes.updates[0]);
|
||||
} else if (changes.deletes.length > 0) {
|
||||
return es.delete(changes.deletes[0].id);
|
||||
return es.remove(changes.deletes[0].id);
|
||||
}
|
||||
};
|
||||
|
||||
@ -680,7 +680,7 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
|
||||
var jqxhr = es.query(queryObj);
|
||||
jqxhr.done(function(results) {
|
||||
var out = {
|
||||
total: results.hits.total,
|
||||
total: results.hits.total
|
||||
};
|
||||
out.hits = _.map(results.hits.hits, function(hit) {
|
||||
if (!('id' in hit._source) && hit._id) {
|
||||
@ -930,7 +930,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
||||
});
|
||||
};
|
||||
|
||||
this.delete = function(doc) {
|
||||
this.remove = function(doc) {
|
||||
var newdocs = _.reject(self.data, function(internalDoc) {
|
||||
return (doc.id === internalDoc.id);
|
||||
});
|
||||
@ -945,7 +945,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
||||
self.update(record);
|
||||
});
|
||||
_.each(changes.deletes, function(record) {
|
||||
self.delete(record);
|
||||
self.remove(record);
|
||||
});
|
||||
dfd.resolve();
|
||||
return dfd.promise();
|
||||
@ -1180,7 +1180,73 @@ my.Transform.mapDocs = function(docs, editFunc) {
|
||||
};
|
||||
|
||||
}(this.recline.Data))
|
||||
// # Recline Backbone Models
|
||||
// This file adds in full array method support in browsers that don't support it
|
||||
// see: http://stackoverflow.com/questions/2790001/fixing-javascript-array-functions-in-internet-explorer-indexof-foreach-etc
|
||||
|
||||
// Add ECMA262-5 Array methods if not supported natively
|
||||
if (!('indexOf' in Array.prototype)) {
|
||||
Array.prototype.indexOf= function(find, i /*opt*/) {
|
||||
if (i===undefined) i= 0;
|
||||
if (i<0) i+= this.length;
|
||||
if (i<0) i= 0;
|
||||
for (var n= this.length; i<n; i++)
|
||||
if (i in this && this[i]===find)
|
||||
return i;
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
if (!('lastIndexOf' in Array.prototype)) {
|
||||
Array.prototype.lastIndexOf= function(find, i /*opt*/) {
|
||||
if (i===undefined) i= this.length-1;
|
||||
if (i<0) i+= this.length;
|
||||
if (i>this.length-1) i= this.length-1;
|
||||
for (i++; i-->0;) /* i++ because from-argument is sadly inclusive */
|
||||
if (i in this && this[i]===find)
|
||||
return i;
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
if (!('forEach' in Array.prototype)) {
|
||||
Array.prototype.forEach= function(action, that /*opt*/) {
|
||||
for (var i= 0, n= this.length; i<n; i++)
|
||||
if (i in this)
|
||||
action.call(that, this[i], i, this);
|
||||
};
|
||||
}
|
||||
if (!('map' in Array.prototype)) {
|
||||
Array.prototype.map= function(mapper, that /*opt*/) {
|
||||
var other= new Array(this.length);
|
||||
for (var i= 0, n= this.length; i<n; i++)
|
||||
if (i in this)
|
||||
other[i]= mapper.call(that, this[i], i, this);
|
||||
return other;
|
||||
};
|
||||
}
|
||||
if (!('filter' in Array.prototype)) {
|
||||
Array.prototype.filter= function(filter, that /*opt*/) {
|
||||
var other= [], v;
|
||||
for (var i=0, n= this.length; i<n; i++)
|
||||
if (i in this && filter.call(that, v= this[i], i, this))
|
||||
other.push(v);
|
||||
return other;
|
||||
};
|
||||
}
|
||||
if (!('every' in Array.prototype)) {
|
||||
Array.prototype.every= function(tester, that /*opt*/) {
|
||||
for (var i= 0, n= this.length; i<n; i++)
|
||||
if (i in this && !tester.call(that, this[i], i, this))
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
}
|
||||
if (!('some' in Array.prototype)) {
|
||||
Array.prototype.some= function(tester, that /*opt*/) {
|
||||
for (var i= 0, n= this.length; i<n; i++)
|
||||
if (i in this && tester.call(that, this[i], i, this))
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
}// # Recline Backbone Models
|
||||
this.recline = this.recline || {};
|
||||
this.recline.Model = this.recline.Model || {};
|
||||
|
||||
@ -1974,7 +2040,7 @@ my.Graph = Backbone.View.extend({
|
||||
horizontal: true,
|
||||
shadowSize: 0,
|
||||
barWidth: 0.8
|
||||
},
|
||||
}
|
||||
},
|
||||
columns: {
|
||||
legend: legend,
|
||||
@ -1995,9 +2061,9 @@ my.Graph = Backbone.View.extend({
|
||||
horizontal: false,
|
||||
shadowSize: 0,
|
||||
barWidth: 0.8
|
||||
},
|
||||
}
|
||||
},
|
||||
grid: { hoverable: true, clickable: true },
|
||||
grid: { hoverable: true, clickable: true }
|
||||
};
|
||||
return optionsPerGraphType[typeId];
|
||||
},
|
||||
@ -2177,7 +2243,7 @@ my.GraphControls = Backbone.View.extend({
|
||||
addSeries: function (idx) {
|
||||
var data = _.extend({
|
||||
seriesIndex: idx,
|
||||
seriesName: String.fromCharCode(idx + 64 + 1),
|
||||
seriesName: String.fromCharCode(idx + 64 + 1)
|
||||
}, this.model.toTemplateJSON());
|
||||
|
||||
var htmls = Mustache.render(this.templateSeriesEditor, data);
|
||||
@ -3183,7 +3249,7 @@ my.MultiView = Backbone.View.extend({
|
||||
<div class="recline-data-explorer"> \
|
||||
<div class="alert-messages"></div> \
|
||||
\
|
||||
<div class="header"> \
|
||||
<div class="header clearfix"> \
|
||||
<div class="navigation"> \
|
||||
<div class="btn-group" data-toggle="buttons-radio"> \
|
||||
{{#views}} \
|
||||
@ -3202,7 +3268,6 @@ my.MultiView = Backbone.View.extend({
|
||||
</div> \
|
||||
</div> \
|
||||
<div class="query-editor-here" style="display:inline;"></div> \
|
||||
<div class="clearfix"></div> \
|
||||
</div> \
|
||||
<div class="data-view-sidebar"></div> \
|
||||
<div class="data-view-container"></div> \
|
||||
|
||||
@ -97,7 +97,7 @@ my.__type__ = 'couchdb';
|
||||
//
|
||||
// @param {Object} id id of object to delete
|
||||
// @return deferred supporting promise API
|
||||
this.delete = function(_id) {
|
||||
this.remove = function(_id) {
|
||||
url = self.endpoint;
|
||||
url += '/' + _id;
|
||||
return self._makeRequest({
|
||||
@ -475,7 +475,7 @@ _deleteDocument = function (del_doc, dataset) {
|
||||
var cdb = new my.CouchDBWrapper(db_url, view_url);
|
||||
|
||||
if (view_url.search('_all_docs') !== -1)
|
||||
return cdb.delete(_id);
|
||||
return cdb.remove(_id);
|
||||
else {
|
||||
_id = model.get('_id').split('__')[0];
|
||||
var jqxhr = cdb.get(_id);
|
||||
@ -484,7 +484,7 @@ _deleteDocument = function (del_doc, dataset) {
|
||||
if (dataset.record_delete)
|
||||
old_doc = dataset.record_delete(del_doc, old_doc);
|
||||
if (_.isNull(del_doc))
|
||||
dfd.resolve(cdb.delete(_id)); // XXX is this the right thing to do?
|
||||
dfd.resolve(cdb.remove(_id)); // XXX is this the right thing to do?
|
||||
else {
|
||||
// couchdb uses _id to identify documents, Backbone models use id.
|
||||
// we should remove it before sending it to the server.
|
||||
|
||||
@ -79,7 +79,7 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
|
||||
//
|
||||
// @param {Object} id id of object to delete
|
||||
// @return deferred supporting promise API
|
||||
this.delete = function(id) {
|
||||
this.remove = function(id) {
|
||||
url = this.endpoint;
|
||||
url += '/' + id;
|
||||
return makeRequest({
|
||||
@ -219,7 +219,7 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
|
||||
else if (changes.updates.length >0) {
|
||||
return es.upsert(changes.updates[0]);
|
||||
} else if (changes.deletes.length > 0) {
|
||||
return es.delete(changes.deletes[0].id);
|
||||
return es.remove(changes.deletes[0].id);
|
||||
}
|
||||
};
|
||||
|
||||
@ -230,7 +230,7 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
|
||||
var jqxhr = es.query(queryObj);
|
||||
jqxhr.done(function(results) {
|
||||
var out = {
|
||||
total: results.hits.total,
|
||||
total: results.hits.total
|
||||
};
|
||||
out.hits = _.map(results.hits.hits, function(hit) {
|
||||
if (!('id' in hit._source) && hit._id) {
|
||||
|
||||
@ -37,7 +37,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
||||
});
|
||||
};
|
||||
|
||||
this.delete = function(doc) {
|
||||
this.remove = function(doc) {
|
||||
var newdocs = _.reject(self.data, function(internalDoc) {
|
||||
return (doc.id === internalDoc.id);
|
||||
});
|
||||
@ -52,7 +52,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
||||
self.update(record);
|
||||
});
|
||||
_.each(changes.deletes, function(record) {
|
||||
self.delete(record);
|
||||
self.remove(record);
|
||||
});
|
||||
dfd.resolve();
|
||||
return dfd.promise();
|
||||
|
||||
67
src/ecma-fixes.js
Normal file
67
src/ecma-fixes.js
Normal file
@ -0,0 +1,67 @@
|
||||
// This file adds in full array method support in browsers that don't support it
|
||||
// see: http://stackoverflow.com/questions/2790001/fixing-javascript-array-functions-in-internet-explorer-indexof-foreach-etc
|
||||
|
||||
// Add ECMA262-5 Array methods if not supported natively
|
||||
if (!('indexOf' in Array.prototype)) {
|
||||
Array.prototype.indexOf= function(find, i /*opt*/) {
|
||||
if (i===undefined) i= 0;
|
||||
if (i<0) i+= this.length;
|
||||
if (i<0) i= 0;
|
||||
for (var n= this.length; i<n; i++)
|
||||
if (i in this && this[i]===find)
|
||||
return i;
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
if (!('lastIndexOf' in Array.prototype)) {
|
||||
Array.prototype.lastIndexOf= function(find, i /*opt*/) {
|
||||
if (i===undefined) i= this.length-1;
|
||||
if (i<0) i+= this.length;
|
||||
if (i>this.length-1) i= this.length-1;
|
||||
for (i++; i-->0;) /* i++ because from-argument is sadly inclusive */
|
||||
if (i in this && this[i]===find)
|
||||
return i;
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
if (!('forEach' in Array.prototype)) {
|
||||
Array.prototype.forEach= function(action, that /*opt*/) {
|
||||
for (var i= 0, n= this.length; i<n; i++)
|
||||
if (i in this)
|
||||
action.call(that, this[i], i, this);
|
||||
};
|
||||
}
|
||||
if (!('map' in Array.prototype)) {
|
||||
Array.prototype.map= function(mapper, that /*opt*/) {
|
||||
var other= new Array(this.length);
|
||||
for (var i= 0, n= this.length; i<n; i++)
|
||||
if (i in this)
|
||||
other[i]= mapper.call(that, this[i], i, this);
|
||||
return other;
|
||||
};
|
||||
}
|
||||
if (!('filter' in Array.prototype)) {
|
||||
Array.prototype.filter= function(filter, that /*opt*/) {
|
||||
var other= [], v;
|
||||
for (var i=0, n= this.length; i<n; i++)
|
||||
if (i in this && filter.call(that, v= this[i], i, this))
|
||||
other.push(v);
|
||||
return other;
|
||||
};
|
||||
}
|
||||
if (!('every' in Array.prototype)) {
|
||||
Array.prototype.every= function(tester, that /*opt*/) {
|
||||
for (var i= 0, n= this.length; i<n; i++)
|
||||
if (i in this && !tester.call(that, this[i], i, this))
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
}
|
||||
if (!('some' in Array.prototype)) {
|
||||
Array.prototype.some= function(tester, that /*opt*/) {
|
||||
for (var i= 0, n= this.length; i<n; i++)
|
||||
if (i in this && tester.call(that, this[i], i, this))
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
}
|
||||
@ -221,7 +221,7 @@ my.Graph = Backbone.View.extend({
|
||||
horizontal: true,
|
||||
shadowSize: 0,
|
||||
barWidth: 0.8
|
||||
},
|
||||
}
|
||||
},
|
||||
columns: {
|
||||
legend: legend,
|
||||
@ -242,9 +242,9 @@ my.Graph = Backbone.View.extend({
|
||||
horizontal: false,
|
||||
shadowSize: 0,
|
||||
barWidth: 0.8
|
||||
},
|
||||
}
|
||||
},
|
||||
grid: { hoverable: true, clickable: true },
|
||||
grid: { hoverable: true, clickable: true }
|
||||
};
|
||||
return optionsPerGraphType[typeId];
|
||||
},
|
||||
@ -424,7 +424,7 @@ my.GraphControls = Backbone.View.extend({
|
||||
addSeries: function (idx) {
|
||||
var data = _.extend({
|
||||
seriesIndex: idx,
|
||||
seriesName: String.fromCharCode(idx + 64 + 1),
|
||||
seriesName: String.fromCharCode(idx + 64 + 1)
|
||||
}, this.model.toTemplateJSON());
|
||||
|
||||
var htmls = Mustache.render(this.templateSeriesEditor, data);
|
||||
|
||||
@ -98,7 +98,7 @@ my.MultiView = Backbone.View.extend({
|
||||
<div class="recline-data-explorer"> \
|
||||
<div class="alert-messages"></div> \
|
||||
\
|
||||
<div class="header"> \
|
||||
<div class="header clearfix"> \
|
||||
<div class="navigation"> \
|
||||
<div class="btn-group" data-toggle="buttons-radio"> \
|
||||
{{#views}} \
|
||||
@ -117,7 +117,6 @@ my.MultiView = Backbone.View.extend({
|
||||
</div> \
|
||||
</div> \
|
||||
<div class="query-editor-here" style="display:inline;"></div> \
|
||||
<div class="clearfix"></div> \
|
||||
</div> \
|
||||
<div class="data-view-sidebar"></div> \
|
||||
<div class="data-view-container"></div> \
|
||||
|
||||
@ -220,7 +220,7 @@ test("write", function() {
|
||||
equal(data._version, 2);
|
||||
|
||||
// delete
|
||||
var jqxhr = backend.delete(rec.id);
|
||||
var jqxhr = backend.remove(rec.id);
|
||||
jqxhr.done(function(data) {
|
||||
ok(data.ok);
|
||||
rec = null;
|
||||
|
||||
@ -135,7 +135,7 @@ test('update and delete', function () {
|
||||
equal(data.data[0].x, newVal);
|
||||
|
||||
// Test Delete
|
||||
data.delete(doc1);
|
||||
data.remove(doc1);
|
||||
equal(data.data.length, 5);
|
||||
equal(data.data[0].x, memoryData[1].x);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user