Skip to content

Commit

Permalink
Merge pull request #5230 from dimagi/old-reminders-edge-case
Browse files Browse the repository at this point in the history
Catch edge case on reminder edit
  • Loading branch information
czue committed Jan 7, 2015
2 parents 2c31f07 + 50b7ff0 commit 48b972c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions corehq/apps/reminders/static/reminders/ko/reminders.manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,23 @@ var ManageRemindersViewModel = function (

self.start_property_offset_type = ko.observable(initial.start_property_offset_type);
self.start_property_offset_type.subscribe(function(val) {
var initial_timing = $.parseJSON(initial.event_timing);
var allow_offset_timing_with_date = (
initial.start_property_offset_type === self.choices.START_REMINDER_ON_CASE_DATE &&
initial_timing.event_interpretation === "OFFSET"
);
$("#id_event_timing").children("option").each(function(i) {
var j = $.parseJSON($(this).val());
if(val === self.choices.START_PROPERTY_OFFSET_IMMEDIATE ||
val === self.choices.START_PROPERTY_OFFSET_DELAY) {
if(allow_offset_timing_with_date && val === self.choices.START_REMINDER_ON_CASE_DATE &&
j.event_interpretation === "OFFSET") {
//This is here to allow editing of any old reminders that started on a date but
//had offset-based event interpretation. This use case is discouraged and is not
//supported by the new ui, but in order to allow editing of any old reminders
//that may use it, we have to show the offset-based event timing options when we
//find a reminder like this.
$(this).show();
} else if(val === self.choices.START_PROPERTY_OFFSET_IMMEDIATE ||
val === self.choices.START_PROPERTY_OFFSET_DELAY) {
$(this).show();
} else {
if(j.event_interpretation === "OFFSET") {
Expand Down

0 comments on commit 48b972c

Please sign in to comment.