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 #1

Updated by Andreas Kienast over 5 years ago

  • Status changed from New to In Progress

Well, in JavaScript you need a date to be able to have a valid Date object, even if you only need the time. But there's indeed an issue with the date calculation.

Actions #2

Updated by Gerrit Code Review over 5 years ago

  • Status changed from In Progress to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59047

Actions #3

Updated by Andreas Fernandez over 5 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #4

Updated by Benni Mack about 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF