Skip to content

Commit

Permalink
Merge pull request #221 from sparc-request/ml-add_indicator_for_custo…
Browse files Browse the repository at this point in the history
…m_visits

Ml add indicator for custom visits
  • Loading branch information
jleonardw9 committed Nov 30, 2016
2 parents ffc97b9 + c12fdfb commit 78120eb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/controllers/appointments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def new
end

def create

@appointment = CustomAppointment.new(custom_appointment_params)

if @appointment.valid?
Expand Down
4 changes: 4 additions & 0 deletions app/models/appointment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def destroy_if_incomplete
end
end

def formatted_name
self.type == 'CustomAppointment' ? "#{self.name} (Custom Visit)" : self.name
end

def initialize_procedures
unless self.is_a? CustomAppointment # custom appointments don't inherit from the study schedule so there is nothing to build out
ActiveRecord::Base.transaction do
Expand Down
2 changes: 1 addition & 1 deletion app/views/appointments/_calendar.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
.col-xs-12
.page-header
%h3.appointment_header
= "Visit: #{appointment.name}"
= "Visit: #{appointment.formatted_name}"
= appointment_notes_formatter(appointment)
.row
.col-md-5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
json.(@appointments) do |appointment|
json.id appointment.id
json.name appointment.name
json.name appointment.formatted_name
json.completed_date format_date(appointment.completed_date)
json.arm appointment.arm.name
end
2 changes: 1 addition & 1 deletion app/views/participants/_dropdown.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
%option{value: -1} Please Select
- arms_for_appointments(participant.appointments).each do |arm|
%option{:disabled => true, :style => 'font-weight:bold;'}= arm.name.humanize + ':'
= options_from_collection_for_select(appointments_for_select(arm, participant), 'id', 'name')
= options_from_collection_for_select(appointments_for_select(arm, participant), 'id', 'formatted_name')
%option{'data-divider' => true, :disabled => true}
%span.custom-visit-container{title: participant.arm_id.nil? ? t(:visit)[:no_arm] : t(:visit)[:custom], data: {toggle: "tooltip", animation: 'false'}}
%button.btn.btn-primary.appointment.new{type: "button", disabled: participant.arm_id.nil? ? true : false, data: {participant_id: participant.id, arm_id: participant.arm_id}}
Expand Down

0 comments on commit 78120eb

Please sign in to comment.