Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- expandTree: function (absolutePath) {
- // get parts for the path
- let parts = absolutePath.split(path.sep)
- let path2 = ''
- let lastNodeKey
- // iterate through the path parts.
- // This code will get the node. If the node is not found,
- // it forces lazy-load by programmatically expanding
- // the parent node.
- for (let index = 0; index < parts.length; ++index) {
- if (parts[index].length === 0) {
- continue
- }
- if (index === 0) {
- path2 += parts[index] + path.sep
- }
- else {
- if (path2[path2.length - 1] !== path.sep) {
- path2 += path.sep
- }
- path2 += parts[index]
- }
- if (index > -1) {
- if ('folders' in this.$refs) {
- const key = this.$refs.folders.getNodeByKey(path2)
- // if we get key, then this folder has already been loaded
- if (key) {
- lastNodeKey = key
- }
- // handle folder not expanded
- if (!this.$refs.folders.isExpanded(lastNodeKey.nodeKey)) {
- this.$refs.folders.setExpanded(lastNodeKey.nodeKey, true)
- if (path2 === absolutePath) {
- this.selected = absolutePath
- }
- else {
- this.$nextTick(() => {
- this.$root.$emit('expand-tree', absolutePath)
- })
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment