client/js/renderer/nodeeditor.js
changeset 331 0628ed75e8d3
parent 330 4f92e61f87ba
child 384 6a7930a0d4d1
--- a/client/js/renderer/nodeeditor.js	Thu Sep 11 16:49:45 2014 +0200
+++ b/client/js/renderer/nodeeditor.js	Fri Sep 19 17:54:55 2014 +0200
@@ -22,7 +22,7 @@
                 '</div></div><p><label><%-renkan.translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p>' +
                 '<p><label><%-renkan.translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p><% } %>' +
                 '<% if (options.show_node_editor_creator && node.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>' +
-                '<% if (options.change_shapes) { %><p><label><%-renkan.translate("Shapes available:")%></label><select class="Rk-Edit-Shape">' +
+                '<% if (options.change_shapes) { %><p><label><%-renkan.translate("Shapes available")%>:</label> <select class="Rk-Edit-Shape">' +
                 '<option class="Rk-Edit-Vocabulary-Property" value="circle"<% if (node.shape === "circle") { %> selected<% } %>><%- renkan.translate("Circle") %></option>' +
                 '<option class="Rk-Edit-Vocabulary-Property" value="rectangle"<% if (node.shape === "rectangle") { %> selected<% } %>><%- renkan.translate("Square") %></option>' +
                 '<option class="Rk-Edit-Vocabulary-Property" value="diamond"<% if (node.shape === "diamond") { %> selected<% } %>><%- renkan.translate("Diamond") %></option>' +
@@ -101,17 +101,23 @@
                                 _data.description = _this.editor_$.find(".Rk-Edit-Description").val();
                             }
                             if (_this.options.change_shapes) {
-                                _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val();
-                                _data.shape_changed = true;
+                                if(_model.get("shape")!==_this.editor_$.find(".Rk-Edit-Shape").val()){
+                                    _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val();
+                                    _data.shape_changed = true;
+                                }
                             }
                             _model.set(_data);
                             _this.redraw();
+                            // For an unknown reason, we have to set data twice when we change shape, otherwise the image disappears.
+                            if(_data.shape_changed===true){
+                                _model.set(_data);
+                            }
                         } else {
                             closeEditor();
                         }
                     }).defer();
                 }).throttle(500);
-
+                
                 this.editor_$.on("keyup", function(_e) {
                     if (_e.keyCode === 27) {
                         closeEditor();