Skip to content

Commit

Permalink
UI-2516: add way to display more entries with monster tables
Browse files Browse the repository at this point in the history
  • Loading branch information
JRMaitre committed Dec 29, 2016
1 parent 93f591d commit 8eb2e55
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/apps/core/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -715,5 +715,16 @@
"__version": "v4.0",
"clipboard": {
"successCopy": "Successfully Copied to Clipboard!"
},

"__comment": "UI-2516: allow users to display more entities",
"__version": "v4.0",
"tablePageSize": {
"show": "Show",
"entries": "entries",
"ten": "10",
"twentyFive": "25",
"fifty": "50",
"hundred": "100"
}
}
19 changes: 19 additions & 0 deletions src/apps/core/style/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -629,4 +629,23 @@ body,
.backend-pagination.full .full-load,
.backend-pagination .partial-load {
display: inline-block
}

/* Page Size Table */
.table-page-size {
float: right;
display: inline-block;
margin-top: 11px;
margin-right: 50px;
}

.table-page-size select {
width: 60px;
margin: 0 5px 3px;
}

/* hacky class to use the same style as footable labels */
.table-page-size span.label {
float: none !important;
margin-right: 0 !important;
}
12 changes: 12 additions & 0 deletions src/apps/core/views/monster-table-pageSize.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div class="table-page-size">
<span class="label label-default">{{i18n.tablePageSize.show}}</span>
<select>
{{#select pageSize}}
<option value="10">{{i18n.tablePageSize.ten}}</option>
<option value="25">{{i18n.tablePageSize.twentyFive}}</option>
<option value="50">{{i18n.tablePageSize.fifty}}</option>
<option value="100">{{i18n.tablePageSize.hundred}}</option>
{{/select}}
</select>
<span class="label label-default">{{i18n.tablePageSize.entries}}</span>
</div>
2 changes: 1 addition & 1 deletion src/css/lib/custom/footable-add.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ table.footable.monster-table .footable-paging ul.pagination {
float: right;
}

table.footable.monster-table > tfoot > tr.footable-paging > td > span.label {
table.footable.monster-table > tfoot > tr.footable-paging > td span.label {
background: rgba(0, 0, 0, 0) none repeat scroll 0 0;
color: #333;
float: right;
Expand Down
29 changes: 27 additions & 2 deletions src/js/lib/monster.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,25 @@ define(function(require){
container.find('tbody').append(rows);
});
},
addPageSizeComponent = function(container, table, pPageSize) {
var pageSize = pPageSize || finalOptions.paging.size || 10,
pageSizeTemplate = $(monster.template(monster.apps.core, 'monster-table-pageSize', { pageSize: pageSize })),
footableInstance;

pageSizeTemplate.find('select').on('change', function() {
pageSize = parseInt($(this).val());
footableInstance = footable.get('#'+table.attr('id'));

footableInstance.pageSize(pageSize);

addPageSizeComponent(container, table, pageSize);

// This is useful so when we use the "load more" button, it uses the right page size we just set
finalOptions.paging.size = pageSize;
});

container.find('.footable-paging td').append(pageSizeTemplate);
},
filters = {
paginate: false
};
Expand Down Expand Up @@ -2201,6 +2220,8 @@ define(function(require){
var newTable = container.footable(finalOptions),
backendTemplate = $(monster.template(monster.apps.core, 'monster-table-backendPagination', { isFull: isAllDataLoaded }));

addPageSizeComponent(container, newTable);

monster.ui.tooltips(backendTemplate);

container.find('.footable-filtering th form').prepend(backendTemplate);
Expand Down Expand Up @@ -2236,13 +2257,17 @@ define(function(require){
finalOptions.getData(filters, function(rows, data) {
addRowsToBody([ rows ]);

container.footable(finalOptions);
var table = container.footable(finalOptions);

addPageSizeComponent(container, table);

finalOptions.afterInitialized && finalOptions.afterInitialized();
});
}
else {
container.footable(finalOptions);
var table = container.footable(finalOptions);

addPageSizeComponent(container, table);

finalOptions.afterInitialized && finalOptions.afterInitialized();
}
Expand Down
3 changes: 3 additions & 0 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ require.config({
'plugins': ['jquery'],
'kazoosdk': ['jquery'],
'touch-punch': ['jqueryui'],
'footable': {
'exports': 'FooTable'
},
'underscore': {
'exports': '_'
},
Expand Down

0 comments on commit 8eb2e55

Please sign in to comment.