forked from bryanlarsen/agility-gitorial-patches
-
Notifications
You must be signed in to change notification settings - Fork 1
/
21-stories-table-add-search.patch
49 lines (41 loc) · 1.81 KB
/
21-stories-table-add-search.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
stories-table-add-search
From: Bryan Larsen <[email protected]>
To get the search feature working, we need to update the controller side. Add a `show` method to `app/controllers/projects_controller.rb` and update the `<table-plus>` to use `@stories` as it's context:
SHOW_PATCH
There's a lot happening here, so we're just going to point you to appropriate manual chapters to explain the concepts.
- [DRYML context switching](/manual/dryml-guide#the_implicit_context)
- [Changing controller action behaviour](/manual/controllers#changing_action_behaviour)
- [search and order_by scopes](/manual/scopes#static_scopes)
- [find_instance](/manual/controller#find_instance)
- [parse_sort_param](/manual/controller#parse_sort_param)
---
app/controllers/projects_controller.rb | 8 ++++++++
app/views/projects/show.dryml | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 210b07d..3c3b39b 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -4,4 +4,12 @@ class ProjectsController < ApplicationController
auto_actions :all
+ def show
+ @project = find_instance
+ @stories = @project.stories.
+ search(params[:search], :title).
+ order_by(parse_sort_param(:title, :status))
+ hobo_show
+ end
+
end
diff --git a/app/views/projects/show.dryml b/app/views/projects/show.dryml
index f62b0b2..0ea6a1d 100644
--- a/app/views/projects/show.dryml
+++ b/app/views/projects/show.dryml
@@ -1,6 +1,6 @@
<show-page>
<collection: replace>
- <table-plus:stories fields="this, tasks_count, status">
+ <table-plus with="&@stories" fields="this, tasks_count, status">
<empty-message:>No stories match your criteria</empty-message:>
</table-plus>
</collection:>