Commit cd0da176 authored by Boris Kocherov's avatar Boris Kocherov

fix creating new property

parent ab0c6934
...@@ -305,7 +305,8 @@ ...@@ -305,7 +305,8 @@
property_name, property_name,
parent_path, parent_path,
scope; scope;
return RSVP.Queue()
.push(function () {
scope = generateUid(g); scope = generateUid(g);
parent_path = options.parent_path; parent_path = options.parent_path;
if (options.parent_type !== "array") { if (options.parent_type !== "array") {
...@@ -314,21 +315,18 @@ ...@@ -314,21 +315,18 @@
property_name = input_element.value; property_name = input_element.value;
} }
if (!property_name) { if (!property_name) {
// XXX notify user throw new Error("can't create property without name");
// you can't create property without property_name
return RSVP.Queue();
} }
if (g.props.objects[parent_path].hasOwnProperty(property_name) && g.props.objects[parent_path][property_name] !== "") { if (g.props.objects[parent_path].hasOwnProperty(property_name) && g.props.objects[parent_path][property_name] !== "") {
// XXX notify user throw new Error("you can't create property with existed name");
// you can't create property with existed property_name
return RSVP.Queue();
} }
if (input_element) { if (input_element) {
input_element.value = ""; input_element.value = "";
} }
} }
return g.declareGadget('gadget_json_generated_form_child.html', {scope: scope}) return g.declareGadget('gadget_json_generated_form_child.html', {scope: scope});
})
.push(function (form_gadget) { .push(function (form_gadget) {
form_gadget.element.setAttribute("data-gadget-parent-scope", form_gadget.element.setAttribute("data-gadget-parent-scope",
g.element.getAttribute("data-gadget-scope")); g.element.getAttribute("data-gadget-scope"));
...@@ -663,6 +661,9 @@ ...@@ -663,6 +661,9 @@
return event(schema_alternatives[value[scope]].value); return event(schema_alternatives[value[scope]].value);
}) })
.push(function (v) { .push(function (v) {
if (v) {
return RSVP.Queue()
.push(function () {
notify.scope = v.scope; notify.scope = v.scope;
notify.path = v.path; notify.path = v.path;
if (rerender) { if (rerender) {
...@@ -676,6 +677,8 @@ ...@@ -676,6 +677,8 @@
.push(function () { .push(function () {
return gadget.rootNotifyChange(notify); return gadget.rootNotifyChange(notify);
}); });
}
});
}, },
rerender: function () { rerender: function () {
return RSVP.Queue() return RSVP.Queue()
...@@ -722,6 +725,9 @@ ...@@ -722,6 +725,9 @@
}; };
return event(schema_alternatives[0].value) return event(schema_alternatives[0].value)
.push(function (v) { .push(function (v) {
if (v) {
return RSVP.Queue()
.push(function () {
notify.scope = v.scope; notify.scope = v.scope;
notify.path = v.path; notify.path = v.path;
if (rerender) { if (rerender) {
...@@ -737,6 +743,8 @@ ...@@ -737,6 +743,8 @@
} }
return gadget.rootNotifyChange(notify); return gadget.rootNotifyChange(notify);
}); });
}
});
}, },
rerender: function () { rerender: function () {
return RSVP.Queue() return RSVP.Queue()
...@@ -1269,7 +1277,11 @@ ...@@ -1269,7 +1277,11 @@
type: value.type, type: value.type,
schema_arr: [value] schema_arr: [value]
}) })
.push(element_append); .push(element_append)
.push(undefined, function (err) {
// XXX notify user
console.error(err);
});
}); });
}); });
return queue; return queue;
......
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