golden-menu 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a9e1ca8781107e28df6d6418e7a2a1d5443089c
4
- data.tar.gz: b8dd7c33402a20495f4545b2c94baf6f0236193b
3
+ metadata.gz: 24aad3f23c4d5d4eff16137628f0827c1f55f25d
4
+ data.tar.gz: 27d23e3f7d04850289387cd766df0a43280cefee
5
5
  SHA512:
6
- metadata.gz: ed26d208087a54659e146a00c895074329f2fd691b3f0a0a39f249dc4c2e2f3eabea95ae5fd565c964fac5e9246752a09de6b7687c972a9eedd639a9f79c63ff
7
- data.tar.gz: 62748ad8a8d3537e824a9d100a9ec6225325a6388e1b4c050360a1a89e2ef834d883eec27680784de5711817ee06812da7b259ece5cab89abd0c1f0015cef284
6
+ metadata.gz: 39d51c4c7da2ddb3d8a0744649492bede430066e095c2f503181a56e367a4eaf677baecfd59adedb71dd965bb8b0911fb820cadb1bdfb30c27d3b271c3a85b5a
7
+ data.tar.gz: 0e60e9501cd1db96a00ba01cefe6d53bceffd6351f0ffa7a825b7c32ea4f348ce0bbd35d7198395e9d8bfa3758cf6508888f888f46b1f80318e910c5cc95d9e6
data/README.md CHANGED
@@ -7,8 +7,7 @@ The `golden-menu` creates menus by building a hierarchiacal tree first and linki
7
7
  For Rails 4 project, `Gemfile` should have
8
8
 
9
9
  ```ruby
10
- gem 'protected_attributes'
11
- gem 'devise', '~> 3.0.0.rc'
10
+ gem 'devise', '> 3.0'
12
11
  gem 'cancan'
13
12
  gem 'simple_form', '~> 3.0.0.rc'
14
13
  gem 'anjlab-bootstrap-rails', require: 'bootstrap-rails'
@@ -2,6 +2,7 @@ class Golden::Menu::HierarchicalMenusController < ApplicationController
2
2
  include ::TheSortableTreeController::Rebuild
3
3
 
4
4
  before_filter :authenticate_session!
5
+ before_filter :new_menu, only: [:create]
5
6
  load_and_authorize_resource :menu, class: 'Golden::Menu::HierarchicalMenu', parent: false #, find_by: :url
6
7
 
7
8
  def index
@@ -26,7 +27,7 @@ class Golden::Menu::HierarchicalMenusController < ApplicationController
26
27
  end
27
28
 
28
29
  def update
29
- @menu.update_attributes params[:menu]
30
+ @menu.update_attributes menu_params
30
31
  respond_with @menu
31
32
  end
32
33
 
@@ -42,6 +43,18 @@ class Golden::Menu::HierarchicalMenusController < ApplicationController
42
43
 
43
44
  protected
44
45
 
46
+ def menu_params
47
+ if params.respond_to? :permit
48
+ params.require(:menu).permit(Golden::Menu.permitted_fields)
49
+ else
50
+ params[:menu]
51
+ end
52
+ end
53
+
54
+ def new_menu
55
+ @menu = Golden::Menu::HierarchicalMenu.new menu_params
56
+ end
57
+
45
58
  def the_define_common_variables
46
59
  ['@menu', 'menus', Golden::Menu::HierarchicalMenu]
47
60
  end
@@ -1,7 +1,6 @@
1
1
  module Golden::Menu::GoldenMenuResource
2
2
  extend ActiveSupport::Concern
3
3
  included do
4
- attr_accessible :menu_ids
5
4
  has_many :menu_resources, class_name: 'Golden::Menu::MenuResource', as: :resource
6
5
  has_many :menus, class_name: 'Golden::Menu::HierarchicalMenu', through: :menu_resources
7
6
  end
@@ -3,8 +3,6 @@ class Golden::Menu::HierarchicalMenu < ActiveRecord::Base
3
3
 
4
4
  self.table_name = 'golden_menus'
5
5
 
6
- attr_accessible :group, :name, :description, :parent_id, :resource_url
7
-
8
6
  validates :name, presence: true
9
7
  validates :url, format: { with: /\A([\w\-]{3,})\z/ }, allow_blank: true
10
8
 
@@ -17,7 +17,7 @@
17
17
  <td><%= menu.description %></td>
18
18
  <td><%= menu.parent.try :name %></td>
19
19
  <td><%= menu.menu_resources.count %></td>
20
- <td>
20
+ <td class="actions">
21
21
  <%= render_btn_group do |btn|
22
22
  if can? :show, menu
23
23
  btn << link_to_show(menu)
@@ -38,6 +38,7 @@ en:
38
38
  hints:
39
39
  golden_menu/hierarchical_menu:
40
40
  menu:
41
+ name: 'Only characters, numbers and, - are allowed. Minimal 3 characters requied.'
41
42
  group: 'Only root menus (blank parent) need to choose a group'
42
43
  resource_url: 'fill redirect URL while click menu'
43
44
  placeholders:
@@ -38,6 +38,7 @@ zh-TW:
38
38
  hints:
39
39
  golden_menu_hierarchical_menu:
40
40
  menu:
41
+ name: '僅限用英文字母(不限大小寫)、阿拉伯數字、底線(_)和破折號(-),至少三個字元'
41
42
  group: '只有最頂層的選單(父層為空者)需要選擇群組'
42
43
  resource_url: '可選填點擊時連結的網址'
43
44
  placeholders:
@@ -8,4 +8,7 @@ Golden::Menu.configure do |config|
8
8
  #config.translate_group_block = lambda do |group|
9
9
  # I18n.t(group, scope: 'golden.menu.groups')
10
10
  #end
11
+
12
+ # Add more allowed fields for strong paramters.
13
+ #config.permitted_fields += []
11
14
  end
@@ -11,6 +11,11 @@ module Golden
11
11
  I18n.t(group, scope: 'golden.menu.groups')
12
12
  }
13
13
 
14
+ mattr_accessor :permitted_fields
15
+ @@permitted_fields = [
16
+ :group, :name, :description, :parent_id, :resource_url, :memu_ids
17
+ ]
18
+
14
19
  def self.configure
15
20
  yield self
16
21
  end
@@ -1,5 +1,5 @@
1
1
  module Golden
2
2
  module Menu
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: golden-menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tse-Ching Ho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-13 00:00:00.000000000 Z
11
+ date: 2013-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties