If enterprise has a white_label_logo attached, then can edit its link

This commit is contained in:
Jean-Baptiste Bellet
2023-03-20 15:32:26 +01:00
committed by Konrad
parent 70a6e9f44b
commit 35778ecf1d
4 changed files with 32 additions and 11 deletions

View File

@@ -35,7 +35,7 @@ module PermittedAttributes
:show_customer_names_to_suppliers, :preferred_shopfront_product_sorting_method,
:preferred_invoice_order_by_supplier,
:preferred_product_low_stock_display,
:hide_ofn_navigation, :white_label_logo,
:hide_ofn_navigation, :white_label_logo, :white_label_logo_link
]
end
end

View File

@@ -6,18 +6,26 @@
.three.columns
= f.check_box :hide_ofn_navigation, { "data-controller": "checkbox-display", "data-checkbox-display-target-id-value": "white_label_logo" }
.row{id: "white_label_logo"}
.three.columns.alpha
= f.label :white_label_logo, t('.upload_logo')
.three.columns
= image_tag @object.white_label_logo_url if @object.white_label_logo.present?
= f.file_field :white_label_logo, accept: "image/*"
- if @object.white_label_logo.variable?
%button.button.small{ type: "button", "data-controller": "modal-link", "data-action": "click->modal-link#open", "data-modal-link-target-value": "remove_logo" }
= t('.remove_logo')
%div{id: "white_label_logo"}
.row
.three.columns.alpha
= f.label :white_label_logo, t('.upload_logo')
.three.columns
= image_tag @object.white_label_logo_url if @object.white_label_logo.present?
= f.file_field :white_label_logo, accept: "image/*"
- if @object.white_label_logo.present?
%button.button.small{ type: "button", "data-controller": "modal-link", "data-action": "click->modal-link#open", "data-modal-link-target-value": "remove_logo" }
= t('.remove_logo')
- if @object.white_label_logo.present?
.row
.three.columns.alpha
= f.label :white_label_logo_link, t('.white_label_logo_link_label')
.three.columns
= f.text_field :white_label_logo_link
- if @object.white_label_logo.variable?
- if @object.white_label_logo.present?
= render ConfirmModalComponent.new(id: "remove_logo", confirm_reflexes: "click->WhiteLabel#remove_logo" ) do
.margin-bottom-30
= t('.remove_logo_confirm')

View File

@@ -1165,6 +1165,7 @@ en:
remove_logo: "Remove logo"
remove_logo_confirm: "Are you sure you want to remove this logo?"
remove_logo_success: "Logo removed"
white_label_logo_link_label: "Link for the logo used in shopfront"
actions:
edit_profile: Settings
properties: Properties

View File

@@ -696,6 +696,10 @@ describe '
expect(distributor1.reload.white_label_logo_blob.filename).to eq("logo-white.png")
end
it "does not show the white label logo link field" do
expect(page).not_to have_field "white_label_logo_link"
end
context "when enterprise has a white label logo" do
before do
distributor1.update white_label_logo: white_logo_file
@@ -717,6 +721,14 @@ describe '
distributor1.reload
expect(distributor1.white_label_logo).to_not be_attached
end
it "can edit the text field white_label_logo_link" do
fill_in "enterprise_white_label_logo_link", with: "https://www.openfoodnetwork.org"
click_button 'Update'
expect(flash_message)
.to eq('Enterprise "First Distributor" has been successfully updated!')
expect(distributor1.reload.white_label_logo_link).to eq("https://www.openfoodnetwork.org")
end
end
end
end