You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1021 B

  1. 'use strict'
  2. import $ from 'jquery'
  3. import Vue from 'vue'
  4. import _ from 'lodash'
  5. module.exports = (alerts, socket) => {
  6. if ($('#page-type-all').length) {
  7. let vueAllPages = new Vue({ // eslint-disable-line no-unused-vars
  8. el: '#page-type-all',
  9. data: {
  10. tree: []
  11. },
  12. methods: {
  13. fetch: function (basePath) {
  14. let self = this
  15. $('#notifload').addClass('active')
  16. Vue.nextTick(() => {
  17. socket.emit('treeFetch', { basePath }, (data) => {
  18. if (self.tree.length > 0) {
  19. let curTree = _.last(self.tree)
  20. curTree.hasChildren = true
  21. _.find(curTree.pages, { _id: basePath }).isActive = true
  22. }
  23. self.tree.push({
  24. hasChildren: false,
  25. pages: data
  26. })
  27. $('#notifload').removeClass('active')
  28. })
  29. })
  30. }
  31. },
  32. mounted: function () {
  33. this.fetch('')
  34. }
  35. })
  36. }
  37. }