Skip to content
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

[#2159] Display the Approve Partner button on the top with a tooltip #2163

Merged
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
28 changes: 28 additions & 0 deletions app/assets/stylesheets/resources/partners.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,31 @@ i.fa {
div#partner-notes {
padding: 0px 20px;
}

div#approve-application-button {
position: fixed;

background: #{$diaper-color-white};
border-top: 1px solid #{$diaper-color-neutral-67};
box-shadow: 1px 1px 5px #{$diaper-color-neutral-67};

bottom:0px;

width: calc(100%);
min-height: #{$diaper-footer-height}px;

padding: 12px 16px;
margin-left: -16px;

z-index: 1;
}

@media only screen and (max-width: 500px) {
div#approve-application-button {
display: flex;
justify-content: center;

margin-left: 0;
width: calc(100% - 32px);
}
}
4 changes: 3 additions & 1 deletion app/helpers/ui_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ def _link_to(link, options = {}, properties = {})
# user sparingly.
center = options[:center].present? ? "center-block" : ""

link_to link, properties.merge(class: "btn btn-#{type} btn-#{size} #{center}") do
disabled = options[:enabled] || options[:enabled].nil? ? "" : "disabled"

link_to link, properties.merge(class: "btn btn-#{type} btn-#{size} #{center} #{disabled}") do
fa_icon icon, text: text
end
end
Expand Down
17 changes: 13 additions & 4 deletions app/views/partners/approve_partner.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
<div class="card card-info card-outline">
<div class="card-header">
<h1 class="card-title"><strong><%= @partner.name %> - Application Details
- <%= link_to @partner.email, "mailto:#{@partner.email}" %></strong></h1>
- <%= link_to @partner.email, "mailto:#{@partner.email}" %></strong>
</h1>
</div>
<div class="card-body p-6">
<div class="row">
Expand Down Expand Up @@ -187,11 +188,19 @@
</div>
</div>
<!-- /.card-body -->
<div class="card-footer">
<%= print_button_to approve_application_partner_path(@partner), {text: "Approve Partner", icon: "thumbs-o-up", type: "success", size: "md"} if @partner.awaiting_review? %>
</div>
</div>
<div id="approve-application-button">
<% tooltip_message = "Partner has not requested approval yet. Partners are able to request approval by going into 'My Organization' and clicking 'Request Approval' button." %>
<span id="pending-approval-request-tooltip" title="<%= tooltip_message unless @partner.awaiting_review? %>">
<%= print_button_to approve_application_partner_path(@partner), { text: "Approve Partner", icon: "thumbs-o-up", type: "success", size: "md", enabled: @partner.awaiting_review? } %>
</span>
</div>
</div>
</div>
</div>
</section>
<script>
$(function () {
$('#pending-approval-request-tooltip').tooltip()
})
</script>
4 changes: 2 additions & 2 deletions spec/requests/partners_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@
subject.call
end

it 'should not show the Approve Partner button' do
expect(response.body).not_to include("Approve Partner")
it 'should show the Approve Partner button' do
expect(response.body).to include("Approve Partner")
end
end
end
Expand Down
39 changes: 39 additions & 0 deletions spec/system/partner_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,43 @@
expect(partner.send_reminders).to be false
end
end

describe "#approve_partner" do
let(:tooltip_message) do
"Partner has not requested approval yet. \
Partners are able to request approval by going into 'My Organization' \
and clicking 'Request Approval' button."
end
let!(:invited_partner) { create(:partner, name: "Amelia Ebonheart", status: :invited) }
let!(:awaiting_review_partner) { create(:partner, name: "Beau Brummel", status: :awaiting_review) }

context "when partner has :invited status" do
before { visit_approval_page(1) }

it { expect(page).to have_selector(:link_or_button, 'Approve Partner') }
it { expect(page).to have_selector('span#pending-approval-request-tooltip > a.btn.btn-success.btn-md.disabled') }

it 'shows correct tooltip' do
page.execute_script('$("#pending-approval-request-tooltip").mouseover()')
expect(page).to have_content tooltip_message
end
end

context "when partner has :awaiting_review status" do
before { visit_approval_page(2) }

it { expect(page).to have_selector(:link_or_button, 'Approve Partner') }
it { expect(page).not_to have_selector('span#pending-approval-request-tooltip > a.btn.btn-success.btn-md.disabled') }

it 'shows no tooltip' do
page.execute_script('$("#pending-approval-request-tooltip").mouseover()')
expect(page).not_to have_content tooltip_message
end
end
end
end

def visit_approval_page(table_row)
visit url_prefix + "/partners"
within("table > tbody > tr:nth-child(#{table_row}) > td:nth-child(5)") { click_on "Review Application" }
end