-
Notifications
You must be signed in to change notification settings - Fork 0
/
form-test.coffee
61 lines (52 loc) · 1.41 KB
/
form-test.coffee
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
if Meteor.isClient
Template['changePasswordForm'].helpers
schema: ->
new SimpleSchema(
currentPassword:
type: String
min: 4
instructions: 'Current password'
label: 'Current password'
newPassword:
type: String
min: 4
label: 'New password'
confirmPassword:
type: String
min: 4
label: 'Confirm new password'
custom: ->
if @value != @field('newPassword').value
return "passwordMismatch"
true
)
action: ->
(els, callbacks, changed) ->
Accounts.changePassword(@currentPassword, @newPassword, (error) ->
unless error
callbacks.success()
callbacks.reset()
else
callbacks.failed()
)
Template['formBlock'].helpers
isNull: ->
if arguments[0] == 0 and arguments[1] == false
return false
else
return true
SimpleSchema.messages
passwordMismatch: "New passwords do not match."
ReactiveForms.createElement
template: 'inputField'
validationEvent: 'keyup'
reset: (el) ->
$(el).val(null)
ReactiveForms.createElement
template: 'passwordField'
validationEvent: 'keyup'
reset: (el) ->
$(el).val(null)
ReactiveForms.createFormBlock
template: 'formBlock'
submitType: 'normal'