Commit da8c0b3d authored by Boris Kocherov's avatar Boris Kocherov

rerender work for addSchemaButtons too

parent fea39d15
...@@ -577,18 +577,44 @@ ...@@ -577,18 +577,44 @@
if (schema_alternatives.length === 1) { if (schema_alternatives.length === 1) {
return RSVP.Queue() return RSVP.Queue()
.push(function () { .push(function () {
if (rerender) {
return rerender(undefined, schema_alternatives);
}
return true;
})
.push(function (ret) {
var input = document.createElement("button"); var input = document.createElement("button");
input.setAttribute("class", input.setAttribute("class",
"ui-shadow-inset ui-btn ui-btn-inline ui-corner-all" + "ui-shadow-inset ui-btn ui-btn-inline ui-corner-all" +
" ui-btn-icon-notext ui-icon-btn ui-icon-plus ui-input-btn"); " ui-btn-icon-notext ui-icon-btn ui-icon-plus ui-input-btn");
input.type = "button"; input.type = "button";
input.hidden = !ret;
gadget.props.add_buttons.push({ gadget.props.add_buttons.push({
element: input, element: input,
event: function () { event: function () {
return event(schema_alternatives[0].value) return event(schema_alternatives[0].value)
.push(function () { .push(function () {
if (rerender) {
return rerender(undefined, schema_alternatives);
}
return true;
})
.push(function (r) {
input.hidden = !r;
return checkValidityAndNotifyChange(gadget); return checkValidityAndNotifyChange(gadget);
}); });
},
rerender: function () {
return RSVP.Queue()
.push(function () {
if (rerender) {
return rerender(undefined, schema_alternatives);
}
return true;
})
.push(function (r) {
input.hidden = !r;
});
} }
}); });
return input; return input;
...@@ -978,14 +1004,17 @@ ...@@ -978,14 +1004,17 @@
item_list.push([item.title, x]); item_list.push([item.title, x]);
} }
} }
if (gadget_s) {
return { return {
name: gadget_s.element.getAttribute('data-gadget-scope'), name: gadget_s.element.getAttribute('data-gadget-scope'),
editable: true, editable: true,
hidden: item_list.length === 0, hidden: item_list.length === 1,
value: item_list[0][1], value: item_list[0][1],
item_list: item_list item_list: item_list
}; };
} }
return item_list.length > 1;
}
}); });
}) })
.push(function (element) { .push(function (element) {
...@@ -1235,6 +1264,8 @@ ...@@ -1235,6 +1264,8 @@
.allowPublicAcquisition("deleteChildren", function (arr, scope) { .allowPublicAcquisition("deleteChildren", function (arr, scope) {
var g = this, var g = this,
key, key,
i,
button_list = this.props.add_buttons,
objects = this.props.objects, objects = this.props.objects,
element = getSubGadgetElement(g, scope), element = getSubGadgetElement(g, scope),
parent = element.getAttribute("data-json-parent"), parent = element.getAttribute("data-json-parent"),
...@@ -1253,6 +1284,9 @@ ...@@ -1253,6 +1284,9 @@
tasks.push(g.props.add_custom_data[key].rerender()); tasks.push(g.props.add_custom_data[key].rerender());
} }
} }
for (i = 0; i < button_list.length; i = i + 1) {
tasks.push(button_list[i].rerender());
}
tasks.push(checkValidityAndNotifyChange(g)); tasks.push(checkValidityAndNotifyChange(g));
return RSVP.Queue() return RSVP.Queue()
.push(function () { .push(function () {
......
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