Vue.Draggable icon indicating copy to clipboard operation
Vue.Draggable copied to clipboard

how to ignore element inside draggable component

Open boldstar opened this issue 7 years ago • 3 comments

so this may be a duplicate but the suggestions I have found have not solved my issue. I am using a draggable component in a table like so

<draggable class="text-left" :element="'tbody'" v-model="workflow.statuses" @start="drag=true" @end="drag=false" @change="updateStatusOrder(workflow.id, workflow.statuses)" ref="table" :options="{animation: 200, handle: '.draggable'}" :sortable="true">
  <template v-for="(status, index) in workflow.statuses">
  <tr :key="status.order"  :class="{'highlight-status': checkValue(status.id)}" @click="showMessage(index, status.workflow_id)" class="draggable">
  <th scope="row" class="status-th"><div class="status-order"></div> {{ appendZero(index + 1) }}</th>
 <td>{{ status.status }}</td>
  <td class="text-center"><i class="fas fa-check text-primary" v-if="status.notify_client"></i></td>
  </tr>
</template>
</draggable>

Now with this set up, when I update the order of the table rows it works fine, however I am trying to implement a conditional element inside of the table but when i do this and attempt to change the order of the table row I get an alarm. Here is the table with the conditional element

<draggable class="text-left" :element="'tbody'" v-model="workflow.statuses" @start="drag=true" @end="drag=false" @change="updateStatusOrder(workflow.id, workflow.statuses)" ref="table" :options="{animation: 200, handle: '.draggable'}" :sortable="true">
 <template v-for="(status, index) in workflow.statuses">
  <tr :key="status.order"  :class="{'highlight-status': checkValue(status.id)}" @click="showMessage(index, status.workflow_id)" class="draggable">
     <th scope="row" class="status-th"><div class="status-order"></div> {{ appendZero(index + 1) }}</th>
    <td>{{ status.status }}</td>
    <td class="text-center"><i class="fas fa-check text-primary" v-if="status.notify_client"></i></td>
   </tr>
<!-- conditional element -->
   <tr v-if="selectedIndex == index && selectedWorkflow === workflow.id" :key="status.id">
    <td colspan="3">
     <div class="d-flex flex-column align-items-end">
      <textarea type="text" class="w-100" cols="5"></textarea>
     <div class="d-flex mt-2">
     <button class="btn btn-sm btn-primary mr-2">Save</button>
     <button class="btn btn-sm btn-secondary" @click="removeRow()">Cancel</button>
     </div>
   </div>
   </td>
 </tr>
</template>
</draggable>

Is there a way I can make the draggablecomponent igonre my conditional element when attempting to re order the list? Ive tried handle but no luck.

boldstar avatar Mar 18 '19 19:03 boldstar

@boldstar Your template won´t work with vue.draggale. The children itens have to match the list elements unless vue.draggable has no clue on with element/index to update. So