I'm building a project management app with three main models:
Clients, Projects, Tasks
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've already made the classic mistake of trying to reflect my model relationships by nesting resources as such:
/** Creates a highly nested UI: */
this.resource('clients', function() {
this.resource('projects', function() {
this.resource('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.resource('projects', function(){});
// Client's projects
this.resource('clientProjects', { path: 'client/:id/projects' }, function() {});
Aucun commentaire:
Enregistrer un commentaire