コード例 #1
0
ファイル: form.js プロジェクト: reinvdwoerd/estimates
import {uid, updateProperty, getFieldAttributes} from '../../utils'


/**
 * Reorder FormOptions
 */

const reload			= _ => sortable('#form-options')[0].addEventListener('sortupdate', updateOrder)
const updateOrder = ({detail}) => Meteor.call('swapOrder', detail.index, detail.oldindex)


Template.form.rendered = reload


Template.form.helpers({
	formoptions: _ => FormOptions.find({}, {sort: {order: 1}})
})


Template.form.events({

	/**
	 * Add/Remove
	 * - set the order to be the last item in the collection
	 */
	'click .new' () {
		FormOptions.insert(new FormOption(FormOptions.find().count()))
		reload()
	},

	'click .form-option > .remove' (e) {
コード例 #2
0
ファイル: form.js プロジェクト: CrsOystr/sBase
Template.autoformer.helpers({
    categoriesHelper: function(){
        var cats = ["C"];
        var sure = ["ok", "rip"];
        Websites.find().forEach(function(obj){
            cats.push(obj.media)
        })
        return [
          {label: "2013", value: 2013},
          {label: "2014", value: 2014},
          {label: "2015", value: 2015}
        ];
    }
});

Template.form.events({
  'submit'(event, template) {
      event.preventDefault();
      console.log("clicked");
      console.log('rekt');
      const target = event.target;
      const url = target.handle.value;
      const handle = target.handle.value;
      console.log(url);
      console.log(handle);

      Meteor.call('userprofiles.insert','Reddit', url, handle);
  },
});
コード例 #3
0
ファイル: main.js プロジェクト: steyr-werke/Messeanmeldung
Template.form.onRendered(() => {
    var form = $("#addProjectForm");
    form.validate({
        rules: {
            inputProjectName: {
                required: true,
                maxlength: 100
            },
            inputProjectDescription: {
                maxlength: 800
            },
            inputFirstName: {
                maxlength: 100
            },
            inputSurName: {
                required: true,
                maxlength: 100
            },
            inputEmail: {
                email: true
            },
            inputSpaceBundle: {
                required: true
            },
            inputElectricityDemand: {
                maxlength: 500
            },
            inputCity: {
                maxlength: 100
            },
            inputParticipationCondition: {
                required: true
            }
        },
        messages: {
            inputProjectName: {
                required: "<p class='text-danger'>Du musst einen Namen f&uuml;r das Projekt angeben!</p>",
                maxlength: "<p class='text-danger'>Maximales Zeichenlimit &uuml;berschritten!</p>"
            },
            inputProjectDescription: {
                maxlength: "<p class='text-danger'>Maximales Zeichenlimit &uuml;berschritten!</p>"
            },
            inputFirstName: {
                maxlength: "<p class='text-danger'>Maximales Zeichenlimit &uuml;berschritten!</p>"
            },
            inputSurName: {
                required: "<p class='text-danger'>Dein Name ist eine Pflichtangabe!</p>",
                maxlength: "<p class='text-danger'>Maximales Zeichenlimit &uuml;berschritten!</p>"
            },
            inputEmail: {
                email: "<p class='text-danger'>Gib einen g&uuml;ltige Mailadresse ein!</p>"
            },
            inputSpaceBundle: {
                required: "<p class='text-danger'>Pflichtangabe!</p>"
            },
            inputElectricityDemand: {
                maxlength: "<p class='text-danger'>Maximales Zeichenlimit &uuml;berschritten!</p>"
            },
            inputCity: {
                maxlength: "<p class='text-danger'>Maximales Zeichenlimit &uuml;berschritten!</p>"
            },
            inputParticipationCondition: {
                required: "<p class='text-danger'>Du musst den Teilnahmebedingungen zustimmen, um bei der Messe ausstellen zu k&ouml;nnen!</p>"
            }
        },
        submitHandler() {
            let submissionProps = {
                //Project Props
                "Project": $("#inputProjectName").val(),
                "ProjectProps": {
                    "ProjectDescription": $("#inputProjectDescription").val(),

                    //Demand Probs
                    "ProjectDemand": {
                        "SpaceBundle": $("input[name='inputSpaceBundle']:checked").val(),
                        "Electricity": $("#inputElectricity").val(),
                        "ElectricityDemand": $("#inputElectricityDemand").val(),
                        "LogisticSlots": $("#inputLogisticsSlots").val(),
                        "LogisticHelp": $("#inputLogisticsHelp").val()
                    }
                },
                //Submitter Probs
                "ProjectContact": {
                    "FirstName": $("#inputFirstName").val(),
                    "SurName": $("#inputSurName").val(),
                    "Contact": {
                        "Email": $("#inputEmail").val(),
                        "Tel": $("#inputTel").val(),
                        "Addr": {
                            "Address": $("#inputAddress").val(),
                            "PostalCode": $("#inputPostalCode").val(),
                            "City": $("#inputCity").val()
                        }
                    },
                    "ConditionOfParticipation": ($("#inputParticipationCondition").val() === "on") ? "yes" : "no"
                },
                "Submitter": Meteor.userId(),
                "SubmittedAt": new Date()
            };

            //console.log(submissionProps);

            //DB insert
            Meteor.call("insertSubmission", submissionProps, function(error, result) {
                if (error) {
                    return alert(error.reason);
                }
            });

            Router.go("submissionFinished");
        }
    });
});