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.
Files changed (52) hide show
  1. checksums.yaml +5 -5
  2. data/app/assets/javascripts/alchemy-custom-model/alchemy_custom_model_select.js +62 -0
  3. data/app/assets/javascripts/alchemy-custom-model/common_init.js +17 -14
  4. data/app/assets/javascripts/alchemy-custom-model/el_finder.js.coffee.erb +31 -0
  5. data/app/assets/javascripts/alchemy-custom-model/manifest.js +5 -0
  6. data/app/assets/javascripts/backend/date_picker.js +24 -0
  7. data/app/assets/javascripts/backend/fix_more_image_in_element.js.coffee +10 -0
  8. data/app/assets/javascripts/backend/override_alchemy_selectbox.js +8 -0
  9. data/app/assets/stylesheets/alchemy-custom-model/custom_elfinder.css.scss +20 -2
  10. data/app/assets/stylesheets/alchemy-custom-model/custom_style.css.scss +95 -0
  11. data/app/controllers/alchemy/custom/model/admin/base_controller.rb +16 -14
  12. data/app/controllers/alchemy/custom/model/admin/base_with_globalize_controller.rb +38 -0
  13. data/app/controllers/concerns/alchemy/admin/nodes_controller_dec.rb +55 -0
  14. data/app/helpers/alchemy/custom/model/admin/base_helper.rb +51 -3
  15. data/app/helpers/alchemy/custom/model/custom_model_helper.rb +26 -13
  16. data/app/helpers/alchemy/pages_helper_decorator.rb +38 -0
  17. data/app/models/concerns/alchemy/node_dec.rb +45 -0
  18. data/app/views/alchemy/admin/nodes/_form.html.erb +126 -0
  19. data/app/views/alchemy/admin/nodes/custom_models.json.jbuilder +10 -0
  20. data/app/views/alchemy/admin/nodes/custom_models_methods.json.jbuilder +10 -0
  21. data/app/views/alchemy/admin/pictures/_custom_model_info.html.erb +27 -0
  22. data/app/views/alchemy/admin/pictures/_infos.html.erb +65 -0
  23. data/app/views/alchemy/custom/model/admin/base/_gallery_item.html.erb +7 -2
  24. data/app/views/alchemy/custom/model/admin/base/_search_panel.html.erb +16 -0
  25. data/app/views/alchemy/custom/model/admin/base/_seo.html.erb +5 -5
  26. data/app/views/alchemy/custom/model/admin/base/_show_object.html.erb +30 -0
  27. data/app/views/alchemy/custom/model/admin/base/_show_objects.html.erb +48 -0
  28. data/app/views/alchemy/custom/model/admin/base/_title.html.erb +1 -1
  29. data/app/views/alchemy/custom/model/admin/base/edit.html.erb +2 -2
  30. data/app/views/alchemy/custom/model/admin/base/index.html.erb +6 -5
  31. data/app/views/alchemy/custom/model/admin/base/new.html.erb +2 -2
  32. data/app/views/alchemy/custom/model/admin/base/show.html.erb +5 -48
  33. data/app/views/alchemy/pages/sitemap.xml.erb +16 -0
  34. data/config/locales/it.yml +6 -0
  35. data/config/routes.rb +16 -0
  36. data/db/migrate/20200424184007_add_fields_to_node.rb +8 -0
  37. data/lib/alchemy/custom/model.rb +58 -0
  38. data/lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb +9 -0
  39. data/lib/alchemy/custom/model/engine.rb +7 -1
  40. data/lib/alchemy/custom/model/globalize_model_decoration.rb +26 -0
  41. data/lib/alchemy/custom/model/menu_methods.rb +16 -0
  42. data/lib/alchemy/custom/model/model_decoration.rb +3 -0
  43. data/lib/alchemy/custom/model/model_utils_methods.rb +28 -0
  44. data/lib/alchemy/custom/model/pages_controller_dec.rb +38 -25
  45. data/lib/alchemy/custom/model/picture_used_by.rb +51 -0
  46. data/lib/alchemy/custom/model/sitemap_methods.rb +18 -0
  47. data/lib/alchemy/custom/model/slug_optimizer.rb +23 -0
  48. data/lib/alchemy/custom/model/version.rb +1 -1
  49. data/lib/tasks/alchemy_custom_model_tasks.rake +3 -0
  50. data/vendor/assets/javascripts/flatpickr/i10n/it.js +71 -0
  51. metadata +66 -9
  52. 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("100x100#").url) %>
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 %>
@@ -1,3 +1,3 @@
1
1
  <h1>
2
- <%= t(:title_action, action: t(action_name, scope: :actions), model: base_class.model_name.human) %>
2
+ <%= acm_t(:title_action, action: acm_t(action_name, scope: :actions), model: base_class.model_name.human) %>
3
3
  </h1>
@@ -2,9 +2,9 @@
2
2
  buttons: [
3
3
  {
4
4
  icon: "angle-double-left ",
5
- label: t(:title_action, action: t(:index, scope: :actions), model: base_class.model_name.human),
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: t(:title_action, action: t(:index, scope: :actions), model: base_class.model_name.human),
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, base_class.to_s.demodulize.downcase.pluralize ], :get, format: :csv)
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, base_class.to_s.demodulize.downcase.pluralize],format: :csv),
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, base_class.to_s.demodulize.downcase.pluralize ], :get, format: :csv)
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, base_class.to_s.demodulize.downcase.pluralize],format: :csv),
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, "#{@objects.count} #{base_class.model_name.human(count: @objects.count)}", class: 'resources-header' %>
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: t(:index, scope: :actions), model: base_class.model_name.human),
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: t(:index, scope: :actions), model: base_class.model_name.human),
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
- buttons = []
3
-
4
- buttons << {
5
- icon: "angle-double-left ",
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%>
@@ -19,3 +19,9 @@ it:
19
19
  minimize_all: Minimizza
20
20
  maxzimize_all: Massimizza
21
21
 
22
+ image_used_in_this_models: Immagine usata nei seguenti modelli
23
+
24
+ alchemy:
25
+ custom_models: Custom Models
26
+ pages_select: Pagine
27
+
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,8 @@
1
+ class AddFieldsToNode < ActiveRecord::Migration[5.2]
2
+ def change
3
+ if "Alchemy::Node".safe_constantize
4
+ add_column :alchemy_nodes, :custom_model_klass, :string
5
+ add_column :alchemy_nodes, :custom_model_method, :string
6
+ end
7
+ end
8
+ end
@@ -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
- Alchemy::Custom::Model::Engine.root.join('app', 'helpers', 'alchemy', 'pages_helper_decorator.rb')
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
@@ -0,0 +1,16 @@
1
+ module Alchemy
2
+ module Custom
3
+ module Model
4
+ module MenuMethods
5
+
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+
10
+ class_attribute :menu_generator_methods, default: []
11
+
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end