From f9f5be654097598da3fb2ccc29bc4d4f4c42c0ec Mon Sep 17 00:00:00 2001 From: Rufus Pollock Date: Wed, 14 Mar 2012 21:14:56 +0000 Subject: [PATCH] [view/query][s]: refactor query view to have from / size changes in new dropdown query menu rather than in pagination. --- css/data-explorer.css | 24 ++++++++++++++---------- src/view.js | 37 ++++++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 19 deletions(-) diff --git a/css/data-explorer.css b/css/data-explorer.css index 935340d2..dfa75161 100644 --- a/css/data-explorer.css +++ b/css/data-explorer.css @@ -29,24 +29,28 @@ .header .recline-query-editor .text-query input { float: left; - margin-right: 5px; } -.header .recline-query-editor .pagination input { - width: 30px; - height: 18px; - padding: 2px 4px; - margin-top: -4px; +.recline-query-editor .text-query .btn-group { + display: inline; + float:left; + margin-left:-2px; +} + +.recline-query-editor .text-query .btn-group .dropdown-toggle { + -moz-border-radius:0px 3px 3px 0px; + -webkit-border-radius:0px 3px 3px 0px; + border-radius:0px 3px 3px 0px; +} + +.recline-query-editor .text-query .btn-group ul { + margin-left:-110px; } .header .recline-query-editor .pagination a { line-height: 26px; } -.header .recline-query-editor form .btn { - vertical-align: top; -} - .data-view-container { display: block; clear: both; diff --git a/src/view.js b/src/view.js index 62924e5d..db7c1e5a 100644 --- a/src/view.js +++ b/src/view.js @@ -207,21 +207,28 @@ my.QueryEditor = Backbone.View.extend({
\ \ \ + \
\ \ - \ \ ', events: { - 'submit form': 'onFormSubmit', - 'click .action-pagination-update': 'onPaginationUpdate' + 'submit form': 'onFormSubmit' + , 'click .action-pagination-update': 'onPaginationUpdate' + , 'click .menu li a': 'onMenuItemClick' }, initialize: function() { @@ -232,10 +239,8 @@ my.QueryEditor = Backbone.View.extend({ }, onFormSubmit: function(e) { e.preventDefault(); - var newFrom = parseInt(this.el.find('input[name="from"]').val()); - var newSize = parseInt(this.el.find('input[name="to"]').val()) - newFrom; var query = this.el.find('.text-query input').val(); - this.model.set({size: newSize, from: newFrom, q: query}); + this.model.set({q: query}); }, onPaginationUpdate: function(e) { e.preventDefault(); @@ -247,6 +252,20 @@ my.QueryEditor = Backbone.View.extend({ } this.model.set({from: newFrom}); }, + onMenuItemClick: function(e) { + e.preventDefault(); + var attrName = $(e.target).attr('data-action'); + var msg = _.template('New value (<%= value %>)', + {value: this.model.get(attrName)} + ); + var newValue = prompt(msg); + if (newValue) { + newValue = parseInt(newValue); + var update = {}; + update[attrName] = newValue; + this.model.set(update); + } + }, render: function() { var tmplData = this.model.toJSON(); tmplData.to = this.model.get('from') + this.model.get('size');