slash_admin 1.0.1 → 1.0.2

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 (29) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/slash_admin/application.js +1 -0
  3. data/app/controllers/slash_admin/application_controller.rb +3 -3
  4. data/app/controllers/slash_admin/base_controller.rb +9 -8
  5. data/app/controllers/slash_admin/batch_actions_controller.rb +1 -0
  6. data/app/controllers/slash_admin/dashboard_controller.rb +3 -1
  7. data/app/controllers/slash_admin/models_controller.rb +102 -81
  8. data/app/controllers/slash_admin/security/sessions_controller.rb +8 -6
  9. data/app/controllers/slash_admin/selectize_controller.rb +4 -6
  10. data/app/helpers/slash_admin/application_helper.rb +30 -31
  11. data/app/helpers/slash_admin/menu_helper.rb +3 -2
  12. data/app/helpers/slash_admin/widgets_helper.rb +1 -1
  13. data/app/mailers/slash_admin/application_mailer.rb +2 -2
  14. data/app/models/slash_admin/admin.rb +5 -6
  15. data/app/models/slash_admin/admin_ability.rb +1 -0
  16. data/app/views/slash_admin/base/_data_list.html.erb +42 -32
  17. data/config/initializers/validators.rb +1 -1
  18. data/config/routes.rb +7 -7
  19. data/db/migrate/20170512104248_create_slash_admin_admins.rb +5 -4
  20. data/lib/batch_translation.rb +3 -3
  21. data/lib/generators/slash_admin/controllers/controllers_generator.rb +5 -4
  22. data/lib/generators/slash_admin/install/install_generator.rb +4 -3
  23. data/lib/generators/slash_admin/override_admin/override_admin_generator.rb +3 -3
  24. data/lib/generators/slash_admin/override_session/override_session_generator.rb +4 -3
  25. data/lib/generators/slash_admin/permissions/permissions_generator.rb +4 -3
  26. data/lib/slash_admin/engine.rb +1 -1
  27. data/lib/slash_admin/version.rb +1 -1
  28. data/lib/slash_admin.rb +22 -22
  29. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1972b380ac6782c7921b54ef60b515ebf3ccbc33499721d871c657f01a6b1060
4
- data.tar.gz: ece587720d629fc7e1960b2ff5b4f6d4f6d4414fc0c041cad48b9f361a99008d
3
+ metadata.gz: 7f61951e5da77acff572ba11839d60c708cc440696971f3ca2eb483e55862ecc
4
+ data.tar.gz: fc105b1a368403c57f01190e863b34b5ad51e35a96c212623d3b695d712da148
5
5
  SHA512:
6
- metadata.gz: bf2af28c8509da877de6786dad8890143a9d3697d6eae4c3732cc6f6d6644d32244851d3e46e34254455f6ea0fc625012e1014cfd9f1c9871f63400a2d25d808
7
- data.tar.gz: cb011eaabf99b171edfb7b9761d72b266e73432861bfa4f71c8d26ae1ca39f801412bf68a0b8dff6cf0abca0a79befb3bb7a4d1ac5c17e6b5e8b6336a70a3c4e
6
+ metadata.gz: eaf607ee5214e9ec808afa71847f8ebfdce4249f06cbede5e0c276de9a3838dca3621cde3e1faead57d88e0950766e3f70fa92128a596bd70fce125fbe233f43
7
+ data.tar.gz: 8ee7c0e991a8eaf2bede39b04c397613847f6b84105afcb6229434f46b680f7f551004b570944ef7478c8fef26e0b558aa0f25e6109467f03608834657c6a91a
@@ -33,6 +33,7 @@ $(document).on("turbolinks:load", init);
33
33
 
