manage 1.3.30 → 1.3.31

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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -20
  3. data/Rakefile +31 -31
  4. data/app/assets/javascripts/manage/collection_actions.js.coffee +30 -30
  5. data/app/assets/javascripts/manage/handlers.js.coffee +46 -46
  6. data/app/assets/javascripts/manage/table_checkboxes.js.coffee +11 -11
  7. data/app/controllers/manage/application_controller.rb +13 -13
  8. data/app/controllers/manage/dashboards_controller.rb +4 -4
  9. data/app/controllers/manage/responder.rb +11 -11
  10. data/app/controllers/manage/sessions_controller.rb +11 -11
  11. data/app/helpers/manage/application_helper.rb +42 -42
  12. data/app/helpers/manage/form_helper.rb +21 -21
  13. data/app/helpers/manage/resource_helper.rb +77 -77
  14. data/app/models/admin_user.rb +4 -4
  15. data/app/views/layouts/manage/_main_menu.html.slim +52 -52
  16. data/app/views/layouts/manage/application.html.slim +39 -39
  17. data/app/views/layouts/manage/sign_in.html.slim +30 -30
  18. data/app/views/manage/resource/_form.html.slim +4 -4
  19. data/app/views/manage/resource/index/_collection_actions.html.slim +2 -2
  20. data/app/views/manage/resource/index/_count.html.slim +6 -6
  21. data/app/views/manage/resource/index/_table.html.slim +1 -1
  22. data/app/views/manage/resource/show.html.slim +10 -10
  23. data/app/views/manage/sessions/new.html.slim +10 -10
  24. data/config/initializers/devise.rb +247 -247
  25. data/config/initializers/session_store.rb +3 -3
  26. data/config/initializers/simple_form.rb +145 -145
  27. data/config/initializers/simple_form_foundation.rb +26 -26
  28. data/config/locales/devise.en.yml +59 -59
  29. data/config/locales/en.yml +20 -20
  30. data/config/routes.rb +10 -10
  31. data/db/migrate/20131204142720_create_admin_users.rb +24 -24
  32. data/lib/manage.rb +5 -5
  33. data/lib/manage/engine.rb +21 -21
  34. data/lib/manage/fields.rb +6 -6
  35. data/lib/manage/fields/reader.rb +57 -57
  36. data/lib/manage/version.rb +1 -1
  37. data/lib/tasks/manage_tasks.rake +15 -15
  38. data/lib/templates/erb/scaffold/_form.html.erb +13 -13
  39. data/spec/controllers/manage/resource_controller_spec.rb +29 -29
  40. data/spec/dummy/README.rdoc +28 -28
  41. data/spec/dummy/Rakefile +6 -6
  42. data/spec/dummy/app/assets/javascripts/application.js +13 -13
  43. data/spec/dummy/app/assets/stylesheets/application.css +13 -13
  44. data/spec/dummy/app/controllers/application_controller.rb +5 -5
  45. data/spec/dummy/app/controllers/manage/posts_controller.rb +4 -4
  46. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  47. data/spec/dummy/app/models/post.rb +3 -3
  48. data/spec/dummy/app/models/user.rb +5 -5
  49. data/spec/dummy/app/views/layouts/application.html.erb +14 -14
  50. data/spec/dummy/bin/bundle +3 -3
  51. data/spec/dummy/bin/rails +4 -4
  52. data/spec/dummy/bin/rake +4 -4
  53. data/spec/dummy/config.ru +4 -4
  54. data/spec/dummy/config/application.rb +24 -24
  55. data/spec/dummy/config/boot.rb +5 -5
  56. data/spec/dummy/config/database.yml +25 -25
  57. data/spec/dummy/config/environment.rb +5 -5
  58. data/spec/dummy/config/environments/development.rb +29 -29
  59. data/spec/dummy/config/environments/production.rb +80 -80
  60. data/spec/dummy/config/environments/test.rb +36 -36
  61. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  62. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
  63. data/spec/dummy/config/initializers/inflections.rb +16 -16
  64. data/spec/dummy/config/initializers/mime_types.rb +5 -5
  65. data/spec/dummy/config/initializers/secret_token.rb +12 -12
  66. data/spec/dummy/config/initializers/session_store.rb +3 -3
  67. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  68. data/spec/dummy/config/locales/en.yml +23 -23
  69. data/spec/dummy/config/routes.rb +10 -10
  70. data/spec/dummy/db/migrate/20130716083410_init_migration.rb +21 -21
  71. data/spec/dummy/db/schema.rb +53 -53
  72. data/spec/dummy/log/test.log +0 -0
  73. data/spec/dummy/public/404.html +58 -58
  74. data/spec/dummy/public/422.html +58 -58
  75. data/spec/dummy/public/500.html +57 -57
  76. data/spec/fields/reader_spec.rb +79 -79
  77. data/spec/spec_helper.rb +24 -24
  78. metadata +90 -88
