UI, history: move show deleted/hidden into content

- Move d/h (deleted/hidden) control into history contents
- normalize names (show_deleted, showDeleted --> includeDeleted)
- add History.contentsShown that checks d/h flags to return num. shown
- move HistoryPreferences into HistoryContents.storage

Misc. fixes:
- fix collection.off to stopListening
- provide interface to HistoryPreferences so that consumers don't need
the model keys (easier to change them later on)
- (some) cleanup
This commit is contained in:
carlfeberhard
2016-05-02 15:47:25 -04:00
parent a7c7af94af
commit 7a6794e104
32 changed files with 237 additions and 55328 deletions
@@ -28,31 +28,25 @@ var HistoryContentMixin = {
// Instead, use type_id which prefixes the history_content_type so the bbone collection can differentiate
idAttribute : 'type_id',
/** override because backbone tests boolean( idAttribute ), but it's not an empty string even for new models
* due to our use of type_id.
*/
// isNew : function(){
// return !this.get( 'id' );
// },
// ........................................................................ common queries
/** the more common alias of visible */
hidden : function(){
return !this.get( 'visible' );
},
/** based on show_deleted, show_hidden (gen. from the container control),
//TODO: remove
/** based on includeDeleted, includeHidden (gen. from the container control),
* would this ds show in the list of ds's?
* @param {Boolean} show_deleted are we showing deleted hdas?
* @param {Boolean} show_hidden are we showing hidden hdas?
* @param {Boolean} includeDeleted are we showing deleted hdas?
* @param {Boolean} includeHidden are we showing hidden hdas?
*/
isVisible : function( show_deleted, show_hidden ){
isVisible : function( includeDeleted, includeHidden ){
var isVisible = true;
if( ( !show_deleted )
if( ( !includeDeleted )
&& ( this.get( 'deleted' ) || this.get( 'purged' ) ) ){
isVisible = false;
}
if( ( !show_hidden )
if( ( !includeHidden )
&& ( !this.get( 'visible' ) ) ){
isVisible = false;
}
@@ -23,6 +23,7 @@ var _super = CONTROLLED_FETCH_COLLECTION.ControlledFetchCollection;
var HistoryContents = _super.extend( BASE_MVC.LoggableMixin ).extend({
_logNamespace : 'history',
// ........................................................................ composite collection
/** since history content is a mix, override model fn into a factory, creating based on history_content_type */
model : function( attrs, options ) {
if( attrs.history_content_type === "dataset" ) {
@@ -46,6 +47,7 @@ var HistoryContents = _super.extend( BASE_MVC.LoggableMixin ).extend({
return { validationError : 'Unknown history_content_type: ' + attrs.history_content_type };
},
// ........................................................................ set up
/** @type {Number} limit used for the first fetch (or a reset) */
limitOnFirstFetch : 500,
/** @type {Number} limit used for each subsequent fetch */
@@ -54,31 +56,6 @@ var HistoryContents = _super.extend( BASE_MVC.LoggableMixin ).extend({
/** @type {String} order used here and when fetching from server */
order : 'hid',
/** Set up */
initialize : function( models, options ){
options = options || {};
_super.prototype.initialize.call( this, models, options );
this.history = options.history || null;
this.historyId = options.historyId || null;
// backbonejs uses collection.model.prototype.idAttribute to determine if a model is *already* in a collection
// and either merged or replaced. In this case, our 'model' is a function so we need to add idAttribute
// manually here - if we don't, contents will not merge but be replaced/swapped.
this.model.prototype.idAttribute = 'type_id';
/** @type {Boolean} does this collection contain and fetch deleted elements */
this.includeDeleted = options.includeDeleted || false;
/** @type {Boolean} does this collection contain and fetch non-visible elements */
this.includeHidden = options.includeHidden || false;
this.on( 'all', function(){
var args = _.toArray( arguments );
if( /^change:*/.test( args[0] ) ){ return; }
console.log.apply( console, [ this + '' ].concat( args ) );
});
},
/** root api url */
urlRoot : Galaxy.root + 'api/histories',
@@ -87,6 +64,58 @@ var HistoryContents = _super.extend( BASE_MVC.LoggableMixin ).extend({
return this.urlRoot + '/' + this.historyId + '/contents';
},
/** Set up */
initialize : function( models, options ){
options = options || {};
_super.prototype.initialize.call( this, models, options );
this.history = options.history || null;
this.setHistoryId( options.historyId || null );
/** @type {Boolean} does this collection contain and fetch deleted elements */
this.includeDeleted = options.includeDeleted || this.includeDeleted;
/** @type {Boolean} does this collection contain and fetch non-visible elements */
this.includeHidden = options.includeHidden || this.includeHidden;
// backbonejs uses collection.model.prototype.idAttribute to determine if a model is *already* in a collection
// and either merged or replaced. In this case, our 'model' is a function so we need to add idAttribute
// manually here - if we don't, contents will not merge but be replaced/swapped.
this.model.prototype.idAttribute = 'type_id';
// this.on( 'all', function(){
// var args = _.toArray( arguments );
// if( /^change:*/.test( args[0] ) ){ return; }
// console.log.apply( console, [ this + '' ].concat( args ) );
// });
},
setHistoryId : function( newId ){
this.historyId = newId;
this._setUpWebStorage();
},
/** Set up client side storage. Currently PersistanStorage keyed under 'history:<id>' */
_setUpWebStorage : function( initialSettings ){
// TODO: use initialSettings
if( !this.historyId ){ return; }
this.storage = new HISTORY_PREFS.HistoryPrefs({
id: HISTORY_PREFS.HistoryPrefs.historyStorageKey( this.historyId )
});
this.trigger( 'new-storage', this.storage, this );
this.on({
'change:include-deleted' : function( newVal ){
this.storage.includeDeleted( newVal );
},
'change:include-hidden' : function( newVal ){
this.storage.includeHidden( newVal );
}
});
this.includeDeleted = this.storage.includeDeleted() || false;
this.includeHidden = this.storage.includeHidden() || false;
return this;
},
// ........................................................................ common queries
/** @type {Object} map of collection available sorting orders containing comparator fns */
comparators : _.extend( _.clone( _super.prototype.comparators ), {
@@ -145,17 +174,22 @@ var HistoryContents = _super.extend( BASE_MVC.LoggableMixin ).extend({
},
/** create a setter in order to publish the change */
setIncludeDeleted : function( setting ){
setIncludeDeleted : function( setting, options ){
if( _.isBoolean( setting ) && setting !== this.includeDeleted ){
this.includeDeleted = setting;
if( _.result( options, 'silent' ) ){ return; }
// TODO: change from change:
this.trigger( 'change:include-deleted', setting, this );
}
},
/** create a setter in order to publish the change */
setIncludeHidden : function( setting ){
setIncludeHidden : function( setting, options ){
if( _.isBoolean( setting ) && setting !== this.includeHidden ){
this.includeHidden = setting;
options = options || {};
if( _.result( options, 'silent' ) ){ return; }
// TODO: change from change:
this.trigger( 'change:include-hidden', setting, this );
}
},
@@ -531,9 +565,9 @@ var HidSectionedHistoryContents = HistoryContents.extend({
var hid = content.get( 'hid' );
if( descending ){
if( hid < range.first ){ console.log( '< first' ); break; }
if( hid < range.first ){ break; }
} else {
if( hid > range.last ){ console.log( '> last' ); break; }
if( hid > range.last ){ break; }
}
subcollection.push( content );
}
@@ -600,7 +634,7 @@ var HidSectionedHistoryContents = HistoryContents.extend({
fetchFirst : function( options ){
_.extend( options || {}, { silent: true });
// console.log( 'fetchFirst?' );
// console.log( 'fetchFirst?', options );
this.currentSection = 0;
if( this.order === 'hid' && this._countSections() > 1 ){
this.currentSection = this._lastFullSection();
@@ -40,16 +40,15 @@ var History = Backbone.Model
// ........................................................................ set up/tear down
/** Set up the model
* @param {Object} historyJSON model data for this History
* @param {Object[]} contentsJSON array of model data for this History's contents (hdas or collections)
* @param {Object} options any extra settings including logger
*/
initialize : function( historyJSON, contentsJSON, options ){
initialize : function( historyJSON, options ){
options = options || {};
this.logger = options.logger || null;
this.log( this + ".initialize:", historyJSON, contentsJSON, options );
this.log( this + ".initialize:", historyJSON, options );
/** HistoryContents collection of the HDAs contained in this history. */
this.contents = new HISTORY_CONTENTS.HistoryContents( contentsJSON || [], {
this.contents = new HISTORY_CONTENTS.HistoryContents( [], {
history : this,
historyId : this.get( 'id' ),
order : options.order,
@@ -91,6 +90,15 @@ var History = Backbone.Model
},
// ........................................................................ derived attributes
/** */
contentsShown : function(){
var contentsActive = this.get( 'contents_active' );
var shown = contentsActive.active || 0;
shown += this.contents.includeDeleted? contentsActive.deleted : 0;
shown += this.contents.includeHidden? contentsActive.hidden : 0;
return shown;
},
/** convert size in bytes to a more human readable version */
nice_size : function(){
return UTILS.bytesToString( this.get( 'size' ), true, 2 );
@@ -246,7 +254,7 @@ var History = Backbone.Model
// fetch history then use history data to fetch (paginated) contents
return this.fetch( options ).pipe( function getContents( history ){
self.contents.history = self;
self.contents.historyId = history.id;
self.contents.setHistoryId( history.id );
return self.fetchContents( contentsOptions );
});
},
@@ -255,11 +263,6 @@ var History = Backbone.Model
fetchContents : function( options ){
options = options || {};
var self = this;
// now that we have a history id, we can read the prefs
// and make the contents fetch based on those
var prefs = HISTORY_PREFS.HistoryPrefs.get( self.id ).toJSON();
self.contents.includeDeleted = prefs.show_deleted;
self.contents.includeHidden = prefs.show_hidden;
// we're updating, reset the update time
self.lastUpdateTime = new Date();
@@ -20,14 +20,42 @@ var HistoryPrefs = BASE_MVC.SessionStorageModel.extend(
/** add an hda id to the hash of expanded hdas */
addExpanded : function( model ){
var key = 'expandedIds';
this.save( key, _.extend( this.get( key ), _.object([ model.id ], [ model.get( 'id' ) ]) ) );
//TODO: use type_id and not model
var current = this.get( 'expandedIds' );
current[ model.id ] = model.get( 'id' );
this.save( 'expandedIds', current );
},
/** remove an hda id from the hash of expanded hdas */
removeExpanded : function( model ){
var key = 'expandedIds';
this.save( key, _.omit( this.get( key ), model.id ) );
var current = this.get( 'expandedIds' );
delete current[ model.id ];
this.save( 'expandedIds', current );
},
isExpanded : function( contentId ){
return _.result( this.get( 'expandedIds' ), contentId, false );
},
allExpanded : function(){
return _.values( this.get( 'expandedIds' ) );
},
clearExpanded : function(){
this.set( 'expandedIds', {} );
},
includeDeleted : function( val ){
// moving the invocation here so other components don't need to know the key
// TODO: change this key later
if( !_.isUndefined( val ) ){ this.set( 'show_deleted', val ); }
return this.get( 'show_deleted' );
},
includeHidden : function( val ){
// TODO: change this key later
if( !_.isUndefined( val ) ){ this.set( 'show_hidden', val ); }
return this.get( 'show_hidden' );
},
toString : function(){
@@ -141,12 +141,12 @@ var CurrentHistoryView = _super.extend(/** @lends CurrentHistoryView.prototype *
/** listening for collection events */
_setUpCollectionListeners : function(){
_super.prototype._setUpCollectionListeners.call( this );
//TODO:?? may not be needed? see history-view-edit, 369
//TODO:?? may not be needed? see history-view-edit, _handleItemVisibleChange
// if a hidden item is created (gen. by a workflow), moves thru the updater to the ready state,
// then: remove it from the collection if the panel is set to NOT show hidden datasets
this.listenTo( this.collection, 'state:ready', function( model, newState, oldState ){
if( ( !model.get( 'visible' ) )
&& ( !this.storage.get( 'show_hidden' ) ) ){
&& ( !this.collection.storage.includeHidden() ) ){
this.removeItemView( model );
}
});
@@ -316,17 +316,18 @@ var HistoryViewEdit = _super.extend(
* @param {Model} the item model to check
*/
_handleItemDeletionChange : function( itemModel ){
// console.log( '_handleItemDeletionChange:', contentsShown, itemModel.get( 'deleted' ), this.showDeleted );
var contents = this.model.contents;
var contentsShown = this.model.get( 'contents_active' );
// console.log( '_handleItemDeletionChange:', contentsShown, itemModel.get( 'deleted' ), contents.includeDeleted );
if( itemModel.get( 'deleted' ) ){
contentsShown.deleted += 1;
if( !this.showDeleted ){
if( !contents.includeDeleted ){
this.removeItemView( itemModel );
}
contentsShown.active -= 1;
} else {
contentsShown.deleted -= 1;
if( !this.showDeleted ){
if( !contents.includeDeleted ){
contentsShown.active -= 1;
}
}
@@ -339,17 +340,18 @@ var HistoryViewEdit = _super.extend(
* @param {Model} the item model to check
*/
_handleItemVisibleChange : function( itemModel ){
var contents = this.model.contents;
var contentsShown = this.model.get( 'contents_active' );
// console.log( '_handleHdaVisibleChange:', contentsShown, itemModel.hidden(), this.showHidden );
// console.log( '_handleItemDeletionChange:', contentsShown, itemModel.get( 'deleted' ), contents.includeHidden );
if( itemModel.hidden() ){
contentsShown.hidden += 1;
if( !this.showHidden ){
if( !contents.includeHidden ){
this.removeItemView( itemModel );
}
contentsShown.active -= 1;
} else {
contentsShown.hidden -= 1;
if( !this.showHidden ){
if( !contents.includeHidden ){
contentsShown.active -= 1;
}
}
@@ -519,7 +521,7 @@ HistoryViewEdit.prototype.templates = (function(){
'<% if( history.contents_active.deleted ){ %>',
'<span class="deleted-count">',
'<% if( view.showDeleted ){ %>',
'<% if( view.model.contents.includeDeleted ){ %>',
'<a class="toggle-deleted-link" href="javascript:void(0);">',
_l( 'hide deleted' ),
'</a>',
@@ -534,7 +536,7 @@ HistoryViewEdit.prototype.templates = (function(){
'<% if( history.contents_active.hidden ){ %>',
'<span class="hidden-count">',
'<% if( view.showHidden ){ %>',
'<% if( view.model.contents.includeHidden ){ %>',
'<a class="toggle-hidden-link" href="javascript:void(0);">',
_l( 'hide hidden' ),
'</a>',
+48 -107
View File
@@ -138,24 +138,6 @@ var HistoryView = _super.extend(
return $.when();
},
/** release/free/shutdown old models and set up panel for new models
* @fires new-model with the panel as parameter
*/
setModel : function( model, attributes ){
_super.prototype.setModel.call( this, model, attributes );
if( this.model ){
this._setUpWebStorage();
}
},
/** Override to reset web storage when the id changes (since it needs the id) */
_setUpModelListeners : function(){
_super.prototype._setUpModelListeners.call( this );
return this.listenTo( this.model, {
'change:id' : this._setUpWebStorage,
});
},
/** Override to reset web storage when the id changes (since it needs the id) */
_setUpCollectionListeners : function(){
_super.prototype._setUpCollectionListeners.call( this );
@@ -166,38 +148,6 @@ var HistoryView = _super.extend(
});
},
// ------------------------------------------------------------------------ browser stored prefs
/** Set up client side storage. Currently PersistanStorage keyed under 'history:<id>'
* @see PersistentStorage
*/
_setUpWebStorage : function(){
if( !this.model || !this.model.id ){ return this; }
//this.log( '_setUpWebStorage', initiallyExpanded, show_deleted, show_hidden );
if( this.storage ){
this.stopListening( this.storage );
}
this.storage = new HISTORY_PREFS.HistoryPrefs({
id: HISTORY_PREFS.HistoryPrefs.historyStorageKey( this.model.get( 'id' ) )
});
this.trigger( 'new-storage', this.storage, this );
this.log( this + ' (init\'d) storage:', this.storage.get() );
// TODO: reverse this - have storage reflect what's used in the view and not visversa
this.listenTo( this.storage, {
'change:show_deleted' : function( view, newVal ){
this.showDeleted = newVal;
},
'change:show_hidden' : function( view, newVal ){
this.showHidden = newVal;
}
}, this );
this.showDeleted = this.storage.get( 'show_deleted' ) || false;
this.showHidden = this.storage.get( 'show_hidden' ) || false;
return this;
},
// ------------------------------------------------------------------------ panel rendering
/** In this override, add a btn to toggle the selectors */
_buildNewRender : function(){
@@ -250,7 +200,7 @@ var HistoryView = _super.extend(
// ------------------------------------------------------------------------ client-side pagination
/** */
renderItems : function( $whereTo ){
console.log( 'renderItems -----------------------------------------------------------' );
// console.log( 'renderItems -----------------------------------------------------------' );
$whereTo = $whereTo || this.$el;
var self = this;
var contents = self.model.contents;
@@ -258,9 +208,9 @@ var HistoryView = _super.extend(
self.freeViews();
// render sections
console.log( 'renderItems:', self.$list( $whereTo ) );
// console.log( 'renderItems:', self.$list( $whereTo ) );
self.$list( $whereTo ).html( contents._mapSectionRanges( function( section ){
console.log( 'renderItems:', section );
// console.log( 'renderItems:', section );
return self.templates.listItemsSection( section, self );
}).join( '\n' ));
// render content views into (only) the current section
@@ -268,12 +218,12 @@ var HistoryView = _super.extend(
self._renderEmptyMessage( $whereTo ).toggle( !self.views.length );
self.trigger( 'views:ready', self.views );
console.log( '----------------------------------------------------------- renderItems' );
// console.log( '----------------------------------------------------------- renderItems' );
return self.views;
},
_renderSection : function( section, $whereTo ){
console.debug( this + '._renderSection', section, $whereTo );
// console.debug( this + '._renderSection', section, $whereTo );
var self = this;
// render views from collection for the current section, replacing that section marker with them
// note: shows only one section's worth of views at a time
@@ -298,12 +248,13 @@ var HistoryView = _super.extend(
},
// ------------------------------------------------------------------------ sub-views
/** in this override, check if the contents would also display based on show_deleted/hidden */
/** in this override, check if the contents would also display based on includeDeleted/hidden */
_filterItem : function( model ){
var panel = this;
return ( _super.prototype._filterItem.call( panel, model )
&& ( !model.hidden() || panel.showHidden )
&& ( !model.isDeletedOrPurged() || panel.showDeleted ) );
var self = this;
var contents = self.model.contents;
return ( contents.includeHidden || !model.hidden() )
&& ( contents.includeDeleted || !model.isDeletedOrPurged() )
&& ( _super.prototype._filterItem.call( self, model ) );
},
/** In this override, since history contents are mixed,
@@ -325,7 +276,7 @@ var HistoryView = _super.extend(
var options = _super.prototype._getItemViewOptions.call( this, model );
return _.extend( options, {
linkTarget : this.linkTarget,
expanded : !!this.storage.get( 'expandedIds' )[ model.id ],
expanded : this.model.contents.storage.isExpanded( model.id ),
hasUser : this.model.ownedByCurrUser()
});
},
@@ -334,21 +285,21 @@ var HistoryView = _super.extend(
_setUpItemViewListeners : function( view ){
var panel = this;
_super.prototype._setUpItemViewListeners.call( panel, view );
//TODO:?? could use 'view:expanded' here?
//TODO: send from content view: this.model.collection.storage.addExpanded
// maintain a list of items whose bodies are expanded
return panel.listenTo( view, {
'expanded': function( v ){
panel.storage.addExpanded( v.model );
panel.model.contents.storage.addExpanded( v.model );
},
'collapsed': function( v ){
panel.storage.removeExpanded( v.model );
panel.model.contents.storage.removeExpanded( v.model );
}
});
},
/** override to remove expandedIds from webstorage */
collapseAll : function(){
this.storage.set( 'expandedIds', {} );
this.model.contents.storage.clearExpanded();
_super.prototype.collapseAll.call( this );
},
@@ -376,35 +327,35 @@ var HistoryView = _super.extend(
}
self.scrollTo( 0 );
console.log( 'contains?', contents.contains( model ) );
console.log( 'get:', contents.get( model.id ) + '' );
console.log( contents.length );
// console.log( 'contains?', contents.contains( model ) );
// console.log( 'get:', contents.get( model.id ) + '' );
// console.log( contents.length );
// contents.on( 'all', console.info, console );
console.log( '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^' );
// console.log( '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^' );
var hid = model.get( 'hid' );
var insertionIndex = contents._indexOfHidInSection( hid, contents.currentSection );
console.log( hid, insertionIndex, contents.at( insertionIndex ) + '' );
console.log( contents.at( insertionIndex - 1 ) + '', contents.at( insertionIndex + 1 ) + '' );
// console.log( hid, insertionIndex, contents.at( insertionIndex ) + '' );
// console.log( contents.at( insertionIndex - 1 ) + '', contents.at( insertionIndex + 1 ) + '' );
if( insertionIndex === null ){ return null; }
//TODO: this should happen elsewhere
// have to manually update the hid_counter
self.model.set( 'hid_counter', self.model.get( 'hid_counter' ) + 1 );
console.log( 'hid_counter:', self.model.get( 'hid_counter' ) );
// console.log( 'hid_counter:', self.model.get( 'hid_counter' ) );
console.log( 'at index', insertionIndex, 'adding: ' + model );
// console.log( 'at index', insertionIndex, 'adding: ' + model );
var view = self._createItemView( model );
self.$emptyMessage().fadeOut( self.fxSpeed );
self._attachView( view, insertionIndex );
console.log( '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^' );
// console.log( '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^' );
return view;
},
/** */
_attachView : function( view, modelIndex, useFx ){
console.log( '_attachView:', view, modelIndex, useFx );
// console.log( '_attachView:', view, modelIndex, useFx );
useFx = _.isUndefined( useFx )? true : useFx;
var self = this;
var $el = self._renderItemView$el( view ).hide();
@@ -412,19 +363,18 @@ var HistoryView = _super.extend(
// Im not sure any of this shit is needed - (it prob. isn't *when adding to the last section*)
var viewIndex = 0;
var prevModel = self.model.contents.at( modelIndex - 1 );
window.prevModel = prevModel;
console.log( 'prevModel: ' + prevModel, prevModel );
// console.log( 'prevModel: ' + prevModel, prevModel );
if( prevModel ){
var found = _.findIndex( self.views, function( v ){
console.log( ' ', v + '', v.model + '' );
console.log( ' ', v.model === prevModel );
// console.log( ' ', v + '', v.model + '' );
// console.log( ' ', v.model === prevModel );
return v.model === prevModel;
});
console.log( 'found:', found );
// console.log( 'found:', found );
if( found !== -1 ){ viewIndex = found + 1; }
}
// var viewIndex = Math.max( 0, _.findIndex( self.views, function( v ){ return v.model === prevModel; }) );
console.log( 'viewIndex:', viewIndex );
// console.log( 'viewIndex:', viewIndex );
self.views.splice( viewIndex, 0, view );
if( viewIndex === 0 ){
@@ -432,12 +382,12 @@ var HistoryView = _super.extend(
} else {
var prevView = self.views[ viewIndex ];
console.log( 'prevView:', prevView + '', prevView.$el.get(0) );
console.log( prevView.$el.parent().get(0) );
// console.log( 'prevView:', prevView + '', prevView.$el.get(0) );
// console.log( prevView.$el.parent().get(0) );
// $el.insertAfter( prevView.$el );
self.$currentSection().children( '.history-content' ).eq( viewIndex - 1 ).after( $el );
}
console.log( 'self.views[ viewIndex ]:', self.views[ viewIndex ] );
// console.log( 'self.views[ viewIndex ]:', self.views[ viewIndex ] );
self.trigger( 'view:attached', view );
if( useFx ){
@@ -515,42 +465,33 @@ var HistoryView = _super.extend(
},
/** Toggle and store the deleted visibility and re-render items
* @returns {Boolean} new show_deleted setting
* @returns {Boolean} new setting
*/
toggleShowDeleted : function( show, store ){
show = ( show !== undefined )?( show ):( !this.showDeleted );
store = ( store !== undefined )?( store ):( true );
toggleShowDeleted : function( show, options ){
show = ( show !== undefined )?( show ):( !this.model.contents.includeDeleted );
var self = this;
self.showDeleted = show;
//TODO: at this point deleted/hidden makes more sense (simpler) in the collection
self.model.contents.includeDeleted = show;
var contents = self.model.contents;
contents.setIncludeDeleted( show, options );
self.trigger( 'show-deleted', show );
if( store ){ self.storage.set( 'show_deleted', show ); }
var fetch = show? fetchDeletedInSection( self.model.contents.currentSection ) : jQuery.when();
var fetch = show? contents.fetchDeletedInSection( contents.currentSection ) : jQuery.when();
fetch.done( function(){ self.renderItems(); });
return self.showDeleted;
return contents.includeDeleted;
},
/** Toggle and store whether to render explicity hidden contents
* @returns {Boolean} new show_hidden setting
* @returns {Boolean} new setting
*/
toggleShowHidden : function( show, store ){
show = ( show !== undefined )?( show ):( !this.showHidden );
store = ( store !== undefined )?( store ):( true );
toggleShowHidden : function( show, store, options ){
show = ( show !== undefined )?( show ):( !this.model.contents.includeHidden );
var self = this;
self.showHidden = show;
self.model.contents.includeHidden = show;
var contents = self.model.contents;
contents.setIncludeHidden( show, options );
self.trigger( 'show-hidden', show );
if( store ){
self.storage.set( 'show_hidden', show );
}
var fetch = show? fetchHiddenInSection( self.model.contents.currentSection ) : jQuery.when();
var fetch = show? contents.fetchHiddenInSection( contents.currentSection ) : jQuery.when();
fetch.done( function(){ self.renderItems(); });
return self.showDeleted;
return contents.includeHidden;
},
/** On the first search, if there are no details - load them, then search */
@@ -682,18 +682,20 @@ var MultiPanelColumns = Backbone.View.extend( baseMVC.LoggableMixin ).extend({
* queueing the ajax call and using a named queue to prevent the call being sent twice
*/
queueHdaFetch : function queueHdaFetch( column ){
// console.log( column.model + '.contentsShown:', column.model.contentsShown() );
var contents = column.model.contents;
// console.log( 'queueHdaFetch:', column, column.model.get( 'contents_active' ) );
// if the history model says it has hdas but none are present, queue an ajax req for them
if( column.model.contents.length === 0 && column.model.get( 'contents_active' ).active ){
// console.log( 'fetch needed: ' + column );
if( contents.length === 0 && column.model.contentsShown() ){
console.log( 'fetch needed: ' + column );
var fetchOptions = { silent: true };
var ids = _.values( column.panel.storage.get( 'expandedIds' ) ).join();
var ids = _.values( contents.storage.allExpanded() ).join();
if( ids ){ fetchOptions.details = ids; }
// this uses a 'named' queue so that duplicate requests are ignored
this.hdaQueue.add({
name : column.model.id,
fn : function(){
return column.model.contents.fetchFirst( fetchOptions )
return contents.fetchFirst( fetchOptions )
.done( function(){ column.panel.renderItems(); });
}
});
@@ -704,13 +706,14 @@ var MultiPanelColumns = Backbone.View.extend( baseMVC.LoggableMixin ).extend({
/** Get the *detailed* json for *all* of a column's history's contents - req'd for searching */
queueHdaFetchDetails : function( column ){
if( ( column.model.contents.length === 0 && column.model.get( 'contents_active' ).active )
|| ( !column.model.contents.haveDetails() ) ){
var contents = column.model.contents;
var needsContentsLoaded = contents.length === 0 && column.model.contentsShown();
if( needsContentsLoaded || !contents.haveDetails() ){
// this uses a 'named' queue so that duplicate requests are ignored
this.hdaQueue.add({
name : column.model.id,
fn : function(){
return column.model.contents.progressivelyFetchDetails()
return contents.progressivelyFetchDetails()
.done( function(){ column.panel._renderEmptyMessage(); });
}
});
+3 -3
View File
@@ -157,14 +157,14 @@ var ListPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend(/** @lends
/** create and return a collection for when none is initially passed */
_createDefaultCollection : function(){
// override
console.log( '(_createDefaultCollection)' );
// console.log( '(_createDefaultCollection)' );
return new this.collectionClass([]);
},
/** listening for collection events */
_setUpCollectionListeners : function(){
this.log( this + '._setUpCollectionListeners', this.collection );
this.collection.off();
this.stopListening( this.collection );
// bubble up error events
this.listenTo( this.collection, {
@@ -960,8 +960,8 @@ var ModelListPanel = ListPanel.extend({
//TODO: relation btwn model, collection becoming tangled here
// free the collection, and assign the new collection to either
// the model[ modelCollectionKey ], attributes.collection, or an empty vanilla collection
this.collection.off();
// console.log( this + '(ModelListPanel) creating collection:', this.modelCollectionKey, this.model[ this.modelCollectionKey ] );
this.stopListening( this.collection );
this.collection = this.model[ this.modelCollectionKey ]
|| attributes.collection
|| this._createDefaultCollection();
@@ -1 +1 @@
{"version":3,"file":"history-content-model.js","sources":["../../../src/mvc/history/history-content-model.js"],"names":["define","HistoryContentMixin","defaults","history_id","history_content_type","hid","visible","idAttribute","hidden","this","get","isVisible","show_deleted","show_hidden","urlRoot","Galaxy","root","url","hide","options","save","jQuery","when","unhide","toString","join"],"mappings":"AAAAA,QACI,qBACA,eACA,sBACD,WACH,YAKA,IAAIC,IAGAC,UAEIC,WAAsB,KAEtBC,qBAAsB,KAEtBC,IAAsB,KAEtBC,SAAsB,GAO1BC,YAAc,UAWdC,OAAS,WACL,OAAQC,KAAKC,IAAK,YAQtBC,UAAY,SAAUC,EAAcC,GAChC,GAAIF,IAAY,CAShB,OAROC,KACDH,KAAKC,IAAK,aAAeD,KAAKC,IAAK,YACrCC,GAAY,GAETE,GACAJ,KAAKC,IAAK,aACbC,GAAY,GAETA,GAMXG,QAASC,OAAOC,KAAO,iBAGvBC,IAAM,WACF,GAAIA,GAAMR,KAAKK,QAAUL,KAAKC,IAAK,cAAiB,aAC7CD,KAAKC,IAAI,wBAA0B,KAAOD,KAAKC,IAAK,KAC3D,OAAOO,IAIXC,KAAO,SAAUC,GACb,MAAKV,MAAKC,IAAK,WACRD,KAAKW,MAAQd,SAAS,GAASa,GADDE,OAAOC,QAIhDC,OAAS,SAAUJ,GACf,MAAIV,MAAKC,IAAK,WAAsBW,OAAOC,OACpCb,KAAKW,MAAQd,SAAS,GAAQa,IAIzCK,SAAW,WACP,OAAUf,KAAKC,IAAK,WAAaD,KAAKC,IAAK,OAASD,KAAKC,IAAK,SAAWe,KAAK,MAMlF,QACIxB,oBAAsBA"}
{"version":3,"file":"history-content-model.js","sources":["../../../src/mvc/history/history-content-model.js"],"names":["define","HistoryContentMixin","defaults","history_id","history_content_type","hid","visible","idAttribute","hidden","this","get","isVisible","includeDeleted","includeHidden","urlRoot","Galaxy","root","url","hide","options","save","jQuery","when","unhide","toString","join"],"mappings":"AAAAA,QACI,qBACA,eACA,sBACD,WACH,YAKA,IAAIC,IAGAC,UAEIC,WAAsB,KAEtBC,qBAAsB,KAEtBC,IAAsB,KAEtBC,SAAsB,GAO1BC,YAAc,UAIdC,OAAS,WACL,OAAQC,KAAKC,IAAK,YAStBC,UAAY,SAAUC,EAAgBC,GAClC,GAAIF,IAAY,CAShB,OAROC,KACDH,KAAKC,IAAK,aAAeD,KAAKC,IAAK,YACrCC,GAAY,GAETE,GACAJ,KAAKC,IAAK,aACbC,GAAY,GAETA,GAMXG,QAASC,OAAOC,KAAO,iBAGvBC,IAAM,WACF,GAAIA,GAAMR,KAAKK,QAAUL,KAAKC,IAAK,cAAiB,aAC7CD,KAAKC,IAAI,wBAA0B,KAAOD,KAAKC,IAAK,KAC3D,OAAOO,IAIXC,KAAO,SAAUC,GACb,MAAKV,MAAKC,IAAK,WACRD,KAAKW,MAAQd,SAAS,GAASa,GADDE,OAAOC,QAIhDC,OAAS,SAAUJ,GACf,MAAIV,MAAKC,IAAK,WAAsBW,OAAOC,OACpCb,KAAKW,MAAQd,SAAS,GAAQa,IAIzCK,SAAW,WACP,OAAUf,KAAKC,IAAK,WAAaD,KAAKC,IAAK,OAASD,KAAKC,IAAK,SAAWe,KAAK,MAMlF,QACIxB,oBAAsBA"}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
{"version":3,"file":"history-preferences.js","sources":["../../../src/mvc/history/history-preferences.js"],"names":["define","BASE_MVC","HistoryPrefs","SessionStorageModel","extend","defaults","expandedIds","show_deleted","show_hidden","addExpanded","model","key","this","save","_","get","object","id","removeExpanded","omit","toString","storageKeyPrefix","historyStorageKey","historyId","Error","clearAll","sessionStorage","indexOf","removeItem"],"mappings":"AAAAA,QACI,gBACD,SAAUC,GAEb,YAEA,IAIIC,GAAeD,EAASE,oBAAoBC,QAG5CC,UAEIC,eACAC,cAAe,EACfC,aAAe,GAInBC,YAAc,SAAUC,GACpB,GAAIC,GAAM,aACVC,MAAKC,KAAMF,EAAKG,EAAEV,OAAQQ,KAAKG,IAAKJ,GAAOG,EAAEE,QAASN,EAAMO,KAAQP,EAAMK,IAAK,WAInFG,eAAiB,SAAUR,GACvB,GAAIC,GAAM,aACVC,MAAKC,KAAMF,EAAKG,EAAEK,KAAMP,KAAKG,IAAKJ,GAAOD,EAAMO,MAGnDG,SAAW,WACP,MAAO,gBAAkBR,KAAKK,GAAK,OAMvCI,iBAAmB,WAGnBC,kBAAoB,SAA4BC,GAC5C,IAAKA,EACD,KAAM,IAAIC,OAAO,kDAAoDD,EAGzE,OAASrB,GAAamB,iBAAmBE,GAI7CR,IAAM,SAAcQ,GAChB,MAAO,IAAIrB,IAAee,GAAIf,EAAaoB,kBAAmBC,MAIlEE,SAAW,WACP,IAAK,GAAId,KAAOe,gBACyC,IAAjDf,EAAIgB,QAASzB,EAAamB,mBAC1BK,eAAeE,WAAYjB,KAOvC,QACIT,aAAcA"}
{"version":3,"file":"history-preferences.js","sources":["../../../src/mvc/history/history-preferences.js"],"names":["define","BASE_MVC","HistoryPrefs","SessionStorageModel","extend","defaults","expandedIds","show_deleted","show_hidden","addExpanded","model","current","this","get","id","save","removeExpanded","isExpanded","contentId","_","result","allExpanded","values","clearExpanded","set","includeDeleted","val","isUndefined","includeHidden","toString","storageKeyPrefix","historyStorageKey","historyId","Error","clearAll","key","sessionStorage","indexOf","removeItem"],"mappings":"AAAAA,QACI,gBACD,SAAUC,GAEb,YAEA,IAIIC,GAAeD,EAASE,oBAAoBC,QAG5CC,UAEIC,eACAC,cAAe,EACfC,aAAe,GAInBC,YAAc,SAAUC,GAEpB,GAAIC,GAAUC,KAAKC,IAAK,cACxBF,GAASD,EAAMI,IAAOJ,EAAMG,IAAK,MACjCD,KAAKG,KAAM,cAAeJ,IAI9BK,eAAiB,SAAUN,GACvB,GAAIC,GAAUC,KAAKC,IAAK,qBACjBF,GAASD,EAAMI,IACtBF,KAAKG,KAAM,cAAeJ,IAG9BM,WAAa,SAAUC,GACnB,MAAOC,GAAEC,OAAQR,KAAKC,IAAK,eAAiBK,GAAW,IAG3DG,YAAc,WACV,MAAOF,GAAEG,OAAQV,KAAKC,IAAK,iBAG/BU,cAAgB,WACZX,KAAKY,IAAK,mBAGdC,eAAiB,SAAUC,GAIvB,MADKP,GAAEQ,YAAaD,IAASd,KAAKY,IAAK,eAAgBE,GAChDd,KAAKC,IAAK,iBAGrBe,cAAgB,SAAUF,GAGtB,MADKP,GAAEQ,YAAaD,IAASd,KAAKY,IAAK,cAAeE,GAC/Cd,KAAKC,IAAK,gBAGrBgB,SAAW,WACP,MAAO,gBAAkBjB,KAAKE,GAAK,OAMvCgB,iBAAmB,WAGnBC,kBAAoB,SAA4BC,GAC5C,IAAKA,EACD,KAAM,IAAIC,OAAO,kDAAoDD,EAGzE,OAAS9B,GAAa4B,iBAAmBE,GAI7CnB,IAAM,SAAcmB,GAChB,MAAO,IAAI9B,IAAeY,GAAIZ,EAAa6B,kBAAmBC,MAIlEE,SAAW,WACP,IAAK,GAAIC,KAAOC,gBACyC,IAAjDD,EAAIE,QAASnC,EAAa4B,mBAC1BM,eAAeE,WAAYH,KAOvC,QACIjC,aAAcA"}
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
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
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
+1 -56
View File
@@ -1,57 +1,2 @@
webpackJsonp([5],[
/* 0 */
/*!**************************************!*\
!*** ./galaxy/scripts/apps/login.js ***!
\**************************************/
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(_) {
var jQuery = __webpack_require__( /*! jquery */ 3 ),
$ = jQuery,
GalaxyApp = __webpack_require__( /*! galaxy */ 4 ).GalaxyApp,
PANEL = __webpack_require__( /*! layout/panel */ 12 ),
_l = __webpack_require__( /*! utils/localization */ 7 ),
PAGE = __webpack_require__( /*! layout/page */ 103 );
window.app = function app( options, bootstrapped ){
window.Galaxy = new GalaxyApp( options, bootstrapped );
Galaxy.debug( 'login app' );
var redirect = encodeURI( options.redirect );
// TODO: remove iframe for user login (at least) and render login page from here
// then remove this redirect
if( !options.show_welcome_with_login ){
var params = jQuery.param({ use_panels : 'True', redirect : redirect });
window.location.href = Galaxy.root + 'user/login?' + params;
return;
}
var loginPage = new PAGE.PageLayoutView( _.extend( options, {
el : 'body',
center : new PANEL.CenterPanel({ el : '#center' }),
right : new PANEL.RightPanel({
title : _l( 'Login required' ),
el : '#right'
}),
}));
$(function(){
// TODO: incorporate *actual* referrer/redirect info as the original page does
var params = jQuery.param({ redirect : redirect }),
loginUrl = Galaxy.root + 'user/login?' + params;
loginPage.render();
// welcome page (probably) needs to remain sandboxed
loginPage.center.$( '#galaxy_main' ).prop( 'src', options.welcome_url );
loginPage.right.$( '.unified-panel-body' )
.css( 'overflow', 'hidden' )
.html( '<iframe src="' + loginUrl + '" frameborder="0" style="width: 100%; height: 100%;"/>' );
});
};
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(/*! underscore */ 1)))
/***/ }
]);
webpackJsonp([4],[function(e,r,n){(function(e){var r=n(1),a=r,i=n(59).GalaxyApp,o=n(10),t=n(5),l=n(61);window.app=function(n,c){window.Galaxy=new i(n,c),Galaxy.debug("login app");var d=encodeURI(n.redirect);if(!n.show_welcome_with_login){var w=r.param({use_panels:"True",redirect:d});return void(window.location.href=Galaxy.root+"user/login?"+w)}var p=new l.PageLayoutView(e.extend(n,{el:"body",center:new o.CenterPanel({el:"#center"}),right:new o.RightPanel({title:t("Login required"),el:"#right"})}));a(function(){var e=r.param({redirect:d}),a=Galaxy.root+"user/login?"+e;p.render(),p.center.$("#galaxy_main").prop("src",n.welcome_url),p.right.$(".unified-panel-body").css("overflow","hidden").html('<iframe src="'+a+'" frameborder="0" style="width: 100%; height: 100%;"/>')})}}).call(r,n(3))}]);
//# sourceMappingURL=login.bundled.js.map
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
@@ -1,2 +1,2 @@
define(["mvc/base-mvc"],function(a){"use strict";var b=a.SessionStorageModel.extend({defaults:{expandedIds:{},show_deleted:!1,show_hidden:!1},addExpanded:function(a){var b="expandedIds";this.save(b,_.extend(this.get(b),_.object([a.id],[a.get("id")])))},removeExpanded:function(a){var b="expandedIds";this.save(b,_.omit(this.get(b),a.id))},toString:function(){return"HistoryPrefs("+this.id+")"}},{storageKeyPrefix:"history:",historyStorageKey:function(a){if(!a)throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+a);return b.storageKeyPrefix+a},get:function(a){return new b({id:b.historyStorageKey(a)})},clearAll:function(){for(var a in sessionStorage)0===a.indexOf(b.storageKeyPrefix)&&sessionStorage.removeItem(a)}});return{HistoryPrefs:b}});
define(["mvc/base-mvc"],function(a){"use strict";var b=a.SessionStorageModel.extend({defaults:{expandedIds:{},show_deleted:!1,show_hidden:!1},addExpanded:function(a){var b=this.get("expandedIds");b[a.id]=a.get("id"),this.save("expandedIds",b)},removeExpanded:function(a){var b=this.get("expandedIds");delete b[a.id],this.save("expandedIds",b)},isExpanded:function(a){return _.result(this.get("expandedIds"),a,!1)},allExpanded:function(){return _.values(this.get("expandedIds"))},clearExpanded:function(){this.set("expandedIds",{})},includeDeleted:function(a){return _.isUndefined(a)||this.set("show_deleted",a),this.get("show_deleted")},includeHidden:function(a){return _.isUndefined(a)||this.set("show_hidden",a),this.get("show_hidden")},toString:function(){return"HistoryPrefs("+this.id+")"}},{storageKeyPrefix:"history:",historyStorageKey:function(a){if(!a)throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+a);return b.storageKeyPrefix+a},get:function(a){return new b({id:b.historyStorageKey(a)})},clearAll:function(){for(var a in sessionStorage)0===a.indexOf(b.storageKeyPrefix)&&sessionStorage.removeItem(a)}});return{HistoryPrefs:b}});
//# sourceMappingURL=../../../maps/mvc/history/history-preferences.js.map
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
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long