Skip to content

Commit 3475a3b

Browse files
committed
add page tag controller with remove method
1 parent 80cbfd5 commit 3475a3b

File tree

7 files changed

+33
-1
lines changed

7 files changed

+33
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class PageTagsController < ApplicationController
2+
def remove
3+
end
4+
end

app/helpers/page_tags_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module PageTagsHelper
2+
end

app/views/data/tags.html.erb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,19 @@
2929
</span>
3030
<% end %>
3131
</div>
32-
<div class="grey-text">
32+
<div class="grey-text" style="padding-top: 1em">
3333
Used by <%= pluralize page_list.length, 'page' %>
3434
</div>
35+
<div>
36+
<%=
37+
link_to 'Delete this tag', tag_remove_path(
38+
page_type: content_type.name,
39+
slug: PageTagService.slug_for(tag)
40+
), data: {
41+
confirm: "Are you sure? This will delete this tag and remove it from all pages."
42+
}
43+
%>
44+
</div>
3545
</div>
3646
<div class="col s12 m6 l8">
3747
<% page_list.each do |page_tag| %>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>PageTags#remove</h1>
2+
<p>Find me in app/views/page_tags/remove.html.erb</p>

config/routes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@
9898

9999
get '/scratchpad', to: 'main#notes', as: :notes
100100

101+
get 'tag/remove'
102+
101103
# Legacy route: left intact so /my/documents/X URLs continue to work for everyone's bookmarks
102104
resources :documents
103105

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require 'test_helper'
2+
3+
class PageTagsControllerTest < ActionDispatch::IntegrationTest
4+
test "should get remove" do
5+
get page_tags_remove_url
6+
assert_response :success
7+
end
8+
9+
end

0 commit comments

Comments
 (0)