Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Date selector should display current value

Locked
tschutter
Posts: 15
Joined: Fri Nov 23, 2012 11:31 pm

Date selector should display current value

Unread post by tschutter »

I am using nubuilder-v2.7.4.11-12.10.24-Build529 on Ubuntu 12.10 browsing with Chromium 22.0.1229.94.

When the user clicks on the date selector for a field, the selector should reflect the current value, not today's date. If the current value is NULL, then today's date is acceptable.

The current behavior makes it difficult to slightly adjust a date value, and it is not what most users expect.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Date selector should display current value

Unread post by admin »

zazzium
Posts: 84
Joined: Mon Jul 04, 2011 12:52 am

Re: Date selector should display current value

Unread post by zazzium »

actually it's a good point. I have noticed the users do stupid date entries, probably this is the reason.

My solution (not the best, because I hardcoded my date format in nuCalendar.js)
I added a new function to
productionnu2/common.js

Code: Select all

/**
* convert date to JavaScript format
* date - date string
* format - date strings format (y-m-d || d-m-y || m-d-y)
*/
function jsDate(date,format)
{
    if(format == 'yyyy-mm-dd' || format == 'y-m-d' || format == 'Y-m-d' || format == 'Y-mm-dd' )
    {
        date_split = date.split('-');
        convertDate = date_split[1]+"/"+date_split[2]+"/"+date_split[0]; 
    }
    if(format == 'dd-mm-yyyy' || format == 'd-m-y' || format == 'd-m-Y' || format == 'dd-mm-Y' )
    {
        date_split = date.split('-');
        convertDate = date_split[1]+"/"+date_split[0]+"/"+date_split[2]; 
    }
    if(format == 'mm-dd-yyyy' || format == 'm-d-y' || format == 'm-d-Y' || format == 'mm-dd-Y' )
    {
        date_split = date.split('-');
        convertDate = date_split[0]+"/"+date_split[1]+"/"+date_split[2]; 
    }
    
    return convertDate;
}
and modified the file
productionnu2/nuCalendar.js

modified rows:
27
44-53 (in row 48 is declared which date format to use (d-m-y) or (m-d-y) or (y-m-d))
202-207

its works for me because i use always the same date format on forms.
If u use different formats on different forms then dont use this solution
You do not have the required permissions to view the files attached to this post.
martbarr
Posts: 60
Joined: Fri Oct 26, 2012 8:09 pm

Re: Date selector should display current value

Unread post by martbarr »

Hi Zazzium, thanks for the code.

I don't really like amending core files ... but in the absence of a formal solution hey what do we do?
Just means I have to remember each time I upgrade.

I wonder if there will be an "official" solution at some point?

cheers
Martin
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Date selector should display current value

Unread post by admin »

.
Locked