enhance view management.
authorcavaliet
Mon, 28 Apr 2014 17:40:41 +0200
changeset 282 12ee99b182cd
parent 281 9ff388c9bc8d
child 283 67f3a24a7c01
enhance view management.
client/data/example-cinema.json
client/js/full-json.js
client/js/models.js
client/js/paper-renderer.js
client/test/test-writable-bins.html
--- a/client/data/example-cinema.json	Mon Apr 28 16:11:21 2014 +0200
+++ b/client/data/example-cinema.json	Mon Apr 28 17:40:41 2014 +0200
@@ -622,7 +622,7 @@
     "space_id": "17f968e4-2640-4319-aa61-b5b8b527ebb4",
     "views": [
         {
-            "id": "view-2014-02-18-628af15b-12ad-457a-8ac0-a28c8998cc3b-0001", 
+            "_id": "view-2014-02-18-628af15b-12ad-457a-8ac0-a28c8998cc3b-0001", 
             "zoom_level": 0.8275032552816195, 
             "offset_x": 832.0104075533723,
             "offset_y": 402.8917139487223
--- a/client/js/full-json.js	Mon Apr 28 16:11:21 2014 +0200
+++ b/client/js/full-json.js	Mon Apr 28 17:40:41 2014 +0200
@@ -29,7 +29,7 @@
         function() {
             setTimeout(_save, 100);
         }, 1000);
-    _proj.on("add:nodes add:edges add:users", function(_model) {
+    _proj.on("add:nodes add:edges add:users add:views", function(_model) {
         _model.on("change remove", function(_model) {
             _thrSave();
         });
--- a/client/js/models.js	Mon Apr 28 16:11:21 2014 +0200
+++ b/client/js/models.js	Mon Apr 28 17:40:41 2014 +0200
@@ -147,6 +147,18 @@
                 relatedModel: User
             }
         ],
+        toJSON: function() {
+            return {
+                _id: this.get("_id"),
+                zoom_level: this.get("zoom_level"),
+                offset_x: this.get("offset_x"),
+                offset_y: this.get("offset_y"),
+                title: this.get("title"),
+                description: this.get("description"),
+                created_by: this.get("created_by") ? this.get("created_by").get("_id") : null
+                // Don't need project id
+            };
+        }
     });
         
     // PROJECT
--- a/client/js/paper-renderer.js	Mon Apr 28 16:11:21 2014 +0200
+++ b/client/js/paper-renderer.js	Mon Apr 28 17:40:41 2014 +0200
@@ -1797,7 +1797,7 @@
         bindClick(".Rk-ZoomFit", "autoScale");
         this.$.find(".Rk-ZoomSave").click( function() {
         	// Save scale and offset point
-        	_this.renkan.project.addView( { id:Rkns.Utils.getUID('view'), zoom_level:_this.scale, offset_x:_this.offset.x, offset_y:_this.offset.y } );
+        	_this.renkan.project.addView( { zoom_level:_this.scale, offset_x:_this.offset.x, offset_y:_this.offset.y } );
             _this.$.find(".Rk-ZoomSetSaved").show();
         });
         this.$.find(".Rk-ZoomSetSaved").click( function() {
--- a/client/test/test-writable-bins.html	Mon Apr 28 16:11:21 2014 +0200
+++ b/client/test/test-writable-bins.html	Mon Apr 28 17:40:41 2014 +0200
@@ -58,7 +58,7 @@
                 static_url: "../"
 			});
 			Rkns.jsonIO(_renkan, {
-			    url: "data/simple-persist.php"
+			    url: "../data/simple-persist.php"
 			});
         });
     </script>