diff --git a/src/view.js b/src/view.js
index 503fa47c..ef37a2cc 100644
--- a/src/view.js
+++ b/src/view.js
@@ -46,7 +46,6 @@ this.recline.View = this.recline.View || {};
//
// **config**: Config options like:
//
-// * displayCount: how many documents to display initially (default: 10)
// * readOnly: true/false (default: false) value indicating whether to
// operate in read-only mode (hiding all editing options).
//
@@ -63,11 +62,6 @@ my.DataExplorer = Backbone.View.extend({
{{label}} \
{{/views}} \
\
- \
\
\
\
@@ -79,16 +73,11 @@ my.DataExplorer = Backbone.View.extend({
\
',
- events: {
- 'submit form.display-count': 'onDisplayCountUpdate'
- },
-
initialize: function(options) {
var self = this;
this.el = $(this.el);
this.config = _.extend({
- displayCount: 50
- , readOnly: false
+ readOnly: false
},
options.config);
if (this.config.readOnly) {
@@ -124,13 +113,11 @@ my.DataExplorer = Backbone.View.extend({
});
},
+ // TODO: listen for being query and end query events on the dataset ...
+ // (This is no longer called by anything ...)
query: function() {
- this.config.displayCount = parseInt(this.el.find('input[name="displayCount"]').val());
- var queryObj = {
- size: this.config.displayCount
- };
my.notify('Loading data', {loader: true});
- this.model.query(queryObj)
+ this.model.query()
.done(function() {
my.clearNotifications();
my.notify('Data loaded', {category: 'success'});
@@ -141,11 +128,6 @@ my.DataExplorer = Backbone.View.extend({
});
},
- onDisplayCountUpdate: function(e) {
- e.preventDefault();
- this.query();
- },
-
setReadOnly: function() {
this.el.addClass('read-only');
},
@@ -160,6 +142,10 @@ my.DataExplorer = Backbone.View.extend({
_.each(this.pageViews, function(view, pageName) {
$dataViewContainer.append(view.view.el)
});
+ var queryEditor = new my.QueryEditor({
+ model: this.model.queryState
+ });
+ this.el.find('.header').append(queryEditor.el);
},
setupRouting: function() {
@@ -191,6 +177,35 @@ my.DataExplorer = Backbone.View.extend({
});
+my.QueryEditor = Backbone.View.extend({
+ className: 'recline-query-editor',
+ template: ' \
+ \
+ ',
+
+ events: {
+ 'submit form.display-count': 'onFormSubmit'
+ },
+
+ initialize: function() {
+ this.el = $(this.el);
+ this.render();
+ },
+ onFormSubmit: function(e) {
+ e.preventDefault();
+ var newSize = parseInt(this.el.find('input[name="displayCount"]').val());
+ this.model.set({size: newSize});
+ },
+ render: function() {
+ var tmplData = this.model.toJSON();
+ var templated = $.mustache(this.template, tmplData);
+ this.el.html(templated);
+ }
+});
+
+
/* ========================================================== */
// ## Miscellaneous Utilities