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
+ /* Toggle Styles */
2
+
3
+ #wrapper {
4
+ padding-left: 0;
5
+ -webkit-transition: all 0.5s ease;
6
+ -moz-transition: all 0.5s ease;
7
+ -o-transition: all 0.5s ease;
8
+ transition: all 0.5s ease;
9
+ }
10
+ #wrapper.toggled {
11
+ padding-left: 250px;
12
+ }
13
+ #sidebar-wrapper {
14
+ z-index: 100;
15
+ position: fixed;
16
+ left: 250px;
17
+ width: 0;
18
+ height: 100%;
19
+ margin-left: -250px;
20
+ overflow-y: auto;
21
+ background: #000;
22
+ -webkit-transition: all 0.5s ease;
23
+ -moz-transition: all 0.5s ease;
24
+ -o-transition: all 0.5s ease;
25
+ transition: all 0.5s ease;
26
+ }
27
+ #wrapper.toggled #sidebar-wrapper {
28
+ width: 250px;
29
+ }
30
+ #page-content-wrapper {
31
+ z-index: 150;
32
+ width: 100%;
33
+ position: absolute;
34
+ padding: 15px;
35
+ background-color: rgb(59,78,89);
36
+ min-height: 100vh;
37
+ }
38
+ #wrapper.toggled #page-content-wrapper {
39
+ position: absolute;
40
+ margin-right: -250px;
41
+ background-color: rgb(59,78,89);
42
+ }
43
+ /* Sidebar Styles */
44
+
45
+ .sidebar-nav {
46
+ position: absolute;
47
+ top: 0;
48
+ width: 250px;
49
+ margin: 0;
50
+ padding: 0;
51
+ list-style: none;
52
+ }
53
+ .sidebar-nav li {
54
+ text-indent: 20px;
55
+ line-height: 40px;
56
+ }
57
+ .sidebar-nav li a {
58
+ display: block;
59
+ text-decoration: none;
60
+ color: #999999;
61
+ }
62
+ .sidebar-nav li a:hover {
63
+ text-decoration: none;
64
+ color: #fff;
65
+ background: rgba(255, 255, 255, 0.2);
66
+ }
67
+ .sidebar-nav li a:active,
68
+ .sidebar-nav li a:focus {
69
+ text-decoration: none;
70
+ }
71
+ .sidebar-nav > .sidebar-brand {
72
+ height: 65px;
73
+ font-size: 18px;
74
+ line-height: 60px;
75
+ }
76
+ .sidebar-nav > .sidebar-brand a {
77
+ color: #999999;
78
+ }
79
+ .sidebar-nav > .sidebar-brand a:hover {
80
+ color: #fff;
81
+ background: none;
82
+ }
83
+
84
+ body.rails_admin .sidebar-nav {
85
+ top: 0px;
86
+ }
87
+
88
+ .sub-menu a {
89
+ padding-left: 20px;
90
+ }
@@ -0,0 +1,43 @@
1
+ class PagesController < ApplicationController
2
+ before_action :authenticate_user!, only: [
3
+ :inside, :contact
4
+ ]
5
+
6
+ # So the static link navigation can be set runtime (yes it's an hack
7
+ # since I have to set this dynamically at runtime, using a class
8
+ # continously re-evaluated)
9
+ RailsAdmin.config do |config|
10
+ config.navigation_static_label = I18n.t('admin.links.label')
11
+ end
12
+
13
+ def home
14
+ end
15
+
16
+ def inside
17
+ end
18
+
19
+
20
+ def email
21
+ @name = params[:name]
22
+ @email = params[:email]
23
+ @message = params[:message]
24
+
25
+ if @name.blank?
26
+ flash[:alert] = "Please enter your name before sending your message. Thank you."
27
+ render :contact
28
+ elsif @email.blank? || @email.scan(/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i).size < 1
29
+ flash[:alert] = "You must provide a valid email address before sending your message. Thank you."
30
+ render :contact
31
+ elsif @message.blank? || @message.length < 10
32
+ flash[:alert] = "Your message is empty. Requires at least 10 characters. Nothing to send."
33
+ render :contact
34
+ elsif @message.scan(/<a href=/).size > 0 || @message.scan(/\[url=/).size > 0 || @message.scan(/\[link=/).size > 0 || @message.scan(/http:\/\//).size > 0
35
+ flash[:alert] = "You can't send links. Thank you for your understanding."
36
+ render :contact
37
+ else
38
+ ContactMailer.contact_message(@name,@email,@message).deliver_now
39
+ redirect_to root_path, notice: "Your message was sent. Thank you."
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,20 @@
1
+ module DeviseBootstrapErrorsHelper
2
+ def devise_bootstrap_error_messages!
3
+ return '' if resource.errors.empty?
4
+
5
+ messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
6
+ sentence = I18n.t('errors.messages.not_saved',
7
+ count: resource.errors.count,
8
+ resource: resource.class.model_name.human.downcase)
9
+
10
+ html = <<-HTML
11
+ <div class="alert alert-danger alert-block devise-bs">
12
+ <button type="button" class="close" data-dismiss="alert">&times;</button>
13
+ <h5>#{sentence}</h5>
14
+ <ul>#{messages}</ul>
15
+ </div>
16
+ HTML
17
+
18
+ html.html_safe
19
+ end
20
+ end
@@ -0,0 +1,54 @@
1
+ module ThecoreHelper
2
+ def bootstrap_class_for(flash_type)
3
+ {
4
+ success: "alert-success",
5
+ error: "alert-error",
6
+ alert: "alert-danger",
7
+ notice: "alert-info"
8
+ }[flash_type.to_sym] || flash_type.to_s
9
+ end
10
+
11
+ def bootstrap_glyphs_icon(flash_type)
12
+ {
13
+ success: "glyphicon-ok",
14
+ error: "glyphicon-exclamation-sign",
15
+ alert: "glyphicon-warning-sign",
16
+ notice: "glyphicon-info-sign"
17
+ }[flash_type.to_sym] || 'glyphicon-screenshot'
18
+ end
19
+
20
+ def title(title)
21
+ content_for(:title) { title }
22
+ end
23
+
24
+ def meta_description(meta_description)
25
+ content_for(:meta_description) { meta_description }
26
+ end
27
+
28
+ def og_title(og_title)
29
+ content_for(:og_title) { og_title }
30
+ end
31
+
32
+ def og_description(og_description)
33
+ content_for(:og_description) { og_description }
34
+ end
35
+
36
+ def og_image(og_image)
37
+ content_for(:og_image) { og_image }
38
+ end
39
+
40
+ def bootstrap_class_for(flash_type)
41
+ case flash_type
42
+ when 'success'
43
+ 'alert-success'
44
+ when 'error'
45
+ 'alert-danger'
46
+ when 'alert'
47
+ 'alert-warning'
48
+ when 'notice'
49
+ 'alert-info'
50
+ else
51
+ flash_type.to_s
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,13 @@
1
+ -# .container-fluid
2
+ -# .navbar-header
3
+ -# %button.navbar-toggle.collapsed{ type: 'button', data: { toggle: 'collapse', target: '#secondary-navigation' }, aria: {expanded: 'false', controls: 'navbar'} }
4
+ -# %span.sr-only= t('admin.toggle_navigation')
5
+ -# %span.icon-bar
6
+ -# %span.icon-bar
7
+ -# %span.icon-bar
8
+ -# - # Added support for app name setting (falling back if not existing to standard rails_admin behaviour)
9
+ -# %a.navbar-brand.pjax{href: dashboard_path}
10
+ -# = Settings.app_name rescue (_get_plugin_name[0] || 'Rails')
11
+ -# %small= _get_plugin_name[1] || 'Admin'
12
+ -# .navbar-collapse.collapse#secondary-navigation
13
+ -# = render partial: 'layouts/rails_admin/secondary_navigation'
@@ -0,0 +1,3 @@
1
+ -# %ul.sidebar-nav
2
+ - actions(:root).each do |action|
3
+ %li= link_to wording_for(:menu, action), { action: action.action_name, controller: 'rails_admin/main' }, class: action.pjax? ? "pjax" : "", style: "padding-left: 0px;text-indent:20px"
@@ -0,0 +1,4 @@
1
+ -# %ul.sidebar-nav
2
+ = main_navigation
3
+ -# %ul.sidebar-nav
4
+ = static_navigation
@@ -0,0 +1,7 @@
1
+ - if _current_user
2
+ -# %ul.sidebar-nav
3
+ %li.dropdown-header=t :current_user
4
+ - if user_link = edit_user_link
5
+ %li.edit_user_root_link= link_to content_tag('i', "", class: 'fa fa-user', style: 'text-indent: 0') + _current_user.email, show_path(:user, _current_user.id)
6
+ - if logout_path.present?
7
+ %li=link_to content_tag('i', "", class: 'fa fa-unlink', style: 'text-indent: 0') + t('admin.misc.log_out'), logout_path, method: logout_method
@@ -0,0 +1,59 @@
1
+ !!! 5
2
+ %html{lang: I18n.locale}
3
+ %head
4
+ %meta{content: "IE=edge", "http-equiv" => "X-UA-Compatible"}
5
+ %meta{content: "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
6
+ %meta{name: "viewport", content: "width=device-width, initial-scale=1"}
7
+ %meta{content: "NONE,NOARCHIVE", name: "robots"}
8
+ = csrf_meta_tag
9
+ %style{media: "screen"}
10
+ div#sidebar-wrapper div.sidebar-nav li.dropdown-header { padding-left: 0px }
11
+ div.sub-menu-container li.sub-menu a.pjax { padding-left: 0px }
12
+ div#wrapper div#sidebar-wrapper { overflow: hidden }
13
+
14
+ -# Getting all the assets needed by thecore_rails_admin from all the gems
15
+ = get_asset_tags_for("thecore_rails_admin")
16
+
17
+ = favicon_link_tag 'apple-touch-icon.png', rel: 'apple-touch-icon', sizes: "180x180"
18
+ = favicon_link_tag 'favicon-32x32.png', rel: 'icon', sizes: "32x32"
19
+ = favicon_link_tag 'favicon-16x16.png', rel: 'icon', sizes: "16x16"
20
+ = favicon_link_tag 'safari-pinned-tab.svg', rel: 'mask-icon', color: "#5bbad5"
21
+ %body.rails_admin
22
+ #admin-js{:'data-i18n-options' => I18n.t("admin.js").to_json}
23
+ -# Initialize JS simple i18n
24
+ :javascript
25
+ RailsAdmin.I18n.init('#{I18n.locale}', document.getElementById("admin-js").dataset.i18nOptions);
26
+ #loading.label.label-warning{style: 'display:none; position:fixed; right:20px; bottom:20px; z-index:100000'}= t('admin.loading')
27
+ -# %nav.navbar.navbar-default.navbar-fixed-top
28
+ -# = render "layouts/rails_admin/navigation"
29
+ #wrapper
30
+ #sidebar-wrapper
31
+ .sidebar-nav
32
+ = render "layouts/rails_admin/secondary_navigation"
33
+ = render "layouts/rails_admin/sidebar_navigation"
34
+ = render "layouts/rails_admin/user_navigation"
35
+ #page-content-wrapper
36
+ .container-fluid
37
+ .row
38
+ .col-lg-12
39
+ %button#sidebar-collapse{href: "#menu-toggle"}
40
+ %i.fa.fa-bars.fa-2x
41
+ -# %a#app-name.pjax{href: dashboard_path}
42
+ %span#app-name
43
+ = Settings.app_name rescue "Thecore"
44
+ .content{:'data-pjax-container' => true}
45
+ = render template: 'layouts/rails_admin/pjax'
46
+ = render "rails_admin/main/modal_interaction"
47
+ -# -# Initialize JS simple i18n
48
+ -# :javascript
49
+ -# RailsAdmin.I18n.init('#{I18n.locale}', JSON.parse("#{j I18n.t("admin.js").to_json}"))
50
+ -# %body.rails_admin
51
+ -# #loading.label.label-warning{style: 'display:none; position:fixed; right:20px; bottom:20px; z-index:100000'}= t('admin.loading')
52
+ -# %nav.navbar.navbar-default.navbar-fixed-top
53
+ -# = render "layouts/rails_admin/navigation"
54
+ -# .container-fluid
55
+ -# .row
56
+ -# .col-sm-3.col-md-2.sidebar-nav
57
+ -# = render "layouts/rails_admin/sidebar_navigation"
58
+ -# .col-sm-9.col-sm-offset-3.col-md-10.col-md-offset-2
59
+ -# .content{:'data-pjax-container' => true}= render template: 'layouts/rails_admin/pjax'
@@ -0,0 +1,25 @@
1
+ :javascript
2
+ $('.nav.nav-pills li.active').removeClass('active');
3
+ $('.nav.nav-pills li[data-model="#{@abstract_model.to_param}"]').addClass('active');
4
+ $(window).off('keydown');
5
+
6
+ - # Integration of the rails_admin_settings gem, if not available, it rescues to the normal naming
7
+ %title= "#{(@abstract_model.try(:pretty_name) || @page_name)} | #{Settings.app_name rescue ([_get_plugin_name[0] || 'Rails', _get_plugin_name[1] || 'Admin'].join(' '))}"
8
+ .page-header
9
+ %h1= @page_name
10
+ - flash && flash.each do |key, value|
11
+ .alert.alert-dismissible{class: flash_alert_class(key)}
12
+ %button.close{type: 'button', :'data-dismiss' => "alert"} &times;
13
+ = value
14
+ - # if it's and abstract model, then is not a root model for sure (like the dashboard)
15
+ - # these actions (root ones) are the actions listed at the same level as the dashboard (not related to a model)
16
+ - if @abstract_model
17
+ = breadcrumb
18
+ .well.well-sm
19
+ %ul.nav.nav-pills
20
+ = menu_for((@abstract_model ? (@object.try(:persisted?) ? :member : :collection) : :root), @abstract_model, @object)
21
+ = content_for :contextual_tabs
22
+ .well.well-sm
23
+ = yield
24
+ - else
25
+ = yield
@@ -0,0 +1,17 @@
1
+ %div.panel.panel-success
2
+ %div.panel-heading
3
+ %ul.inline.list-inline.pull-right
4
+ = menu_for :member, @abstract_model, object, true
5
+ %h4.panel-title
6
+ = check_box_tag "bulk_ids[]", object.id, false, id: "bulk_ids_#{object.id}"
7
+ %a{:"data-toggle" => "collapse", href: "#object-id-#{object.id}"}
8
+ = (object.resume rescue false || object.display_name rescue false || object.title rescue false || object.name rescue false || object.code rescue false)
9
+ %div{id: "object-id-#{object.id}", class: "panel-collapse collapse"}
10
+ %div.panel-body
11
+ - properties.map{ |property| property.bind(:object, object) }.each do |property|
12
+ - key = capitalize_first_letter(property.label)
13
+ - value = property.pretty_value
14
+ %p.card-text{class: "#{property.css_class} #{property.type_css_class}", title: strip_tags(value.to_s)}
15
+ %strong
16
+ = key + ":"
17
+ = value
@@ -0,0 +1,53 @@
1
+ <div id="modal-interaction" class="modal fade" tabindex="-1" role="dialog">
2
+ <div class="modal-dialog" role="document">
3
+ <div class="modal-content">
4
+ <div class="modal-header">
5
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
6
+ <span aria-hidden="true">&times;</span>
7
+ </button>
8
+ <h4 class="modal-title" id="modal-interaction-label">&nbsp;</h4>
9
+ </div>
10
+ <div class="modal-body" id="modal-interaction-body">
11
+ &nbsp;
12
+ </div>
13
+ <div class="modal-footer" id="modal-interaction-footer">
14
+ <button type="button" class="btn btn-default" data-dismiss="modal" id="modal-interaction-secondary">&nbsp;</button>
15
+ <button type="button" class="btn btn-primary" id="modal-interaction-primary">&nbsp;</button>
16
+ </div>
17
+ </div>
18
+ <!-- /.modal-content -->
19
+ </div>
20
+ <!-- /.modal-dialog -->
21
+ </div>
22
+ <!-- /.modal -->
23
+
24
+ <script>
25
+ function openModal(title, message, buttonPrimary, buttonSecondary) {
26
+ $('#modal-interaction-label').html(title);
27
+ $('#modal-interaction-body').html(message);
28
+ if (buttonPrimary != null) {
29
+ $('#modal-interaction-primary').html(buttonPrimary.lbl);
30
+ $('#modal-interaction-primary').on('click', buttonPrimary.func);
31
+ $('#modal-interaction-primary').show();
32
+ }
33
+ if (buttonSecondary != null) {
34
+ $('#modal-interaction-secondary').html(buttonSecondary.lbl);
35
+ $('#modal-interaction-secondary').on('click', buttonSecondary.func);
36
+ $('#modal-interaction-secondary').show();
37
+ }
38
+ (buttonPrimary != null || buttonSecondary != null) ? $("#modal-interaction-footer").show() : $("#modal-interaction-footer").hide();
39
+ $('#modal-interaction').modal('show');
40
+ }
41
+ function closeModal() {
42
+ $('#modal-interaction').modal('hide');
43
+ $('#modal-interaction-label').html("&nbsp;");
44
+ $('#modal-interaction-body').html("&nbsp;");
45
+ $('#modal-interaction-primary').html("&nbsp;");
46
+ $('#modal-interaction-secondary').html("&nbsp;");
47
+ $('#modal-interaction-primary').hide();
48
+ $('#modal-interaction-secondary').hide();
49
+ $("#modal-interaction-footer").hide();
50
+ $('#modal-interaction-primary').off();
51
+ $('#modal-interaction-secondary').off();
52
+ }
53
+ </script>
@@ -0,0 +1,43 @@
1
+ = breadcrumb
2
+ - charts_high = []
3
+ - charts_medium = []
4
+ - self.methods.each do |m|
5
+ - charts_high << m if m.start_with? "charts_high_"
6
+ - charts_medium << m if m.start_with? "charts_medium_"
7
+
8
+ - charts_high.in_groups_of(2, false).each_with_index do |group, i|
9
+ .row
10
+ - group.each do |item|
11
+ .col-sm-6
12
+ .box.bg.bg-clear= self.send(item)
13
+
14
+ - charts_medium.in_groups_of(3, false).each_with_index do |group, i|
15
+ .row
16
+ - group.each do |item|
17
+ .col-sm-4
18
+ .box.bg.bg-clear= self.send(item)
19
+
20
+ - @list_bg = ['info', 'success', 'danger', 'success', 'info', 'warning', 'danger', 'info', 'success']
21
+ - if @abstract_models
22
+ .row
23
+ - index = 0
24
+ - @abstract_models.each do |abstract_model|
25
+ - index_path = index_path(model_name: abstract_model.to_param)
26
+ - if authorized?(:index, abstract_model) && !index_path.include?("ckeditor")
27
+ - if index == @list_bg.length
28
+ - index = 0
29
+ - row_class = "box bg-#{ @list_bg[index].to_s } #{"link" if index_path} #{abstract_model.param_key}_links #{abstract_model.config.label_plural}"
30
+ .col-sm-4
31
+ .box{class: row_class, :"data-link" => index_path}
32
+ %i{class: "icon-bg #{abstract_model.config.navigation_icon.present? ? abstract_model.config.navigation_icon : 'file' }"}
33
+ .text-center
34
+ %p= capitalize_first_letter(abstract_model.config.label_plural)
35
+ %strong= @count[abstract_model.model.name].to_s
36
+ %p= link_to content_tag("i", "", class: "fa fa-list-ul"), index_path, class: 'btn btn-black pjax'
37
+ - index += 1
38
+
39
+ - if @auditing_adapter && authorized?(:history_index)
40
+ #block-tables.block
41
+ .content
42
+ %h2= t("admin.actions.history_index.menu")
43
+ = render partial: 'rails_admin/main/dashboard_history'