-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
56 lines (43 loc) · 1.24 KB
/
app.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
(function() {
return {
events: {
'app.activated': 'activated',
'ticket.save' : 'trySave',
'click .reject': 'safeDone',
'click .accept': 'setAssigneeAndSafeDone'
},
activated: function(){
this.switchTo('modal', { modal_message: this.I18n.t('modal.main',
{ name: this.currentUser().name() })});
},
trySave: function(){
if (this.canSave()) { return true; }
this.modalField().modal('show');
return this.promise(function(done, fail) {
var self = this;
this.done = done;
this.timeoutId = setTimeout(function() {
self.safeDone();
}, 15000);
});
},
canSave: function(){
return this.ticket().assignee().user() ||
this.ticket().status() !== 'solved';
},
setAssigneeAndSafeDone: function(){
this.ticket().assignee({
userId: this.currentUser().id()
});
this.safeDone();
},
safeDone: function(){
if (this.timeoutId) { clearTimeout(this.timeoutId); }
this.modalField().modal('hide');
return this.done && this.done();
},
modalField: function(){
return this.$('.assign-on-solve-modal');
}
};
}());