Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Added a check to see if there were no items. If there are no items it…
Browse files Browse the repository at this point in the history
… will not insert the extra multi select row and will not run multi select functions attached to it.

Added support for actions as well if there are no items

1436
  • Loading branch information
BenjaminNeilDavis committed Aug 5, 2015
1 parent 20695a9 commit dcf5e85
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions js/repeater-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@
this.list_sortDirection = null;
this.list_sortProperty = null;
this.list_actions_width = (this.viewOptions.list_actions.width !== undefined) ? this.viewOptions.list_actions.width : 37;
this.list_noItems = false;
callback();
},
resize: function () {
Expand Down Expand Up @@ -481,16 +482,16 @@
after: function(){
var $sorted;

if (this.viewOptions.list_frozenColumns || this.viewOptions.list_selectable === 'multi') {
if ((this.viewOptions.list_frozenColumns || this.viewOptions.list_selectable === 'multi') && !this.list_noItems) {
this.list_setFrozenColumns();
}

if (this.viewOptions.list_actions) {
if (this.viewOptions.list_actions && !this.list_noItems) {
this.list_createItemActions();
this.list_sizeActionsTable();
}

if (this.viewOptions.list_frozenColumns || this.viewOptions.list_actions || this.viewOptions.list_selectable === 'multi') {
if ((this.viewOptions.list_frozenColumns || this.viewOptions.list_actions || this.viewOptions.list_selectable === 'multi') && !this.list_noItems) {
this.list_positionColumns();
this.list_frozenOptionsInitialize();
}
Expand Down Expand Up @@ -739,7 +740,12 @@
$table.append($tbody);
}

if (data.items && data.items.length < 1) {
if (typeof data.error === 'string' && data.error.length > 0) {
$empty = $('<tr class="empty text-danger"><td colspan="' + this.list_columns.length + '"></td></tr>');
$empty.find('td').append(data.error);
$tbody.append($empty);
}
else if (data.items && data.items.length < 1) {
$empty = $('<tr class="empty"><td colspan="' + this.list_columns.length + '"></td></tr>');
$empty.find('td').append(this.viewOptions.list_noItemsHTML);
$tbody.append($empty);
Expand Down Expand Up @@ -777,7 +783,11 @@
if (this.list_firstRender || differentColumns(this.list_columns, columns) || $thead.length === 0) {
$thead.remove();

if (this.viewOptions.list_selectable === 'multi') {
if (data.count < 1) {
this.list_noItems = true;
}

if (this.viewOptions.list_selectable === 'multi' && !this.list_noItems) {
var checkboxColumn = {
label: 'c',
property: '@_CHECKBOX_@',
Expand All @@ -790,7 +800,7 @@
this.list_firstRender = false;
this.$loader.removeClass('noHeader');

if (this.viewOptions.list_actions){
if (this.viewOptions.list_actions && !this.list_noItems){
var actionsColumn = {
label: this.viewOptions.list_actions.label || '<span class="actions-hidden">a</span>',
property: '@_ACTIONS_@',
Expand All @@ -808,7 +818,7 @@
}
$table.prepend($thead);

if (this.viewOptions.list_selectable === 'multi') {
if (this.viewOptions.list_selectable === 'multi' && !this.list_noItems) {
//after checkbox column is created need to get width of checkbox column from
//its css class
var checkboxWidth = this.$element.find('.repeater-list-wrapper .header-checkbox').outerWidth();
Expand Down

0 comments on commit dcf5e85

Please sign in to comment.