feat: All Pages directory handling
This commit is contained in:
parent
f44d0a3c44
commit
0d3e10edda
@ -4,6 +4,8 @@ import $ from 'jquery'
|
||||
import Vue from 'vue'
|
||||
import _ from 'lodash'
|
||||
|
||||
const rootUrl = '/'
|
||||
|
||||
module.exports = (alerts, socket) => {
|
||||
if ($('#page-type-all').length) {
|
||||
let vueAllPages = new Vue({ // eslint-disable-line no-unused-vars
|
||||
@ -29,6 +31,9 @@ module.exports = (alerts, socket) => {
|
||||
$('#notifload').removeClass('active')
|
||||
})
|
||||
})
|
||||
},
|
||||
goto: function (entryPath) {
|
||||
window.location.assign(rootUrl + entryPath)
|
||||
}
|
||||
},
|
||||
mounted: function () {
|
||||
|
@ -301,7 +301,7 @@ module.exports = {
|
||||
winston.error(err)
|
||||
return err
|
||||
}).then((content) => {
|
||||
// let entryPaths = _.split(content.entryPath, '/')
|
||||
let parentPath = _.chain(content.entryPath).split('/').initial().join('/').value()
|
||||
return db.Entry.findOneAndUpdate({
|
||||
_id: content.entryPath
|
||||
}, {
|
||||
@ -309,11 +309,22 @@ module.exports = {
|
||||
title: content.meta.title || content.entryPath,
|
||||
subtitle: content.meta.subtitle || '',
|
||||
parentTitle: content.parent.title || '',
|
||||
parentPath: content.parent.path || ''
|
||||
parentPath: parentPath,
|
||||
isDirectory: false
|
||||
}, {
|
||||
new: true,
|
||||
upsert: true
|
||||
})
|
||||
}).then(result => {
|
||||
return db.Entry.distinct('parentPath', { parentPath: { $ne: '' } }).then(allPaths => {
|
||||
if (allPaths.length > 0) {
|
||||
return db.Entry.updateMany({ _id: { $in: allPaths } }, { $set: { isDirectory: true } }).then(() => {
|
||||
return result
|
||||
})
|
||||
} else {
|
||||
return result
|
||||
}
|
||||
})
|
||||
}).catch(err => {
|
||||
winston.error(err)
|
||||
return err
|
||||
|
@ -28,6 +28,10 @@ block content
|
||||
span Login
|
||||
ul.collapsable-nav(v-for='treeItem in tree', :class='{ "has-children": treeItem.hasChildren }', v-cloak)
|
||||
li(v-for='page in treeItem.pages', :class='{ "is-active": page.isActive }')
|
||||
a(v-on:click='fetch(page._id)')
|
||||
i(:class='{ "icon-folder2": page.isFolder, "icon-file": !page.isFolder }')
|
||||
a(v-on:click='(page.isDirectory) ? fetch(page._id) : goto(page._id)')
|
||||
template(v-if='page._id !== "home"')
|
||||
i(:class='{ "icon-folder2": page.isDirectory, "icon-file-text-o": !page.isDirectory }')
|
||||
span {{ page.title }}
|
||||
template(v-else)
|
||||
i.icon-home
|
||||
span Home
|
||||
|
Loading…
Reference in New Issue
Block a user