ende 0.5.13 → 0.5.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/assets/javascripts/widgets/accreditor/main.js.coffee +96 -0
- data/lib/assets/javascripts/widgets/accreditor/presenter.js.coffee +9 -0
- data/lib/assets/javascripts/widgets/accreditor/states/default.html +49 -0
- data/lib/assets/javascripts/widgets/accreditor/states/index.js.coffee +2 -0
- data/lib/ende/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0ab47790786a055f8bd08d30db788c7739ffb13
|
4
|
+
data.tar.gz: f77c4bf89a7aebeb81afb4ad95abcf09fb8e8c84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f8255a4cc67e96c4d542a7ed8a925304153ea12c90fd52d9a59b6b4849302ab142ece9a3944ec72ab081713ce61480243771d3ec1d7ca9bd3267660a70b02b9
|
7
|
+
data.tar.gz: 50c34abbfb0c4bd7a74c5a3a8b5e5645495872cd375042126c2db0c4e06627b24ab70d3806aab42fa1b61bb5fd4289bb5be635e3c07158b9c69ccb16395565c5
|
@@ -0,0 +1,96 @@
|
|
1
|
+
define ['./states/index', './presenter'], (templates, presenter) ->
|
2
|
+
|
3
|
+
type: 'Base'
|
4
|
+
|
5
|
+
# TODO add devise extension as requirement
|
6
|
+
|
7
|
+
# Widget initialization method, will be called upon loading, options
|
8
|
+
# are already filled with defaults
|
9
|
+
initialize: (options) ->
|
10
|
+
sandbox = @sandbox
|
11
|
+
@scope = @sandbox.resource 'user'
|
12
|
+
sandbox.logger.log "initialized!"
|
13
|
+
|
14
|
+
# Will also initialize sandbox!
|
15
|
+
@html templates.default
|
16
|
+
|
17
|
+
# Bind presenter to template
|
18
|
+
@user = @scope()
|
19
|
+
|
20
|
+
ui =
|
21
|
+
status: 'idle'
|
22
|
+
|
23
|
+
classes: =>
|
24
|
+
"widget #{ui.status} accreditor"
|
25
|
+
|
26
|
+
button_label: "Cadastrar"
|
27
|
+
# TODO add support for custom resources on devise to move
|
28
|
+
# accreditation logic to devi=se
|
29
|
+
# TODO move accreditation logic to devise extension!
|
30
|
+
accredit: (event, models) ->
|
31
|
+
return false if ui.status.match 'loading'
|
32
|
+
|
33
|
+
{user} = models
|
34
|
+
|
35
|
+
ui.status = 'loading blocked'
|
36
|
+
ui.button_label = "Validando dados..."
|
37
|
+
user.validate().done (record) ->
|
38
|
+
if !record.errors.length
|
39
|
+
user.save accreditation.done, accreditation.failed
|
40
|
+
else
|
41
|
+
ui.status = "error blocked"
|
42
|
+
ui.button_label = "Confira os errors acima."
|
43
|
+
|
44
|
+
setTimeout ->
|
45
|
+
ui.status = "error"
|
46
|
+
ui.button_label = "Cadastrar"
|
47
|
+
, 2000
|
48
|
+
|
49
|
+
event.preventDefault()
|
50
|
+
|
51
|
+
changed: (event, models) -> models.user.dirty = true
|
52
|
+
|
53
|
+
accreditation =
|
54
|
+
done: (attributes, status, xhr) =>
|
55
|
+
setTimeout =>
|
56
|
+
|
57
|
+
# TODO move accreditation logic to devise extension!
|
58
|
+
# TODO figure out why mongoid renders incorrect id!
|
59
|
+
attributes._id = attributes._id['$oid'] if attributes._id['$oid']
|
60
|
+
|
61
|
+
# TODO move accreditation logic to devise extension!
|
62
|
+
app.sandbox.signed_in = true
|
63
|
+
current_user = sandbox.models.user()
|
64
|
+
current_user.assign_attributes attributes
|
65
|
+
sandbox.current_user = current_user
|
66
|
+
sandbox.signed_in = true
|
67
|
+
|
68
|
+
# TODO implement as a indemma extension
|
69
|
+
token = xhr.getResponseHeader 'X-CSRF-Token'
|
70
|
+
console.error "Server did not send the new csrf token.\n User may not be logged in!" unless token
|
71
|
+
$('meta[name="csrf-token"]').attr 'content', token
|
72
|
+
|
73
|
+
sandbox.emit 'session.created', current_user
|
74
|
+
sandbox.emit 'user.signed_in' , current_user
|
75
|
+
|
76
|
+
sandbox.emit "accreditor.#{@identifier}.accredited", @
|
77
|
+
, 2000
|
78
|
+
|
79
|
+
ui.status = "success blocked"
|
80
|
+
ui.button_label = "Cadastro realizado! Preparando seu mural de anúncios..."
|
81
|
+
|
82
|
+
failed: =>
|
83
|
+
sandbox.emit "accreditor.#{@identifier}.accreditation_failed", @errors
|
84
|
+
|
85
|
+
ui.status = "error blocked"
|
86
|
+
ui.button_label = "Erro ao efetuar cadastro!"
|
87
|
+
|
88
|
+
setTimeout ->
|
89
|
+
ui.status = "error"
|
90
|
+
ui.button_label = 'Cadastrar'
|
91
|
+
, 2000
|
92
|
+
|
93
|
+
@user.dirty = true
|
94
|
+
presentation = presenter ui, @user
|
95
|
+
@$el.attr 'data-class', 'accreditor.classes < accreditor.status'
|
96
|
+
@bind presentation
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<div class="popup-form">
|
2
|
+
|
3
|
+
<h1>Cadastre-se</h1>
|
4
|
+
|
5
|
+
<div class="block dark">
|
6
|
+
<div class="form">
|
7
|
+
<form accept-charset="UTF-8" action="/users" class="new_user" id="new_user" method="post" data-on-change="accreditor.changed">
|
8
|
+
|
9
|
+
<div class="form-group" data-class-invalid="user.errors.messages.name">
|
10
|
+
<input type="text" data-value="user.name" class="form-control input-lg" placeholder="nome">
|
11
|
+
<div class="tooltip right">
|
12
|
+
<div class="tooltip-inner" data-html="user.errors.messages.name"></div>
|
13
|
+
<div class="tooltip-arrow"></div>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<div class="form-group" data-class-invalid="user.errors.messages.email">
|
18
|
+
<input type="email" data-value="user.email" class="form-control input-lg" placeholder="e-mail" />
|
19
|
+
<div class="tooltip right">
|
20
|
+
<div class="tooltip-inner" data-html="user.errors.messages.email"></div>
|
21
|
+
<div class="tooltip-arrow"></div>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<div class="form-group" data-class-invalid="user.errors.messages.password">
|
26
|
+
<input id="user-password" type="password" class="form-control input-lg" data-value="user.password" placeholder="senha" />
|
27
|
+
<div class="tooltip right">
|
28
|
+
<div class="tooltip-inner" data-html="user.errors.messages.password"></div>
|
29
|
+
<div class="tooltip-arrow"></div>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div class="form-group" data-class-invalid="user.errors.messages.password_confirmation">
|
34
|
+
<input type="password" class="form-control input-lg" data-value="user.password_confirmation" placeholder="repita a senha" />
|
35
|
+
<div class="tooltip right">
|
36
|
+
<div class="tooltip-inner" data-html="user.errors.messages.password_confirmation"></div>
|
37
|
+
<div class="tooltip-arrow"></div>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<button type="submit" class="btn btn-block btn-success btn-lg" data-on-click="accreditor.accredit" data-html="accreditor.button_label">
|
42
|
+
Cadastrar
|
43
|
+
</button>
|
44
|
+
|
45
|
+
</form>
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
|
49
|
+
</div>
|
data/lib/ende/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ende
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Heitor Salazar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -198,6 +198,10 @@ files:
|
|
198
198
|
- lib/assets/javascripts/config/load_components.js.coffee
|
199
199
|
- lib/assets/javascripts/ende.js.coffee
|
200
200
|
- lib/assets/javascripts/value_objects/phone.js.coffee
|
201
|
+
- lib/assets/javascripts/widgets/accreditor/main.js.coffee
|
202
|
+
- lib/assets/javascripts/widgets/accreditor/presenter.js.coffee
|
203
|
+
- lib/assets/javascripts/widgets/accreditor/states/default.html
|
204
|
+
- lib/assets/javascripts/widgets/accreditor/states/index.js.coffee
|
201
205
|
- lib/assets/javascripts/widgets/attachable/main.js.coffee
|
202
206
|
- lib/assets/javascripts/widgets/authenticator/main.js.coffee
|
203
207
|
- lib/assets/javascripts/widgets/authenticator/presenter.js.coffee
|