From 2734ff7d4ee2f3b16a8dc3759c2c4abafe2f608c Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 29 Jul 2016 10:44:38 +0200 Subject: [PATCH] add a UI to render proper time picker --- apps/workflowengine/js/requesttimeplugin.js | 105 ++++++++++++++++++-- 1 file changed, 97 insertions(+), 8 deletions(-) diff --git a/apps/workflowengine/js/requesttimeplugin.js b/apps/workflowengine/js/requesttimeplugin.js index aee0e773c9..96cb8a40f7 100644 --- a/apps/workflowengine/js/requesttimeplugin.js +++ b/apps/workflowengine/js/requesttimeplugin.js @@ -24,6 +24,11 @@ OCA.WorkflowEngine.Plugins = OCA.WorkflowEngine.Plugins || {}; OCA.WorkflowEngine.Plugins.RequestTimePlugin = { + timezones: [ + "Europe/Berlin", + "Europe/London" + ], + _$element: null, getCheck: function() { return { 'class': 'OCA\\WorkflowEngine\\Check\\RequestTime', @@ -39,14 +44,98 @@ return; } - var placeholder = '["10:00 Europe\\/Berlin","16:00 Europe\\/Berlin"]'; // FIXME need a time picker JS plugin - $(element).css('width', '300px') - .attr('placeholder', placeholder) - .attr('title', t('workflowengine', 'Example: {placeholder}', {placeholder: placeholder}, undefined, {escape: false})) - .addClass('has-tooltip') - .tooltip({ - placement: 'bottom' - }); + var startTime = '16:00', + endTime = '18:00', + timezone = 'Europe/London', + $element = $(element); + if (_.isString(check['value']) && check['value'] !== '') { + var value = JSON.parse(check['value']), + splittedStart = value[0].split(' ', 2), + splittedEnd = value[1].split(' ', 2); + + startTime = splittedStart[0]; + endTime = splittedEnd[0]; + timezone = splittedStart[1]; + } + var valueJSON = JSON.stringify([startTime + ' ' + timezone, endTime + ' ' + timezone]); + if (check['value'] !== valueJSON) { + check['value'] = valueJSON; + $element.val(valueJSON); + } + + $element.css('display', 'none'); + + $('') + .attr('type', 'text') + .attr('placeholder', t('workflowengine', 'Start')) + .addClass('start') + .val(startTime) + .insertBefore($element); + $('') + .attr('type', 'text') + .attr('placeholder', t('workflowengine', 'End')) + .addClass('end') + .val(endTime) + .insertBefore($element); + + var timezoneSelect = $('