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

What is a proper way to link to the "edit" page? #312

Open Maay opened 8 years ago

Maay commented 8 years ago

On my main page I have this logic next to the element so that I could fastly go to the edit section

{{#if currentUser}}
   <a target="_blank" href="/admin/Posts/{{_id}}/edit">EDIT</a>
{{/if}}

It gives me the link like http://localhost:3000/admin/Post/oEzftd8y49DZfxQFj/edit which is the same that I get from inside the admin interface (on the "View All" section). But unless I've opened that element before from the "View All" section, that link from outside the admin section would give me allways loading state:

<body class="fixed">
  <div class="admin-layout">
    <b>Loading</b>
  </div>
  <div class="modal fade" id="admin-delete-modal">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
          <h4 class="modal-title">Confirm delete</h4>
        </div>
        <div class="modal-body">
          <p>Are you sure you want to delete this?</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          <button type="button" id="confirm-delete" class="btn btn-danger">Delete</button>
        </div>
      </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
  </div><!-- /.modal -->

  </body>

Same happens when I'm on the edit page and meteor refreshes the page after I'm updating any code.

What is the proper way to link to the edit page? Thank you.

Maay commented 8 years ago

@mpowaga any help?

snamoah commented 8 years ago

@Maay the meteor admin routes are structured so: "/admin/{collectionName}/edit" for edit and "/admin/{collectionName}/ for view_all. From your pathFor, it looks like you left out the 's' in Posts collection name

Maay commented 8 years ago

@snamoah it's not the issue here because I'm using "Posts" here as an example, it has different name in my code. I think I need to use <a target="_blank" href="{{pathFor route='/admin/Posts/:_id/edit' }} "> EDIT </a> but it doesn't work as well with error pathFor couldn't find a route named "/admin/Posts/:_id/edit"

snamoah commented 8 years ago

@Maay have you tried specifying the url directly without pathFor; as in <a href="/admin/Posts/{{id}}/edit"> EDIT </a>

Maay commented 8 years ago

@snamoah yes, I've started from that. I think it doesn't subscribe or something like that.

snamoah commented 8 years ago

@Maay can you paste the error you're getting with the initial code... I'm still not getting you

Maay commented 8 years ago

@snamoah I'm not getting any errors, what I get is the "loading" state of admin interface, that I showed in the post. It looks like it can't get the elements. You can get the same error if you'll open the "edit" page on the admin, then change your code, meteor will refresh the page and here it is - the loading page. At least in my case.