Skip to content

Commit ab871bb

Browse files
committed
Merge branch 'release/4.1.20'
* release/4.1.20: updated the changelog added dynamic pagination to filtered lists
2 parents 707bf7f + ba3bea8 commit ab871bb

File tree

13 files changed

+144
-51
lines changed

13 files changed

+144
-51
lines changed

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Release Notes
22

3+
## [v4.1.20](https://github.com/cnvs/canvas/compare/v4.1.19...v4.1.20)
4+
5+
### Added
6+
- Added dynamic pagination to Vue component filtered lists ([ec087a4](https://github.com/cnvs/canvas/commit/ec087a4fcea738775df95df2d795e695b12d6b1d))
7+
38
## [v4.1.19](https://github.com/cnvs/canvas/compare/v4.1.18...v4.1.19)
49

510
### Changed

public/js/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/app.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/mix-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"/js/app.js": "/js/app.js?id=e14eab4148aca57fd14d",
2+
"/js/app.js": "/js/app.js?id=7ed9ca64baed70416578",
33
"/css/app.css": "/css/app.css?id=30702a620a23ba741c32",
44
"/css/app-dark.css": "/css/app-dark.css?id=ceb9852370c32c15e835",
5-
"/js/app.js.map": "/js/app.js.map?id=b49f81db61bd83e7ae34",
5+
"/js/app.js.map": "/js/app.js.map?id=9bbcbd4034997da44ae1",
66
"/favicon.png": "/favicon.png?id=d1ff042f5749eb7e2f66"
77
}

resources/js/components/PostList.vue

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,44 @@
55
data() {
66
return {
77
search: '',
8-
postList: this.models ? this.models : []
8+
postList: this.models ? this.models : [],
9+
limit: 7,
10+
load: false
11+
}
12+
},
13+
14+
methods: {
15+
/**
16+
* Return a number formatted with a suffix.
17+
*
18+
* @return string
19+
*/
20+
suffixedNumber(n) {
21+
let format = '';
22+
let suffix = '';
23+
24+
if (n < 900) {
25+
format = n.toFixed();
26+
suffix = '';
27+
} else if (n < 900000) {
28+
let n_total = n / 1000;
29+
format = n_total.toFixed(1);
30+
suffix = 'K';
31+
} else if (n < 900000000) {
32+
let n_total = n / 1000000;
33+
format = n_total.toFixed(1);
34+
suffix = 'M';
35+
} else if (n < 900000000000) {
36+
let n_total = n / 1000000000;
37+
format = n_total.toFixed(1);
38+
suffix = 'B';
39+
} else {
40+
let n_total = n / 1000000000000;
41+
format = n_total.toFixed(1);
42+
suffix = 'T';
43+
}
44+
45+
return format + suffix;
946
}
1047
},
1148
@@ -16,10 +53,18 @@
1653
* @source https://codepen.io/AndrewThian/pen/QdeOVa
1754
*/
1855
filteredList() {
19-
return this.postList.filter(post => {
56+
let filtered = this.postList.filter(post => {
2057
return post.title.toLowerCase().includes(this.search.toLowerCase())
21-
})
58+
});
59+
60+
if (Object.keys(filtered).length > this.limit) {
61+
this.load = true;
62+
} else {
63+
this.load = false;
64+
}
65+
66+
return this.limit ? filtered.slice(0, this.limit) : this.postList;
2267
}
2368
},
2469
}
25-
</script>
70+
</script>

resources/js/components/TagList.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
data() {
66
return {
77
search: '',
8-
tagList: this.models ? this.models : []
8+
tagList: this.models ? this.models : [],
9+
limit: 10,
10+
load: false
911
}
1012
},
1113
@@ -16,10 +18,18 @@
1618
* @source https://codepen.io/AndrewThian/pen/QdeOVa
1719
*/
1820
filteredList() {
19-
return this.tagList.filter(tag => {
21+
let filtered = this.tagList.filter(tag => {
2022
return tag.name.toLowerCase().includes(this.search.toLowerCase())
21-
})
23+
});
24+
25+
if (Object.keys(filtered).length > this.limit) {
26+
this.load = true;
27+
} else {
28+
this.load = false;
29+
}
30+
31+
return this.limit ? filtered.slice(0, this.limit) : this.tagList;
2232
}
2333
},
2434
}
25-
</script>
35+
</script>

resources/js/components/TopicList.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
data() {
66
return {
77
search: '',
8-
topicList: this.models ? this.models : []
8+
topicList: this.models ? this.models : [],
9+
limit: 10,
10+
load: false
911
}
1012
},
1113
@@ -16,10 +18,18 @@
1618
* @source https://codepen.io/AndrewThian/pen/QdeOVa
1719
*/
1820
filteredList() {
19-
return this.topicList.filter(topic => {
21+
let filtered = this.topicList.filter(topic => {
2022
return topic.name.toLowerCase().includes(this.search.toLowerCase())
21-
})
23+
});
24+
25+
if (Object.keys(filtered).length > this.limit) {
26+
this.load = true;
27+
} else {
28+
this.load = false;
29+
}
30+
31+
return this.limit ? filtered.slice(0, this.limit) : this.topicList;
2232
}
2333
},
2434
}
25-
</script>
35+
</script>

