myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2106] trunk: improved tag suggestions experience


From: noreply
Subject: [myexperiment-hackers] [2106] trunk: improved tag suggestions experience
Date: Mon, 16 Feb 2009 07:51:58 -0500 (EST)

Revision
2106
Author
dgc
Date
2009-02-16 07:51:57 -0500 (Mon, 16 Feb 2009)

Log Message

improved tag suggestions experience

Modified Paths

Diff

Modified: trunk/app/controllers/workflows_controller.rb (2105 => 2106)


--- trunk/app/controllers/workflows_controller.rb	2009-02-13 18:08:13 UTC (rev 2105)
+++ trunk/app/controllers/workflows_controller.rb	2009-02-16 12:51:57 UTC (rev 2106)
@@ -314,7 +314,13 @@
 
         if policy_err_msg.blank?
         	flash[:notice] = 'Workflow was successfully created.'
-          format.html { redirect_to tag_suggestions_workflow_url(@workflow) }
+          format.html {
+            if @workflow.get_tag_suggestions.length > 0
+              redirect_to tag_suggestions_workflow_url(@workflow)
+            else
+              redirect_to workflow_url(@workflow)
+            end
+          }
         else
         	flash[:notice] = "Workflow was successfully created. However some problems occurred, please see these below.</br></br><span style='color: red;'>" + policy_err_msg + "</span>"
           format.html { redirect_to :controller => 'workflows', :id => @workflow, :action ="" "edit" }

Modified: trunk/app/views/workflows/tag_suggestions.rhtml (2105 => 2106)


--- trunk/app/views/workflows/tag_suggestions.rhtml	2009-02-13 18:08:13 UTC (rev 2105)
+++ trunk/app/views/workflows/tag_suggestions.rhtml	2009-02-16 12:51:57 UTC (rev 2106)
@@ -1,37 +1,30 @@
 <%= _javascript__include_tag "tag_suggestions.js" %>
 
-<h1>Tag suggestions</h1>
+<h1>Tags</h1>
 
-<p>Based on the content of your workflow, here are some tags which you may wish to add:</p>
+<h2>Automatic tag suggestions</h2>
 
-<h2>Selected tags to add</h2>
+<p>The following tag suggestions are based on the content of your workflow.
+Click on each tag that you wish to use.<p>
 
-<% if false %>
-
-  <form action="" "/workflows/address@hidden/tag" %>" method="post"  Ajax.Request(<%= "'/workflows/address@hidden/tag'" %>, { asynchronous:true, evalScripts:true, onComplete:function(request){addTag(<%= "'#{suggestion}'" %>)}, onLoading:function(request){addingTag(<%= "'#{suggestion}'" %>)}, onSuccess:function(request){tagSuccess(<%= "'#{suggestion}'" %>)}, parameters:Form.serialize(this)}); return false;">
-
-    <span><%= suggestion %></span>
-    <input id="tag_list" name="tag_list" type="hidden" value="<%= suggestion %>"/>
-    <input name="commit" type="submit" value="Add" />
-
-  </form>
-  <% end %>
-
-<p>Click on tags below to add them.  Once you have chosen all the tags you want, press submit.</p>
-
-<div class="box_simple" style="font-size: 93%; text-align: left; margin-top: 1em;">
-  <div id="to-add"></div>
+<div class="box_simple" style="font-size: 93%; text-align: left; margin: 2em;">
+  <div id="suggestions"></div>
 </div>
 
-<h2>Tag suggestions</h2>
+<p><em>Note: Tag suggestions are given by matching words in your workflow with other
+tags already used in myExperiment.</em></p>
 
-<p>These are the tags that have been suggested for your upload, based on the content.  The tags
-shown here are already used by other content.</p>
+<h2>Summary</h2>
 
-<div class="box_simple" style="font-size: 93%; text-align: left; margin-top: 1em;">
-  <div id="suggestions"></div>
-</div>
+<div id="summary-text"></div>
 
+<form action="" "/workflows/address@hidden/process_tag_suggestions" %>" method="post">
+  <p style="text-align: center">
+    <input id="submit-button" type="submit" value="Continue" />
+    <input type="hidden" name="tag_list" id="tag_list" />
+  </p>
+</form>
+
 <script type="text/ecmascript">
   <% @suggestions.each do |suggestion| %>
     defineTag("<%= suggestion %>");
@@ -40,10 +33,3 @@
   updateTagViews();
 </script>
 
-<form action="" "/workflows/address@hidden/process_tag_suggestions" %>" method="post">
-  <p style="text-align: center">
-    <input type="submit" value="Continue" />
-    <input type="hidden" name="tag_list" id="tag_list" />
-  </p>
-</form>
-

Modified: trunk/public/_javascript_s/tag_suggestions.js (2105 => 2106)


--- trunk/public/_javascript_s/tag_suggestions.js	2009-02-13 18:08:13 UTC (rev 2105)
+++ trunk/public/_javascript_s/tag_suggestions.js	2009-02-16 12:51:57 UTC (rev 2106)
@@ -3,9 +3,27 @@
 var suggestions = new Array();
 var tagsToAdd   = new Array();
 
