thecore_ui_rails_admin 2.1.3 → 2.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/rails_admin/ra.widgets.coffee +233 -0
  3. data/app/assets/javascripts/thecore_ui_rails_admin/thecore_rails_admin.js +78 -0
  4. data/app/assets/stylesheets/thecore_ui_rails_admin/animate.css +3458 -0
  5. data/app/assets/stylesheets/thecore_ui_rails_admin/apexcharts.scss +7 -0
  6. data/app/assets/stylesheets/thecore_ui_rails_admin/common.scss +36 -0
  7. data/app/assets/stylesheets/thecore_ui_rails_admin/devise.scss +248 -0
  8. data/app/assets/stylesheets/thecore_ui_rails_admin/flashing.scss +28 -0
  9. data/app/assets/stylesheets/thecore_ui_rails_admin/mixins.scss +18 -0
  10. data/app/assets/stylesheets/thecore_ui_rails_admin/thecore.scss +25 -0
  11. data/app/assets/stylesheets/thecore_ui_rails_admin/thecore_rails_admin.scss +204 -0
  12. data/app/assets/stylesheets/thecore_ui_rails_admin/togglable-sidebar.scss +90 -0
  13. data/app/controllers/pages_controller.rb +43 -0
  14. data/app/helpers/devise_bootstrap_errors_helper.rb +20 -0
  15. data/app/helpers/thecore_helper.rb +54 -0
  16. data/app/views/layouts/rails_admin/_navigation.html.haml +13 -0
  17. data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +3 -0
  18. data/app/views/layouts/rails_admin/_sidebar_navigation.html.haml +4 -0
  19. data/app/views/layouts/rails_admin/_user_navigation.html.haml +7 -0
  20. data/app/views/layouts/rails_admin/application.html.haml +59 -0
  21. data/app/views/layouts/rails_admin/pjax.html.haml +25 -0
  22. data/app/views/rails_admin/main/_card.html.haml +17 -0
  23. data/app/views/rails_admin/main/_modal_interaction.html.erb +53 -0
  24. data/app/views/rails_admin/main/dashboard.html.haml +43 -0
  25. data/app/views/rails_admin/main/index.html.haml +90 -0
  26. data/app/views/shared/_flash.html.erb +10 -0
  27. data/config/initializers/rails_admin.rb +73 -0
  28. data/config/initializers/thecore_concern.rb +130 -0
  29. data/config/initializers/thecore_ui_rails_admin_app_configs.rb +17 -0
  30. data/config/locales/en.index_cards.custom.yml +8 -0
  31. data/config/locales/en.main.yml +27 -0
  32. data/config/locales/en.rails_admin.yml +34 -0
  33. data/config/locales/en.rollincode.yml +5 -0
  34. data/config/locales/it.index_cards.custom.yml +20 -0
  35. data/config/locales/it.main.yml +27 -0
  36. data/config/locales/it.rails_admin.yml +4 -0
  37. data/config/locales/it.rollincode.yml +5 -0
  38. data/config/locales/thecore_settings.en.yml +31 -0
  39. data/config/locales/thecore_settings.it.yml +31 -0
  40. data/config/routes.rb +10 -0
  41. data/db/migrate/20161227101954_create_rails_admin_settings.rb +25 -0
  42. data/db/migrate/20161227101956_add_app_name.rb +5 -0
  43. data/lib/abilities/thecore_ui_rails_admin.rb +12 -0
  44. data/lib/concerns/rails_admin_requirements.rb +19 -0
  45. data/lib/concerns/thecore_rails_admin_bulk_delete_concern.rb +16 -0
  46. data/lib/concerns/thecore_rails_admin_export_concern.rb +16 -0
  47. data/lib/concerns/thecore_ui_rails_admin_permission.rb +32 -0
  48. data/lib/concerns/thecore_ui_rails_admin_role.rb +36 -0
  49. data/lib/concerns/thecore_ui_rails_admin_user.rb +75 -0
  50. data/lib/thecore_ui_rails_admin.rb +21 -3
  51. data/lib/thecore_ui_rails_admin/version.rb +1 -1
  52. metadata +147 -2
