Skip to content

Commit

Permalink
Fix template helper assignment deprecation warning. (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslagle committed Oct 30, 2014
1 parent f972a3c commit 4eb69e2
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 57 deletions.
2 changes: 1 addition & 1 deletion examples/leaderboard/.meteor/versions
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
anti:[email protected]
[email protected]
aslagle:[email protected].0
aslagle:[email protected].2
[email protected]
[email protected]
[email protected]
Expand Down
48 changes: 26 additions & 22 deletions examples/leaderboard/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,33 @@
Players = new Meteor.Collection("players");

if (Meteor.isClient) {
Template.leaderboard.players = function () {
Template.leaderboard.helpers({
players : function () {
return Players.find({}, {sort: {score: -1, name: 1}});
};

Template.leaderboard.tableSettings = function () {
return {
fields: [
{ key: 'name', label: 'Full Name' },
{ key: 'name', label: 'First Name', fn: function (name) { return name.split(' ')[0]; } },
{ key: 'score', label: 'Score' }
],
useFontAwesome: true
};
};

Template.leaderboard.selected_name = function () {
var player = Players.findOne(Session.get("selected_player"));
return player && player.name;
};

Template.player.selected = function () {
return Session.equals("selected_player", this._id) ? "selected" : '';
};
},

tableSettings : function () {
return {
fields: [
{ key: 'name', label: 'Full Name' },
{ key: 'name', label: 'First Name', fn: function (name) { return name.split(' ')[0]; } },
{ key: 'score', label: 'Score' }
],
useFontAwesome: true
};
},

selected_name : function () {
var player = Players.findOne(Session.get("selected_player"));
return player && player.name;
}
});

Template.player.helpers({
selected : function () {
return Session.equals("selected_player", this._id) ? "selected" : '';
}
});

Template.leaderboard.events({
'click input.inc': function () {
Expand Down
2 changes: 1 addition & 1 deletion examples/table-features/.meteor/versions
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
anti:[email protected]
[email protected]
aslagle:[email protected].0
aslagle:[email protected].2
[email protected]
[email protected]
[email protected]
Expand Down
61 changes: 32 additions & 29 deletions examples/table-features/table-features.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
var Tables = new Meteor.Collection('features');

if (Meteor.isClient) {
Template.featureComparison.tables = function () {
return Tables;
};

var checkOrX = function (value) {
var html;
Expand All @@ -28,32 +25,38 @@ if (Meteor.isClient) {
return new Spacebars.SafeString(html);
};

Template.featureComparison.tableSettings = function () {
return {
rowsPerPage: 5,
showNavigation: 'auto',
showColumnToggles: true,
fields: [
{
key: 'name',
label: 'Library',
fn: function (name, object) {
var html = '<a name="' + name +'" target="_blank" href="' + object.url + '">' + name + '</a>';
return new Spacebars.SafeString(html);
}
},
{ key: 'sort', label: 'Sorting', fn: checkOrX },
{ key: 'pages', label: 'Pagination', fn: checkOrX },
{ key: 'filter', label: 'Filtering/Search', fn: checkOrX },
{ key: 'resize', label: 'Resizable Columns', fn: checkOrX },
{ key: 'edit', label: 'Inline Editing', fn: checkOrX },
{ key: 'responsive', label: 'Mobile/Responsive', fn: checkOrX, hidden: true },
{ key: 'i18n', label: 'Internationalization', fn: checkOrX, hidden: true },
{ key: 'keyboard', label: 'Keyboard navigation', fn: checkOrX, hidden: true },
{ key: 'meteor', label: 'Meteor Integration', fn: checkOrX, hidden: function () { return true; } }
]
};
};
Template.featureComparison.helpers({
tables : function () {
return Tables;
},

tableSettings : function () {
return {
rowsPerPage: 5,
showNavigation: 'auto',
showColumnToggles: true,
fields: [
{
key: 'name',
label: 'Library',
fn: function (name, object) {
var html = '<a name="' + name +'" target="_blank" href="' + object.url + '">' + name + '</a>';
return new Spacebars.SafeString(html);
}
},
{ key: 'sort', label: 'Sorting', fn: checkOrX },
{ key: 'pages', label: 'Pagination', fn: checkOrX },
{ key: 'filter', label: 'Filtering/Search', fn: checkOrX },
{ key: 'resize', label: 'Resizable Columns', fn: checkOrX },
{ key: 'edit', label: 'Inline Editing', fn: checkOrX },
{ key: 'responsive', label: 'Mobile/Responsive', fn: checkOrX, hidden: true },
{ key: 'i18n', label: 'Internationalization', fn: checkOrX, hidden: true },
{ key: 'keyboard', label: 'Keyboard navigation', fn: checkOrX, hidden: true },
{ key: 'meteor', label: 'Meteor Integration', fn: checkOrX, hidden: function () { return true; } }
]
};
}
});
}

if (Meteor.isServer) {
Expand Down
8 changes: 5 additions & 3 deletions lib/reactive_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Template.reactiveTable.rendered = function () {
}
};

Template.reactiveTable.getPageCount = function () {
var getPageCount = function () {
var rowsPerPage = this.rowsPerPage.get();
var filterQuery = getFilterQuery(this.filter.get(), this.fields);
var count = this.collection.find(filterQuery).count();
Expand Down Expand Up @@ -307,6 +307,8 @@ Template.reactiveTable.helpers({
return this.filter.get() || '';
},

'getPageCount' : getPageCount,

'getRowsPerPage' : function () {
return this.rowsPerPage.get();
},
Expand All @@ -330,7 +332,7 @@ Template.reactiveTable.helpers({
'showNavigation' : function () {
if (this.showNavigation === 'always') return true;
if (this.showNavigation === 'never') return false;
return Template.reactiveTable.getPageCount.call(this) > 1;
return getPageCount.call(this) > 1;
}
});

Expand Down Expand Up @@ -374,7 +376,7 @@ Template.reactiveTable.events({

'change .reactive-table-navigation .page-number input': function (event) {
var currentPage = Math.max(~~$(event.target).val(), 1);
var pageCount = Template.reactiveTable.getPageCount.call(this);
var pageCount = getPageCount.call(this);
if (currentPage > pageCount) {
currentPage = pageCount;
}
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
summary: "A reactive table designed for Meteor",
version: "0.5.1",
version: "0.5.2",
name: "aslagle:reactive-table",
git: "https://github.com/ecohealthalliance/reactive-table.git"
});
Expand Down

0 comments on commit 4eb69e2

Please sign in to comment.