summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-08-18 20:01:58 -0400
committerJules Laplace <jules@okfoc.us>2015-08-18 20:01:58 -0400
commitbbd62d9c7f3838d07e42e46c244c317a5dbdb5ae (patch)
tree6f197837e1438f4c5fc5eeac4cf6047b4ca6a8e8
parent83649f62ecbd92cc8a27ca47ac141cc3a81210a1 (diff)
clear shapes
-rw-r--r--public/assets/javascripts/rectangles/engine/shapes/shapelist.js6
-rw-r--r--public/assets/javascripts/ui/blueprint/BlueprintSettings.js38
-rw-r--r--public/assets/javascripts/ui/blueprint/BlueprintView.js5
-rw-r--r--views/controls/blueprint/settings.ejs18
-rw-r--r--views/controls/blueprint/toolbar.ejs2
5 files changed, 16 insertions, 53 deletions
diff --git a/public/assets/javascripts/rectangles/engine/shapes/shapelist.js b/public/assets/javascripts/rectangles/engine/shapes/shapelist.js
index 932ce36..e86c5d6 100644
--- a/public/assets/javascripts/rectangles/engine/shapes/shapelist.js
+++ b/public/assets/javascripts/rectangles/engine/shapes/shapelist.js
@@ -13,6 +13,12 @@ var ShapeList = Fiber.extend(function(base){
this.shapes.splice(index, 1)
}
}
+ exports.destroy = function(){
+ this.shapes.forEach(function(shape){
+ shape.destroy()
+ })
+ this.shapes = []
+ }
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 1ff3d6e..d460a9d 100644
--- a/public/assets/javascripts/ui/blueprint/BlueprintSettings.js
+++ b/public/assets/javascripts/ui/blueprint/BlueprintSettings.js
@@ -2,16 +2,14 @@
var BlueprintSettings = FormView.extend({
el: "#blueprintSettings",
- createAction: "/api/layout/new",
- updateAction: "/api/layout/edit",
- destroyAction: "/api/layout/destroy",
+ action: "/api/blueprint/edit",
+ destroyAction: "/api/blueprint/destroy",
events: {
"mousedown": "stopPropagation",
"keydown": 'stopPropagation',
"keydown [name=name]": 'enterSubmit',
"click [data-role='save-layout']": 'clickSave',
- "click [data-role='clone-layout']": 'clone',
"click [data-role='clear-layout']": 'clear',
"click [data-role='destroy-layout']": 'destroy',
},
@@ -23,40 +21,15 @@ var BlueprintSettings = FormView.extend({
this.$id = this.$("[name=_id]")
this.$csrf = this.$("[name=_csrf]")
this.$name = this.$("[name=name]")
- this.$privacy = this.$("[name=privacy]")
},
load: function(data){
this.$id.val(data._id)
this.$name.val(data.name)
-
- this.parent.colorControl.loadDefaults()
-
- data.rooms && Rooms.deserialize(data.rooms)
- data.startPosition && scene.camera.move(data.startPosition)
- data.privacy && this.$privacy.find("[value=" + data.privacy + "]").prop('checked', "checked")
-
- this.action = data.isNew ? this.createAction : this.updateAction
- },
-
- clone: function(){
- var names = this.$name.val().split(" ")
- if ( ! isNaN(Number( names[names.length-1] )) ) {
- names[names.length-1] = Number( names[names.length-1] ) + 1
- }
- else {
- names.push("2")
- }
-
- this.$id.val('new')
- this.$name.val( names.join(" ") )
- this.action = this.createAction
-
- window.history.pushState(null, document.title, "/builder/new")
},
clear: function(){
- Rooms.removeAll()
+ shapes.destroy()
},
destroy: function(){
@@ -89,10 +62,10 @@ var BlueprintSettings = FormView.extend({
var errors = []
var name = this.$name.val()
if (! name || ! name.length) {
- errors.push("Layout needs a name.")
+ errors.push("Blueprint needs a name.")
}
if (Rooms.count() == 0) {
- errors.push("Please add some rooms by drawing boxes.")
+ errors.push("Please add some walls.")
}
return errors
},
@@ -113,7 +86,6 @@ var BlueprintSettings = FormView.extend({
fd.append( "_csrf", this.$csrf.val() )
fd.append( "_id", this.$id.val() )
fd.append( "name", this.$name.val() )
- fd.append( "privacy", this.$privacy.filter(":checked").val() == "private" )
fd.append( "rooms", JSON.stringify( Rooms.serialize() ) )
fd.append( "startPosition", JSON.stringify( app.position(scene.camera) ) )
fd.append( "thumbnail", dataUriToBlob(thumbnail.toDataURL()) )
diff --git a/public/assets/javascripts/ui/blueprint/BlueprintView.js b/public/assets/javascripts/ui/blueprint/BlueprintView.js
index f919cc7..8330154 100644
--- a/public/assets/javascripts/ui/blueprint/BlueprintView.js
+++ b/public/assets/javascripts/ui/blueprint/BlueprintView.js
@@ -8,7 +8,6 @@ var BlueprintView = View.extend({
},
initialize: function(){
-// this.settings = new BuilderSettings ({ parent: this })
// this.colorControl = new ColorControl ({ parent: this })
// this.cursor = new HelpCursor({ parent: this })
this.map = this.buildMap()
@@ -17,11 +16,11 @@ var BlueprintView = View.extend({
this.uploader = new BlueprintUploader ({ parent: this })
this.scaler = new BlueprintScaler ({ parent: this })
this.info = new BlueprintInfo ({ parent: this })
+ this.settings = new BlueprintSettings ({ parent: this })
},
load: function(name){
if (! name || name == "new") {
-// this.ready({ isNew: true, _id: "new", name: "" })
this.uploader.load()
return
}
@@ -53,7 +52,7 @@ var BlueprintView = View.extend({
},
ready: function(data){
-// this.settings.load(data)
+ this.settings.load(data)
this.info.load(data)
this.editor.loadFloorplan(data)
},
diff --git a/views/controls/blueprint/settings.ejs b/views/controls/blueprint/settings.ejs
index a7ce2f0..1347f5b 100644
--- a/views/controls/blueprint/settings.ejs
+++ b/views/controls/blueprint/settings.ejs
@@ -10,29 +10,15 @@
</div>
<div class="setting">
- <input type="text" name="name" placeholder="layout name">
+ <input type="text" name="name" placeholder="Blueprint name">
</div>
-
- <div class="setting">
- <div class="radio-group">
- <input id="privacy_private" class="radio-group__option" type="radio" name="privacy" value="public" checked>
- <label class="radio-group__label" for="privacy_private">
- Everyone
- </label>
- <input id="privacy_public" class="radio-group__option" type="radio" name="privacy" value="private">
- <label class="radio-group__label" for="privacy_public">
- Just for me
- </label>
- </div>
- </div>
-
+
<div class="setting">
<button data-role="save-layout">Save</button>
</div>
<div class="setting subButtons">
<a href="#" data-role="clear-layout">Clear</a>
- <a href="#" data-role="clone-layout">Clone</a>
<a href="#" data-role="destroy-layout">Delete</a>
</div>
diff --git a/views/controls/blueprint/toolbar.ejs b/views/controls/blueprint/toolbar.ejs
index 82cbcba..9c55a4a 100644
--- a/views/controls/blueprint/toolbar.ejs
+++ b/views/controls/blueprint/toolbar.ejs
@@ -32,7 +32,7 @@
<span
data-role='toggle-layout-settings'
- data-info="save layout"
+ data-info="save blueprint"
class="ion-ios-compose-outline"></span>
</div>
<!--