alchemy-custom-model 2.0.3 → 2.2.1

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/alchemy-custom-model/total_page_elfinder.js.coffee +1 -1
  7. data/app/assets/javascripts/backend/date_picker.js +24 -0
  8. data/app/assets/javascripts/backend/fix_more_image_in_element.js.coffee +10 -0
  9. data/app/assets/javascripts/backend/override_alchemy_selectbox.js +8 -0
  10. data/app/assets/stylesheets/alchemy-custom-model/custom_elfinder.css.scss +20 -2
  11. data/app/assets/stylesheets/alchemy-custom-model/custom_style.css.scss +95 -0
  12. data/app/controllers/alchemy/custom/model/admin/base_controller.rb +58 -10
  13. data/app/controllers/alchemy/custom/model/admin/base_with_globalize_controller.rb +38 -0
  14. data/app/controllers/concerns/alchemy/admin/nodes_controller_dec.rb +55 -0
  15. data/app/helpers/alchemy/custom/model/admin/base_helper.rb +50 -2
  16. data/app/helpers/alchemy/custom/model/custom_model_helper.rb +26 -13
  17. data/app/helpers/alchemy/pages_helper_decorator.rb +38 -0
  18. data/app/models/concerns/alchemy/node_dec.rb +45 -0
  19. data/app/views/alchemy/admin/nodes/_form.html.erb +126 -0
  20. data/app/views/alchemy/admin/nodes/custom_models.json.jbuilder +10 -0
  21. data/app/views/alchemy/admin/nodes/custom_models_methods.json.jbuilder +10 -0
  22. data/app/views/alchemy/admin/pictures/_custom_model_info.html.erb +27 -0
  23. data/app/views/alchemy/admin/pictures/_infos.html.erb +65 -0
  24. data/app/views/alchemy/custom/model/admin/base/_gallery_item.html.erb +7 -2
  25. data/app/views/alchemy/custom/model/admin/base/_search_panel.html.erb +16 -0
  26. data/app/views/alchemy/custom/model/admin/base/_seo.html.erb +5 -5
  27. data/app/views/alchemy/custom/model/admin/base/_show_object.html.erb +30 -0
  28. data/app/views/alchemy/custom/model/admin/base/_show_objects.html.erb +48 -0
  29. data/app/views/alchemy/custom/model/admin/base/_title.html.erb +1 -1
  30. data/app/views/alchemy/custom/model/admin/base/edit.html.erb +2 -2
  31. data/app/views/alchemy/custom/model/admin/base/index.html.erb +24 -2
  32. data/app/views/alchemy/custom/model/admin/base/new.html.erb +2 -2
  33. data/app/views/alchemy/custom/model/admin/base/show.html.erb +5 -48
  34. data/app/views/alchemy/pages/sitemap.xml.erb +16 -0
  35. data/config/locales/it.yml +6 -0
  36. data/config/routes.rb +16 -0
  37. data/db/migrate/20200424184007_add_fields_to_node.rb +8 -0
  38. data/lib/alchemy/custom/model.rb +58 -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 +58 -7
  52. data/lib/alchemy-custom-model.rb +0 -31
