tkh_menus 0.2.2 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
 
4
4
 
5
+ ## 0.3.2
6
+
7
+ * Refactored the language switchers
8
+
9
+
10
+ ## 0.3.1
11
+
12
+ * Fixed typo bug in 3 locale files
13
+
14
+
15
+ ## 0.3
16
+
17
+ * Added tab admin menu navigation.
18
+ * Set up many translations
19
+ * Autocomplete of the parent menu in form
20
+ * Added Italian to the full name hash
21
+
22
+
5
23
  ## 0.2.2
6
24
 
7
25
  * Removed automatic blog link from menu navbar partial.
data/app/models/menu.rb CHANGED
@@ -5,7 +5,7 @@ end
5
5
 
6
6
  class Menu < ActiveRecord::Base
7
7
 
8
- attr_accessible :name, :path, :position, :parent_id
8
+ attr_accessible :name, :path, :position, :parent_id, :parent_menu_name
9
9
 
10
10
  validates_presence_of :name, :path
11
11
 
@@ -15,6 +15,7 @@ class Menu < ActiveRecord::Base
15
15
  name ? "#{id}-#{name.to_url}" : id
16
16
  end
17
17
 
18
+ scope :alphabetical, order('name')
18
19
  scope :ordered, order('position, id')
19
20
  # tree scopes
20
21
  scope :orphans, where('parent_id IS ?', nil)
@@ -44,4 +45,17 @@ class Menu < ActiveRecord::Base
44
45
  Menu.with_parent_id(parent_id)
45
46
  end
46
47
 
48
+ ### autocomplete related instance methods
49
+ def parent_menu_name
50
+ parent.try(:name) unless self.orphan?
51
+ end
52
+
53
+ def parent_menu_name=(name)
54
+ if name.present? && Menu.find_by_name(name)
55
+ self.parent_id = Menu.find_by_name(name).id
56
+ else
57
+ self.parent_id = nil
58
+ end
59
+ end
60
+
47
61
  end
@@ -2,9 +2,17 @@
2
2
  <%= f.error_notification %>
3
3
 
4
4
  <div class="form-inputs">
5
- <%= f.input :name, hint: 'should be rather short as it will figure in navbar and space there is at a premium' %>
6
- <%= f.input :path, hint: 'the url the menu is pointing to' %>
7
- <%= f.input :parent_id, hint: 'for nested menu items' %>
5
+ <%= f.input :name, label: t('activerecord.attributes.menu.name'), hint: t('menus.hint.name') %>
6
+ <%= f.input :path, label: t('activerecord.attributes.menu.path'), hint: t('menus.hint.path') %>
7
+ <%# = f.input :parent_id, label: t('activerecord.attributes.menu.parent'), hint: t('menus.hint.parent') %>
8
+ <%= f.input :parent_menu_name,
9
+ as: :string,
10
+ :wrapper_html => { :id => 'parent-menu-name' },
11
+ label: t('activerecord.attributes.menu.parent'),
12
+ :input_html => {
13
+ :data => { provide: 'typeahead',
14
+ source: Menu.orphans.alphabetical.map(&:name).to_json }
15
+ } %>
8
16
  </div>
9
17
 
10
18
  <div class="form-actions">
@@ -0,0 +1,5 @@
1
+ <ul class="nav nav-tabs" id="admin-menu-tab">
2
+ <%= content_tag :li, link_to(t('new'), new_menu_path), ({ class: 'active' } if controller.action_name.to_s == 'new' ) %>
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'), menus_path), ({ class: 'active' }) if controller.action_name.to_s == 'edit' %>
5
+ </ul>
@@ -1,2 +1,6 @@
1
+ <h1><%= t('activerecord.models.menus') %></h1>
2
+
3
+ <%= render 'tab_admin_menu' %>
4
+
1
5
  <%= render 'form' %>
2
6
  <%= render 'shared/admin_sidebar' %>
@@ -1,12 +1,14 @@
1
- <h1>Listing Menus</h1>
1
+ <h1><%= t('activerecord.models.menus') %></h1>
2
+
3
+ <%= render 'tab_admin_menu' %>
2
4
 
3
5
  <table class='table table-striped'>
4
6
  <thead>
5
7
  <tr>
