hancock_cms 2.0.0.2 → 2.0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +4 -0
  3. data/app/assets/images/{devices → hancock/devise}/login-bg.jpg +0 -0
  4. data/app/assets/images/{rails-admin → hancock/rails_admin}/hancock_logo.svg +0 -0
  5. data/app/assets/javascripts/hancock/cms.coffee +1 -1
  6. data/app/assets/javascripts/hancock/rails_admin/cms.ui.coffee +11 -37
  7. data/app/assets/javascripts/hancock/rails_admin/en_ru_switcher.coffee +90 -0
  8. data/app/assets/javascripts/hancock/rails_admin/enum_with_custom.coffee +42 -0
  9. data/app/assets/javascripts/hancock/rails_admin/form_controls_fixed.coffee +44 -0
  10. data/app/assets/javascripts/hancock/rails_admin/leftside_hider.coffee +106 -0
  11. data/app/assets/javascripts/hancock/rails_admin/multiselect.coffee +8 -0
  12. data/app/assets/javascripts/hancock/rails_admin/navigation_dropdown.coffee +25 -0
  13. data/app/assets/javascripts/hancock/rails_admin/navigation_filter.coffee +108 -0
  14. data/app/assets/javascripts/hancock/rails_admin/navigation_scroll.coffee +12 -0
  15. data/app/assets/javascripts/hancock/rails_admin/plugins.coffee.erb +16 -0
  16. data/app/assets/javascripts/jquery.placeholder.js +3 -2
  17. data/app/assets/javascripts/rails_admin/custom/ui.coffee +1 -0
  18. data/app/assets/stylesheets/hancock/cms/devise.sass +4 -1
  19. data/app/assets/stylesheets/hancock/rails_admin/cms.theming.sass +354 -147
  20. data/app/assets/stylesheets/hancock/rails_admin/fieldsets.sass +198 -0
  21. data/app/assets/stylesheets/hancock/rails_admin/plugins.sass.erb +6 -0
  22. data/app/assets/stylesheets/rails_admin/custom/theming.sass +1 -1
  23. data/app/controllers/concerns/hancock/decorators/home.rb +1 -1
  24. data/app/controllers/concerns/hancock/errors.rb +5 -7
  25. data/app/controllers/hancock/registrations_controller.rb +2 -7
  26. data/app/controllers/hancock/sessions_controller.rb +3 -7
  27. data/app/helpers/hancock/powered_helper.rb +3 -3
  28. data/app/helpers/hancock/settings_helper.rb +44 -0
  29. data/app/helpers/rails_admin/application/hancock_helper.rb +19 -0
  30. data/app/helpers/rails_admin/hancock/form_builder.rb +44 -0
  31. data/app/helpers/rails_admin/main/hancock_helper.rb +51 -0
  32. data/app/models/concerns/hancock/boolean_field.rb +7 -2
  33. data/app/models/concerns/hancock/decorators/embedded_element.rb +1 -9
  34. data/app/models/concerns/hancock/enableable.rb +1 -0
  35. data/app/models/concerns/hancock/hash_field.rb +9 -8
  36. data/app/models/concerns/hancock/html_field.rb +6 -3
  37. data/app/models/concerns/hancock/insertion_field.rb +115 -0
  38. data/app/models/concerns/hancock/mappable.rb +1 -0
  39. data/app/models/concerns/hancock/master_collection.rb +31 -0
  40. data/app/models/concerns/hancock/model_localizeable.rb +4 -1
  41. data/app/models/concerns/hancock/rails_admin_patch.rb +22 -3
  42. data/app/models/concerns/hancock/sort_field.rb +26 -3
  43. data/app/models/concerns/hancock/sortable.rb +3 -0
  44. data/app/models/concerns/hancock/user_defined.rb +53 -0
  45. data/app/views/blocks/_footer.html.slim +1 -1
  46. data/app/views/devise/passwords/edit.html.slim +0 -2
  47. data/app/views/devise/passwords/new.html.slim +0 -2
  48. data/app/views/devise/registrations/edit.html.slim +0 -2
  49. data/app/views/devise/registrations/new.html.slim +0 -2
  50. data/app/views/devise/sessions/new.html.slim +0 -2
  51. data/app/views/hancock/home/index.html.slim +4 -1
  52. data/app/views/layouts/application.html.slim +1 -11
  53. data/app/views/layouts/hancock/_assets.html.slim +15 -0
  54. data/app/views/layouts/hancock/devise/confirmations.html.slim +7 -4
  55. data/app/views/layouts/hancock/devise/passwords.html.slim +7 -4
  56. data/app/views/layouts/hancock/devise/registrations.html.slim +7 -4
  57. data/app/views/layouts/hancock/devise/sessions.html.slim +7 -4
  58. data/app/views/layouts/hancock/devise/unlocks.html.slim +7 -4
  59. data/app/views/layouts/rails_admin/_footer.html.slim +2 -2
  60. data/app/views/layouts/rails_admin/_footer_navigation.html.slim +20 -4
  61. data/app/views/layouts/rails_admin/_navigation.html.slim +13 -47
  62. data/app/views/layouts/rails_admin/_secondary_navigation.html.slim +5 -12
  63. data/app/views/layouts/rails_admin/_sidebar_navigation.html.slim +2 -0
  64. data/app/views/layouts/rails_admin/_sidebar_navigation_filter.html.slim +3 -0
  65. data/app/views/layouts/rails_admin/application.html.haml +3 -38
  66. data/app/views/rails_admin/main/_enum_for_settings_kinds.html.slim +24 -0
  67. data/app/views/rails_admin/main/_form_hancock_enum.html.slim +18 -0
  68. data/app/views/rails_admin/main/_form_hancock_enum_with_custom.slim +20 -0
  69. data/app/views/rails_admin/main/_hancock_html.html.slim +2 -2
  70. data/app/views/rails_admin/main/_hancock_html_ml.html.slim +31 -34
  71. data/app/views/rails_admin/main/edit.html.haml +18 -0
  72. data/app/views/rails_admin/main/new.html.haml +17 -0
  73. data/app/views/shared/_admin_link.html.slim +4 -2
  74. data/config/initializers/nested_set_patch.rb +76 -73
  75. data/config/initializers/rails_admin_mongoid_patch.rb +27 -0
  76. data/config/initializers/sprockets_patch.rb +159 -0
  77. data/config/locales/en.hancock.yml +1 -0
  78. data/config/locales/ru.devise.yml +22 -18
  79. data/config/locales/ru.hancock.yml +5 -5
  80. data/config/locales/ru.rails_admin.yml +3 -0
  81. data/hancock_cms.gemspec +7 -2
  82. data/lib/filename_to_slug.rb +0 -20
  83. data/lib/generators/hancock/cms/ability_generator.rb +1 -0
  84. data/lib/generators/hancock/cms/admin_generator.rb +1 -0
  85. data/lib/generators/hancock/cms/application_generator.rb +1 -0
  86. data/lib/generators/hancock/cms/assets_generator.rb +1 -0
  87. data/lib/generators/hancock/cms/layout_generator.rb +1 -0
  88. data/lib/generators/hancock/cms/model_generator.rb +1 -0
  89. data/lib/generators/hancock/cms/models/templates/embedded_element.erb +2 -2
  90. data/lib/generators/hancock/cms/rack_generator.rb +1 -0
  91. data/lib/generators/hancock/cms/raven_generator.rb +13 -0
  92. data/lib/generators/hancock/cms/robots_generator.rb +1 -0
  93. data/lib/generators/hancock/cms/scripts_generator.rb +1 -0
  94. data/lib/generators/hancock/cms/setup_generator.rb +146 -33
  95. data/lib/generators/hancock/cms/templates/Gemfile.erb +4 -5
  96. data/lib/generators/hancock/cms/templates/ability.erb +1 -1
  97. data/lib/generators/hancock/cms/templates/admin.erb +12 -4
  98. data/lib/generators/hancock/cms/templates/hancock_cms.erb +6 -3
  99. data/lib/generators/hancock/cms/templates/model.erb +5 -6
  100. data/lib/generators/hancock/cms/templates/raven.erb +13 -0
  101. data/lib/generators/hancock/cms/templates/robots.txt.erb +6 -2
  102. data/lib/generators/hancock/cms/templates/scripts/db_dump.sh.erb +1 -1
  103. data/lib/generators/hancock/cms/unicorn_god_generator.rb +1 -0
  104. data/lib/generators/hancock/cms/utils.rb +2 -0
  105. data/lib/hancock/admin.rb +153 -21
  106. data/lib/hancock/admin/embedded_element.rb +7 -2
  107. data/lib/hancock/configuration.rb +49 -4
  108. data/lib/hancock/controller.rb +1 -1
  109. data/lib/hancock/engine.rb +32 -36
  110. data/lib/hancock/model.rb +10 -0
  111. data/lib/hancock/models/embedded_element.rb +2 -0
  112. data/lib/hancock/models/mongoid/embedded_element.rb +17 -0
  113. data/lib/hancock/plugin_configuration.rb +1 -1
  114. data/lib/hancock/rails_admin_ext/config.rb +21 -4
  115. data/lib/hancock/rails_admin_ext/hancock_array.rb +19 -0
  116. data/lib/hancock/rails_admin_ext/hancock_enum.rb +33 -0
  117. data/lib/hancock/rails_admin_ext/hancock_enum_with_custom.rb +34 -0
  118. data/lib/hancock/rails_admin_ext/hancock_hash.rb +8 -1
  119. data/lib/hancock/rails_admin_ext/hancock_html.rb +17 -2
  120. data/lib/hancock/rails_admin_ext/hancock_multiselect.rb +1 -5
  121. data/lib/hancock/rails_admin_ext/hancock_slugs.rb +2 -6
  122. data/lib/hancock/rails_admin_ext/patches/field_patch.rb +2 -1
  123. data/lib/hancock/rails_admin_ext/patches/fieldset_patch.rb +14 -0
  124. data/lib/hancock/rails_admin_ext/patches/group_patch.rb +9 -0
  125. data/lib/hancock/rails_admin_ext/patches/hancock_cms_group.rb +2 -0
  126. data/lib/hancock/rails_admin_ext/patches/has_fields.rb +27 -0
  127. data/lib/hancock/rails_admin_ext/patches/navigation_patch.rb +25 -0
  128. data/lib/hancock/rails_admin_settings_patch.rb +219 -0
  129. data/lib/hancock/version.rb +1 -1
  130. data/lib/hancock_cms.rb +12 -9
  131. data/lib/manual_slug/active_record.rb +8 -8
  132. data/lib/manual_slug/mongoid.rb +6 -1
  133. data/lib/rails_admin/custom_show_in_app.rb +21 -32
  134. data/template.rb +19 -20
  135. metadata +104 -12
  136. data/app/controllers/concerns/hancock/no_cache.rb +0 -12
  137. data/app/models/concerns/hancock/cacheable.rb +0 -51
