diff --git a/cms/static/coffee/spec/views/course_info_spec.coffee b/cms/static/coffee/spec/views/course_info_spec.coffee index 344c95fb47..edcf9bf7a7 100644 --- a/cms/static/coffee/spec/views/course_info_spec.coffee +++ b/cms/static/coffee/spec/views/course_info_spec.coffee @@ -98,15 +98,9 @@ define ["js/views/course_info_handout", "js/views/course_info_update", "js/model @courseInfoEdit.onNew(@event) expect(@courseInfoEdit.$el.find('.save-button').hasClass("is-disabled")).toEqual(false) @courseInfoEdit.$el.find('input.date').val(value).trigger("change") - courseInfoEdit = @courseInfoEdit - jasmine.waitUntil(-> - courseInfoEdit.$el.find('.save-button').hasClass('is-disabled') == true - ).then -> - courseInfoEdit.$el.find('input.date').val('01/01/16').trigger 'change' - jasmine.waitUntil(-> - courseInfoEdit.$el.find('.save-button').hasClass('is-disabled') == false - ).always done - return + expect(@courseInfoEdit.$el.find('.save-button').hasClass("is-disabled")).toEqual(true) + @courseInfoEdit.$el.find('input.date').val("01/01/16").trigger("change") + expect(@courseInfoEdit.$el.find('.save-button').hasClass("is-disabled")).toEqual(false) cancelEditingUpdate = (update, modalCover, useCancelButton) -> if useCancelButton diff --git a/cms/static/js/utils/date_utils.js b/cms/static/js/utils/date_utils.js index 544ea32132..db2b9ff726 100644 --- a/cms/static/js/utils/date_utils.js +++ b/cms/static/js/utils/date_utils.js @@ -15,21 +15,13 @@ function($, date, TriggerChangeEventOnEnter) { var timefield = $(div).find("input.time"); var cacheview = view; var setfield = function (event) { - var newVal = getDate(datefield, timefield), - oldTime = new Date(cacheModel.get(fieldName)).getTime(); - if (newVal) { - if (!cacheModel.has(fieldName) || oldTime !== newVal.getTime()) { - cacheview.clearValidationErrors(); - cacheview.setAndValidate(fieldName, newVal, event); - } - } - else { - // Clear date (note that this clears the time as well, as date and time are linked). - // Note also that the validation logic prevents us from clearing the start date - // (start date is required by the back end). - cacheview.clearValidationErrors(); - cacheview.setAndValidate(fieldName, null, event); - } + var newVal = getDate(datefield, timefield); + + // Setting to null clears the time as well, as date and time are linked. + // Note also that the validation logic prevents us from clearing the start date + // (start date is required by the back end). + cacheview.clearValidationErrors(); + cacheview.setAndValidate(fieldName, (newVal || null), event); }; // instrument as date and time pickers diff --git a/cms/static/js/views/course_info_update.js b/cms/static/js/views/course_info_update.js index 7b5babc771..0a3c0277c0 100644 --- a/cms/static/js/views/course_info_update.js +++ b/cms/static/js/views/course_info_update.js @@ -71,7 +71,7 @@ define(["js/views/validation", "codemirror", "js/models/course_update", }, handleValidationError : function(model, error) { - var ele = this.$el.find('#course-update-list li[name=\"'+model.cid+'\"'); + var ele = this.$el.find('#course-update-list li[name=\"'+model.cid+'\"]'); $(ele).find('.message-error').remove(); for (var field in error) { if (error.hasOwnProperty(field)) { @@ -86,7 +86,7 @@ define(["js/views/validation", "codemirror", "js/models/course_update", validateModel: function(model) { if (model.isValid()) { - var ele = this.$el.find('#course-update-list li[name=\"' + model.cid + '\"'); + var ele = this.$el.find('#course-update-list li[name=\"' + model.cid + '\"]'); $(ele).find('.message-error').remove(); $(ele).find('.save-button').removeClass('is-disabled'); }