resources/views/posts/index.blade.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ class="mr-2"
6363
</div>
6464
</div>
6565

66+
<div class="d-flex justify-content-center">
67+
<a href="#!" class="btn btn-link" @click="limit += 7" v-if="load">Show more <i class="fa fa-fw fa-angle-down"></i></a>
68+
</div>
69+
6670
<p class="mt-4" v-if="!filteredList.length">No posts matched the given search criteria.</p>
6771
</div>
6872
@else
@@ -72,4 +76,4 @@ class="mr-2"
7276
</div>
7377
</div>
7478
</post-list>
75-
@endsection
79+
@endsection

resources/views/stats/index.blade.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,41 +32,41 @@
3232
<div class="card-body">
3333
<h5 class="card-title text-muted small text-uppercase font-weight-bold">Publishing</h5>
3434
<ul>
35-
<li>{{ $data['posts']['published']->count() }} Published Post(s)</li>
36-
<li>{{ $data['posts']['drafts']->count() }} Draft(s)</li>
35+
<li>{{ $data['posts']['published_count'] }} Published Post(s)</li>
36+
<li>{{ $data['posts']['drafts_count'] }} Draft(s)</li>
3737
</ul>
3838
</div>
3939
</div>
4040
</div>
4141

4242
<line-chart :views="{{ $data['views']['trend'] }}"></line-chart>
4343

44-
<div class="mt-4">
45-
@foreach($data['posts']['published'] as $post)
46-
<div class="d-flex border-top py-3 align-items-center">
47-
<div class="mr-auto">
48-
<p class="mb-1 mt-2">
49-
<a href="{{ route('canvas.stats.show', $post->id) }}"
50-
class="font-weight-bold lead">{{ $post->title }}</a>
51-
</p>
52-
<p class="text-muted mb-2">
53-
{{ $post->read_time }} ― <a
54-
href="{{ route('canvas.post.edit', $post->id) }}">Edit
55-
post</a> ― <a
56-
href="{{ route('canvas.stats.show', $post->id) }}">Details</a>
44+
<post-list :models="{{ $data['posts']['all'] }}" inline-template>
45+
<div class="mt-4">
46+
<div v-cloak>
47+
<div class="d-flex border-top py-3 align-items-center" v-for="post in filteredList">
48+
<div class="mr-auto">
49+
<p class="mb-1 mt-2">
50+
<a :href="'/canvas/stats/' + post.id" class="font-weight-bold lead">@{{ post.title }}</a>
5751
</p>
52+
<p class="text-muted mb-2">
53+
@{{ post.read_time }} ―
54+
<a :href="'/canvas/posts/' + post.id + '/edit'">Edit post</a> ―
55+
<a :href="'/canvas/stats/' + post.id">Details</a>
56+
</p>
57+
</div>
58+
<div class="ml-auto d-none d-lg-block">
59+
<span class="text-muted mr-3">@{{ suffixedNumber(post.views_count) }} View(s)</span>
60+
Created @{{ moment(post.created_at).fromNow() }}
61+
</div>
5862
</div>
59-
<div class="ml-auto d-none d-lg-block">
60-
<span class="text-muted mr-3">{{ \Canvas\SuffixedNumber::format($post->views_count) }} View(s)</span>
61-
Created {{ \Carbon\Carbon::parse($post->created_at)->diffForHumans() }}
63+
64+
<div class="d-flex justify-content-center">
65+
<a href="#!" class="btn btn-link" @click="limit += 7" v-if="load">Show more <i class="fa fa-fw fa-angle-down"></i></a>
6266
</div>
6367
</div>
64-
@endforeach
65-
66-
<div class="d-flex justify-content-center">
67-
{{ $data['posts']['all']->links() }}
6868
</div>
69-
</div>
69+
</post-list>
7070
@else
7171
<p class="mt-4">There are no published posts for which you can view stats.</p>
7272
@endif

resources/views/tags/index.blade.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ class="font-weight-bold lead">@{{ tag.name }}</a>
4949
</div>
5050
</div>
5151

52+
<div class="d-flex justify-content-center">
53+
<a href="#!" class="btn btn-link" @click="limit += 10" v-if="load">Show more <i class="fa fa-fw fa-angle-down"></i></a>
54+
</div>
55+
5256
<p class="mt-4" v-if="!filteredList.length">No tags matched the given search criteria.</p>
5357
</div>
5458
@else
@@ -58,4 +62,4 @@ class="font-weight-bold lead">@{{ tag.name }}</a>
5862
</div>
5963
</div>
6064
</tag-list>
61-
@endsection
65+
@endsection

0 commit comments

Comments
 (0)