manage 1.3.29 → 1.3.30

Sign up to get free protection for your applications and to get access to all the features.
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/resource_controller.rb +6 -0
  10. data/app/controllers/manage/responder.rb +11 -11
  11. data/app/controllers/manage/sessions_controller.rb +11 -11
  12. data/app/helpers/manage/application_helper.rb +42 -42
  13. data/app/helpers/manage/form_helper.rb +21 -21
  14. data/app/helpers/manage/resource_helper.rb +77 -77
  15. data/app/models/admin_user.rb +4 -4
  16. data/app/views/layouts/manage/_main_menu.html.slim +52 -52
  17. data/app/views/layouts/manage/application.html.slim +39 -39
  18. data/app/views/layouts/manage/sign_in.html.slim +30 -30
  19. data/app/views/manage/resource/_form.html.slim +4 -4
  20. data/app/views/manage/resource/index/_collection_actions.html.slim +2 -2
  21. data/app/views/manage/resource/index/_count.html.slim +6 -6
  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/engine.rb +21 -21
  33. data/lib/manage/fields/reader.rb +57 -57
  34. data/lib/manage/fields.rb +6 -6
  35. data/lib/manage/version.rb +1 -1
  36. data/lib/manage.rb +5 -5
  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/application.rb +24 -24
  54. data/spec/dummy/config/boot.rb +5 -5
  55. data/spec/dummy/config/database.yml +25 -25
  56. data/spec/dummy/config/environment.rb +5 -5
  57. data/spec/dummy/config/environments/development.rb +29 -29
  58. data/spec/dummy/config/environments/production.rb +80 -80
  59. data/spec/dummy/config/environments/test.rb +36 -36
  60. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  61. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
  62. data/spec/dummy/config/initializers/inflections.rb +16 -16
  63. data/spec/dummy/config/initializers/mime_types.rb +5 -5
  64. data/spec/dummy/config/initializers/secret_token.rb +12 -12
  65. data/spec/dummy/config/initializers/session_store.rb +3 -3
  66. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  67. data/spec/dummy/config/locales/en.yml +23 -23
  68. data/spec/dummy/config/routes.rb +10 -10
  69. data/spec/dummy/config.ru +4 -4
  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/public/404.html +58 -58
  73. data/spec/dummy/public/422.html +58 -58
  74. data/spec/dummy/public/500.html +57 -57
  75. data/spec/fields/reader_spec.rb +79 -79
  76. data/spec/spec_helper.rb +24 -24
  77. metadata +88 -90
  78. data/spec/dummy/log/test.log +0 -0
@@ -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
+
@@ -1,4 +1,4 @@
1
- = manage_form_for [ resource ] do |f|
2
- - edit_fields.each do |field|
3
- = f.input field
4
- = f.submit class: 'button small'
1
+ = manage_form_for [ resource ] do |f|
2
+ - edit_fields.each do |field|
3
+ = f.input field
4
+ = f.submit class: 'button small'
@@ -1,3 +1,3 @@
1
- - if collection.count > 0 and collection_actions(collection).present?
2
- .panel.collection_actions
1
+ - if collection.count > 0 and collection_actions(collection).present?
2
+ .panel.collection_actions
3
3
  = collection_actions(collection)
@@ -1,6 +1,6 @@
1
- .panel
2
- dl.sub-nav
3
- dt Count:
4
- dd.active
5
- = collection.total_count
6
-
1
+ .panel
2
+ dl.sub-nav
3
+ dt Count:
4
+ dd.active
5
+ = collection.total_count
6
+
@@ -1,11 +1,11 @@
1
- nav
2
- = [ link_to(t('manage.actions.index', model: resource_class.model_name.human(count: 2)), resource.class, class: 'button small secondary'),
3
- link_to(t('manage.actions.edit'), [:edit, resource], class: 'button small'),
4
- resource_actions(resource),
5
- ].compact.join('&nbsp;').html_safe
6
-
7
- article
8
- dl
9
- - resource_class.attribute_names.each do |attr|
10
- dt= resource_class.human_attribute_name(attr)
1
+ nav
2
+ = [ link_to(t('manage.actions.index', model: resource_class.model_name.human(count: 2)), resource.class, class: 'button small secondary'),
3
+ link_to(t('manage.actions.edit'), [:edit, resource], class: 'button small'),
4
+ resource_actions(resource),
5
+ ].compact.join('&nbsp;').html_safe
6
+
7
+ article
8
+ dl
9
+ - resource_class.attribute_names.each do |attr|
10
+ dt= resource_class.human_attribute_name(attr)
11
11
  dd= resource.public_send(attr)
@@ -1,10 +1,10 @@
1
- h2 = t('.sign_in')
2
-
3
- = simple_form_for(resource, :as => resource_name, :url => admin_user_session_path) do |f|
4
- .form-inputs
5
- = f.input :email, :required => false, :autofocus => true
6
- = f.input :password, :required => false
7
- = f.input :remember_me, :as => :boolean if devise_mapping.rememberable?
8
- .form-actions
9
- = f.submit t('devise.users.registrations.login')
10
-
1
+ h2 = t('.sign_in')
2
+
3
+ = simple_form_for(resource, :as => resource_name, :url => admin_user_session_path) do |f|
4
+ .form-inputs
5
+ = f.input :email, :required => false, :autofocus => true
6
+ = f.input :password, :required => false
7
+ = f.input :remember_me, :as => :boolean if devise_mapping.rememberable?
8
+ .form-actions
9
+ = f.submit t('devise.users.registrations.login')
10
+