@@ -0,0 +1,198 @@
1
+ body.rails_admin .form-horizontal .tab-content .tab-pane > .remove_nested_fields, body.rails_admin .form-horizontal .tab-content .tab-pane > .remove_nested_one_fields
2
+ opacity: 1
3
+ z-index: 10
4
+ left: 50px
5
+ top: 10px
6
+
7
+ body.rails_admin .form-horizontal.denser
8
+ margin-top: 15px
9
+ fieldset > legend
10
+ margin-bottom: 0px
11
+ legend i
12
+ font-size: 14px
13
+
14
+ body.rails_admin .nav.nav-tabs
15
+ margin-bottom: -1px
16
+ border-bottom: 0px
17
+ padding: 0px 5px
18
+
19
+ body.rails_admin .form-horizontal .tab-content .tab-pane
20
+ fieldset
21
+ margin-left: 50px
22
+ margin-right: 25px
23
+
24
+ .form-horizontal.denser
25
+ fieldset.opened
26
+ min-height: 180px
27
+ padding-bottom: 10px
28
+ fieldset
29
+ .form-group
30
+ margin-left: 25px !important
31
+ margin-top: 15px
32
+ margin-bottom: 15px
33
+ fieldset.default_fieldset
34
+ padding-top: 0px
35
+ border: 0px
36
+
37
+ fieldset
38
+ +border-radius(4px)
39
+ border: 1px solid #e3e3e3
40
+ background: #fff
41
+ margin-bottom: 5px
42
+ padding: 0px
43
+ min-height: 30px
44
+ overflow: visible
45
+ padding-top: 29px
46
+ &:first-child
47
+ margin-top: 5px
48
+ &:last-child
49
+ margin-bottom: 0px
50
+ legend
51
+ height: 30px
52
+ padding: 5px 10px
53
+ font-size: 18px
54
+ line-height: 20px
55
+ top: 0px
56
+ position: absolute
57
+ .form-group
58
+ margin-left: 25px
59
+ margin-right: 0px
60
+ margin-top: 15px
61
+ margin-bottom: 15px
62
+ .input-group
63
+ float: none !important
64
+ input[type=checkbox]
65
+ width: 25px !important
66
+ height: 25px !important
67
+ label
68
+ font-size: 13px
69
+ label.dropdown-toggle
70
+ width: auto
71
+ .help-block
72
+ margin-bottom: 0px
73
+ color: #aaaaaa
74
+ font-size: 12px
75
+ line-height: 12px
76
+ .ra-multiselect .ra-multiselect-column
77
+ float: left
78
+ margin-bottom: 5px
79
+
80
+ fieldset.default.hover
81
+ > .leftside_hider
82
+ opacity: 0
83
+
84
+ fieldset.hover
85
+ > .leftside_hider
86
+ opacity: 1.0
87
+
88
+ fieldset
89
+ +transition(all 0.3s)
90
+ position: relative
91
+ > .leftside_hider
92
+ overflow: hidden
93
+ width: 65px
94
+ position: absolute
95
+ top: 30px
96
+ bottom: 0px
97
+ background: rgba(100,100,100,0.05)
98
+ cursor: pointer
99
+ padding: 10px 0px
100
+ z-index: 9
101
+ opacity: 0
102
+ +transition(background 0.3s, opacity 0.2s)
103
+ &:hover
104
+ background: rgba(100,100,100,0.1)
105
+ &:active
106
+ background: rgba(100,100,100,0.075)
107
+
108
+ .scroll_fieldset_block
109
+ overflow: visible
110
+ position: absolute
111
+ width: 45px
112
+ top: 10px
113
+ margin-left: 10px
114
+ height: 126px
115
+ opacity: 0.75
116
+ cursor: pointer
117
+ z-index: 10
118
+ background: #fff
119
+ border: 1px solid #e3e3e3
120
+ +border-radius(4px)
121
+ +transition(scale 0.3s, opacity 0.3s)
122
+ +transform(scale(0))
123
+ transform-origin: top center
124
+ -webkit-transform-origin: top left
125
+ -o-transform-origin: top left
126
+ -moz-transform-origin: top left
127
+ padding: 5px
128
+ +box-shadow(0px 5px 10px -5px rgba(0, 0, 0, 0.5))
129
+ &:hover
130
+ opacity: 1.0
131
+ > *
132
+ height: 35px
133
+ width: 35px
134
+ +border-radius(4px)
135
+ margin-bottom: 5px
136
+ z-index: 11
137
+ display: flex
138
+ align-items: center
139
+ justify-content: center
140
+ background-color: #e53935
141
+ +transition(all 0.3s)
142
+ color: #fff
143
+ &:hover
144
+ background-color: #c73800
145
+ opacity: 1
146
+ &:active
147
+ background-color: #e53935
148
+ opacity: 1
149
+
150
+ .links-list
151
+ width: auto
152
+ display: inline-flex
153
+ background: #fff
154
+ border: 1px solid #e3e3e3
155
+ +border-radius(4px)
156
+ +box-shadow(0px 5px 10px -5px rgba(0, 0, 0, 0.5))
157
+ padding: 3px
158
+
159
+ .select_fieldset
160
+ +transition(all 0.3s)
161
+ overflow: visible
162
+ a, span
163
+ background-color: #e53935
164
+ display: inline-block
165
+ text-align: center
166
+ width: 50px
167
+ height: 29px
168
+ margin-right: 3px
169
+ overflow: hidden
170
+ white-space: nowrap
171
+ text-overflow: ellipsis
172
+ color: #ffffff
173
+ padding: 0px 3px
174
+ font-size: 10px
175
+ line-height: 29px
176
+ text-decoration: none
177
+ +transition(all 0.3s)
178
+ +border-radius(4px)
179
+ &:hover
180
+ background-color: #c73800
181
+ opacity: 1
182
+ &:last-child
183
+ margin-right: 0px
184
+ span
185
+ background-color: lightblue
186
+ cursor: auto
187
+ color: black
188
+ &:hover
189
+ background-color: lightblue
190
+ opacity: 1
191
+
192
+ fieldset.opened, fieldset.default_fieldset
193
+ .scroll_fieldset_block
194
+ +transform(scale(1))
195
+
196
+ fieldset[disabled] .btn-info, fieldset[disabled] .btn-info:hover, fieldset[disabled] .btn-info:focus, fieldset[disabled] .btn-info:active, fieldset[disabled] .btn-info.active
197
+ background-color: #ef3b36
198
+ border-color: #e53a36
@@ -0,0 +1,6 @@
1
+ <% Hancock::PLUGINS.each do |plugin| %>
2
+ <% p_name = plugin.name.demodulize.underscore %>
3
+ <% if defined?(plugin::Engine) and File.exists?(plugin::Engine.root.join("app", "assets", "stylesheets", "hancock", "rails_admin", "plugins", "#{p_name}.sass")) %>
4
+ @import 'hancock/rails_admin/plugins/<%= p_name %>'
5
+ <% end %>
6
+ <% end %>
@@ -1,4 +1,4 @@
1
1
  @import hancock/cms/mixins
