mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Replace url generation with 'whatsapp_url' method
As suggested by mkllnk's following comment:
1eda7d8a4c (r890656117)
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"}
|
||||
|
||||
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user