From e9af38081e05eb1dd84ab18a055b9e3fff215407 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 22 Jun 2022 14:36:38 -0600 Subject: [PATCH] Move email-specific D-n-d into Et2SelectEmail class --- api/js/etemplate/Et2Select/Et2SelectEmail.ts | 32 ++++++++++++++++++++ api/js/etemplate/Et2Select/SearchMixin.ts | 27 ----------------- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/api/js/etemplate/Et2Select/Et2SelectEmail.ts b/api/js/etemplate/Et2Select/Et2SelectEmail.ts index 44d033ff0b..db0c392585 100644 --- a/api/js/etemplate/Et2Select/Et2SelectEmail.ts +++ b/api/js/etemplate/Et2Select/Et2SelectEmail.ts @@ -69,6 +69,38 @@ export class Et2SelectEmail extends Et2Select super.connectedCallback(); } + + protected _bindListeners() + { + super._bindListeners(); + if(!this.multiple) + { + return; + } + interact(this).dropzone({ + accept: `.et2-select-draggable`, + ondrop: function(e) + { + e.target.createFreeEntry(e.draggable.target.value); + e.target.classList.remove('et2_toolbarDropArea'); + + // remove the dragged value from its origin source + e.draggable.parent_node.value = e.draggable.parent_node.value.filter(_item => {return e.draggable.target.value !== _item;}) + + // set value for newly dropped target + e.target.value.push(e.draggable.target.value); + }, + ondragenter: function(e) + { + e.target.classList.add('et2_dropZone'); + }, + ondragleave: function(e) + { + e.target.classList.remove('et2_dropZone'); + } + }); + } + /** * Actually query the server. * diff --git a/api/js/etemplate/Et2Select/SearchMixin.ts b/api/js/etemplate/Et2Select/SearchMixin.ts index 58e42cb038..699e43944e 100644 --- a/api/js/etemplate/Et2Select/SearchMixin.ts +++ b/api/js/etemplate/Et2Select/SearchMixin.ts @@ -12,7 +12,6 @@ import {css, html, LitElement, render, repeat, SlotMixin} from "@lion/core"; import {cleanSelectOptions, SelectOption} from "./FindSelectOptions"; import {Validator} from "@lion/form-core"; import {Et2Tag} from "./Tag/Et2Tag"; -import interact from "@interactjs/interact"; // Otherwise import gets stripped let keep_import : Et2Tag; @@ -449,32 +448,6 @@ export const Et2WithSearchMixin = >(superclass this.addEventListener("sl-select", this._handleSelect); this.addEventListener("sl-clear", this._handleClear) this._searchButtonNode.addEventListener("click", this._handleSearchButtonClick); - if (this.nodeName === 'ET2-SELECT-EMAIL') - { - interact(this).dropzone({ - accept: `.et2-select-draggable`, - ondrop: function(e) - { - e.target.createFreeEntry(e.draggable.target.value); - e.target.classList.remove('et2_toolbarDropArea'); - - // remove the dragged value from its origin source - e.draggable.parent_node.value = e.draggable.parent_node.value.filter(_item=>{return e.draggable.target.value !== _item;}) - - // set value for newly dropped target - e.target.value.push(e.draggable.target.value); - }, - ondragenter: function(e) - { - e.target.classList.add('et2_dropZone'); - }, - ondragleave: function(e) - { - e.target.classList.remove('et2_dropZone'); - } - }); - } - } protected _unbindListeners()