From ed5ee3235e5f377e9485fc0f65d6fe6571a91d2a Mon Sep 17 00:00:00 2001 From: MichiK <6341204+der-michik@users.noreply.github.com> Date: Wed, 5 Dec 2018 18:43:51 +0100 Subject: Add timepickers in shifts view --- resources/assets/js/forms.js | 42 ++++++++++++++++++++++++++++++++++ resources/views/pages/user-shifts.html | 21 ++++------------- 2 files changed, 46 insertions(+), 17 deletions(-) (limited to 'resources') diff --git a/resources/assets/js/forms.js b/resources/assets/js/forms.js index f1581907..3f2014d0 100644 --- a/resources/assets/js/forms.js +++ b/resources/assets/js/forms.js @@ -125,3 +125,45 @@ $(function () { }); }); }); + +/* + * Add a timepicker to all time input fields. + */ +$(function () { + $('.input-group.time').each(function () { + var elem = $(this); + var opts = { + locale: 'en', + format: 'HH:mm', + widgetPositioning: {horizontal: 'auto', vertical: 'bottom'} + }; + $.extend(opts, elem.data()); + elem.children('input').attr('type', 'text'); + elem.datetimepicker(opts); + elem.children('input').on('click', function (ev) { + ev.stopImmediatePropagation(); + elem.data('DateTimePicker').toggle(); + }); + }); +}); + +/* + * Button to set current time in time input fields. + */ +$(function () { + $('.input-group.time').each(function () { + var elem = $(this); + elem.find('button').on('click', function () { + var input = elem.children('input').first(); + input.val(moment().format('HH:mm')); + var day_selector = $('#' + input.attr('id').replace('time', 'day')); + var days = day_selector.children('option'); + days.each(function (i) { + if ($(days[i]).val() === moment().format('YYYY-MM-DD')) { + day_selector.val($(days[i]).val()); + return false; + } + }); + }); + }); +}); diff --git a/resources/views/pages/user-shifts.html b/resources/views/pages/user-shifts.html index 3b75ac7f..f467c6fd 100644 --- a/resources/views/pages/user-shifts.html +++ b/resources/views/pages/user-shifts.html @@ -1,16 +1,3 @@ - -
@@ -18,11 +5,11 @@

%title%

%start_select%
-
+
-
@@ -31,11 +18,11 @@ –
%end_select%
-
+
-
-- cgit v1.2.3-54-g00ecf