ZoomApps / Liveapp

Liveapp Framework :rocket:
https://www.liveapp.com.au
2 stars 1 forks source link

date filter error onsave #37

Closed jaffars closed 6 years ago

jaffars commented 7 years ago

image

Getting ReportDate filter issue for incident module in CIMSXpress.After degugging the issue the it was pointing to the PageViewer.js

Function - this.OnSave = function (close, skipcheck, okclicked) { //Update filters. m_record.Filter(filters[i][0], f.Value);

The above line is stripping a bracket ")". from the m_record.view object

view = WHERE(UserID=CONST(52),Status=CONST(Open),ProgramID=FILTER(520),FF$ProgramID=FILTER(Residential - Acacia House),ReportDate=FILTER(Thu Sep 14 2017 00:00:00 GMT+1000 (AUS Eastern Standard Time)))

stripped view looks like this:- WHERE(UserID=CONST(52),Status=CONST(Open),ProgramID=FILTER(520),FF$ProgramID=FILTER(Residential - Acacia House),ReportDate=FILTER(Thu Sep 14 2017 00:00:00 GMT+1000 (AUS Eastern Standard Time))

Issue is in the regular expression:-

Application.GetFilters = function (view, friendify) {

friendify = Default(friendify,true);

var arr = new Array();

view = Default(view,"");

//Issue #36 - View errors when it contains a comma or equals sign.
if (view.indexOf("WHERE") != -1) {

    view = view.replace("WHERE (", "WHERE(");

    **var check = new RegExp("\\,*(.*?)\\=\\s*(\\w+)\\s*\\((.*?)\\)", 'g');**
    var matches = view.substr(view.indexOf("WHERE(") + 6).match(check);
    if (matches) {
        for (var i = 0; i < matches.length; i++) {

            var name = matches[i].replace(check, '$1');
            var type = matches[i].replace(check, '$2');
            var filt = matches[i].replace(check, '$3');

            if(!friendify){
                arr.push(name.trim()+"="+type+"("+filt+")");
            }else{
                arr.push([name.trim(),filt]);
            }
        }
    }
}

return arr;

};

jaffars commented 7 years ago

I added below line to provide a temporary fix

if(f.Type=="Date")
{
    var dt=new Date(f.Value);
    if(dt!==null)
    {
        f.Value=$.format.date(dt, 'dd/MM/yy');
    }
}

m_record.Filter(filters[i][0], f.Value); - I entered the my fix above this line on pageviewer.js->this.OnSave = function (close, skipcheck, okclicked) {

paulfisher53 commented 6 years ago

Please load this fix: Fix-37.zip

NOTE: It is different from the fix @jaffars has supplied. I suggest you remove that fix before merging this one in

jaffars commented 6 years ago

tested and verified