From 6a2ee9cc4868fa046330aaf45ac2942d22b42337 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 18 Jan 2016 12:58:57 -0500 Subject: [PATCH] Set some values based on current calendar view, reset modal on click --- js/calendar/mods-for-hesk-calendar.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/js/calendar/mods-for-hesk-calendar.js b/js/calendar/mods-for-hesk-calendar.js index bcf0c13a..6203f277 100644 --- a/js/calendar/mods-for-hesk-calendar.js +++ b/js/calendar/mods-for-hesk-calendar.js @@ -8,7 +8,6 @@ $(document).ready(function() { editable: true, eventLimit: true, events: function(start, end, timezone, callback) { - console.log('in events'); $.ajax({ url: getHelpdeskUrl() + '/internal-api/admin/calendar/?start=' + start + '&end=' + end, method: 'GET', @@ -22,7 +21,7 @@ $(document).ready(function() { }); }, dayClick: function(date, jsEvent, view) { - displayCreateModal(date); + displayCreateModal(date, view.name); } }); @@ -33,10 +32,27 @@ $(document).ready(function() { }); }); -function displayCreateModal(date) { +function displayCreateModal(date, viewName) { + $('input[name="name"]').val(''); + $('input[name="location"]').val(''); + $('textarea[name="comments"]').val(''); + var $modal = $('#create-event-modal'); var formattedDate = date.format('YYYY-MM-DD'); $modal.find('input[name="start-date"]').val(formattedDate).end() - .find('input[name="end-date"]').val(formattedDate); + .find('input[name="end-date"]').val(formattedDate).end(); + if (viewName === 'month') { + // Select "All Day" + $('input[name="all-day"]').prop('checked', true); + $('.clockpicker').hide(); + } else { + $('input[name="all-day"]').prop('checked', false); + $('.clockpicker').show(); + var formattedTime = date.format('h:mm:ss'); + var selectedHour = date.hour(); + $modal.find('input[name="start-time"]').val(formattedTime).end() + .find('input[name="end-time"]').val(date.hour(selectedHour + 1).format('h:mm:ss')); + } + $('#create-event-modal').modal('show'); } \ No newline at end of file