From 3cd5ed58c03bb9d35fba56b255caeca2c7af2084 Mon Sep 17 00:00:00 2001 From: Nihal Mohammed Date: Tue, 10 Aug 2021 15:54:47 +0530 Subject: [PATCH] Add checkbox to clear business_address form --- app/models/enterprise.rb | 2 +- app/services/permitted_attributes/business_address.rb | 2 +- .../admin/enterprises/form/_business_address.html.haml | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index efc9763c98..b394f2bca7 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -60,7 +60,7 @@ class Enterprise < ApplicationRecord delegate :latitude, :longitude, :city, :state_name, to: :address accepts_nested_attributes_for :address - accepts_nested_attributes_for :business_address + accepts_nested_attributes_for :business_address, allow_destroy: true accepts_nested_attributes_for :producer_properties, allow_destroy: true, reject_if: lambda { |pp| pp[:property_name].blank? diff --git a/app/services/permitted_attributes/business_address.rb b/app/services/permitted_attributes/business_address.rb index 2d04223143..2a4154e7ea 100644 --- a/app/services/permitted_attributes/business_address.rb +++ b/app/services/permitted_attributes/business_address.rb @@ -6,7 +6,7 @@ module PermittedAttributes [ :company, :address1, :address2, :city, :country_id, :state_id, :zipcode, - :phone + :phone, :_destroy ] end end diff --git a/app/views/admin/enterprises/form/_business_address.html.haml b/app/views/admin/enterprises/form/_business_address.html.haml index 547d98e1d7..f44f606442 100644 --- a/app/views/admin/enterprises/form/_business_address.html.haml +++ b/app/views/admin/enterprises/form/_business_address.html.haml @@ -39,3 +39,9 @@ = bf.label :phone, t(".legal_phone_number") .eight.columns.omega = bf.text_field :phone, { placeholder: t(".phone_placeholder") } + +.row + .three.columns.alpha + = bf.label :clear + .eight.columns.omega + = bf.check_box :_destroy