Skip to content

Commit

Permalink
[#170752951] better max subject count handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kayla-glick committed Mar 24, 2020
1 parent 05d0b03 commit 96ca8ac
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/utilities.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ $text-map: (
.rotate {
animation: rotate 3s linear infinite;
}

.pointer-none {
pointer-events: none;
}
4 changes: 4 additions & 0 deletions app/controllers/arms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def update
setup_calendar_pages

if @arm.update_attributes(arm_params)
if params[:apply_max_subject_count] == 'true'
@arm.line_items_visits.update_all(subject_count: @arm.subject_count)
end

flash[:success] = t('arms.updated')
else
@errors = @arm.errors
Expand Down
8 changes: 7 additions & 1 deletion app/views/arms/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@
= f.text_field :name, class: 'form-control'
.form-group
= f.label :subject_count, class: 'required', title: t('arms.tooltips.subject_count'), data: { toggle: 'tooltip' }
= f.number_field :subject_count, class: 'form-control', min: 0
.input-group
= f.number_field :subject_count, class: 'form-control', min: 0
.input-group-append
%button.btn.btn-secondary#applyMaxSubjectCount{ type: 'button', onclick: "$('#apply_max_subject_count').prop('checked', !$('#apply_max_subject_count').prop('checked'))" }
%span.mr-2
= t('actions.apply_all')
= check_box_tag :apply_max_subject_count, 'true', false, class: 'pointer-none'
.form-group
= f.label :visit_count, class: 'required', title: t('arms.tooltips.subject_count'), data: { toggle: 'tooltip' }
= f.number_field :visit_count, class: 'form-control', min: 0
Expand Down
6 changes: 5 additions & 1 deletion app/views/line_items_visits/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
.modal-body
.form-group
= f.label params[:field], class: 'required'
= f.number_field params[:field], class: 'form-control', min: 0, max: line_items_visit.arm.subject_count
.input-group
.input-group-prepend
%button.btn.btn-secondary#subjectCountMax{ type: 'button', onclick: "$('#line_items_visit_subject_count').val(#{line_items_visit.arm.subject_count})" }
= t('actions.max')
= f.number_field params[:field], class: 'form-control', min: 0, max: line_items_visit.arm.subject_count
%small.form-text.text-muted
= t('constants.min', min: 0)
= t('constants.max', max: line_items_visit.arm.subject_count)
Expand Down
4 changes: 3 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ en:
activate: "Activate"
add: "Add"
adding: "Adding..."
apply_all: "Apply to all"
back: "Back"
approve: "Approve"
cancel: "Cancel"
Expand All @@ -45,6 +46,7 @@ en:
edit: "Edit"
export: "Export"
filter: "Filter"
max: "Max"
preview: "Preview"
print: "Print"
remove: "Remove"
Expand Down Expand Up @@ -74,7 +76,7 @@ en:
attributes:
arm:
name: "Arm Name"
subject_count: "Subject Count"
subject_count: "Max Subject Count"
visit_count: "Visit Count"
document:
doc_type: "Document Type"
Expand Down

0 comments on commit 96ca8ac

Please sign in to comment.