Commit f535b2d4 authored by Jérome Perrin's avatar Jérome Perrin

allow changing the name of an element

parent 6f66a0ad
...@@ -98,6 +98,10 @@ ...@@ -98,6 +98,10 @@
var element_id_prefix = element_id.split("_")[0]; var element_id_prefix = element_id.split("_")[0];
var property_list = configuration[element_id_prefix].property_list || []; var property_list = configuration[element_id_prefix].property_list || [];
var previous_data = that.getData()["element"]; var previous_data = that.getData()["element"];
var element_name = previous_data[element_id]['name'] || element_id;
fieldset.append('<label>Name</label><input type="text" name="name" id="name" value="' + element_name + '" class="text ui-widget-content ui-corner-all"/>');
previous_data = previous_data[element_id] || {}; previous_data = previous_data[element_id] || {};
previous_data = previous_data.data || {}; previous_data = previous_data.data || {};
var previous_value; var previous_value;
...@@ -147,6 +151,7 @@ ...@@ -147,6 +151,7 @@
if (prefix === undefined) { if (prefix === undefined) {
prefix = ""; prefix = "";
} }
$.each(property_list, function(key, property) { $.each(property_list, function(key, property) {
if (property._class === "Dream.Property") { if (property._class === "Dream.Property") {
prefixed_property_id = prefix + property.id; prefixed_property_id = prefix + property.id;
...@@ -159,8 +164,10 @@ ...@@ -159,8 +164,10 @@
} }
}); });
}; };
updateDataPropertyList(property_list, data); updateDataPropertyList(property_list, data);
that.updateElementData(element_id, {data: data}); that.updateElementData(element_id, {data: data, name: $("#name").val() || element_id});
$( this ).dialog( "close" ); $( this ).dialog( "close" );
}, },
}, },
......
...@@ -166,6 +166,9 @@ ...@@ -166,6 +166,9 @@
that.updateElementData = function (element_id, data) { that.updateElementData = function (element_id, data) {
$.extend(priv.element_container[element_id], data); $.extend(priv.element_container[element_id], data);
if (data['name']) {
$("#" + element_id).text(data["name"]);
}
priv.onDataChange(); priv.onDataChange();
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment