summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorigbe <igbe@odoo.com>2025-01-13 10:38:55 +0100
committerigbe <igbe@odoo.com>2025-02-05 06:01:24 +0000
commit94ed7173de4d6a73c5cfa6843b3628084248f18d (patch)
treec287191bda6e7ce473f3194d1d5ce64d30219310
parent5c773969b3cf94ebeb012d20fb004a795f8fcaf0 (diff)
[IMP] account: allow only file drop
This commit change a bit the behaviour of drag & drop feature in multiple account view. The main goal is to avoid users to drag and drop text in files drop zones. So now, if a user is dragging a text, we hide the files drop zones. opw-4366605 closes odoo/odoo#195506 X-original-commit: 92e83eba213f7ed01dce18ea583a5bf79516ce59 Related: odoo/enterprise#78037 Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com> Signed-off-by: Igor Bertrand (igbe) <igbe@odoo.com>
-rw-r--r--addons/account/static/src/views/account_dashboard_kanban/account_dashboard_kanban_renderer.js5
-rw-r--r--addons/account/static/src/views/file_upload_kanban/file_upload_kanban_renderer.js6
-rw-r--r--addons/account/static/src/views/file_upload_kanban/file_upload_kanban_renderer.xml2
-rw-r--r--addons/account/static/src/views/file_upload_list/file_upload_list_renderer.js5
-rw-r--r--addons/account/static/src/views/file_upload_list/file_upload_list_renderer.xml2
5 files changed, 16 insertions, 4 deletions
diff --git a/addons/account/static/src/views/account_dashboard_kanban/account_dashboard_kanban_renderer.js b/addons/account/static/src/views/account_dashboard_kanban/account_dashboard_kanban_renderer.js
index 470172aa7ff..9d02b879c4a 100644
--- a/addons/account/static/src/views/account_dashboard_kanban/account_dashboard_kanban_renderer.js
+++ b/addons/account/static/src/views/account_dashboard_kanban/account_dashboard_kanban_renderer.js
@@ -19,13 +19,14 @@ export class DashboardKanbanRenderer extends KanbanRenderer {
}
kanbanDragEnter(e) {
- this.env.dashboardState.isDragging = true;
+ this.setDragging(e.dataTransfer.types.includes("Files"));
}
kanbanDragLeave(e) {
const mouseX = e.clientX, mouseY = e.clientY;
const {x, y, width, height} = this.rootRef.el.getBoundingClientRect();
- if (!(mouseX > x && mouseX <= x + width && mouseY > y && mouseY <= y + height)) {
+ const mouseInsideKanbanRenderer = mouseX > x && mouseX <= x + width && mouseY > y && mouseY <= y + height;
+ if (!mouseInsideKanbanRenderer || !e.dataTransfer.types.includes("Files")) {
// if the mouse position is outside the kanban renderer, all cards should hide their dropzones.
this.setDragging(false);
} else {
diff --git a/addons/account/static/src/views/file_upload_kanban/file_upload_kanban_renderer.js b/addons/account/static/src/views/file_upload_kanban/file_upload_kanban_renderer.js
index 5422b7e099c..8f525c947ac 100644
--- a/addons/account/static/src/views/file_upload_kanban/file_upload_kanban_renderer.js
+++ b/addons/account/static/src/views/file_upload_kanban/file_upload_kanban_renderer.js
@@ -23,4 +23,10 @@ export class FileUploadKanbanRenderer extends KanbanRenderer {
ev.preventDefault();
this.uploadFileFromData(ev.clipboardData);
}
+
+ onDragStart(ev) {
+ if (ev.dataTransfer.types.includes("Files")) {
+ this.dropzoneState.visible = true;
+ }
+ }
}
diff --git a/addons/account/static/src/views/file_upload_kanban/file_upload_kanban_renderer.xml b/addons/account/static/src/views/file_upload_kanban/file_upload_kanban_renderer.xml
index d662be687f6..01120b015cc 100644
--- a/addons/account/static/src/views/file_upload_kanban/file_upload_kanban_renderer.xml
+++ b/addons/account/static/src/views/file_upload_kanban/file_upload_kanban_renderer.xml
@@ -7,7 +7,7 @@
hideZone="() => dropzoneState.visible = false"/>
</xpath>
<xpath expr="//div[@t-ref='root']" position="attributes">
- <attribute name="t-on-dragenter.stop.prevent">() => dropzoneState.visible = true</attribute>
+ <attribute name="t-on-dragenter.stop.prevent">onDragStart</attribute>
<attribute name="t-on-paste">onPaste</attribute>
</xpath>
</t>
diff --git a/addons/account/static/src/views/file_upload_list/file_upload_list_renderer.js b/addons/account/static/src/views/file_upload_list/file_upload_list_renderer.js
index 0591e59cedc..58e220c9022 100644
--- a/addons/account/static/src/views/file_upload_list/file_upload_list_renderer.js
+++ b/addons/account/static/src/views/file_upload_list/file_upload_list_renderer.js
@@ -24,4 +24,9 @@ export class FileUploadListRenderer extends ListRenderer {
this.uploadFileFromData(ev.clipboardData);
}
+ onDragStart(ev) {
+ if (ev.dataTransfer.types.includes("Files")) {
+ this.dropzoneState.visible = true;
+ }
+ }
}
diff --git a/addons/account/static/src/views/file_upload_list/file_upload_list_renderer.xml b/addons/account/static/src/views/file_upload_list/file_upload_list_renderer.xml
index a87ebe131c5..1ca34cb4404 100644
--- a/addons/account/static/src/views/file_upload_list/file_upload_list_renderer.xml
+++ b/addons/account/static/src/views/file_upload_list/file_upload_list_renderer.xml
@@ -7,7 +7,7 @@
hideZone="() => dropzoneState.visible = false"/>
</xpath>
<xpath expr="//div[@t-ref='root']" position="attributes">
- <attribute name="t-on-dragenter.stop.prevent">() => dropzoneState.visible = true</attribute>
+ <attribute name="t-on-dragenter.stop.prevent">onDragStart</attribute>
<attribute name="t-on-paste">onPaste</attribute>
</xpath>
</t>