Skip to content

Commit

Permalink
[#1251] Add record count to recline grid
Browse files Browse the repository at this point in the history
Ideally this would be fixed in Recline itself. I created an issue in their
repository to try to contribute it upstream
(datopian/datahub#424).
  • Loading branch information
vitorbaptista committed May 6, 2014
1 parent 1a6e562 commit b54b165
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ckanext/reclinepreview/theme/public/css/recline.css
Expand Up @@ -7,6 +7,12 @@ body {
overflow: auto;
}

.recline-record-count {
float: left;
margin-left: 10px;
line-height: 26px;
}

.loading-dialog {
width: 120px;
}
Expand Down
1 change: 1 addition & 0 deletions ckanext/reclinepreview/theme/public/preview_recline.js
Expand Up @@ -104,6 +104,7 @@ this.ckan.module('reclinepreview', function (jQuery, _) {
view = new recline.View.SlickGrid({model: dataset});
controls = [
new recline.View.Pager({model: view.model.queryState}),
new recline.View.RecordCount({model: dataset}),
new recline.View.QueryEditor({model: view.model.queryState})
];
}
Expand Down
1 change: 1 addition & 0 deletions ckanext/reclinepreview/theme/public/resource.config
Expand Up @@ -32,6 +32,7 @@ main =

vendor/recline/recline.js

widget.recordcount.js
preview_recline.js

vendor/bootstrap/2.0.2/css/bootstrap.css
Expand Down
29 changes: 29 additions & 0 deletions ckanext/reclinepreview/theme/public/widget.recordcount.js
@@ -0,0 +1,29 @@
/*jshint multistr:true */

this.recline = this.recline || {};
this.recline.View = this.recline.View || {};

(function($, my) {
"use strict";

my.RecordCount = Backbone.View.extend({
className: 'recline-record-count',
template: ' \
<span class="count">{{recordCount}}</span> records \
',

initialize: function() {
_.bindAll(this, 'render');
this.model.bind('query:done', this.render);
this.render();
},

render: function() {
var tmplData = this.model.toTemplateJSON();
tmplData.recordCount = tmplData.recordCount || 'Unknown number of';
var templated = Mustache.render(this.template, tmplData);
this.$el.html(templated);
}
});

})(jQuery, recline.View);

0 comments on commit b54b165

Please sign in to comment.