From cc0b7c1b3b341f89e91530cb3df59d0be039cce0 Mon Sep 17 00:00:00 2001 From: Martha Rodriguez Date: Mon, 28 Dec 2020 21:32:50 -0600 Subject: [PATCH 1/2] migration created to add daily time fields to migrations table --- ...29031222_add_time_to_medication_daily_reminders.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 db/migrate/20201229031222_add_time_to_medication_daily_reminders.rb diff --git a/db/migrate/20201229031222_add_time_to_medication_daily_reminders.rb b/db/migrate/20201229031222_add_time_to_medication_daily_reminders.rb new file mode 100644 index 0000000000..1fc667b1e6 --- /dev/null +++ b/db/migrate/20201229031222_add_time_to_medication_daily_reminders.rb @@ -0,0 +1,11 @@ +class AddTimeToMedicationDailyReminders < ActiveRecord::Migration[6.0] + def change + add_column :medications, :sunday, :time + add_column :medications, :monday, :time + add_column :medications, :tuesday, :time + add_column :medications, :wednesday, :time + add_column :medications, :thursday, :time + add_column :medications, :friday, :time + add_column :medications, :staurday, :time + end +end From fc53efea8c33cb63c992c67106773e8dc46df116 Mon Sep 17 00:00:00 2001 From: Martha Rodriguez Date: Mon, 28 Dec 2020 22:50:29 -0600 Subject: [PATCH 2/2] medications form helper updated to add time inputs to front end --- app/helpers/medications_form_helper.rb | 52 ++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/app/helpers/medications_form_helper.rb b/app/helpers/medications_form_helper.rb index 47b7b0ced7..3a9fa4da80 100644 --- a/app/helpers/medications_form_helper.rb +++ b/app/helpers/medications_form_helper.rb @@ -87,7 +87,7 @@ def hidden_props(field, value) def medication_weekly_dosage { type: 'checkboxGroup', - checkboxes: days_checkbox, + # checkboxes: days_checkbox, label: t('common.days'), info: t('medications.form.weekly_dosage_hint'), required: true @@ -95,7 +95,7 @@ def medication_weekly_dosage end def extra_fields - [medication_weekly_dosage, medication_refill, medication_comments] + [medication_refill, medication_comments] end def common_fields @@ -107,7 +107,7 @@ def common_fields medication_unit_field('total'), medication_field('dosage'), medication_unit_field('dosage') - ].concat(extra_fields).concat(reminder_fields) + ].concat(daily_reminder).concat(extra_fields).concat(reminder_fields) end def medication_comments @@ -141,6 +141,51 @@ def medication_name }.merge(medication_basic_props('name')) end + def daily_reminder_checkbox(i) + { + id: "medication_weekly_dosage_#{i}", + type: 'checkbox', + label: t(:'date.abbr_day_names')[i], + name: 'medication[weekly_dosage][]', + checked: @medication.weekly_dosage.include?(i), + value: i, + dark: true + } + end + + def daily_reminder_input(i) + { + type: 'time', + name: 'medication[weekly_dosage_time]', + }.merge(medication_basic_props('daily_reminder_input')) + end + + def daily_reminder + [ + medication_weekly_dosage, + daily_reminder_checkbox(0), + daily_reminder_input(0), + + daily_reminder_checkbox(1), + daily_reminder_input(1), + + daily_reminder_checkbox(2), + daily_reminder_input(2), + + daily_reminder_checkbox(3), + daily_reminder_input(3), + + daily_reminder_checkbox(4), + daily_reminder_input(4), + + daily_reminder_checkbox(5), + daily_reminder_input(5), + + daily_reminder_checkbox(6), + daily_reminder_input(6) + ] + end + def medication_refill { type: 'date', @@ -226,5 +271,6 @@ def medication_field(type) required: true }.merge(medication_basic_props(type)) end + end # rubocop:enable Metrics/ModuleLength