2
2
 
3
3
  @import hancock/rails_admin/cms.theming
4
- @import hancock/rails_admin/custom/theming
4
+ @import hancock/rails_admin/custom/theming
@@ -2,7 +2,7 @@ module Hancock::Decorators
2
2
  module Home
3
3
  extend ActiveSupport::Concern
4
4
 
5
- # included
5
+ # included do
6
6
  # def index
7
7
  # render layout: Hancock.config.main_index_layout
8
8
  # end
@@ -26,12 +26,10 @@ module Hancock::Errors
26
26
  unless exception.nil?
27
27
  Rails.logger.error exception.message
28
28
  Rails.logger.error exception.backtrace.join("\n")
29
- capture_exception(exception) if defined?(Raven)
29
+ capture_exception(exception) if Hancock.config.raven_support
30
30
  end
31
31
  Rails.logger.error "__________________________"
32
32
  if !user_signed_in?
33
- #scope = rails_admin? ? main_app : self
34
- #redirect_to scope.new_user_session_path, alert: "Необходимо авторизоваться"
35
33
  authenticate_user!
36
34
  else
37
35
  if rails_admin? and can?(:access, :rails_admin)
@@ -44,7 +42,7 @@ module Hancock::Errors
44
42
  end
45
43
 
46
44
  rescue_from ActionController::InvalidAuthenticityToken do |exception|
