summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--public/assets/javascripts/rectangles/engine/shapes/shapelist.js3
-rw-r--r--public/assets/javascripts/ui/blueprint/BlueprintSettings.js8
-rw-r--r--server/lib/schemas/Blueprint.js7
3 files changed, 12 insertions, 6 deletions
diff --git a/public/assets/javascripts/rectangles/engine/shapes/shapelist.js b/public/assets/javascripts/rectangles/engine/shapes/shapelist.js
index c3b5758..d8a03b2 100644
--- a/public/assets/javascripts/rectangles/engine/shapes/shapelist.js
+++ b/public/assets/javascripts/rectangles/engine/shapes/shapelist.js
@@ -19,6 +19,9 @@ var ShapeList = Fiber.extend(function(base){
})
this.shapes = []
}
+ exports.count = function(){
+ return this.shapes.length
+ }
exports.removeSegment = function (segment){
var shape = segment.shape
var head = shape.getHeadAtIndex(segment.head)
diff --git a/public/assets/javascripts/ui/blueprint/BlueprintSettings.js b/public/assets/javascripts/ui/blueprint/BlueprintSettings.js
index d460a9d..f9c9e78 100644
--- a/public/assets/javascripts/ui/blueprint/BlueprintSettings.js
+++ b/public/assets/javascripts/ui/blueprint/BlueprintSettings.js
@@ -26,6 +26,7 @@ var BlueprintSettings = FormView.extend({
load: function(data){
this.$id.val(data._id)
this.$name.val(data.name)
+ this.data = data
},
clear: function(){
@@ -64,7 +65,7 @@ var BlueprintSettings = FormView.extend({
if (! name || ! name.length) {
errors.push("Blueprint needs a name.")
}
- if (Rooms.count() == 0) {
+ if (shapes.count() == 0) {
errors.push("Please add some walls.")
}
return errors
@@ -81,14 +82,13 @@ var BlueprintSettings = FormView.extend({
},
serialize: function(){
- var thumbnail = map.draw.render()
var fd = new FormData()
fd.append( "_csrf", this.$csrf.val() )
fd.append( "_id", this.$id.val() )
fd.append( "name", this.$name.val() )
- fd.append( "rooms", JSON.stringify( Rooms.serialize() ) )
+ fd.append( "shapes", JSON.stringify( shapes.serialize() ) )
fd.append( "startPosition", JSON.stringify( app.position(scene.camera) ) )
- fd.append( "thumbnail", dataUriToBlob(thumbnail.toDataURL()) )
+ fd.append( "thumbnail", this.data.url )
return fd
},
diff --git a/server/lib/schemas/Blueprint.js b/server/lib/schemas/Blueprint.js
index 40e67d8..78a388f 100644
--- a/server/lib/schemas/Blueprint.js
+++ b/server/lib/schemas/Blueprint.js
@@ -29,7 +29,7 @@ var BlueprintSchema = new mongoose.Schema({
type: Number,
default: 0
},
- title: {
+ name: {
type: String,
default: ""
},
@@ -44,7 +44,10 @@ var BlueprintSchema = new mongoose.Schema({
heightDimension: { type: Number },
units: { type: String },
line: { type: String },
-
+
+ rooms: [mongoose.Schema.Types.Mixed],
+ startPosition: mongoose.Schema.Types.Mixed,
+
user_id: { type: mongoose.Schema.ObjectId, index: true },
created_at: { type: Date },
});