details: http://www.bx.psu.edu/hg/galaxy/rev/eba44fc830bf changeset: 2669:eba44fc830bf user: Kanwei Li <kanwei@gmail.com> date: Tue Sep 08 17:33:38 2009 -0400 description: Fix issue with updater in history.mako with frozen status indicators, improve JS coding consistency 2 file(s) affected in this change: templates/dataset/edit_attributes.mako templates/root/history.mako diffs (277 lines): diff -r 30579f99ecb6 -r eba44fc830bf templates/dataset/edit_attributes.mako --- a/templates/dataset/edit_attributes.mako Fri Sep 04 17:38:09 2009 -0400 +++ b/templates/dataset/edit_attributes.mako Tue Sep 08 17:33:38 2009 -0400 @@ -9,44 +9,43 @@ <% user, user_roles = trans.get_user_and_roles() %> <%def name="javascripts()"> - ## <!--[if lt IE 7]> - ## <script type='text/javascript' src="/static/scripts/IE7.js"> </script> - ## <![endif]--> - ${h.js( "jquery", "galaxy.base", "jquery.autocomplete", "autocomplete_tagging" )} - <script type="text/javascript"> - $( document ).ready( function() { + ## <!--[if lt IE 7]> + ## <script type='text/javascript' src="/static/scripts/IE7.js"> </script> + ## <![endif]--> + ${h.js( "jquery", "galaxy.base", "jquery.autocomplete", "autocomplete_tagging" )} + <script type="text/javascript"> + $( document ).ready( function() { // Set up autocomplete tagger. <% - ## Build string of tag name, values. - tag_names_and_values = list() - for tag in data.tags: - tag_name = tag.user_tname - tag_value = "" - if tag.value is not None: - tag_value = tag.user_value - tag_names_and_values.append("\"" + tag_name + "\" : \"" + tag_value + "\"") + ## Build string of tag name, values. + tag_names_and_values = list() + for tag in data.tags: + tag_name = tag.user_tname + tag_value = "" + if tag.value is not None: + tag_value = tag.user_value + tag_names_and_values.append("\"" + tag_name + "\" : \"" + tag_value + "\"") %> - var options = - { - tags : {${", ".join(tag_names_and_values)}}, - tag_click_fn: function(tag) { /* Do nothing. */ }, - use_toggle_link: false, - input_size: 30, - in_form: true, - <% encoded_data_id = trans.security.encode_id(data.id) %> - ajax_autocomplete_tag_url: "${h.url_for( controller='tag', action='tag_autocomplete_data', id=encoded_data_id, item_type="hda" )}", - ajax_add_tag_url: "${h.url_for( controller='tag', action='add_tag_async', id=encoded_data_id, item_type="hda" )}", - ajax_delete_tag_url: "${h.url_for( controller='tag', action='remove_tag_async', id=encoded_data_id, item_type="hda" )}", - delete_tag_img: "${h.url_for('/static/images/delete_tag_icon_gray.png')}", - delete_tag_img_rollover: "${h.url_for('/static/images/delete_tag_icon_white.png')}", - add_tag_img: "${h.url_for('/static/images/add_icon.png')}", - add_tag_img_rollover: "${h.url_for('/static/images/add_icon_dark.png')}", + var options = { + tags : {${", ".join(tag_names_and_values)}}, + tag_click_fn: function(tag) { /* Do nothing. */ }, + use_toggle_link: false, + input_size: 30, + in_form: true, + <% encoded_data_id = trans.security.encode_id(data.id) %> + ajax_autocomplete_tag_url: "${h.url_for( controller='tag', action='tag_autocomplete_data', id=encoded_data_id, item_type="hda" )}", + ajax_add_tag_url: "${h.url_for( controller='tag', action='add_tag_async', id=encoded_data_id, item_type="hda" )}", + ajax_delete_tag_url: "${h.url_for( controller='tag', action='remove_tag_async', id=encoded_data_id, item_type="hda" )}", + delete_tag_img: "${h.url_for('/static/images/delete_tag_icon_gray.png')}", + delete_tag_img_rollover: "${h.url_for('/static/images/delete_tag_icon_white.png')}", + add_tag_img: "${h.url_for('/static/images/add_icon.png')}", + add_tag_img_rollover: "${h.url_for('/static/images/add_icon_dark.png')}", }; % if trans.get_user() is not None: - $("#dataset-tag-area").autocomplete_tagging(options); - }); + $("#dataset-tag-area").autocomplete_tagging(options); % endif - </script> +}); + </script> </%def> <%def name="datatype( dataset, datatypes )"> diff -r 30579f99ecb6 -r eba44fc830bf templates/root/history.mako --- a/templates/root/history.mako Fri Sep 04 17:38:09 2009 -0400 +++ b/templates/root/history.mako Tue Sep 08 17:33:38 2009 -0400 @@ -74,105 +74,88 @@ }); // Updater updater({ - %for i, data in enumerate( reversed( datasets ) ): - %if data.visible and data.state not in [ "deleted", "empty", "error", "ok" ]: - %if i > 0: - , - %endif - "${data.id}": "${data.state}" - %endif - %endfor + <% updateable = [data for data in reversed( datasets ) if data.visible and data.state not in [ "deleted", "empty", "error", "ok" ]] %> + ${ ",".join( map(lambda data: "\"%s\" : \"%s\"" % (data.id, data.state), updateable) ) } }); - // // Set up autocomplete tagger. - // <% - ## Build string of tag name, values. - tag_names_and_values = list() - for tag in history.tags: - tag_name = tag.user_tname - tag_value = "" - if tag.value is not None: - tag_value = tag.user_value - tag_names_and_values.append("\"" + tag_name + "\" : \"" + tag_value + "\"") + ## Build string of tag name, values. + tag_names_and_values = list() + for tag in history.tags: + tag_name = tag.user_tname + tag_value = "" + if tag.value is not None: + tag_value = tag.user_value + tag_names_and_values.append("\"" + tag_name + "\" : \"" + tag_value + "\"") %> - // - // Returns the number of keys (elements) in an array/dictionary. - // - var array_length = function(an_array) - { - if (an_array.length) - return an_array.length; + // Returns the number of keys (elements) in an array/dictionary. + var array_length = function(an_array) + { + if (an_array.length) + return an_array.length; - var count = 0; - for (element in an_array) - count++; - return count; - }; + var count = 0; + for (element in an_array) + count++; + return count; + }; - // - // Function get text to display on the toggle link. - // - var get_toggle_link_text = function(tags) - { - var text = ""; - var num_tags = array_length(tags); - if (num_tags != 0) - { - text = num_tags + (num_tags != 1 ? " Tags" : " Tag"); - /* - // Show first N tags; hide the rest. - var max_to_show = 1; + // Function get text to display on the toggle link. + var get_toggle_link_text = function(tags) + { + var text = ""; + var num_tags = array_length(tags); + if (num_tags != 0) { + text = num_tags + (num_tags != 1 ? " Tags" : " Tag"); + /* + // Show first N tags; hide the rest. + var max_to_show = 1; - // Build tag string. - var tag_strs = new Array(); - var count = 0; - for (tag_name in tags) - { - tag_value = tags[tag_name]; - tag_strs[tag_strs.length] = build_tag_str(tag_name, tag_value); - if (++count == max_to_show) - break; - } - tag_str = tag_strs.join(", "); - - // Finalize text. - var num_tags_hiding = num_tags - max_to_show; - text = "Tags: " + tag_str + - (num_tags_hiding != 0 ? " and " + num_tags_hiding + " more" : ""); - */ - } - else - { - // No tags. - text = "Add tags to this history"; - } - return text; - }; - - var options = - { - tags : {${", ".join(tag_names_and_values)}}, - get_toggle_link_text_fn: get_toggle_link_text, - input_size: 15, - tag_click_fn: function(tag) { /* Do nothing. */ }, - <% encoded_history_id = trans.security.encode_id(history.id) %> - ajax_autocomplete_tag_url: "${h.url_for( controller='tag', action='tag_autocomplete_data', id=encoded_history_id, item_type="history" )}", - ajax_add_tag_url: "${h.url_for( controller='tag', action='add_tag_async', id=encoded_history_id, item_type="history" )}", - ajax_delete_tag_url: "${h.url_for( controller='tag', action='remove_tag_async', id=encoded_history_id, item_type="history" )}", - delete_tag_img: "${h.url_for('/static/images/delete_tag_icon_gray.png')}", - delete_tag_img_rollover: "${h.url_for('/static/images/delete_tag_icon_white.png')}", - add_tag_img: "${h.url_for('/static/images/add_icon.png')}", - add_tag_img_rollover: "${h.url_for('/static/images/add_icon_dark.png')}", - }; + // Build tag string. + var tag_strs = new Array(); + var count = 0; + for (tag_name in tags) + { + tag_value = tags[tag_name]; + tag_strs[tag_strs.length] = build_tag_str(tag_name, tag_value); + if (++count == max_to_show) + break; + } + tag_str = tag_strs.join(", "); + + // Finalize text. + var num_tags_hiding = num_tags - max_to_show; + text = "Tags: " + tag_str + + (num_tags_hiding != 0 ? " and " + num_tags_hiding + " more" : ""); + */ + } else { + // No tags. + text = "Add tags to this history"; + } + return text; + }; + + var options = { + tags : {${", ".join(tag_names_and_values)}}, + get_toggle_link_text_fn: get_toggle_link_text, + input_size: 15, + tag_click_fn: function(tag) { /* Do nothing. */ }, + <% encoded_history_id = trans.security.encode_id(history.id) %> + ajax_autocomplete_tag_url: "${h.url_for( controller='tag', action='tag_autocomplete_data', id=encoded_history_id, item_type="history" )}", + ajax_add_tag_url: "${h.url_for( controller='tag', action='add_tag_async', id=encoded_history_id, item_type="history" )}", + ajax_delete_tag_url: "${h.url_for( controller='tag', action='remove_tag_async', id=encoded_history_id, item_type="history" )}", + delete_tag_img: "${h.url_for('/static/images/delete_tag_icon_gray.png')}", + delete_tag_img_rollover: "${h.url_for('/static/images/delete_tag_icon_white.png')}", + add_tag_img: "${h.url_for('/static/images/add_icon.png')}", + add_tag_img_rollover: "${h.url_for('/static/images/add_icon_dark.png')}", + }; % if trans.get_user() is not None: - $("#history-tag-area").autocomplete_tagging(options); + $("#history-tag-area").autocomplete_tagging(options); % endif }); // Functionized so AJAX'd datasets can call them -// Get shown/hidden state from cookie function initShowHide() { // Load saved state and show as neccesary @@ -215,8 +198,7 @@ delete prefs[id]; $.jStore.store("history_expand_state", JSON.stringify(prefs)); } - } - else { + } else { // Showing stuff here body.slideDown( "fast", function() { if ( $.browser.mozilla ) { peek.css( "overflow", "auto" ); } @@ -326,8 +308,7 @@ }); if ( force_history_refresh ) { parent.frames.galaxy_history.location.reload(); - } - else { + } else { // Keep going (if there are still any items to track) updater( tracked_datasets ); }