From a2bc61475bc1300cb391a750474d2bfe03b8069c Mon Sep 17 00:00:00 2001 From: Arthur Vieira Date: Fri, 3 Jun 2022 11:15:27 -0300 Subject: [PATCH 01/11] Add whatsapp_phone column to enterprises --- .../20220603140943_add_whatsapp_phone_to_enterprises.rb | 7 +++++++ db/schema.rb | 1 + 2 files changed, 8 insertions(+) create mode 100644 db/migrate/20220603140943_add_whatsapp_phone_to_enterprises.rb diff --git a/db/migrate/20220603140943_add_whatsapp_phone_to_enterprises.rb b/db/migrate/20220603140943_add_whatsapp_phone_to_enterprises.rb new file mode 100644 index 0000000000..e830ca4d5d --- /dev/null +++ b/db/migrate/20220603140943_add_whatsapp_phone_to_enterprises.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddWhatsappPhoneToEnterprises < ActiveRecord::Migration[6.1] + def change + add_column :enterprises, :whatsapp_phone, :string, limit: 255 + end +end diff --git a/db/schema.rb b/db/schema.rb index acee8ae142..9494745876 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -241,6 +241,7 @@ ActiveRecord::Schema.define(version: 2022_06_21_230907) do t.integer "business_address_id" t.boolean "show_customer_names_to_suppliers", default: false, null: false t.string "visible", limit: 255, default: "public", null: false + t.string "whatsapp_phone", limit: 255 t.index ["address_id"], name: "index_enterprises_on_address_id" t.index ["is_primary_producer", "sells"], name: "index_enterprises_on_is_primary_producer_and_sells" t.index ["name"], name: "index_enterprises_on_name", unique: true From b565b6ba4d71f19a29a8ec164e64da199569f68e Mon Sep 17 00:00:00 2001 From: Arthur Vieira Date: Fri, 3 Jun 2022 19:00:57 -0300 Subject: [PATCH 02/11] Add whatsapp_phone to permitted attributes Allows creating and updating the enterprise's WhatsApp phone number in the registration form and contact edit views. --- app/services/permitted_attributes/enterprise.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/permitted_attributes/enterprise.rb b/app/services/permitted_attributes/enterprise.rb index 2c7346eaf7..f651edf77a 100644 --- a/app/services/permitted_attributes/enterprise.rb +++ b/app/services/permitted_attributes/enterprise.rb @@ -24,7 +24,7 @@ module PermittedAttributes def self.basic_permitted_attributes [ - :id, :name, :visible, :permalink, :owner_id, :contact_name, :email_address, :phone, + :id, :name, :visible, :permalink, :owner_id, :contact_name, :email_address, :phone, :whatsapp_phone, :is_primary_producer, :sells, :website, :facebook, :instagram, :linkedin, :twitter, :description, :long_description, :logo, :promo_image, :terms_and_conditions, :allow_guest_orders, :allow_order_changes, :require_login, :enable_subscriptions, From 62ee3c2de1ad09f5b86fbd97c58e1a65a0097bb4 Mon Sep 17 00:00:00 2001 From: Arthur Vieira Date: Fri, 3 Jun 2022 19:15:56 -0300 Subject: [PATCH 03/11] Add admin view field for whatsapp number Creates a field and tooltip in /admin/enterprises//edit#!/contact for updating the enterprise's WhatsApp phone number, with corresponding i18n keys for the name of the field, placeholder and tooltip text. --- app/views/admin/enterprises/form/_contact.html.haml | 7 +++++++ config/locales/en.yml | 3 +++ 2 files changed, 10 insertions(+) diff --git a/app/views/admin/enterprises/form/_contact.html.haml b/app/views/admin/enterprises/form/_contact.html.haml index 61f7eb341d..cfcc19a417 100644 --- a/app/views/admin/enterprises/form/_contact.html.haml +++ b/app/views/admin/enterprises/form/_contact.html.haml @@ -15,6 +15,13 @@ = f.label :phone, t('.phone') .omega.eight.columns = f.text_field :phone, { placeholder: t('.phone_placeholder') } +.row + .alpha.three.columns + = f.label :whatsapp_phone, t('.whatsapp_phone') + %div{'ofn-with-tip' => t('.whatsapp_phone_tip')} + %a= t('admin.whats_this') + .omega.eight.columns + = f.text_field :whatsapp_phone, { placeholder: t('.whatsapp_phone_placeholder') } .row .alpha.three.columns = f.label :website, t('.website') diff --git a/config/locales/en.yml b/config/locales/en.yml index 7a00eac98e..b7df81ed95 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -888,6 +888,9 @@ en: email_address_tip: "This email address will be displayed in your public profile" phone: Phone phone_placeholder: eg. 98 7654 3210 + whatsapp_phone: WhatsApp phone number + whatsapp_phone_placeholder: eg. +61 4 9876 5432 + whatsapp_phone_tip: "This number will be displayed in your public profile to be opened as a WhatsApp link." website: Website website_placeholder: eg. www.truffles.com enterprise_fees: From 79e762a815e841a31d0964b184cecf2fe1926c4d Mon Sep 17 00:00:00 2001 From: Arthur Vieira Date: Fri, 3 Jun 2022 19:28:46 -0300 Subject: [PATCH 04/11] Add whatsapp number to registration form Creates a field on the contact step of the enterprise registration form to create an enterprise with a WhatsApp phone number, with corresponding i18n keys for the field's name and placeholder text. --- app/views/registration/steps/_contact.html.haml | 4 ++++ config/locales/en.yml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/app/views/registration/steps/_contact.html.haml b/app/views/registration/steps/_contact.html.haml index eed9c25c73..b77f263554 100644 --- a/app/views/registration/steps/_contact.html.haml +++ b/app/views/registration/steps/_contact.html.haml @@ -24,6 +24,10 @@ .small-12.columns.field %label{ for: 'enterprise_phone' }= t(".phone_field")+":" %input.chunky.small-12.columns{ id: 'enterprise_phone', name: 'phone', placeholder: "{{'registration.steps.contact.phone_field_placeholder' | t}}", ng: { model: 'enterprise.phone' } } + .row + .small-12.columns.field + %label{ "for" => 'enterprise_whatsapp_phone', 'data-toggle' => "tooltip", 'title' => "Disabled tooltip" }= t(".whatsapp_phone_field")+":" + %input.chunky.small-12.columns{ id: 'enterprise_whatsapp_phone', name: 'whatsapp_phone', placeholder: "{{'registration.steps.contact.whatsapp_phone_field_placeholder' | t}}", ng: { model: 'enterprise.whatsapp_phone' } } .small-12.medium-12.large-5.hide-for-small-only .row.buttons diff --git a/config/locales/en.yml b/config/locales/en.yml index b7df81ed95..193868da43 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2336,7 +2336,9 @@ See the %{link} to find out more about %{sitename}'s features and to start using contact_field_placeholder: "Contact Name" contact_field_required: "You need to enter a primary contact." phone_field: "Phone number" + whatsapp_phone_field: "WhatsApp phone number" phone_field_placeholder: "eg. (03) 1234 5678" + whatsapp_phone_field_placeholder: "eg. +61 4 1234 5678" type: title: "Type" headline: "Last step to add %{enterprise}!" From 77360f41af237be550d05acd8b97a77cfd773199 Mon Sep 17 00:00:00 2001 From: Arthur Vieira Date: Fri, 3 Jun 2022 19:33:55 -0300 Subject: [PATCH 05/11] Show WhatsApp link on contact modal on map Strips '+' and ' ' characters from the phone number for the generated link, but doesn't guarantee the link is valid because the number registered isn't validated for now. --- .../javascripts/templates/partials/contact.html.haml | 5 ++++- app/models/enterprise.rb | 8 ++++++++ app/serializers/api/cached_enterprise_serializer.rb | 2 +- app/serializers/api/enterprise_shopfront_serializer.rb | 6 +++--- app/services/permitted_attributes/enterprise.rb | 10 +++++----- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/templates/partials/contact.html.haml b/app/assets/javascripts/templates/partials/contact.html.haml index 58c8c4a64d..e0150ce65b 100644 --- a/app/assets/javascripts/templates/partials/contact.html.haml +++ b/app/assets/javascripts/templates/partials/contact.html.haml @@ -1,8 +1,11 @@ %div.contact-container - %div.modal-centered{"ng-if" => "::enterprise.email_address || enterprise.website || enterprise.phone"} + %div.modal-centered{"ng-if" => "::enterprise.email_address || enterprise.website || enterprise.phone || enterprise.whatsapp_phone"} %p.modal-header {{'contact' | t}} %p{"ng-if" => "::enterprise.phone", "ng-bind" => "::enterprise.phone"} + %p{"ng-if" => "::enterprise.whatsapp_phone"} + %a{"ng-href" => "http://wa.me/{{::enterprise.whatsapp_phone}}", target: "_blank", "ng-bind" => "::enterprise.whatsapp_phone"} + %p{"ng-if" => "::enterprise.email_address"} %a{"ng-href" => "{{::enterprise.email_address | stripUrl}}", target: "_blank", mailto: true} %span.obfuscatedEmail.email{"ng-bind" => "::enterprise.email_address | stripUrl"} diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index aa7edfc960..91ccf04a66 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -312,6 +312,10 @@ class Enterprise < ApplicationRecord correct_instagram_url self[:instagram] end + def whatsapp_phone + correct_whatsapp_phone self[:whatsapp_phone] + end + def inventory_variants if prefers_product_selection_from_inventory_only? Spree::Variant.visible_for(self) @@ -448,6 +452,10 @@ class Enterprise < ApplicationRecord url&.sub(%r{(https?://)?}, '') end + def correct_whatsapp_phone(phone_number) + phone_number&.tr('+ ', '') + end + def correct_instagram_url(url) url && strip_url(url).sub(%r{www.instagram.com/}, '').delete("@") end diff --git a/app/serializers/api/cached_enterprise_serializer.rb b/app/serializers/api/cached_enterprise_serializer.rb index ef6b37c9cf..846a56896a 100644 --- a/app/serializers/api/cached_enterprise_serializer.rb +++ b/app/serializers/api/cached_enterprise_serializer.rb @@ -14,7 +14,7 @@ module Api attributes :name, :id, :description, :latitude, :longitude, :long_description, :website, :instagram, :linkedin, :twitter, - :facebook, :is_primary_producer, :is_distributor, :phone, :visible, + :facebook, :is_primary_producer, :is_distributor, :phone, :whatsapp_phone, :visible, :email_address, :hash, :logo, :promo_image, :path, :pickup, :delivery, :icon, :icon_font, :producer_icon_font, :category diff --git a/app/serializers/api/enterprise_shopfront_serializer.rb b/app/serializers/api/enterprise_shopfront_serializer.rb index 894152778f..5ee13b3544 100644 --- a/app/serializers/api/enterprise_shopfront_serializer.rb +++ b/app/serializers/api/enterprise_shopfront_serializer.rb @@ -7,9 +7,9 @@ module Api attributes :name, :id, :description, :latitude, :longitude, :long_description, :website, :instagram, :linkedin, :twitter, :facebook, :is_primary_producer, :is_distributor, - :phone, :visible, :email_address, :hash, :logo, :promo_image, :path, :category, - :active, :producers, :orders_close_at, :hubs, :taxons, :supplied_taxons, :pickup, - :delivery, :preferred_product_low_stock_display + :phone, :whatsapp_phone, :visible, :email_address, :hash, :logo, :promo_image, :path, + :category, :active, :producers, :orders_close_at, :hubs, :taxons, :supplied_taxons, + :pickup, :delivery, :preferred_product_low_stock_display has_one :address, serializer: Api::AddressSerializer has_many :supplied_properties, serializer: Api::PropertySerializer diff --git a/app/services/permitted_attributes/enterprise.rb b/app/services/permitted_attributes/enterprise.rb index f651edf77a..5aff8fbb76 100644 --- a/app/services/permitted_attributes/enterprise.rb +++ b/app/services/permitted_attributes/enterprise.rb @@ -24,11 +24,11 @@ module PermittedAttributes def self.basic_permitted_attributes [ - :id, :name, :visible, :permalink, :owner_id, :contact_name, :email_address, :phone, :whatsapp_phone, - :is_primary_producer, :sells, :website, :facebook, :instagram, :linkedin, :twitter, - :description, :long_description, :logo, :promo_image, :terms_and_conditions, - :allow_guest_orders, :allow_order_changes, :require_login, :enable_subscriptions, - :abn, :acn, :charges_sales_tax, :display_invoice_logo, :invoice_text, + :id, :name, :visible, :permalink, :owner_id, :contact_name, :email_address, :phone, + :whatsapp_phone, :is_primary_producer, :sells, :website, :facebook, :instagram, :linkedin, + :twitter, :description, :long_description, :logo, :promo_image, :terms_and_conditions, + :allow_guest_orders, :allow_order_changes, :require_login, :enable_subscriptions, :abn, + :acn, :charges_sales_tax, :display_invoice_logo, :invoice_text, :preferred_product_selection_from_inventory_only, :preferred_shopfront_message, :preferred_shopfront_closed_message, :preferred_shopfront_taxon_order, :preferred_shopfront_producer_order, :preferred_shopfront_order_cycle_order, From cace62a71843795671e2d2f7f9d57e1d0738de90 Mon Sep 17 00:00:00 2001 From: Arthur Vieira Date: Mon, 6 Jun 2022 11:10:02 -0300 Subject: [PATCH 06/11] Add producer whatsapp link to producers list Adds WhatsApp number with wa.me link between phone number and e-mail address in the producers list profile. --- app/views/producers/_fat.html.haml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/producers/_fat.html.haml b/app/views/producers/_fat.html.haml index 54e7c7298a..0037b0992f 100644 --- a/app/views/producers/_fat.html.haml +++ b/app/views/producers/_fat.html.haml @@ -38,6 +38,10 @@ = t :producers_contact_phone %span{"ng-bind" => "::producer.phone"} + %p.word-wrap{"ng-if" => "::producer.whatsapp_phone"} + %a{"ng-href" => "http://wa.me/{{::producer.whatsapp_phone}}", target: "_blank"} + %span{"ng-bind" => "::producer.whatsapp_phone"} + %p.word-wrap{"ng-if" => "::producer.email_address"} %a{"ng-href" => "{{::producer.email_address | stripUrl}}", target: "_blank", mailto: true} %span.obfuscatedEmail.email{"ng-bind" => "::producer.email_address | stripUrl"} From 624485ff25d370220832465d51108df02d12c7ac Mon Sep 17 00:00:00 2001 From: Arthur Vieira Date: Mon, 6 Jun 2022 11:55:40 -0300 Subject: [PATCH 07/11] Add whatsapp link to contact tab view --- app/views/shopping_shared/tabs/_contact.html.haml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/shopping_shared/tabs/_contact.html.haml b/app/views/shopping_shared/tabs/_contact.html.haml index cf8cf6da5f..769c10cdac 100644 --- a/app/views/shopping_shared/tabs/_contact.html.haml +++ b/app/views/shopping_shared/tabs/_contact.html.haml @@ -18,7 +18,7 @@ = current_distributor.address.zipcode .small-12.large-4.columns - - if current_distributor.website || current_distributor.email_address || current_distributor.phone + - if current_distributor.website || current_distributor.email_address || current_distributor.phone || current_distributor.whatsapp_phone %div.center .header = t :shopping_contact_web @@ -26,6 +26,10 @@ - if current_distributor.phone.present? = current_distributor.phone %br + - if current_distributor.whatsapp_phone.present? + %a{href: "https://wa.me/#{current_distributor.whatsapp_phone}", target: "_blank" } + = current_distributor.whatsapp_phone + %br - if current_distributor.website.present? %a{href: "http://#{current_distributor.website}", target: "_blank" } = current_distributor.website From 0deb3cd782ab16a5db0edd37e685685003414ec1 Mon Sep 17 00:00:00 2001 From: Arthur Vieira Date: Wed, 8 Jun 2022 11:37:35 -0300 Subject: [PATCH 08/11] Replace url generation with 'whatsapp_url' method As suggested by mkllnk's following comment: https://github.com/openfoodfoundation/openfoodnetwork/pull/9236/commits/1eda7d8a4cf5fa4f1beed51be75a2e205340ac39#r890656117 --- .../javascripts/templates/partials/contact.html.haml | 2 +- app/models/enterprise.rb | 8 ++++---- app/serializers/api/cached_enterprise_serializer.rb | 6 +++--- app/serializers/api/enterprise_shopfront_serializer.rb | 6 +++--- app/views/producers/_fat.html.haml | 2 +- app/views/shopping_shared/tabs/_contact.html.haml | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/templates/partials/contact.html.haml b/app/assets/javascripts/templates/partials/contact.html.haml index e0150ce65b..72ea06b9d6 100644 --- a/app/assets/javascripts/templates/partials/contact.html.haml +++ b/app/assets/javascripts/templates/partials/contact.html.haml @@ -4,7 +4,7 @@ %p{"ng-if" => "::enterprise.phone", "ng-bind" => "::enterprise.phone"} %p{"ng-if" => "::enterprise.whatsapp_phone"} - %a{"ng-href" => "http://wa.me/{{::enterprise.whatsapp_phone}}", target: "_blank", "ng-bind" => "::enterprise.whatsapp_phone"} + %a{"ng-href" => "{{::enterprise.whatsapp_url}}", target: "_blank", "ng-bind" => "::enterprise.whatsapp_phone"} %p{"ng-if" => "::enterprise.email_address"} %a{"ng-href" => "{{::enterprise.email_address | stripUrl}}", target: "_blank", mailto: true} diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 91ccf04a66..5d7892f3ee 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -312,8 +312,8 @@ class Enterprise < ApplicationRecord correct_instagram_url self[:instagram] end - def whatsapp_phone - correct_whatsapp_phone self[:whatsapp_phone] + def whatsapp_url + correct_whatsapp_url self[:whatsapp_phone] end def inventory_variants @@ -452,8 +452,8 @@ class Enterprise < ApplicationRecord url&.sub(%r{(https?://)?}, '') end - def correct_whatsapp_phone(phone_number) - phone_number&.tr('+ ', '') + def correct_whatsapp_url(phone_number) + phone_number && "https://wa.me/" + phone_number.tr('+ ', '') end def correct_instagram_url(url) diff --git a/app/serializers/api/cached_enterprise_serializer.rb b/app/serializers/api/cached_enterprise_serializer.rb index 846a56896a..bef58f0c77 100644 --- a/app/serializers/api/cached_enterprise_serializer.rb +++ b/app/serializers/api/cached_enterprise_serializer.rb @@ -14,9 +14,9 @@ module Api attributes :name, :id, :description, :latitude, :longitude, :long_description, :website, :instagram, :linkedin, :twitter, - :facebook, :is_primary_producer, :is_distributor, :phone, :whatsapp_phone, :visible, - :email_address, :hash, :logo, :promo_image, :path, :pickup, :delivery, - :icon, :icon_font, :producer_icon_font, :category + :facebook, :is_primary_producer, :is_distributor, :phone, :whatsapp_phone, + :whatsapp_url, :visible, :email_address, :hash, :logo, :promo_image, :path, :pickup, + :delivery, :icon, :icon_font, :producer_icon_font, :category attributes :taxons, :supplied_taxons diff --git a/app/serializers/api/enterprise_shopfront_serializer.rb b/app/serializers/api/enterprise_shopfront_serializer.rb index 5ee13b3544..ae0e30ff66 100644 --- a/app/serializers/api/enterprise_shopfront_serializer.rb +++ b/app/serializers/api/enterprise_shopfront_serializer.rb @@ -7,9 +7,9 @@ module Api attributes :name, :id, :description, :latitude, :longitude, :long_description, :website, :instagram, :linkedin, :twitter, :facebook, :is_primary_producer, :is_distributor, - :phone, :whatsapp_phone, :visible, :email_address, :hash, :logo, :promo_image, :path, - :category, :active, :producers, :orders_close_at, :hubs, :taxons, :supplied_taxons, - :pickup, :delivery, :preferred_product_low_stock_display + :phone, :whatsapp_phone, :whatsapp_url, :visible, :email_address, :hash, :logo, + :promo_image, :path, :category, :active, :producers, :orders_close_at, :hubs, + :taxons, :supplied_taxons, :pickup, :delivery, :preferred_product_low_stock_display has_one :address, serializer: Api::AddressSerializer has_many :supplied_properties, serializer: Api::PropertySerializer diff --git a/app/views/producers/_fat.html.haml b/app/views/producers/_fat.html.haml index 0037b0992f..f99594dea1 100644 --- a/app/views/producers/_fat.html.haml +++ b/app/views/producers/_fat.html.haml @@ -39,7 +39,7 @@ %span{"ng-bind" => "::producer.phone"} %p.word-wrap{"ng-if" => "::producer.whatsapp_phone"} - %a{"ng-href" => "http://wa.me/{{::producer.whatsapp_phone}}", target: "_blank"} + %a{"ng-href" => "{{::producer.whatsapp_url}}", target: "_blank"} %span{"ng-bind" => "::producer.whatsapp_phone"} %p.word-wrap{"ng-if" => "::producer.email_address"} diff --git a/app/views/shopping_shared/tabs/_contact.html.haml b/app/views/shopping_shared/tabs/_contact.html.haml index 769c10cdac..8ba32bee92 100644 --- a/app/views/shopping_shared/tabs/_contact.html.haml +++ b/app/views/shopping_shared/tabs/_contact.html.haml @@ -27,7 +27,7 @@ = current_distributor.phone %br - if current_distributor.whatsapp_phone.present? - %a{href: "https://wa.me/#{current_distributor.whatsapp_phone}", target: "_blank" } + %a{href: "#{current_distributor.whatsapp_url}", target: "_blank" } = current_distributor.whatsapp_phone %br - if current_distributor.website.present? From e483ef8ccd48dc712240f7d62c84521fd8be8694 Mon Sep 17 00:00:00 2001 From: Arthur Vieira Date: Wed, 8 Jun 2022 15:14:57 -0300 Subject: [PATCH 09/11] Fix whatsapp phone tooltip in registration The tooltip on the contact step of the registration form now displays the proper text, which has been added in the source language file. --- app/views/registration/steps/_contact.html.haml | 2 +- config/locales/en.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/registration/steps/_contact.html.haml b/app/views/registration/steps/_contact.html.haml index b77f263554..370101ada3 100644 --- a/app/views/registration/steps/_contact.html.haml +++ b/app/views/registration/steps/_contact.html.haml @@ -26,7 +26,7 @@ %input.chunky.small-12.columns{ id: 'enterprise_phone', name: 'phone', placeholder: "{{'registration.steps.contact.phone_field_placeholder' | t}}", ng: { model: 'enterprise.phone' } } .row .small-12.columns.field - %label{ "for" => 'enterprise_whatsapp_phone', 'data-toggle' => "tooltip", 'title' => "Disabled tooltip" }= t(".whatsapp_phone_field")+":" + %label{ "for" => 'enterprise_whatsapp_phone', 'data-toggle' => "tooltip", 'title' => "{{'registration.steps.contact.whatsapp_phone_tooltip' | t}}" }= t(".whatsapp_phone_field")+":" %input.chunky.small-12.columns{ id: 'enterprise_whatsapp_phone', name: 'whatsapp_phone', placeholder: "{{'registration.steps.contact.whatsapp_phone_field_placeholder' | t}}", ng: { model: 'enterprise.whatsapp_phone' } } .small-12.medium-12.large-5.hide-for-small-only diff --git a/config/locales/en.yml b/config/locales/en.yml index 193868da43..8a1103009e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2337,6 +2337,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using contact_field_required: "You need to enter a primary contact." phone_field: "Phone number" whatsapp_phone_field: "WhatsApp phone number" + whatsapp_phone_tooltip: "This number will be displayed in your public profile to be opened as a WhatsApp link." phone_field_placeholder: "eg. (03) 1234 5678" whatsapp_phone_field_placeholder: "eg. +61 4 1234 5678" type: From 54ec4e5016941aea865ce15acdfdf50becbe4ebb Mon Sep 17 00:00:00 2001 From: Arthur <2237750+arthurtui@users.noreply.github.com> Date: Mon, 20 Jun 2022 10:21:12 -0300 Subject: [PATCH 10/11] Update app/views/shopping_shared/tabs/_contact.html.haml Co-authored-by: Maikel --- app/views/shopping_shared/tabs/_contact.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shopping_shared/tabs/_contact.html.haml b/app/views/shopping_shared/tabs/_contact.html.haml index 8ba32bee92..7c01f96d6e 100644 --- a/app/views/shopping_shared/tabs/_contact.html.haml +++ b/app/views/shopping_shared/tabs/_contact.html.haml @@ -27,7 +27,7 @@ = current_distributor.phone %br - if current_distributor.whatsapp_phone.present? - %a{href: "#{current_distributor.whatsapp_url}", target: "_blank" } + %a{href: current_distributor.whatsapp_url, target: "_blank" } = current_distributor.whatsapp_phone %br - if current_distributor.website.present? From 066879fe629772eadbaeb86c0c537fa9b809cce7 Mon Sep 17 00:00:00 2001 From: Arthur Vieira Date: Wed, 29 Jun 2022 18:52:16 -0300 Subject: [PATCH 11/11] Add icons to whatsapp links Uses the font awesome 4 WhatsApp icon in .svg format (which is under the Open Font License) in the pages where an enterprise's WhatsApp number appears as an hyperlink. --- app/assets/javascripts/templates/partials/contact.html.haml | 1 + app/views/producers/_fat.html.haml | 1 + app/views/shopping_shared/tabs/_contact.html.haml | 1 + app/webpacker/images/social-logos/whatsapp.svg | 2 ++ public/map_icons/social-logos/whatsapp.svg | 2 ++ 5 files changed, 7 insertions(+) create mode 100644 app/webpacker/images/social-logos/whatsapp.svg create mode 100644 public/map_icons/social-logos/whatsapp.svg diff --git a/app/assets/javascripts/templates/partials/contact.html.haml b/app/assets/javascripts/templates/partials/contact.html.haml index 72ea06b9d6..c601f47fd7 100644 --- a/app/assets/javascripts/templates/partials/contact.html.haml +++ b/app/assets/javascripts/templates/partials/contact.html.haml @@ -4,6 +4,7 @@ %p{"ng-if" => "::enterprise.phone", "ng-bind" => "::enterprise.phone"} %p{"ng-if" => "::enterprise.whatsapp_phone"} + %img{ src: image_path("/map_icons/social-logos/whatsapp.svg") } %a{"ng-href" => "{{::enterprise.whatsapp_url}}", target: "_blank", "ng-bind" => "::enterprise.whatsapp_phone"} %p{"ng-if" => "::enterprise.email_address"} diff --git a/app/views/producers/_fat.html.haml b/app/views/producers/_fat.html.haml index f99594dea1..4f10a189fb 100644 --- a/app/views/producers/_fat.html.haml +++ b/app/views/producers/_fat.html.haml @@ -40,6 +40,7 @@ %p.word-wrap{"ng-if" => "::producer.whatsapp_phone"} %a{"ng-href" => "{{::producer.whatsapp_url}}", target: "_blank"} + %img{ src: image_pack_path("social-logos/whatsapp.svg") } %span{"ng-bind" => "::producer.whatsapp_phone"} %p.word-wrap{"ng-if" => "::producer.email_address"} diff --git a/app/views/shopping_shared/tabs/_contact.html.haml b/app/views/shopping_shared/tabs/_contact.html.haml index 7c01f96d6e..cbad4a1966 100644 --- a/app/views/shopping_shared/tabs/_contact.html.haml +++ b/app/views/shopping_shared/tabs/_contact.html.haml @@ -28,6 +28,7 @@ %br - if current_distributor.whatsapp_phone.present? %a{href: current_distributor.whatsapp_url, target: "_blank" } + %img{ src: image_pack_path("social-logos/whatsapp.svg") } = current_distributor.whatsapp_phone %br - if current_distributor.website.present? diff --git a/app/webpacker/images/social-logos/whatsapp.svg b/app/webpacker/images/social-logos/whatsapp.svg new file mode 100644 index 0000000000..ca946b5520 --- /dev/null +++ b/app/webpacker/images/social-logos/whatsapp.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/public/map_icons/social-logos/whatsapp.svg b/public/map_icons/social-logos/whatsapp.svg new file mode 100644 index 0000000000..ca946b5520 --- /dev/null +++ b/public/map_icons/social-logos/whatsapp.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file