-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathindex.js
58 lines (48 loc) · 1.33 KB
/
index.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
var $ = require('jquery')
var _ = require('underscore')
var Marionette = require('marionette')
var UploadView = require('app/views/missions/upload')
var WorkshopView = require('app/views/missions/workshop')
var ListView = require('app/views/missions/list')
var tpl = require('tpl/missions/index.html')
module.exports = Marionette.LayoutView.extend({
template: _.template(tpl),
templateHelpers: function () {
return {
filterValue: this.filterValue
}
},
regions: {
uploadView: '#upload',
workshopView: '#workshop',
listView: '#list'
},
events: {
'click #refresh': 'refresh',
'keyup #filterMissions': 'updateFilter'
},
initialize: function () {
this.filterValue = ''
},
updateFilter: function (event) {
this.filterValue = event.target.value
this.listView.currentView.filterValue = this.filterValue
this.listView.currentView.render()
},
onRender: function () {
this.uploadView.show(new UploadView())
this.workshopView.show(new WorkshopView())
this.listView.show(new ListView({ collection: this.options.missions, filterValue: this.filterValue }))
},
refresh: function (event) {
event.preventDefault()
$.ajax({
url: 'api/missions/refresh',
type: 'POST',
success: function (resp) {
},
error: function (resp) {
}
})
}
})