tkh_menus 0.0.2 → 0.1

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.
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
 
4
4
 
5
+ ## 0.1
6
+
7
+ * Implemented the reordering of context menus
8
+
9
+
5
10
  ## 0.0.2
6
11
 
7
12
  * Added German translation strings
Binary file
@@ -0,0 +1,6 @@
1
+ jQuery ->
2
+ $('.draggable').sortable
3
+ axis: 'y'
4
+ handle: '.handle'
5
+ update: ->
6
+ $.post($(this).data('update-url'), $(this).sortable('serialize'))
@@ -1,21 +1,52 @@
1
1
  <% content_for :context_menu do %>
2
- <% if @page %>
3
- <% if @page.has_children? %>
4
- <h2><%= @page.nickname %></h2>
5
- <ul>
6
- <% for page in @page.children %>
7
- <%= content_tag :li, link_to(page.nickname, page) %>
8
- <% end %>
9
- </ul>
10
- <% end %>
11
2
 
12
- <% if !@page.orphan? && @page.has_siblings? %>
13
- <h2><%= link_to @page.parent.nickname, @page.parent %></h2>
14
- <ul>
15
- <% for page in @page.siblings %>
16
- <%= content_tag :li, link_to(page.nickname, page) %>
17
- <% end %>
18
- </ul>
19
- <% end %>
3
+ <% unless administrator? # basic functionality for all users %>
4
+ <% if @page %>
5
+ <% if @page.has_children? %>
6
+ <h2><%= @page.nickname %></h2>
7
+ <ul>
8
+ <% for page in @page.children %>
9
+ <%= content_tag :li, link_to(page.nickname, page) %>
10
+ <% end %>
11
+ </ul>
12
+ <% end %>
13
+
14
+ <% if !@page.orphan? && @page.has_siblings? %>
15
+ <h2><%= link_to @page.parent.nickname, @page.parent %></h2>
16
+ <ul>
17
+ <% for page in @page.siblings %>
18
+ <%= content_tag :li, link_to(page.nickname, page) %>
19
+ <% end %>
20
+ </ul>
21
+ <% end %>
22
+ <% end -%>
23
+
24
+ <% else # administrators can reorder menu pages %>
25
+
26
+ <% if @page %>
27
+ <% if @page.has_children? %>
28
+ <h2><%= @page.nickname %></h2>
29
+ <ul class="draggable" data-update-url="<%= sort_pages_path %>">
30
+ <% for page in @page.children.by_menu_position %>
31
+ <%= content_tag :li, page, class: 'page', id: "page_#{page.id}" do %>
32
+ <%= image_tag 'drag-handle.gif', :class => 'handle silhouette' %> <%= link_to page.nickname, page -%>
33
+ <% end -%>
34
+ <% end %>
35
+ </ul>
36
+ <% end %>
37
+
38
+ <% if !@page.orphan? && @page.has_siblings? %>
39
+ <h2><%= link_to @page.parent.nickname, @page.parent %></h2>
40
+ <ul class="draggable" data-update-url="<%= sort_pages_path %>">
41
+ <% for page in @page.siblings.by_menu_position %>
42
+ <%= content_tag :li, page, class: 'page', id: "page_#{page.id}" do %>
43
+ <%= image_tag 'drag-handle.gif', :class => 'handle silhouette' %> <%= link_to page.nickname, page -%>
44
+ <% end -%>
45
+ <% end %>
46
+ </ul>
47
+ <% end %>
48
+ <% end -%>
49
+
20
50
  <% end -%>
51
+
21
52
  <% end -%>
@@ -17,6 +17,7 @@ module TkhMenus
17
17
 
18
18
  def copy_migrations
19
19
  migration_template "create_menus.rb", "db/migrate/create_menus.rb"
20
+ migration_template "add_menu_position_to_pages.rb", "db/migrate/add_menu_position_to_pages.rb"
20
21
  end
21
22
 
22
23
  end
@@ -0,0 +1,9 @@
1
+ class AddMenuPositionToPages < ActiveRecord::Migration
2
+ def up
3
+ add_column :pages, :menu_position, :integer, :default => 0
4
+ end
5
+
6
+ def down
7
+ remove_column :pages, :menu_position
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module TkhMenus
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tkh_menus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: '0.1'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-18 00:00:00.000000000 Z
12
+ date: 2013-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -98,6 +98,8 @@ executables: []
98
98
  extensions: []
99
99
  extra_rdoc_files: []
100
100
  files:
101
+ - app/assets/images/drag-handle.gif
102
+ - app/assets/javascripts/drag-and-sort.js.coffee
101
103
  - app/controllers/menus_controller.rb
102
104
  - app/models/menu.rb
103
105
  - app/views/menus/_form.html.erb
@@ -114,6 +116,7 @@ files:
114
116
  - lib/generators/tkh_menus/create_or_update_locales/templates/es.yml
115
117
  - lib/generators/tkh_menus/create_or_update_locales/templates/fr.yml
116
118
  - lib/generators/tkh_menus/create_or_update_migrations/create_or_update_migrations_generator.rb
119
+ - lib/generators/tkh_menus/create_or_update_migrations/templates/add_menu_position_to_pages.rb
117
120
  - lib/generators/tkh_menus/create_or_update_migrations/templates/create_menus.rb
118
121
  - lib/tasks/tkh_menus_tasks.rake
119
122
  - lib/tkh_menus/version.rb
@@ -166,7 +169,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
169
  version: '0'
167
170
  segments:
168
171
  - 0
169
- hash: -758630460195800702
172
+ hash: -2983082608256837938
170
173
  required_rubygems_version: !ruby/object:Gem::Requirement
171
174
  none: false
172
175
  requirements:
@@ -175,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
178
  version: '0'
176
179
  segments:
177
180
  - 0
178
- hash: -758630460195800702
181
+ hash: -2983082608256837938
179
182
  requirements: []
180
183
  rubyforge_project:
181
184
  rubygems_version: 1.8.23