I'm building a project management app with three main models:
Client
, Project
, Task
My models (relationships only)
let client = DS.Model.extend({
projects: DS.hasMany('project');
});
let project = DS.Model.extend({
client: DS.belongsTo('client'),
tasks: DS.hasMany('task')
});
let task = DS.Model.extend({
project: DS.belongsTo('project')
});
Requirements:
- Display list of all clients
- Display list of all a client's projects (not nested in UI)
- Display list of a project's tasks (not nested in UI)
- Display task's details (not nested in UI)
- Display list of all projects for all clients (yep, not nested)
I'm not sure if it's incorrect to reflect model relationships by nesting resources as such:
/** Creates a nested UI by default: */
this.route('clients', function() {
this.route('projects', function() {
this.route('tasks', function() {});
});
});
I don't want my UI to be nested and show all the projects below all the clients etc.
Is there a better way of handling resources than this?
// All projects for all clients
this.route('projects', function(){});
// Client's projects
this.route('clientProjects', { path: 'client/:id/projects' }, function() {});