From 4163a40a5e2dfba9c0c407c48a4f098fe8364601 Mon Sep 17 00:00:00 2001 From: p0zi Date: Fri, 21 Oct 2016 01:37:42 +0200 Subject: [PATCH 1/2] 218 - Unable to edit providers breaks in Google Chrome [https://github.com/alextselegidis/easyappointments/issues/218] --- src/assets/js/working_plan.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/assets/js/working_plan.js b/src/assets/js/working_plan.js index a1ed8f96..e38f3a87 100644 --- a/src/assets/js/working_plan.js +++ b/src/assets/js/working_plan.js @@ -283,21 +283,25 @@ * Save the editable values and restore the table to its initial state. * * @param {jQuery.Event} e + * + * @todo: Prevent from adding interrelated breaks */ $(document).on('click', '.save-break', function(e) { // Break's start time must always be prior to break's end. var element = e.target, - start = Date.parse($(element).parent().parent().find('.break-start input').val()), - end = Date.parse($(element).parent().parent().find('.break-end input').val()); + $editedTr = $(element).closest('tr'), + start = Date.parse($editedTr.find('.break-start input').val()), + end = Date.parse($editedTr.find('.break-end input').val()); + if (start > end) { - $(element).parent().parent().find('.break-end input').val(start.addHours(1).toString('HH:mm')); + $editedTr.find('.break-end input').val(start.addHours(1).toString('HH:mm')); } this.enableSubmit = true; - $(element).parent().parent().find('.editable .submit-editable').trigger('click'); + $editedTr.find('.editable .submit-editable').trigger('click'); this.enableSubmit = false; - $(element).parent().find('.save-break, .cancel-break').addClass('hidden'); + $(element).closest('table').find('.save-break, .cancel-break').addClass('hidden'); $(element).closest('table').find('.edit-break, .delete-break').removeClass('hidden'); $('.add-break').prop('disabled', false); }.bind(this)); @@ -307,6 +311,8 @@ * Get the working plan settings. * * @return {Object} Returns the working plan settings object. + * + * @todo: Add sorting by range within day breaks */ WorkingPlan.prototype.get = function() { var workingPlan = {}; @@ -329,6 +335,11 @@ 'end': end }); } + + workingPlan[id].breaks.sort(function(break1, break2) { + // We can do a direct string comparison since we have time based on 24 hours clock + return break1.start - break2.start; + }); }.bind(this)); } else { workingPlan[id] = null; @@ -444,4 +455,4 @@ window.WorkingPlan = WorkingPlan; -})(); +})(); \ No newline at end of file From 5534ebd1f749b0689e2c2a9053c6e78ba9f795a8 Mon Sep 17 00:00:00 2001 From: p0zi Date: Fri, 21 Oct 2016 01:54:54 +0200 Subject: [PATCH 2/2] 218 - Unable to edit providers breaks in Google Chrome [https://github.com/alextselegidis/easyappointments/issues/218] Small fix to previous commit --- src/assets/js/working_plan.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets/js/working_plan.js b/src/assets/js/working_plan.js index e38f3a87..ccf067a1 100644 --- a/src/assets/js/working_plan.js +++ b/src/assets/js/working_plan.js @@ -301,7 +301,7 @@ $editedTr.find('.editable .submit-editable').trigger('click'); this.enableSubmit = false; - $(element).closest('table').find('.save-break, .cancel-break').addClass('hidden'); + $editedTr.find('.save-break, .cancel-break').addClass('hidden'); $(element).closest('table').find('.edit-break, .delete-break').removeClass('hidden'); $('.add-break').prop('disabled', false); }.bind(this));