spree_cm_commissioner 1.17.0.pre.pre7 → 1.17.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a00e3ade6665258924af6b63276add5be49a3b887d193942c41b8ba4a1fa573
4
- data.tar.gz: c30315d4d2f4313a342f94be21cf567cab1dbc4bac07cd754542d61d5de17990
3
+ metadata.gz: 9270cf6464159655e0c794de5c2cfd928bb6a696707676f4166a5062d80810d1
4
+ data.tar.gz: e5039d47fd725c87a214187184f9610fd7be488b1d0e5b75925ec382088d0fc0
5
5
  SHA512:
6
- metadata.gz: 30c14950496e7a3df59fd8a5e3233572a30437f750d0d546d4ec87cc405a8d24850912b161ca74eab4530d1d7cf27e3cb333625b0b4915e63102e3b45f1a3e94
7
- data.tar.gz: 3062f419e60420e2e9a87c57b8720051292ebdbff63b4308bc739e32309b4aef55498b06c1b2134ee3761b9c4fca5cea8d0ecf912d3bf928701292123a23e11b
6
+ metadata.gz: 22b9ab443f30d5214daa18cb51b487c7bbce4764af5a4c27afe3d65b20102c11536a75122167b58bd9b12030b0e9cd737e89f6b3424a2894a746d07917baa154
7
+ data.tar.gz: 4bc00907e7fe3afe5d7266fcb0b40cde518d3b9c9f9bd343ef7b0e80caaa958e76f127028d87292a53e7204fc50b7d4e9e56e48a1c81d7500bcd53bc4275e9ab
data/Gemfile.lock CHANGED
@@ -34,7 +34,7 @@ GIT
34
34
  PATH
35
35
  remote: .
36
36
  specs:
37
- spree_cm_commissioner (1.17.0.pre.pre7)
37
+ spree_cm_commissioner (1.17.0)
38
38
  activerecord-multi-tenant
39
39
  activerecord_json_validator (~> 2.1, >= 2.1.3)
40
40
  aws-sdk-cloudfront
@@ -38,24 +38,7 @@ module Spree
38
38
  def update
39
39
  spree_authorize! :update, spree_current_order, order_token
40
40
 
41
- if guest_params[:guest_dynamic_fields_attributes]
42
- resource.guest_dynamic_fields.destroy_all
43
-
44
- guest_params[:guest_dynamic_fields_attributes].each do |attr|
45
- field = resource.guest_dynamic_fields.build(attr.except(:id))
46
-
47
- if field.dynamic_field.requires_dynamic_field_options?
48
- option = field.dynamic_field.dynamic_field_options.find_by(id: field.value)
49
- field.dynamic_field_option = option if option
50
- end
51
-
52
- field.save!
53
- end
54
- end
55
-
56
- resource.assign_attributes(guest_params.except(:guest_dynamic_fields_attributes))
57
-
58
- if resource.save
41
+ if resource.update(guest_params)
59
42
  render_serialized_payload { serialize_resource(resource) }
60
43
  else
61
44
  render_error_payload(resource, 400)
@@ -93,7 +76,7 @@ module Spree
93
76
  :upload_later,
94
77
  :country_code,
95
78
  :contact,
96
- guest_dynamic_fields_attributes: %i[id dynamic_field_id dynamic_field_option_id value _destroy]
79
+ guest_dynamic_fields_attributes: %i[id dynamic_field_id value _destroy]
97
80
  )
98
81
  end
99
82
  end
@@ -6,27 +6,15 @@ module SpreeCmCommissioner
6
6
  has_many :guest_dynamic_fields, class_name: 'SpreeCmCommissioner::GuestDynamicField', dependent: :destroy
7
7
  has_many :product_dynamic_fields, class_name: 'SpreeCmCommissioner::ProductDynamicField', dependent: :destroy
8
8
 
9
- enum data_type: { text: 0, number: 1, boolean: 2, checkbox: 3, radio: 4, selection: 5, textarea: 6 }
9
+ enum data_type: { string: 0, integer: 1, boolean: 2, checkbox: 3, radio: 4 }
10
10
 
11
11
  accepts_nested_attributes_for :dynamic_field_options, allow_destroy: true, reject_if: :all_blank