47
- redirect_to :back, alert: t('hancock.errors.form_expired')
45
+ redirect_back(fallback_location: root_path, alert: t('hancock.errors.form_expired'))
48
46
  end
49
47
  end
50
48
 
@@ -57,7 +55,7 @@ module Hancock::Errors
57
55
  unless exception.nil?
58
56
  Rails.logger.error exception.message
59
57
  Rails.logger.error exception.backtrace.join("\n")
60
- capture_exception(exception) if defined?(Raven)
58
+ capture_exception(exception) if Hancock.config.raven_support
61
59
  end
62
60
  Rails.logger.error "__________________________".freeze
63
61
  render_error(404)
@@ -71,12 +69,12 @@ module Hancock::Errors
71
69
  unless exception.nil?
72
70
  Rails.logger.error exception.message
73
71
  Rails.logger.error exception.backtrace.join("\n")
74
- capture_exception(exception) if defined?(Raven)
72
+ capture_exception(exception) if Hancock.config.raven_support
75
73
  end
76
74
  Rails.logger.error "__________________________".freeze
77
75
  begin
78
76
  if rails_admin?
79
- render text: t('hancock.errors.internal_error_full', klass: exception.class.name, message: exception.message), status: 500
77
+ render plain: t('hancock.errors.internal_error_full', klass: exception.class.name, message: exception.message), status: 500
80
78
  return
