Skip to content

Commit

Permalink
add anchors to help preserve scroll position
Browse files Browse the repository at this point in the history
  • Loading branch information
crowesn committed Mar 4, 2024
1 parent e6a10a4 commit ef7afc1
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 23 deletions.
6 changes: 3 additions & 3 deletions app/controllers/con_tech_records_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ def create
@conservation_record = ConservationRecord.find(params[:conservation_record_id])
@con_tech_record = @conservation_record.con_tech_records.create(create_params)
if @con_tech_record.valid?
redirect_to conservation_record_path(@conservation_record)
redirect_to conservation_record_path(@conservation_record) + '#conservators-and-technicians'
else
redirect_to conservation_record_path(@conservation_record),
redirect_to conservation_record_path(@conservation_record) + '#conservators-and-technicians',
notice: "Conservator/Technician record not saved: #{@con_tech_record.errors.full_messages[0]}"
end
end
Expand All @@ -20,7 +20,7 @@ def destroy
@conservation_record = ConservationRecord.find(params[:conservation_record_id])
@con_tech_record = @conservation_record.con_tech_records.find(params[:id])
@con_tech_record.destroy
redirect_to conservation_record_path(@conservation_record)
redirect_to conservation_record_path(@conservation_record) + '#conservators-and-technicians'
end

private
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/cost_return_reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ class CostReturnReportsController < ApplicationController
def create
@conservation_record = ConservationRecord.find(params[:conservation_record_id])
CostReturnReport.create(cost_return_report_params)
redirect_to conservation_record_path(@conservation_record), notice: 'Treatment record saved successfully'
redirect_to conservation_record_path(@conservation_record) + '#cost-and-return-information', notice: 'Treatment record saved successfully'
end

def update
@conservation_record = ConservationRecord.find(params[:conservation_record_id])
@cost_return_report = @conservation_record.cost_return_report.update(cost_return_report_params)
redirect_to conservation_record_path(@conservation_record), notice: 'Treatment record updated'
redirect_to conservation_record_path(@conservation_record) + '#cost-and-return-information', notice: 'Treatment record updated'
end

def destroy
@conservation_record = ConservationRecord.find(params[:conservation_record_id])
@cost_return_report = @conservation_record.cost_return_report
@cost_return_report.destroy
redirect_to conservation_record_path(@conservation_record)
redirect_to conservation_record_path(@conservation_record) + '#cost-and-return-information'
end

private
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/external_repair_records_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ def create
@repair_record = @conservation_record.external_repair_records.create(create_params)

if @repair_record.valid?
redirect_to conservation_record_path(@conservation_record)
redirect_to conservation_record_path(@conservation_record) + '#external-repairs'
else
redirect_to conservation_record_path(@conservation_record), notice: "External repair not saved: #{@repair_record.errors.full_messages[0]}"
redirect_to conservation_record_path(@conservation_record) + '#external-repairs', notice: "External repair not saved: #{@repair_record.errors.full_messages[0]}"
end
end

def destroy
@conservation_record = ConservationRecord.find(params[:conservation_record_id])
@repair_record = @conservation_record.external_repair_records.find(params[:id])
@repair_record.destroy
redirect_to conservation_record_path(@conservation_record)
redirect_to conservation_record_path(@conservation_record) + '#external-repairs'
end

private
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/in_house_repair_records_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ def create
@conservation_record = ConservationRecord.find(params[:conservation_record_id])
@repair_record = @conservation_record.in_house_repair_records.create(create_params)
if @repair_record.valid?
redirect_to conservation_record_path(@conservation_record)
redirect_to conservation_record_path(@conservation_record) + '#in-house-repairs'
else
redirect_to conservation_record_path(@conservation_record), notice: "In house repair not saved: #{@repair_record.errors.full_messages[0]}"
redirect_to conservation_record_path(@conservation_record) + '#in-house-repairs', notice: "In house repair not saved: #{@repair_record.errors.full_messages[0]}"
end
end

def destroy
@conservation_record = ConservationRecord.find(params[:conservation_record_id])
@repair_record = @conservation_record.in_house_repair_records.find(params[:id])
@repair_record.destroy
redirect_to conservation_record_path(@conservation_record)
redirect_to conservation_record_path(@conservation_record) + '#in-house-repairs'
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/treatment_reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ def create
@treatment_report.save

flash
redirect_to conservation_record_path(@treatment_report.conservation_record), notice: 'Treatment record saved successfully!'
redirect_to conservation_record_path(@treatment_report.conservation_record) + '#treatment-report-tab', notice: 'Treatment record saved successfully!'
end

def update
@treatment_report = TreatmentReport.find(params[:id])

@treatment_report.update(treatment_report_params)
redirect_to conservation_record_path(@treatment_report.conservation_record), notice: 'Treatment Record updated successfully!'
redirect_to conservation_record_path(@treatment_report.conservation_record) + '#treatment-report-tab', notice: 'Treatment Record updated successfully!'
end

private
Expand Down
8 changes: 4 additions & 4 deletions app/views/conservation_records/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<p></p>

<div class="header">
<h3>In-House Repairs</h3>
<h3 id="in-house-repairs">In-House Repairs</h3>
<% if can? :crud, InHouseRepairRecord %>
<button type="button" class="btn btn-primary cta-btn" data-toggle="modal" data-target="#inHouseRepairModal">
Add In-House Repairs
Expand Down Expand Up @@ -96,7 +96,7 @@

