alchemy-custom-model 2.1.2 → 2.2.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/controllers/alchemy/custom/model/admin/base_controller.rb +3 -0
- 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 +5 -2
- 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/_seo.html.erb +5 -5
- 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 +1 -1
- data/app/views/alchemy/custom/model/admin/base/new.html.erb +2 -2
- data/app/views/alchemy/custom/model/admin/base/show.html.erb +2 -2
- 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 → alchemy/custom/model.rb} +20 -0
- data/lib/alchemy/custom/model/engine.rb +7 -1
- data/lib/alchemy/custom/model/globalize_model_decoration.rb +25 -0
- data/lib/alchemy/custom/model/menu_methods.rb +16 -0
- data/lib/alchemy/custom/model/model_decoration.rb +2 -0
- data/lib/alchemy/custom/model/model_utils_methods.rb +28 -0
- data/lib/alchemy/custom/model/picture_used_by.rb +51 -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 +53 -7
@@ -0,0 +1,28 @@
|
|
1
|
+
module Alchemy
|
2
|
+
module Custom
|
3
|
+
module Model
|
4
|
+
module ModelUtilsMethods
|
5
|
+
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
|
10
|
+
def to_url
|
11
|
+
layout = Alchemy::PageLayout.get_all_by_attributes(custom_model: self.class.to_s).select { |ly| ly["custom_model_action"] == "show" }.first
|
12
|
+
page = Alchemy::Language.current.pages.find_by(page_layout: layout["name"]).parent
|
13
|
+
page.urlname
|
14
|
+
end
|
15
|
+
|
16
|
+
def ui_title
|
17
|
+
self.class.to_s.demodulize.downcase
|
18
|
+
end
|
19
|
+
|
20
|
+
def breadcrumb_name
|
21
|
+
self.class.to_s.demodulize.titleize
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Alchemy
|
2
|
+
module Custom
|
3
|
+
module Model
|
4
|
+
class PictureUsedBy
|
5
|
+
|
6
|
+
def self.used_by(picture_id)
|
7
|
+
model_to_search_for = ApplicationRecord.descendants.collect(&:name)
|
8
|
+
|
9
|
+
finded_pictures = []
|
10
|
+
model_to_search_for.each do |mname|
|
11
|
+
relations = mname.constantize.reflections.collect{|c| c[0] }
|
12
|
+
|
13
|
+
relations.each do |refc|
|
14
|
+
relation = mname.constantize.reflections[refc]
|
15
|
+
|
16
|
+
if relation.class_name == "Alchemy::Picture"
|
17
|
+
begin
|
18
|
+
if relation.class == ActiveRecord::Reflection::BelongsToReflection
|
19
|
+
mm = mname.constantize.where(relation.foreign_key.to_sym => picture_id)
|
20
|
+
mm.each do |rec|
|
21
|
+
finded_pictures << rec
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
if relation.class == ActiveRecord::Reflection::ThroughReflection
|
26
|
+
relation_through = mname.constantize.reflections[relation.options[:through].to_s]
|
27
|
+
mm = relation_through.klass.where(relation.foreign_key.to_sym => picture_id)
|
28
|
+
mm.each do |rec|
|
29
|
+
rec.class.reflections.collect{|c| c[0] }.each do |relative_relation|
|
30
|
+
relation_relation_class = rec.class.reflections[relative_relation]
|
31
|
+
if relation_relation_class.class_name == mname
|
32
|
+
mm = relation_relation_class.klass.find( rec[relation_relation_class.foreign_key] )
|
33
|
+
finded_pictures << mm unless mm.nil?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
rescue Exception => excp
|
40
|
+
Rails.logger.error {"PictureUsedBy ERROR: #{excp.message}"}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
finded_pictures
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Alchemy
|
2
|
+
module Custom
|
3
|
+
module Model
|
4
|
+
module SlugOptimizer
|
5
|
+
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
validates friendly_id_config.query_field, uniqueness: {:allow_nil => true}
|
10
|
+
before_save :prevent_wrong_slug
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def prevent_wrong_slug
|
15
|
+
self.send("#{friendly_id_config.query_field}=", normalize_friendly_id(self.slug))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -30,10 +30,13 @@ namespace :alchemy_custom_model do
|
|
30
30
|
|
31
31
|
#installa friendly_id
|
32
32
|
system("rails generate friendly_id")
|
33
|
+
system("bin/rails alchemy_custom_model:install:migrations")
|
33
34
|
system("bin/rails db:migrate")
|
34
35
|
|
35
36
|
system("yarn add alchemy-custom-model") || exit!(1)
|
36
37
|
|
38
|
+
|
39
|
+
|
37
40
|
install_helper.inject_assets
|
38
41
|
install_helper.inject_routes
|
39
42
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
4
|
+
(global = global || self, factory(global.it = {}));
|
5
|
+
}(this, function (exports) { 'use strict';
|
6
|
+
|
7
|
+
var fp = typeof window !== "undefined" && window.flatpickr !== undefined
|
8
|
+
? window.flatpickr
|
9
|
+
: {
|
10
|
+
l10ns: {}
|
11
|
+
};
|
12
|
+
var Italian = {
|
13
|
+
weekdays: {
|
14
|
+
shorthand: ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"],
|
15
|
+
longhand: [
|
16
|
+
"Domenica",
|
17
|
+
"Lunedì",
|
18
|
+
"Martedì",
|
19
|
+
"Mercoledì",
|
20
|
+
"Giovedì",
|
21
|
+
"Venerdì",
|
22
|
+
"Sabato",
|
23
|
+
]
|
24
|
+
},
|
25
|
+
months: {
|
26
|
+
shorthand: [
|
27
|
+
"Gen",
|
28
|
+
"Feb",
|
29
|
+
"Mar",
|
30
|
+
"Apr",
|
31
|
+
"Mag",
|
32
|
+
"Giu",
|
33
|
+
"Lug",
|
34
|
+
"Ago",
|
35
|
+
"Set",
|
36
|
+
"Ott",
|
37
|
+
"Nov",
|
38
|
+
"Dic",
|
39
|
+
],
|
40
|
+
longhand: [
|
41
|
+
"Gennaio",
|
42
|
+
"Febbraio",
|
43
|
+
"Marzo",
|
44
|
+
"Aprile",
|
45
|
+
"Maggio",
|
46
|
+
"Giugno",
|
47
|
+
"Luglio",
|
48
|
+
"Agosto",
|
49
|
+
"Settembre",
|
50
|
+
"Ottobre",
|
51
|
+
"Novembre",
|
52
|
+
"Dicembre",
|
53
|
+
]
|
54
|
+
},
|
55
|
+
firstDayOfWeek: 1,
|
56
|
+
ordinal: function () { return "°"; },
|
57
|
+
rangeSeparator: " al ",
|
58
|
+
weekAbbreviation: "Se",
|
59
|
+
scrollTitle: "Scrolla per aumentare",
|
60
|
+
toggleTitle: "Clicca per cambiare",
|
61
|
+
time_24hr: true
|
62
|
+
};
|
63
|
+
fp.l10ns.it = Italian;
|
64
|
+
var it = fp.l10ns;
|
65
|
+
|
66
|
+
exports.Italian = Italian;
|
67
|
+
exports.default = it;
|
68
|
+
|
69
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
70
|
+
|
71
|
+
}));
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy-custom-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Baccanelli
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: alchemy_cms
|
@@ -79,20 +79,48 @@ dependencies:
|
|
79
79
|
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: 5.2.4
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: globalize
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '5.3'
|
89
|
+
type: :runtime
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '5.3'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: friendly_id-globalize
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.0.0.alpha3
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - '='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.0.0.alpha3
|
82
110
|
- !ruby/object:Gem::Dependency
|
83
111
|
name: active_type
|
84
112
|
requirement: !ruby/object:Gem::Requirement
|
85
113
|
requirements:
|
86
114
|
- - "~>"
|
87
115
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
116
|
+
version: '1.3'
|
89
117
|
type: :runtime
|
90
118
|
prerelease: false
|
91
119
|
version_requirements: !ruby/object:Gem::Requirement
|
92
120
|
requirements:
|
93
121
|
- - "~>"
|
94
122
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
123
|
+
version: '1.3'
|
96
124
|
description: A gem for semplify model implementation with Alchemy CMS
|
97
125
|
email:
|
98
126
|
- alexbaccanelli@gmail.com
|
@@ -106,6 +134,7 @@ files:
|
|
106
134
|
- Rakefile
|
107
135
|
- app/assets/config/alchemy_custom_model_manifest.js
|
108
136
|
- app/assets/images/alchemy-custom-model/no_image.png
|
137
|
+
- app/assets/javascripts/alchemy-custom-model/alchemy_custom_model_select.js
|
109
138
|
- app/assets/javascripts/alchemy-custom-model/change_language.js
|
110
139
|
- app/assets/javascripts/alchemy-custom-model/common_init.js
|
111
140
|
- app/assets/javascripts/alchemy-custom-model/custom_admin_element_editor.js.coffee
|
@@ -118,15 +147,20 @@ files:
|
|
118
147
|
- app/assets/javascripts/alchemy-custom-model/sortable.js
|
119
148
|
- app/assets/javascripts/alchemy-custom-model/subobjects.js
|
120
149
|
- app/assets/javascripts/alchemy-custom-model/total_page_elfinder.js.coffee
|
150
|
+
- app/assets/javascripts/backend/date_picker.js
|
151
|
+
- app/assets/javascripts/backend/fix_more_image_in_element.js.coffee
|
152
|
+
- app/assets/javascripts/backend/override_alchemy_selectbox.js
|
121
153
|
- app/assets/stylesheets/alchemy-custom-model/custom_elfinder.css.scss
|
122
154
|
- app/assets/stylesheets/alchemy-custom-model/custom_style.css.scss
|
123
155
|
- app/assets/stylesheets/alchemy-custom-model/custom_tiny_mce.scss
|
124
156
|
- app/assets/stylesheets/alchemy-custom-model/manifest.css
|
125
157
|
- app/controllers/alchemy/custom/model/admin/base_controller.rb
|
158
|
+
- app/controllers/alchemy/custom/model/admin/base_with_globalize_controller.rb
|
126
159
|
- app/controllers/alchemy/custom/model/admin/clones_controller.rb
|
127
160
|
- app/controllers/alchemy/custom/model/admin/files_controller.rb
|
128
161
|
- app/controllers/alchemy/custom/model/admin/orders_controller.rb
|
129
162
|
- app/controllers/alchemy/pages_controller_decorator.rb
|
163
|
+
- app/controllers/concerns/alchemy/admin/nodes_controller_dec.rb
|
130
164
|
- app/helpers/alchemy/custom/model/admin/base_helper.rb
|
131
165
|
- app/helpers/alchemy/custom/model/admin/orders_helper.rb
|
132
166
|
- app/helpers/alchemy/custom/model/base_helper.rb
|
@@ -135,6 +169,12 @@ files:
|
|
135
169
|
- app/models/admin_override_to_param.rb
|
136
170
|
- app/models/alchemy/custom/model/cloner.rb
|
137
171
|
- app/models/application_record.rb
|
172
|
+
- app/models/concerns/alchemy/node_dec.rb
|
173
|
+
- app/views/alchemy/admin/nodes/_form.html.erb
|
174
|
+
- app/views/alchemy/admin/nodes/custom_models.json.jbuilder
|
175
|
+
- app/views/alchemy/admin/nodes/custom_models_methods.json.jbuilder
|
176
|
+
- app/views/alchemy/admin/pictures/_custom_model_info.html.erb
|
177
|
+
- app/views/alchemy/admin/pictures/_infos.html.erb
|
138
178
|
- app/views/alchemy/custom/model/admin/base/_buttons_tool.html.erb
|
139
179
|
- app/views/alchemy/custom/model/admin/base/_gallery_item.html.erb
|
140
180
|
- app/views/alchemy/custom/model/admin/base/_language_tree_select.html.erb
|
@@ -154,7 +194,8 @@ files:
|
|
154
194
|
- config/locales/en.yml
|
155
195
|
- config/locales/it.yml
|
156
196
|
- config/routes.rb
|
157
|
-
-
|
197
|
+
- db/migrate/20200424184007_add_fields_to_node.rb
|
198
|
+
- lib/alchemy/custom/model.rb
|
158
199
|
- lib/alchemy/custom/model/el_finder.rb
|
159
200
|
- lib/alchemy/custom/model/el_finder/ability.rb
|
160
201
|
- lib/alchemy/custom/model/el_finder/connector.rb
|
@@ -180,13 +221,19 @@ files:
|
|
180
221
|
- lib/alchemy/custom/model/errors/error.rb
|
181
222
|
- lib/alchemy/custom/model/errors/parent_nil.rb
|
182
223
|
- lib/alchemy/custom/model/global_id_setter.rb
|
224
|
+
- lib/alchemy/custom/model/globalize_model_decoration.rb
|
225
|
+
- lib/alchemy/custom/model/menu_methods.rb
|
183
226
|
- lib/alchemy/custom/model/model_decoration.rb
|
227
|
+
- lib/alchemy/custom/model/model_utils_methods.rb
|
184
228
|
- lib/alchemy/custom/model/order.rb
|
185
229
|
- lib/alchemy/custom/model/pages_controller_dec.rb
|
230
|
+
- lib/alchemy/custom/model/picture_used_by.rb
|
231
|
+
- lib/alchemy/custom/model/slug_optimizer.rb
|
186
232
|
- lib/alchemy/custom/model/translation_scope.rb
|
187
233
|
- lib/alchemy/custom/model/version.rb
|
188
234
|
- lib/alchemy/touching_decorator.rb
|
189
235
|
- lib/tasks/alchemy_custom_model_tasks.rake
|
236
|
+
- vendor/assets/javascripts/flatpickr/i10n/it.js
|
190
237
|
- vendor/assets/javascripts/tinymce/langs/it.js
|
191
238
|
- vendor/assets/javascripts/tinymce/plugins/image/plugin.min.js
|
192
239
|
- vendor/assets/stylesheets/elFinder.scss
|
@@ -266,8 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
266
313
|
- !ruby/object:Gem::Version
|
267
314
|
version: '0'
|
268
315
|
requirements: []
|
269
|
-
|
270
|
-
rubygems_version: 2.4.8
|
316
|
+
rubygems_version: 3.0.3
|
271
317
|
signing_key:
|
272
318
|
specification_version: 4
|
273
319
|
summary: A gem for semplify model implementation with Alchemy CMS
|