hi everybody this is my first project in meteor js. i’m using Meteor 1.4.1.1 whit this packages : aldeed:collection2 2.10.0 i have this field in my collection
Clienti.ClienteSchema = new SimpleSchema({
cantieri: {
type: [Clienti.Cantieri],
optional: true,
autoform: {
type: "hidden"
}
}
});
Clienti.Cantieri = new SimpleSchema({
giorni: {
type: [Clienti.Giorni],
optional: true,
autoform: {
type: "hidden"
}
}
});
Clienti.Giorni = new SimpleSchema({
giorno: {
type: Date,
label: "giorno del lavoro"
},
oraPartenza: {
type: Date,
label: 'Giorno e ora partenza',
},
oraInizio: {
type: Date,
label: 'Giorno e ora inizio',
optional: true
},
oraFine: {
type: Date,
label: 'Giorno e ora fine',
optional: true
},
dipendenti: {
type: [Dipendenti]
}
});
with form i’d like submit the last field Giorni in a existing Cliente.cantiere.
i proceded so: this field form
Template.nuovoGiorno.events({
'submit #Giorno'(event) {
event.preventDefault();
const id = FlowRouter.getParam('id');
const target = event.target;
const giorno = target.giorno.value;
const oraPartenza = target.oraPartenza.value;
let select = target.dipendenti.options;
let selezionati=[];
for (var i = 0; i < select.length; i++) {
var option = select[i];
if (option.selected){
console.log(id);
console.log('opzione ' + option.value);
Clienti.update({_id:id}, {$set:{
'cantieri.giorni.giorno': giorno,
'cantieri.giorni.oraPartenza': oraPartenza,
'cantieri.giorni.dipendenti._id': option.value
}});
}
}
}
});
but doesn’t work. i need rewrite the code or there is a way more efficiently to do it? help me please.