Closed sibinx7 closed 8 years ago
Hey, thanks for the elaborate explanation.
Can you also add the js code for the addTaskForm template?
Thanks for your quick reply
This plugin save lots of time, thank you very much.
/**
* Created by Sibin Xavier on 2/10/2016.
*/
Meteor.startup(function(){
Wizard.useRouter('kadira:flow-router');
Template.addTaskForm.onCreated(function(){
Schemas.workingFor = new SimpleSchema({
working_for:{
type: String,
label:'Working For'
}
});
Schemas.Quantify = new SimpleSchema({
quantify: {
type: String,
label: 'Quantify'
}
});
Schemas.Achieve = new SimpleSchema({
achieved: {
type: String,
label: 'Achieve'
}
});
Schemas.SlowDown = new SimpleSchema({
slow_down: {
type: String,
label: 'Slow Down'
}
});
Schemas.Resolve = new SimpleSchema({
resolve: {
type: String,
label: 'Resolved'
}
});
Schemas.Tomorrow = new SimpleSchema({
tomorrow:{
type: String,
label:'Tomorrow'
}
});
Tasks.attachSchema([
Schemas.workingFor,
Schemas.quantify,
Schemas.Achieve,
Schemas.SlowDown,
Schemas.Resolve,
Schemas.Tomorrow
]);
});
});
Template.addTaskForm.helpers({
steps: function(){
var todayDate = moment().format('DD/MM/YYYY');
var getLatestOne = Tasks.findOne({
date: todayDate,
user_id: Meteor.userId()
},{
fields : {
working_for: 1,
quantity: 1,
achieved: 1,
resolve: 1,
slow_down: 1,
tomorrow: 1
}
});
return [
{
id:'working_for',
title:'Working On',
schema: Schemas.workingFor,
data: getLatestOne,
formId:'working_for-form',
template: 'wizardWidget',
onSubmit: function(data, wizard){
saveOrUpdateWizard(data,wizard)
wizard.next(data)
}
},
{
id: 'quantify',
title: 'Quantify',
schema: Schemas.Quantify,
data: getLatestOne,
formId:'quantify-form',
template: 'wizardWidget',
onSubmit: function(data,wizard){
saveOrUpdateWizard(data,wizard);
// if time is less than 11:00 AM, then
// redirect to home page, else
// continue
if(moment().hour() > 11){
wizard.next(data)
}else{
wizard.show('quantify')
}
}
},
{
id: 'achieved',
title: 'Achieved',
schema: Schemas.Achieve,
data: getLatestOne,
formId: 'achieved-form',
template: 'wizardWidget',
onSubmit: function(data, wizard){
saveOrUpdateWizard(data,wizard)
wizard.next(data)
}
},
{
id: 'slow_down',
title: 'Slow Down',
schema: Schemas.SlowDown,
data: getLatestOne,
formId:'slow_down-form',
template: 'wizardWidget',
onSubmit: function(data, wizard){
saveOrUpdateWizard(data,wizard)
wizard.next(data)
}
},
{
id: 'resolve',
title: 'Resolve',
schema: Schemas.Resolve,
data: getLatestOne,
formId: 'resolve-form',
template: 'wizardWidget',
onSubmit: function(data, wizard){
saveOrUpdateWizard(data,wizard)
wizard.next(data)
}
},
{
id: 'tomorrow',
title: 'Tomorrow',
schema: Schemas.Tomorrow,
data: getLatestOne,
formId: 'tomorrow-form',
template: 'wizardWidget',
onSubmit: function(data, wizard){
var complete_data =_.extend(wizard.mergedData(),data);
Meteor.call('saveTask',complete_data, Meteor.user(), function(err, result){
if(typeof result!="undefined" && result!=""){
FlowRouter.go('/')
}
})
}
}
]
}
});
saveOrUpdateWizard = function(data, wizard){
var completeData = _.extend(wizard.mergedData(), data)
Meteor.call('saveTask', completeData, Meteor.user(), function(err, result){
if(result){
// result
}
if(err){
console.log(err)
}
})
};
When i set data to each steps it now working ( i'm not sure, sometime it won't work ),
Live Demo : teamreporter.herokuapp.com ( old code without data attribute on each step)
Also i'm very new to meteor, not an expert...
Did you manage to solve the problem?
@Pagebakers
var getLatestOne = Tasks.findOne({
date: todayDate,
user_id: Meteor.userId()
},{
fields : {
working_for: 1,
quantity: 1,
achieved: 1,
resolve: 1,
slow_down: 1,
tomorrow: 1
}
});
return [
{
id:'working_for',
title:'Working On',
schema: Schemas.workingFor,
data: getLatestOne,
formId:'working_for-form',
template: 'wizardWidget',
onSubmit: function(data, wizard){
saveOrUpdateWizard(data,wizard)
wizard.next(data)
}
}]
getLatestOne getLatestOne = Last filled data ( daily task of user )
I have added data property for each step, now i think it working( lgetLatestOne), it working.
If i add doc = data (same data, in autoform ), I think it only work if we don't do hard refresh or use any new browser ( After filling fields, if i use any other browser or open a tab in private mode, it won't work but it work after i adding data property for each step).
Thanks for your valuable support.
I have a wizard, i which I can add data, it only accept first 2 step at morning, and users can fill remaining data later. If i enter data and logout, then come back again it show the last step ( 2 or 3rd step depend upon users input, if they fill 2, i need to show 2nd step). This working fine but if i am referesh page ( ctrl +R) or use another browser, it show first page eventhough i have filled something. Please check screenshots
After hard refresh/ new browser ( 2 fields are already filled, check left sidebar), If i press next ( first step), then second step show empty field
After finishing some input, logout, then came back, then it work, it show all filled data.
I use autoform inside this wizard
Template : Wizard
Template : Forms inside Widget
wizardWidget Javascript