Skip to content

Commit

Permalink
add more filters to posts screen
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid committed Nov 18, 2018
1 parent 54f4060 commit 1f6d5b9
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 28 deletions.
160 changes: 148 additions & 12 deletions public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3655,6 +3655,8 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
data: function data() {
return {
baseURL: '/api/posts',
tags: [],
authors: [],
entries: [],
hasMoreEntries: false,
nextPageUrl: null,
Expand All @@ -3663,7 +3665,9 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
searchQuery: '',

filters: {
status: ''
status: '',
author_id: '',
tag_id: ''
}
};
},
Expand All @@ -3677,11 +3681,29 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });

this.loadEntries();

this.loadResources();

this.watchFiltersChanges();
},


methods: {
/**
* Load the resources needed for the screen.
*/
loadResources: function loadResources() {
var _this = this;

this.http().get('/api/tags').then(function (response) {
_this.tags = response.data.data;
});

this.http().get('/api/team').then(function (response) {
_this.authors = response.data.data;
});
},


/**
* Format the given tags for display.
*/
Expand Down Expand Up @@ -52401,7 +52423,7 @@ var render = function() {
}
],
staticClass: "w-1/2 focus:outline-none",
attrs: { name: "status", id: "author_id" },
attrs: { name: "status" },
on: {
change: function($event) {
var $$selectedVal = Array.prototype.filter
Expand Down Expand Up @@ -52445,6 +52467,120 @@ var render = function() {
]
)
]
),
_vm._v(" "),
_c(
"div",
{ staticClass: "flex items-center justify-between mt-3" },
[
_c("span", [_vm._v("Author")]),
_vm._v(" "),
_c(
"select",
{
directives: [
{
name: "model",
rawName: "v-model",
value: _vm.filters.author_id,
expression: "filters.author_id"
}
],
staticClass: "w-1/2 focus:outline-none",
attrs: { name: "status" },
on: {
change: function($event) {
var $$selectedVal = Array.prototype.filter
.call($event.target.options, function(o) {
return o.selected
})
.map(function(o) {
var val = "_value" in o ? o._value : o.value
return val
})
_vm.$set(
_vm.filters,
"author_id",
$event.target.multiple
? $$selectedVal
: $$selectedVal[0]
)
}
}
},
[
_c("option", { attrs: { value: "" } }, [
_vm._v("All")
]),
_vm._v(" "),
_vm._l(_vm.authors, function(author) {
return _c(
"option",
{ domProps: { value: author.id } },
[_vm._v(_vm._s(author.name))]
)
})
],
2
)
]
),
_vm._v(" "),
_c(
"div",
{ staticClass: "flex items-center justify-between mt-3" },
[
_c("span", [_vm._v("Tag")]),
_vm._v(" "),
_c(
"select",
{
directives: [
{
name: "model",
rawName: "v-model",
value: _vm.filters.tag_id,
expression: "filters.tag_id"
}
],
staticClass: "w-1/2 focus:outline-none",
attrs: { name: "status" },
on: {
change: function($event) {
var $$selectedVal = Array.prototype.filter
.call($event.target.options, function(o) {
return o.selected
})
.map(function(o) {
var val = "_value" in o ? o._value : o.value
return val
})
_vm.$set(
_vm.filters,
"tag_id",
$event.target.multiple
? $$selectedVal
: $$selectedVal[0]
)
}
}
},
[
_c("option", { attrs: { value: "" } }, [
_vm._v("All")
]),
_vm._v(" "),
_vm._l(_vm.tags, function(tag) {
return _c(
"option",
{ domProps: { value: tag.id } },
[_vm._v(_vm._s(tag.name))]
)
})
],
2
)
]
)
]
)
Expand All @@ -52454,7 +52590,7 @@ var render = function() {
_vm._v(" "),
!_vm.ready ? _c("preloader") : _vm._e(),
_vm._v(" "),
_vm.ready && _vm.entries.length == 0 && !_vm.searchQuery
_vm.ready && _vm.entries.length == 0 && !_vm.isFiltered
? _c(
"div",
[
Expand All @@ -52476,7 +52612,7 @@ var render = function() {
)
: _vm._e(),
_vm._v(" "),
_vm.ready && _vm.entries.length == 0 && _vm.searchQuery
_vm.ready && _vm.entries.length == 0 && _vm.isFiltered
? _c("div", [
_vm._v(
"\n No posts matched the given search.\n "
Expand Down Expand Up @@ -52778,7 +52914,7 @@ var render = function() {
_vm._v(" "),
!_vm.ready ? _c("preloader") : _vm._e(),
_vm._v(" "),
_vm.ready && _vm.entries.length == 0 && !_vm.searchQuery
_vm.ready && _vm.entries.length == 0 && !_vm.isFiltered
? _c("div", [
_c(
"p",
Expand All @@ -52800,7 +52936,7 @@ var render = function() {
])
: _vm._e(),
_vm._v(" "),
_vm.ready && _vm.entries.length == 0 && _vm.searchQuery
_vm.ready && _vm.entries.length == 0 && _vm.isFiltered
? _c("div", [
_vm._v(
"\n No authors matched the given search.\n "
Expand Down Expand Up @@ -53055,7 +53191,7 @@ var render = function() {
_vm._v(" "),
!_vm.ready ? _c("preloader") : _vm._e(),
_vm._v(" "),
_vm.ready && _vm.entries.length == 0 && !_vm.searchQuery
_vm.ready && _vm.entries.length == 0 && !_vm.isFiltered
? _c(
"div",
[
Expand All @@ -53077,7 +53213,7 @@ var render = function() {
)
: _vm._e(),
_vm._v(" "),
_vm.ready && _vm.entries.length == 0 && _vm.searchQuery
_vm.ready && _vm.entries.length == 0 && _vm.isFiltered
? _c("div", [
_vm._v(
"\n No pages matched the given search.\n "
Expand Down Expand Up @@ -53945,7 +54081,7 @@ var render = function() {
_vm._v(" "),
!_vm.ready ? _c("preloader") : _vm._e(),
_vm._v(" "),
_vm.ready && _vm.entries.length == 0 && !_vm.searchQuery
_vm.ready && _vm.entries.length == 0 && !_vm.isFiltered
? _c("div", [
_c(
"p",
Expand All @@ -53967,7 +54103,7 @@ var render = function() {
])
: _vm._e(),
_vm._v(" "),
_vm.ready && _vm.entries.length == 0 && _vm.searchQuery
_vm.ready && _vm.entries.length == 0 && _vm.isFiltered
? _c("div", [
_vm._v(
"\n No tags matched the given search.\n "
Expand Down Expand Up @@ -72731,15 +72867,15 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
module.exports = {
computed: {
isFiltered: function isFiltered() {
return !!this.searchQuery.length || this.filters && this.filters.status;
return !!this.searchQuery.length || this.filters && this.filters.status || this.filters && this.filters.author_id || this.filters && this.filters.tag_id;
}
},

methods: {
loadEntries: function loadEntries() {
var _this = this;

this.http().get(this.baseURL + '?wink=wink' + (this.searchQuery ? '&search=' + this.searchQuery : '') + (this.filters && this.filters.status ? '&status=' + this.filters.status : '')).then(function (response) {
this.http().get(this.baseURL + '?wink=wink' + (this.searchQuery ? '&search=' + this.searchQuery : '') + (this.filters && this.filters.status ? '&status=' + this.filters.status : '') + (this.filters && this.filters.author_id ? '&author_id=' + this.filters.author_id : '') + (this.filters && this.filters.tag_id ? '&tag_id=' + this.filters.tag_id : '')).then(function (response) {
_this.entries = response.data.data;

_this.hasMoreEntries = !!response.data.next_page_url;
Expand Down
2 changes: 1 addition & 1 deletion public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"/app.js": "/app.js?id=060839fe56e1bb879945",
"/app.js": "/app.js?id=47e656dd2bb0b7281aeb",
"/light.css": "/light.css?id=5c4e6e802e09bd489fc6",
"/favicon.png": "/favicon.png?id=b0b34b4095fcdbb8942d"
}
3 changes: 1 addition & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Wink is shipped with an admin panel that's simple to use. However, we give you f
public function index()
{
$posts = WinkPost::with('tags')
->published()
->live()
->orderBy('publish_date', 'DESC')
->simplePaginate(12);
Expand Down Expand Up @@ -85,9 +84,9 @@ Here's the plan for what's coming:
- [x] Customize Twitter/Facebook cards and SEO metadata.
- [x] Optimize CSS. Move to Tailwind?
- [x] Add text search inside listings.
- [x] Filter posts by status, scheduling, tags, and authors.
- [ ] Ability to extract featured image/ social images from images used in post/page.
- [ ] Create an initial theme that people can use right away.
- [ ] Filter posts by status, scheduling, tags, and authors.
- [ ] Adding image galleries to posts and pages.
- [ ] Attach metadata to posts and pages.
- [ ] Link social accounts and automatic post on new published content.
Expand Down
10 changes: 8 additions & 2 deletions resources/js/screens/loadsEntries.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
module.exports = {
computed: {
isFiltered(){
return !!this.searchQuery.length || (this.filters && this.filters.status);
return !!this.searchQuery.length ||
(this.filters && this.filters.status) ||
(this.filters && this.filters.author_id) ||
(this.filters && this.filters.tag_id)
;
}
},

Expand All @@ -10,7 +14,9 @@ module.exports = {
loadEntries(){
this.http().get(this.baseURL + '?wink=wink' +
(this.searchQuery ? '&search=' + this.searchQuery : '') +
(this.filters && this.filters.status ? '&status=' + this.filters.status : '')
(this.filters && this.filters.status ? '&status=' + this.filters.status : '') +
(this.filters && this.filters.author_id ? '&author_id=' + this.filters.author_id : '') +
(this.filters && this.filters.tag_id ? '&tag_id=' + this.filters.tag_id : '')
).then(response => {
this.entries = response.data.data;

Expand Down
4 changes: 2 additions & 2 deletions resources/js/screens/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@

<preloader v-if="!ready"></preloader>

<div v-if="ready && entries.length == 0 && !searchQuery">
<div v-if="ready && entries.length == 0 && !isFiltered">
No pages were found, start by
<router-link :to="{name:'page-new'}" class="no-underline text-primary hover:text-primary-dark">writing your first page</router-link>
.
</div>

<div v-if="ready && entries.length == 0 && searchQuery">
<div v-if="ready && entries.length == 0 && isFiltered">
No pages matched the given search.
</div>

Expand Down
Loading

0 comments on commit 1f6d5b9

Please sign in to comment.