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

Bloquei botão quando existe dose cadastrada (#371) #399

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions app/helpers/admin/patients_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,15 @@ def admin_nav_links(current_filter, current_search, total_count)
links << search_link(current_search, total_count, admin_patients_path(search: current_search)) if current_search.present?
end.join.html_safe # rubocop:disable Rails/OutputSafety
end

def register_appointment(patient)
link_class = 'btn btn-success'

if patient.doses.any?
link_class = 'btn btn-success disabled'
end

link_to "Registrar dose", new_admin_appointment_path(patient_id: patient.id), class: link_class
Comment on lines +21 to +25
Copy link
Collaborator

@Mat-Bit Mat-Bit Oct 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if patient.doses.any?
link_class = 'btn btn-success disabled'
end
link_to "Registrar dose", new_admin_appointment_path(patient_id: patient.id), class: link_class
button_text = 'Registrar dose'
if patient.doses.any?
link_class = 'btn btn-info'
button_text += ' de reforço'
end
link_to button_text, new_admin_appointment_path(patient_id: patient.id), class: link_class

Nesse momento o botão está útil para registrar corretamente uma dose se o paciente já possui uma dose registrada.

Por isso faço essa sugestão no seu PR para podermos alinhar com o uso atual do sistema, o que achas?

(Talvez precise redimensionar o tamanho do botão para o texto caso o paciente já possua uma dose)

pr_399

end
end
end
2 changes: 1 addition & 1 deletion app/views/admin/patients/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
</h1>
</div>
<div class="col-2">
<%= link_to "Registrar dose", new_admin_appointment_path(patient_id: @patient.id), class: 'btn btn-success' %>
<%= register_appointment(@patient) %>
</div>
</div>
</div>
Expand Down