summaryrefslogtreecommitdiffstats
path: root/packages/kadira-flow-router/client/group.js
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2019-04-20 15:18:33 +0300
committerLauri Ojansivu <x@xet7.org>2019-04-20 15:18:33 +0300
commit73e265d8fd050ae3daa67472b4465a5c49d68910 (patch)
tree677b233934a43d8f873e24c794ce289d85e3a9b7 /packages/kadira-flow-router/client/group.js
parent6117097a93bfb11c8bd4c87a23c44a50e22ceb87 (diff)
downloadwekan-73e265d8fd050ae3daa67472b4465a5c49d68910.tar.gz
wekan-73e265d8fd050ae3daa67472b4465a5c49d68910.tar.bz2
wekan-73e265d8fd050ae3daa67472b4465a5c49d68910.zip
Include to Wekan packages directory contents, so that meteor command would build all directly.
This also simplifies build scripts. Thanks to xet7 !
Diffstat (limited to 'packages/kadira-flow-router/client/group.js')
-rw-r--r--packages/kadira-flow-router/client/group.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/packages/kadira-flow-router/client/group.js b/packages/kadira-flow-router/client/group.js
new file mode 100644
index 00000000..b93296bc
--- /dev/null
+++ b/packages/kadira-flow-router/client/group.js
@@ -0,0 +1,57 @@
+Group = function(router, options, parent) {
+ options = options || {};
+
+ if (options.prefix && !/^\/.*/.test(options.prefix)) {
+ var message = "group's prefix must start with '/'";
+ throw new Error(message);
+ }
+
+ this._router = router;
+ this.prefix = options.prefix || '';
+ this.name = options.name;
+ this.options = options;
+
+ this._triggersEnter = options.triggersEnter || [];
+ this._triggersExit = options.triggersExit || [];
+ this._subscriptions = options.subscriptions || Function.prototype;
+
+ this.parent = parent;
+ if (this.parent) {
+ this.prefix = parent.prefix + this.prefix;
+
+ this._triggersEnter = parent._triggersEnter.concat(this._triggersEnter);
+ this._triggersExit = this._triggersExit.concat(parent._triggersExit);
+ }
+};
+
+Group.prototype.route = function(pathDef, options, group) {
+ options = options || {};
+
+ if (!/^\/.*/.test(pathDef)) {
+ var message = "route's path must start with '/'";
+ throw new Error(message);
+ }
+
+ group = group || this;
+ pathDef = this.prefix + pathDef;
+
+ var triggersEnter = options.triggersEnter || [];
+ options.triggersEnter = this._triggersEnter.concat(triggersEnter);
+
+ var triggersExit = options.triggersExit || [];
+ options.triggersExit = triggersExit.concat(this._triggersExit);
+
+ return this._router.route(pathDef, options, group);
+};
+
+Group.prototype.group = function(options) {
+ return new Group(this._router, options, this);
+};
+
+Group.prototype.callSubscriptions = function(current) {
+ if (this.parent) {
+ this.parent.callSubscriptions(current);
+ }
+
+ this._subscriptions.call(current.route, current.params, current.queryParams);
+};