Skip to content

Commit

Permalink
Medication variables are now sorted by position, addresses #697.
Browse files Browse the repository at this point in the history
  • Loading branch information
remomueller committed Mar 11, 2019
1 parent d482fa4 commit 5cf8c15
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/editor/medication_variables_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ def find_medication_variable_or_redirect
end

def medication_variable_params
params.require(:medication_variable).permit(:name, :autocomplete_values)
params.require(:medication_variable).permit(:name, :autocomplete_values, :position)
end
end
2 changes: 1 addition & 1 deletion app/models/concerns/medications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Medications

included do
# Relationships
has_many :medication_variables, -> { current }
has_many :medication_variables, -> { current.order("position nulls last") }
has_many :medications
has_many :medication_values
end
Expand Down
1 change: 1 addition & 0 deletions app/views/editor/medication_variables/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
= form_with model: [medication_variable.project, medication_variable], url: url, method: method, local: true do |form|
= render "forms/horizontal/text_field", form: form, object: medication_variable, key: :name, autocomplete: "off"
= render "forms/horizontal/text_area", form: form, object: medication_variable, key: :autocomplete_values, rows: 7, help_text: "Place values on separate lines"
= render "forms/horizontal/number_field", form: form, object: medication_variable, key: :position
= render "forms/horizontal/submit", form: form, object: [medication_variable.project, medication_variable], cancel: url
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPositionToMedicationVariables < ActiveRecord::Migration[6.0]
def change
add_column :medication_variables, :position, :integer
end
end

0 comments on commit 5cf8c15

Please sign in to comment.