I would like to make a sort of directory structure with Ember.js.
Here is an example of how an url can look like: folder/1/folder/44/document/3
As you can see a folder can have multiple folders inside but also documents. I'm wondering how I should handle something like this in my router because beforehand my application doesn't know if a folder has other folders inside or only documents.
I think I need to make separated routes instead of nested routes:
App.Router.map(function() {
this.route('folder', {path: 'folder/:folder_id'}); // -> FolderRoute
this.route('document', {path: 'document/:document_id'}); // -> DocumentRoute
});
When a folder or document has parent folders the id's of the parent folders will be given in an array from the backend.
Let's take my example url. The deepest nested model is a document with id: 3. This document model has folder_id: 44 and folder 44 has parent_folder_ids: [1]. Somehow my router needs to know that it has to generate the example url from it.
I've seen it's possible to use router.generate to generate urls but I'm not sure if that's wat I need or if queryParams will be the best solution.