Giter Club home page Giter Club logo

Comments (13)

David-Desmaisons avatar David-Desmaisons commented on July 28, 2024 2

I meant transformOnAdd would by a prop of vue.draggable that would be a function taking copied element as entry and returning the element to insert:

function transformOnAdd(copiedElement){
   ...
   return elementToCopyInTheTarget;
}

from vue.draggable.

vTrippy avatar vTrippy commented on July 28, 2024 1

There is a Vue function named Vue.$forceUpdate() which forces vDOM to update.
What you need to do is only writethis.$forceUpdate(); at the end of the success part of your XHR.

from vue.draggable.

David-Desmaisons avatar David-Desmaisons commented on July 28, 2024

Could you provide the template HTML?

from vue.draggable.

SebastienDenooz avatar SebastienDenooz commented on July 28, 2024

Here is the from:

<h3>Group fields templates</h3>
<ul class="list-group" id="availableGroups">
    <draggable @add="onAdd" @sort="onSort" @update="onUpdate" :clone="cloneGroup" :list="groups" :options="{animation: 150, sort: false, group: {name: 'fields', pull: 'clone', put: false}}">
        <available-groups v-for="group in groups" :group="group"></available-groups>
    </draggable>
</ul>

And here is the to:

<div class="panel-body">
    <draggable class="list-group field-list" :id="'field-list-' + page.id" :data-page_id="page.id" element="ul" @add="onAdd" @sort="onSort" @update="onUpdate" :list="page.fields" :options="{animation: 150, draggable: '.draggable',group: {name: 'fields',pull: 'clone'}}">
        <ha-field v-for="field in page.fields" :page_id="page.id" v-bind:field="field" v-on:delete-field="deleteField(field)" v-on:delete-group-field="deleteGroupField(field, [group, field])" v-on:delete-group="deleteGroup(field)"></ha-field>
    </draggable>
</div>

And here are the field component template:

<li class="list-group-item draggable ignore-elements"  :id="'field-' + field.id">
    <span v-if="field.is_group"><strong>Group: </strong></span>
    <span v-else="field.is_group"><strong>Field: </strong></span>
    <span class="field-name">@{{field.name}}
        <a v-if='field.is_group' :href="'#field-group-list-' + field.id" role="button" data-toggle="collapse" class="btn btn-xs btn-links">
            <i class="fa fa-plus"></i></a>
    </span>
    <p class="pull-right">
        <a v-if='!field.is_group' href="#" class="btn btn-xs btn-primary edit-field" :data-field_id="field.id" @click.prevent="editField"><i class="glyphicon glyphicon-pencil"></i></a>
        <a v-if='field.is_group' href="#" class="btn btn-xs btn-warning delete-field" :data-field_id="field.id" @click.prevent="$emit('delete-group')"><i class="glyphicon glyphicon-trash"></i></a>
        <a v-else='field.is_group' href="#" class="btn btn-xs btn-warning delete-field" :data-field_id="field.id" @click.prevent="$emit('delete-field')"><i class="glyphicon glyphicon-trash"></i></a>
    </p>
    <ul v-if='field.is_group' class="list-group grouped-fields collapse" :id="'field-group-list-'+field.id">
        <li v-for="_field in field.fields" class="list-group-item" :id="'group_field_' + _field.id">
            <strong>Field: </strong> @{{ _field.name }}
            <p class="pull-right">
                <a href="#" class="btn btn-xs btn-primary edit-field" :data-field_id="_field.id" @click.prevent="editField(_field.id)"><i class="glyphicon glyphicon-pencil"></i></a>
                <a href="#" class="btn btn-xs btn-warning delete-field" :data-field_id="_field.id" @click.prevent="deleteGroupField(field, _field)"><i class="glyphicon glyphicon-trash"></i></a>
            </p>
        </li>
    </ul>
</li>

Thx

from vue.draggable.

David-Desmaisons avatar David-Desmaisons commented on July 28, 2024

Hi @SebastienDenooz , could you please simplify and create a jsfiddle? Thanks

from vue.draggable.

David-Desmaisons avatar David-Desmaisons commented on July 28, 2024

@SebastienDenooz , Did the fix by @vTrippy work for you?

from vue.draggable.

David-Desmaisons avatar David-Desmaisons commented on July 28, 2024

I am closing this. If needed provided a jsfidle and I will re-open the issue.

from vue.draggable.

SebastienDenooz avatar SebastienDenooz commented on July 28, 2024

Hi all,

So, here is my jsfiddle. I try to simplify a maximum my code : https://jsfiddle.net/jon33s0z/1/

The main question is: How to modify / replace the 'cloned' element in the list where it is droped.

Thank's for your time all!!

Seb

from vue.draggable.

David-Desmaisons avatar David-Desmaisons commented on July 28, 2024

@SebastienDenooz use clone props

from vue.draggable.

SebastienDenooz avatar SebastienDenooz commented on July 28, 2024

Yes i see it, but the clone is fired dirctly on the drag start.

If i have more than one page (more than one target for the drag), the clone is fired on drag start, the xhr is made but i do not know yet what "target" page it is. Assuming the REST ressource is POST /pages/#/fieds/, on the clone i do not known the page_id.

from vue.draggable.

David-Desmaisons avatar David-Desmaisons commented on July 28, 2024

Well, you can use the add event on the target draggable component or watch the underlying list using vue watch methods.

Another posiibility should be create an "transformOnAdd" prop that on target component will transform the copied element. Thougths?

from vue.draggable.

SebastienDenooz avatar SebastienDenooz commented on July 28, 2024

transformOnAdd would be a good idea!

But i can not 'find' the new element in the event passed to the add to pass it to the transformOnAdd.

I can not find the new vue element. How can find it to passing it to transformOnAdd? That's my problem :s

from vue.draggable.

David-Desmaisons avatar David-Desmaisons commented on July 28, 2024

@SebastienDenooz what is your feedback on this?

from vue.draggable.

Related Issues (20)

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.