6
- <th><%= t( 'activerecord.attributes.menus.name').capitalize %></th>
7
- <th><%= t( 'activerecord.attributes.menus.path').capitalize %></th>
8
- <th><%= t( 'activerecord.attributes.menus.parent').capitalize %></th>
9
- <th>Actions</th>
8
+ <th><%= t('activerecord.attributes.menu.name') %></th>
9
+ <th><%= t('activerecord.attributes.menu.path') %></th>
10
+ <th><%= t('activerecord.attributes.menu.parent') %></th>
11
+ <th><%= t('actions') %></th>
10
12
  </tr>
11
13
  </thead>
12
14
 
@@ -23,6 +25,6 @@
23
25
  </tbody>
24
26
  </table>
25
27
 
26
- <%= link_to t('menus.create_new').capitalize, new_menu_path, class: 'btn btn-primary' %>
28
+ <%= link_to t('menus.create_new'), new_menu_path, class: 'btn btn-primary' %>
27
29
 
28
30
  <%= render 'shared/admin_sidebar' %>
@@ -1,2 +1,6 @@
1
+ <h1><%= t('activerecord.models.menus') %></h1>
2
+
3
+ <%= render 'tab_admin_menu' %>
4
+
1
5
  <%= render 'form' %>
2
6
  <%= render 'shared/admin_sidebar' %>
@@ -1,23 +1,11 @@
1
- <% def full_language_name( lang = :en) %>
2
- <% list = { :en => 'English',
3
- :fr => 'Français',
4
- :es => 'Español',
5
- :de => 'Deutsch'
6
- }
7
- %>
8
- <% list[lang] %>
9
- <% end %>
10
-
11
1
  <% if I18n.available_locales.size > 1 %>
12
2
 
13
3
  <div class="btn-group">
14
- <a class="btn btn-medium btn-primary btn-success dropdown-toggle" data-toggle="dropdown" href="#">
15
- <%= full_language_name(I18n.locale) %>
16
- <span class="caret"></span>
4
+ <a class="btn btn-medium btn-primary btn-success dropdown-toggle" data-toggle="dropdown" href="#"><%= t('full_name') %>&nbsp;<span class="caret"></span>
17
5
  </a>
18
6
  <ul class="dropdown-menu">
19
7
  <% for loc in I18n.available_locales %>
20
- <%= content_tag( :li, link_to( full_language_name(loc), :locale => loc )) unless loc.to_s == I18n.locale.to_s %>
8
+ <%= content_tag( :li, link_to( t('full_name', locale: loc), :locale => loc )) unless loc.to_s == I18n.locale.to_s %>
21
9
  <% end %>
22
10
  </ul>
23
11
  </div>
@@ -1,20 +1,10 @@
1
1
  <% if I18n.available_locales.size > 1 %>
2
2
 
3
- <% def full_language_name( lang = :en) %>
4
- <% list = { :en => 'English',
5
- :fr => 'Français',
6
- :es => 'Español',
7
- :de => 'Deutsch'
8
- }
9
- %>
10
- <% list[lang] %>
11
- <% end %>
12
-
13
3
  <li class="dropdown active">
14
- <a class="dropdown-toggle" data-toggle="dropdown" href="#"><%= full_language_name(I18n.locale) %><span class="caret"></span></a>
4
+ <a class="dropdown-toggle" data-toggle="dropdown" href="#"><%= t('full_name') %>&nbsp;<span class="caret"></span></a>
15
5
  <ul class="dropdown-menu">
16
6
  <% for loc in I18n.available_locales %>
17
- <%= content_tag( :li, link_to( full_language_name(loc), :locale => loc )) unless loc.to_s == I18n.locale.to_s %>
7
+ <%= content_tag( :li, link_to(t('full_name', locale: loc), :locale => loc)) unless loc.to_s == I18n.locale.to_s %>
18
8
  <% end %>
19
9
  </ul>
20
10
  </li>
@@ -22,7 +22,7 @@
22
22
  <% Menu.orphans.ordered.each do |menu| %>
23
23
  <% if menu.has_children? %>
24
24
  <li class='dropdown'>
25
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">menu.name <b class="caret"></b></a>
25
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= menu.name %> <b class="caret"></b></a>
26
26
  <ul class="dropdown-menu">
27
27
  <%= content_tag :li, link_to(menu.name, menu.path) %>