@@ -1,21 +1,21 @@
1
- module Manage
2
-
3
- module FormHelper
4
- include SimpleForm::ActionViewExtensions::FormHelper
5
-
6
- OPTIONS = {
7
- wrapper: :foundation,
8
- class: 'custom'
9
- }
10
-
11
- def manage_form_for(record, options={}, &block)
12
- simple_form_for(record, options.merge(Manage::FormHelper::OPTIONS), &block)
13
- end
14
-
15
- def manage_fields_for(record_name, record_object = nil, options = {}, &block)
16
- simple_fields_for(record_name, record_object = nil, options.merge(Manage::FormHelper::OPTIONS), &block)
17
- end
18
-
19
- end
20
-
21
- end
1
+ module Manage
2
+
3
+ module FormHelper
4
+ include SimpleForm::ActionViewExtensions::FormHelper
5
+
6
+ OPTIONS = {
7
+ wrapper: :foundation,
8
+ class: 'custom'
9
+ }
10
+
11
+ def manage_form_for(record, options={}, &block)
12
+ simple_form_for(record, options.merge(Manage::FormHelper::OPTIONS), &block)
13
+ end
14
+
15
+ def manage_fields_for(record_name, record_object = nil, options = {}, &block)
16
+ simple_fields_for(record_name, record_object = nil, options.merge(Manage::FormHelper::OPTIONS), &block)
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -1,77 +1,77 @@
1
- module Manage
2
- module ResourceHelper
3
- def index_fields
4
- list_index_fields
5
- end
6
-
7
- def edit_fields
8
- list_edit_fields
9
- end
10
-
11
- def attributes
12
- resource_class.attribute_names - %w(id created_at updated_at)
13
- end
14
-
15
- def field_value(scope, field_data)
16
- Fields::Reader.field_value(scope, field_data).to_s
17
- end
18
-
19
- def field_title(resource_class, field_data)
20
- Fields::Reader.field_title(resource_class, field_data)
21
- end
22
-
23
-
24
- #
25
- # to customise the actions for a resource define a list of actions
26
- #
27
- # example:
28
- # action_links :posts, :tickets, ->(resource) {link_to "#{resource.name}"}
29
- #
30
- # @param scope [type] [description]
31
- # @param link_data [type] [description]
32
- #
33
- # @return [type] [description]
34
- def action_link(scope, link_data)
35
- value = nil
36
- case link_data
37
-
38
- when Proc
39
- value = link_data.call(scope)
40
-
41
- when Hash
42
- relation = link_data.keys.first
43
- entity = Fields::Reader.field_value(scope, relation)
44
- unless entity.present?
45
- return ''
46
- end
47
- if link_data[relation][:label_field].present?
48
- value = field_value(scope, link_data[relation][:label_field])
49
- elsif link_data[relation][:label].present?
50
- value = link_data[relation][:label]
51
- end
52
-
53
- path = entity.class.name.dasherize.pluralize.downcase
54
- return link_to value, [scope.public_send(relation)]
55
-
56
- when *[Symbol, String]
57
- relation = link_data.to_s
58
- assocation = scope.class.reflect_on_association(link_data.to_sym)
59
- raise "assocation #{link_data} not found on #{scope.class}" unless assocation
60
- if assocation.options[:class_name].present?
61
- rel_name = scope.class.reflect_on_association(link_data.to_sym).options[:class_name]
62
- relation = rel_name.downcase.dasherize.pluralize
63
- end
64
- if scope.class.reflect_on_association(link_data.to_sym).options[:as].present?
65
- key = scope.class.reflect_on_association(link_data.to_sym).options[:as].to_s + '_id'
66
- else
67
- key = scope.class.name.downcase.dasherize + '_id'
68
- end
69
- return "<a href=\"#{relation}?f%5B#{key}%5D=#{scope.id}\">#{resource_class.human_attribute_name(link_data.to_s)}</a>".html_safe
70
- else
71
- raise 'Unsupported link data'
72
- end
73
-
74
- end
75
-
76
- end
77
- end
1
+ module Manage
2
+ module ResourceHelper
3
+ def index_fields
4
+ list_index_fields
5
+ end
6
+
7
+ def edit_fields
8
+ list_edit_fields
9
+ end
10
+
11
+ def attributes
12
+ resource_class.attribute_names - %w(id created_at updated_at)
13
+ end
14
+
15
+ def field_value(scope, field_data)
16
+ Fields::Reader.field_value(scope, field_data).to_s
17
+ end
18
+
19
+ def field_title(resource_class, field_data)
20
+ Fields::Reader.field_title(resource_class, field_data)
21
+ end
22
+
23
+
24
+ #
25
+ # to customise the actions for a resource define a list of actions
26
+ #
27
+ # example:
28
+ # action_links :posts, :tickets, ->(resource) {link_to "#{resource.name}"}
29
+ #
30
+ # @param scope [type] [description]
31
+ # @param link_data [type] [description]
32
+ #
33
+ # @return [type] [description]
34
+ def action_link(scope, link_data)
35
+ value = nil
36
+ case link_data
37
+
38
+ when Proc
39
+ value = link_data.call(scope)
40
+
41
+ when Hash
42
+ relation = link_data.keys.first
43
+ entity = Fields::Reader.field_value(scope, relation)
44
+ unless entity.present?
45
+ return ''
46
+ end
47
+ if link_data[relation][:label_field].present?
48
+ value = field_value(scope, link_data[relation][:label_field])
49
+ elsif link_data[relation][:label].present?
50
+ value = link_data[relation][:label]
51
+ end
52
+
53
+ path = entity.class.name.dasherize.pluralize.downcase
54
+ return link_to value, [scope.public_send(relation)]
55
+
56
+ when *[Symbol, String]
57
+ relation = link_data.to_s
58
+ assocation = scope.class.reflect_on_association(link_data.to_sym)
59
+ raise "assocation #{link_data} not found on #{scope.class}" unless assocation
60
+ if assocation.options[:class_name].present?
61
+ rel_name = scope.class.reflect_on_association(link_data.to_sym).options[:class_name]
62
+ relation = rel_name.downcase.dasherize.pluralize
63
+ end
64
+ if scope.class.reflect_on_association(link_data.to_sym).options[:as].present?
65
+ key = scope.class.reflect_on_association(link_data.to_sym).options[:as].to_s + '_id'
66
+ else
67
+ key = scope.class.name.downcase.dasherize + '_id'
68
+ end
69
+ return "<a href=\"#{relation}?f%5B#{key}%5D=#{scope.id}\">#{resource_class.human_attribute_name(link_data.to_s)}</a>".html_safe
70
+ else
71
+ raise 'Unsupported link data'
72
+ end
73
+
74
+ end
75
+
76
+ end
77
+ end
@@ -1,4 +1,4 @@
1
- class AdminUser < ActiveRecord::Base
2
- devise :database_authenticatable, :registerable, :lockable, :timeoutable,
3
- :recoverable, :rememberable, :trackable, :validatable
4
- end
1
+ class AdminUser < ActiveRecord::Base
2
+ devise :database_authenticatable, :registerable, :lockable, :timeoutable,
3
+ :recoverable, :rememberable, :trackable, :validatable
4
+ end
@@ -1,52 +1,52 @@
1
- // Override me in /views/layouts/manage/main_menu
2
-
3
- ul.right
4
- li.divider.hide-for-small
5
- li = link_to current_user.email, current_user
6
- li.divider.hide-for-small
7
- li = link_to 'users', users_path
8
- li.divider.hide-for-small
9
- li = link_to AdminUser.model_name.human(count:2), admin_users_path
10
- li.divider.hide-for-small
11
- li.has-dropdown
12
- a href="#" Main Item 1
13
- ul.dropdown
14
- li
15
- label Dropdown Level 1 Label
16
- li.has-dropdown
17
- a href="#" Dropdown Level 1a
18
- ul.dropdown
19
- li
20
- a href="#" Dropdown Level 2a
21
- li
22
- a href="#" Dropdown Level 2b
23
- li.has-dropdown
24
- a href="#">Dropdown Level 2c
25
- ul.dropdown
26
- li
27
- a href="#" Dropdown Level 3a
28
- li
29
- a href="#" Dropdown Level 3b
30
- li
31
- a href="#" Dropdown Level 3c
32
- li
33
- a href="#" Dropdown Level 2d
34
- li
35
- a href="#" Dropdown Level 2e
36
- li
37
- a href="#" Dropdown Level 2f
38
- li
39
- a href="#" Dropdown Level 1b
40
- li
41
- a href="#" Dropdown Level 1c
42
- li.divider
43
- li
44
- label Dropdown Level 1 Label
45
- li
46
- a href="#" Dropdown Level 1d
47
- li
48
- a href="#" Dropdown Level 1e
49
- li
50
- a href="#" Dropdown Level 1f
51
- li.has-form
52
- a.button href="http://foundation.zurb.com/docs" Sample button
1
+ // Override me in /views/layouts/manage/main_menu
2
+
3
+ ul.right
4
+ li.divider.hide-for-small
5
+ li = link_to current_user.email, current_user
6
+ li.divider.hide-for-small
7
+ li = link_to 'users', users_path
8
+ li.divider.hide-for-small
9
+ li = link_to AdminUser.model_name.human(count:2), admin_users_path
10
+ li.divider.hide-for-small
11
+ li.has-dropdown
12
+ a href="#" Main Item 1
13
+ ul.dropdown
14
+ li
15
+ label Dropdown Level 1 Label
16
+ li.has-dropdown
17
+ a href="#" Dropdown Level 1a
18
+ ul.dropdown
19
+ li
20
+ a href="#" Dropdown Level 2a
21
+ li
22
+ a href="#" Dropdown Level 2b
23
+ li.has-dropdown
24
+ a href="#">Dropdown Level 2c
25
+ ul.dropdown
26
+ li
27
+ a href="#" Dropdown Level 3a
28
+ li
29
+ a href="#" Dropdown Level 3b
30
+ li
31
+ a href="#" Dropdown Level 3c
32
+ li
33
+ a href="#" Dropdown Level 2d
34
+ li
35
+ a href="#" Dropdown Level 2e
36
+ li
37
+ a href="#" Dropdown Level 2f
38
+ li
39
+ a href="#" Dropdown Level 1b
40
+ li
41
+ a href="#" Dropdown Level 1c
42
+ li.divider
43
+ li
44
+ label Dropdown Level 1 Label
45
+ li
46
+ a href="#" Dropdown Level 1d
47
+ li
48
+ a href="#" Dropdown Level 1e
49
+ li
50
+ a href="#" Dropdown Level 1f
51
+ li.has-form
52
+ a.button href="http://foundation.zurb.com/docs" Sample button
@@ -1,40 +1,40 @@
1
- html
2
- head
3
- meta charset="utf-8"
4
- meta name="viewport" content="width=device-width, initial-scale=1.0"
5
- title Manage
6
- = stylesheet_link_tag "manage/application", media: "all"
7
-
8
- = stylesheet_link_tag "manage/custom", media: "all"
9
-
10
- = javascript_include_tag "modernizr.min.js"
11
- = csrf_meta_tags
12
-
13
- body class="#{controller.action_name} #{controller_path.gsub(/[-\/]/, '-')} simple" data-locale=I18n.locale
14
- nav.top-bar data-options="is_hover:false"
15
- ul.title-area
16
- li.name
17
- h1
18
- a href="/manage" Manage
19
- li.toggle-topbar.menu-icon
20
- a href="#"
21
- span Menu
22
- section.top-bar-section
23
- = render '/layouts/manage/main_menu'
24
-
25
- section.main
26
- #flash
27
- - flash.each do |key, value|
28
- - key = 'info' if key == :notice
29
- - key = 'alert' if key == :error
30
- div data-alert="" class="alert-box #{key}"
31
- - if value.is_a?(Array)
32
- - value.each do |element|
33
- p #{element.html_safe}
34
- - else
35
- p #{value.html_safe}
36
- a.close href="#" &times;
37
-
38
- = yield
39
-
1
+ html
2
+ head
3
+ meta charset="utf-8"
4
+ meta name="viewport" content="width=device-width, initial-scale=1.0"
5
+ title Manage
6
+ = stylesheet_link_tag "manage/application", media: "all"
7
+
8
+ = stylesheet_link_tag "manage/custom", media: "all"
9
+
10
+ = javascript_include_tag "modernizr.min.js"
11
+ = csrf_meta_tags
12
+
13
+ body class="#{controller.action_name} #{controller_path.gsub(/[-\/]/, '-')} simple" data-locale=I18n.locale
14
+ nav.top-bar data-options="is_hover:false"
15
+ ul.title-area
16
+ li.name
17
+ h1
18
+ a href="/manage" Manage
19
+ li.toggle-topbar.menu-icon
20
+ a href="#"
21
+ span Menu
22
+ section.top-bar-section
23
+ = render '/layouts/manage/main_menu'
24
+
25
+ section.main
26
+ #flash
27
+ - flash.each do |key, value|
28
+ - key = 'info' if key == :notice
29
+ - key = 'alert' if key == :error
30
+ div data-alert="" class="alert-box #{key}"
31
+ - if value.is_a?(Array)
32
+ - value.each do |element|
33
+ p #{element.html_safe}
34
+ - else
35
+ p #{value.html_safe}
36
+ a.close href="#" &times;
37
+
38
+ = yield
39
+
40
40
  = javascript_include_tag "manage/application"
