mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-04 22:16:08 +00:00
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.
This commit is contained in:
@@ -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"}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user