Skip to content

Commit

Permalink
Dm 4266 fix partner practices imgs (#726)
Browse files Browse the repository at this point in the history
* add practice_partners and practice_partner_practices factories

update spec to use factories

* spacing

* add utilities js for practice_parnter_practices

* remove extra js include tag

* add js include tags for practice_partners show

* invoke `replaceImagePlaceholders` function for paginated partner practices

* spacing

* spacing

* spacing
  • Loading branch information
PhilipDeFraties authored Oct 26, 2023
1 parent 989a8c4 commit 85c01ec
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 38 deletions.
1 change: 0 additions & 1 deletion app/assets/javascripts/_practice_card_utilities.es6
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

function truncateOnArrive(arrivingEle, shaveHeight) {
$(document).arrive(arrivingEle, function(newElem) {
$(newElem).shave(shaveHeight);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(($) => {
const $document = $(document);

function execPageBuilderFunctions() {
replaceImagePlaceholders();
}

$document.on('turbolinks:load', execPageBuilderFunctions);
})(window.jQuery);
1 change: 0 additions & 1 deletion app/views/page/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<%= javascript_include_tag 'ie', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'shared/_signed_resource', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag '_page_show', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'shared/_signed_resource', 'data-turbolinks-track': 'false', defer: true %>
<%= javascript_include_tag '_practice_card_utilities', 'data-turbolinks-track': 'reload' %>
<% end %>
<% accordion_ctr = 0 %>
Expand Down
5 changes: 5 additions & 0 deletions app/views/practice_partners/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<% provide :head_tags do %>
<%= javascript_include_tag '_practice_card_utilities', 'data-turbolinks-track': 'load' %>
<%= javascript_include_tag 'shared/_signed_resource' %>
<%= javascript_include_tag '_practice_partner_practices_utilities', 'data-turbolinks-track': 'reload' %>
<% end %>
<div>
<section class="grid-container">
<%= render partial: "shared/messages", locals: {small_text: false} %>
Expand Down
8 changes: 5 additions & 3 deletions app/views/practice_partners/show.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function paginatedPartnerPractices() {
<% pagy = @pagy_partner_practices %>
<% current_page = pagy.page %>
<% next_page = pagy.next %>

// Append the next set of practice cards to the current set
$(practicesClass).append("<%= escape_javascript render(partial: 'shared/practice_cards_row', locals: {
practices: @paginated_partner_practices
Expand All @@ -17,9 +17,11 @@ function paginatedPartnerPractices() {
<% link = pagy_link_proc(pagy) %>
$(loadMoreClass).append(`<%= link.call(next_page, 'Load more').html_safe %>`);
<% else %>
// If there isn't another set, remove the current 'Load more' link
// If there isn't another set, remove the current 'Load more' link
$(loadMoreClass).remove();
<% end %>

replaceImagePlaceholders();
}

$(paginatedPartnerPractices);
$(paginatedPartnerPractices);
6 changes: 6 additions & 0 deletions spec/factories/practice_partner_practices.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FactoryBot.define do
factory :practice_partner_practice do
association :practice_partner
association :practice
end
end
16 changes: 16 additions & 0 deletions spec/factories/practice_partners.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FactoryBot.define do
factory :practice_partner do
name { Faker::Company.unique.name }
short_name { Faker::Company.unique.name } # Generates a 3-letter initials
description { Faker::Lorem.paragraph }
position { Faker::Number.non_zero_digit }
color { Faker::Color.hex_color }
icon { Faker::Lorem.word }

trait :not_major_partner do
is_major { false }
end

is_major { true }
end
end
66 changes: 33 additions & 33 deletions spec/features/practice_partners_spec.rb
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
require 'rails_helper'
describe 'Practice partners pages', type: :feature do
before do
@pp = PracticePartner.create!(name: 'Diffusion of Excellence', short_name: '', description: 'The Diffusion of Excellence Initiative helps to identify and disseminate clinical and administrative best innovations through a learning environment that empowers its top performers to apply their innovative ideas throughout the system — further establishing VA as a leader in health care while promoting positive outcomes for Veterans.', icon: 'fas fa-heart', color: '#E4A002', is_major: true)
@pp_2 = PracticePartner.create!(name: 'Awesome Practice Partner', short_name: 'APP', description: 'Hello world')
@user = User.create!(email: '[email protected]', password: 'Password123', password_confirmation: 'Password123', skip_va_validation: true, confirmed_at: Time.now, accepted_terms: true)
@user2 = User.create!(email: '[email protected]', password: 'Password123', password_confirmation: 'Password123', skip_va_validation: true, confirmed_at: Time.now, accepted_terms: true)
@admin = User.create!(email: '[email protected]', password: 'Password123', password_confirmation: 'Password123', skip_va_validation: true, confirmed_at: Time.now, accepted_terms: true)
@approver = User.create!(email: '[email protected]', password: 'Password123', password_confirmation: 'Password123', skip_va_validation: true, confirmed_at: Time.now, accepted_terms: true)
@pp = create(:practice_partner, name: 'Diffusion of Excellence', short_name: '', description: 'The Diffusion of Excellence Initiative helps to identify and disseminate clinical and administrative best innovations through a learning environment that empowers its top performers to apply their innovative ideas throughout the system — further establishing VA as a leader in health care while promoting positive outcomes for Veterans.', icon: 'fas fa-heart', color: '#E4A002')
@pp_2 = create(:practice_partner, :not_major_partner, name: 'Awesome Practice Partner', short_name: 'APP', description: 'Hello world')
@user = create(:user, email: '[email protected]', password: 'Password123', password_confirmation: 'Password123', skip_va_validation: true, confirmed_at: Time.now, accepted_terms: true)
@user2 = create(:user, email: '[email protected]', password: 'Password123', password_confirmation: 'Password123', skip_va_validation: true, confirmed_at: Time.now, accepted_terms: true)
@admin = create(:user, email: '[email protected]', password: 'Password123', password_confirmation: 'Password123', skip_va_validation: true, confirmed_at: Time.now, accepted_terms: true)
@approver = create(:user, email: '[email protected]', password: 'Password123', password_confirmation: 'Password123', skip_va_validation: true, confirmed_at: Time.now, accepted_terms: true)
@admin.add_role(User::USER_ROLES[1].to_sym)
@approver.add_role(User::USER_ROLES[0].to_sym)
@pr_1 = Practice.create!(name: 'A public practice', approved: true, published: true, enabled: true, is_public: true, initiating_facility_type: 'other', user: @user2)
@pr_2 = Practice.create!(name: 'practice two', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_3 = Practice.create!(name: 'practice three', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_4 = Practice.create!(name: 'practice four', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_5 = Practice.create!(name: 'practice five', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_6 = Practice.create!(name: 'practice six', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_7 = Practice.create!(name: 'practice seven', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_8 = Practice.create!(name: 'practice eight', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_9 = Practice.create!(name: 'practice nine', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_10 = Practice.create!(name: 'practice ten', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_11 = Practice.create!(name: 'practice eleven', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_12 = Practice.create!(name: 'practice twelve', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_13 = Practice.create!(name: 'practice thirteen', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
Practice.create!(name: 'random practice', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
PracticePartnerPractice.create!(practice_partner: @pp, practice: @pr_1)
PracticePartnerPractice.create!(practice_partner: @pp, practice: @pr_2)
PracticePartnerPractice.create!(practice_partner: @pp, practice: @pr_3)
PracticePartnerPractice.create!(practice_partner: @pp, practice: @pr_4)
PracticePartnerPractice.create!(practice_partner: @pp, practice: @pr_5)
PracticePartnerPractice.create!(practice_partner: @pp, practice: @pr_6)
PracticePartnerPractice.create!(practice_partner: @pp, practice: @pr_7)
PracticePartnerPractice.create!(practice_partner: @pp, practice: @pr_8)
PracticePartnerPractice.create!(practice_partner: @pp, practice: @pr_9)
PracticePartnerPractice.create!(practice_partner: @pp, practice: @pr_10)
PracticePartnerPractice.create!(practice_partner: @pp, practice: @pr_11)
PracticePartnerPractice.create!(practice_partner: @pp, practice: @pr_12)
PracticePartnerPractice.create!(practice_partner: @pp, practice: @pr_13)
@pr_1 = create(:practice, name: 'A public practice', approved: true, published: true, enabled: true, is_public: true, initiating_facility_type: 'other', user: @user2)
@pr_2 = create(:practice, name: 'practice two', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_3 = create(:practice, name: 'practice three', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_4 = create(:practice, name: 'practice four', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_5 = create(:practice, name: 'practice five', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_6 = create(:practice, name: 'practice six', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_7 = create(:practice, name: 'practice seven', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_8 = create(:practice, name: 'practice eight', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_9 = create(:practice, name: 'practice nine', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_10 = create(:practice, name: 'practice ten', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_11 = create(:practice, name: 'practice eleven', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_12 = create(:practice, name: 'practice twelve', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
@pr_13 = create(:practice, name: 'practice thirteen', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
create(:practice, name: 'random practice', approved: true, published: true, enabled: true, initiating_facility_type: 'other', user: @user2)
create(:practice_partner_practice, practice_partner: @pp, practice: @pr_1)
create(:practice_partner_practice, practice_partner: @pp, practice: @pr_2)
create(:practice_partner_practice, practice_partner: @pp, practice: @pr_3)
create(:practice_partner_practice, practice_partner: @pp, practice: @pr_4)
create(:practice_partner_practice, practice_partner: @pp, practice: @pr_5)
create(:practice_partner_practice, practice_partner: @pp, practice: @pr_6)
create(:practice_partner_practice, practice_partner: @pp, practice: @pr_7)
create(:practice_partner_practice, practice_partner: @pp, practice: @pr_8)
create(:practice_partner_practice, practice_partner: @pp, practice: @pr_9)
create(:practice_partner_practice, practice_partner: @pp, practice: @pr_10)
create(:practice_partner_practice, practice_partner: @pp, practice: @pr_11)
create(:practice_partner_practice, practice_partner: @pp, practice: @pr_12)
create(:practice_partner_practice, practice_partner: @pp, practice: @pr_13)
end

context 'for a logged in user' do
Expand Down

0 comments on commit 85c01ec

Please sign in to comment.