alchemy-custom-model 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/alchemy/custom/model/admin/clones_controller.rb +2 -2
- data/app/helpers/alchemy/custom/model/admin/orders_helper.rb +6 -1
- data/app/models/alchemy/custom/model/cloner.rb +24 -1
- data/app/views/alchemy/custom/model/admin/orders/new.html.erb +1 -1
- data/lib/alchemy/custom/model/order.rb +11 -2
- data/lib/alchemy/custom/model/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ed0ee1023ebbe7aa4406999e824b2cf0b23bc8e
|
4
|
+
data.tar.gz: 7d245b0a99f8ed1de3ecc347d03f7eeb79da2400
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a174324f0a85e471597c66fd1602281cdd067915c897aed4b9815a73ee2012aaa4e4474960e3cc2bbd7da159925c567cb2bf4e80e24eb493f10bf16d5d5726da
|
7
|
+
data.tar.gz: 01fdb0b4e39999267464b77248c9cb81cef4e774165515323de6d62f797d16cf123007d44421f134cf9e0655725698270ccefe45efc5b9715c106244f74f42bb
|
@@ -5,8 +5,8 @@ module Alchemy
|
|
5
5
|
class ClonesController < ::Alchemy::Custom::Model::Admin::BaseController
|
6
6
|
def create
|
7
7
|
@obj.assign_attributes clean_params
|
8
|
-
if @parent.present?
|
9
|
-
@obj.send
|
8
|
+
if @parent.present?
|
9
|
+
@obj.send("#{@obj.class.to_cloner_name}=",@parent)
|
10
10
|
end
|
11
11
|
@obj = yield @obj if block_given?
|
12
12
|
if @obj.apply
|
@@ -19,8 +19,13 @@ module Alchemy::Custom::Model::Admin::OrdersHelper
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def update_order_path(options = {})
|
22
|
+
def update_order_path(obj=nil,options = {})
|
23
|
+
if obj.nil?
|
23
24
|
polymorphic_path([:admin, base_class.to_s.pluralize.underscore, :order], options)
|
25
|
+
else
|
26
|
+
polymorphic_path([:admin, obj, :order], options)
|
27
|
+
|
28
|
+
end
|
24
29
|
end
|
25
30
|
|
26
31
|
def print_order_identify(el)
|
@@ -3,6 +3,8 @@ module Alchemy
|
|
3
3
|
module Model
|
4
4
|
class Cloner < ::ActiveType::Object
|
5
5
|
|
6
|
+
|
7
|
+
|
6
8
|
attribute :language_id, :integer
|
7
9
|
attribute :site_id, :integer
|
8
10
|
|
@@ -14,7 +16,7 @@ module Alchemy
|
|
14
16
|
# ritorna true se il clone è andato a buon fine false altrimenti
|
15
17
|
def apply
|
16
18
|
if valid?
|
17
|
-
cloned = self.
|
19
|
+
cloned = self.send(self.to_cloner_name).clone_to_other_lang(get_attributes_for_clone.with_indifferent_access)
|
18
20
|
if cloned.valid?
|
19
21
|
true
|
20
22
|
else
|
@@ -30,6 +32,27 @@ module Alchemy
|
|
30
32
|
|
31
33
|
|
32
34
|
|
35
|
+
private
|
36
|
+
|
37
|
+
class << self
|
38
|
+
def cloner_of(name,scope = nil, options={})
|
39
|
+
class_attribute :to_cloner_name
|
40
|
+
name = name.to_sym
|
41
|
+
if options[:foreign_key]
|
42
|
+
attribute options[:foreign_key]
|
43
|
+
else
|
44
|
+
attribute :"#{name}_id"
|
45
|
+
end
|
46
|
+
belongs_to name, scope, options
|
47
|
+
self.to_cloner_name = name
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_attributes_for_clone
|
52
|
+
self.attributes
|
53
|
+
end
|
54
|
+
|
55
|
+
|
33
56
|
protected
|
34
57
|
|
35
58
|
def check_lang_in_site
|
@@ -22,7 +22,7 @@
|
|
22
22
|
<%= t(:suggestion) %>
|
23
23
|
</div>
|
24
24
|
<div class="buttons">
|
25
|
-
<button name="button" type="submit" id="save_order" data-url-update=<%= update_order_path %>><%= t(:save_order) %>
|
25
|
+
<button name="button" type="submit" id="save_order" data-url-update=<%= update_order_path(@obj) %>><%= t(:save_order) %>
|
26
26
|
</button>
|
27
27
|
</div>
|
28
28
|
</div>
|
@@ -31,9 +31,14 @@ module Alchemy::Custom::Model
|
|
31
31
|
|
32
32
|
|
33
33
|
def update
|
34
|
+
if !self.class.method_for_show.blank?
|
35
|
+
klass= klass_for_show_elements
|
36
|
+
else
|
37
|
+
klass= self.parent_klass
|
38
|
+
end
|
34
39
|
updated_nodes = params[:ordered_data]
|
35
|
-
|
36
|
-
process_nodes updated_nodes,
|
40
|
+
klass.transaction do
|
41
|
+
process_nodes updated_nodes, klass
|
37
42
|
end
|
38
43
|
redirect_to polymorphic_path([:admin, self.parent_klass])
|
39
44
|
end
|
@@ -44,6 +49,10 @@ module Alchemy::Custom::Model
|
|
44
49
|
self.class.parent_klass
|
45
50
|
end
|
46
51
|
|
52
|
+
def klass_for_show_elements
|
53
|
+
self.class.method_for_show.to_s.singularize.classify.constantize
|
54
|
+
end
|
55
|
+
|
47
56
|
private
|
48
57
|
|
49
58
|
def check_parent
|
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.0.
|
4
|
+
version: 2.0.2
|
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: 2019-05-
|
12
|
+
date: 2019-05-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: alchemy_cms
|
@@ -267,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
267
267
|
version: '0'
|
268
268
|
requirements: []
|
269
269
|
rubyforge_project:
|
270
|
-
rubygems_version: 2.
|
270
|
+
rubygems_version: 2.6.12
|
271
271
|
signing_key:
|
272
272
|
specification_version: 4
|
273
273
|
summary: A gem for semplify model implementation with Alchemy CMS
|