Skip to content

Commit d15b14b

Browse files
committed
organize options for download and info features
1 parent 2c79af0 commit d15b14b

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Change Log
22

33
## v4.1.13-alpha
4-
- `ufTable`: Implement `rowTemplateSelector` for customizing how rows are rendered (#787)
4+
- `ufTable`: Implement `rowTemplate` for customizing how rows are rendered (#787)
55
- `ufTable`: Support for passing callbacks for column templates instead of Handlebars templates
66
- Remove explicit references to `id` columns (#803)
77
- Fix Docker

app/sprinkles/core/assets/userfrosting/js/uf-table.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
filterAllField : '_all',
103103
useLoadingTransition : true,
104104
rowTemplate : null,
105+
columnTemplates : {},
105106
tablesorter : {
106107
debug: false,
107108
theme : 'bootstrap',
@@ -174,11 +175,13 @@
174175
var tableElement = this.$element.find('.tablesorter');
175176

176177
var lateDefaults = {
177-
downloadButton: this.$element.find('.js-uf-table-download'),
178-
onDownload: $.proxy(this._onDownload, this),
179-
renderInfoMessages: $.proxy(this._renderInfoMessages, this),
178+
download: {
179+
button: this.$element.find('.js-uf-table-download'),
180+
callback: $.proxy(this._onDownload, this)
181+
},
180182
info: {
181-
container: this.$element.find('.js-uf-table-info')
183+
container: this.$element.find('.js-uf-table-info'),
184+
callback: $.proxy(this._renderInfoMessages, this)
182185
},
183186
overlay: {
184187
container: this.$element.find('.js-uf-table-overlay')
@@ -231,7 +234,6 @@
231234
infoContainer.data('message-empty-rows') :
232235
"Sorry, we've got nothing here."
233236
},
234-
columnTemplates: {},
235237
tablesorter: {
236238
widgetOptions: {
237239
// possible variables: {size}, {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows}
@@ -304,7 +306,7 @@
304306
}
305307

306308
// Link CSV download button
307-
this.settings.downloadButton.on('click', this.settings.onDownload);
309+
this.settings.download.button.on('click', this.settings.download.callback);
308310

309311
// Allow clicking on the labels in the table menu without closing the menu
310312
$(this.settings.tablesorter.widgetOptions.columnSelector_container).find('label').on('click', function(e) {
@@ -317,7 +319,7 @@
317319
}, this));
318320

319321
// Show info messages when there are no rows/no results
320-
this.ts.on('filterEnd filterReset pagerComplete', this.settings.renderInfoMessages);
322+
this.ts.on('filterEnd filterReset pagerComplete', this.settings.info.callback);
321323

322324
// Detect changes to element attributes
323325
this.$element.attrchange({
@@ -494,6 +496,7 @@
494496

495497
/**
496498
* Implements handler for the "download CSV" button.
499+
* Default callback for download.callback
497500
* @private
498501
*/
499502
Plugin.prototype._onDownload = function () {
@@ -549,7 +552,7 @@
549552

550553
/**
551554
* Render info messages, such as when there are no results.
552-
* Default callback for renderInfoMessages
555+
* Default callback for info.callback
553556
* @private
554557
*/
555558
Plugin.prototype._renderInfoMessages = function () {

0 commit comments

Comments
 (0)