[hg] galaxy 2647: add tagging to histories
details: http://www.bx.psu.edu/hg/galaxy/rev/77dfb7834a94 changeset: 2647:77dfb7834a94 user: jeremy goecks <jeremy.goecks@emory.edu> date: Fri Aug 28 15:40:32 2009 -0400 description: add tagging to histories 1 file(s) affected in this change: templates/root/history.mako diffs (118 lines): diff -r 817c183aa633 -r 77dfb7834a94 templates/root/history.mako --- a/templates/root/history.mako Fri Aug 28 15:38:46 2009 -0400 +++ b/templates/root/history.mako Fri Aug 28 15:40:32 2009 -0400 @@ -14,8 +14,8 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Pragma" content="no-cache"> -${h.css( "base", "history" )} -${h.js( "jquery", "json2", "jquery.jstore-all" )} +${h.css( "base", "history", "autocomplete_tagging" )} +${h.js( "jquery", "json2", "jquery.jstore-all", "jquery.autocomplete", "autocomplete_tagging" )} <script type="text/javascript"> $(function() { @@ -83,6 +83,93 @@ %endif %endfor }); + + // + // 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 + "\"") +%> + // + // 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; + }; + + // + // 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')}", + }; +% if trans.get_user() is not None: + $("#history-tag-area").autocomplete_tagging(options); +% endif + }); // Functionized so AJAX'd datasets can call them // Get shown/hidden state from cookie @@ -290,6 +377,9 @@ <p></p> %endif +<div id="history-tag-area" style="margin-bottom: 1em"> +</div> + <%namespace file="history_common.mako" import="render_dataset" /> %if not datasets:
participants (1)
-
Greg Von Kuster