tkh_menus 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/app/assets/images/{drag-handle.gif → admin/drag-handle.gif} +0 -0
- data/app/controllers/menus_controller.rb +13 -0
- data/app/models/menu.rb +13 -1
- data/app/views/menus/_tab_admin_menu.html.erb +3 -2
- data/app/views/menus/index.html.erb +2 -3
- data/app/views/menus/reorder.html.erb +13 -0
- data/app/views/shared/_context_menu_for_pages.html.erb +4 -4
- data/config/routes.rb +9 -2
- data/lib/generators/tkh_menus/create_or_update_locales/templates/de.yml +3 -1
- data/lib/generators/tkh_menus/create_or_update_locales/templates/es.yml +4 -1
- data/lib/generators/tkh_menus/create_or_update_locales/templates/fr.yml +7 -5
- data/lib/tkh_menus/version.rb +1 -1
- data/test/dummy/config/locales/en.yml +2 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e152ddfbb8fb6b47007b7b3dbe91c2fa456f8901
|
4
|
+
data.tar.gz: e4aa5e8dda6208c361cc133ed0660f6403e9d83a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3243401af3ca4ca725d875db5bf1295e3173a319e36aab70b816b7b69733d395feec8fa6d8b294177791dc33c8241c8d1777c917461ad2863a0f5e9cc26ee33
|
7
|
+
data.tar.gz: 4c5d63422012986418115bb408231a4622b70d9bf8874f1259d302e361c2e75d3ae988fc6ce591dee7c0b990857a170abe97bf8b4454fd0dec568bcf860ceb2b
|
data/CHANGELOG.md
CHANGED
File without changes
|
@@ -42,6 +42,19 @@ class MenusController < ApplicationController
|
|
42
42
|
redirect_to menus_url, notice: t('menus.destroy.notice')
|
43
43
|
end
|
44
44
|
|
45
|
+
def reorder
|
46
|
+
menu = Menu.find(params[:id])
|
47
|
+
@menus = menu.self_and_siblings.ordered
|
48
|
+
switch_to_admin_layout
|
49
|
+
end
|
50
|
+
|
51
|
+
def sort
|
52
|
+
params[:menu].each_with_index do |id, index|
|
53
|
+
Menu.update(id, position: index+1)
|
54
|
+
end
|
55
|
+
render nothing: true
|
56
|
+
end
|
57
|
+
|
45
58
|
private
|
46
59
|
|
47
60
|
# Never trust parameters from the scary internet, only allow the white list through.
|
data/app/models/menu.rb
CHANGED
@@ -33,6 +33,10 @@ class Menu < ActiveRecord::Base
|
|
33
33
|
Menu.with_parent_id(id)
|
34
34
|
end
|
35
35
|
|
36
|
+
def has_parent?
|
37
|
+
!parent_id.nil?
|
38
|
+
end
|
39
|
+
|
36
40
|
def parent
|
37
41
|
Menu.find(parent_id)
|
38
42
|
end
|
@@ -42,7 +46,15 @@ class Menu < ActiveRecord::Base
|
|
42
46
|
end
|
43
47
|
|
44
48
|
def siblings
|
45
|
-
|
49
|
+
self_and_siblings - [self]
|
50
|
+
end
|
51
|
+
|
52
|
+
def self_and_siblings
|
53
|
+
if has_parent?
|
54
|
+
parent.children
|
55
|
+
else
|
56
|
+
Menu.orphans
|
57
|
+
end
|
46
58
|
end
|
47
59
|
|
48
60
|
### autocomplete related instance methods
|
@@ -1,5 +1,6 @@
|
|
1
|
-
<ul class="nav nav-tabs" id="admin-menu-tab">
|
1
|
+
<ul class="nav nav-tabs" id="admin-menu-tab">
|
2
2
|
<%= content_tag :li, link_to(t('new'), new_menu_path), ({ class: 'active' } if controller.action_name.to_s == 'new' ) %>
|
3
3
|
<%= content_tag :li, link_to(t('list'), menus_path), ({ class: 'active' } if controller.action_name.to_s == 'index' ) %>
|
4
|
-
<%= content_tag :li, link_to(t('edit'), '#'), ({ class: 'active' }) if controller.action_name.to_s == 'edit' %>
|
4
|
+
<%= content_tag :li, link_to(t('edit'), '#'), ({ class: 'active' }) if controller.action_name.to_s == 'edit' %>
|
5
|
+
<%= content_tag :li, link_to(t('menus.reorder'), reorder_menu_path(Menu.orphans.first.id)), ({ class: 'active' } if controller.action_name.to_s == 'reorder' ) %>
|
5
6
|
</ul>
|
@@ -11,15 +11,14 @@
|
|
11
11
|
<th><%= t('actions') %></th>
|
12
12
|
</tr>
|
13
13
|
</thead>
|
14
|
-
|
14
|
+
|
15
15
|
<tbody>
|
16
16
|
<% @menus.each do |menu| %>
|
17
17
|
<tr>
|
18
18
|
<td><%= menu.name %></td>
|
19
19
|
<td><%= menu.path %></td>
|
20
20
|
<td><%= "#{menu.parent.id} - #{menu.parent.name}" unless menu.orphan? %></td>
|
21
|
-
<td><%= link_to t('edit'), edit_menu_path(menu), class: 'btn btn-
|
22
|
-
<%= link_to t('delete'), menu, method: :delete, data: { confirm: t('are_you_sure') }, class: 'btn btn-mini btn-danger' %></td>
|
21
|
+
<td><%= link_to t('edit'), edit_menu_path(menu), class: 'btn btn-xs btn-default' %><%= link_to t('delete'), menu, method: :delete, data: { confirm: t('are_you_sure') }, class: 'btn btn-xs btn-danger' %></td>
|
23
22
|
</tr>
|
24
23
|
<% end %>
|
25
24
|
</tbody>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%= render 'tab_admin_menu' %>
|
2
|
+
|
3
|
+
<p>Please use this page to reorder menu items within one level and one section. For reorganizing the menu hierarchy you should edit the individual menu entry's 'parent id' field.</p>
|
4
|
+
|
5
|
+
<p>To change the position of menu items in this list use the little handle to drag entries up or down.</p>
|
6
|
+
|
7
|
+
<ul class="draggable" data-update-url="<%= sort_menus_path %>">
|
8
|
+
<% for menu in @menus %>
|
9
|
+
<%= content_tag_for :li, menu, class: 'handle' do %>
|
10
|
+
<%= image_tag 'admin/drag-handle.gif', :class => 'handle' %> <%= menu.id.to_s + ". " + menu.name.to_s -%>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
</ul>
|
@@ -18,7 +18,7 @@
|
|
18
18
|
</ul>
|
19
19
|
<% end %>
|
20
20
|
<% end -%>
|
21
|
-
|
21
|
+
|
22
22
|
<% else # administrators can reorder menu pages %>
|
23
23
|
|
24
24
|
<% if @page %>
|
@@ -27,7 +27,7 @@
|
|
27
27
|
<ul class="draggable" data-update-url="<%= sort_pages_path %>">
|
28
28
|
<% for page in @page.children.by_menu_position %>
|
29
29
|
<%= content_tag :li, page, class: 'page', id: "page_#{page.id}" do %>
|
30
|
-
<%= image_tag 'drag-handle.gif', :class => 'handle silhouette' %> <%= link_to page.nickname, page -%>
|
30
|
+
<%= image_tag 'admin/drag-handle.gif', :class => 'handle silhouette' %> <%= link_to page.nickname, page -%>
|
31
31
|
<% end -%>
|
32
32
|
<% end %>
|
33
33
|
</ul>
|
@@ -38,11 +38,11 @@
|
|
38
38
|
<ul class="draggable" data-update-url="<%= sort_pages_path %>">
|
39
39
|
<% for page in @page.siblings.by_menu_position %>
|
40
40
|
<%= content_tag :li, page, class: 'page', id: "page_#{page.id}" do %>
|
41
|
-
<%= image_tag 'drag-handle.gif', :class => 'handle silhouette' %> <%= link_to page.nickname, page -%>
|
41
|
+
<%= image_tag 'admin/drag-handle.gif', :class => 'handle silhouette' %> <%= link_to page.nickname, page -%>
|
42
42
|
<% end -%>
|
43
43
|
<% end %>
|
44
44
|
</ul>
|
45
45
|
<% end %>
|
46
46
|
<% end -%>
|
47
|
-
|
47
|
+
|
48
48
|
<% end -%>
|
data/config/routes.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
fr:
|
2
|
-
|
2
|
+
|
3
3
|
menus: 'menus'
|
4
|
-
|
4
|
+
|
5
5
|
activerecord:
|
6
6
|
models:
|
7
7
|
menu: 'menu'
|
8
8
|
menus: 'les menus'
|
9
|
-
|
9
|
+
|
10
10
|
attributes:
|
11
11
|
menu:
|
12
12
|
name: "nom"
|
13
13
|
path: 'chemin'
|
14
14
|
parent: 'parent du menu'
|
15
|
-
|
15
|
+
|
16
16
|
menus:
|
17
17
|
create_new: 'créer un nouveau menu'
|
18
18
|
hint:
|
19
19
|
name: 'doit être assez court pour se placer sur la barre de navigation sans encombre'
|
20
20
|
path: "l'URL de la page web qui correspond a ce menu. Par exemple /blog ou http://tenthousandhours.eu"
|
21
21
|
parent: 'pour les sous-menus de deuxième niveau'
|
22
|
-
|
22
|
+
|
23
23
|
create:
|
24
24
|
notice: 'Le menu a été créé.'
|
25
25
|
warning: "Il y'a eu un probleme et le menu n'a pas été sauvegardé"
|
@@ -28,3 +28,5 @@ fr:
|
|
28
28
|
warning: "Il y'a eu un probleme et les changements de ce menu n'ont pas été sauvegardés"
|
29
29
|
destroy:
|
30
30
|
notice: 'Le menu a été supprimé'
|
31
|
+
|
32
|
+
reorder: 'organiser'
|
data/lib/tkh_menus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tkh_menus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Swami Atma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02
|
11
|
+
date: 2014-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -87,7 +87,7 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
-
- app/assets/images/drag-handle.gif
|
90
|
+
- app/assets/images/admin/drag-handle.gif
|
91
91
|
- app/assets/javascripts/drag-and-sort.js.coffee
|
92
92
|
- app/controllers/menus_controller.rb
|
93
93
|
- app/models/menu.rb
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- app/views/menus/edit.html.erb
|
97
97
|
- app/views/menus/index.html.erb
|
98
98
|
- app/views/menus/new.html.erb
|
99
|
+
- app/views/menus/reorder.html.erb
|
99
100
|
- app/views/shared/_context_menu.html.erb
|
100
101
|
- app/views/shared/_context_menu_for_levels.html.erb
|
101
102
|
- app/views/shared/_context_menu_for_pages.html.erb
|