1+ <%
2+ showed_any_tags = false
3+ %>
4+
5+ <h2 class ="grey-text " style ="font-size: 2rem "> Your Notebook.ai tags</ h2 >
6+ < ul class ="collapsible ">
7+ <% Rails . application . config . content_types [ :all ] . each do |content_type | %>
8+ <%
9+ grouped_tags = PageTag . where ( page_type : content_type . name , user_id : current_user ) . order ( 'tag ASC' ) . group_by ( &:tag )
10+
11+ next if grouped_tags . values . length == 0
12+
13+ showed_any_tags = true
14+ %>
15+
16+ < li >
17+ < div class ="collapsible-header ">
18+ < i class ="material-icons <%= content_type . text_color %> "> <%= content_type . icon %> </ i >
19+ <%= content_type . name %> tags
20+ < span class ="badge "> <%= grouped_tags . values . length %> </ span >
21+ </ div >
22+ < div class ="collapsible-body ">
23+ <% grouped_tags . each do |tag , page_list | %>
24+ < div class ="row " style ="border-bottom: 1px solid #ccc; padding-bottom: 2em; margin-bottom: 2em ">
25+ < div class ="col s12 m6 l4 ">
26+ < div >
27+ <%=
28+ link_to send (
29+ "#{ content_type . name . downcase . pluralize } _path" ,
30+ slug : PageTagService . slug_for ( tag )
31+ ) do
32+ %>
33+ < span class ="<%= content_type . color %> white-text " style ="padding: 0.3em 0.4em; font-size: 1em ">
34+ <%= tag %>
35+ </ span >
36+ <% end %>
37+ </ div >
38+ < div class ="grey-text " style ="padding-top: 1em ">
39+ Used by <%= pluralize page_list . length , 'page' %>
40+ </ div >
41+ < div >
42+ <%=
43+ link_to 'Delete this tag' , tag_remove_path (
44+ page_type : content_type . name ,
45+ slug : PageTagService . slug_for ( tag )
46+ ) , data : {
47+ confirm : "Are you sure? This will delete this tag and remove it from all pages."
48+ } , class : 'red-text'
49+ %>
50+ </ div >
51+ </ div >
52+ < div class ="col s12 m6 l8 ">
53+ <% page_list . each do |page_tag | %>
54+ < div class ="chip js-load-page-name " data-klass ="<%= page_tag . page_type %> " data-id ="<%= page_tag . page_id %> ">
55+ <%= link_to send ( "#{ page_tag . page_type . downcase } _path" , page_tag . page_id ) do %>
56+ < span class ="<%= content_type . text_color %> ">
57+ < i class ="material-icons left ">
58+ <%= content_type . icon %>
59+ </ i >
60+ </ span >
61+ < span class ="name-container ">
62+ < em > Loading <%= content_type . name %> name...</ em >
63+ </ span >
64+ <% end %>
65+ </ div >
66+ <% end %>
67+ </ div >
68+ </ div >
69+ <% end %>
70+ </ div >
71+ </ li >
72+ <% end %>
73+ </ ul >
74+
75+ <% if !showed_any_tags %>
76+ < div class ="card-panel ">
77+ When you create tags for your pages, they'll appear here. Come back later when you've added some!
78+ </ div >
79+ <% end %>
0 commit comments