2017-04-10 01:13:53 +00:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
import $ from 'jquery'
|
2017-04-18 02:44:04 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
import _ from 'lodash'
|
2017-04-10 01:13:53 +00:00
|
|
|
|
|
|
|
module.exports = (alerts, socket) => {
|
|
|
|
if ($('#page-type-all').length) {
|
2017-04-18 02:44:04 +00:00
|
|
|
let vueAllPages = new Vue({ // eslint-disable-line no-unused-vars
|
|
|
|
el: '#page-type-all',
|
|
|
|
data: {
|
|
|
|
tree: []
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
fetch: function (basePath) {
|
|
|
|
let self = this
|
|
|
|
$('#notifload').addClass('active')
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
socket.emit('treeFetch', { basePath }, (data) => {
|
|
|
|
if (self.tree.length > 0) {
|
|
|
|
let curTree = _.last(self.tree)
|
|
|
|
curTree.hasChildren = true
|
|
|
|
_.find(curTree.pages, { _id: basePath }).isActive = true
|
|
|
|
}
|
|
|
|
self.tree.push({
|
|
|
|
hasChildren: false,
|
|
|
|
pages: data
|
|
|
|
})
|
|
|
|
$('#notifload').removeClass('active')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted: function () {
|
2017-04-23 14:56:14 +00:00
|
|
|
let basePath = window.location.pathname.slice(0, -4)
|
|
|
|
if (basePath.length > 1) {
|
|
|
|
basePath = basePath.slice(1)
|
|
|
|
}
|
|
|
|
this.fetch(basePath)
|
2017-04-18 02:44:04 +00:00
|
|
|
}
|
|
|
|
})
|
2017-04-10 01:13:53 +00:00
|
|
|
}
|
|
|
|
}
|