Skip to content

Commit a243e18

Browse files
committed
add the ability to remove specific tags from tag management page
1 parent 94bfb0f commit a243e18

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

app/controllers/page_tags_controller.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class PageTagsController < ApplicationController
2+
# Remove a tag and all of its links to a page
23
def remove
34
# Params
45
# {"page_type"=>"Location", "slug"=>"mountains", "controller"=>"page_tags", "action"=>"remove"
@@ -12,4 +13,11 @@ def remove
1213

1314
return redirect_back fallback_location: root_path, notice: 'Tag deleted successfully.'
1415
end
16+
17+
# Destroy a specific tag by ID
18+
def destroy
19+
PageTag.find_by(id: params[:id], user_id: current_user.id).destroy!
20+
21+
return redirect_back fallback_location: root_path, notice: 'Tag deleted successfully.'
22+
end
1523
end

app/views/data/tags.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
<em>Loading <%= content_type.name %> name...</em>
6363
</span>
6464
<% end %>
65+
<%= link_to destroy_specific_tag_path(page_tag), method: :delete, class: 'tooltipped', data: { tooltip: 'Remove this tag' } do %>
66+
<i class="close material-icons">close</i>
67+
<% end %>
6568
</div>
6669
<% end %>
6770
</div>

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
get '/scratchpad', to: 'main#notes', as: :notes
100100

101101
get 'tag/remove', to: 'page_tags#remove'
102+
delete 'tag/:id/destroy', to: 'page_tags#destroy', as: :destroy_specific_tag
102103

103104
# Legacy route: left intact so /my/documents/X URLs continue to work for everyone's bookmarks
104105
resources :documents

0 commit comments

Comments
 (0)