@@ -0,0 +1,90 @@
1
+ :ruby
2
+ query = params[:query]
3
+ params = request.params.except(:authenticity_token, :action, :controller, :utf8, :bulk_export, :_pjax)
4
+ params.delete(:query) if params[:query].blank?
5
+ params.delete(:sort_reverse) unless params[:sort_reverse] == 'true'
6
+ sort_reverse = params[:sort_reverse]
7
+ sort = params[:sort]
8
+ params.delete(:sort) if params[:sort] == @model_config.list.sort_by.to_s
9
+ export_action = RailsAdmin::Config::Actions.find(:export, { controller: self.controller, abstract_model: @abstract_model })
10
+ export_action = nil unless export_action && authorized?(export_action.authorization_key, @abstract_model)
11
+ description = RailsAdmin.config(@abstract_model.model_name).description
12
+ properties = @model_config.list.with(controller: self.controller, view: self, object: @abstract_model.model.new).visible_fields
13
+ checkboxes = @model_config.list.checkboxes?
14
+ # columns paginate
15
+ unless (frozen_columns = @model_config.list.sidescroll_frozen_columns)
16
+ sets = get_column_sets(properties)
17
+ properties = sets[params[:set].to_i] || []
18
+ other_left = ((params[:set].to_i - 1) >= 0) && sets[params[:set].to_i - 1].present?
19
+ other_right = sets[params[:set].to_i + 1].present?
20
+ end
21
+
22
+ - content_for :contextual_tabs do
23
+ - if checkboxes
24
+ = bulk_menu
25
+ - if filterable_fields.present?
26
+ %li.dropdown{style: 'float:right'}
27
+ %a.dropdown-toggle{href: '#', :'data-toggle' => "dropdown"}
28
+ = t('admin.misc.add_filter')
29
+ %b.caret
30
+ %ul.dropdown-menu#filters{style: 'left:auto; right:0;'}
31
+ - filterable_fields.each do |field|
32
+ - field_options = case field.type
33
+ - when :enum
34
+ - options_for_select(field.with(object: @abstract_model.model.new).enum)
35
+ - else
36
+ - ''
37
+ %li
38
+ %a{href: '#', :"data-field-label" => field.label, :"data-field-name" => field.name, :"data-field-options" => field_options.html_safe, :"data-field-type" => field.type, :"data-field-value" => "", :"data-field-datetimepicker-format" => (field.try(:parser) && field.parser.to_momentjs)}= capitalize_first_letter(field.label)
39
+
40
+ %style
41
+ - properties.select{ |p| p.column_width.present? }.each do |property|
42
+ = "#list th.#{property.css_class} { width: #{property.column_width}px; min-width: #{property.column_width}px; }"
43
+ = "#list td.#{property.css_class} { max-width: #{property.column_width}px; }"
44
+
45
+ #list
46
+ = form_tag(index_path(params.except(*%w[page f query])), method: :get, class: "pjax-form form-inline") do
47
+ .well
48
+ %span#filters_box{data: {options: ordered_filter_options.to_json}}
49
+ %hr.filters_box{style: "display:#{ordered_filters.empty? ? 'none' : 'block'}"}
50
+ .input-group
51
+ %input.form-control.input-small{name: "query", type: "search", value: query, placeholder: t("admin.misc.filter")}
52
+ %span.input-group-btn
53
+ %button.btn.btn-primary{type: 'submit', :'data-disable-with' => '<i class="icon-white icon-refresh"></i> '.html_safe + t('admin.misc.refresh')}
54
+ %i.icon-white.icon-refresh
55
+ = t('admin.misc.refresh')
56
+ %button#remove_filter.btn.btn-info{title: "Reset filters"}
57
+ %i.icon-white.icon-remove
58
+ - if export_action
59
+ %span{style: 'float:right'}= link_to wording_for(:link, export_action), export_path(params.except('set').except('page')), class: 'btn btn-info'
60
+
61
+ - unless @model_config.list.scopes.empty?
62
+ %ul.nav.nav-tabs#scope_selector
63
+ - @model_config.list.scopes.each_with_index do |scope, index|
64
+ - scope = '_all' if scope.nil?
65
+ %li{class: "#{'active' if scope.to_s == params[:scope] || (params[:scope].blank? && index == 0)}"}
66
+ %a{href: index_path(params.merge(scope: scope, page: nil)), class: 'pjax'}= I18n.t("admin.scopes.#{@abstract_model.to_param}.#{scope}", default: I18n.t("admin.scopes.#{scope}", default: scope.to_s.titleize))
67
+
68
+ = form_tag bulk_action_path(model_name: @abstract_model.to_param), method: :post, id: "bulk_form", class: ["form", frozen_columns ? 'ra-sidescroll' : nil], data: (frozen_columns ? {ra_sidescroll: frozen_columns} : {}) do
69
+ = hidden_field_tag :bulk_action
70
+ - if description.present?
71
+ %p
72
+ %strong= description
73
+
74
+ - @objects.each do |object|
75
+ = render partial: "card", locals: {object: object, properties: properties, sort: sort, sort_reverse: sort_reverse}
76
+
77
+ - if @model_config.list.limited_pagination
78
+ .row
79
+ .col-md-6= paginate(@objects, theme: 'ra-twitter-bootstrap/without_count', total_pages: Float::INFINITY, remote: true)
80
+
81
+ - elsif @objects.respond_to?(:total_count)
82
+ - total_count = @objects.total_count.to_i
83
+ .row
84
+ .col-md-6= paginate(@objects, theme: 'ra-twitter-bootstrap', remote: true)
85
+ .row
86
+ .col-md-6= link_to(t("admin.misc.show_all"), index_path(params.merge(all: true)), class: "show-all btn btn-default clearfix pjax") unless total_count > 100 || total_count <= @objects.to_a.size
87
+ .clearfix.total-count= "#{total_count} #{@model_config.pluralize(total_count).downcase}"
88
+
89
+ - else
90
+ .clearfix.total-count= "#{@objects.size} #{@model_config.pluralize(@objects.size).downcase}"
@@ -0,0 +1,10 @@
1
+ <% flash.each do |type, message| %>
2
+ <%-unless [true, "true", :true].include? message%>
3
+ <div class="alert <%= bootstrap_class_for(type) %> fade in" role='alert'>
4
+ <button class="close" data-dismiss="alert">×</button>
5
+ <span class="glyphicon <%= bootstrap_glyphs_icon(type)%>" aria-hidden="true"></span>
6
+ <span class="sr-only"><%= type.capitalize%>:</span>
7
+ <%= message %>
8
+ </div>
9
+ <%-end%>
10
+ <% end %>
@@ -0,0 +1,73 @@
1
+ require 'rails_admin'
2
+
3
+ RailsAdmin.config do |config|
4
+ # Link for background Job
5
+ (config.navigation_static_links ||= {}).merge! "Background Monitor" => "#{ENV['RAILS_RELATIVE_URL_ROOT']}/app/sidekiq"
6
+
7
+ ### Popular gems integration
8
+ config.model "RoleUser" do
9
+ visible false
10
+ end
11
+
12
+ config.model "Predicate" do
13
+ visible false
14
+ end
15
+
16
+ config.model "Target" do
17
+ visible false
18
+ end
19
+
20
+ config.model "Action" do
21
+ visible false
22
+ end
23
+
24
+ config.model "PermissionRole" do
25
+ visible false
26
+ end
27
+
28
+ config.model "Permission" do
29
+ visible false
30
+ end
31
+
32
+ config.model "ActionText::RichText" do
33
+ visible false
34
+ end
35
+
36
+ config.model "ActiveStorage::Blob" do
37
+ visible false
38
+ end
39
+
40
+ config.model "ActiveStorage::Attachment" do
41
+ visible false
42
+ end
43
+
44
+ ## == Devise ==
45
+ config.authenticate_with do
46
+ warden.authenticate! scope: :user
47
+ end
48
+ config.current_user_method(&:current_user)
49
+
50
+ ## == Cancan ==
51
+ config.authorize_with :cancancan
52
+
53
+ ## == PaperTrail ==
54
+ # config.audit_with :paper_trail, 'User', 'PaperTrail::Version' # PaperTrail >= 3.0.0
55
+ config.show_gravatar = false
56
+ ### More at https://github.com/sferik/rails_admin/wiki/Base-configuration
57
+ config.label_methods.unshift(:display_name)
58
+
59
+ config.actions do
60
+ # show_in_app
61
+ dashboard # mandatory
62
+ index # mandatory
63
+ new
64
+ export
65
+ bulk_delete
66
+ show
67
+ edit
68
+ delete
69
+ toggle
70
+ end
71
+ end
72
+
73
+ # require "thecore_rails_admin_main_controller_concern"
@@ -0,0 +1,130 @@
1
+ require 'active_support/concern'
2
+
3
+ module ThecoreConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ # Prevent CSRF attacks by raising an exception.
8
+ # For APIs, you may want to use :null_session instead.
9
+ layout 'thecore'
10
+ protect_from_forgery with: :exception, prepend: true
11
+ rescue_from CanCan::AccessDenied do |exception|
12
+ redirect_to main_app.root_url, :alert => exception.message
13
+ end
14
+ include HttpAcceptLanguage::AutoLocale
15
+ before_action :store_user_location!, if: :storable_location?
16
+ before_action :configure_permitted_parameters, if: :devise_controller?
17
+ before_action :reject_locked!, if: :devise_controller?
18
+
19
+ helper_method :reject_locked!
20
+ helper_method :require_admin!
21
+ helper_method :line_break
22
+ helper_method :title
23
+ helper_method :bootstrap_class_for
24
+
25
+ # Redirects on successful sign in
26
+ def after_sign_in_path_for resource
27
+ # Rails.logger.debug("SUCCESFULL SIGNIN, USER IS ADMIN? #{current_user.admin?}")
28
+ #if current_user.admin?
29
+ # GETTING JUST THE ROOT ACTIONS I (CURRENT_USER) CAN MANAGE
30
+ root_actions = RailsAdmin::Config::Actions.all(:root).select {|action| can? action.action_name, :all }
31
+ # Rails.logger.debug "ROOT ACTIONS: #{root_actions.inspect}"
32
+ # GETTING THE FIRST ACTION I CAN MANAGE
33
+ action = root_actions.collect(&:action_name).first
34
+ # Rails.logger.debug "FIRST ACTION: #{action}"
35
+ # REDIRECT TO THAT ACTION
36
+ stored_location_for(resource) || rails_admin.send("#{action}_path").sub("#{ENV['RAILS_RELATIVE_URL_ROOT']}#{ENV['RAILS_RELATIVE_URL_ROOT']}", "#{ENV['RAILS_RELATIVE_URL_ROOT']}")
37
+ end
38
+ end
39
+
40
+ def title value = "Thecore"
41
+ @title = value
42
+ end
43
+
44
+ def bootstrap_class_for flash_type
45
+ case flash_type
46
+ when 'success'
47
+ 'alert-success'
48
+ when 'error'
49
+ 'alert-danger'
50
+ when 'alert'
51
+ 'alert-warning'
52
+ when 'notice'
53
+ 'alert-info'
54
+ else
55
+ flash_type.to_s
56
+ end
57
+ end
58
+
59
+ def line_break s
60
+ s.gsub("\n", "<br/>")
61
+ end
62
+ # Devise permitted params
63
+ def configure_permitted_parameters
64
+ devise_parameter_sanitizer.permit(:sign_in) {
65
+ |u| u.permit(
66
+ :username,
67
+ :password,
68
+ :email,
69
+ :login,
70
+ :password_confirmation,
71
+ :remember_me)
72
+ }
73
+ devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(
74
+ :username,
75
+ :password,
76
+ :email,
77
+ :login,
78
+ :password_confirmation)
79
+ }
80
+ devise_parameter_sanitizer.permit(:account_update) { |u| u.permit(
81
+ :username,
82
+ :email,
83
+ :login,
84
+ :password,
85
+ :password_confirmation,
86
+ :current_password)
87
+ }
88
+ end
89
+
90
+ # Auto-sign out locked users
91
+ def reject_locked!
92
+ if current_user && current_user.locked?
93
+ sign_out current_user
94
+ user_session = nil
95
+ current_user = nil
96
+ flash[:alert] = "Your account is locked."
97
+ flash[:notice] = nil
98
+ redirect_to root_url
99
+ end
100
+ end
101
+
102
+ # Only permits admin users
103
+ def require_admin!
104
+ authenticate_user!
105
+
106
+ if current_user && !current_user.admin?
107
+ redirect_to inside_path
108
+ end
109
+ end
110
+
111
+ # Its important that the location is NOT stored if:
112
+ # - The request method is not GET (non idempotent)
113
+ # - The request is handled by a Devise controller such as
114
+ # Devise::SessionsController as that could cause an
115
+ # infinite redirect loop.
116
+ # - The request is an Ajax request as this can lead to very unexpected
117
+ # behaviour.
118
+ def storable_location?
119
+ request.get? && is_navigational_format? && !devise_controller? && !request.xhr?
120
+ end
121
+
122
+ def store_user_location!
123
+ # :user is the scope we are authenticating
124
+ store_location_for(:user, request.fullpath)
125
+ end
126
+ end
127
+
128
+ # include the extension
129
+ ActionController::Base.send(:include, ThecoreConcern)
130
+
@@ -0,0 +1,17 @@
1
+ Rails.application.configure do
2
+ # config.assets.paths << root.join("app", "assets", "stylesheets", "thecore_ui_rails_admin")
3
+ # config.assets.paths << root.join("app", "assets", "javascripts", "thecore_ui_rails_admin")
4
+ # Login Page and pages not in RailsAdmin
5
+ config.assets.precompile += %w( thecore_ui_rails_admin/thecore.css thecore_ui_rails_admin/thecore.js )
6
+ # Pages under Rails Admin
7
+ config.assets.precompile += %w( thecore_ui_rails_admin/thecore_rails_admin.css thecore_ui_rails_admin/thecore_rails_admin.js )
8
+
9
+ config.after_initialize do
10
+ RailsAdmin::Config::Actions::Export.send(:include, ExportConcern)
11
+ RailsAdmin::Config::Actions::BulkDelete.send(:include, BulkDeleteConcern)
12
+ RailsAdminSettings::Setting.send(:include, RailsAdminSettings::RailsAdminExtensionConfig)
13
+ User.send(:include, ThecoreUiRailsAdminUser)
14
+ Role.send(:include, ThecoreUiRailsAdminRole)
15
+ Permission.send(:include, ThecoreUiRailsAdminPermission)
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ en:
2
+ admin:
3
+ export:
4
+ found: Export found
5
+ misc:
6
+ order_by: Order by
7
+ select:
8
+ toggle: Toggle Selection
@@ -0,0 +1,27 @@
1
+ it:
2
+ yes: Yes
3
+ no: Cancel
4
+ error: Error
5
+ question: Question
6
+ root_actions: Root Actions
7
+ admin:
8
+ js:
9
+ true: True
10
+ false: False
11
+ is_present: Is present
12
+ is_blank: Is blank
13
+ date: Date ...
14
+ between_and_: Between ... and ...
15
+ today: Today
16
+ yesterday: Yesterday
17
+ this_week: This week
18
+ last_week: Last week
19
+ number: Number ...
20
+ contains: Contains
21
+ is_exactly: Is exactly
22
+ starts_with: Starts with
23
+ ends_with: Ends with
24
+ too_many_objects: "Too many objects, use search box above"
25
+ no_objects: "No objects found"
26
+ loading: "Loading..."
27
+ toggle_navigation: Toggle navigation
@@ -0,0 +1,34 @@
1
+ en:
2
+ admin:
3
+ misc:
4
+ scopes: Fast Filters
5
+ scopes:
6
+ all: All
7
+ order_by_name: Order By Name
8
+ order_by_insert_date: Order By Date
9
+ starts_with_a: Starts with A
10
+ starts_with_b: Starts with B
11
+ starts_with_c: Starts with C
12
+ starts_with_d: Starts with D
13
+ starts_with_e: Starts with E
14
+ starts_with_f: Starts with F
15
+ starts_with_g: Starts with G
16
+ starts_with_h: Starts with H
17
+ starts_with_i: Starts with I
18
+ starts_with_j: Starts with J
19
+ starts_with_k: Starts with K
20
+ starts_with_l: Starts with L
21
+ starts_with_m: Starts with M
22
+ starts_with_n: Starts with N
23
+ starts_with_o: Starts with O
24
+ starts_with_p: Starts with P
25
+ starts_with_q: Starts with Q
26
+ starts_with_r: Starts with R
27
+ starts_with_s: Starts with S
28
+ starts_with_t: Starts with T
29
+ starts_with_u: Starts with U
30
+ starts_with_v: Starts with V
31
+ starts_with_w: Starts with W
32
+ starts_with_x: Starts with X
33
+ starts_with_y: Starts with Y
34
+ starts_with_z: Starts with Z
@@ -0,0 +1,5 @@
1
+ en:
2
+ admin:
3
+ rollincode:
4
+ number: "Number"
5
+ show: "Show"
@@ -0,0 +1,20 @@
1
+ it:
2
+ admin:
3
+ actions:
4
+ new:
5
+ menu: ""
6
+ index:
7
+ menu: ""
8
+ export:
9
+ menu: ""
10
+ export:
11
+ found: ➦
12
+ misc:
13
+ order_by: ⇅
14
+ scopes: ⋔
15
+ add_filter: ⋔
16
+ add_new: ⋔
17
+ refresh: ""
18
+ bulk_menu_title: ☰✔
19
+ select:
20
+ toggle: ☑
@@ -0,0 +1,27 @@
1
+ it:
2
+ yes: Si
3
+ no: Annulla
4
+ error: Errore
5
+ question: Domanda
6
+ root_actions: "Operazioni"
7
+ admin:
8
+ js:
9
+ true: Vero
10
+ false: Falso
11
+ is_present: Is present
12
+ is_blank: Is blank
13
+ date: Date ...
14
+ between_and_: Between ... and ...
15
+ today: Today
16
+ yesterday: Yesterday
17
+ this_week: This week
18
+ last_week: Last week
19
+ number: Number ...
20
+ contains: Contains
21
+ is_exactly: Is exactly
22
+ starts_with: Starts with
23
+ ends_with: Ends with
24
+ too_many_objects: "Too many objects, use search box above"
25
+ no_objects: "No objects found"
26
+ loading: "Loading..."
27
+ toggle_navigation: Toggle navigation