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
|
var BuilderSettings = FormView.extend({
el: "#builderSettings",
createAction: "/api/layouts/new",
updateAction: "/api/layouts/edit",
events: {
"click [data-role='save-layout']": 'save',
},
initialize: function(opt){
this.parent = opt.parent
this.__super__.initialize.call(this)
this.$name = this.$("[name=name]")
this.$newName = this.$("[name=new_name]")
this.$privacy = this.$("[name=privacy]")
},
load: function(data){
this.$name.val(data.name)
this.$newName.val(data.name)
this.$privacy.find("[value=" + data.privacy + "]").prop('checked', true);
},
toggle: function(){
this.$el.toggleClass("active")
},
validate: function(){
var errors = []
var name = this.$name.val()
if (! name || ! name.length) {
errors.push("Layout needs a name.")
}
if (Rooms.count() == 0) {
errors.push("Please add some rooms by drawing boxes.")
}
return errors
},
showErrors: function(errors){
var $errors = $("<span>")
errors.forEach(function(err){
var $row = $("<div>")
$row.html(err)
$errors.append( $row )
})
ErrorModal.alert($errors)
},
serialize: function(){
var fd = new FormData()
fd.append("name", this.$name.val())
fd.append("new_name", this.$newName.val())
fd.append("privacy", this.$privacy.val())
fd.append("rooms", Rooms.serialize())
fd.append("startPosition", app.position(scene.camera))
return fd
},
success: function(){
},
})
|