12
12
 
13
13
  validates :label, presence: true
14
14
  validates :data_type, presence: true
15
- validates :configurations, presence: true, allow_blank: false
16
15
 
17
- def requires_dynamic_field_options?
18
- checkbox? || radio? || selection?
19
- end
20
-
21
- def multiple_select
22
- return nil unless selection?
23
-
24
- configurations['multiple_select'] == true
25
- end
26
-
27
- def multiple_select=(value)
28
- self.configurations ||= {}
29
- self.configurations['multiple_select'] = ActiveModel::Type::Boolean.new.cast(value)
16
+ def selection?
17
+ checkbox? || radio?
30
18
  end
31
19
  end
32
20
  end
@@ -1,12 +1,8 @@
1
1
  module SpreeCmCommissioner
2
2
  class DynamicFieldOption < SpreeCmCommissioner::Base
3
3
  belongs_to :dynamic_field, class_name: 'SpreeCmCommissioner::DynamicField', optional: false
4
- has_many :guest_dynamic_fields, class_name: 'SpreeCmCommissioner::GuestDynamicField', dependent: :restrict_with_error
5
-
6
- enum status: { active: 0, draft: 1, archived: 2 }
7
4
 
8
5
  validates :value, presence: true, uniqueness: { scope: :dynamic_field_id }
9
- validates :status, presence: true
10
6
  validate :parent_field_must_be_selection_type
11
7
 
12
8
  private
@@ -14,7 +10,7 @@ module SpreeCmCommissioner
14
10
  def parent_field_must_be_selection_type
15
11
  return unless dynamic_field
16
12
 
17
- return if dynamic_field.requires_dynamic_field_options?
13
+ return if dynamic_field.selection?
18
14
 
19
15
  errors.add(:dynamic_field, 'must be a selection type field')
20
16
  end
@@ -2,11 +2,9 @@ module SpreeCmCommissioner
2
2
  class GuestDynamicField < SpreeCmCommissioner::Base
3
3
  belongs_to :guest, class_name: 'SpreeCmCommissioner::Guest', optional: false
4
4
  belongs_to :dynamic_field, class_name: 'SpreeCmCommissioner::DynamicField', optional: false
5
- belongs_to :dynamic_field_option, class_name: 'SpreeCmCommissioner::DynamicFieldOption', optional: true
6
5
 
7
6
  validates :value, presence: true
8
7
  validate :validate_value_format, if: -> { value.present? && dynamic_field.present? }
9
- validate :validate_option_reference, if: -> { dynamic_field_option.present? }
10
8
 
11
9
  private
12
10
 
@@ -14,30 +12,14 @@ module SpreeCmCommissioner
14
12
  return if dynamic_field.blank?
15
13
 
16
14
  case dynamic_field.data_type.to_s
17
- when 'number'
15
+ when 'integer'
18
16
  errors.add(:value, 'must be a number') unless value.to_s.match?(/\A\d+\z/)
19
17
  when 'boolean'
20
- errors.add(:value, 'must be true or false') unless %w[true false].include?(value.to_s.downcase)
21
- when 'checkbox', 'radio', 'selection'
22
- validate_option_value
23
- end
24
- end
25
-
26
- def validate_option_value
27
- if dynamic_field_option.present?
28
- self.value ||= dynamic_field_option.value
29
- else
18
+ errors.add(:value, 'must be true or false') unless %w[true false 1 0].include?(value.to_s.downcase)
19
+ when 'checkbox', 'radio'
30
20
  valid_options = dynamic_field.dynamic_field_options.pluck(:id).map(&:to_s)
31
21
  errors.add(:value, 'is not a valid option') unless valid_options.include?(value)
32
22
  end
33
23
  end
34
-
35
- def validate_option_reference
36
- return if dynamic_field.blank? || dynamic_field_option.blank?
37
-
38
- return if dynamic_field_option.dynamic_field_id == dynamic_field_id
39
-
40
- errors.add(:dynamic_field_option, 'must belong to the same dynamic field')
41
- end
42
24
  end
43
25
  end
@@ -2,7 +2,9 @@ module SpreeCmCommissioner
2
2
  module V2
3
3
  module Storefront
4
4
  class DynamicFieldOptionSerializer < BaseSerializer