@@ -1,30 +1,30 @@
1
- html
2
- head
3
- meta charset="utf-8"
4
- meta name="viewport" content="width=device-width, initial-scale=1.0"
5
- title Manage
6
- = stylesheet_link_tag "manage/application", media: "all"
7
- = javascript_include_tag "modernizr.min.js"
8
-
9
- = stylesheet_link_tag "manage/custom", media: "all"
10
-
11
- = csrf_meta_tags
12
-
13
- body class="simple" data-locale=I18n.locale
14
- section.main
15
- #flash
16
- - flash.each do |key, value|
17
- - key = 'info' if key == :notice
18
- - key = 'alert' if key == :error
19
- div data-alert="" class="alert-box #{key}"
20
- - if value.is_a?(Array)
21
- - value.each do |element|
22
- p #{element.html_safe}
23
- - elsif value.is_a?(String)
24
- p #{value.html_safe}
25
- a.close href="#" &times;
26
-
27
- = yield
28
-
29
- = javascript_include_tag "manage/application"
30
-
1
+ html
2
+ head
3
+ meta charset="utf-8"
4
+ meta name="viewport" content="width=device-width, initial-scale=1.0"
5
+ title Manage
6
+ = stylesheet_link_tag "manage/application", media: "all"
7
+ = javascript_include_tag "modernizr.min.js"
8
+
9
+ = stylesheet_link_tag "manage/custom", media: "all"
10
+
11
+ = csrf_meta_tags
12
+
13
+ body class="simple" data-locale=I18n.locale
14
+ section.main
15
+ #flash
16
+ - flash.each do |key, value|
17
+ - key = 'info' if key == :notice
18
+ - key = 'alert' if key == :error
19
+ div data-alert="" class="alert-box #{key}"
20
+ - if value.is_a?(Array)
21
+ - value.each do |element|
22
+ p #{element.html_safe}
23
+ - elsif value.is_a?(String)
24
+ p #{value.html_safe}
25
+ a.close href="#" &times;
26
+
27
+ = yield
28
+
29
+ = javascript_include_tag "manage/application"
30
+