Add business_address form to business details section

This commit is contained in:
Nihal Mohammed
2021-07-26 19:24:57 +05:30
committed by Nihal M. Kelanthodika
parent 26c7cb2bd3
commit 7096667c6f
3 changed files with 48 additions and 1 deletions

View File

@@ -13,7 +13,9 @@ module Spree
has_one :enterprise, dependent: :restrict_with_exception
has_many :shipments
validates :firstname, :lastname, :address1, :city, :country, presence: true
validates :address1, :city, presence: true
validates :firstname, :lastname, presence: true, unless: -> { :company.present? }
validates :company, presence: true, unless: -> { :firstname.present? || :lastname.present? }
validates :zipcode, presence: true, if: :require_zipcode?
validate :state_validate

View File

@@ -0,0 +1,40 @@
.row
.three.columns.alpha
= bf.label :company, t(:Company_legal_name)
.eight.columns.omega
= bf.text_field :company, { placeholder: t(:legal_name_placeholder) }
.row
.three.columns.alpha
= bf.label :address1, t(:address)
.eight.columns.omega
= bf.text_field :address1, { placeholder: t(:address_placeholder) }
.row
.alpha.three.columns
= bf.label :address2, t(:address2)
.eight.columns.omega
= bf.text_field :address2
.row
.three.columns.alpha
= bf.label :city, t(:city)
\/
= bf.label :zipcode, t(:postcode)
.four.columns
= bf.text_field :city, { placeholder: t(:city_placeholder) }
.four.columns.omega
= bf.text_field :zipcode, { placeholder: t(:postcode_placeholder) }
.row
.three.columns.alpha
= bf.label :state_id, t(:state)
\/
= bf.label :country_id, t(:country)
.four.columns{ "ng-controller" => "countryCtrl" }
%input.ofn-select2.fullwidth#enterprise_address_attributes_state_id{ name: 'enterprise[address_attributes][state_id]', type: 'number', data: 'countriesById[Enterprise.address.country_id].states', placeholder: t('admin.choose'), ng: { model: 'Enterprise.address.state_id' } }
.four.columns.omega{ "ng-controller" => "countryCtrl" }
%input.ofn-select2.fullwidth#enterprise_address_attributes_country_id{ name: 'enterprise[address_attributes][country_id]', type: 'number', data: 'countries', placeholder: t('admin.choose'), ng: { model: 'Enterprise.address.country_id' } }
.row
.three.columns.alpha
= bf.label :phone, t(:legal_phone_number)
.eight.columns.omega
= bf.text_field :phone, { placeholder: t(:phone_placeholder) }

View File

@@ -47,3 +47,8 @@
.pad-top
%a.button.red{ href: '', ng: {click: 'removeTermsAndConditions()', if: 'Enterprise.terms_and_conditions'} }
= t('.remove_terms_and_conditions')
= f.fields_for :business_address, @enterprise.business_address || @enterprise.build_business_address do |bf|
%legend {{business_address.label}}
= render 'admin/enterprises/form/business_address', bf: bf