28
28
  <li class="divider"></li>
@@ -1,19 +1,24 @@
1
1
  de:
2
2
 
3
- are_you_sure: 'Bist Du sicher?'
4
- delete: 'löschen'
5
- edit: 'bearbeiten'
6
3
  menus: 'Menüs'
7
4
 
8
- activerecord:
5
+ activerecord:
6
+ models:
7
+ menu: 'Menü'
8
+ menus: 'Menüs'
9
+
9
10
  attributes:
10
- menus:
11
+ menu:
11
12
  name: "Name"
12
13
  path: 'Pfad'
13
14
  parent: 'Haupmenü'
14
15
 
15
16
  menus:
16
- create_new: 'erstelle neues Menü'
17
+ create_new: 'Erstelle neues Menü'
18
+ hint:
19
+ name: 'Sollte eher kurz sein, da er in die Navigationsleiste kommt und der Platz dort kostbar ist'
20
+ path: 'Die Url zu der das Menü hinführt. Beispiel: /blog oder http://tenthousandhours.eu'
21
+ parent: 'Für die zweite Ebene der Untermenüs'
17
22
 
18
23
  create:
19
24
  notice: 'Das Menü wurde erfolgreich erstellt.'
@@ -22,4 +27,4 @@ de:
22
27
  notice: 'Das Menü wurde erfolgreich aktualisiert.'
23
28
  warning: 'Beim Speichern des Menüs ist ein Fehler aufgetreten'
24
29
  destroy:
25
- notice: 'Das Menü wurde gelöscht'
30
+ notice: 'Das Menü wurde gelöscht'
@@ -1,20 +1,24 @@
1
1
  en:
2
2
 
3
- are_you_sure: 'are you sure?'
4
- delete: 'delete'
5
- edit: 'edit'
6
- menus: 'menus'
3
+ menus: 'menus' # legacy. needed?
7
4
 
8
-
9
- activerecord:
5
+ activerecord:
6
+ models:
7
+ menu: 'menu'
8
+ menus: 'menus'
9
+
10
10
  attributes:
11
- menus:
11
+ menu:
12
12
  name: "name"
13
13
  path: 'path'
14
14
  parent: 'parent menu'
15
15
 
16
16
  menus:
17
17
  create_new: 'create new menu'
18
+ hint:
19
+ name: 'should be rather short as it will figure in navigation bar and space there is at a premium'
20
+ path: 'the url the menu is pointing to. Example: /blog ou http://tenthousandhours.eu'
21
+ parent: 'for second level sub-menu items'
18
22
 
19
23
  create:
20
24
  notice: 'The menu was successfully created.'
@@ -23,4 +27,4 @@ en:
23
27
  notice: 'The menu was successfully updated.'
24
28
  warning: 'There was a problem saving the menu'
25
29
  destroy:
26
- notice: 'The menu was deleted'
30
+ notice: 'The menu was deleted'
@@ -1,20 +1,24 @@
1
1
  es:
2
2
 
3
- are_you_sure: 'are you sure?'
4
- delete: 'delete'
5
- edit: 'edit'
6
3
  menus: 'menus'
7
4
 
8
-
9
- activerecord:
5
+ activerecord:
6
+ models:
7
+ menu: 'menu'
8
+ menus: 'menus'
9
+
10
10
  attributes:
11
- menus:
11
+ menu:
12
12
  name: "name"
13
13
  path: 'path'
14
14
  parent: 'parent menu'
15
15
 
16
16
  menus:
17
17
  create_new: 'create new menu'
18
+ hint:
19
+ name: 'should be rather short as it will figure in navigation bar and space there is at a premium'
20
+ path: 'the url the menu is pointing to. Example: /blog ou http://tenthousandhours.eu'
21
+ parent: 'for second level sub-menu items'
18
22
 
19
23
  create:
20
24
  notice: 'The menu was successfully created.'
@@ -23,4 +27,4 @@ es:
23
27
  notice: 'The menu was successfully updated.'
24
28
  warning: 'There was a problem saving the menu'
25
29
  destroy:
26
- notice: 'The menu was deleted'
30
+ notice: 'The menu was deleted'
@@ -1,19 +1,24 @@
1
1
  fr:
2
2
 
3
- are_you_sure: 'êtes vous sûr ?'
4
- delete: 'supprimer'
5
- edit: 'modifier'
6
3
  menus: 'menus'
