solidus_bling 3.4.5 → 3.4.6

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: 86fb55a042d40aa34d5eaf3c1dc697d189a8ab9d5bdf551410871eb002b816bd
4
- data.tar.gz: b95270aa77365172bdab967704f0ad64ee4e3b26cef5daed44a007c80fd5892e
3
+ metadata.gz: 96ae26320b68f766dc44bb621d62ea6588edca4942dd652e27f9db773b3746a7
4
+ data.tar.gz: 3cc77c798db3a3e13fae2af0825d3ab9f1c11b9cec025873d7858a47bbb8ad75
5
5
  SHA512:
6
- metadata.gz: 64986dd4c0f9177c8ae667c8414d6b28e4aad0c0e821f614241c29ae426ebb8325993c0c3e4943dd8b7b7a1e2ce64bffc82a069de49c0faec72aca5cf141d536
7
- data.tar.gz: f76a22b611035be87d7a326bb67441807df7b4ef115be32454a4b93691abc14b2716f0d929ab35a02a095400fe62a0bbad4b7c857bf00944d4f44aa402fab858
6
+ metadata.gz: e84e85d97a04a3515d3dda9d97e46f8fe947bf15590d315f4fef2a4972d3804c903244e074e041e270d635015db561a1c72a62514ad7de8d25ca5ffeef3bce2e
7
+ data.tar.gz: 4cf11ba85c9efe1315a498ef9bde72528ee84de38c4768ee416d2bc222adf9897ebb50def3d382e5cd21728441cbaa41f361af7d8c25df31a7ae362b69053d50
@@ -38,9 +38,11 @@ module Spree
38
38
  def edit
39
39
  @payment_methods = ::Spree::PaymentMethod.all.pluck(:name, :id)
40
40
  @shipping_methods = ::Spree::ShippingMethod.all.pluck(:name, :id)
41
+ @sellers = @bling_account.sellers.actives.order(:name).pluck(:name, :id)
41
42
  end
42
43
 
43
44
  def update
45
+ @bling_account.sellers.find_by_id(params[:account]["default_seller"]).update(default: true)
44
46
  @bling_account.update account_params
45
47
  redirect_to edit_admin_solidus_bling_account_path(@bling_account.id)
46
48
  end
@@ -2,8 +2,8 @@ module SolidusBling
2
2
  class Seller < ApplicationRecord
3
3
  validates :name, presence: true
4
4
  validates :external_id, presence: true
5
-
6
5
  belongs_to :account
6
+ after_save :falsify_all_others
7
7
 
8
8
  def self.upsert_sellers account
9
9
  account.check_token
@@ -30,5 +30,9 @@ module SolidusBling
30
30
  sellers_inactive = where(external_id: ids_sellers_inactive)
31
31
  sellers_inactive.update_all(active: false)
32
32
  end
33
+
34
+ def falsify_all_others
35
+ self.class.where("id != ?", id).update(default: false) if default
36
+ end
33
37
  end
34
38
  end
@@ -119,16 +119,20 @@
119
119
  <% end %>
120
120
  </fieldset>
121
121
 
122
- <fieldset class="no-border-top text-center">
123
- <legend>
124
- Vendedor padrão
125
- </legend>
126
- <% if bling_account.sellers.default %>
127
- <span><%= bling_account.sellers.default.name %></span>
128
- <% else %>
129
- <span>Vendedor padrão não selecionado</span>
130
- <% end %>
131
- </fieldset>
122
+ <% if @sellers %>
123
+ <fieldset class="no-border-top text-center">
124
+ <legend>
125
+ Vendedor padrão
126
+ </legend>
127
+ <div class="col-12 col-md-6 mx-auto">
128
+ <div class="field">
129
+ <%= form.select "default_seller", @sellers, {selected: ::SolidusBling::Seller.default&.id, include_blank: true }, { class: "custom-select fullwidth" } %>
130
+ </div>
131
+ </div>
132
+
133
+ </fieldset>
134
+ <% end %>
135
+
132
136
 
133
137
 
134
138
  <div class="form-buttons filter-actions actions" data-hook="buttons">
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusBling
4
- VERSION = "3.4.5"
4
+ VERSION = "3.4.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_bling
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.5
4
+ version: 3.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todas Essas Coisas