9426: tags display
authorradhika <radhika@curoverse.com>
Mon, 19 Jun 2017 18:11:48 +0000 (14:11 -0400)
committerradhika <radhika@curoverse.com>
Fri, 23 Jun 2017 18:26:09 +0000 (14:26 -0400)
Arvados-DCO-1.1-Signed-off-by: Radhika Chippada <radhika@curoverse.com>

apps/workbench/app/assets/javascripts/edit_collection_tags.js
apps/workbench/app/controllers/collections_controller.rb
apps/workbench/app/views/collections/_show_tags.html.erb
apps/workbench/app/views/collections/save_tags.js.erb
apps/workbench/app/views/collections/tags.js.erb [new file with mode: 0644]
apps/workbench/config/routes.rb

index 26b0ba7eb9ac4783798b7fb9150c7d45f71fbcb0..8dc9d6138f2399dc162de07a9d966998d89b74b1 100644 (file)
@@ -3,6 +3,7 @@
 $(document).
     on('click', '.collection-tag-save, .collection-tag-cancel', function(event) {
         $('.edit-collection-tags').removeClass('disabled');
+        $('#edit-collection-tags').attr("title", "Edit tags");
         $('.collection-tag-add').addClass('hide');
         $('.collection-tag-remove').addClass('hide');
         $('.collection-tag-save').addClass('hide');
@@ -11,6 +12,7 @@ $(document).
     }).
     on('click', '.edit-collection-tags', function(event) {
         $('.edit-collection-tags').addClass('disabled');
+        $('#edit-collection-tags').attr("title", "");
         $('.collection-tag-add').removeClass('hide');
         $('.collection-tag-remove').removeClass('hide');
         $('.collection-tag-save').removeClass('hide');
@@ -37,6 +39,11 @@ $(document).
       }).fail(function(jqxhr, status, error) {
         $('.collection-tags-status').append('<div class="collection-tags-status-label alert alert-danger"><p class="contain-align-left">We are sorry. There was an error saving tags. Please try again.</p></div>');
       });
+    }).
+    on('click', '.collection-tag-cancel', function(e){
+      $.ajax($(location).attr('pathname')+'/tags', {
+          type: 'POST'
+      });
     });
 
 jQuery(function($){
index 8b3cc2feb860f2483b5572930ca5a4ac32053cb1..8e1e8a5b521c8e6bb748840f39d9ad66b653b0f7 100644 (file)
@@ -345,12 +345,19 @@ class CollectionsController < ApplicationController
     end
   end
 
+  def tags
+    render
+  end
+
   def save_tags
-    props = @object.properties
-    props[:tags] = params['tag_data']
-    if @object.update_attributes properties: props
-    else
-      self.render_error status: 422
+    if params['tag_data']
+      props = @object.properties
+      props[:tags] = params['tag_data']
+
+      if @object.update_attributes properties: props
+      else
+        self.render_error status: 422
+      end
     end
   end
 
index e1b0de7ae2e591c974c09dd8b29d8986aa2e848a..54c9c5c34190bcc22e2c8302cc6f56c147fba72e 100644 (file)
           <button class="btn btn-primary btn-sm collection-tag-add hide"><i class="glyphicon glyphicon-plus"></i> Add new tag </button>
         </div>
         <div class="pull-right">
-          <%= link_to(save_tags_collection_path, {class: 'btn btn-primary collection-tag-save hide', :remote => true, method: 'post', return_to: request.url}) do %>
+          <%= link_to(save_tags_collection_path, {class: 'btn btn-sm btn-primary collection-tag-save hide', :remote => true, method: 'post', return_to: request.url}) do %>
             Save
           <% end %>
-          <button type="button" class="btn btn-sm btn-primary collection-tag-cancel hide">Cancel</button>
+          <%= link_to(tags_collection_path, {class: 'btn btn-sm btn-primary collection-tag-cancel hide', :remote => true, method: 'post', return_to: request.url}) do %>
+            Cancel
+          <% end %>
         </div>
 
         <div><div class="collection-tags-status"/></div></div>
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e2faff169a677a0ae9c1dfe89a207729f0718e61 100644 (file)
@@ -0,0 +1 @@
+$(".collection-tag-rows").html("<%= escape_javascript(render partial: 'show_tag_rows', locals: {object: @object}) %>");
diff --git a/apps/workbench/app/views/collections/tags.js.erb b/apps/workbench/app/views/collections/tags.js.erb
new file mode 100644 (file)
index 0000000..e2faff1
--- /dev/null
@@ -0,0 +1 @@
+$(".collection-tag-rows").html("<%= escape_javascript(render partial: 'show_tag_rows', locals: {object: @object}) %>");
index 880cc15f6dd5db52feacc62648472fc655c3035b..5bd484956f7627ab962394f9cd5eb169d3649ded 100644 (file)
@@ -88,6 +88,7 @@ ArvadosWorkbench::Application.routes.draw do
     post 'unshare', :on => :member
     get 'choose', on: :collection
     post 'remove_selected_files', on: :member
+    post 'tags', on: :member
     post 'save_tags', on: :member
   end
   get('/collections/download/:uuid/:reader_token/*file' => 'collections#show_file',