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

View File

@ -4,10 +4,6 @@ import './style.scss';
import UserError from 'core/lib/user-error'; import UserError from 'core/lib/user-error';
class Controller extends Section { class Controller extends Section {
constructor($element, $, vnReport) {
super($element, $);
this.droppableElement = 'a.vn-tr';
}
get isChecked() { get isChecked() {
if (this.tickets) { if (this.tickets) {
for (let instance of this.tickets) for (let instance of this.tickets)
@ -124,10 +120,20 @@ class Controller extends Section {
} }
onDrop($event) { onDrop($event) {
const target = $event.target; const ticketId = $event.dataTransfer.getData('Text');
const droppable = target.closest(this.droppableElement);
const ticketId = droppable.id; if (isNaN(ticketId)) {
console.log($event, target, droppable, 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) { insert(ticketId) {