/** * @copyright Copyright (c) 2016 Joas Schilling * * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ (function() { OCA.WorkflowEngine = OCA.WorkflowEngine || {}; 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', 'name': t('workflowengine', 'Request time'), 'operators': [ {'operator': 'in', 'name': t('workflowengine', 'between')}, {'operator': '!in', 'name': t('workflowengine', 'not between')} ] }; }, render: function(element, check) { if (check['class'] !== 'OCA\\WorkflowEngine\\Check\\RequestTime') { return; } 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 = $('