yogiben / meteor-admin

A complete admin dashboard solution
https://atmospherejs.com/yogiben/admin
GNU General Public License v3.0
827 stars 261 forks source link

Allow custom route options #265

Closed carlosbaraza closed 8 years ago

carlosbaraza commented 9 years ago

Hi @yogiben,

Recently I experienced troubles setting up custom options for the routes generated by meteor-admin. Concretely about the waitOn hook to subscribe to other collections.

I hope this feature could be useful for someone. We could adapt my implementation to whatever you feel is right.

Here there is the documentation relating the feature:

Custom route options

It is possible to setup some custom options that will be used during the generation of the routes for your collections. If no options are given, default ones will be used.

This could be useful in order to set up waitOn or onAfterAction hooks:

AdminConfig = {
  // ...
  collections: {
    Posts: {
      routes: {
        new: {
          waitOn: function () { return Meteor.subscribe('images'); }
        },
        view: {
          waitOn: function () { return Meteor.subscribe('images'); }
        },
        edit: {
          waitOn: function () { return Meteor.subscribe('images'); }
        }
      }
    }
  }
  // ...
}

All the options that Iron Router accept are also accepted here, except: path, template, controller, action and data.

However, data context could be set up using the collectionObject key:

AdminConfig = {
  // ...
  collections: {
    Posts: {
      collectionObject: {
        key: 'value'
      }
    }
  }
  // ...
}