Giter Club home page Giter Club logo

Comments (4)

Pagebakers avatar Pagebakers commented on July 18, 2024

Hey, thanks for the elaborate explanation.

Can you also add the js code for the addTaskForm template?

from meteor-wizard.

sibinx7 avatar sibinx7 commented on July 18, 2024

Thanks for your quick reply

This plugin save lots of time, thank you very much.

Javascript

/**
 * 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...

from meteor-wizard.

Pagebakers avatar Pagebakers commented on July 18, 2024

Did you manage to solve the problem?

from meteor-wizard.

sibinx7 avatar sibinx7 commented on July 18, 2024

@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.

from meteor-wizard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.