Browse Source

feat: update helper methods, and show managing and owning filters as well in support secondary nav

pull/1998/head
natdeanlewissoftwire 3 years ago
parent
commit
ce4c889d82
  1. 16
      app/helpers/filters_helper.rb
  2. 6
      app/views/logs/_log_filters.html.erb

16
app/helpers/filters_helper.rb

@ -116,16 +116,20 @@ module FiltersHelper
user.support? || org.stock_owners.count > 1 || (org.holds_own_stock? && org.stock_owners.count.positive?) user.support? || org.stock_owners.count > 1 || (org.holds_own_stock? && org.stock_owners.count.positive?)
end end
def show_needstype_filter? def has_logs_for_both_needstypes?
[1,2].all?{ |needstype| current_user.lettings_logs.where(needstype:).count.positive? } && request.path.include?("/lettings-logs") [1, 2].all? { |needstype| current_user.lettings_logs.where(needstype:).count.positive? }
end end
def show_owning_org_filter? def multiple_owning_orgs?
(current_user.support? || current_user.organisation.stock_owners.count > 1) && request.path == "/lettings-logs" current_user.support? || current_user.organisation.stock_owners.count > 1
end end
def show_managing_org_filter? def multiple_managing_orgs?
(current_user.support? || current_user.organisation.managing_agents.count > 1) && request.path == "/lettings-logs" current_user.support? || current_user.organisation.managing_agents.count > 1
end
def user_or_org_lettings_path?
request.path.include?("/lettings-logs")
end end
private private

6
app/views/logs/_log_filters.html.erb

@ -42,7 +42,7 @@
category: "status", category: "status",
} %> } %>
<% if show_needstype_filter? %> <% if has_logs_for_both_needstypes? && user_or_org_lettings_path? %>
<%= render partial: "filters/checkbox_filter", <%= render partial: "filters/checkbox_filter",
locals: { locals: {
f:, f:,
@ -73,7 +73,7 @@
category: "assigned_to", category: "assigned_to",
} %> } %>
<% if show_owning_org_filter? %> <% if multiple_owning_orgs? && user_or_org_lettings_path? %>
<%= render partial: "filters/radio_filter", locals: { <%= render partial: "filters/radio_filter", locals: {
f:, f:,
options: { options: {
@ -93,7 +93,7 @@
} %> } %>
<% end %> <% end %>
<% if show_managing_org_filter? %> <% if multiple_managing_orgs? && user_or_org_lettings_path? %>
<%= render partial: "filters/radio_filter", locals: { <%= render partial: "filters/radio_filter", locals: {
f:, f:,
options: { options: {

Loading…
Cancel
Save