Skip to content

[Org Home] Disable transactions if organizers aren't signed in #10647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions app/views/events/home/_money_movement.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
<% end %>

<% @money_in.each do |transaction| %>
<a href="<%= url_for(transaction.local_hcb_code) %>" class="homepage-transaction <%= Flipper.enabled?(:hcb_code_popovers_2023_06_16, current_user) && (@event || transaction.local_hcb_code.event).present? ? "cursor-pointer hover:bg-gray-50 active:bg-gray-100 transition-colors dark:hover:bg-neutral-700 dark:active:bg-neutral-600" : "" %>" data-behavior="modal_trigger" data-modal="money_movement_tx_details_<%= transaction.local_hcb_code.__id__ %>">
<a
class="homepage-transaction <%= organizer_signed_in? && Flipper.enabled?(:hcb_code_popovers_2023_06_16, current_user) && (@event || transaction.local_hcb_code.event).present? ? "cursor-pointer hover:bg-gray-50 active:bg-gray-100 transition-colors dark:hover:bg-neutral-700 dark:active:bg-neutral-600" : "" %>"
<% if organizer_signed_in? %>
href="<%= url_for(transaction.local_hcb_code) %>"
data-behavior="modal_trigger"
data-modal="money_movement_tx_details_<%= transaction.local_hcb_code.__id__ %>"
<% end %>>
Comment on lines +13 to +19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: If I'm reading this correctly, we're basically removing all useful classes and properties from this <a> tag when organizer_signed_in?, which leaves me with two questions:

  1. Do we need this to be a <a> when there is no href?

    → The capture helper might come in handy here so we can wrap the inner content with different outer elements.

  2. Can we simplify the class attribute logic?

    → Would a local variable be more readable?

^ putting the above together we end up with something like

<% @money_in.each do |transaction| %>
  <% rendered_transaction = capture do %>
    <!-- What was previously in the `<a>` tag -->
  <% end %>  

  <% if organizer.signed_in? %>
    <!-- 👇 We should probably name this -->
    <% name_this_concept = Flipper.enabled?(:hcb_code_popovers_2023_06_16, current_user) && (@event || transaction.local_hcb_code.event).present? %>
    <% css_classes = "cursor-pointer hover:bg-gray-50 active:bg-gray-100 transition-colors dark:hover:bg-neutral-700 dark:active:bg-neutral-600" if name_this_concept  %>
    <a
      class="homepage-transaction <%= css_classes %>" 
      href="<%= url_for(transaction.local_hcb_code) %>"
      data-behavior="modal_trigger"
      data-modal="money_movement_tx_details_<%= transaction.local_hcb_code.__id__ %>"
    >
      <%= rendered_transaction %>
    </a>
  <% else %>
    <div class="homepage-transaction">
      <%= rendered_transaction %>
    </div>
  <% end %>
<% end %>

<div style="min-width:0;flex:1">
<span class="truncate block"><%= transaction_memo(transaction) %></span>
<div class="text-sm text-gray-500">
Expand Down Expand Up @@ -48,7 +54,13 @@
<% end %>

<% @money_out.each do |transaction| %>
<a href="<%= url_for(transaction.local_hcb_code) %>" class="homepage-transaction <%= Flipper.enabled?(:hcb_code_popovers_2023_06_16, current_user) && (@event || transaction.local_hcb_code.event).present? ? "cursor-pointer hover:bg-gray-50 active:bg-gray-100 transition-colors dark:hover:bg-neutral-700 dark:active:bg-neutral-600" : "" %>" data-behavior="modal_trigger" data-modal="money_movement_tx_details_<%= transaction.local_hcb_code.__id__ %>">
<a
class="homepage-transaction <%= organizer_signed_in? && Flipper.enabled?(:hcb_code_popovers_2023_06_16, current_user) && (@event || transaction.local_hcb_code.event).present? ? "cursor-pointer hover:bg-gray-50 active:bg-gray-100 transition-colors dark:hover:bg-neutral-700 dark:active:bg-neutral-600" : "" %>"
<% if organizer_signed_in? %>
href="<%= url_for(transaction.local_hcb_code) %>"
data-behavior="modal_trigger"
data-modal="money_movement_tx_details_<%= transaction.local_hcb_code.__id__ %>"
<% end %>>
<div style="min-width:0;flex:1">
<span class="truncate block"><%= transaction_memo(transaction) %></span>
<div class="text-sm text-gray-500">
Expand Down
9 changes: 8 additions & 1 deletion app/views/events/home/_transactions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
<div class="card card--breakdown shadow-none p-0 px-0 flex-1 flex flex-col">
<h3 class="m-0 p-4 pb-0 mb-1">Recent transactions</h3>
<% @recent_transactions.each do |transaction| %>
<a style="height:60px" href="<%= url_for(transaction.local_hcb_code) %>" class="homepage-transaction <%= Flipper.enabled?(:hcb_code_popovers_2023_06_16, current_user) && (@event || transaction.local_hcb_code.event).present? ? "cursor-pointer hover:bg-gray-50 active:bg-gray-100 transition-colors dark:hover:bg-neutral-700 dark:active:bg-neutral-600" : "" %>" data-behavior="modal_trigger" data-modal="transaction_details_<%= transaction.local_hcb_code.__id__ %>">
<a
style="height:60px"
class="homepage-transaction <%= organizer_signed_in? && Flipper.enabled?(:hcb_code_popovers_2023_06_16, current_user) && (@event || transaction.local_hcb_code.event).present? ? "cursor-pointer hover:bg-gray-50 active:bg-gray-100 transition-colors dark:hover:bg-neutral-700 dark:active:bg-neutral-600" : "" %>"
<% if organizer_signed_in? %>
href="<%= url_for(transaction.local_hcb_code) %>"
data-behavior="modal_trigger"
data-modal="transaction_details_<%= transaction.local_hcb_code.__id__ %>"
<% end %>>
<div style="min-width:0;flex:1">
<span class="truncate block"><%= transaction_memo(transaction) %></span>
<div class="text-sm text-gray-500">
Expand Down