Diff
Modified: trunk/app/controllers/workflows_controller.rb (2045 => 2046)
--- trunk/app/controllers/workflows_controller.rb 2009-01-12 19:24:48 UTC (rev 2045)
+++ trunk/app/controllers/workflows_controller.rb 2009-01-13 16:10:29 UTC (rev 2046)
@@ -313,7 +313,7 @@
if policy_err_msg.blank?
flash[:notice] = 'Workflow was successfully created.'
- format.html { redirect_to workflow_url(@workflow) }
+ format.html { redirect_to tag_suggestions_workflow_url(@workflow) }
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" }
@@ -564,6 +564,15 @@
@suggestions = @workflow.get_tag_suggestions
end
+ def process_tag_suggestions
+
+ params[:tag_list].split(',').each do |tag|
+ @workflow.add_tag(tag, current_user)
+ end
+
+ redirect_to(workflow_url(@workflow))
+ end
+
protected
def find_workflows
Modified: trunk/app/models/policy.rb (2045 => 2046)
--- trunk/app/models/policy.rb 2009-01-12 19:24:48 UTC (rev 2045)
+++ trunk/app/models/policy.rb 2009-01-13 16:10:29 UTC (rev 2046)
@@ -329,7 +329,8 @@
"edit_item",
"update_item",
"quick_add",
- "resolve_link"],
+ "resolve_link",
+ "process_tag_suggestions"],
"view" => ["index",
"show",
"statistics",
Added: trunk/app/views/workflows/tag_suggestions.rhtml (0 => 2046)
--- trunk/app/views/workflows/tag_suggestions.rhtml (rev 0)
+++ trunk/app/views/workflows/tag_suggestions.rhtml 2009-01-13 16:10:29 UTC (rev 2046)
@@ -0,0 +1,49 @@
+<%= _javascript__include_tag "tag_suggestions.js" %>
+
+<h1>Tag suggestions</h1>
+
+<p>Based on the content of your workflow, here are some tags which you may wish to add:</p>
+
+<h2>Selected tags to add</h2>
+
+<% 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>
+
+<h2>Tag suggestions</h2>
+
+<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>
+
+<div class="box_simple" style="font-size: 93%; text-align: left; margin-top: 1em;">
+ <div id="suggestions"></div>
+</div>
+
+<script type="text/ecmascript">
+ <% @suggestions.each do |suggestion| %>
+ defineTag("<%= suggestion %>");
+ <% end %>
+
+ 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/config/routes.rb (2045 => 2046)
--- trunk/config/routes.rb 2009-01-12 19:24:48 UTC (rev 2045)
+++ trunk/config/routes.rb 2009-01-13 16:10:29 UTC (rev 2046)
@@ -82,6 +82,7 @@
:update_version => :put,
:comments_timeline => :get,
:comments => :get,
+ :process_tag_suggestions => :post,
:tag_suggestions => :get } do |workflow|
# workflows have nested citations
workflow.resources :citations
Modified: trunk/public/_javascript_s/tag_suggestions.js (2045 => 2046)
--- trunk/public/_javascript_s/tag_suggestions.js 2009-01-12 19:24:48 UTC (rev 2045)
+++ trunk/public/_javascript_s/tag_suggestions.js 2009-01-13 16:10:29 UTC (rev 2046)
@@ -71,6 +71,7 @@
// selected tags
markup = "";
+ form_value = "";
if (tagsToAdd.length == 0) {
@@ -85,9 +86,16 @@
if (i != (tagsToAdd.length - 1))
markup += separator;
+
+ if (i > 0)
+ form_value = form_value + ",";
+
+ form_value = form_value + tagsToAdd[i];
}
}
document.getElementById("to-add").innerHTML = markup;
+
+ document.getElementById("tag_list").value = form_value;
}