5
- attributes :id, :value, :dynamic_field_id, :status, :created_at, :updated_at
5
+ set_type :dynamic_field_option
6
+
7
+ attributes :id, :value, :dynamic_field_id, :created_at, :updated_at
6
8
  end
7
9
  end
8
10
  end
@@ -2,7 +2,9 @@ module SpreeCmCommissioner
2
2
  module V2
3
3
  module Storefront
4
4
  class DynamicFieldSerializer < BaseSerializer
5
- attributes :id, :label, :data_type, :vendor_id, :multiple_select, :created_at, :updated_at
5
+ set_type :dynamic_field
6
+
7
+ attributes :id, :label, :data_type, :vendor_id, :created_at, :updated_at
6
8
 
7
9
  has_many :dynamic_field_options, serializer: SpreeCmCommissioner::V2::Storefront::DynamicFieldOptionSerializer
8
10
  end
@@ -4,10 +4,9 @@ module SpreeCmCommissioner
4
4
  class GuestDynamicFieldSerializer < BaseSerializer
5
5
  set_type :guest_dynamic_field
6
6
 
7
- attributes :id, :value, :guest_id, :dynamic_field_id, :dynamic_field_option_id, :created_at, :updated_at
7
+ attributes :id, :value, :guest_id, :dynamic_field_id, :created_at, :updated_at
8
8
 
9
9
  belongs_to :dynamic_field, serializer: SpreeCmCommissioner::V2::Storefront::DynamicFieldSerializer
10
- belongs_to :dynamic_field_option, serializer: SpreeCmCommissioner::V2::Storefront::DynamicFieldOptionSerializer
11
10
  end
12
11
  end
13
12
  end
@@ -1,5 +1,5 @@
1
1
  module SpreeCmCommissioner
2
- VERSION = '1.17.0-pre7'.freeze
2
+ VERSION = '1.17.0'.freeze
3
3
 
4
4
  module_function
5
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_cm_commissioner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.0.pre.pre7
4
+ version: 1.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - You
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-04 00:00:00.000000000 Z
11
+ date: 2025-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree
@@ -2517,9 +2517,6 @@ files:
2517
2517
  - db/migrate/20250611023548_add_country_code_to_guests.rb
2518
2518
  - db/migrate/20250612035937_add_intel_phone_number_to_guests.rb
2519
2519
  - db/migrate/20250616084219_add_description_to_cm_vendor_place.rb
2520
- - db/migrate/20250701093203_add_configurations_to_cm_dynamic_field.rb
2521
- - db/migrate/20250702091305_add_dynamic_field_option_to_guest_dynamic_field.rb
2522
- - db/migrate/20250702091935_add_status_to_dynamic_field_option.rb
2523
2520
  - docker-compose.yml
2524
2521
  - docs/option_types/attr_types.md
2525
2522
  - docs/private_key.pem
@@ -2672,9 +2669,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
2672
2669
  version: '2.7'
2673
2670
  required_rubygems_version: !ruby/object:Gem::Requirement
2674
2671
  requirements:
2675
- - - ">"
2672
+ - - ">="
2676
2673
  - !ruby/object:Gem::Version
2677
- version: 1.3.1
2674
+ version: '0'
2678
2675
  requirements:
2679
2676
  - none
2680
2677
  rubygems_version: 3.4.1
@@ -1,6 +0,0 @@
1
- class AddConfigurationsToCmDynamicField < ActiveRecord::Migration[7.0]
2
- def change
3
- add_column :cm_dynamic_fields, :configurations, :jsonb, default: {}, null: false, if_not_exists: true
4
- add_index :cm_dynamic_fields, :configurations, if_not_exists: true
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- class AddDynamicFieldOptionToGuestDynamicField < ActiveRecord::Migration[7.0]
2
- def change
3
- add_reference :cm_guest_dynamic_fields, :dynamic_field_option, index: true, foreign_key: { to_table: :cm_dynamic_field_options }, if_not_exists: true
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class AddStatusToDynamicFieldOption < ActiveRecord::Migration[7.0]
2
- def change
3
- add_column :cm_dynamic_field_options, :status, :integer, default: 0, if_not_exists: true
4
- end
5
- end