Commit a9ac5818 authored by Boris Kocherov's avatar Boris Kocherov

rerender() use keyword arguments now

parent 9d7adfd1
...@@ -257,7 +257,10 @@ ...@@ -257,7 +257,10 @@
return generateSchema(settings); return generateSchema(settings);
}) })
.push(function (schema) { .push(function (schema) {
return gadget_settings.rerender(rerender_path, schema); return gadget_settings.rerender({
path: rerender_path,
schema: schema
});
}) })
.push(function () { .push(function () {
// return g.notifyChange(); // return g.notifyChange();
......
...@@ -963,25 +963,41 @@ ...@@ -963,25 +963,41 @@
return g; return g;
}); });
}) })
.declareMethod('rerender', function (path, schema) { .declareMethod('rerender', function (opt) {
var g = this, var g = this,
gadget; gadget,
if (path) { queue = RSVP.Queue();
return g.props.form_gadget.getGadgetByPath(path) if (opt.path) {
queue
.push(function () {
return g.props.form_gadget.getGadgetByPath(opt.path);
})
.push(function (ret) { .push(function (ret) {
gadget = ret.gadget; gadget = ret.gadget;
});
}
if (opt.scope) {
queue
.push(function () {
return g.props.form_gadget.getDeclaredGadget(opt.scope);
})
.push(function (ret) {
gadget = ret;
});
}
return queue
.push(function () {
return gadget.getContent(); return gadget.getContent();
}) })
.push(function (value) { .push(function (value) {
return gadget.rerender({ return gadget.rerender({
schema: schema, schema: opt.schema,
value: value value: value
}) })
.push(function () { .push(function () {
return gadget.reValidate(value, schema); return gadget.reValidate(value, opt.schema);
}); });
}); });
}
}) })
.allowPublicAcquisition("expandSchema", function (arr) { .allowPublicAcquisition("expandSchema", function (arr) {
......
...@@ -625,11 +625,16 @@ ...@@ -625,11 +625,16 @@
gadget.props.add_custom_data[scope] = { gadget.props.add_custom_data[scope] = {
element: g.element, element: g.element,
event: function () { event: function () {
var notify = {
action: "add"
};
return g.getContent() return g.getContent()
.push(function (value) { .push(function (value) {
return event(schema_alternatives[value[scope]].value); return event(schema_alternatives[value[scope]].value);
}) })
.push(function () { .push(function (v) {
notify.scope = v.scope;
notify.path = v.path;
if (rerender) { if (rerender) {
return rerender(g, schema_alternatives); return rerender(g, schema_alternatives);
} }
...@@ -639,9 +644,7 @@ ...@@ -639,9 +644,7 @@
return g.render(render_options); return g.render(render_options);
}) })
.push(function () { .push(function () {
// XXX need path argument return gadget.rootNotifyChange(notify);
// absent in current context
return gadget.rootNotifyChange();
}); });
}, },
rerender: function () { rerender: 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