98 lines
2.2 KiB
JavaScript
98 lines
2.2 KiB
JavaScript
$(function(){
|
|
|
|
mh.initScoresModel = function(){
|
|
var timer;
|
|
|
|
function fAddScoreType(i, s){
|
|
var dit = this;
|
|
this.nr = s.sysnr;
|
|
this.omschrijving = s.omschrijving;
|
|
this.opties = ko.observableArray();
|
|
if(s.opties){
|
|
$.each(s.opties, function(x, o){
|
|
dit.opties.push(new fAddOptie(x, o))
|
|
});
|
|
}
|
|
}
|
|
|
|
function fAddOptie(x, o){
|
|
this.id = o.id;
|
|
this.optie = o.optie;
|
|
this.scoretekst = ko.observable(o.omschrijving ? o.omschrijving : 'niet beschikbaar');
|
|
this.scoretekstoud = ko.observable(o.omschrijving ? o.omschrijving : 'niet beschikbaar');
|
|
|
|
}
|
|
|
|
if (mh.ScoresModel !== undefined){
|
|
mh.ScoresModel.initModel();
|
|
}
|
|
else {
|
|
mh.ScoresModel = {
|
|
scoretypes : ko.observableArray([]),
|
|
selectedType : ko.observable(),
|
|
editok : ko.observable(false),
|
|
newScoretekst : ko.observable(),
|
|
|
|
|
|
initBindings :function(){
|
|
var self = mh.ScoresModel;
|
|
if (!ko.dataFor(document.getElementById('pagScores')) ) {
|
|
ko.applyBindings(mh.ScoresModel, document.getElementById("pagScores"));
|
|
}
|
|
$.post("index.php/monpas/swvversies/getAntwoordtypesEnOmschrijving" , function(types){
|
|
self.scoretypes.removeAll();
|
|
if (types){
|
|
|
|
$.each(types, function(i,s){
|
|
if(s.opties) {
|
|
self.scoretypes.push(new fAddScoreType(i, s));
|
|
}
|
|
}); // each
|
|
|
|
|
|
}; // if
|
|
self.initModel();
|
|
},'json');
|
|
},
|
|
initModel: function(){
|
|
var self =mh.ScoresModel;
|
|
|
|
},
|
|
|
|
fChangeScoretype: function(){
|
|
var self = mh.ScoresModel;
|
|
|
|
},
|
|
|
|
fEditOmschrijving: function(){
|
|
var self = mh.ScoresModel;
|
|
self.editok(!self.editok());
|
|
},
|
|
|
|
fSaveEdit: function(){
|
|
var self = mh.ScoresModel;
|
|
var dit = this;
|
|
if (timer){
|
|
clearTimeout(timer);
|
|
timeout = null;
|
|
}
|
|
timer = setTimeout(function(){
|
|
var submitData=
|
|
{id : dit.id,
|
|
omschrijving : dit.scoretekst(),
|
|
};
|
|
|
|
|
|
$.post("index.php/monpas/swvversies/updateAntwoordopties",submitData, function(result){
|
|
|
|
},'json');
|
|
},700);
|
|
|
|
},
|
|
|
|
|
|
} ; // definition van model
|
|
mh.ScoresModel.initBindings();
|
|
}; // else
|
|
}// function initScoresModel
|
|
}); |