34
34
  function init() {
35
35
  Turbolinks.clearCache();
36
+ $('[data-toggle="tooltip"]').tooltip();
36
37
 
37
38
  $('.page-sidebar a[href$="#"]').on("click", function(e) {
38
39
  e.preventDefault();
@@ -10,8 +10,8 @@ module SlashAdmin
10
10
 
11
11
  private
12
12
 
13
- def set_locale
14
- I18n.locale = http_accept_language.compatible_language_from(I18n.available_locales)
15
- end
13
+ def set_locale
14
+ I18n.locale = http_accept_language.compatible_language_from(I18n.available_locales)
15
+ end
16
16
  end
17
17
  end
@@ -6,24 +6,25 @@ module SlashAdmin
6
6
  before_action :prepend_view_paths
7
7
  helper_method :current_admin, :boolean_to_string
8
8
 
9
- protected
9
+ protected
10
10
 
11
- def handle_default; end
11
+ def handle_default
12
+ end
12
13
 
13
14
  def handle_default_mode
14
15
  session[:compact] ||= false
15
16
  end
16
17
 
17
18
  def prepend_view_paths
18
- prepend_view_path 'app/views/slash_admin'
19
+ prepend_view_path "app/views/slash_admin"
19
20
  end
20
21
 
21
- private
22
+ private
22
23
 
23
24
  def authenticate_admin!
24
25
  return true if current_admin.present?
25
- flash[:error] = t('slash_admin.sessions.login_required')
26
- redirect_to login_url unless controller_name == 'sessions'
26
+ flash[:error] = t("slash_admin.sessions.login_required")
27
+ redirect_to login_url unless controller_name == "sessions"
27
28
  end
28
29
 
29
30
  def current_admin
@@ -31,11 +32,11 @@ module SlashAdmin
31
32
  end
32
33
 
33
34
  def to_boolean(str)
34
- str == 'true'
35
+ str == "true"
35
36
  end
36
37
 
37
38
  def boolean_to_string(str)
38
- str ? 'true' : 'false'
39
+ str ? "true" : "false"
39
40
  end
40
41
 
41
42
  def should_load_layout_data?
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module SlashAdmin
3
4
  class BatchActionsController < SlashAdmin::BaseController
4
5
  def delete
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module SlashAdmin
3
4
  class DashboardController < SlashAdmin::BaseController
4
- def home; end
5
+ def home
6
+ end
5
7
 
6
8
  def toggle
7
9
  session[:compact] = session[:compact].blank? ? true : nil
@@ -1,4 +1,4 @@
1
- require 'csv'
1
+ require "csv"
2
2
 
3
3
  module SlashAdmin
4
4
  class ModelsController < SlashAdmin::BaseController
@@ -9,7 +9,7 @@ module SlashAdmin
9
9
  before_action :handle_default_params
10
10
  before_action :handle_assocations
11
11
 
12
- helper_method :list_params, :export_params, :create_params, :update_params, :show_params, :nested_params, :should_add_translatable?, :translatable_params
12
+ helper_method :list_params, :export_params, :create_params, :update_params, :show_params, :nested_params, :should_add_translatable?, :translatable_params, :tooltips
13
13
 
14
14
  def index
15
15
  authorize! :index, @model_class
@@ -21,12 +21,12 @@ module SlashAdmin
21
21
 
22
22
  column = @model_class.arel_table[params[:order_field].to_sym]
23
23
  order = params[:order].downcase
24
- if %w(asc desc).include?(order)
24
+ if %w[asc desc].include?(order)
25
25
  if @models_export.is_a? Array
26
- if order == 'asc'
27
- @models = @models_export.sort { |m1, m2| m1.send(params[:order_field]) <=> m2.send(params[:order_field]) }
26
+ @models = if order == "asc"
27
+ @models_export.sort { |m1, m2| m1.send(params[:order_field]) <=> m2.send(params[:order_field]) }
28
28
  else
29
- @models = @models_export.sort { |m1, m2| m2.send(params[:order_field]) <=> m1.send(params[:order_field]) }
29
+ @models_export.sort { |m1, m2| m2.send(params[:order_field]) <=> m1.send(params[:order_field]) }
30
30
  end
31
31
  @models = Kaminari.paginate_array(@models).page(params[:page]).per(params[:per])
32
32
  else
@@ -36,8 +36,8 @@ module SlashAdmin
36
36
 
37
37
  @fields = if @use_export_params
38
38
  export_params
39
- else
40
- @model_class.column_names
39
+ else
40
+ @model_class.column_names
41
41
  end
42
42
 
43
43
  respond_to do |format|
@@ -53,8 +53,12 @@ module SlashAdmin
53
53
  @model = @model_class.new
54
54
  end
55
55
 
56
- def before_validate_on_create; end
57
- def after_save_on_create; end
56
+ def before_validate_on_create
57
+ end
58
+
59
+ def after_save_on_create
60
+ end
61
+
58
62
  def create
59
63
  authorize! :new, @model_class
60
64
  handle_has_one
@@ -69,19 +73,19 @@ module SlashAdmin
69
73
  after_save_on_create
70
74
  respond_to do |format|
71
75
  format.html do
72
- flash[:success] = t('slash_admin.controller.create.success', model_name: @model_name)
73
- redirect_to handle_redirect_after_submit and return
76
+ flash[:success] = t("slash_admin.controller.create.success", model_name: @model_name)
77
+ redirect_to(handle_redirect_after_submit) && return
74
78
  end
75
- format.js { render json: { id: @model.id, name: helpers.show_object(@model) } and return }
79
+ format.js { render(json: {id: @model.id, name: helpers.show_object(@model)}) && return }
76
80
  end
77
81
  end
78
82
  else
79
- flash[:error] = t('slash_admin.controller.create.error', model_name: @model_name)
83
+ flash[:error] = t("slash_admin.controller.create.error", model_name: @model_name)
80
84
  end
81
85
 
82
86
  respond_to do |format|
83
87
  format.html { render :new }
84
- format.js { render json: { errors: @model.errors.full_messages } }
88
+ format.js { render json: {errors: @model.errors.full_messages} }
85
89
  end
86
90
  end
87
91
 
@@ -104,14 +108,14 @@ module SlashAdmin
104
108
  if @model.valid?
105
109
  if @model.save!
106
110
  after_save_on_update
107
- flash[:success] = t('slash_admin.controller.update.success', model_name: @model_name)
111
+ flash[:success] = t("slash_admin.controller.update.success", model_name: @model_name)
108
112
  respond_to do |format|
109
- format.html { redirect_to handle_redirect_after_submit and return }
113
+ format.html { redirect_to(handle_redirect_after_submit) && return }
110
114
  format.js
111
115
  end
112
116
  end
113
117
  else
114
- flash[:error] = t('slash_admin.controller.update.error', model_name: @model_name)
118
+ flash[:error] = t("slash_admin.controller.update.error", model_name: @model_name)
115
119
  end
116
120
  render :edit
117
121
  end
@@ -128,20 +132,33 @@ module SlashAdmin
128
132
 
129
133
  def destroy
130
134
  @model_class.find(params[:id]).destroy!
131
- flash[:success] = t('slash_admin.controller.delete.success', model_name: @model_name)
135
+ flash[:success] = t("slash_admin.controller.delete.success", model_name: @model_name)
132
136
  respond_to do |format|
133
137
  format.html { redirect_to main_app.polymorphic_url([:slash_admin, @model_class]) }
134
138
  format.js
135
139
  end
136
140
  end
137
141
 
138
- def before_validate_on_update; end
139
- def after_save_on_update; end
142
+ def before_validate_on_update
143
+ end
144
+
145
+ def after_save_on_update
146
+ end
147
+
148
+ # Add tooltip to th list view
149
+ # {
150
+ # attr: 'Value',
151
+ # title: 'The title of my model',
152
+ # }
153
+ #
154
+ def tooltips
155
+ {}
156
+ end
140
157
 
141
158
  def handle_has_one
142
159
  @has_one = {}
143
160
  Array.wrap(update_params + create_params).uniq.each do |p|
144
- if helpers.guess_field_type(@model_class.new, p) == 'has_one' && !@model_class.nested_attributes_options.key?(p.to_sym)
161
+ if helpers.guess_field_type(@model_class.new, p) == "has_one" && !@model_class.nested_attributes_options.key?(p.to_sym)
145
162
  @has_one[p] = permit_params[p]
146
163
  permit_params.delete(p)
147
164
  end
@@ -168,7 +185,7 @@ module SlashAdmin
168
185
  @model.send("#{k}=", JSON.parse(permit_params[k]))
169
186
  rescue
170
187
  # Handle case when single string passed, we transform it into array to have a valid json
171
- json = permit_params[k].split(',').to_json
188
+ json = permit_params[k].split(",").to_json
172
189
  @model.send("#{k}=", JSON.parse(json))
173
190
  end
174
191
  end
@@ -180,31 +197,31 @@ module SlashAdmin
180
197
 
181
198
  def nestable
182
199
  unless @is_nestable
183
- flash[:error] = t('slash_admin.controller.nestable.error', model_name: @model_name)
184
- redirect_to main_app.polymorphic_url([:slash_admin, @model_class]) and return
200
+ flash[:error] = t("slash_admin.controller.nestable.error", model_name: @model_name)
201
+ redirect_to(main_app.polymorphic_url([:slash_admin, @model_class])) && return
185
202
  end
186
203
 
187
204
  if request.post?
188
205
  if params[:nestable][:data].present?
189
206
  JSON.parse(params[:nestable][:data]).each_with_index do |p, i|
190
- m = @model_class.find(p['id'])
207
+ m = @model_class.find(p["id"])
191
208
  m.position = i
192
209
  m.save!
193
210
  end
194
211
  end
195
212
 
196
- flash[:success] = t('slash_admin.controller.nestable.success')
213
+ flash[:success] = t("slash_admin.controller.nestable.success")
197
214
 
198
- redirect_to main_app.polymorphic_url(['slash_admin', @model_class]) and return if params.key?(:submit_redirect)
215
+ redirect_to(main_app.polymorphic_url(["slash_admin", @model_class])) && return if params.key?(:submit_redirect)
199
216
  redirect_to main_app.polymorphic_url([:nestable, :slash_admin, @model_class])
200
217
  end
201
218
  end
202
219
 
203
220
  def handle_filtered_search
204
- if @model_class.respond_to? :translated_attribute_names
205
- search = @model_class.with_translations(I18n.locale).all
221
+ search = if @model_class.respond_to? :translated_attribute_names
222
+ @model_class.with_translations(I18n.locale).all
206
223
  else
207
- search = @model_class.all
224
+ @model_class.all
208
225
  end
209
226
 
210
227
  virtual_fields = []
@@ -215,17 +232,17 @@ module SlashAdmin
215
232
  if @model_class.respond_to?(:translated_attribute_names) && @model_class.translated_attribute_names.include?(attr.to_sym)
216
233
  attr = "#{@model_class.name.singularize.underscore}_translations.#{attr}"
217
234
  end
218
- attr_prefixed = model.table_name + '.' + attr
235
+ attr_prefixed = model.table_name + "." + attr
219
236
  case attr_type
220
- # TODO : Should be rewritten
221
- when 'belongs_to'
237
+ # TODO : Should be rewritten
238
+ when "belongs_to"
222
239
  search = search.eager_load(attr.to_s)
223
- search = search.where(attr.to_s + '_id IN (' + query.join(',') + ')')
224
- # TODO : Should be rewritten
225
- when 'has_one'
240
+ search = search.where(attr.to_s + "_id IN (" + query.join(",") + ")")
241
+ # TODO : Should be rewritten
242
+ when "has_one"
226
243
  search = search.eager_load(attr.to_s)
227
- search = search.where(attr.to_s.pluralize + '.id IN (' + query.join(',') + ')')
228
- when 'string', 'text'
244
+ search = search.where(attr.to_s.pluralize + ".id IN (" + query.join(",") + ")")
245
+ when "string", "text"
229
246
  query.strip! unless query.strip!.nil?
230
247
  attributes = @model_class.new.attributes.keys
231
248
  if !attributes.include?(attr.to_s) && @model_class.method_defined?(attr.to_s)
@@ -237,38 +254,38 @@ module SlashAdmin
237
254
  search = search.where("lower(#{attr_prefixed}) LIKE lower(:query)", query: "%#{query}%")
238
255
  end
239
256
  end
240
- when 'date', 'datetime'
257
+ when "date", "datetime"
241
258
  if query.is_a?(String)
242
259
  search = search.where("#{attr_prefixed} = :query", query: query)
243
260
  else
244
- if query['from'].present? || query['to'].present?
245
- if query['from'].to_date != query['to'].to_date
246
- if query['from'].present?
247
- search = search.where("#{attr_prefixed} >= :query", query: query['from'].to_date)
261
+ if query["from"].present? || query["to"].present?
262
+ if query["from"].to_date != query["to"].to_date
263
+ if query["from"].present?
264
+ search = search.where("#{attr_prefixed} >= :query", query: query["from"].to_date)
248
265
  end
249
- if query['to'].present?
250
- search = search.where("#{attr_prefixed} <= :query", query: query['to'].to_date)
266
+ if query["to"].present?
267
+ search = search.where("#{attr_prefixed} <= :query", query: query["to"].to_date)
251
268
  end
252
269
  else
253
- search = search.where("#{attr_prefixed} = :query", query: query['from'].to_date)
270
+ search = search.where("#{attr_prefixed} = :query", query: query["from"].to_date)
254
271
  end
255
272
  end
256
273
  end
257
- when 'decimal', 'number', 'integer'
274
+ when "decimal", "number", "integer"
258
275
  if query.instance_of?(ActionController::Parameters)
259
- if query['from'].present? || query['to'].present?
260
- search = search.where("#{attr_prefixed} >= :query", query: query['from']) if query['from'].present?
261
- search = search.where("#{attr_prefixed} <= :query", query: query['to']) if query['to'].present?
276
+ if query["from"].present? || query["to"].present?
277
+ search = search.where("#{attr_prefixed} >= :query", query: query["from"]) if query["from"].present?
278
+ search = search.where("#{attr_prefixed} <= :query", query: query["to"]) if query["to"].present?
262
279
  end
263
280
  else
264
- if attr_type == 'decimal' || attr_type == 'number'
281
+ if attr_type == "decimal" || attr_type == "number"
265
282
  query = query.to_f
266
- elsif attr_type == 'integer'
283
+ elsif attr_type == "integer"
267
284
  query = query.to_i
268
285
  end
269
286
  search = search.where("#{attr_prefixed} = :query", query: query)
270
287
  end
271
- when 'boolean'
288
+ when "boolean"
272
289
  search = search.where("#{attr_prefixed} = :query", query: to_boolean(query))
273
290
  else
274
291
  raise Exception.new("Unable to query for attribute_type : #{attr_type}")
@@ -293,7 +310,7 @@ module SlashAdmin
293
310
  end
294
311
 
295
312
  def update_params(options = {})
296
- if (options.present?)
313
+ if options.present?
297
314
  create_params(options)
298
315
  else
299
316
  create_params
@@ -306,27 +323,31 @@ module SlashAdmin
306
323
  aut_params << m if model.respond_to? m
307
324
  end
308
325
 
309
- raise Exception.new('You have to defined autocomplete_params in your admin model controller') if aut_params.blank?
326
+ raise Exception.new("You have to defined autocomplete_params in your admin model controller") if aut_params.blank?
310
327
  aut_params
311
328
  end
312
329
 
313
- protected
330
+ protected
314
331
 
315
332
  def prepend_view_paths
316
- prepend_view_path 'app/views/slash_admin'
317
- prepend_view_path "app/views/slash_admin/models/#{@model_class.model_name.to_s.pluralize.underscore}" rescue nil
333
+ prepend_view_path "app/views/slash_admin"
334
+ begin
335
+ prepend_view_path "app/views/slash_admin/models/#{@model_class.model_name.to_s.pluralize.underscore}"
336
+ rescue
337
+ nil
338
+ end
318
339
  end
319
340
 
320
341
  def handle_redirect_after_submit
321
- path = main_app.edit_polymorphic_url(['slash_admin', @model])
322
- path = main_app.polymorphic_url(['slash_admin', @model_class]) if params.key?(:submit_redirect)
323
- path = main_app.new_polymorphic_url(['slash_admin', @model_class]) if params.key?(:submit_add)
342
+ path = main_app.edit_polymorphic_url(["slash_admin", @model])
343
+ path = main_app.polymorphic_url(["slash_admin", @model_class]) if params.key?(:submit_redirect)
344
+ path = main_app.new_polymorphic_url(["slash_admin", @model_class]) if params.key?(:submit_add)
324
345
 
325
346
  path
326
347
  end
327
348
 
328
349
  def permit_params
329
- params[@model_class.name.split('::').last.underscore].permit!
350
+ params[@model_class.name.split("::").last.underscore].permit!
330
351
  end
331
352
 
332
353
  def handle_default
@@ -337,7 +358,7 @@ module SlashAdmin
337
358
  @per_values = [20, 30, 50, 100, 150]
338
359
  @use_export_params = false
339
360
  @order_field = :id
340
- @order = 'DESC'
361
+ @order = "DESC"
341
362
  end
342
363
 
343
364
  def nestable_config
@@ -386,15 +407,13 @@ module SlashAdmin
386
407
 
387
408
  # By default we are looking in SlashAdmin:: namespace
388
409
  def model
389
- begin
390
- return controller_name.classify.constantize
391
- rescue
392
- return ('SlashAdmin::' + controller_name.classify).constantize
393
- end
410
+ controller_name.classify.constantize
411
+ rescue
412
+ ("SlashAdmin::" + controller_name.classify).constantize
394
413
  end
395
414
 
396
415
  def create_params(options = {})
397
- exclude_default_params(controller_name.classify.constantize.attribute_names).map { |attr| attr.gsub(/_id$/, '') }
416
+ exclude_default_params(controller_name.classify.constantize.attribute_names).map { |attr| attr.gsub(/_id$/, "") }
398
417
  end
399
418
 
400
419
  def translatable_params
@@ -402,13 +421,13 @@ module SlashAdmin
402
421
  end
403
422
 
404
423
  def show_params
405
- @model_class.attribute_names.map { |attr| attr.gsub(/_id$/, '') }
424
+ @model_class.attribute_names.map { |attr| attr.gsub(/_id$/, "") }
406
425
  end
407
426
 
408
427
  def nested_params
409
428
  nested_params = []
410
429
  @model_class.nested_attributes_options.keys.each do |nested|
411
- nested_params << { nested => exclude_default_params(nested.to_s.singularize.classify.constantize.attribute_names.map { |attr| attr.gsub(/_id$/, '') }) - [@model.model_name.param_key] }
430
+ nested_params << {nested => exclude_default_params(nested.to_s.singularize.classify.constantize.attribute_names.map { |attr| attr.gsub(/_id$/, "") }) - [@model.model_name.param_key]}
412
431
  end
413
432
 
414
433
  nested_params
@@ -416,16 +435,16 @@ module SlashAdmin
416
435
 
417
436
  # Exclude default params for edit and create
418
437
  def exclude_default_params(params)
419
- params = params - %w(id created_at updated_at slug position)
438
+ params -= %w[id created_at updated_at slug position]
420
439
  if @model_class.try(:translated_attribute_names).present?
421
- params = params - @model_class.translated_attribute_names.map(&:to_s)
440
+ params -= @model_class.translated_attribute_names.map(&:to_s)
422
441
  end
423
442
  params
424
443
  end
425
444
 
426
445
  def stream_file(filename, extension)
427
- response.headers['Content-Type'] = 'application/octet-stream'
428
- response.headers['Content-Disposition'] = "attachment; filename=#{filename}.#{extension}"
446
+ response.headers["Content-Type"] = "application/octet-stream"
447
+ response.headers["Content-Disposition"] = "attachment; filename=#{filename}.#{extension}"
429
448
 
430
449
  yield response.stream
431
450
  ensure
@@ -434,23 +453,25 @@ module SlashAdmin
434
453
 
435
454
  def stream_csv_report
436
455
  query = @models_export.limit(5000).to_sql
437
- query_options = 'WITH CSV HEADER'
456
+ query_options = "WITH CSV HEADER"
438
457
 
439
- stream_file("#{@model_class.model_name.plural.upcase}_#{Date.today}", 'csv') do |stream|
458
+ stream_file("#{@model_class.model_name.plural.upcase}_#{Date.today}", "csv") do |stream|
440
459
  stream_query_rows(query, query_options) do |row_from_db|
441
460
  stream.write row_from_db
442
461
  end
443
462
  end
444
463
  end
445
464
 
446
- private
447
- def list_params; end
465
+ private
466
+
467
+ def list_params
468
+ end
448
469
 
449
470
  def export_params
450
471
  list_params
451
472
  end
452
473
 
453
- def stream_query_rows(sql_query, options = 'WITH CSV HEADER')
474
+ def stream_query_rows(sql_query, options = "WITH CSV HEADER")
454
475
  conn = ActiveRecord::Base.connection.raw_connection
455
476
  conn.copy_data "COPY (#{sql_query}) TO STDOUT #{options};" do
456
477
  while row = conn.get_copy_data
@@ -1,22 +1,24 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module SlashAdmin
3
4
  module Security
4
5
  class SessionsController < ActionController::Base
5
6
  protect_from_forgery with: :exception
6
7
 
7
- layout 'slash_admin/admin_user'
8
+ layout "slash_admin/admin_user"
8
9
 
9
- def new; end
10
+ def new
11
+ end
10
12
 
11
13
  def create
12
- admin = Admin.where('username = :value OR lower(email) = lower(:value)', value: params[:admin][:login]).first
14
+ admin = Admin.where("username = :value OR lower(email) = lower(:value)", value: params[:admin][:login]).first
13
15
  if admin&.authenticate(params[:admin][:password])
14
16
  session[:admin_id] = admin.id
15
- flash[:success] = 'Vous êtes à présent connecté.'
17
+ flash[:success] = "Vous êtes à présent connecté."
16
18
  redirect_to slash_admin.dashboard_path
17
19
  else
18
- @error_messages = 'Merci de vérifier vos identifiants'
19
- render :new and return
20
+ @error_messages = "Merci de vérifier vos identifiants"
21
+ render(:new) && return
20
22
  end
21
23
  end
22
24
 
@@ -8,10 +8,10 @@ module SlashAdmin
8
8
  class SelectizeController < SlashAdmin::BaseController
9
9
  def search
10
10
  model_class = model
11
- if model_class.respond_to? :translated_attribute_names
12
- results = model_class.with_translations(I18n.locale).all
11
+ results = if model_class.respond_to? :translated_attribute_names
12
+ model_class.with_translations(I18n.locale).all
13
13
  else
14
- results = model_class.all
14
+ model_class.all
15
15
  end
16
16
 
17
17
  duplicate_for_orwhere = results
@@ -48,11 +48,9 @@ module SlashAdmin
48
48
  end
49
49
  end
50
50
 
51
-
52
-
53
51
  formatted_result = []
54
52
  results.each do |r|
55
- formatted_result << { id: r.id, name: helpers.show_object(r) }
53
+ formatted_result << {id: r.id, name: helpers.show_object(r)}
56
54
  end
57
55
 
58
56
  render json: formatted_result
@@ -100,7 +100,7 @@ module SlashAdmin
100
100
  # Default available field_type handeled
101
101
  def orderable?(object, attr)
102
102
  field_type = guess_field_type(object, attr)
103
- %w(boolean integer number decimal string text date datetime).include?(field_type)
103
+ %w[boolean integer number decimal string text date datetime].include?(field_type)
104
104
  end
105
105
 
106
106
  # By default all sortable fields are orderable
@@ -115,17 +115,17 @@ module SlashAdmin
115
115
  # Default label for object to string, title and name
116
116
  # can be an attribute, a string or the model_class
117
117
  def object_label(a)
118
- if a.is_a? Hash
119
- constantized_model = a.keys.first.to_s.singularize.classify.constantize
118
+ constantized_model = if a.is_a? Hash
119
+ a.keys.first.to_s.singularize.classify.constantize
120
120
  elsif a.is_a? ActiveRecord::Base
121
- constantized_model = a
121
+ a
122
122
  else
123
- constantized_model = a.to_s.singularize.classify.constantize
123
+ a.to_s.singularize.classify.constantize
124
124
  end
125
125
 
126
126
  constantized_model = constantized_model.new
127
127
 
128
- method = 'to_s'
128
+ method = "to_s"
129
129
  object_label_methods.each do |m|
130
130
  method = m if constantized_model.respond_to?(m)
131
131
  end
@@ -134,7 +134,7 @@ module SlashAdmin
134
134
  end
135
135
 
136
136
  def show_object(a)
137
- method = 'to_s'
137
+ method = "to_s"
138
138
 
139
139
  unless a.blank?
140
140
  object_label_methods.each do |m|
@@ -149,10 +149,10 @@ module SlashAdmin
149
149
  # object params can be a Model Class or a Model Instance
150
150
  # boolean integer number decimal string text date datetime has_many belongs_to
151
151
  def guess_field_type(object, attr)
152
- if object.class === Class
153
- object_class = object
152
+ object_class = if object.class === Class
153
+ object
154
154
  else
155
- object_class = object.class
155
+ object.class
156
156
  end
157
157
 
158
158
  belongs_to_fields = object_class.reflect_on_all_associations(:belongs_to).map(&:name)
@@ -162,19 +162,19 @@ module SlashAdmin
162
162
  return if attr.is_a? Hash
163
163
 
164
164
  type = if object_class&.uploaders&.key?(attr.to_sym)
165
- 'image'
165
+ "image"
166
166
  elsif belongs_to_fields.include?(attr.to_sym)
167
- 'belongs_to'
167
+ "belongs_to"
168
168
  elsif has_many_fields.include?(attr.to_sym)
169
- 'has_many'
169
+ "has_many"
170
170
  elsif has_one_fields.include?(attr.to_sym)
171
- 'has_one'
171
+ "has_one"
172
172
  else
173
173
  object_class.type_for_attribute(attr.to_s).type.to_s
174
174
  end
175
175
 
176
176
  # Virtual field default string eg password
177
- return 'string' if object_class.new.respond_to?(attr) && type.blank?
177
+ return "string" if object_class.new.respond_to?(attr) && type.blank?
178
178
 
179
179
  # Raise exception if no type fouded
180
180
  raise Exception.new("Unable to guess field_type for attribute: #{attr} in model: #{object_class}") if type.blank?
@@ -184,15 +184,14 @@ module SlashAdmin
184
184
  # From shoulda-matchers https://github.com/thoughtbot/shoulda-matchers/blob/da4e6ddd06de54016e7c2afd953120f0f6529c70/lib/shoulda/matchers/rails_shim.rb
185
185
  # @param model @model_class
186
186
  def serialized_attributes_for(model)
187
- serialized_columns = model.columns.select do |column|
187
+ serialized_columns = model.columns.select { |column|
188
188
  model.type_for_attribute(column.name).is_a?(
189
189
  ::ActiveRecord::Type::Serialized,
190
- )
191
- end
190
+ )
191
+ }
192
192
 
193
- serialized_columns.inject({}) do |hash, column|
193
+ serialized_columns.each_with_object({}) do |column, hash|
194
194
  hash[column.name.to_s] = model.type_for_attribute(column.name).coder
195
- hash
196
195
  end
197
196
  end
198
197
 
@@ -205,7 +204,7 @@ module SlashAdmin
205
204
 
206
205
  def admin_custom_field(form, attribute)
207
206
  type = attribute[attribute.keys.first][:type].to_s
208
- render partial: "slash_admin/custom_fields/#{type}", locals: { f: form, a: attribute }
207
+ render partial: "slash_admin/custom_fields/#{type}", locals: {f: form, a: attribute}
209
208
  end
210
209
 
211
210
  # Form helper for generic field
@@ -220,32 +219,32 @@ module SlashAdmin
220
219
  admin_custom_field(form, attribute)
221
220
  elsif belongs_to_fields.include?(attribute.to_sym)
222
221
  if form.object.class.nested_attributes_options.key?(attribute.to_sym)
223
- render partial: 'slash_admin/fields/nested_belongs_to', locals: { f: form, a: attribute }
222
+ render partial: "slash_admin/fields/nested_belongs_to", locals: {f: form, a: attribute}
224
223
  else
225
- render partial: 'slash_admin/fields/belongs_to', locals: { f: form, a: attribute }
224
+ render partial: "slash_admin/fields/belongs_to", locals: {f: form, a: attribute}
226
225
  end
227
226
  elsif has_many_fields.include?(attribute.to_sym)
228
227
  # if has nested_attributes_options for has_many field
229
228
  if form.object.class.nested_attributes_options.key?(attribute.to_sym)
230
- render partial: 'slash_admin/fields/nested_has_many', locals: { f: form, a: attribute }
229
+ render partial: "slash_admin/fields/nested_has_many", locals: {f: form, a: attribute}
231
230
  else
232
- render partial: 'slash_admin/fields/has_many', locals: { f: form, a: attribute }
231
+ render partial: "slash_admin/fields/has_many", locals: {f: form, a: attribute}
233
232
  end
234
233
  elsif has_one_fields.include?(attribute.to_sym)
235
234
  if form.object.class.nested_attributes_options.key?(attribute.to_sym)
236
- render partial: 'slash_admin/fields/nested_has_one', locals: { f: form, a: attribute }
235
+ render partial: "slash_admin/fields/nested_has_one", locals: {f: form, a: attribute}
237
236
  else
238
- render partial: 'slash_admin/fields/has_one', locals: { f: form, a: attribute }
237
+ render partial: "slash_admin/fields/has_one", locals: {f: form, a: attribute}
239
238
  end
240
239
  elsif form.object.class&.uploaders&.key?(attribute.to_sym)
241
- render partial: 'slash_admin/fields/carrierwave', locals: { f: form, a: attribute }
240
+ render partial: "slash_admin/fields/carrierwave", locals: {f: form, a: attribute}
242
241
  else
243
242
  type = form.object.class.type_for_attribute(attribute.to_s).type.to_s
244
- if type == 'date' || type == 'datetime'
245
- render partial: 'slash_admin/fields/date', locals: { f: form, a: attribute }
243
+ if type == "date" || type == "datetime"
244
+ render partial: "slash_admin/fields/date", locals: {f: form, a: attribute}
246
245
  else
247
246
  raise Exception.new("Unable to guess field_type for attribute: #{attribute} in model: #{object_class}") if type.blank?
248
- render partial: "slash_admin/fields/#{type}", locals: { f: form, a: attribute }
247
+ render partial: "slash_admin/fields/#{type}", locals: {f: form, a: attribute}
249
248
  end
250
249
  end
251
250
  end
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module SlashAdmin
3
4
  module MenuHelper
4
5
  def menu_entries
5
6
  [
6
7
  {
7
- title: 'Dashboard',
8
+ title: "Dashboard",
8
9
  path: slash_admin.dashboard_path,
9
- icon: 'icon-home',
10
+ icon: "icon-home",
10
11
  },
11
12
  ]
12
13
  end
@@ -3,6 +3,6 @@
3
3
  module SlashAdmin::WidgetsHelper
4
4
  # number, title, icon, progress_label, percent, status
5
5
  def statistic_progress_tile(options = {})
6
- render 'slash_admin/dashboard/widgets/statistic_progress_tile', options: options
6
+ render "slash_admin/dashboard/widgets/statistic_progress_tile", options: options
7
7
  end
8
8
  end
@@ -1,6 +1,6 @@
1
1
  module SlashAdmin
2
2
  class ApplicationMailer < ActionMailer::Base
3
- default from: 'from@example.com'
4
- layout 'mailer'
3
+ default from: "from@example.com"
4
+ layout "mailer"
5
5
  end
6
6
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module SlashAdmin
3
4
  class Admin < ApplicationRecord
4
5
  include CanCan::Ability
@@ -9,7 +10,7 @@ module SlashAdmin
9
10
 
10
11
  EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
11
12
  USERNAME_REGEX = /^[a-zA-Z0-9_\.]*$/
12
- validates :username, presence: true, uniqueness: true, length: { in: 3..20 }
13
+ validates :username, presence: true, uniqueness: true, length: {in: 3..20}
13
14
  validates :email, presence: true, uniqueness: true
14
15
  validates_length_of :password, in: 6..20, on: :create
15
16
  validates_format_of :email, with: EMAIL_REGEX, multiline: true
@@ -28,15 +29,13 @@ module SlashAdmin
28
29
  end
29
30
 
30
31
  def handle_default_role
31
- self.roles = 'superadmin' unless roles.present?
32
+ self.roles = "superadmin" unless roles.present?
32
33
  end
33
34
 
34
- def login=(login)
35
- @login = login
36
- end
35
+ attr_writer :login
37
36
 
38
37
  def login
39
- @login || self.username || self.email
38
+ @login || username || email
40
39
  end
41
40
 
42
41
  def identicon
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module SlashAdmin
3
4
  class AdminAbility
4
5
  include CanCan::Ability
@@ -17,43 +17,52 @@
17
17
  <input type="checkbox" class="toggle-all"/>
18
18
  </th>
19
19
  <th
20
- data-order-field="id"
21
- <% if params[:order_field].to_s == 'id' %>
22
- class="ordered <%= params[:order].downcase %>"
23
- data-order="<%= params[:order] %>"
24
- <% else %>
25
- class="ordered"
26
- <% end %>
27
- >#
20
+ data-order-field="id"
21
+ <% if params[:order_field].to_s == 'id' %>
22
+ class="ordered <%= params[:order].downcase %>"
23
+ data-order="<%= params[:order] %>"
24
+ <% else %>
25
+ class="ordered"
26
+ <% end %>
27
+ >#
28
28
  </th>
29
29
  <% list_params.each do |attr| %>
30
30
  <% if attr.is_a?(Hash) %>
31
- <th><%= @model_class.human_attribute_name(attr.keys.first) %></th>
31
+ <th>
32
+ <%= @model_class.human_attribute_name(attr.keys.first) %>
33
+ <% if tooltips.key? attr.keys.first %>
34
+ <a href="#" data-toggle="tooltip" data-placement="top" title="<%= tooltips[attr] %>"><i class="fas fa-question-circle"></i></a>
35
+ <% end %>
36
+ </th>
32
37
  <% else %>
33
38
  <th
34
- <% if orderable?(@model_class, attr) %>
35
- data-order-field="<%= attr %>"
36
- <% if params[:order_field].to_s == attr.to_s %>
37
- class="ordered <%= params[:order].downcase %>"
38
- data-order="<%= params[:order] %>"
39
- <% else %>
40
- class="ordered"
41
- <% end %>
42
- <% end %>>
39
+ <% if orderable?(@model_class, attr) %>
40
+ data-order-field="<%= attr %>"
41
+ <% if params[:order_field].to_s == attr.to_s %>
42
+ class="ordered <%= params[:order].downcase %>"
43
+ data-order="<%= params[:order] %>"
44
+ <% else %>
45
+ class="ordered"
46
+ <% end %>
47
+ <% end %>>
43
48
  <%= @model_class.human_attribute_name(attr) %>
49
+ <% if tooltips.key? attr %>
50
+ <a href="#" data-toggle="tooltip" data-placement="top" title="<%= tooltips[attr] %>"><i class="fas fa-question-circle"></i></a>
51
+ <% end %>
44
52
  </th>
45
53
  <% end %>
46
54
  <% end %>
47
55
  <th class="text-center"><%= t('slash_admin.view.actions') %></th>
48
56
  </tr>
49
57
 
50
- <%= render 'filters', model: @model_class %>
58
+ <%= render 'filters', model: @model_class %>
51
59
  </thead>
52
60
 
53
61
  <tbody>
54
62
  <% @models.each do |m| %>
55
63
  <tr>
56
- <td class="fit"><input type="checkbox" name="<%= @model_name.pluralize.downcase %>[] %>" value="<%= m.id %>"></td>
64
+ <td class="fit"><input type="checkbox" name="<%= @model_name.pluralize.downcase %>[] %>" value="<%= m.id %>">
65
+ </td>
57
66
  <td class="fit"><%= m.id %></td>
58
67
  <% list_params.each do |attr| %>
59
68
  <% if attr.is_a?(Hash) %>
@@ -65,7 +74,7 @@
65
74
  <em><%= t('slash_admin.view.no_image') %></em>
66
75
  <% end %>
67
76
  </td>
68
- <% else %>
77
+ <% else %>
69
78
  <td class="<%= attr.to_s.parameterize.underscore.downcase %>"><%= render attr.keys.first.to_s, model: m %></td>
70
79
  <% end %>
71
80
  <% else %>
@@ -88,7 +97,8 @@
88
97
  <div class="modal-dialog" role="document">
89
98
  <div class="modal-content">
90
99
  <div class="modal-header">
91
- <h5 class="modal-title" id="exampleModalLabel"><%= t('slash_admin.view.associations') %> <strong>(<%= m.send(attr).length %>)</strong></h5>
100
+ <h5 class="modal-title" id="exampleModalLabel"><%= t('slash_admin.view.associations') %>
101
+ <strong>(<%= m.send(attr).length %>)</strong></h5>
92
102
  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
93
103
  <span aria-hidden="true">&times;</span>
94
104
  </button>
@@ -99,7 +109,7 @@
99
109
  <% else %>
100
110
  <% m.send(attr).each do |a| %>
101
111
  <%= link_to(edit_polymorphic_url([:slash_admin, a]), class: 'link', target: '_blank') do %>
102
- <%= show_object(a) %><br />
112
+ <%= show_object(a) %><br/>
103
113
  <% end rescue show_object(a) %>
104
114
  <% end %>
105
115
  <% end %>
@@ -145,7 +155,7 @@
145
155
  <%= render 'slash_admin/shared/better_paginate' %>
146
156
 
147
157
  <script type="text/javascript">
148
- $(document).on('turbolinks:load', function() {
158
+ $(document).on('turbolinks:load', function () {
149
159
  $('.bootstrap-datepicker').datepicker({
150
160
  language: '<%= I18n.locale.to_s %>',
151
161
  format: "YYYY-MM-DD",
@@ -156,7 +166,7 @@
156
166
  });
157
167
 
158
168
  // handle Sort
159
- $('.ordered').on('click', function() {
169
+ $('.ordered').on('click', function () {
160
170
  var field = $(this).data('order-field');
161
171
 
162
172
  if (field) {
@@ -170,13 +180,13 @@
170
180
 
171
181
  // change order field should reset pagination
172
182
  $('.admin-pagination input').val(1);
173
- $('.admin-pagination option:first').prop('selected',true);
183
+ $('.admin-pagination option:first').prop('selected', true);
174
184
  handleFiltersAndLocation();
175
185
  }
176
186
  });
177
187
 
178
188
  function toggle_order(order_direction) {
179
- return order_direction == 'DESC' ? 'ASC' : 'DESC';
189
+ return order_direction === 'DESC' ? 'ASC' : 'DESC';
180
190
  }
181
191
 
182
192
  function handle_form(field, order_direction) {
@@ -240,11 +250,11 @@
240
250
  }
241
251
  });
242
252
 
243
- $('#reset-filters').on('click', function(e) {
253
+ $('#reset-filters').on('click', function (e) {
244
254
  e.preventDefault();
245
255
 
246
256
  $("input[name*='filters']").val('');
247
- $("select[name*='filters'] option:first").prop('selected',true);
257
+ $("select[name*='filters'] option:first").prop('selected', true);
248
258
 
249
259
  $('#filters').trigger('submit');
250
260
  });
@@ -258,9 +268,9 @@
258
268
  var paginationParams = $('.admin-pagination').first().serialize();
259
269
  var orderParams = $('#order').serialize();
260
270
 
261
- parameters = '';
262
- $.each([filtersParams, paginationParams, orderParams], function(index, params) {
263
- if (index != 0) {
271
+ var parameters = '';
272
+ $.each([filtersParams, paginationParams, orderParams], function (index, params) {
273
+ if (index !== 0) {
264
274
  parameters += '&' + params;
265
275
  } else {
266
276
  parameters += params;
@@ -1,6 +1,6 @@
1
1
  class JsonValidator < ActiveModel::EachValidator
2
2
  def validate_each(record, attribute, value)
3
- record.errors[attribute] << (options[:message] || I18n.t('slash_admin.view.json_not_valid')) unless valid_json?(value)
3
+ record.errors[attribute] << (options[:message] || I18n.t("slash_admin.view.json_not_valid")) unless valid_json?(value)
4
4
  end
5
5
 
6
6
  def valid_json?(string)
data/config/routes.rb CHANGED
@@ -1,16 +1,16 @@
1
1
  SlashAdmin::Engine.routes.draw do
2
2
  scope :admin do
3
- get '/' => 'dashboard#home', as: 'dashboard'
4
- get 'login' => 'security/sessions#new'
5
- post 'login', to: 'security/sessions#create'
6
- get 'logout' => 'security/sessions#destroy'
7
- get 'dashboard/toggle' => 'dashboard#toggle', as: 'toggle_dashboard'
3
+ get "/" => "dashboard#home", :as => "dashboard"
4
+ get "login" => "security/sessions#new"
5
+ post "login", to: "security/sessions#create"
6
+ get "logout" => "security/sessions#destroy"
7
+ get "dashboard/toggle" => "dashboard#toggle", :as => "toggle_dashboard"
8
8
 
9
- get 'search' => 'selectize#search', as: 'remote_selectize'
9
+ get "search" => "selectize#search", :as => "remote_selectize"
10
10
 
11
11
  # Batch actions
12
12
 
13
13
  # DELETE
14
- post 'batch_actions/delete/:model_class', to: 'batch_actions#delete', as: 'batch_delete'
14
+ post "batch_actions/delete/:model_class", to: "batch_actions#delete", as: "batch_delete"
15
15
  end
16
16
  end
@@ -1,16 +1,17 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class CreateSlashAdminAdmins < ActiveRecord::Migration[5.0]
3
4
  def change
4
5
  create_table :slash_admin_admins do |t|
5
6
  ## Database authenticatable
6
- t.string :username, null: false, default: ''
7
- t.string :email, null: false, default: ''
8
- t.string :password_digest, null: false, default: ''
7
+ t.string :username, null: false, default: ""
8
+ t.string :email, null: false, default: ""
9
+ t.string :password_digest, null: false, default: ""
9
10
  t.string :avatar
10
11
  t.string :roles
11
12
 
12
13
  ## Recoverable
13
- t.string :reset_password_token
14
+ t.string :reset_password_token
14
15
  t.datetime :reset_password_sent_at
15
16
 
16
17
  t.timestamps null: false
@@ -4,13 +4,13 @@ module ActionView
4
4
  module Helpers
5
5
  class FormBuilder
6
6
  def globalize_fields_for(locale, *args, &proc)
7
- raise ArgumentError, 'Missing block' unless block_given?
7
+ raise ArgumentError, "Missing block" unless block_given?
8
8
  options = args.extract_options!
9
9
  @index = @index ? @index + 1 : 1
10
10
  object_name = "#{@object_name}[translations_attributes][#{@index}]"
11
11
  form_object = @object || @object_name.to_s.camelize.constantize.new
12
- object = form_object.translations.select { |t| t.locale.to_s == locale.to_s }.first
13
- @template.concat @template.hidden_field_tag("#{object_name}[id]", object ? object.id : '')
12
+ object = form_object.translations.find { |t| t.locale.to_s == locale.to_s }
13
+ @template.concat @template.hidden_field_tag("#{object_name}[id]", object ? object.id : "")
14
14
  @template.concat @template.hidden_field_tag("#{object_name}[locale]", locale)
15
15
  @template.fields_for(object_name, object, options, &proc)
16
16
  end
@@ -1,15 +1,16 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module SlashAdmin
3
4
  module Generators
4
5
  class ControllersGenerator < Rails::Generators::Base
5
- source_root File.expand_path('../templates', __FILE__)
6
+ source_root File.expand_path("../templates", __FILE__)
6
7
  argument :model, required: true,
7
- desc: 'The model concerned'
8
+ desc: "The model concerned"
8
9
 
9
10
  def create_controller
10
11
  @model_name = model.camelize
11
- template 'controllers.erb',
12
- "app/controllers/slash_admin/models/#{model}_controller.rb"
12
+ template "controllers.erb",
13
+ "app/controllers/slash_admin/models/#{model}_controller.rb"
13
14
  end
14
15
  end
15
16
  end
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module SlashAdmin
3
4
  module Generators
4
5
  class InstallGenerator < Rails::Generators::Base
5
- source_root File.expand_path('../templates', __FILE__)
6
+ source_root File.expand_path("../templates", __FILE__)
6
7
 
7
8
  def install
8
- template 'install.erb',
9
- 'app/helpers/slash_admin/menu_helper.rb'
9
+ template "install.erb",
10
+ "app/helpers/slash_admin/menu_helper.rb"
10
11
  end
11
12
  end
12
13
  end
@@ -3,11 +3,11 @@
3
3
  module SlashAdmin
4
4
  module Generators
5
5
  class OverrideAdminGenerator < Rails::Generators::Base
6
- source_root File.expand_path('../templates', __FILE__)
6
+ source_root File.expand_path("../templates", __FILE__)
7
7
 
8
8
  def override_admin
9
- template 'admin.erb',
10
- 'app/models/slash_admin/admin.rb'
9
+ template "admin.erb",
10
+ "app/models/slash_admin/admin.rb"
11
11
  end
12
12
  end
13
13
  end
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module SlashAdmin
3
4
  module Generators
4
5
  class OverrideSessionGenerator < Rails::Generators::Base
5
- source_root File.expand_path('../templates', __FILE__)
6
+ source_root File.expand_path("../templates", __FILE__)
6
7
 
7
8
  def override_session
8
- template 'session.erb',
9
- 'app/controllers/slash_admin/security/sessions_controller.rb'
9
+ template "session.erb",
10
+ "app/controllers/slash_admin/security/sessions_controller.rb"
10
11
  end
11
12
  end
12
13
  end
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module SlashAdmin
3
4
  module Generators
4
5
  class PermissionsGenerator < Rails::Generators::Base
5
- source_root File.expand_path('../templates', __FILE__)
6
+ source_root File.expand_path("../templates", __FILE__)
6
7
 
7
8
  def create_permissions
8
- template 'permissions.erb',
9
- 'app/models/slash_admin/admin_ability.rb'
9
+ template "permissions.erb",
10
+ "app/models/slash_admin/admin_ability.rb"
10
11
  end
11
12
  end
12
13
  end
@@ -2,7 +2,7 @@ module SlashAdmin
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace SlashAdmin
4
4
  config.to_prepare do
5
- Rails.application.config.assets.precompile += %w( slash_admin/* )
5
+ Rails.application.config.assets.precompile += %w[slash_admin/*]
6
6
  end
7
7
  end
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module SlashAdmin
2
- VERSION = '1.0.1'
2
+ VERSION = "1.0.2"
3
3
  end
data/lib/slash_admin.rb CHANGED
@@ -1,27 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'slash_admin/engine'
4
- require 'cancancan'
5
- require 'kaminari'
6
- require 'groupdate'
7
- require 'ruby_identicon'
8
- require 'bcrypt'
9
- require 'chartkick'
10
- require 'chart-js-rails'
11
- require 'highcharts-rails'
12
- require 'selectize-rails'
13
- require 'js-routes'
14
- require 'i18n-js'
15
- require 'bootstrap'
16
- require 'cocoon'
17
- require 'datetime_picker_rails'
18
- require 'jquery-rails'
19
- require 'jquery-minicolors-rails'
20
- require 'momentjs-rails'
21
- require 'tether-rails'
22
- require 'sweetalert-rails'
23
- require 'http_accept_language'
24
- require 'batch_translation'
3
+ require "slash_admin/engine"
4
+ require "cancancan"
5
+ require "kaminari"
6
+ require "groupdate"
7
+ require "ruby_identicon"
8
+ require "bcrypt"
9
+ require "chartkick"
10
+ require "chart-js-rails"
11
+ require "highcharts-rails"
12
+ require "selectize-rails"
13
+ require "js-routes"
14
+ require "i18n-js"
15
+ require "bootstrap"
16
+ require "cocoon"
17
+ require "datetime_picker_rails"
18
+ require "jquery-rails"
19
+ require "jquery-minicolors-rails"
20
+ require "momentjs-rails"
21
+ require "tether-rails"
22
+ require "sweetalert-rails"
23
+ require "http_accept_language"
24
+ require "batch_translation"
25
25
 
26
26
  module SlashAdmin
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slash_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - KOVACS Nicolas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-28 00:00:00.000000000 Z
11
+ date: 2019-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails