-
Notifications
You must be signed in to change notification settings - Fork 0
/
hybrisPoll.js
111 lines (96 loc) · 2.44 KB
/
hybrisPoll.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
Polls = new Meteor.Collection("polls");
Polls.attachSchema(new SimpleSchema({
email: {
type: String,
regEx: SimpleSchema.RegEx.Email,
label: "Email"
},
ecranV: {
type: Number,
allowedValues: [1, 2, 3, 4, 5],
label: "Ecran ventes",
optional:true
},
ecranP: {
type: Number,
allowedValues: [1, 2, 3, 4, 5],
label: "Ecran P - Produits",
optional:true
},
ecranU: {
type: Number,
allowedValues: [1, 2, 3, 4, 5],
label: "Ecran U - Arborescence",
optional:true
},
ecranF: {
type: Number,
allowedValues: [1, 2, 3, 4, 5],
label: "Ecran F - Famille des produits",
optional:true
},
preview: {
type: Number,
allowedValues: [1, 2, 3, 4, 5],
label: "Preview",
optional:true
},
commentaire: {
type: String,
label: "Commentaires",
optional:true
}
}));
if (Meteor.isClient) {
Template.viewAll.val = function () {
console.log(this);
return this;
};
Template.pollUpdate.editingDoc = function(){
var poll = Session.get("currentPoll");
console.log(poll);
return poll;
}
Template.home.events({
'click #action':function(){
var email = $("#myEmail")[0].value;
var poll = Polls.findOne({email:email});
if (poll)
{
Session.set("currentPoll", poll);
$('#pollUpdate').modal('toggle');
}
else
{
$('#createEmail')[0].value = email;
$('#pollCreate').modal('toggle');
}
//Session.set("currentEmail", $("#myEmail")[0].value);
//Router.go('/update/'+ $("#myEmail")[0].value);
}
});
// Template.update.events({
// 'click #update':function(){
// Router.go('home');
// }
//});
AutoForm.hooks({
"insertPollForm":{
after: {
insert: function(error, result, template) {console.log(result)},
},
// Called when any operation succeeds, where operation will be
// "insert", "update", or the method name.
onSuccess: function(operation, result, template)
{
console.log(result)
Session.set("currrentPoll", result)
},
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}