js: widgets

ha h.

januari is al zo’n beetje voor de helft voorbij gevliedt en ik ben nog steeds oude code aan het herschrijven. hopelijk zal blijken dat de wat stevigere fundamenten (json, data-models, observer pattern, widgets) zullen leiden tot snellere implementatie van functionaliteit !

gr,
m

//widget call-in function:

//this.mm = mm; //if extended
this.fcall_in = function(args){
fb(mm.container + '::fcall_in:' + fstringify(args));

if(!args.hasOwnProperty('reqAct')){
fb("ERROR no reqAct property." + mm.container);
}

var res = {}, tmp ='';
switch(args.reqAct){
case "reqGetData":
res = _fUIGetInputVals();
break;
case "reqSetData": // {navCode: reset|btnX , data : the-recs-as-from-converter}
if(args.navCode == 'reset' || args.navCode == 'btnCancel'
|| args.navCode == 'btnOk'){
if(args.navCode == 'reset' || args.navCode == 'btnOk'){
mm.nav.setQRecs(args.data.recs.length); //auto-moves 'first'
//so delete is a bit unfriendly bwth ftm... zz99
}

res = mm.nav.move('nomove');
if(args.navCode == 'btnOk' && mm.crudState == 'AOC'){res = mm.nav.move('last');}

$(mm.elbase + '.infolabel').html(res.navInfo);

if(args.data.recs.length>0){
_fUISetInputVals(args.data.ui2db,args.data.recs[parseInt(res.curr)]);
_fSetCrudState('PNAD');
}else{
_fUISetGetEmptyRecVals();
_fSetCrudState('A');
}
}else if(args.navCode == 'btnNext' || args.navCode == 'btnPrevious'){
(args.navCode == 'btnNext') ? tmp = 'next' : tmp = 'previous';
res = mm.nav.move(tmp);//res eg: {"curr":0,"qrecs":12,"navInfo":"1/12"}
$(mm.elbase + '.infolabel').html(res.navInfo);
_fUISetInputVals(args.data.ui2db,args.data.recs[parseInt(res.curr)]);
}
break;
/*case "reqSetEmptyData":
res = _fUISetGetEmptyRecVals();
break;*/
case "reqSetCrudState": //return as reqGetVals but with empties/defaults (?)
res= _fSetCrudState(args.crudState,'');
break;
case "reqGetNavInfo": //ao: handle parent(maps) move, so child (markers) can be synched
res = mm.nav.move('nomove');
break;
default:
fb("ERROR unknown reqAct:" + args.reqAct);
}
return res;
};