Skip to content

Commit d90678e

Browse files
committed
Filters no longer really used in templates.
Use a computed function instead.
1 parent a1cbf7f commit d90678e

File tree

5 files changed

+31
-23
lines changed

5 files changed

+31
-23
lines changed

test/controllers/refresh_controller_test.exs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
defmodule Caster.RefreshControllerTest do
22
use Caster.ConnCase
3+
@moduletag :production_api_test
34

45
test "can refresh vimcasts", %{conn: conn} do
56
conn = put conn, refresh_path(conn, :update, "vimcast")

web/static/js/components/Cast-List.vue

+26-12
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
<th></th>
1717
</tr>
1818
</thead>
19-
<tr is="cast" :removeable="removeable" :cast="cast" v-for="cast in casts | filterBy 'true' in 'interesting'"></tr>
19+
<tbody>
20+
<tr is="cast" :removeable="removeable" :cast="cast" v-for="cast in interestingCasts"></tr>
21+
</tbody>
2022
</table>
2123
</div>
2224

@@ -30,13 +32,15 @@
3032
<th></th>
3133
</tr>
3234
</thead>
33-
<tr is="cast" :cast="cast" :removeable="removeable" v-for="cast in casts | filterBy 'false' in 'interesting'"></tr>
35+
<tbody>
36+
<tr is="cast" :cast="cast" :removeable="removeable" v-for="cast in normalCasts"></tr>
37+
</tbody>
3438
</table>
3539
</div>
3640
</div>
3741
<p v-else>Loading...</p>
3842

39-
<modal :callback="saveNote" :show.sync="showModal">
43+
<modal :callback="saveNote" @cancel="showModal = false" :value.sync="showModal">
4044
<div slot="modal-header" class="modal-header">
4145
<h4 class="modal-title">Notes for {{ selectedCast.title }}</h4>
4246
</div>
@@ -62,15 +66,12 @@
6266
title: "",
6367
showModal: false,
6468
selectedCast: { title: "", note: "" },
65-
error: null
69+
error: null,
70+
initialFetchComplete: false,
6671
}
6772
},
6873
6974
props: {
70-
initialFetchComplete: {
71-
type: Boolean,
72-
default: false
73-
},
7475
refreshable: {
7576
type: Boolean,
7677
default: false
@@ -83,6 +84,18 @@
8384
},
8485
hasNormalCasts () {
8586
return this.casts.filter((c) => c.interesting === false).length > 0
87+
},
88+
interestingCasts: function () {
89+
var self = this;
90+
return self.casts.filter(function (cast) {
91+
return cast.interesting == true;
92+
})
93+
},
94+
normalCasts: function () {
95+
var self = this;
96+
return self.casts.filter(function (cast) {
97+
return cast.interesting == false;
98+
})
8699
}
87100
},
88101
@@ -92,10 +105,7 @@
92105
modal
93106
},
94107
95-
created () {
96-
if (this.initialFetchComplete) {
97-
return;
98-
}
108+
created: function() {
99109
this.fetchCasts()
100110
},
101111
@@ -114,6 +124,10 @@
114124
})
115125
},
116126
127+
cancelPressed: function () {
128+
debugger;
129+
},
130+
117131
fetchCasts () {
118132
this.$http.get('/casts?source=' + this.castType())
119133
.then(response => {

web/templates/cast/index.html.eex

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<cast-list></cast-list>
1+
<div id="cast-list">
2+
<cast-list></cast-list>
3+
</div>
24

35
<script type="text/javascript">
46
window.source = "<%= @conn.assigns.source.source %>";

web/templates/cast/show.html.eex

-10
This file was deleted.

web/templates/layout/app.html.eex

+1
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@
3737

3838
</div> <!-- /container -->
3939
<script src="<%= static_path(@conn, "/js/app.js") %>"></script>
40+
4041
</body>
4142
</html>

0 commit comments

Comments
 (0)