UI, history: render on deleted/hidden toggle

- Fixes lack of render when only one hidden/deleted dataset is shown
by sending a `renderAll` flag then caught by the update listener
This commit is contained in:
carlfeberhard
2016-07-28 11:43:44 -04:00
parent 53f34b8c9e
commit 97b171632d
8 changed files with 27 additions and 21 deletions
@@ -241,7 +241,7 @@ var HistoryView = _super.extend(
/** override to render pagination also */
renderItems: function( $whereTo ){
console.log( this + '.renderItems-----------------', new Date() );
// console.log( this + '.renderItems-----------------', new Date() );
$whereTo = $whereTo || this.$el;
var self = this;
var $list = self.$list( $whereTo );
@@ -391,7 +391,7 @@ var HistoryView = _super.extend(
contents.setIncludeDeleted( show, options );
self.trigger( 'show-deleted', show );
contents.fetchCurrentPage();
contents.fetchCurrentPage({ renderAll: true });
return show;
},
@@ -399,13 +399,14 @@ var HistoryView = _super.extend(
* @returns {Boolean} new setting
*/
toggleShowHidden : function( show, store, options ){
// console.log( 'toggleShowHidden', show, store );
show = ( show !== undefined )?( show ):( !this.model.contents.includeHidden );
var self = this;
var contents = self.model.contents;
contents.setIncludeHidden( show, options );
self.trigger( 'show-hidden', show );
contents.fetchCurrentPage();
contents.fetchCurrentPage({ renderAll: true });
return show;
},
@@ -596,7 +597,7 @@ HistoryView.prototype.templates = (function(){
var paginationTemplate = BASE_MVC.wrapTemplate([
'<button class="prev" <%- pages.current === 1 ? "disabled" : "" %>>previous</button>',
'<select class="pages form-control" ',
'title="', _l( 'Click to open and select a page. Begin typing a page number to jump to it' ), '">',
'title="', _l( 'Click to open and select a page. Begin typing a page number to select it' ), '">',
'<% _.range( 1, pages.last + 1 ).forEach( function( i ){ %>',
'<option value="<%- i - 1 %>" <%- i === pages.current ? "selected" : "" %>>',
'<%- view.ordinalIndicator( i ) %> of <%- pages.last %> pages',
+6 -4
View File
@@ -153,17 +153,19 @@ var ListPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend(/** @lends
this.trigger( 'error', model, xhr, options, msg, details );
},
update : function( collection, options ){
this.info( 'update:', collection, options, '\n', options.changes );
var changes = options.changes;
// console.info( collection + ', update:', changes, '\noptions:', options );
// more than one: render everything
if( options.renderAll || ( changes.added.length + changes.removed.length > 1 ) ){
return this.renderItems();
}
// otherwise, let the single add/remove handlers do it
if( changes.added.length === 1 ){
return this.addItemView( _.first( changes.added ), collection, options );
}
if( changes.removed.length === 1 ){
return this.removeItemView( _.first( changes.removed ), collection, options );
}
if( changes.added.length + changes.removed.length > 1 ){
return this.renderItems();
}
}
});
return this;
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+11 -8
View File
@@ -18281,7 +18281,7 @@ webpackJsonp([0,1],[
/** override to render pagination also */
renderItems: function( $whereTo ){
console.log( this + '.renderItems-----------------', new Date() );
// console.log( this + '.renderItems-----------------', new Date() );
$whereTo = $whereTo || this.$el;
var self = this;
var $list = self.$list( $whereTo );
@@ -18431,7 +18431,7 @@ webpackJsonp([0,1],[
contents.setIncludeDeleted( show, options );
self.trigger( 'show-deleted', show );
contents.fetchCurrentPage();
contents.fetchCurrentPage({ renderAll: true });
return show;
},
@@ -18439,13 +18439,14 @@ webpackJsonp([0,1],[
* @returns {Boolean} new setting
*/
toggleShowHidden : function( show, store, options ){
// console.log( 'toggleShowHidden', show, store );
show = ( show !== undefined )?( show ):( !this.model.contents.includeHidden );
var self = this;
var contents = self.model.contents;
contents.setIncludeHidden( show, options );
self.trigger( 'show-hidden', show );
contents.fetchCurrentPage();
contents.fetchCurrentPage({ renderAll: true });
return show;
},
@@ -18636,7 +18637,7 @@ webpackJsonp([0,1],[
var paginationTemplate = BASE_MVC.wrapTemplate([
'<button class="prev" <%- pages.current === 1 ? "disabled" : "" %>>previous</button>',
'<select class="pages form-control" ',
'title="', _l( 'Click to open and select a page. Begin typing a page number to jump to it' ), '">',
'title="', _l( 'Click to open and select a page. Begin typing a page number to select it' ), '">',
'<% _.range( 1, pages.last + 1 ).forEach( function( i ){ %>',
'<option value="<%- i - 1 %>" <%- i === pages.current ? "selected" : "" %>>',
'<%- view.ordinalIndicator( i ) %> of <%- pages.last %> pages',
@@ -18824,17 +18825,19 @@ webpackJsonp([0,1],[
this.trigger( 'error', model, xhr, options, msg, details );
},
update : function( collection, options ){
this.info( 'update:', collection, options, '\n', options.changes );
var changes = options.changes;
// console.info( collection + ', update:', changes, '\noptions:', options );
// more than one: render everything
if( options.renderAll || ( changes.added.length + changes.removed.length > 1 ) ){
return this.renderItems();
}
// otherwise, let the single add/remove handlers do it
if( changes.added.length === 1 ){
return this.addItemView( _.first( changes.added ), collection, options );
}
if( changes.removed.length === 1 ){
return this.removeItemView( _.first( changes.removed ), collection, options );
}
if( changes.added.length + changes.removed.length > 1 ){
return this.renderItems();
}
}
});
return this;
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long