7
4
 
8
- activerecord:
5
+ activerecord:
6
+ models:
7
+ menu: 'menu'
8
+ menus: 'les menus'
9
+
9
10
  attributes:
10
- menus:
11
+ menu:
11
12
  name: "nom"
12
- path: 'adresse'
13
- parent: 'menu parent'
13
+ path: 'chemin'
14
+ parent: 'parent du menu'
14
15
 
15
16
  menus:
16
17
  create_new: 'créer un nouveau menu'
18
+ hint:
19
+ name: 'doit être assez court pour se placer sur la barre de navigation sans encombre'
20
+ path: "l'URL de la page web qui correspond a ce menu. Par exemple /blog ou http://tenthousandhours.eu"
21
+ parent: 'pour les sous-menus de deuxième niveau'
17
22
 
18
23
  create:
19
24
  notice: 'Le menu a été créé.'
@@ -22,4 +27,4 @@ fr:
22
27
  notice: 'Les changements de ce menu ont été sauvegardés'
23
28
  warning: "Il y'a eu un probleme et les changements de ce menu n'ont pas été sauvegardés"
24
29
  destroy:
25
- notice: 'Le menu a été supprimé'
30
+ notice: 'Le menu a été supprimé'
@@ -0,0 +1,30 @@
1
+ it:
2
+
3
+ menus: 'menus'
4
+
5
+ activerecord:
6
+ models:
7
+ menu: 'menu'
8
+ menus: 'menus'
9
+
10
+ attributes:
11
+ menu:
12
+ name: "name"
13
+ path: 'path'
14
+ parent: 'parent menu'
15
+
16
+ menus:
17
+ create_new: 'create new menu'
18
+ hint:
19
+ name: 'should be rather short as it will figure in navigation bar and space there is at a premium'
20
+ path: 'the url the menu is pointing to. Example: /blog ou http://tenthousandhours.eu'
21
+ parent: 'for second level sub-menu items'
22
+
23
+ create:
24
+ notice: 'The menu was successfully created.'
25
+ warning: 'There was a problem saving the menu'
26
+ update:
27
+ notice: 'The menu was successfully updated.'
28
+ warning: 'There was a problem saving the menu'
29
+ destroy:
30
+ notice: 'The menu was deleted'
@@ -1,3 +1,3 @@
1
1
  module TkhMenus
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.2"
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.2.2
4
+ version: 0.3.2
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: 2013-01-27 00:00:00.000000000 Z
12
+ date: 2013-02-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -103,6 +103,7 @@ files:
103
103
  - app/controllers/menus_controller.rb
104
104
  - app/models/menu.rb
105
105
  - app/views/menus/_form.html.erb
106
+ - app/views/menus/_tab_admin_menu.html.erb
106
107
  - app/views/menus/edit.html.erb
107
108
  - app/views/menus/index.html.erb
108
109
  - app/views/menus/new.html.erb
@@ -117,6 +118,7 @@ files:
117
118
  - lib/generators/tkh_menus/create_or_update_locales/templates/en.yml
118
119
  - lib/generators/tkh_menus/create_or_update_locales/templates/es.yml
119
120
  - lib/generators/tkh_menus/create_or_update_locales/templates/fr.yml
121
+ - lib/generators/tkh_menus/create_or_update_locales/templates/it.yml
120
122
  - lib/generators/tkh_menus/create_or_update_migrations/create_or_update_migrations_generator.rb
121
123
  - lib/generators/tkh_menus/create_or_update_migrations/templates/add_menu_position_to_pages.rb
122
124
  - lib/generators/tkh_menus/create_or_update_migrations/templates/create_menus.rb
@@ -171,7 +173,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
173
  version: '0'
172
174
  segments:
173
175
  - 0
174
- hash: 3342123741814739327
176
+ hash: 3984902534821179842
175
177
  required_rubygems_version: !ruby/object:Gem::Requirement
176
178
  none: false
177
179
  requirements:
@@ -180,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
182
  version: '0'
181
183
  segments:
182
184
  - 0
183
- hash: 3342123741814739327
185
+ hash: 3984902534821179842
184
186
  requirements: []
185
187
  rubyforge_project:
186
188
  rubygems_version: 1.8.23