Skip to content

Commit

Permalink
Use a common method for desktop and mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
Flaburgan committed Feb 11, 2024
1 parent 14cf4ff commit 4e6772c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 6 additions & 0 deletions app/helpers/publisher_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
# the COPYRIGHT file.

module PublisherHelper
def display_available_services
current_user.services.each do |service|
return service_button(service) if AppConfig.configured_services.map(&:to_s).include? service.provider
end
end

def service_button(service)
provider_title = I18n.t("services.index.share_to", provider: service.provider.titleize)
content_tag :div,
Expand Down
6 changes: 2 additions & 4 deletions app/views/publisher/_publisher.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@
%button.btn.btn-group.btn-primary#submit= t("shared.publisher.share")

.btn-toolbar.pull-right#publisher-service-icons
- if current_user.services
- current_user.services.each do |service|
- if AppConfig.configured_services.map(&:to_s).include? service.provider
= service_button(service)
= display_available_services

.btn.btn-link.question_mark{title: t("shared.public_explain.manage"),
data: {toggle: "modal", target: "#publicExplainModal"}}
%i.entypo-cog
Expand Down
8 changes: 2 additions & 6 deletions app/views/publisher/_publisher.mobile.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@

= hidden_field_tag "aspect_ids[]", "all_aspects"
.form-group
%span#publisher-service-icons
- if current_user.services
- for service in current_user.services
= image_tag "social-media-logos/#{service.provider}-32x32.png",
title: service.provider.titleize, class: "service_icon dim",
id: "#{service.provider}", maxchar: "#{service.class::MAX_CHARACTERS}"

.clear
#publisher-textarea-wrapper
Expand All @@ -32,3 +26,5 @@
data: {"disable-with" => t("shared.publisher.posting")}
.pull-right
= render partial: "aspects/aspect_dropdown"
.pull-right#publisher-service-icons
= display_available_services

0 comments on commit 4e6772c

Please sign in to comment.