Skip to content

Commit

Permalink
Issue #3483: Enabled DF datetime value set on AJAX update.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhaerter authored and svenoe committed Jun 13, 2024
1 parent ae2bd40 commit 72b99ac
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
15 changes: 14 additions & 1 deletion var/httpd/htdocs/js/Core.AJAX.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// OTOBO is a web-based ticketing system for service organisations.
// --
// Copyright (C) 2001-2020 OTRS AG, https://otrs.com/
// Copyright (C) 2019-2024 Rother OSS GmbH, https://otobo.de/
// Copyright (C) 2019-2024 Rother OSS GmbH, https://otobo.io/
// --
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -375,8 +375,15 @@ Core.AJAX = (function (TargetNS) {
var $Element = $('#' + DataKey);

if ((!$Element.length || typeof DataValue == 'undefined') && !$Element.is('textarea')) {

// catch multivalue case where DataKey is present in attribute name
$Element = $('[name=' + DataKey + ']');

// date time elements
if ( !$Element.length ) {
$Element = $('[name=' + DataKey + 'Used]').parent();
}

if ((!$Element.length || typeof DataValue == 'undefined')) {
return;
}
Expand Down Expand Up @@ -423,6 +430,12 @@ Core.AJAX = (function (TargetNS) {
return;
}

// date time
if ( $Element.hasClass('DynamicFieldDate') ) {
Core.UI.InputFields.SetDate($Element, DataValue);
return;
}

// reference fields
// both hidden and visible input element need to be set
var $ReferenceElement = $Element.parent().find('.DynamicFieldReference');
Expand Down
31 changes: 30 additions & 1 deletion var/httpd/htdocs/js/Core.UI.InputFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// OTOBO is a web-based ticketing system for service organisations.
// --
// Copyright (C) 2001-2020 OTRS AG, https://otrs.com/
// Copyright (C) 2019-2024 Rother OSS GmbH, https://otobo.de/
// Copyright (C) 2019-2024 Rother OSS GmbH, https://otobo.io/
// --
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -3132,6 +3132,35 @@ Core.UI.InputFields = (function (TargetNS) {
return false;
};

/**
* @name SetDate
* @memberof Core.UI.InputFields
* @function
* @returns {Boolean} false
* @param {$Parent} jQuery div element containing a date selection
* @param {DateString} string with date to set
* @description
* This function sets a given date for a given date selection
*/
TargetNS.SetDate = function ($Parent, DateString) {
var DateObj = new Date(DateString);
var $YearElement = $Parent.find('select[id$=Year]');
$YearElement.val(DateObj.getFullYear());
var $MonthElement = $Parent.find('select[id$=Month]');
$MonthElement.val(DateObj.getMonth() + 1);
var $DayElement = $Parent.find('select[id$=Day]');
$DayElement.val(DateObj.getDate());
var $HourElement = $Parent.find('select[id$=Hour]');
if ( $HourElement.length ) {
$HourElement.val(DateObj.getHours());
}
var $MinuteElement = $Parent.find('select[id$=Minute]');
if ( $MinuteElement.length ) {
$MinuteElement.val(DateObj.getMinutes());
}
return true;
};

// jsTree plugin for multi selection without modifier key
// Skip ESLint check below for no camelcase property, we are overriding an existing one!
$.jstree.defaults.multiselect = {};
Expand Down

0 comments on commit 72b99ac

Please sign in to comment.