feat: drag and drop
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2022-06-09 13:48:57 +02:00
parent 409e935cc7
commit afd95872c8
2 changed files with 30 additions and 43 deletions

View File

@ -49,10 +49,17 @@
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="ticket in $ctrl.tickets" ng-attr-id="{{::ticket.id}}" vn-droppable="$ctrl.onDrop($event)">
<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-td shrink>
<vn-check
ng-model="ticket.checked">
ng-model="ticket.checked"
vn-click-stop>
</vn-check>
</vn-td>
<vn-td>
@ -60,7 +67,8 @@
on-change="$ctrl.setPriority(ticket.id, ticket.priority)"
ng-model="ticket.priority"
rule="Ticket"
class="dense">
class="dense"
vn-click-stop>
</vn-input-number>
</vn-td>
<vn-td expand title="{{::ticket.street}}">{{::ticket.street}}</vn-td>
@ -69,7 +77,8 @@
<vn-td expand>
<span
ng-click="clientDescriptor.show($event, ticket.clientFk)"
class="link">
class="link"
vn-click-stop>
{{::ticket.nickname}}
</span>
</vn-td>
@ -78,7 +87,8 @@
<vn-td number>
<span
ng-click="ticketDescriptor.show($event, ticket.id)"
class="link">
class="link"
vn-click-stop>
{{::ticket.id}}
</span>
</vn-td>
@ -87,7 +97,8 @@
ng-if="::ticket.notes.length"
title="{{::ticket.notes[0].description}}"
icon="insert_drive_file"
class="bright">
class="bright"
vn-click-stop>
</vn-icon>
</vn-td>
<vn-td>
@ -95,10 +106,11 @@
translate-attr="{title: 'Remove ticket'}"
icon="delete"
ng-click="$ctrl.showDeleteConfirm(ticket.id)"
tabindex="-1">
tabindex="-1"
vn-click-stop>
</vn-icon-button>
</vn-td>
</vn-tr>
</a>
</vn-tbody>
</vn-table>
</vn-card>

View File

@ -4,6 +4,10 @@ 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)
@ -58,7 +62,9 @@ class Controller extends Section {
let url = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr=';
lines.forEach(line => {
addresses = addresses + '+to:' + line.postalCode + ' ' + line.city + ' ' + line.street;
if lineOld.street <> line.street
addresses = addresses + '+to:' + line.postalCode + ' ' + line.city + ' ' + line.street;
lineOld = line
});
window.open(url + addresses, '_blank');
@ -96,42 +102,11 @@ class Controller extends Section {
});
}
findDroppable($event) {
onDrop($event) {
const target = $event.target;
const droppable = target.closest(this.droppableElement);
return droppable;
}
onDrop($event) {
const model = this.$.model;
const droppable = this.findDroppable($event);
const travelId = parseInt(droppable.id);
console.log(travelId);
const currentDroppable = this.entry.closest(this.droppableElement);
if (currentDroppable == droppable) return;
if (this.entryId && travelId) {
const path = `Entries/${this.entryId}`;
this.$http.patch(path, {travelFk: travelId})
.then(() => model.refresh())
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
}
// 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);
const ticketId = droppable.id;
console.log($event, target, droppable, ticketId);
}
insert(ticketId) {