Developer forum

Forum » Dynamicweb 10 » Change default grid row publication time?

Change default grid row publication time?

Arnór Halldórsson
Arnór Halldórsson
Reply

Hi guys,

I got a question from a client that I wanted to forward to you.

Would it be possible to add a setting to control the default publication start / end time, so that it would f.e. always be 00:00 and end at 23:59? Instead of now, the default value for both is the current time when you click the Show local date and time picker

Example:

Best regards,
Arnór

 


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Arnór

Not sure we can do that. It is a html 5 datetime control with no value set when entering. When you click the calendar it is the browser that handles what happens.

With the native <input type="datetime-local">, you cannot override the suggested initial date/time without setting a value - without ninja hacks...

 
Arnór Halldórsson
Arnór Halldórsson
Reply

Hi Nicolai,

Thanks for the reply :)

You´re correct, you would have to add some javascript to manually set the value of the input like:

    const today = new Date();
    const yyyy = today.getFullYear();
    const mm = String(today.getMonth() + 1).padStart(2, "0");
    const dd = String(today.getDate()).padStart(2, "0");
    const validFromInput = document.getElementById("ValidFrom") as HTMLInputElement | null;
    if (validFromInput) {
      validFromInput.value = `${yyyy}-${mm}-${dd}T00:00`;
    }

And you would have to read the TXX:XX value from a config somewhere in the admin, aaaaaand of course safeguard the value input by the user so you´re not reverting it to the default every time the datepicker is rendered.

Guess it smells a little "hacky".

Best regards,
Arnór

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Yes - and code like this would have to not trigger until the user clicks the icon - and if they escape and choose not to set a date, it should be null again. Causing this to easily become potentially buggy...

Votes for this answer: 1
 
Arnór Halldórsson
Arnór Halldórsson
Reply

Yeah you´re absolutely right.

Thanks anyway! :)

 

You must be logged in to post in the forum