-function updateAddBox() {
+function commaList(list) {
+
+  result = "";
+
+  for (i = 0; i < list.length; i++) {
+    result += "<em>" + list[i] + "</em>";
+
+    if (i < (list.length - 2)) {
+      result += ", ";
+    } else if (i < (list.length - 1)) {
+      result += " and ";
+    }
+  }
+
+  return result;
 }
 
+function defineTag(name) {
+  suggestions.push(name);
+}
+
 function addTag(name) {
 
   if (tagsToAdd.indexOf(name) == -1) {
@@ -21,81 +39,49 @@
   updateTagViews();
 }
 
-function addingTag(name) {
-  alert("Adding tag: " + name);
-}
-
-function tagSuccess(name) {
-  document.getElementById("tag_" + name).innerHTML = "Tag \""+ name + "\" added.";
-  alert("Tag success: " + name);
-}
-
-function defineTag(name) {
-  suggestions.push(name);
-}
-
 function updateTagViews() {
 
-  visibleSuggestions = new Array();
+  separator  = ' <span style="color: #999999;">|</span> ';
+  markup     = "";
+  submitText = "";
+  summary    = "";
 
-  for (var i = 0; i < suggestions.length; i++) {
-    s = suggestions[i];
-    if (tagsToAdd.indexOf(s) == -1) {
-      visibleSuggestions.push(s);
-    }
-  }
+  if (suggestions.length == 0) {
 
-  var separator = ' <span style="color: #999999;">|</span> ';
+    markup = "There are no tag suggestions!";
 
-  // visible suggestions
-
-  var markup = "";
-
-  if (visibleSuggestions.length == 0) {
-
-    markup = "There are no remaining tag suggestions!";
   } else {
 
-    for (var i = 0; i < visibleSuggestions.length; i++) {
+    for (i = 0; i < suggestions.length; i++) {
 
-      markup += '<a href=""  + visibleSuggestions[i] +
-        '\'); return false;">' + visibleSuggestions[i] + '</a>';
+      tag = suggestions[i];
+      cl  = 'unselected_tag_suggestion';
+      fun = 'addTag';
 
-      if (i != (visibleSuggestions.length - 1))
+      if (tagsToAdd.indexOf(tag) != -1) {
+        cl  = 'selected_tag_suggestion';
+        fun = 'removeTag';
+      }
+      
+      markup += '<a class="' + cl + '" href=""  + fun +
+        '(\'' + tag + '\'); return false;">' + tag + '</a>';
+
+      if (i != (suggestions.length - 1))
         markup += separator;
     }
   }
 
-  document.getElementById("suggestions").innerHTML = markup;
-
-  // selected tags
-
-  markup = "";
-  form_value = "";
-
   if (tagsToAdd.length == 0) {
-
-    markup = "You have not selected any tag suggestions (click on tags below to add).";
-
+    submitText = 'Skip this step';
+    summary = "<p>You have no tags to add to this workflow.</p>";
   } else {
-
-    for (var i = 0; i < tagsToAdd.length; i++) {
-
-      markup += '<a href=""  + tagsToAdd[i] +
-        '\'); return false;">' + tagsToAdd[i] + '</a>';
-
-      if (i != (tagsToAdd.length - 1))
-        markup += separator;
-
-      if (i > 0)
-        form_value = form_value + ",";
-
-      form_value = form_value + tagsToAdd[i];
-    }
+    submitText = 'Tag';
+    summary = "<p>You are about tag this workflow with: " + commaList(tagsToAdd.sort()) + ".";
   }
 
-  document.getElementById("to-add").innerHTML = markup;
-
-  document.getElementById("tag_list").value = form_value;
+  document.getElementById("suggestions").innerHTML  = markup;
+  document.getElementById("tag_list").value         = tagsToAdd.join(", ");
+  document.getElementById("submit-button").value    = submitText;
+  document.getElementById("summary-text").innerHTML = summary;
 }
 

Modified: trunk/public/stylesheets/styles.css (2105 => 2106)


--- trunk/public/stylesheets/styles.css	2009-02-13 18:08:13 UTC (rev 2105)
+++ trunk/public/stylesheets/styles.css	2009-02-16 12:51:57 UTC (rev 2106)
@@ -1927,4 +1927,36 @@
 
 #version_info_box p * {
 	vertical-align: middle;
-}
\ No newline at end of file
+}
+
+.unselected_tag_suggestion {
+  border: 1px SOLID white;
+  padding-left: 4px;
+  padding-right: 4px;
+}
+
+.unselected_tag_suggestion:hover {
+  border: 1px SOLID #d0d0f0;
+  background-color: #d0d0f0;
+  padding-left: 4px;
+  padding-right: 4px;
+  color: #000099;
+  text-decoration: none;
+}
+
+.selected_tag_suggestion {
+  border: 1px SOLID #a0a0c0;
+  background-color: #d0d0f0;
+  padding-left: 4px;
+  padding-right: 4px;
+}
+
+.selected_tag_suggestion:hover {
+  border: 1px SOLID #a0a0c0;
+  background-color: #d0d0f0;
+  padding-left: 4px;
+  padding-right: 4px;
+  color: #000099;
+  text-decoration: none;
+}
+

reply via email to

[Prev in Thread] Current Thread [Next in Thread]