81
79
  end
82
80
  rescue Exception => e
@@ -1,20 +1,15 @@
1
1
  class Hancock::RegistrationsController < Devise::RegistrationsController
2
2
  prepend_before_action :check_recaptcha, only: [:create]
3
3
 
4
- private
4
+ # private :check_recaptcha
5
5
  def check_recaptcha
6
6
  if Hancock.config.recaptcha_support and (!Rails.env.development? or Hancock.config.captcha_on_development)
7
- if verify_recaptcha
8
- true
9
- else
7
+ unless verify_recaptcha
10
8
  self.resource = resource_class.new sign_up_params
11
9
  self.resource.valid?
12
10
  @recaptcha_error = "Вы робот?".freeze
13
11
  respond_with_navigational(resource) { render :new }
14
12
  end
15
-
16
- else
17
- true
18
13
  end
19
14
  end
20
15
 
@@ -1,21 +1,17 @@
1
1
  class Hancock::SessionsController < Devise::SessionsController
2
2
  prepend_before_action :check_recaptcha, only: [:create]
3
+ prepend_before_action :require_no_authentication, :only => [ :new, :create ]
3
4
 
4
- private
5
+ # private :check_recaptcha
5
6
  def check_recaptcha
6
7
  if Hancock.config.recaptcha_support and (!Rails.env.development? or Hancock.config.captcha_on_development)
