thecore_ui_rails_admin 2.1.5 → 2.1.8
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/thecore_ui_rails_admin/thecore.js +0 -0
- data/app/assets/javascripts/{rails_admin/custom/ui.js → thecore_ui_rails_admin/thecore_rails_admin.js} +0 -2
- data/app/assets/stylesheets/{animate.css → thecore_ui_rails_admin/animate.css} +0 -0
- data/app/assets/stylesheets/thecore_ui_rails_admin/common.scss +32 -0
- data/app/assets/stylesheets/{devise.scss → thecore_ui_rails_admin/devise.scss} +0 -0
- data/app/assets/stylesheets/{rails_admin → thecore_ui_rails_admin}/flashing.scss +0 -0
- data/app/assets/stylesheets/{mixins.scss → thecore_ui_rails_admin/mixins.scss} +0 -0
- data/app/assets/stylesheets/{thecore_rails_admin.scss → thecore_ui_rails_admin/thecore.scss} +4 -7
- data/app/assets/stylesheets/{rails_admin/theming.scss → thecore_ui_rails_admin/thecore_rails_admin.scss} +1 -33
- data/app/assets/stylesheets/{rails_admin → thecore_ui_rails_admin}/togglable-sidebar.scss +0 -0
- data/app/helpers/devise_bootstrap_errors_helper.rb +20 -0
- data/app/helpers/thecore_helper.rb +54 -0
- data/app/views/layouts/rails_admin/application.html.haml +5 -0
- data/app/views/shared/_flash.html.erb +10 -0
- data/config/initializers/rails_admin.rb +8 -0
- data/config/initializers/thecore_concern.rb +6 -0
- data/config/initializers/thecore_ui_rails_admin_app_configs.rb +5 -4
- data/config/locales/thecore_settings.it.yml +32 -0
- data/db/migrate/20161227101954_create_rails_admin_settings.rb +25 -0
- data/db/migrate/20161227101956_add_app_name.rb +5 -0
- data/lib/abilities/thecore_ui_rails_admin.rb +13 -0
- data/lib/concerns/rails_admin_requirements.rb +19 -0
- data/lib/concerns/thecore_ui_rails_admin_user.rb +8 -24
- data/lib/thecore_ui_rails_admin.rb +8 -1
- data/lib/thecore_ui_rails_admin/engine.rb +2 -6
- data/lib/thecore_ui_rails_admin/version.rb +1 -1
- metadata +48 -12
- data/app/assets/javascripts/rails_admin/custom/timer.js +0 -135
- data/app/assets/javascripts/rails_admin/ra.widgets.coffee +0 -233
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 75369cb3f050b4996aafce1b1651216c51db2c3248195a46a5a9e42293372b6e
|
|
4
|
+
data.tar.gz: 7f72b944c75a1a4a9a36a2633266c977d48638b34a15a6ea8915156b86adcc21
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b81368ff53b4f4362f2318a0949b5be0a673161899c5c4a85433895683f13fbee00dae9bb3cc2137dee5fc56698b7e4983ccd763128eab3d8b7a9b1d4f0c681b
|
|
7
|
+
data.tar.gz: 72557529214aef7ed4f464309c10846ff0ad57a1f594ed1ecc328a3a940a79eaf37b965e7a40eccf22e14fcfcdf76eed89ab9f5a902f1ec413cfbd7a0146f7fc
|
|
File without changes
|
|
@@ -20,8 +20,6 @@ $(document).on('ready pjax:success', function(e) {
|
|
|
20
20
|
$('.page-header, .content').removeClass('dashboard');
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
$('textarea[data-richtext="froala-wysiwyg"').froalaEditor();
|
|
24
|
-
|
|
25
23
|
// $(document).ready(function () {
|
|
26
24
|
// Hide and show the sidebar
|
|
27
25
|
// Make the sidebar button shine a bit
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
body {
|
|
2
|
+
height: 100vh;
|
|
3
|
+
// background: linear-gradient(-20deg, #09b7b9 30%, #1c51a4 100%);
|
|
4
|
+
background-color: rgb(59, 78, 89);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.jumbotron {
|
|
8
|
+
background-color: rgb(59, 78, 89);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.vertical-center {
|
|
12
|
+
min-height: 100%;
|
|
13
|
+
/* Fallback for browsers do NOT support vh unit */
|
|
14
|
+
min-height: 100vh;
|
|
15
|
+
/* These two lines are counted as one :-) */
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#up-arrow {
|
|
21
|
+
bottom: -2em;
|
|
22
|
+
margin-right: auto;
|
|
23
|
+
margin-left: auto;
|
|
24
|
+
opacity: 0.2;
|
|
25
|
+
filter: alpha(opacity=20);
|
|
26
|
+
/* For IE8 and earlier */
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.fa-pencil:before,
|
|
30
|
+
.icon-pencil:before {
|
|
31
|
+
content: "\f044";
|
|
32
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/app/assets/stylesheets/{thecore_rails_admin.scss → thecore_ui_rails_admin/thecore.scss}
RENAMED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* file per style scope.
|
|
12
12
|
*
|
|
13
13
|
*= required _colors
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
*= require_tree .
|
|
16
16
|
*= require_self
|
|
17
17
|
*/
|
|
@@ -19,14 +19,11 @@
|
|
|
19
19
|
@import "jquery-ui/dialog";
|
|
20
20
|
@import 'bootstrap-sprockets';
|
|
21
21
|
@import 'bootstrap';
|
|
22
|
-
@import
|
|
22
|
+
@import 'common';
|
|
23
23
|
@import 'devise';
|
|
24
24
|
@import 'animate';
|
|
25
25
|
@import 'mixins';
|
|
26
26
|
|
|
27
|
-
#new_user {
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
body {
|
|
31
|
-
background-color: green;
|
|
27
|
+
#new_user div.actions input.btn.btn-warning {
|
|
28
|
+
width: 100%;
|
|
32
29
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@import "togglable-sidebar";
|
|
2
2
|
@import "flashing";
|
|
3
|
+
@import 'common';
|
|
3
4
|
|
|
4
5
|
$RAprimary: #1c2c41;
|
|
5
6
|
$RAgreen: #37BC9B;
|
|
@@ -7,39 +8,6 @@ $RAblue: #3BAFDA;
|
|
|
7
8
|
$RAred: #E9573F;
|
|
8
9
|
$RAyellow: #F6BB42;
|
|
9
10
|
|
|
10
|
-
body {
|
|
11
|
-
height: 100vh;
|
|
12
|
-
// background: linear-gradient(-20deg, #09b7b9 30%, #1c51a4 100%);
|
|
13
|
-
background-color: rgb(59, 78, 89);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.jumbotron {
|
|
17
|
-
background-color: rgb(59, 78, 89);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.vertical-center {
|
|
21
|
-
min-height: 100%;
|
|
22
|
-
/* Fallback for browsers do NOT support vh unit */
|
|
23
|
-
min-height: 100vh;
|
|
24
|
-
/* These two lines are counted as one :-) */
|
|
25
|
-
display: flex;
|
|
26
|
-
align-items: center;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
#up-arrow {
|
|
30
|
-
bottom: -2em;
|
|
31
|
-
margin-right: auto;
|
|
32
|
-
margin-left: auto;
|
|
33
|
-
opacity: 0.2;
|
|
34
|
-
filter: alpha(opacity=20);
|
|
35
|
-
/* For IE8 and earlier */
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.fa-pencil:before,
|
|
39
|
-
.icon-pencil:before {
|
|
40
|
-
content: "\f044";
|
|
41
|
-
}
|
|
42
|
-
|
|
43
11
|
.page-header.dashboard {
|
|
44
12
|
border-color: $RAprimary;
|
|
45
13
|
}
|
|
File without changes
|
|
@@ -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">×</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
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
= stylesheet_link_tag "rails_admin/rails_admin.css", media: :all
|
|
15
15
|
= javascript_include_tag "rails_admin/rails_admin.js"
|
|
16
16
|
|
|
17
|
+
- Rails.application.config.assets.paths.each do |p|
|
|
18
|
+
-# Getting all the assets needed by thecore from all the gems
|
|
19
|
+
= stylesheet_link_tag("#{p.to_s.split("/").last}/thecore_rails_admin", media: 'all', 'data-turbolinks-track' => true) if File.exists?("#{p}/thecore_rails_admin.scss")
|
|
20
|
+
= javascript_include_tag("#{Dir["#{p}/**/thecore_rails_admin.js"].first.split("/")[-2]}/thecore_rails_admin", 'data-turbolinks-track' => true) if Dir["#{p}/**/thecore_rails_admin.js"].any?
|
|
21
|
+
|
|
17
22
|
= favicon_link_tag 'apple-touch-icon.png', rel: 'apple-touch-icon', sizes: "180x180"
|
|
18
23
|
= favicon_link_tag 'favicon-32x32.png', rel: 'icon', sizes: "32x32"
|
|
19
24
|
= favicon_link_tag 'favicon-16x16.png', rel: 'icon', sizes: "16x16"
|
|
@@ -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 %>
|
|
@@ -5,6 +5,14 @@ RailsAdmin.config do |config|
|
|
|
5
5
|
# [(Settings.app_name rescue (ENV["APP_NAME"] || "TheCore App")), "#{controller.params[:action].try(:titleize)} (#{Time.zone.now.to_s(:time)})"]
|
|
6
6
|
# }
|
|
7
7
|
### Popular gems integration
|
|
8
|
+
config.model "RoleUser" do
|
|
9
|
+
visible false
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
config.model "ActionText::RichText" do
|
|
13
|
+
visible false
|
|
14
|
+
end
|
|
15
|
+
|
|
8
16
|
config.model "ActiveStorage::Blob" do
|
|
9
17
|
visible false
|
|
10
18
|
end
|
|
@@ -66,16 +66,22 @@ module ThecoreConcern
|
|
|
66
66
|
|u| u.permit(
|
|
67
67
|
:username,
|
|
68
68
|
:password,
|
|
69
|
+
:email,
|
|
70
|
+
:login,
|
|
69
71
|
:password_confirmation,
|
|
70
72
|
:remember_me)
|
|
71
73
|
}
|
|
72
74
|
devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(
|
|
73
75
|
:username,
|
|
74
76
|
:password,
|
|
77
|
+
:email,
|
|
78
|
+
:login,
|
|
75
79
|
:password_confirmation)
|
|
76
80
|
}
|
|
77
81
|
devise_parameter_sanitizer.permit(:account_update) { |u| u.permit(
|
|
78
82
|
:username,
|
|
83
|
+
:email,
|
|
84
|
+
:login,
|
|
79
85
|
:password,
|
|
80
86
|
:password_confirmation,
|
|
81
87
|
:current_password)
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Rails.application.configure do
|
|
2
|
+
# Login Page and pages not in RailsAdmin
|
|
3
|
+
config.assets.precompile += %w( thecore_ui_rails_admin/thecore.css thecore_ui_rails_admin/thecore.js )
|
|
4
|
+
# Pages under Rails Admin
|
|
5
|
+
config.assets.precompile += %w( thecore_ui_rails_admin/thecore_rails_admin.css thecore_ui_rails_admin/thecore_rails_admin.js )
|
|
2
6
|
|
|
3
|
-
config.assets.precompile += %w( thecore_rails_admin.css )
|
|
4
|
-
|
|
5
|
-
puts "ASSETS PRECOMPILE: #{config.assets.precompile.inspect}"
|
|
6
|
-
|
|
7
7
|
config.after_initialize do
|
|
8
8
|
RailsAdmin::Config::Actions::Export.send(:include, ExportConcern)
|
|
9
9
|
RailsAdmin::Config::Actions::BulkDelete.send(:include, BulkDeleteConcern)
|
|
10
|
+
RailsAdminSettings::Setting.send(:include, RailsAdminSettings::RailsAdminExtensionConfig)
|
|
10
11
|
User.send(:include, ThecoreUiRailsAdminUser)
|
|
11
12
|
end
|
|
12
13
|
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
it:
|
|
2
|
+
settings:
|
|
3
|
+
namespaces:
|
|
4
|
+
main: Principale
|
|
5
|
+
names:
|
|
6
|
+
app_name: Nome dell'applicazione
|
|
7
|
+
admin:
|
|
8
|
+
settings:
|
|
9
|
+
label: 'Impostazioni'
|
|
10
|
+
no_ckeditor_detected: CKEditor non trovato — mostro il campo come semplice testo
|
|
11
|
+
phone_invalid: Telefono non valido
|
|
12
|
+
phones_invalid: "Telefono non valido: %{phones}"
|
|
13
|
+
email_invalid: Email non valida
|
|
14
|
+
yaml_invalid: YAML non valido
|
|
15
|
+
color_invalid: Colore non valido
|
|
16
|
+
mongoid: &mongoid
|
|
17
|
+
models:
|
|
18
|
+
rails_admin_settings/setting: Configurazioni
|
|
19
|
+
attributes:
|
|
20
|
+
rails_admin_settings/setting:
|
|
21
|
+
c_at: Creato
|
|
22
|
+
u_at: Modificato
|
|
23
|
+
enabled: Abilitato
|
|
24
|
+
ns: Gruppo
|
|
25
|
+
name: Nome
|
|
26
|
+
key: Chiave
|
|
27
|
+
raw: Valore
|
|
28
|
+
type: Tipo
|
|
29
|
+
kind: Tipo
|
|
30
|
+
label: Etichetta
|
|
31
|
+
activerecord:
|
|
32
|
+
<<: *mongoid
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
class CreateRailsAdminSettings < ActiveRecord::Migration[5.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :rails_admin_settings do |t|
|
|
4
|
+
t.boolean :enabled, default: true
|
|
5
|
+
t.string :kind, null: false, default: 'string'
|
|
6
|
+
t.string :ns, default: 'main'
|
|
7
|
+
t.string :key, null: false
|
|
8
|
+
if Object.const_defined?('Geocoder')
|
|
9
|
+
t.float :latitude
|
|
10
|
+
t.float :longitude
|
|
11
|
+
end
|
|
12
|
+
t.text :raw
|
|
13
|
+
t.string :label
|
|
14
|
+
if defined?(Paperclip)
|
|
15
|
+
t.attachment :file
|
|
16
|
+
elsif defined?(CarrierWave)
|
|
17
|
+
t.string :file
|
|
18
|
+
end
|
|
19
|
+
t.timestamps
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
add_index :rails_admin_settings, :key
|
|
23
|
+
add_index :rails_admin_settings, [:ns, :key], unique: true
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Abilities
|
|
2
|
+
class ThecoreUiRailsAdmin
|
|
3
|
+
include CanCan::Ability
|
|
4
|
+
def initialize user
|
|
5
|
+
puts "LAMMEEEEEEEEERDAAAAAAAAAAAAAAAAAAAAAAAA"
|
|
6
|
+
# No one is allowed to add or destroy settings
|
|
7
|
+
# just list or edit existing
|
|
8
|
+
cannot :create, RailsAdminSettings::Setting
|
|
9
|
+
cannot :destroy, RailsAdminSettings::Setting
|
|
10
|
+
cannot :show, RailsAdminSettings::Setting
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module RailsAdminSettings
|
|
2
|
+
module RailsAdminExtensionConfig
|
|
3
|
+
def self.included(base)
|
|
4
|
+
# IMPORTANT: To extend rails admin section in model, directly, instead of using concerns, I can
|
|
5
|
+
# extend the included method. Be sure to use a different module name, otherwis it will be overwritten
|
|
6
|
+
# See thecore_settings_rails_admin_model_extensions.rb initializer for a reference
|
|
7
|
+
# on how to extend rails_admin section of a model previously defined (say it's defined in another gem)
|
|
8
|
+
if base.respond_to?(:rails_admin)
|
|
9
|
+
base.rails_admin do
|
|
10
|
+
navigation_icon 'fa fa-cogs'
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def display_name
|
|
15
|
+
"#{I18n.t "settings.namespaces.#{ns}", default: ns.titleize}: #{I18n.t "settings.names.#{name}", default: name.titleize}"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -2,8 +2,9 @@ require 'active_support/concern'
|
|
|
2
2
|
|
|
3
3
|
module ThecoreUiRailsAdminUser
|
|
4
4
|
extend ActiveSupport::Concern
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
included do
|
|
7
|
+
|
|
7
8
|
RailsAdmin.config do |config|
|
|
8
9
|
config.model self.name.underscore.capitalize.constantize do
|
|
9
10
|
# rails_admin do
|
|
@@ -24,29 +25,12 @@ module ThecoreUiRailsAdminUser
|
|
|
24
25
|
bindings[:view].current_user.admin? && bindings[:view].current_user.id != bindings[:object].id
|
|
25
26
|
end
|
|
26
27
|
end
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
# visible !ROLES.blank?
|
|
34
|
-
# pretty_value do # used in list view columns and show views, defaults to formatted_value for non-association fields
|
|
35
|
-
# begin
|
|
36
|
-
# value.map { |v| bindings[:object].roles_enum.rassoc(v)[0] rescue nil }.compact.join ", "
|
|
37
|
-
# rescue
|
|
38
|
-
# I18n.t "roles.#{ROLES[value.to_i - 1]}"
|
|
39
|
-
# end
|
|
40
|
-
# end
|
|
41
|
-
# export_value do
|
|
42
|
-
# begin
|
|
43
|
-
# value.map { |v| bindings[:object].roles_enum.rassoc(v)[0] rescue nil }.compact.join ", " # used in exports, where no html/data is allowed
|
|
44
|
-
# rescue
|
|
45
|
-
# I18n.t "roles.#{ROLES[value.to_i - 1]}"
|
|
46
|
-
# end
|
|
47
|
-
# end
|
|
48
|
-
# queryable false
|
|
49
|
-
# end
|
|
28
|
+
field :locked do
|
|
29
|
+
visible do
|
|
30
|
+
bindings[:view].current_user.admin? && bindings[:view].current_user.id != bindings[:object].id
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
field :roles
|
|
50
34
|
# include UserRailsAdminConcern
|
|
51
35
|
|
|
52
36
|
# Fields only in lists and forms
|
|
@@ -4,7 +4,12 @@ ENV['RAILS_ADMIN_THEME'] ||= 'rollincode'
|
|
|
4
4
|
require 'rails_admin_rollincode'
|
|
5
5
|
require 'rails_admin'
|
|
6
6
|
require 'rails_admin-i18n'
|
|
7
|
+
require 'safe_yaml'
|
|
7
8
|
require 'rails_admin_toggleable'
|
|
9
|
+
require 'rails_admin_settings'
|
|
10
|
+
require 'concerns/rails_admin_requirements'
|
|
11
|
+
# Abilities
|
|
12
|
+
require 'abilities/thecore_ui_rails_admin'
|
|
8
13
|
# Rails Admin Buildups
|
|
9
14
|
require 'jquery-ui-rails'
|
|
10
15
|
require 'bootstrap-sass'
|
|
@@ -16,5 +21,7 @@ require 'concerns/thecore_rails_admin_bulk_delete_concern'
|
|
|
16
21
|
require "thecore_ui_rails_admin/engine"
|
|
17
22
|
|
|
18
23
|
module ThecoreUiRailsAdmin
|
|
19
|
-
#
|
|
24
|
+
# Rails Admin Settings
|
|
25
|
+
SafeYAML::OPTIONS[:default_mode] = :safe
|
|
26
|
+
SafeYAML::OPTIONS[:deserialize_symbols] = false
|
|
20
27
|
end
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
module ThecoreUiRailsAdmin
|
|
2
2
|
class Engine < ::Rails::Engine
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
# just a dependency of another engine
|
|
6
|
-
initializer 'thecore_ui_rails_admin.load_static_assets' do |app|
|
|
7
|
-
# puts "Loading static assets for #{root}"
|
|
8
|
-
app.middleware.use ::ActionDispatch::Static, "#{root}/app"
|
|
3
|
+
initializer :assets do |config|
|
|
4
|
+
Rails.application.config.assets.paths << root.join("app", "assets", "stylesheets", "thecore_ui_rails_admin")
|
|
9
5
|
end
|
|
10
6
|
initializer 'thecore_ui_rails_admin.add_to_migrations' do |app|
|
|
11
7
|
unless app.root.to_s.match root.to_s
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: thecore_ui_rails_admin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1.
|
|
4
|
+
version: 2.1.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gabriele Tassoni
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-05-
|
|
11
|
+
date: 2020-05-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thecore_ui_commons
|
|
@@ -122,6 +122,34 @@ dependencies:
|
|
|
122
122
|
- - "~>"
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
124
|
version: '0.7'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: safe_yaml
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '1.0'
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '1.0'
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: rails_admin_settings
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - "~>"
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '1.5'
|
|
146
|
+
type: :runtime
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - "~>"
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '1.5'
|
|
125
153
|
- !ruby/object:Gem::Dependency
|
|
126
154
|
name: jquery-ui-rails
|
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -148,17 +176,19 @@ files:
|
|
|
148
176
|
- README.md
|
|
149
177
|
- Rakefile
|
|
150
178
|
- app/assets/config/thecore_ui_rails_admin_manifest.js
|
|
151
|
-
- app/assets/javascripts/
|
|
152
|
-
- app/assets/javascripts/
|
|
153
|
-
- app/assets/
|
|
154
|
-
- app/assets/stylesheets/
|
|
155
|
-
- app/assets/stylesheets/devise.scss
|
|
156
|
-
- app/assets/stylesheets/
|
|
157
|
-
- app/assets/stylesheets/
|
|
158
|
-
- app/assets/stylesheets/
|
|
159
|
-
- app/assets/stylesheets/
|
|
160
|
-
- app/assets/stylesheets/
|
|
179
|
+
- app/assets/javascripts/thecore_ui_rails_admin/thecore.js
|
|
180
|
+
- app/assets/javascripts/thecore_ui_rails_admin/thecore_rails_admin.js
|
|
181
|
+
- app/assets/stylesheets/thecore_ui_rails_admin/animate.css
|
|
182
|
+
- app/assets/stylesheets/thecore_ui_rails_admin/common.scss
|
|
183
|
+
- app/assets/stylesheets/thecore_ui_rails_admin/devise.scss
|
|
184
|
+
- app/assets/stylesheets/thecore_ui_rails_admin/flashing.scss
|
|
185
|
+
- app/assets/stylesheets/thecore_ui_rails_admin/mixins.scss
|
|
186
|
+
- app/assets/stylesheets/thecore_ui_rails_admin/thecore.scss
|
|
187
|
+
- app/assets/stylesheets/thecore_ui_rails_admin/thecore_rails_admin.scss
|
|
188
|
+
- app/assets/stylesheets/thecore_ui_rails_admin/togglable-sidebar.scss
|
|
161
189
|
- app/controllers/pages_controller.rb
|
|
190
|
+
- app/helpers/devise_bootstrap_errors_helper.rb
|
|
191
|
+
- app/helpers/thecore_helper.rb
|
|
162
192
|
- app/views/layouts/rails_admin/_navigation.html.haml
|
|
163
193
|
- app/views/layouts/rails_admin/_secondary_navigation.html.haml
|
|
164
194
|
- app/views/layouts/rails_admin/_sidebar_navigation.html.haml
|
|
@@ -169,6 +199,7 @@ files:
|
|
|
169
199
|
- app/views/rails_admin/main/_modal_interaction.html.erb
|
|
170
200
|
- app/views/rails_admin/main/dashboard.html.haml
|
|
171
201
|
- app/views/rails_admin/main/index.html.haml
|
|
202
|
+
- app/views/shared/_flash.html.erb
|
|
172
203
|
- config/initializers/rails_admin.rb
|
|
173
204
|
- config/initializers/thecore_concern.rb
|
|
174
205
|
- config/initializers/thecore_ui_rails_admin_app_configs.rb
|
|
@@ -180,7 +211,12 @@ files:
|
|
|
180
211
|
- config/locales/it.main.yml
|
|
181
212
|
- config/locales/it.rails_admin.yml
|
|
182
213
|
- config/locales/it.rollincode.yml
|
|
214
|
+
- config/locales/thecore_settings.it.yml
|
|
183
215
|
- config/routes.rb
|
|
216
|
+
- db/migrate/20161227101954_create_rails_admin_settings.rb
|
|
217
|
+
- db/migrate/20161227101956_add_app_name.rb
|
|
218
|
+
- lib/abilities/thecore_ui_rails_admin.rb
|
|
219
|
+
- lib/concerns/rails_admin_requirements.rb
|
|
184
220
|
- lib/concerns/thecore_rails_admin_bulk_delete_concern.rb
|
|
185
221
|
- lib/concerns/thecore_rails_admin_export_concern.rb
|
|
186
222
|
- lib/concerns/thecore_ui_rails_admin_user.rb
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
(function (root, factory) {
|
|
2
|
-
'use strict'
|
|
3
|
-
if (typeof define === 'function' && define.amd) define([], factory)
|
|
4
|
-
else if (typeof exports === 'object') module.exports = factory()
|
|
5
|
-
else root.Timer = factory()
|
|
6
|
-
}(this, function () {
|
|
7
|
-
'use strict'
|
|
8
|
-
|
|
9
|
-
var defaultOptions = {
|
|
10
|
-
tick : 1,
|
|
11
|
-
onstart : null,
|
|
12
|
-
ontick : null,
|
|
13
|
-
onpause : null,
|
|
14
|
-
onstop : null,
|
|
15
|
-
onend : null
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
var Timer = function (options) {
|
|
19
|
-
if (!(this instanceof Timer)) return new Timer(options)
|
|
20
|
-
this._ = {
|
|
21
|
-
id : +new Date,
|
|
22
|
-
options : {},
|
|
23
|
-
duration : 0,
|
|
24
|
-
status : 'initialized',
|
|
25
|
-
start : 0,
|
|
26
|
-
measures : []
|
|
27
|
-
}
|
|
28
|
-
for (var prop in defaultOptions) this._.options[prop] = defaultOptions[prop]
|
|
29
|
-
this.options(options)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
Timer.prototype.start = function (duration) {
|
|
33
|
-
if (!+duration && !this._.duration) return this
|
|
34
|
-
duration && (duration *= 1000)
|
|
35
|
-
if (this._.timeout && this._.status === 'started') return this
|
|
36
|
-
this._.duration = duration || this._.duration
|
|
37
|
-
this._.timeout = setTimeout(end.bind(this), this._.duration)
|
|
38
|
-
if (typeof this._.options.ontick === 'function')
|
|
39
|
-
this._.interval = setInterval(function () {
|
|
40
|
-
trigger.call(this, 'ontick', this.getDuration())
|
|
41
|
-
}.bind(this), +this._.options.tick * 1000)
|
|
42
|
-
this._.start = +new Date
|
|
43
|
-
this._.status = 'started'
|
|
44
|
-
trigger.call(this, 'onstart', this.getDuration())
|
|
45
|
-
return this
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
Timer.prototype.pause = function () {
|
|
49
|
-
if (this._.status !== 'started') return this
|
|
50
|
-
this._.duration -= (+new Date - this._.start)
|
|
51
|
-
clear.call(this, false)
|
|
52
|
-
this._.status = 'paused'
|
|
53
|
-
trigger.call(this, 'onpause')
|
|
54
|
-
return this
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
Timer.prototype.stop = function () {
|
|
58
|
-
if (!/started|paused/.test(this._.status)) return this
|
|
59
|
-
clear.call(this, true)
|
|
60
|
-
this._.status = 'stopped'
|
|
61
|
-
trigger.call(this, 'onstop')
|
|
62
|
-
return this
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
Timer.prototype.getDuration = function () {
|
|
66
|
-
if (this._.status === 'started')
|
|
67
|
-
return this._.duration - (+new Date - this._.start)
|
|
68
|
-
if (this._.status === 'paused') return this._.duration
|
|
69
|
-
return 0
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
Timer.prototype.getStatus = function () {
|
|
73
|
-
return this._.status
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
Timer.prototype.options = function (option, value) {
|
|
77
|
-
if (option && value) this._.options[option] = value
|
|
78
|
-
if (!value && typeof option === 'object')
|
|
79
|
-
for (var prop in option)
|
|
80
|
-
if (this._.options.hasOwnProperty(prop))
|
|
81
|
-
this._.options[prop] = option[prop]
|
|
82
|
-
return this
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
Timer.prototype.on = function (option, value) {
|
|
86
|
-
if (typeof option !== 'string' || typeof value !== 'function') return this
|
|
87
|
-
if (!(/^on/).test(option))
|
|
88
|
-
option = 'on' + option
|
|
89
|
-
if (this._.options.hasOwnProperty(option))
|
|
90
|
-
this._.options[option] = value
|
|
91
|
-
return this
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
Timer.prototype.off = function (option) {
|
|
95
|
-
if (typeof option !== 'string') return this
|
|
96
|
-
option = option.toLowerCase()
|
|
97
|
-
if (option === 'all') {
|
|
98
|
-
this._.options = defaultOptions
|
|
99
|
-
return this
|
|
100
|
-
}
|
|
101
|
-
if (!(/^on/).test(option)) option = 'on' + option
|
|
102
|
-
if (this._.options.hasOwnProperty(option))
|
|
103
|
-
this._.options[option] = defaultOptions[option]
|
|
104
|
-
return this
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
Timer.prototype.measureStart = function (label) {
|
|
108
|
-
this._.measures[label || ''] = +new Date
|
|
109
|
-
return this
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
Timer.prototype.measureStop = function (label) {
|
|
113
|
-
return +new Date - this._.measures[label || '']
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function end () {
|
|
117
|
-
clear.call(this)
|
|
118
|
-
this._.status = 'stopped'
|
|
119
|
-
trigger.call(this, 'onend')
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function trigger (event) {
|
|
123
|
-
var callback = this._.options[event],
|
|
124
|
-
args = [].slice.call(arguments, 1)
|
|
125
|
-
typeof callback === 'function' && callback.apply(this, args)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function clear (clearDuration) {
|
|
129
|
-
clearTimeout(this._.timeout)
|
|
130
|
-
clearInterval(this._.interval)
|
|
131
|
-
if (clearDuration === true) this._.duration = 0
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return Timer
|
|
135
|
-
}))
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
$(document).on 'rails_admin.dom_ready', (e, content) ->
|
|
2
|
-
content = if content then content else $('form')
|
|
3
|
-
|
|
4
|
-
if content.length # don't waste time otherwise
|
|
5
|
-
|
|
6
|
-
# colorpicker
|
|
7
|
-
|
|
8
|
-
content.find('[data-color]').each ->
|
|
9
|
-
that = this
|
|
10
|
-
$(this).ColorPicker
|
|
11
|
-
color: $(that).val()
|
|
12
|
-
onShow: (el) ->
|
|
13
|
-
$(el).fadeIn(500)
|
|
14
|
-
false
|
|
15
|
-
onHide: (el) ->
|
|
16
|
-
$(el).fadeOut(500)
|
|
17
|
-
false
|
|
18
|
-
onChange: (hsb, hex, rgb) ->
|
|
19
|
-
$(that).val(hex)
|
|
20
|
-
$(that).css('backgroundColor', '#' + hex)
|
|
21
|
-
|
|
22
|
-
# datetime picker
|
|
23
|
-
$.fn.datetimepicker.defaults.icons =
|
|
24
|
-
time: 'fa fa-clock'
|
|
25
|
-
date: 'fa fa-calendar'
|
|
26
|
-
up: 'fa fa-chevron-up'
|
|
27
|
-
down: 'fa fa-chevron-down'
|
|
28
|
-
previous: 'fa fa-angle-double-left'
|
|
29
|
-
next: 'fa fa-angle-double-right'
|
|
30
|
-
today: 'fa fa-dot-circle'
|
|
31
|
-
clear: 'fa fa-trash'
|
|
32
|
-
close: 'fa fa-times'
|
|
33
|
-
|
|
34
|
-
content.find('[data-datetimepicker]').each ->
|
|
35
|
-
options = $(this).data('options')
|
|
36
|
-
$.extend(options, {locale: RailsAdmin.I18n.locale})
|
|
37
|
-
$(this).datetimepicker options
|
|
38
|
-
|
|
39
|
-
# enumeration
|
|
40
|
-
|
|
41
|
-
content.find('[data-enumeration]').each ->
|
|
42
|
-
if $(this).is('[multiple]')
|
|
43
|
-
$(this).filteringMultiselect $(this).data('options')
|
|
44
|
-
else
|
|
45
|
-
$(this).filteringSelect $(this).data('options')
|
|
46
|
-
|
|
47
|
-
# fileupload
|
|
48
|
-
|
|
49
|
-
content.find('[data-fileupload]').each ->
|
|
50
|
-
input = this
|
|
51
|
-
$(this).on 'click', ".delete input[type='checkbox']", ->
|
|
52
|
-
$(input).children('.toggle').toggle('slow')
|
|
53
|
-
|
|
54
|
-
# fileupload-preview
|
|
55
|
-
|
|
56
|
-
content.find('[data-fileupload]').change ->
|
|
57
|
-
input = this
|
|
58
|
-
image_container = $("#" + input.id).parent().children(".preview")
|
|
59
|
-
unless image_container.length
|
|
60
|
-
image_container = $("#" + input.id).parent().prepend($('<img />').addClass('preview').addClass('img-thumbnail')).find('img.preview')
|
|
61
|
-
image_container.parent().find('img:not(.preview)').hide()
|
|
62
|
-
ext = $("#" + input.id).val().split('.').pop().toLowerCase()
|
|
63
|
-
if input.files and input.files[0] and $.inArray(ext, ['gif', 'png', 'jpg', 'jpeg', 'bmp']) != -1
|
|
64
|
-
reader = new FileReader()
|
|
65
|
-
reader.onload = (e) ->
|
|
66
|
-
image_container.attr "src", e.target.result
|
|
67
|
-
reader.readAsDataURL input.files[0]
|
|
68
|
-
image_container.show()
|
|
69
|
-
else
|
|
70
|
-
image_container.hide()
|
|
71
|
-
|
|
72
|
-
# filtering-multiselect
|
|
73
|
-
|
|
74
|
-
content.find('[data-filteringmultiselect]').each ->
|
|
75
|
-
$(this).filteringMultiselect $(this).data('options')
|
|
76
|
-
if $(this).parents("#modal").length # hide link if we already are inside a dialog (endless issues on nested dialogs with JS)
|
|
77
|
-
$(this).siblings('.btn').remove()
|
|
78
|
-
else
|
|
79
|
-
$(this).parents('.control-group').first().remoteForm()
|
|
80
|
-
|
|
81
|
-
# filtering-select
|
|
82
|
-
|
|
83
|
-
content.find('[data-filteringselect]').each ->
|
|
84
|
-
$(this).filteringSelect $(this).data('options')
|
|
85
|
-
if $(this).parents("#modal").length # hide link if we already are inside a dialog (endless issues on nested dialogs with JS)
|
|
86
|
-
$(this).siblings('.btn').remove()
|
|
87
|
-
else
|
|
88
|
-
$(this).parents('.control-group').first().remoteForm()
|
|
89
|
-
|
|
90
|
-
# nested-many
|
|
91
|
-
|
|
92
|
-
content.find('[data-nestedmany]').each ->
|
|
93
|
-
field = $(this).parents('.control-group').first()
|
|
94
|
-
nav = field.find('> .controls > .nav')
|
|
95
|
-
tab_content = field.find('> .tab-content')
|
|
96
|
-
toggler = field.find('> .controls > .btn-group > .toggler')
|
|
97
|
-
# add each nested field to a tab-pane and reference it in the nav
|
|
98
|
-
tab_content.children('.fields:not(.tab-pane)').addClass('tab-pane').each ->
|
|
99
|
-
$(this).attr('id', 'unique-id-' + (new Date().getTime()) + Math.floor(Math.random() * 100000)) # some elements are created on the same ms
|
|
100
|
-
nav.append('<li><a data-toggle="tab" href="#' + this.id + '">' + $(this).children('.object-infos').data('object-label') + '</a></li>')
|
|
101
|
-
# only if no tab is set to active
|
|
102
|
-
if nav.find("> li.active").length == 0
|
|
103
|
-
# init first tab, toggler and tab_content/tabs visibility
|
|
104
|
-
nav.find("> li > a[data-toggle='tab']:first").tab('show')
|
|
105
|
-
if nav.children().length == 0
|
|
106
|
-
nav.hide()
|
|
107
|
-
tab_content.hide()
|
|
108
|
-
toggler.addClass('disabled').removeClass('active').children('i').addClass('icon-chevron-right')
|
|
109
|
-
else
|
|
110
|
-
if toggler.hasClass('active')
|
|
111
|
-
nav.show()
|
|
112
|
-
tab_content.show()
|
|
113
|
-
toggler.children('i').addClass('icon-chevron-down')
|
|
114
|
-
else
|
|
115
|
-
nav.hide()
|
|
116
|
-
tab_content.hide()
|
|
117
|
-
toggler.children('i').addClass('icon-chevron-right')
|
|
118
|
-
|
|
119
|
-
# nested-one
|
|
120
|
-
|
|
121
|
-
content.find('[data-nestedone]').each ->
|
|
122
|
-
field = $(this).parents('.control-group').first()
|
|
123
|
-
nav = field.find("> .controls > .nav")
|
|
124
|
-
tab_content = field.find("> .tab-content")
|
|
125
|
-
toggler = field.find('> .controls > .btn-group > .toggler')
|
|
126
|
-
tab_content.children(".fields:not(.tab-pane)").addClass('tab-pane active').each ->
|
|
127
|
-
# Convert the "add nested field" button to just showing the title of the new model
|
|
128
|
-
field.find('> .controls .add_nested_fields').removeClass('add_nested_fields').html($(this).children('.object-infos').data('object-label'))
|
|
129
|
-
nav.append('<li><a data-toggle="tab" href="#' + this.id + '">' + $(this).children('.object-infos').data('object-label') + '</a></li>')
|
|
130
|
-
first_tab = nav.find("> li > a[data-toggle='tab']:first")
|
|
131
|
-
first_tab.tab('show')
|
|
132
|
-
field.find("> .controls > [data-target]:first").html('<i class="icon-white"></i> ' + first_tab.html())
|
|
133
|
-
nav.hide()
|
|
134
|
-
if nav.children().length == 0
|
|
135
|
-
nav.hide()
|
|
136
|
-
tab_content.hide()
|
|
137
|
-
toggler.addClass('disabled').removeClass('active').children('i').addClass('icon-chevron-right')
|
|
138
|
-
else
|
|
139
|
-
if toggler.hasClass('active')
|
|
140
|
-
toggler.children('i').addClass('icon-chevron-down')
|
|
141
|
-
tab_content.show()
|
|
142
|
-
else
|
|
143
|
-
toggler.children('i').addClass('icon-chevron-right')
|
|
144
|
-
tab_content.hide()
|
|
145
|
-
|
|
146
|
-
# polymorphic-association
|
|
147
|
-
|
|
148
|
-
content.find('[data-polymorphic]').each ->
|
|
149
|
-
type_select = $(this)
|
|
150
|
-
field = type_select.parents('.control-group').first()
|
|
151
|
-
object_select = field.find('select').last()
|
|
152
|
-
urls = type_select.data('urls')
|
|
153
|
-
type_select.on 'change', (e) ->
|
|
154
|
-
if $(this).val() is ''
|
|
155
|
-
object_select.html('<option value=""></option>')
|
|
156
|
-
else
|
|
157
|
-
$.ajax
|
|
158
|
-
url: urls[type_select.val()]
|
|
159
|
-
data:
|
|
160
|
-
compact: true
|
|
161
|
-
all: true
|
|
162
|
-
beforeSend: (xhr) ->
|
|
163
|
-
xhr.setRequestHeader("Accept", "application/json")
|
|
164
|
-
success: (data, status, xhr) ->
|
|
165
|
-
html = $('<option></option>')
|
|
166
|
-
$(data).each (i, el) ->
|
|
167
|
-
option = $('<option></option>')
|
|
168
|
-
option.attr('value', el.id)
|
|
169
|
-
option.text(el.label)
|
|
170
|
-
html = html.add(option)
|
|
171
|
-
object_select.html(html)
|
|
172
|
-
|
|
173
|
-
# ckeditor
|
|
174
|
-
|
|
175
|
-
goCkeditors = ->
|
|
176
|
-
content.find('[data-richtext=ckeditor]').not('.ckeditored').each (index, domEle) ->
|
|
177
|
-
try
|
|
178
|
-
if instance = window.CKEDITOR.instances[this.id]
|
|
179
|
-
instance.destroy(true)
|
|
180
|
-
window.CKEDITOR.replace(this, $(this).data('options'))
|
|
181
|
-
$(this).addClass('ckeditored')
|
|
182
|
-
|
|
183
|
-
$editors = content.find('[data-richtext=ckeditor]').not('.ckeditored')
|
|
184
|
-
if $editors.length
|
|
185
|
-
if not window.CKEDITOR
|
|
186
|
-
options = $editors.first().data('options')
|
|
187
|
-
window.CKEDITOR_BASEPATH = options['base_location']
|
|
188
|
-
$.getScript options['jspath'], (script, textStatus, jqXHR) =>
|
|
189
|
-
goCkeditors()
|
|
190
|
-
else
|
|
191
|
-
goCkeditors()
|
|
192
|
-
|
|
193
|
-
#codemirror
|
|
194
|
-
|
|
195
|
-
goCodeMirrors = (array) =>
|
|
196
|
-
array.each (index, domEle) ->
|
|
197
|
-
options = $(this).data('options')
|
|
198
|
-
textarea = this
|
|
199
|
-
$.getScript options['locations']['mode'], (script, textStatus, jqXHR) ->
|
|
200
|
-
$('head').append('<link href="' + options['locations']['theme'] + '" rel="stylesheet" media="all" type="text\/css">')
|
|
201
|
-
CodeMirror.fromTextArea(textarea, options['options'])
|
|
202
|
-
$(textarea).addClass('codemirrored')
|
|
203
|
-
|
|
204
|
-
array = content.find('[data-richtext=codemirror]').not('.codemirrored')
|
|
205
|
-
if array.length
|
|
206
|
-
@array = array
|
|
207
|
-
if not window.CodeMirror
|
|
208
|
-
options = $(array[0]).data('options')
|
|
209
|
-
$('head').append('<link href="' + options['csspath'] + '" rel="stylesheet" media="all" type="text\/css">')
|
|
210
|
-
$.getScript options['jspath'], (script, textStatus, jqXHR) =>
|
|
211
|
-
goCodeMirrors(@array)
|
|
212
|
-
else
|
|
213
|
-
goCodeMirrors(@array)
|
|
214
|
-
|
|
215
|
-
# bootstrap_wysihtml5
|
|
216
|
-
|
|
217
|
-
goBootstrapWysihtml5s = (array, config_options) =>
|
|
218
|
-
array.each ->
|
|
219
|
-
$(@).addClass('bootstrap-wysihtml5ed')
|
|
220
|
-
$(@).closest('.controls').addClass('well')
|
|
221
|
-
$(@).wysihtml5(config_options)
|
|
222
|
-
|
|
223
|
-
array = content.find('[data-richtext=bootstrap-wysihtml5]').not('.bootstrap-wysihtml5ed')
|
|
224
|
-
if array.length
|
|
225
|
-
@array = array
|
|
226
|
-
options = $(array[0]).data('options')
|
|
227
|
-
config_options = $.parseJSON(options['config_options'])
|
|
228
|
-
if not window.wysihtml5
|
|
229
|
-
$('head').append('<link href="' + options['csspath'] + '" rel="stylesheet" media="all" type="text\/css">')
|
|
230
|
-
$.getScript options['jspath'], (script, textStatus, jqXHR) =>
|
|
231
|
-
goBootstrapWysihtml5s(@array, config_options)
|
|
232
|
-
else
|
|
233
|
-
goBootstrapWysihtml5s(@array, config_options)
|