You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/components/collection.md
+111-8Lines changed: 111 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,11 +9,11 @@ The `collection` component is designed:
9
9
- paginate the displayed instances without full page reload
10
10
- order the displayed instances without full page reload
11
11
12
-
The `collection` component should be as flexible as possible while still reducing the complexity of implementing all classic collection features by hand
12
+
The `collection` component should be as flexible as possible while still reducing the complexity of implementing all classic collection features by hand.
13
13
14
14
## Prerequisites
15
15
16
-
We use a ActiveRecord Model in the following examples. This Model has two columns: `id` and `title`.
16
+
We use an ActiveRecord Model in the following examples. This Model has two columns: `id` and `title`.
17
17
18
18
## Examples
19
19
@@ -47,7 +47,12 @@ class Pages::MyApp::Collection < Matestack::Ui::Page
47
47
heading size:2, text:"My Collection"
48
48
49
49
partial :filter
50
-
partial :content
50
+
51
+
# the content has to be wrapped in an `async` component
52
+
# the event has to be "your_custom_collection_id" + "-update"
53
+
async rerender_on:"my-first-collection-update"do
54
+
partial :content
55
+
end
51
56
}
52
57
end
53
58
@@ -68,15 +73,17 @@ class Pages::MyApp::Collection < Matestack::Ui::Page
68
73
end
69
74
70
75
defcontent
71
-
partial {
76
+
partial {
72
77
collection_content @my_collection.config do
78
+
73
79
ul do
74
80
@my_collection.data.each do |dummy|
75
81
li do
76
82
plain dummy.title
77
83
end
78
84
end
79
85
end
86
+
80
87
end
81
88
}
82
89
end
@@ -117,7 +124,11 @@ class Pages::MyApp::Collection < Matestack::Ui::Page
117
124
heading size:2, text:"My Collection"
118
125
119
126
partial :filter
120
-
partial :content
127
+
128
+
async rerender_on:"my-first-collection-update"do
129
+
partial :content
130
+
partial :paginator#has to be placed within the `async` component!
131
+
end
121
132
}
122
133
end
123
134
@@ -140,6 +151,7 @@ class Pages::MyApp::Collection < Matestack::Ui::Page
140
151
defcontent
141
152
partial {
142
153
collection_content @my_collection.config do
154
+
143
155
ul do
144
156
# now we use paginated_data!
145
157
@my_collection.paginated_data.each do |dummy|
@@ -148,7 +160,7 @@ class Pages::MyApp::Collection < Matestack::Ui::Page
148
160
end
149
161
end
150
162
end
151
-
partial :paginator#has to be placed within `collection_content`!
163
+
152
164
end
153
165
}
154
166
end
@@ -216,7 +228,11 @@ class Pages::MyApp::Collection < Matestack::Ui::Page
216
228
217
229
partial :filter
218
230
partial :ordering
219
-
partial :content
231
+
232
+
async rerender_on:"my-first-collection-update"do
233
+
partial :content
234
+
partial :paginator#has to be placed within the `async` component!
235
+
end
220
236
}
221
237
end
222
238
@@ -258,14 +274,15 @@ class Pages::MyApp::Collection < Matestack::Ui::Page
258
274
defcontent
259
275
partial {
260
276
collection_content @my_collection.config do
277
+
261
278
ul do
262
279
@my_collection.paginated_data.each do |dummy|
263
280
li do
264
281
plain dummy.title
265
282
end
266
283
end
267
284
end
268
-
partial :paginator
285
+
269
286
end
270
287
}
271
288
end
@@ -298,3 +315,89 @@ end
298
315
```
299
316
300
317
### Action enriched collection
318
+
319
+
In this example, we want to display ALL instances of `DummyModel` and filter the collection by title using a text input. Additionally we want to delete an item of the list using the `action` component.
0 commit comments