@@ -0,0 +1,10 @@
1
+
2
+ json.meta do
3
+ json.total_count @custom_model_klasses.count
4
+ json.page params[:page]
5
+ json.per_page 10
6
+ end
7
+ json.results @custom_model_klasses do |result|
8
+ json.id result
9
+ json.text result
10
+ end
@@ -0,0 +1,10 @@
1
+
2
+ json.meta do
3
+ json.total_count @custom_model_methods.count
4
+ json.page params[:page]
5
+ json.per_page 10
6
+ end
7
+ json.results @custom_model_methods do |result|
8
+ json.id result
9
+ json.text result
10
+ end
@@ -0,0 +1,27 @@
1
+ <div class="picture-usage-info resource_info">
2
+ <h3>
3
+ <%= I18n.t(:image_used_in_this_models, scope: :alchemy_custom_model) %>
4
+ </h3>
5
+ <div id="pictures_page_list">
6
+ <% used_in = Alchemy::Custom::Model::PictureUsedBy.used_by(@picture.id)%>
7
+ <% if used_in.any? %>
8
+ <ul>
9
+ <% used_in.each do |m| %>
10
+ <li>
11
+ <% begin %>
12
+ <h3>
13
+ <%= render_icon 'file-alt' %>
14
+ <p><%= link_to "#{m.model_name.human}, #{m.try(:slug).to_s}", main_app.edit_polymorphic_path([:admin, m]) %></p>
15
+ </h3>
16
+ <% rescue %>
17
+ <% end %>
18
+ </li>
19
+ <% end %>
20
+ </ul>
21
+ <% else %>
22
+ <%= render_message do %>
23
+ <%= Alchemy.t(:picture_not_in_use_yet) %>
24
+ <% end %>
25
+ <% end %>
26
+ </div>
27
+ </div>
@@ -0,0 +1,65 @@
1
+ <div class="resource_info">
2
+ <div class="picture-file-infos">
3
+ <div class="value">
4
+ <label><%= Alchemy::Picture.human_attribute_name(:image_file_name) %></label>
5
+ <p><%= @picture.image_file_name %></p>
6
+ </div>
7
+ <div class="value">
8
+ <label><%= Alchemy::Picture.human_attribute_name(:image_file_dimensions) %></label>
9
+ <p><%= @picture.image_file_dimensions %>px</p>
10
+ </div>
11
+ <div class="value">
12
+ <label><%= Alchemy::Picture.human_attribute_name(:image_file_size) %></label>
13
+ <p><%= number_to_human_size @picture.image_file_size %></p>
14
+ </div>
15
+ </div>
16
+ </div>
17
+
18
+ <div class="picture-usage-info resource_info">
19
+ <h3>
20
+ <%= Alchemy.t(:this_picture_is_used_on_these_pages) %>
21
+ </h3>
22
+ <div id="pictures_page_list">
23
+ <% if @assignments.any? %>
24
+ <ul>
25
+ <% @assignments.group_by(&:page).each do |page, essence_pictures| %>
26
+ <% if page %>
27
+ <li>
28
+ <h3>
29
+ <%= render_icon 'file-alt' %>
30
+ <p><%= link_to page.name, edit_admin_page_path(page) %></p>
31
+ </h3>
32
+ <ul class="list">
33
+ <% essence_pictures.group_by(&:element).each do |element, essence_pictures| %>
34
+ <li class="<%= cycle('even', 'odd') %>">
35
+ <% page_link = link_to element.display_name_with_preview_text,
36
+ edit_admin_page_path(page, anchor: "element_#{element.id}") %>
37
+ <% pictures = essence_pictures.collect do |e|
38
+ e.content.name_for_label
39
+ end.to_sentence %>
40
+ <% if element.public? %>
41
+ <%= render_icon('window-maximize', style: 'regular') %>
42
+ <% else %>
43
+ <%= render_icon('window-close') %>
44
+ <% end %>
45
+ <p>
46
+ <%== Alchemy.t(:pictures_in_page, page: page_link, pictures: pictures) %>
47
+ <em><%= Alchemy::Element.human_attribute_name(:trashed) if element.trashed? %></em>
48
+ </p>
49
+ </li>
50
+ <% end %>
51
+ </ul>
52
+ </li>
53
+ <% end %>
54
+ <% end %>
55
+ </ul>
56
+ <% else %>
57
+ <%= render_message do %>
58
+ <%= Alchemy.t(:picture_not_in_use_yet) %>
59
+ <% end %>
60
+ <% end %>
61
+ </div>
62
+ </div>
63
+
64
+ <%= render partial: "custom_model_info" %>
65
+
@@ -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]
@@ -1,4 +1,3 @@
1
-
2
1
  <% content_for(:toolbar) do %>
3
2
  <%= render 'alchemy/admin/partials/site_select' %>
4
3
  <%= render 'language_tree_select' %>
@@ -32,6 +31,28 @@
32
31
  }
33
32
  end
34
33
 
34
+ if can?(:export_csv, base_class) and check_presence_polymorphic_path([:export_csv, :admin, base_class.to_s.demodulize.pluralize.underscore ], :get, format: :csv)
35
+ buttons << {
36
+ icon: "download",
37
+ label: t(:export_selected_data),
38
+ url: polymorphic_path([:export_csv, :admin, base_class.to_s.demodulize.pluralize.underscore], {format: :csv}.merge(request.query_parameters) ),
39
+ title: t(:export_selected_data),
40
+ dialog: false,
41
+ if_permitted_to: [:export_csv, base_class]
42
+ }
43
+ end
44
+
45
+ if can?(:export_csv_full, base_class) and check_presence_polymorphic_path([:export_csv_full, :admin, base_class.to_s.demodulize.pluralize.underscore ], :get, format: :csv)
46
+ buttons << {
47
+ icon: "file-archive",
48
+ label: t(:export_all_data),
49
+ url: polymorphic_path([:export_csv_full, :admin, base_class.to_s.demodulize.pluralize.underscore],format: :csv),
50
+ title: t(:export_all_data),
51
+ dialog: false,
52
+ if_permitted_to: [:export_csv_full, base_class]
53
+ }
54
+ end
55
+
35
56
  %>
36
57
 
37
58
  <% toolbar(
@@ -44,8 +65,9 @@
44
65
 
45
66
  <div id="archive_all" class="resources-table-wrapper">
46
67
 
47
- <%= 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' %>
48
69
 
70
+ <%= render partial: "search_panel" %>
49
71
 
50
72
  <%= render partial: "table" %>
51
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