|
|
@ -50,14 +50,10 @@ const onMove = (event: { moved: { newIndex: number } }) => { |
|
|
|
|
|
|
|
|
|
|
|
if (fields.value.length < 2) return |
|
|
|
if (fields.value.length < 2) return |
|
|
|
|
|
|
|
|
|
|
|
if (fields.value.length - 1 === event.moved.newIndex) { |
|
|
|
fields.value.map((field, index) => { |
|
|
|
fields.value[event.moved.newIndex].order = (fields.value[event.moved.newIndex - 1].order || 1) + 1 |
|
|
|
field.order = index + 1 |
|
|
|
} else if (event.moved.newIndex === 0) { |
|
|
|
return field |
|
|
|
fields.value[event.moved.newIndex].order = (fields.value[1].order || 1) / 2 |
|
|
|
}) |
|
|
|
} else { |
|
|
|
|
|
|
|
fields.value[event.moved.newIndex].order = |
|
|
|
|
|
|
|
((fields.value[event.moved.newIndex - 1].order || 1) + (fields.value[event.moved.newIndex + 1].order || 1)) / 2 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
saveOrUpdate(fields.value[event.moved.newIndex], event.moved.newIndex) |
|
|
|
saveOrUpdate(fields.value[event.moved.newIndex], event.moved.newIndex) |
|
|
|
|
|
|
|
|
|
|
@ -88,7 +84,7 @@ const onMove = (event: { moved: { newIndex: number } }) => { |
|
|
|
<a-input v-model:value="filterQuery" size="small" :placeholder="$t('placeholder.searchFields')" /> |
|
|
|
<a-input v-model:value="filterQuery" size="small" :placeholder="$t('placeholder.searchFields')" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="nc-fields-list py-1"> |
|
|
|
<div class="nc-fields-list py-1"> |
|
|
|
<Draggable :list="fields" item-key="id" @change="onMove($event)"> |
|
|
|
<Draggable v-model="fields" item-key="id" @change="onMove($event)"> |
|
|
|
<template #item="{ element: field, index: index }"> |
|
|
|
<template #item="{ element: field, index: index }"> |
|
|
|
<div v-show="filteredFieldList.includes(field)" :key="field.id" class="px-2 py-1 flex" @click.stop> |
|
|
|
<div v-show="filteredFieldList.includes(field)" :key="field.id" class="px-2 py-1 flex" @click.stop> |
|
|
|
<a-checkbox v-model:checked="field.show" class="flex-shrink" @change="saveOrUpdate(field, index)"> |
|
|
|
<a-checkbox v-model:checked="field.show" class="flex-shrink" @change="saveOrUpdate(field, index)"> |
|
|
|