From aee74220328be12113ea597e593b4ab6f120aeac Mon Sep 17 00:00:00 2001 From: radhika Date: Mon, 19 Jun 2017 14:11:48 -0400 Subject: [PATCH] 9426: tags display Arvados-DCO-1.1-Signed-off-by: Radhika Chippada --- .../assets/javascripts/edit_collection_tags.js | 7 +++++++ .../app/controllers/collections_controller.rb | 17 ++++++++++++----- .../app/views/collections/_show_tags.html.erb | 6 ++++-- .../app/views/collections/save_tags.js.erb | 1 + .../workbench/app/views/collections/tags.js.erb | 1 + apps/workbench/config/routes.rb | 1 + 6 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 apps/workbench/app/views/collections/tags.js.erb diff --git a/apps/workbench/app/assets/javascripts/edit_collection_tags.js b/apps/workbench/app/assets/javascripts/edit_collection_tags.js index 26b0ba7eb9..8dc9d6138f 100644 --- a/apps/workbench/app/assets/javascripts/edit_collection_tags.js +++ b/apps/workbench/app/assets/javascripts/edit_collection_tags.js @@ -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('

We are sorry. There was an error saving tags. Please try again.

'); }); + }). + on('click', '.collection-tag-cancel', function(e){ + $.ajax($(location).attr('pathname')+'/tags', { + type: 'POST' + }); }); jQuery(function($){ diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb index 8b3cc2feb8..8e1e8a5b52 100644 --- a/apps/workbench/app/controllers/collections_controller.rb +++ b/apps/workbench/app/controllers/collections_controller.rb @@ -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 diff --git a/apps/workbench/app/views/collections/_show_tags.html.erb b/apps/workbench/app/views/collections/_show_tags.html.erb index e1b0de7ae2..54c9c5c341 100644 --- a/apps/workbench/app/views/collections/_show_tags.html.erb +++ b/apps/workbench/app/views/collections/_show_tags.html.erb @@ -34,10 +34,12 @@
- <%= 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 %> - + <%= 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 %>
diff --git a/apps/workbench/app/views/collections/save_tags.js.erb b/apps/workbench/app/views/collections/save_tags.js.erb index e69de29bb2..e2faff169a 100644 --- a/apps/workbench/app/views/collections/save_tags.js.erb +++ b/apps/workbench/app/views/collections/save_tags.js.erb @@ -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 index 0000000000..e2faff169a --- /dev/null +++ b/apps/workbench/app/views/collections/tags.js.erb @@ -0,0 +1 @@ +$(".collection-tag-rows").html("<%= escape_javascript(render partial: 'show_tag_rows', locals: {object: @object}) %>"); diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb index 880cc15f6d..5bd484956f 100644 --- a/apps/workbench/config/routes.rb +++ b/apps/workbench/config/routes.rb @@ -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', -- 2.30.2