commit/galaxy-central: carlfeberhard: history.js: fix to HistoryView tagging functionality
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/3231b9ca8d82/ changeset: 3231b9ca8d82 user: carlfeberhard date: 2012-10-10 01:10:30 summary: history.js: fix to HistoryView tagging functionality affected #: 4 files diff -r dcb22217c17527427c17f4ca3edeb5d6a98f6f4d -r 3231b9ca8d82219cbef87cfeb4fc57013c11f3c5 static/scripts/mvc/history.js --- a/static/scripts/mvc/history.js +++ b/static/scripts/mvc/history.js @@ -558,6 +558,14 @@ parent.append( this._render_displayApps() ); parent.append( this._render_peek() ); + + //TODO??: still needed? + //// If Mozilla, hide scrollbars in hidden items since they cause animation bugs + //if ( $.browser.mozilla ) { + // $( "div.historyItemBody" ).each( function() { + // if ( !$(this).is(":visible") ) { $(this).find( "pre.peek" ).css( "overflow", "hidden" ); } + // }); + //} }, _render_body : function(){ @@ -704,7 +712,13 @@ toggleBodyVisibility : function( visible ){ var $body = this.$el.find( '.historyItemBody' ); - $body.toggle(); + if( visible === undefined ){ + $body.toggle(); + } else if( visible ){ + $body.show(); + } else { + $body.hide(); + } this.trigger( 'toggleBodyVisibility', this.model.get( 'id' ), $body.is( ':visible' ) ); }, @@ -715,9 +729,7 @@ } }); - //------------------------------------------------------------------------------ -//HistoryItemView.templates = InDomTemplateLoader.getTemplates({ HistoryItemView.templates = { warningMsg : Handlebars.templates[ 'template-warningmessagesmall' ], @@ -875,7 +887,6 @@ //------------------------------------------------------------------------------ // view for the HistoryCollection (as per current right hand panel) -//var HistoryView = BaseView.extend( LoggableMixin ).extend( UsesStorageMixin ) .extend({ var HistoryView = BaseView.extend( LoggableMixin ).extend({ // uncomment this out see log messages @@ -894,16 +905,20 @@ ); // set up the individual history items/datasets this.initializeItems(); + }, initializeItems : function(){ this.itemViews = {}; var historyPanel = this; + + // set up a view for each item, init with model and listeners, cache to map ( model.id : view ) this.model.items.each( function( item ){ var itemId = item.get( 'id' ), + visible = historyPanel.storage.get( 'visibleItems' ).get( itemId ), itemView = new HistoryItemView({ - model: item, visible: - historyPanel.storage.get( 'visibleItems' ).get( itemId ) + model: item, + visible: visible }); historyPanel.setUpItemListeners( itemView ); historyPanel.itemViews[ itemId ] = itemView; @@ -912,6 +927,7 @@ setUpItemListeners : function( itemView ){ var HistoryPanel = this; + // use storage to maintain a list of items whose bodies are visible itemView.bind( 'toggleBodyVisibility', function( id, visible ){ if( visible ){ @@ -930,7 +946,34 @@ this.itemsDiv = this.$el.find( '#' + this.model.get( 'id' ) + '-datasets' ); //TODO: set up widgets, tooltips, etc. + async_save_text( + "history-name-container", + "history-name", + this.model.get( 'renameURL' ), + "new_name", + 18 + ); + this.$el.find( '.tooltip' ).tooltip(); + var historyAnnotationArea = this.$el.find( '#history-annotation-area' ); + $( '#history-annotate' ).click( function() { + if ( historyAnnotationArea.is( ":hidden" ) ) { + historyAnnotationArea.slideDown( "fast" ); + } else { + historyAnnotationArea.slideUp( "fast" ); + } + return false; + }); + async_save_text( + "history-annotation-container", + "history-annotation", + this.model.get( 'annotateURL' ), + "new_annotation", + 18, + true, + 4 + ); + if( this.model.items.length ){ // render to temp, move all at once, remove temp holder var tempDiv = this._render_items(); @@ -950,6 +993,53 @@ return div; }, + events : { + 'click #history-collapse-all' : 'hideAllItemBodies', + 'click #history-tag' : 'loadAndDisplayTags' + }, + + hideAllItemBodies : function(){ + _.each( this.itemViews, function( item ){ + item.toggleBodyVisibility( false ); + }); + }, + + loadAndDisplayTags : function( event ){ + //BUG: broken with latest + //TODO: this is a drop in from history.mako - should use MV as well + this.log( this + '.loadAndDisplayTags', event ); + var tagArea = this.$el.find( '#history-tag-area' ), + tagElt = tagArea.find( '.tag-elt' ); + this.log( '\t tagArea', tagArea, ' tagElt', tagElt ); + + // Show or hide tag area; if showing tag area and it's empty, fill it. + if( tagArea.is( ":hidden" ) ){ + if( !jQuery.trim( tagElt.html() ) ){ + var view = this; + // Need to fill tag element. + $.ajax({ + //TODO: the html from this breaks a couple of times + url: this.model.get( 'tagURL' ), + error: function() { alert( "Tagging failed" ); }, + success: function(tag_elt_html) { + view.log( view + ' tag elt html (ajax)', tag_elt_html ); + tagElt.html(tag_elt_html); + tagElt.find(".tooltip").tooltip(); + tagArea.slideDown("fast"); + } + }); + } else { + // Tag element is filled; show. + tagArea.slideDown("fast"); + } + + } else { + // Hide. + tagArea.slideUp("fast"); + } + return false; + }, + toString : function(){ var nameString = this.model.get( 'name' ) || ''; return 'HistoryView(' + nameString + ')'; diff -r dcb22217c17527427c17f4ca3edeb5d6a98f6f4d -r 3231b9ca8d82219cbef87cfeb4fc57013c11f3c5 static/scripts/templates/compiled/template-history-historyPanel.js --- a/static/scripts/templates/compiled/template-history-historyPanel.js +++ b/static/scripts/templates/compiled/template-history-historyPanel.js @@ -23,21 +23,13 @@ else { stack1 = depth0.local; stack1 = typeof stack1 === functionType ? stack1() : stack1; } if (!helpers.local) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(6, program6, data)}); } if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\"\n class=\"icon-button tags tooltip\" target=\"galaxy_main\" href=\""; - foundHelper = helpers.tagURL; - if (foundHelper) { stack1 = foundHelper.call(depth0, {hash:{}}); } - else { stack1 = depth0.tagURL; stack1 = typeof stack1 === functionType ? stack1() : stack1; } - buffer += escapeExpression(stack1) + "\"></a>\n <a id=\"history-annotate\" title=\""; + buffer += "\"\n class=\"icon-button tags tooltip\" target=\"galaxy_main\" href=\"javascript:void(0)\"></a>\n <a id=\"history-annotate\" title=\""; foundHelper = helpers.local; if (foundHelper) { stack1 = foundHelper.call(depth0, {hash:{},inverse:self.noop,fn:self.program(8, program8, data)}); } else { stack1 = depth0.local; stack1 = typeof stack1 === functionType ? stack1() : stack1; } if (!helpers.local) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(8, program8, data)}); } if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\"\n class=\"icon-button annotate tooltip\" target=\"galaxy_main\" href=\""; - foundHelper = helpers.annotateURL; - if (foundHelper) { stack1 = foundHelper.call(depth0, {hash:{}}); } - else { stack1 = depth0.annotateURL; stack1 = typeof stack1 === functionType ? stack1() : stack1; } - buffer += escapeExpression(stack1) + "\"></a>\n </div>\n "; + buffer += "\"\n class=\"icon-button annotate tooltip\" target=\"galaxy_main\" href=\"javascript:void(0)\"></a>\n </div>\n "; return buffer;} function program6(depth0,data) { @@ -143,9 +135,9 @@ var buffer = "", stack1; buffer += "\n"; - buffer += "\n<div style=\"margin: 0px 5px 10px 5px\">\n\n <div id=\"history-tag-area\" style=\"display: none\">\n <b>Tags:</b>\n "; + buffer += "\n<div style=\"margin: 0px 5px 10px 5px\">\n\n <div id=\"history-tag-area\" style=\"display: none\">\n "; buffer += "\n "; - buffer += "\n </div>\n\n <div id=\"history-annotation-area\" style=\"display: none\">\n <strong>Annotation / Notes:</strong>\n <div id=\"history-annotation-container\">\n <div id=\"history-annotation\" class=\"tooltip editable-text\" title=\"Click to edit annotation\">\n "; + buffer += "\n <strong>Tags:</strong>\n <div class=\"tag-elt\"></div>\n </div>\n\n <div id=\"history-annotation-area\" style=\"display: none\">\n <strong>Annotation / Notes:</strong>\n <div id=\"history-annotation-container\">\n <div id=\"history-annotation\" class=\"tooltip editable-text\" title=\"Click to edit annotation\">\n "; stack1 = depth0.annotation; stack1 = helpers['if'].call(depth0, stack1, {hash:{},inverse:self.program(27, program27, data),fn:self.program(25, program25, data)}); if(stack1 || stack1 === 0) { buffer += stack1; } @@ -228,7 +220,7 @@ else { stack1 = depth0.local; stack1 = typeof stack1 === functionType ? stack1() : stack1; } if (!helpers.local) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(3, program3, data)}); } if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "' class='icon-button toggle tooltip' href='#' style=\"display: none\"></a>\n "; + buffer += "' id=\"history-collapse-all\"\n class='icon-button toggle tooltip' href='javascript:void(0);'></a>\n "; stack1 = depth0.userRoles; stack1 = helpers['if'].call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(5, program5, data)}); if(stack1 || stack1 === 0) { buffer += stack1; } @@ -252,7 +244,6 @@ if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n\n"; buffer += "\n"; - buffer += "\n"; stack1 = depth0.userRoles; stack1 = helpers['if'].call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(24, program24, data)}); if(stack1 || stack1 === 0) { buffer += stack1; } diff -r dcb22217c17527427c17f4ca3edeb5d6a98f6f4d -r 3231b9ca8d82219cbef87cfeb4fc57013c11f3c5 static/scripts/templates/history-templates.html --- a/static/scripts/templates/history-templates.html +++ b/static/scripts/templates/history-templates.html @@ -103,13 +103,14 @@ <script type="text/template" class="template-history" id="template-history-historyPanel"><div id="top-links" class="historyLinks"><a title="{{#local}}refresh{{/local}}" class="icon-button arrow-circle tooltip" href="{{baseURL}}"></a> - <a title='{{#local}}collapse all{{/local}}' class='icon-button toggle tooltip' href='#' style="display: none"></a> + <a title='{{#local}}collapse all{{/local}}' id="history-collapse-all" + class='icon-button toggle tooltip' href='javascript:void(0);'></a> {{#if userRoles}} <div style="width: 40px; float: right; white-space: nowrap;"><a id="history-tag" title="{{#local}}Edit history tags{{/local}}" - class="icon-button tags tooltip" target="galaxy_main" href="{{tagURL}}"></a> + class="icon-button tags tooltip" target="galaxy_main" href="javascript:void(0)"></a><a id="history-annotate" title="{{#local}}Edit history annotation{{/local}}" - class="icon-button annotate tooltip" target="galaxy_main" href="{{annotateURL}}"></a> + class="icon-button annotate tooltip" target="galaxy_main" href="javascript:void(0)"></a></div> {{/if}} </div> @@ -148,15 +149,15 @@ {{/if}} {{! tags and annotations }} -{{! TODO: wire these to js events }} {{#if userRoles}} {{! TODO: move inline styles out }} <div style="margin: 0px 5px 10px 5px"><div id="history-tag-area" style="display: none"> - <b>Tags:</b> {{! load via js render_individual_tagging_element }} {{! render_individual_tagging_element(user=trans.get_user(), tagged_item=history, elt_context="history.mako", use_toggle_link=False, input_size="20") }} + <strong>Tags:</strong> + <div class="tag-elt"></div></div><div id="history-annotation-area" style="display: none"> @@ -202,6 +203,3 @@ </div> {{/if}} </script> - - - diff -r dcb22217c17527427c17f4ca3edeb5d6a98f6f4d -r 3231b9ca8d82219cbef87cfeb4fc57013c11f3c5 templates/root/alternate_history.mako --- a/templates/root/alternate_history.mako +++ b/templates/root/alternate_history.mako @@ -291,9 +291,10 @@ ##TODO: move to API for_editing = True + encoded_history_id = trans.security.encode_id( history.id ) context_dict = { 'history' : { - 'id' : trans.security.encode_id( history.id ), + 'id' : encoded_history_id, 'name' : history.name, 'status' : status, @@ -324,11 +325,13 @@ 'annotation' : h.to_unicode( annotation ), ##TODO: broken - 'baseURL' : h.url_for( 'history', show_deleted=show_deleted ), - 'hideDeletedURL' : h.url_for( 'history', show_deleted=False ), - 'hideHiddenURL' : h.url_for( 'history', show_hidden=False ), - 'tagURL' : h.url_for( controller='history', action='tag' ), - 'annotateURL' : h.url_for( controller='history', action='annotate' ) + 'baseURL' : h.url_for( controller="/history", show_deleted=show_deleted ), + 'hideDeletedURL' : h.url_for( controller="/history", show_deleted=False ), + 'hideHiddenURL' : h.url_for( controller="/history", show_hidden=False ), + 'renameURL' : h.url_for( controller="/history", action="rename_async", id=encoded_history_id ), + 'tagURL' : h.url_for( controller='tag', action='get_tagging_elt_async', + item_class=history.__class__.__name__, item_id=encoded_history_id ), + 'annotateURL' : h.url_for( controller="/history", action="annotate_async", id=encoded_history_id ) }, 'hdas' : [ prep_hda( hda, for_editing ) for hda in datasets ], Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket