forked from bryanlarsen/agility-gitorial-patches
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path25-odds-and-ends.patch
49 lines (32 loc) · 1.88 KB
/
25-odds-and-ends.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
25-odds-and-ends.patch
From: Ignacio Huerta <ignacio@ihuerta.net>
# Odds and ends
We're now going to work through some more easy but very valuable enhancements to the app. We're going to add:
* A menu for story statuses. The free-form text field is a bit poor after all. We'll do this first with a hard-wired set of options, and then add the ability to manage the set of available statuses.
* Add filtering of stories by status to the project page
* Drag and drop re-ordering of tasks. This effectively gives us prioritisation of tasks.
* Markdown or textile formatting of stories. This is implemented by changing *one symbol* in the source code.
Off we go.
## Story status menu
We're going to do this in two stages - first a fixed menu that would require a source-code change if you ever need to alter the available statuses. We'll then remove that restriction by adding a StoryStatus model. We'll also see the migration generator in action again.
The fixed menu is brain-dead simple. Track down the declaration of the status field in `story.rb` (it's in the `fields do ... end` block), and change it to read something like:
SHOW_PATCH
Job done. If you want the gory details, `enum_string` is a *type constructor*. It creates an anonymous class that represents this enumerated type (a subclass of String). You can see this in action by trying this in the console:
>> Story.find(:first).status.class
{: .ruby}
---
app/models/story.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/models/story.rb b/app/models/story.rb
index 1d84850..1722f1f 100644
--- a/app/models/story.rb
+++ b/app/models/story.rb
@@ -5,7 +5,7 @@ class Story < ActiveRecord::Base
fields do
title :string
body :text
- status :string
+ status enum_string(:new, :accepted, :discussion, :implementation)
tasks_count :integer, :default => 0, :null => false
timestamps
end