Project

General

Profile

Actions

Bug #87060

closed

Adminpanel resetting simulate time javascript error

Added by Einar Gislason over 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
AdminPanel
Target version:
-
Start date:
2018-12-03
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

Admin panel:
After selecting a date, it is currently impossible to reset that date to be empty.

Solution:
In adminpanel/Resources/Public/JavaScript/Modules/Preview.js

Change updateDateField to:

    var updateDateField = function () {
        var dateVal = document.getElementById('preview_simulateDate-date-hr').value;
        var timeVal = document.getElementById('preview_simulateDate-time-hr').value;

        if (dateVal && !timeVal) {
            timeVal =  "00:00";
        }

        if(!dateVal) {
                  // If no date val, assume the date should be reset, regardless of timeVal
            targetField.value = "";
        } else {
            var stringDate = dateVal + " " + timeVal;
            var date = new Date(stringDate);
            targetField.value = date.toISOString();
        }
    };

Essentially this just removes lines 15-18 from the code:

    if (!dateVal && timeVal) {
            var tempDate = new Date();
            dateVal = tempDate.getDate() + "-" + tempDate.getMonth() + "-" + tempDate.getFullYear();
        }

Bonus point: If the code block above doesn't get removed, it at least has to get modified to:

dateVal = tempDate.getFullYear() + "-" + tempDate.getMonth() + "-" + tempDate.getDate();
as the format is wrong :)

Actions

Also available in: Atom PDF