<br />
<div class="header">
<h3>External Repairs</h3>
<h3 id="external-repairs">External Repairs</h3>
<% if can? :crud, ExternalRepairRecord %>
<button type="button" class="btn btn-primary cta-btn" data-toggle="modal" data-target="#externalRepairModal">
Add External Repair
Expand Down Expand Up @@ -128,7 +128,7 @@
<% end %>
<br />
<div class="header">
<h3>Conservators and Technicians</h3>
<h3 id="conservators-and-technicians">Conservators and Technicians</h3>
<% if can? :crud, ConTechRecord %>
<button type="button" class="btn btn-primary cta-btn" data-toggle="modal" data-target="#ConservatorsTechniciansModal">
Add Conservators and Technicians
Expand Down Expand Up @@ -183,7 +183,7 @@

<br>
<div class="header">
<h3>Cost and Return Information</h3>
<h3 id="cost-and-return-information">Cost and Return Information</h3>
</div>
<%= form_with(model: [@conservation_record, @conservation_record.cost_return_report], class: 'disable_input') do |f| %>

Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/con_tech_records_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
describe 'POST #create' do
it 'creates a new conservators and technicians record' do
post :create, params: { con_tech_record: valid_attributes, conservation_record_id: conservation_record.id }
expect(response).to redirect_to(conservation_record)
expect(response).to redirect_to(conservation_record_path(conservation_record) + '#conservators-and-technicians')
end
end

Expand All @@ -33,6 +33,7 @@
expect do
delete :destroy, params: { id: con_tech_record.to_param, conservation_record_id: conservation_record.id }
end.to change(ConTechRecord, :count).by(-1)
expect(response).to redirect_to(conservation_record_path(conservation_record) + '#conservators-and-technicians')
end
end
end
4 changes: 3 additions & 1 deletion spec/controllers/cost_return_reports_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
it 'creates a new cost return report record' do
conservation_record = create(:conservation_record)
post :create, params: { conservation_record_id: conservation_record.id, cost_return_report: valid_attributes }
expect(response).to redirect_to(conservation_record_path(conservation_record))
expect(response).to redirect_to(conservation_record_path(conservation_record) + '#cost-and-return-information')
end
end
end
Expand All @@ -41,6 +41,7 @@
expect do
delete :destroy, params: { conservation_record_id: conservation_record.id, id: cost_return_report.to_param }
end.to change(CostReturnReport, :count).by(-1)
expect(response).to redirect_to(conservation_record_path(conservation_record) + '#cost-and-return-information')
end
end

Expand All @@ -60,6 +61,7 @@
it 'updates Cost Return Report' do
cost_return_report = CostReturnReport.create! valid_attributes
put :update, params: { conservation_record_id: conservation_record.id, id: cost_return_report.to_param, cost_return_report: new_attributes }
expect(response).to redirect_to(conservation_record_path(conservation_record) + '#cost-and-return-information')
cost_return_report.reload
expect(cost_return_report.repair_estimate).to eq(110.10)
expect(cost_return_report.repair_cost).to eq(130.10)
Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/external_repair_records_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
describe 'POST #create' do
it 'creates a new in house repair record' do
post :create, params: { external_repair_record: valid_attributes, conservation_record_id: conservation_record.id }
expect(response).to redirect_to(conservation_record)
expect(response).to redirect_to(conservation_record_path(conservation_record) + '#external-repairs')
end
end

Expand All @@ -36,6 +36,7 @@
expect do
delete :destroy, params: { id: external_repair_record.to_param, conservation_record_id: conservation_record.id }
end.to change(ExternalRepairRecord, :count).by(-1)
expect(response).to redirect_to(conservation_record_path(conservation_record) + '#external-repairs')
end
end
end
3 changes: 2 additions & 1 deletion spec/controllers/in_house_repair_records_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
describe 'POST #create' do
it 'creates a new in house repair record' do
post :create, params: { in_house_repair_record: valid_attributes, conservation_record_id: conservation_record.id }
expect(response).to redirect_to(conservation_record)
expect(response).to redirect_to(conservation_record_path(conservation_record) + '#in-house-repairs')
end

it 'does not have valid staff code to create in house repair record' do
Expand All @@ -55,6 +55,7 @@
expect do
delete :destroy, params: { id: in_house_repair_record.to_param, conservation_record_id: conservation_record.id }
end.to change(InHouseRepairRecord, :count).by(-1)
expect(response).to redirect_to(conservation_record_path(conservation_record) + '#in-house-repairs')
end
end
end
3 changes: 2 additions & 1 deletion spec/controllers/treatment_reports_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
it 'creates a new conservation record' do
conservation_record = create(:conservation_record)
post :create, params: { conservation_record_id: conservation_record.id, treatment_report: valid_attributes }
expect(response).to redirect_to(conservation_record_path(conservation_record))
expect(response).to redirect_to(conservation_record_path(conservation_record) + '#treatment-report-tab')
end
end
end
Expand Down Expand Up @@ -90,6 +90,7 @@
it 'updates the Treatment Report' do
treatment_report = TreatmentReport.create! valid_attributes
put :update, params: { conservation_record_id: conservation_record.id, id: treatment_report.to_param, treatment_report: new_attributes }
expect(response).to redirect_to(conservation_record_path(conservation_record) + '#treatment-report-tab')
treatment_report.reload
expect(treatment_report.description_primary_support).to eq('Description Support')
end
Expand Down

0 comments on commit ef7afc1

Please sign in to comment.