Skip to content

Commit

Permalink
boiler plate added
Browse files Browse the repository at this point in the history
  • Loading branch information
lokisk1155 committed Aug 7, 2023
1 parent d4e6ec2 commit b2df7b1
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -709,4 +709,4 @@ RUBY VERSION
ruby 3.1.2p20

BUNDLED WITH
2.4.17
2.4.18
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Reports::ManufacturerDonationsSummaryController < ApplicationController
def index
@recent_donations_from_manufacturers = current_organization.donations.during(helpers.selected_range).by_source(:manufacturer)
end
end
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def default_title_content
end

def active_class(name)
name.any? { |path_name| controller_path.include? path_name } ? "active" : controller_path
(name.any? { |path_name| controller_path.include? path_name }) ? "active" : controller_path
end

def menu_open?(name)
name.any? { |path_name| controller_path.include? path_name } ? 'menu-open' : ''
(name.any? { |path_name| controller_path.include? path_name }) ? 'menu-open' : ''
end

def can_administrate?
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/donations_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ def total_received_donations_unformatted(range = selected_range)
def total_received_from_product_drives_unformatted(range = selected_range)
LineItem.active.where(itemizable: current_organization.donations.by_source(:product_drive).during(range)).sum(:quantity)
end
end
end
30 changes: 0 additions & 30 deletions app/views/dashboard/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -251,36 +251,6 @@
<%= render partial: "product_drive", collection: @recent_donations.by_source(:product_drive), as: :donation %>
</div>
<% end %>
<%= render(
"shared/card",
id: "manufacturers",
gradient: "success",
title: "Manufacturer Donations",
subtitle: @selected_date_range,
footer_options: { class: "text-center" },
footer: link_to("See more...", donations_path(
filters: {
by_source: "Manufacturer"
}
)),
) do %>
<h3 class="text-center">
<span class="total_received_donations">
<%= number_with_delimiter(@recent_donations_from_manufacturers.sum { |d| d.line_items.total }) %>
</span>
items donated <%= @selected_date_range_label %>
by
<span class="num_manufacturers_donated">
<%= pluralize(@recent_donations_from_manufacturers.group_by(&:manufacturer).count, 'Manufacturer') %>
</span>
</h3>
<div class="box-body">
<h4>Top Manufacturer Donations</h4>
<%= render partial: "manufacturer", collection: @top_manufacturers, as: :manufacturer %>
</div>
<% end %>

</div>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions app/views/layouts/_lte_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@
<%= link_to(reports_donations_summary_index_path(organization_id: current_user.organization), class: "nav-link #{active_class(['reports/donations_summary'])}") do %>
<i class="nav-icon fa fa-circle-o"></i> Donations Summary
<% end %>
</li>
<li class="nav-item <%= active_class(['reports']) %>">
<%= link_to(reports_manufacturer_donations_summary_index_path(organization_id: current_user.organization), class: "nav-link #{active_class(['reports/donations_summary'])}") do %>
<i class="nav-icon fa fa-circle-o"></i> Manufacturer Donations
<% end %>
</li>
<li class="nav-item <%= active_class(['purchases_summary']) %>">
<%= link_to(purchases_summary_path(organization_id: current_user.organization), class: "nav-link #{"active" if current_page?(purchases_summary_path)}") do %>
Expand Down
File renamed without changes.
28 changes: 28 additions & 0 deletions app/views/reports/manufacturer_donations_summary/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<%= render(
"shared/card",
id: "manufacturers",
gradient: "success",
title: "Manufacturer Donations",
subtitle: @selected_date_range,
footer_options: { class: "text-center" },
footer: link_to("See more...", donations_path(
filters: {
by_source: "Manufacturer"
}
)),
) do %>
<h3 class="text-center">
<span class="total_received_donations">
<%= number_with_delimiter(@recent_donations_from_manufacturers.sum { |d| d.line_items.total }) %>
</span>
items donated <%= @selected_date_range_label %>
by
<span class="num_manufacturers_donated">
<%= pluralize(@recent_donations_from_manufacturers.group_by(&:manufacturer).count, 'Manufacturer') %>
</span>
</h3>
<div class="box-body">
<h4>Top Manufacturer Donations</h4>
<%= render partial: "manufacturer", collection: @top_manufacturers, as: :manufacturer %>
</div>
<% end %>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def set_up_flipper
post :recalculate, on: :member
end
resources :donations_summary, only: [:index]
resources :manufacturer_donations_summary, only: [:index]
resources :itemized_donations, only: [:index]
resources :itemized_distributions, only: [:index]
end
Expand Down
6 changes: 3 additions & 3 deletions spec/requests/reports/donations_summary_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'rails_helper'
require "rails_helper"

RSpec.describe "Reports::DonationsSummary", type: :request do
let(:default_params) do
{ organization_id: @organization.to_param }
{organization_id: @organization.to_param}
end

describe "while signed in" do
Expand All @@ -15,7 +15,7 @@
get reports_donations_summary_index_path(default_params.merge(format: response_format))
response
end
let(:response_format) { 'html' }
let(:response_format) { "html" }

it { is_expected.to have_http_status(:success) }
end
Expand Down
6 changes: 3 additions & 3 deletions spec/system/reports/donations_summary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

context "when visiting the summary page" do
it "has a link to create a new donation" do
visit @url_prefix + "/reports/donations_summary"
visit @url_prefix + "/reports/donations_summary"
expect(page).to have_link "New Donation", href: "#{@url_prefix}/donations/new"
end

Expand Down Expand Up @@ -103,7 +103,7 @@ def create_next_donation(donation_date:)

describe("filtering to '#{filtered_date_range_label}'" + (set_custom_dates ? " (#{custom_dates})" : "")) do
before do
visit @url_prefix + "/reports/donations_summary"
visit @url_prefix + "/reports/donations_summary"
filter_to_date_range(filtered_date_range_label, custom_dates)
end

Expand Down Expand Up @@ -163,4 +163,4 @@ def valid_bracketing_dates(date_range_info)
[before_filtered_date_range, after_filtered_date_range]
end
end
end
end

0 comments on commit b2df7b1

Please sign in to comment.