forked from projects/fipamo
implemented admin post filtering
This commit is contained in:
parent
57684e7a27
commit
c2290a2e26
8 changed files with 92 additions and 50 deletions
|
@ -12,7 +12,7 @@
|
||||||
"no-class-assign": 2,
|
"no-class-assign": 2,
|
||||||
"no-compare-neg-zero": 2,
|
"no-compare-neg-zero": 2,
|
||||||
"no-cond-assign": 2,
|
"no-cond-assign": 2,
|
||||||
"no-console": 2,
|
"no-console": 1,
|
||||||
"no-const-assign": 2,
|
"no-const-assign": 2,
|
||||||
"no-constant-condition": 2,
|
"no-constant-condition": 2,
|
||||||
"no-control-regex": 1,
|
"no-control-regex": 1,
|
||||||
|
|
|
@ -11,9 +11,11 @@ const dateUtils = new DateUtils();
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// POSTS
|
// POSTS
|
||||||
//--------------------------
|
//--------------------------
|
||||||
router.get('/:page?', function(req, res) {
|
router.get('/:filter?/:page?', function(req, res) {
|
||||||
var pageNum = req.params.page;
|
var pageNum = req.params.page;
|
||||||
|
var filter = req.params.filter;
|
||||||
if (pageNum == '' || pageNum == null) pageNum = 1;
|
if (pageNum == '' || pageNum == null) pageNum = 1;
|
||||||
|
if (filter == '' || filter == null) filter = 'all';
|
||||||
if (req.session.user) {
|
if (req.session.user) {
|
||||||
Models.FreshPost.findAll({
|
Models.FreshPost.findAll({
|
||||||
order: [['id', 'DESC']]
|
order: [['id', 'DESC']]
|
||||||
|
@ -35,14 +37,26 @@ router.get('/:page?', function(req, res) {
|
||||||
deleted.push(posts[index]);
|
deleted.push(posts[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var count = Math.round(all.length / 6);
|
var filtered;
|
||||||
|
switch (filter) {
|
||||||
|
case 'published':
|
||||||
|
filtered = published;
|
||||||
|
break;
|
||||||
|
case 'deleted':
|
||||||
|
filtered = deleted;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
filtered = all;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var count = Math.round(filtered.length / 6);
|
||||||
var pageItems = [];
|
var pageItems = [];
|
||||||
var itemLimit = 6;
|
var itemLimit = 6;
|
||||||
var rangeStart = pageNum * itemLimit - itemLimit;
|
var rangeStart = pageNum * itemLimit - itemLimit;
|
||||||
for (var i = 0; i < itemLimit; i++) {
|
for (var i = 0; i < itemLimit; i++) {
|
||||||
try {
|
try {
|
||||||
if (all[i + rangeStart].id != null) {
|
if (filtered[i + rangeStart].id != null) {
|
||||||
pageItems.push(all[i + rangeStart]);
|
pageItems.push(filtered[i + rangeStart]);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//console.log("NO POST", e)
|
//console.log("NO POST", e)
|
||||||
|
@ -62,6 +76,7 @@ router.get('/:page?', function(req, res) {
|
||||||
},
|
},
|
||||||
page_index: pageNum,
|
page_index: pageNum,
|
||||||
page_count: count,
|
page_count: count,
|
||||||
|
postFilter: filter,
|
||||||
user_status: true
|
user_status: true
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
|
@ -1614,6 +1614,10 @@ svg.icons {
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
.main-container section header #header-wrapper #header-one #the-logo,
|
||||||
|
.main-container section header #header-wrapper #header-two #the-logo {
|
||||||
|
width: 40px;
|
||||||
|
}
|
||||||
.main-container section header #header-wrapper #header-two {
|
.main-container section header #header-wrapper #header-two {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
color: #f2f1ef;
|
color: #f2f1ef;
|
||||||
|
@ -1622,12 +1626,12 @@ svg.icons {
|
||||||
text-decoration-color: #fc6399;
|
text-decoration-color: #fc6399;
|
||||||
}
|
}
|
||||||
.main-container section header #header-wrapper #header-two label#the-title {
|
.main-container section header #header-wrapper #header-two label#the-title {
|
||||||
font-family: 'Apercu-Mono';
|
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
font-weight: 300;
|
font-weight: 400;
|
||||||
color: #f5ab35;
|
color: #f5ab35;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: block;
|
display: block;
|
||||||
|
line-height: 0.8;
|
||||||
}
|
}
|
||||||
.main-container section header #header-wrapper #header-two #dash-menu {
|
.main-container section header #header-wrapper #header-two #dash-menu {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
@ -2165,6 +2169,10 @@ select {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
#post-index #post-index-wrapper #post-index-menu .current-filter {
|
||||||
|
color: #fc6399;
|
||||||
|
text-decoration-color: #b2cce5;
|
||||||
|
}
|
||||||
#post-index #post-index-wrapper #posts-list {
|
#post-index #post-index-wrapper #posts-list {
|
||||||
margin: 20px 0 0 0;
|
margin: 20px 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -20,7 +20,7 @@ html(xmlns='http://www.w3.org/1999/xhtml', lang='en', xml:lang="en")
|
||||||
#header-wrapper.columns
|
#header-wrapper.columns
|
||||||
#header-one.column
|
#header-one.column
|
||||||
a(href="/@/dashboard")
|
a(href="/@/dashboard")
|
||||||
img(src="/dash/assets/images/the-logo.svg")
|
img#the-logo(src="/dash/assets/images/the-logo.svg")
|
||||||
#header-two.column
|
#header-two.column
|
||||||
label#the-title= welcome
|
label#the-title= welcome
|
||||||
-if(user_status)
|
-if(user_status)
|
||||||
|
|
|
@ -1,15 +1,22 @@
|
||||||
extends frame
|
extends frame
|
||||||
block main-content
|
block main-content
|
||||||
#post-index
|
#post-index
|
||||||
#post-index-wrapper
|
#post-index-wrapper
|
||||||
#post-index-menu
|
#post-index-menu
|
||||||
a(href="#")= "All Posts ("+page_info.all+")"
|
- if(postFilter=='all')
|
||||||
|
a.current-filter(href="/@/dashboard/posts/all")= "All Posts ("+page_info.all+")"
|
||||||
|
- else
|
||||||
|
a(href="/@/dashboard/posts/all")= "All Posts ("+page_info.all+")"
|
||||||
| .
|
| .
|
||||||
a(href="#")= "Published ("+page_info.published+")"
|
- if(postFilter=='published')
|
||||||
|
a.current-filter(href="/@/dashboard/posts/published")= "Published ("+page_info.published+")"
|
||||||
|
- else
|
||||||
|
a(href="/@/dashboard/posts/published")= "Published ("+page_info.published+")"
|
||||||
| .
|
| .
|
||||||
a(href="#")= "Pages ("+page_info.pages+")"
|
- if(postFilter=='deleted')
|
||||||
| .
|
a.current-filter(href="/@/dashboard/posts/deleted")= "Deleted ("+page_info.deleted+")"
|
||||||
a(href="#")= "Deleted ("+page_info.deleted+")"
|
- else
|
||||||
|
a(href="/@/dashboard/posts/deleted")= "Deleted ("+page_info.deleted+")"
|
||||||
|
|
||||||
a.add-new-post(href="/@/dashboard/posts/add/new") + Create New Post
|
a.add-new-post(href="/@/dashboard/posts/add/new") + Create New Post
|
||||||
#posts-list
|
#posts-list
|
||||||
|
@ -27,13 +34,13 @@ block main-content
|
||||||
- if(prev <= 0) prev = page_count
|
- if(prev <= 0) prev = page_count
|
||||||
|
|
||||||
br
|
br
|
||||||
a.page-btns(href="/@/dashboard/posts/"+prev)
|
a.page-btns(href="/@/dashboard/posts/"+postFilter+"/"+prev)
|
||||||
svg(viewBox="0 0 20 20" class="icons")
|
svg(viewBox="0 0 20 20" class="icons")
|
||||||
use(xlink:href='/dash/assets/images/sprite.svg#entypo-chevron-left')
|
use(xlink:href='/dash/assets/images/sprite.svg#entypo-chevron-left')
|
||||||
|
|
||||||
span.paginate= "PAGE "+page_index+" OF "+page_count
|
span.paginate= "PAGE "+page_index+" OF "+page_count
|
||||||
|
|
||||||
a.page-btns(href="/@/dashboard/posts/"+next)
|
a.page-btns(href="/@/dashboard/posts/"+postFilter+"/"+next)
|
||||||
svg(viewBox="0 0 20 20" class="icons")
|
svg(viewBox="0 0 20 20" class="icons")
|
||||||
use(xlink:href='/dash/assets/images/sprite.svg#entypo-chevron-right')
|
use(xlink:href='/dash/assets/images/sprite.svg#entypo-chevron-right')
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,13 @@
|
||||||
|
|
||||||
#post-index-wrapper
|
#post-index-wrapper
|
||||||
padding 0.75rem
|
padding 0.75rem
|
||||||
|
|
||||||
#post-index-menu
|
#post-index-menu
|
||||||
color $white
|
color $white
|
||||||
|
|
||||||
a
|
a
|
||||||
text-decoration-color: $highlight
|
text-decoration-color $highlight
|
||||||
|
|
||||||
a.add-new-post
|
a.add-new-post
|
||||||
display inline-block
|
display inline-block
|
||||||
background $highlight
|
background $highlight
|
||||||
|
@ -19,8 +22,13 @@
|
||||||
margin-bottom 10px
|
margin-bottom 10px
|
||||||
float right
|
float right
|
||||||
|
|
||||||
|
.current-filter
|
||||||
|
color $highlight
|
||||||
|
text-decoration-color $secondary
|
||||||
|
|
||||||
#posts-list
|
#posts-list
|
||||||
margin 20px 0 0 0
|
margin 20px 0 0 0
|
||||||
|
|
||||||
a.post-link
|
a.post-link
|
||||||
background $white
|
background $white
|
||||||
display inline-block
|
display inline-block
|
||||||
|
@ -28,32 +36,35 @@
|
||||||
width 100%
|
width 100%
|
||||||
text-decoration none
|
text-decoration none
|
||||||
margin 0 0 20px 0
|
margin 0 0 20px 0
|
||||||
border-radius: 3px
|
border-radius 3px
|
||||||
color $primary - 60%
|
color $primary - 60%
|
||||||
|
|
||||||
label
|
label
|
||||||
font-size 1.3em
|
font-size 1.3em
|
||||||
font-weight: 500
|
font-weight 500
|
||||||
padding 10px
|
padding 10px
|
||||||
display inline-block
|
display inline-block
|
||||||
vertical-align: top
|
vertical-align top
|
||||||
width: 45%
|
width 45%
|
||||||
|
|
||||||
span
|
span
|
||||||
display inline-block
|
display inline-block
|
||||||
vertical-align: top
|
vertical-align top
|
||||||
font-size 0.8em
|
font-size 0.8em
|
||||||
font-family 'Apercu-Mono'
|
font-family 'Apercu-Mono'
|
||||||
width: 50%
|
width 50%
|
||||||
text-align: right
|
text-align right
|
||||||
padding 10px
|
padding 10px
|
||||||
|
|
||||||
div.post-bg
|
div.post-bg
|
||||||
width: 100%
|
width 100%
|
||||||
height 350px
|
height 350px
|
||||||
background-color: $highlight
|
background-color $highlight
|
||||||
|
|
||||||
p
|
p
|
||||||
padding 10px
|
padding 10px
|
||||||
font-size 1.2em
|
font-size 1.2em
|
||||||
font-weight: 400
|
font-weight 400
|
||||||
|
|
||||||
#post-edit-index
|
#post-edit-index
|
||||||
width 100%
|
width 100%
|
||||||
|
@ -77,6 +88,7 @@
|
||||||
color $white
|
color $white
|
||||||
padding 5px
|
padding 5px
|
||||||
margin 0 0 5px 0
|
margin 0 0 5px 0
|
||||||
|
|
||||||
#post-date
|
#post-date
|
||||||
background $primary - 10%
|
background $primary - 10%
|
||||||
border-radius 0 3px 3px 0
|
border-radius 0 3px 3px 0
|
||||||
|
@ -119,22 +131,16 @@
|
||||||
|
|
||||||
button[data-active='false']
|
button[data-active='false']
|
||||||
background $secondary
|
background $secondary
|
||||||
|
|
||||||
svg
|
svg
|
||||||
fill $primary
|
fill $primary
|
||||||
|
|
||||||
button[data-active='true']
|
button[data-active='true']
|
||||||
background $tertiary
|
background $tertiary
|
||||||
|
|
||||||
svg
|
svg
|
||||||
fill $tertiary - 70%
|
fill $tertiary - 70%
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//.option-inactive
|
|
||||||
|
|
||||||
//.option-active
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#post-meta
|
#post-meta
|
||||||
#post_tags
|
#post_tags
|
||||||
background $primary - 4%
|
background $primary - 4%
|
||||||
|
|
|
@ -53,22 +53,28 @@ svg.icons
|
||||||
#header-one, #header-two
|
#header-one, #header-two
|
||||||
z-index 10
|
z-index 10
|
||||||
position relative
|
position relative
|
||||||
|
|
||||||
|
#the-logo
|
||||||
|
width 40px
|
||||||
|
|
||||||
#header-two
|
#header-two
|
||||||
text-align right
|
text-align right
|
||||||
color $white
|
color $white
|
||||||
|
|
||||||
a
|
a
|
||||||
text-decoration-color: $highlight
|
text-decoration-color $highlight
|
||||||
|
|
||||||
label#the-title
|
label#the-title
|
||||||
font-family 'Apercu-Mono'
|
|
||||||
font-size 1.2em
|
font-size 1.2em
|
||||||
font-weight: 300
|
font-weight 400
|
||||||
color $tertiary
|
color $tertiary
|
||||||
text-decoration none
|
text-decoration none
|
||||||
display block
|
display block
|
||||||
|
line-height 0.8
|
||||||
// word-break: break-all;
|
// word-break: break-all;
|
||||||
|
|
||||||
#dash-menu
|
#dash-menu
|
||||||
text-align: right
|
text-align right
|
||||||
|
|
||||||
/* Mozilla based browsers */
|
/* Mozilla based browsers */
|
||||||
::-moz-selection
|
::-moz-selection
|
||||||
|
|
Loading…
Reference in a new issue