refactor: undo chages about drag&drop
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2022-06-14 13:52:32 +02:00
parent 52e78db9ee
commit e61784b6ba
2 changed files with 25 additions and 34 deletions

View File

@ -7,8 +7,7 @@
auto-load="true">
</vn-crud-model>
<vn-data-viewer
model="model"
class="travel-list">
model="model">
<form
class="vn-w-xl"
name="form">
@ -34,7 +33,7 @@
</vn-tool-bar>
</vn-card>
<vn-card class="vn-mt-lg">
<vn-table model="model" auto-load="false">
<vn-table model="model" auto-load="false" vn-droppable="$ctrl.onDrop($event)">
<vn-thead>
<vn-tr>
<vn-th shrink>
@ -57,25 +56,17 @@
</vn-tr>
</vn-thead>
<vn-tbody>
<a ng-repeat="ticket in $ctrl.tickets"
class="clickable vn-tr search-result"
href="#"
ng-attr-id="{{::ticket.id}}"
ng-attr-priority="{{::ticket.priority}}"
vn-droppable="$ctrl.onDrop($event)"
>
<vn-tr ng-repeat="ticket in $ctrl.tickets">
<vn-td shrink>
<vn-check
ng-model="ticket.checked"
vn-click-stop>
ng-model="ticket.checked">
</vn-check>
</vn-td>
<vn-td>
<vn-icon-button
icon="add_circle"
ng-click="$ctrl.setHighestPriority(ticket.id)"
tabindex="-1"
vn-click-stop>
tabindex="-1">
</vn-icon-button>
</vn-td>
<vn-td>
@ -83,8 +74,7 @@
on-change="$ctrl.setPriority(ticket.id, ticket.priority)"
ng-model="ticket.priority"
rule="Ticket"
class="dense"
vn-click-stop>
class="dense">
</vn-input-number>
</vn-td>
<vn-td expand title="{{::ticket.street}}">{{::ticket.street}}</vn-td>
@ -93,8 +83,7 @@
<vn-td expand>
<span
ng-click="clientDescriptor.show($event, ticket.clientFk)"
class="link"
vn-click-stop>
class="link">
{{::ticket.nickname}}
</span>
</vn-td>
@ -103,8 +92,7 @@
<vn-td number>
<span
ng-click="ticketDescriptor.show($event, ticket.id)"
class="link"
vn-click-stop>
class="link">
{{::ticket.id}}
</span>
</vn-td>
@ -113,8 +101,7 @@
ng-if="::ticket.notes.length"
title="{{::ticket.notes[0].description}}"
icon="insert_drive_file"
class="bright"
vn-click-stop>
class="bright">
</vn-icon>
</vn-td>
<vn-td>
@ -122,8 +109,7 @@
translate-attr="{title: 'Remove ticket'}"
icon="delete"
ng-click="$ctrl.showDeleteConfirm(ticket.id)"
tabindex="-1"
vn-click-stop>
tabindex="-1">
</vn-icon-button>
</vn-td>
<vn-td>
@ -131,8 +117,7 @@
ng-if="::ticket.description"
vn-tooltip="{{::ticket.description}}"
icon="icon-notes"
tabindex="-1"
vn-click-stop>
tabindex="-1">
</vn-icon-button>
</vn-td>
</a>

View File

@ -4,10 +4,6 @@ import './style.scss';
import UserError from 'core/lib/user-error';
class Controller extends Section {
constructor($element, $, vnReport) {
super($element, $);
this.droppableElement = 'a.vn-tr';
}
get isChecked() {
if (this.tickets) {
for (let instance of this.tickets)
@ -124,10 +120,20 @@ class Controller extends Section {
}
onDrop($event) {
const target = $event.target;
const droppable = target.closest(this.droppableElement);
const ticketId = droppable.id;
console.log($event, target, droppable, ticketId);
const ticketId = $event.dataTransfer.getData('Text');
if (isNaN(ticketId)) {
const regexp = new RegExp(/\/ticket\/([0-9]+)\//i);
const matches = ticketId.match(regexp);
if (matches && matches.length)
this.insert(matches[1]);
else
this.vnApp.showError(this.$t('Ticket not found'));
}
if (!isNaN(ticketId))
this.insert(ticketId);
}
insert(ticketId) {