alchemy-custom-model 2.1.2 → 3.1.0
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 +5 -5
- data/app/assets/javascripts/alchemy-custom-model/alchemy_custom_model_select.js +62 -0
- data/app/assets/javascripts/alchemy-custom-model/common_init.js +17 -14
- data/app/assets/javascripts/alchemy-custom-model/el_finder.js.coffee.erb +31 -0
- data/app/assets/javascripts/alchemy-custom-model/manifest.js +5 -0
- data/app/assets/javascripts/backend/date_picker.js +24 -0
- data/app/assets/javascripts/backend/fix_more_image_in_element.js.coffee +10 -0
- data/app/assets/javascripts/backend/override_alchemy_selectbox.js +8 -0
- data/app/assets/stylesheets/alchemy-custom-model/custom_elfinder.css.scss +20 -2
- data/app/assets/stylesheets/alchemy-custom-model/custom_style.css.scss +95 -0
- data/app/controllers/alchemy/custom/model/admin/base_controller.rb +16 -14
- data/app/controllers/alchemy/custom/model/admin/base_with_globalize_controller.rb +38 -0
- data/app/controllers/concerns/alchemy/admin/nodes_controller_dec.rb +55 -0
- data/app/helpers/alchemy/custom/model/admin/base_helper.rb +51 -3
- data/app/helpers/alchemy/custom/model/custom_model_helper.rb +26 -13
- data/app/helpers/alchemy/pages_helper_decorator.rb +38 -0
- data/app/models/concerns/alchemy/node_dec.rb +45 -0
- data/app/views/alchemy/admin/nodes/_form.html.erb +126 -0
- data/app/views/alchemy/admin/nodes/custom_models.json.jbuilder +10 -0
- data/app/views/alchemy/admin/nodes/custom_models_methods.json.jbuilder +10 -0
- data/app/views/alchemy/admin/pictures/_custom_model_info.html.erb +27 -0
- data/app/views/alchemy/admin/pictures/_infos.html.erb +65 -0
- data/app/views/alchemy/custom/model/admin/base/_gallery_item.html.erb +7 -2
- data/app/views/alchemy/custom/model/admin/base/_search_panel.html.erb +16 -0
- data/app/views/alchemy/custom/model/admin/base/_seo.html.erb +5 -5
- data/app/views/alchemy/custom/model/admin/base/_show_object.html.erb +30 -0
- data/app/views/alchemy/custom/model/admin/base/_show_objects.html.erb +48 -0
- data/app/views/alchemy/custom/model/admin/base/_title.html.erb +1 -1
- data/app/views/alchemy/custom/model/admin/base/edit.html.erb +2 -2
- data/app/views/alchemy/custom/model/admin/base/index.html.erb +6 -5
- data/app/views/alchemy/custom/model/admin/base/new.html.erb +2 -2
- data/app/views/alchemy/custom/model/admin/base/show.html.erb +5 -48
- data/app/views/alchemy/pages/sitemap.xml.erb +16 -0
- data/config/locales/it.yml +6 -0
- data/config/routes.rb +16 -0
- data/db/migrate/20200424184007_add_fields_to_node.rb +8 -0
- data/lib/alchemy/custom/model.rb +58 -0
- data/lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb +9 -0
- data/lib/alchemy/custom/model/engine.rb +7 -1
- data/lib/alchemy/custom/model/globalize_model_decoration.rb +26 -0
- data/lib/alchemy/custom/model/menu_methods.rb +16 -0
- data/lib/alchemy/custom/model/model_decoration.rb +3 -0
- data/lib/alchemy/custom/model/model_utils_methods.rb +28 -0
- data/lib/alchemy/custom/model/pages_controller_dec.rb +38 -25
- data/lib/alchemy/custom/model/picture_used_by.rb +51 -0
- data/lib/alchemy/custom/model/sitemap_methods.rb +18 -0
- data/lib/alchemy/custom/model/slug_optimizer.rb +23 -0
- data/lib/alchemy/custom/model/version.rb +1 -1
- data/lib/tasks/alchemy_custom_model_tasks.rake +3 -0
- data/vendor/assets/javascripts/flatpickr/i10n/it.js +71 -0
- metadata +66 -9
- data/lib/alchemy-custom-model.rb +0 -31
@@ -1,4 +1,9 @@
|
|
1
|
-
<div class="gallery_item_blk">
|
2
|
-
<%= image_tag(picture.image_file.thumb("
|
1
|
+
<div class="gallery_item_blk" data-id="<%= jr_id %>">
|
2
|
+
<%= image_tag(picture.image_file.thumb("140x140#").url) %>
|
3
3
|
<%= yield if block_given? %>
|
4
|
+
<div class="command_area">
|
5
|
+
<div class="destroy">
|
6
|
+
<i class="fas fa-times fa-lg fa-fw"></i>
|
7
|
+
</div>
|
8
|
+
</div>
|
4
9
|
</div>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%= search_panel do |form| %>
|
2
|
+
|
3
|
+
<span>Ovverride with personalized ransack fields</span>
|
4
|
+
<div class="row">
|
5
|
+
form.input :field1_i_cont <br/>
|
6
|
+
form.input :field2_i_cont <br/>
|
7
|
+
form.input :field3_i_cont <br/>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="row">
|
11
|
+
form.input :field4_i_cont <br/>
|
12
|
+
form.input :field5_i_cont <br/>
|
13
|
+
form.input :field6_i_cont <br/>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<% end %>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<fieldset>
|
2
2
|
<legend><%= t(:seo_fields)%></legend>
|
3
|
-
<%= f.input :meta_title %>
|
4
|
-
<%= f.input :meta_description %>
|
5
|
-
<%= f.input :meta_keywords %>
|
6
|
-
<%= f.input :robot_follow %>
|
7
|
-
<%= f.input :robot_index %>
|
3
|
+
<%= f.input :meta_title, as: :string %>
|
4
|
+
<%= f.input :meta_description, as: :text%>
|
5
|
+
<%= f.input :meta_keywords, as: :text %>
|
6
|
+
<%= f.input :robot_follow, as: :boolean %>
|
7
|
+
<%= f.input :robot_index, as: :boolean %>
|
8
8
|
</fieldset>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<%=toolbar(
|
2
|
+
buttons: [
|
3
|
+
{
|
4
|
+
icon: "angle-double-left ",
|
5
|
+
label: acm_t(:title_action, action: acm_t(:index, scope: :actions), model: base_class.model_name.human),
|
6
|
+
url: polymorphic_path(url_namespace),
|
7
|
+
title: acm_t(:title_action, action: acm_t(:index, scope: :actions), model: base_class.model_name.human),
|
8
|
+
hotkey: 'alt+b',
|
9
|
+
dialog: false,
|
10
|
+
if_permitted_to: [:index, @obj.class]
|
11
|
+
}
|
12
|
+
|
13
|
+
],
|
14
|
+
search: false
|
15
|
+
) %>
|
16
|
+
|
17
|
+
|
18
|
+
<div class="show_page">
|
19
|
+
<% @obj.attributes.each do |attribute| %>
|
20
|
+
<div class="attribute_row">
|
21
|
+
<div class="labelfield">
|
22
|
+
<%= @obj.class.human_attribute_name(attribute.first.to_sym) %>
|
23
|
+
</div>
|
24
|
+
<div class="valuefield">
|
25
|
+
<%= attribute[1] %>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
</div>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<%
|
2
|
+
buttons = []
|
3
|
+
|
4
|
+
buttons << {
|
5
|
+
icon: "angle-double-left ",
|
6
|
+
label: acm_t(:title_action, action: acm_t(:index, scope: :actions), model: base_class.model_name.human),
|
7
|
+
url: polymorphic_path(url_namespace),
|
8
|
+
title: acm_t(:title_action, action: acm_t(:index, scope: :actions), model: base_class.model_name.human),
|
9
|
+
hotkey: 'alt+b',
|
10
|
+
dialog: false,
|
11
|
+
if_permitted_to: [:index, @obj.class]
|
12
|
+
}
|
13
|
+
|
14
|
+
if exist_order_path? @obj
|
15
|
+
buttons << {
|
16
|
+
icon: :random,
|
17
|
+
label: acm_t(:title_action, action: acm_t(:order, scope: :actions), model: base_class.model_name.human),
|
18
|
+
url: order_path(@obj),
|
19
|
+
title: acm_t(:title_action, action: acm_t(:order, scope: :actions), model: base_class.model_name.human),
|
20
|
+
hotkey: 'alt+n',
|
21
|
+
dialog: false,
|
22
|
+
if_permitted_to: [:order, base_class]
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
%>
|
27
|
+
|
28
|
+
|
29
|
+
<% toolbar(
|
30
|
+
buttons: buttons,
|
31
|
+
search: false
|
32
|
+
) %>
|
33
|
+
|
34
|
+
|
35
|
+
<%= base_container do %>
|
36
|
+
|
37
|
+
<div id="archive_all" class="resources-table-wrapper">
|
38
|
+
|
39
|
+
<%= content_tag :h1, "#{@objects.count} #{base_class.model_name.human(count: @objects.count)}", class: 'resources-header' %>
|
40
|
+
|
41
|
+
|
42
|
+
<%= render partial: "table" %>
|
43
|
+
|
44
|
+
<%= paginate @objects, theme: 'alchemy', hide_per_page_select: true %>
|
45
|
+
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<% end %>
|
@@ -2,9 +2,9 @@
|
|
2
2
|
buttons: [
|
3
3
|
{
|
4
4
|
icon: "angle-double-left ",
|
5
|
-
label:
|
5
|
+
label: acm_t(:title_action, action: acm_t(:index, scope: :actions), model: base_class.model_name.human),
|
6
6
|
url: polymorphic_path(url_namespace),
|
7
|
-
title:
|
7
|
+
title: acm_t(:title_action, action: acm_t(:index, scope: :actions), model: base_class.model_name.human),
|
8
8
|
hotkey: 'alt+b',
|
9
9
|
dialog: false,
|
10
10
|
if_permitted_to: [:index, @obj.class]
|
@@ -31,22 +31,22 @@
|
|
31
31
|
}
|
32
32
|
end
|
33
33
|
|
34
|
-
if can?(:export_csv, base_class) and check_presence_polymorphic_path([:export_csv, :admin,
|
34
|
+
if can?(:export_csv, base_class) and check_presence_polymorphic_path([:export_csv, :admin, base_class.to_s.demodulize.pluralize.underscore.to_sym ], :get, format: :csv)
|
35
35
|
buttons << {
|
36
36
|
icon: "download",
|
37
37
|
label: t(:export_selected_data),
|
38
|
-
url: polymorphic_path([:export_csv, :admin,
|
38
|
+
url: polymorphic_path([:export_csv, :admin, base_class.to_s.demodulize.pluralize.underscore.to_sym], {format: :csv}.merge(request.query_parameters) ),
|
39
39
|
title: t(:export_selected_data),
|
40
40
|
dialog: false,
|
41
41
|
if_permitted_to: [:export_csv, base_class]
|
42
42
|
}
|
43
43
|
end
|
44
44
|
|
45
|
-
if can?(:export_csv_full, base_class) and check_presence_polymorphic_path([:export_csv_full, :admin,
|
45
|
+
if can?(:export_csv_full, base_class) and check_presence_polymorphic_path([:export_csv_full, :admin, base_class.to_s.demodulize.pluralize.underscore.to_sym ], :get, format: :csv)
|
46
46
|
buttons << {
|
47
47
|
icon: "file-archive",
|
48
48
|
label: t(:export_all_data),
|
49
|
-
url: polymorphic_path([:export_csv_full, :admin,
|
49
|
+
url: polymorphic_path([:export_csv_full, :admin, base_class.to_s.demodulize.pluralize.underscore.to_sym],format: :csv),
|
50
50
|
title: t(:export_all_data),
|
51
51
|
dialog: false,
|
52
52
|
if_permitted_to: [:export_csv_full, base_class]
|
@@ -65,8 +65,9 @@
|
|
65
65
|
|
66
66
|
<div id="archive_all" class="resources-table-wrapper">
|
67
67
|
|
68
|
-
<%= content_tag :h1, "#{@
|
68
|
+
<%= content_tag :h1, "#{@total_objects.count} #{base_class.model_name.human(count: @objects.count)}", class: 'resources-header' %>
|
69
69
|
|
70
|
+
<%= render partial: "search_panel" %>
|
70
71
|
|
71
72
|
<%= render partial: "table" %>
|
72
73
|
|
@@ -2,9 +2,9 @@
|
|
2
2
|
buttons: [
|
3
3
|
{
|
4
4
|
icon: "angle-double-left ",
|
5
|
-
label: acm_t(:title_action, action:
|
5
|
+
label: acm_t(:title_action, action: acm_t(:index, scope: :actions), model: base_class.model_name.human),
|
6
6
|
url: polymorphic_path(url_namespace),
|
7
|
-
title: acm_t(:title_action, action:
|
7
|
+
title: acm_t(:title_action, action: acm_t(:index, scope: :actions), model: base_class.model_name.human),
|
8
8
|
hotkey: 'alt+b',
|
9
9
|
dialog: false,
|
10
10
|
if_permitted_to: [:index, @obj.class]
|
@@ -1,48 +1,5 @@
|
|
1
|
-
<%
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
label: acm_t(:title_action, action: t(:index, scope: :actions), model: base_class.model_name.human),
|
7
|
-
url: polymorphic_path(url_namespace),
|
8
|
-
title: acm_t(:title_action, action: t(:index, scope: :actions), model: base_class.model_name.human),
|
9
|
-
hotkey: 'alt+b',
|
10
|
-
dialog: false,
|
11
|
-
if_permitted_to: [:index, @obj.class]
|
12
|
-
}
|
13
|
-
|
14
|
-
if exist_order_path? @obj
|
15
|
-
buttons << {
|
16
|
-
icon: :random,
|
17
|
-
label: acm_t(:title_action, action: acm_t(:order, scope: :actions), model: base_class.model_name.human),
|
18
|
-
url: order_path(@obj),
|
19
|
-
title: acm_t(:title_action, action: acm_t(:order, scope: :actions), model: base_class.model_name.human),
|
20
|
-
hotkey: 'alt+n',
|
21
|
-
dialog: false,
|
22
|
-
if_permitted_to: [:order, base_class]
|
23
|
-
}
|
24
|
-
end
|
25
|
-
|
26
|
-
%>
|
27
|
-
|
28
|
-
|
29
|
-
<% toolbar(
|
30
|
-
buttons: buttons,
|
31
|
-
search: false
|
32
|
-
) %>
|
33
|
-
|
34
|
-
|
35
|
-
<%= base_container do %>
|
36
|
-
|
37
|
-
<div id="archive_all" class="resources-table-wrapper">
|
38
|
-
|
39
|
-
<%= content_tag :h1, "#{@objects.count} #{base_class.model_name.human(count: @objects.count)}", class: 'resources-header' %>
|
40
|
-
|
41
|
-
|
42
|
-
<%= render partial: "table" %>
|
43
|
-
|
44
|
-
<%= paginate @objects, theme: 'alchemy', hide_per_page_select: true %>
|
45
|
-
|
46
|
-
</div>
|
47
|
-
|
48
|
-
<% end %>
|
1
|
+
<% if @objects.nil? %>
|
2
|
+
<%= render partial: "show_object" %>
|
3
|
+
<% else %>
|
4
|
+
<%= render partial: "show_objects" %>
|
5
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%- @pages.each do |page| -%>
|
2
|
+
<url>
|
3
|
+
<loc><%= show_alchemy_page_url(page) %></loc>
|
4
|
+
<lastmod><%= page.updated_at.utc.iso8601 %></lastmod>
|
5
|
+
<changefreq><%= Alchemy::Custom::Model.sitemap_change_freq %></changefreq>
|
6
|
+
</url>
|
7
|
+
<%- end -%>
|
8
|
+
<% Alchemy::Language.published.each do |language| %>
|
9
|
+
<% @custom_elements.each do |ce| %>
|
10
|
+
<url>
|
11
|
+
<loc><%= custom_model_url(ce, language: language) %></loc>
|
12
|
+
<lastmod><%= ce.updated_at.utc.iso8601 %></lastmod>
|
13
|
+
<changefreq><%= Alchemy::Custom::Model.sitemap_change_freq %></changefreq>
|
14
|
+
</url>
|
15
|
+
<% end %>
|
16
|
+
<% end%>
|
data/config/locales/it.yml
CHANGED
data/config/routes.rb
CHANGED
@@ -6,3 +6,19 @@ Alchemy::Custom::Model::Engine.routes.draw do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
end
|
9
|
+
|
10
|
+
|
11
|
+
Alchemy::Engine.routes.draw do
|
12
|
+
|
13
|
+
if "Alchemy::Node".safe_constantize
|
14
|
+
namespace :admin do
|
15
|
+
resources :nodes do
|
16
|
+
collection do
|
17
|
+
get :custom_models, defaults: {format: 'json'}, constraints: {format: :json}
|
18
|
+
get :custom_models_methods, defaults: {format: 'json'}, constraints: {format: :json}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "alchemy_cms"
|
2
|
+
require "jquery/ui/rails"
|
3
|
+
require "el_finder"
|
4
|
+
require "friendly_id"
|
5
|
+
require "globalize"
|
6
|
+
require 'friendly_id/globalize'
|
7
|
+
require "active_type"
|
8
|
+
require "alchemy/custom/model/engine"
|
9
|
+
|
10
|
+
|
11
|
+
module Alchemy
|
12
|
+
extend ActiveSupport::Autoload
|
13
|
+
autoload :NodeDec
|
14
|
+
|
15
|
+
module Admin
|
16
|
+
extend ActiveSupport::Autoload
|
17
|
+
autoload :NodesControllerDec
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
module Custom
|
22
|
+
module Model
|
23
|
+
extend ActiveSupport::Autoload
|
24
|
+
|
25
|
+
autoload :ElFinder
|
26
|
+
autoload :GlobalIdSetter
|
27
|
+
autoload :MenuMethods
|
28
|
+
autoload :SlugOptimizer
|
29
|
+
autoload :ModelDecoration
|
30
|
+
autoload :TranslationScope
|
31
|
+
autoload :PagesControllerDec
|
32
|
+
autoload :PictureUsedBy
|
33
|
+
autoload :ModelUtilsMethod
|
34
|
+
autoload :SitemapMethods
|
35
|
+
autoload :GlobalizeModelDecoration
|
36
|
+
|
37
|
+
|
38
|
+
mattr_accessor :sitemap_change_freq
|
39
|
+
@@sitemap_change_freq = "weekly"
|
40
|
+
|
41
|
+
mattr_accessor :sitemaps_models
|
42
|
+
@@sitemaps_models = []
|
43
|
+
|
44
|
+
|
45
|
+
mattr_accessor :base_admin_controller_class
|
46
|
+
|
47
|
+
@@base_admin_controller_class = 'Alchemy::Admin::BaseController'
|
48
|
+
|
49
|
+
mattr_accessor :allowed_custom_models_for_menu
|
50
|
+
@@allowed_custom_models_for_menu = []
|
51
|
+
|
52
|
+
|
53
|
+
def self.admin_controller_class
|
54
|
+
@@base_admin_controller_class.constantize
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -35,6 +35,15 @@ module Alchemy::Custom::Model::ElFinder
|
|
35
35
|
"#{p.id}#{URI_SPACER}"
|
36
36
|
end
|
37
37
|
|
38
|
+
##
|
39
|
+
# Identifichiamo la data di modifica del file con la data di modifica del record, in questo modo la cache
|
40
|
+
# che viene generata attraverso l'inserimento di un parametro nella query con il valore t=orario non andrà ad essere
|
41
|
+
# aggiornato ad ogni refresh, anche solo a livello di browser
|
42
|
+
# nel caso abbiamo problemi usiamo lo standard
|
43
|
+
def mtime
|
44
|
+
active_record_instance.updated_at rescue super
|
45
|
+
end
|
46
|
+
|
38
47
|
def file
|
39
48
|
active_record_instance.file
|
40
49
|
end
|
@@ -20,9 +20,15 @@ module Alchemy
|
|
20
20
|
|
21
21
|
Alchemy::PagesController.include(PagesControllerDec)
|
22
22
|
|
23
|
+
|
24
|
+
if "Alchemy::Node".safe_constantize
|
25
|
+
Alchemy::Node.include Alchemy::NodeDec
|
26
|
+
Alchemy::Admin::NodesController.include Alchemy::Admin::NodesControllerDec
|
27
|
+
end
|
28
|
+
|
23
29
|
# load degli helpers per alchemy
|
24
30
|
[
|
25
|
-
|
31
|
+
Alchemy::Custom::Model::Engine.root.join('app', 'helpers', 'alchemy', 'pages_helper_decorator.rb')
|
26
32
|
].each do |f|
|
27
33
|
Rails.configuration.cache_classes ? require(f) : load(f)
|
28
34
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Alchemy::Custom::Model
|
2
|
+
module GlobalizeModelDecoration
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
|
7
|
+
include GlobalIdSetter
|
8
|
+
include MenuMethods
|
9
|
+
include ModelUtilsMethods
|
10
|
+
include SitemapMethods
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
def self.use_friendly(base = nil, options = {}, &block)
|
15
|
+
extend FriendlyId
|
16
|
+
|
17
|
+
self.friendly_id(base, options.merge(use: [:globalize]), &block)
|
18
|
+
|
19
|
+
include SlugOptimizer
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|