Page 1 of 1

Date selector should display current value

Posted: Tue Nov 27, 2012 3:55 am
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.

Re: Date selector should display current value

Posted: Tue Nov 27, 2012 5:25 am
by admin

Re: Date selector should display current value

Posted: Fri Nov 30, 2012 5:36 pm
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

Re: Date selector should display current value

Posted: Wed Jan 09, 2013 6:04 pm
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

Re: Date selector should display current value

Posted: Mon Jan 14, 2013 3:45 am
by admin
.