7
- if verify_recaptcha
8
- true
9
- else
8
+ unless verify_recaptcha
10
9
  self.resource = resource_class.new sign_in_params
11
10
  resource.errors.add(:email, "Неверный e-mail или пароль".freeze)
12
11
  resource.errors.add(:password, "Неверный e-mail или пароль".freeze)
13
12
  @recaptcha_error = "Вы робот?".freeze
14
13
  respond_with_navigational(resource) { render :new }
15
14
  end
16
-
17
- else
18
- true
19
15
  end
20
16
  end
21
17
 
@@ -15,7 +15,7 @@ module Hancock::PoweredHelper
15
15
  # "hancock-goto-disabled": true
16
16
  # }
17
17
  # }
18
- # ret << link_to("Hancock CMS", "http://hancock.redrocks.pro/", _attrs)
18
+ # ret << link_to("Hancock CMS", "https://hancock.redrocks.pro/", _attrs)
19
19
  # ret.join.html_safe
20
20
  # end
21
21
  # end
@@ -29,12 +29,12 @@ module Hancock::PoweredHelper
29
29
  _attrs = {
30
30
  class: "created_by",
31
31
  target: "_blank",
32
- title: "Hancock Creative studio",
32
+ title: "Redrocks Creative studio",
33
33
  data: {
34
34
  "hancock-goto-disabled": true
35
35
  }
36
36
  }.freeze
37
- ret << link_to("Redrocks studio".freeze, "http://redrocks.pro/".freeze, _attrs)
37
+ ret << link_to("Redrocks studio".freeze, "https://redrocks.pro/".freeze, _attrs)
38
38
  ret.join.html_safe
39
39
  end
40
40
  end
