Skip to content

Commit

Permalink
add-users-to-tasks
Browse files Browse the repository at this point in the history
## Add assigned users to the tasks

At the moment, the only way to see who's assigned to a task is to click the task's edit link. Not good. Let's add a list of the assigned users to each task when we're looking at a story.

DRYML has a feature called *polymorphic tags*. These are tags that are defined differently for different types of object. Rapid makes use of this feature with a system of "cards". The tasks that are displayed on the story page are rendered by the `<card>`. You can define custom cards for particular models. Furthermore, if you call `<base-card>` you can define your card by tweaking the default, rather than starting from scratch. This is what DRYML is all about. It's like a smart-bomb, capable of taking out little bits of unwanted HTML with pin-point strikes and no collateral damage.

The file `app/views/taglibs/application.dryml` is a place to put tag definitions that will be available throughout the site. Add this definition to that file:

SHOW_PATCH

OK there's a lot of new concepts thrown at you at once there :-)

First off, refresh the story page. You'll see that in the cards for each task there is now a list of assigned users. The users are clickable - they link to each users home page (which doesn't have much on it at the moment).

The `<extend>` tag is used to extend any tag that's already defined. The body of `<extend>` is our new definition. It's very common to want to base the new definition on the old one, for example, we often want to insert a bit of extra content as we've done here. We can do that by calling the "old" definition, which is available as `<old-card>`. We've passed the `<append-body:>` parameter to `<old-card>` which, in a startling twist, is used to append content to the body of the card. Some points to note:

 * The `<repeat>` tag provides a `join` attribute which we use to insert the commas
 * The link is created with a simple empty `<a/>`. It links to the 'current context' which, in this case, is the user.
 * The `:users` in `<repeat:users>` switches the context. It selects the `users` association of the task.
 * DRYML has a multi-purpose `<else>` tag. When used with repeat, it provides a default for the case when the collection is empty.
  • Loading branch information
bryanlarsen committed Dec 2, 2009
1 parent 5218c45 commit 82f849d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/views/taglibs/application.dryml
Expand Up @@ -7,3 +7,13 @@
<set-theme name="clean"/>

<def tag="app-name">Agility</def>

<extend tag="card" for="Task">
<old-card merge>
<append-body:>
<div class="users">
Assigned users: <repeat:users join=", "><a/></repeat><else>None</else>
</div>
</append-body:>
</old-card>
</extend>

0 comments on commit 82f849d

Please sign in to comment.