Guest User

Untitled

a guest
Nov 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. expandTree: function (absolutePath) {
  2. // get parts for the path
  3. let parts = absolutePath.split(path.sep)
  4. let path2 = ''
  5. let lastNodeKey
  6.  
  7. // iterate through the path parts.
  8. // This code will get the node. If the node is not found,
  9. // it forces lazy-load by programmatically expanding
  10. // the parent node.
  11. for (let index = 0; index < parts.length; ++index) {
  12. if (parts[index].length === 0) {
  13. continue
  14. }
  15. if (index === 0) {
  16. path2 += parts[index] + path.sep
  17. }
  18. else {
  19. if (path2[path2.length - 1] !== path.sep) {
  20. path2 += path.sep
  21. }
  22. path2 += parts[index]
  23. }
  24. if (index > -1) {
  25. if ('folders' in this.$refs) {
  26. const key = this.$refs.folders.getNodeByKey(path2)
  27. // if we get key, then this folder has already been loaded
  28. if (key) {
  29. lastNodeKey = key
  30. }
  31. // handle folder not expanded
  32. if (!this.$refs.folders.isExpanded(lastNodeKey.nodeKey)) {
  33. this.$refs.folders.setExpanded(lastNodeKey.nodeKey, true)
  34. if (path2 === absolutePath) {
  35. this.selected = absolutePath
  36. }
  37. else {
  38. this.$nextTick(() => {
  39. this.$root.$emit('expand-tree', absolutePath)
  40. })
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }
Add Comment
Please, Sign In to add comment