Commit 3cd406b7 authored by Boris Kocherov's avatar Boris Kocherov

add getSubGadget()

parent c53ac880
...@@ -706,6 +706,31 @@ ...@@ -706,6 +706,31 @@
this.props.errors[arr[1]] = arr[0]; this.props.errors[arr[1]] = arr[0];
} }
}) })
.declareMethod('getSubGadget', function (scope) {
// recursive getDeclaredGadget
// work only if subgadget scope contain parent
// scope as prefix
// example:
// gadget: scope1234
// subgadet: scope1234_subgadgetscope1
// subsubgadet: scope1234_subgadgetscope1_subsubgadetscope
var i,
gadget = this,
scope_arr = scope.split('_'),
queue = RSVP.Queue()
.push(function () {
return gadget.props.form_gadget;
});
function getDeclaredGadget(scope) {
return function (g) {
return g.getDeclaredGadget(scope);
};
}
for (i = 2; i <= scope_arr.length; i += 1) {
queue.push(getDeclaredGadget(scope_arr.slice(0, i).join('_')));
}
return queue;
})
.declareMethod('getGadgetByPath', function (path) { .declareMethod('getGadgetByPath', function (path) {
return this.props.form_gadget.getGadgetByPath(path || "/"); return this.props.form_gadget.getGadgetByPath(path || "/");
}) })
...@@ -961,6 +986,9 @@ ...@@ -961,6 +986,9 @@
}) })
.push(function () { .push(function () {
return g; return g;
})
.push(undefined, function (err) {
console.error(err);
}); });
}) })
.declareMethod('rerender', function (opt) { .declareMethod('rerender', function (opt) {
......
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