Git Product home page Git Product logo

vuetify-draggable-treeview's Introduction

Actions Status npm version

vuetify-draggable-treeview

Drag and drop v-treeview (Vuetify Treeview) component.

Live Demo

v-treeview

Installation

yarn add vuetify-draggable-treeview
// @NOTE: This component requires vue, vuetify, vuedraggable as peerDependency.
yarn add vuedraggable

Setup

import VuetifyDraggableTreeview from 'vuetify-draggable-treeview'
Vue.use(VuetifyDraggableTreeview)

// or manually import
VuetifyDraggableTreeview

export default Vue.extend({
  components: {
    VuetifyDraggableTreeview
  }
})

Usage

Basic Example

<template>
<v-draggable-treeview
  group="test"
  v-model="items"
></v-draggable-treeview>
</template>

<script>
export default {
  data() {
    return {
      items: [{ id: 1, name: "hoge", children: [{ id:11, name: "hoge-child1" }] }]
    }
  }
}
</script>

Drag and drop only in children.

<template>
<v-draggable-treeview
  v-model="items"
></v-draggable-treeview>
</template>

<script>
export default {
  data() {
    return {
      items: [{ id: 1, name: "hoge", children: [{ id:11, name: "hoge-child1" }] }]
    }
  }
}
</script>

Using slot

<template>
<v-draggable-treeview v-model="items" group="hoge">
  <template v-slot:prepend="{ item }">
    <v-icon>mdi-file</v-icon>
  </template>
  <template v-slot:label="{ item }">
    <span class="primary--text">{{ item.name }}</span>
  </template>
  <template v-slot:append="{ item }">
    <template
            v-if="item.children != null && item.children.length > 0"
    >
      has {{ item.children.length }} children
    </template>
  </template>
</v-draggable-treeview>
</template>

<script>
export default {
  data() {
    return {
      items: [{ id: 1, name: "hoge", children: [{ id:11, name: "hoge-child1" }] }]
    }
  }
}
</script>

API

Currently, this component dose not support all original v-treeview component's props, slots, event.

Props

Name Type Default Description
value Object [] items for treeview. item-key, item-text, item-children are not customizable currently. value can be like { id: 1, name: "test", children: []} .
group string null group name for vuedraggable. If this props not provided, drag and drop are enabled only in children.
expand-icon string 'mdi-menu-down' mdi string for the expand icon.

Events

Name Value Description
input array Emits the array of selected items when this value changes

Slots

Name Props Description
append { item: any, open: boolean } Appends content after label
label { item: any, open: boolean } Label content
prepend { item: any, open: boolean } Prepends content before label

vuetify-draggable-treeview's People

Contributors

ayhaski avatar dependabot-preview[bot] avatar dependabot[bot] avatar suusan2go avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vuetify-draggable-treeview's Issues

draggable item are disappear

If group is not null, sometimes draggable item are disappear if they dropped between rows.
What should I put in the 'group' prop?

Draggable prop not working?

Im trying to disable the drag in specific cases but it's not working and I didn't find in docs more about it

<v-draggable-treeview 
...
:draggable="item => !['Senão', 'Então', 'Iterar'].includes(item.name)">

bad data emission

Hello thanks for this great component, I have a question to see if you help me, I am using it so that drag and drop is only between children, but I have a question when I catch the @input event, the data that returns me is always that of the parents, why does this happen? Using in vue tools I see that the event emits the array correctly, but what I receive in the data is only the parent array, I don't know if I explain myself!

<v-draggable-treeview v-model="items" @input="getDataDragg" >
this is the data seen from the vue tools when it emits the imput event, the IDs are 50, 44, 45
[[{"id":50,"category_id":41,"is_parent":false,"name":"Automatic","slug":"automatic","status":true,"position":3,"children":[]},{"id":44,"category_id":41,"is_parent":true,"name":"Motherboard","slug":"motherboard","status":true,"position":1,"children":{"id":45,"category_id":41,"is_parent":true,"name":"Microprocesor","slug":"microprocesor","status":true,"position":2,"children":

getDataDragg(data) {
console.log(data)
},
and it is in the data that I receive in the method when it is issued
[[{"id":43,"category_id":null,"is_parent":true,"name":"Digitals","slug":"digitals","status":true,"position":3,"children"{"id":49,"category_id":null,"is_parent":false,"name":"Others","slug":"others","status":true,"position":1,"children":[]},{"id":41,"category_id":null,"is_parent":true,"name":"Computers","slug":"computers","status":true,"position":2,"children":

that data are the root swims to tell you in some way
What am I doing wrong or how to solve it, thanks

Support for Vuetify props ?

Hi,

Seems I can't use the props which are available for a 'normal' v-treeview.
e.g. I would like to use the "dense" prop, though this doesn't seem to be supported.

Or am I missing something ?
Thanks in advance for your reply,

Johnny

Possibility for an "open-all" prop

I really like the component, thank you for your work on it.

Would it be possible to add something like an "open-all" prop that will expand all nodes?

Insert, children = null or empty

Great work!

What about if there is no children and I want to insert a node to another node, that has no children? currently it does not work at all.

... node.vue:


            <draggable
                    @input="updateValue"
            >


            /**
            * Workaround if there is no child yet
            */
            move(value: any): void {
               const parent = value.relatedContext.component.$parent;
               const isNodeComponent = parent.updateChildValue;
               if (!parent.hasChildren && isNodeComponent ) {
                     const insertedElement: TreeItem = value.draggedContext.element;
                    parent.updateChildValue(insertedElement);
               }
            }

Any better idea? =)

Looking bad after build

Hi.
When I use npm run serve It works well.
But with npm run build It looking bad.

While serving:
image

After build:
image

My Code:

<v-draggable-treeview
  group="test"
  v-model="items"
></v-draggable-treeview>

Data Section:

items: [{ id: 1, name: "hoge", children: [{ id:11, name: "hoge-child1" }] }]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.