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

iron router to AdminConfig #9

Open pajooh opened 9 years ago

pajooh commented 9 years ago

currently, i'm using the iron-router for routing. my new post route is like this:

    this.route('post_edit', {
      template: 'post_edit',
      path: '/posts/:_id/edit',
      waitOn: function () {
        return [
          coreSubscriptions.subscribe('singlePost', this.params._id),
          coreSubscriptions.subscribe('allUsersAdmin')
        ];
      },
      data: function() {
        return {
          postId: this.params._id,
          post: Posts.findOne(this.params._id)
        };
      },
      fastRender: true
    });

could you please show haw can this be converted to post edit template in AdminConfig? i mean, how the waitOn and other iron-router api calls can be defined in the new context?

yogiben commented 9 years ago

You add add your custom templates via the AdminConfig option; it's in the readme.

In the next phase, I will get rid of that and use this package:

https://github.com/aldeed/meteor-template-extension

Please check out the router.coffee file. You should be able to get all the subscriptions you've given above already. Users, for example, is included.

pajooh commented 9 years ago

i've already added template, there is no problem here. the point here is how to do special things that iron-router can do in waitOn etc? like subscribing to a special subscription (sub collection, filters, etc), not all collection entries which can be set via auxCollections.

yogiben commented 9 years ago

Most if not all of the work is already done by the router.coffee file. If you look in the admin_templates.html file, the last template is what you should copy, modify, give a different name and set in the AdminConfig.

pajooh commented 9 years ago

sorry, i edited my prev answer after your response

pajooh commented 9 years ago

as stated in the readme, templates for a Collection could be customized, why not letting the user customise every router definitions like waitOn, path etc. in my case, the Posts collection needs another collection to be loaded. but i can not use auxCollections because i want to load collection docs partially (subscribing to all via auxCollection is not efficient). i need the full power of iron-router in adminConfig to customize my needs, not just to customize template and data

yogiben commented 9 years ago

I understand what you need.

I haven't tried this, but I imagine that you could create a new route with the same path as the one you want to replace.

You should check out the router.coffee file and set the layout to adminLayout. This way, you can hopefully override the route that this package provides.

I can't think of a good way to complete replace the routes. Please let me know if you do.