@@ -0,0 +1,44 @@
1
+ module Hancock::SettingsHelper
2
+
3
+ def hancock_settings(key, options = {}, &block)
4
+ if key.is_a?(Hash)
5
+ key, options = key[:key], key
6
+ end
7
+ ns = options.delete(:ns)
8
+ settings_scope = options.delete(:settings_scope) || Settings.ns(ns)
9
+ key ||= options.delete(:key)
10
+ options.delete(:key)
11
+
12
+ cache_keys = options[:cache_keys_str] || options[:cache_keys] || options[:cache_key] || []
13
+ if cache_keys.is_a?(::Array)
14
+ cache_keys = cache_keys.map { |k| k.to_s.strip }.join(" ")
15
+ else
16
+ cache_keys = cache_keys.to_s.strip
17
+ end
18
+ options.delete(:cache_keys)
19
+ options.delete(:cache_key)
20
+
21
+ # options[:loadable] = cache_keys.blank? if options[:loadable].nil? # temporary
22
+ options[:cache_keys_str] = cache_keys
23
+ options[:kind] ||= :html
24
+
25
+ options[:default] = capture(&block) if block
26
+ case (options.delete(:as) || :value).to_sym
27
+ when :value
28
+ ret = settings_scope.__send__(key, options)
29
+ when :object
30
+ ret = settings_scope.getnc(key)
31
+ ret.loadable ||= options[:loadable]
32
+ _old_cache_keys = options[:cache_keys_str].strip.split(" ")
33
+ options[:cache_keys_str] = (_old_cache_keys + ret.cache_keys).uniq
34
+ if (options[:cache_keys_str] - _old_cache_keys).blank?
35
+ ret.cache_keys_str = options[:cache_keys_str]
36
+ end
37
+ ret.save unless ret.changes.blank?
38
+ ret
39
+ else
40
+ ret = settings_scope.__send__(key, options)
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,19 @@
1
+ require 'rails_admin/application_helper'
2
+ module RailsAdmin::Application
3
+ module HancockHelper
4
+
5
+ def hancock_navigation(nodes_stack, nodes, level = 0)
6
+ nodes.collect do |node|
7
+ model_param = node.abstract_model.to_param
8
+ url = rails_admin.url_for(action: :index, controller: 'rails_admin/main', model_name: model_param)
9
+ level_class = " nav-level-#{level}" if level > 0
10
+ nav_icon = node.navigation_icon ? %(<i class="#{node.navigation_icon}"></i>).html_safe : ''
11
+ li = content_tag :li, data: {model: model_param, "name-synonyms": node.name_synonyms} do
12
+ link_to nav_icon + capitalize_first_letter(node.label_plural), url, class: "pjax#{level_class}", title: capitalize_first_letter(node.label_plural)
13
+ end
14
+ li + hancock_navigation(nodes_stack, nodes_stack.select { |n| n.parent.to_s == node.abstract_model.model_name }, level + 1)
15
+ end.join.html_safe
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,44 @@
1
+ require 'rails_admin/form_builder'
2
+ module RailsAdmin::Hancock
3
+ class FormBuilder < ::RailsAdmin::FormBuilder
4
+
5
+ def fieldset_for(fieldset, nested_in)
6
+ fields = fieldset.with(
7
+ form: self,
8
+ object: @object,
9
+ view: @template,
10
+ controller: @template.controller,
11
+ ).visible_fields
12
+ return if fields.empty?
13
+
14
+ _defailt_fieldset = fieldset.name == :default
15
+ @template.content_tag :fieldset, class: _defailt_fieldset ? 'default_fieldset' : '' do
16
+ if fieldset.leftside_hider
17
+ leftside_hider = @template.content_tag(:div, class: 'control-group leftside_hider', title: _defailt_fieldset ? "" : "Свернуть блок") do
18
+ @template.content_tag(:div, class: 'scroll_fieldset_block') do
19
+ ret = []
20
+ ret << @template.content_tag(:div, class: 'scroll_fieldset_top', title: "Вверх блока") do
21
+ @template.content_tag(:i, "", class: 'fa fa-arrow-up')
22
+ end
23
+ ret << @template.content_tag(:div, class: 'select_fieldset', title: "Выбрать другой блок") do
24
+ @template.content_tag(:i, "", class: 'fa fa-indent')
25
+ end
26
+ ret << @template.content_tag(:div, class: 'scroll_fieldset_bottom', title: "Вниз блока") do
27
+ @template.content_tag(:i, "", class: 'fa fa-arrow-down')
28
+ end
29
+ ret.join.html_safe
30
+ end
31
+ end
32
+ end
33
+
34
+ contents = []
35
+ contents << @template.content_tag(:legend, %(<i class="icon-chevron-#{(fieldset.active? ? 'down' : 'right')}"></i> #{fieldset.label}).html_safe, style: fieldset.name == :default ? 'display:none' : '')
36
+ contents << @template.content_tag(:p, fieldset.help) if fieldset.help.present?
37
+ contents << leftside_hider if fieldset.leftside_hider and leftside_hider
38
+ contents << fields.collect { |field| field_wrapper_for(field, nested_in) }.join
39
+ contents.join.html_safe
40
+ end
41
+ end
42
+
43
+ end
44
+ end