From 5854bb7d12ebae359dc1bef20c966c9f0e8d983e Mon Sep 17 00:00:00 2001 From: Khoi Nguyen Date: Thu, 6 Jul 2017 10:43:00 +0200 Subject: [PATCH] [IMP] web: Add disableDrop option to dragAndDrop In some situations, it would be desirable to be able to attempt a drag and drop, without actually triggering the dropping action. As an example, we would like to see whether dragging a new field in studio ensures that a class 'o_web_studio_nearest_hook' be assigned. This can only be tested *before* the new field is dropped. This commit adds an optional argument 'disableDrop' to the dragAndDrop method, and sets it by default to false. The dropping action will then only be triggered if the aforementioned parameter is set to false. --- addons/web/static/tests/helpers/test_utils.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/addons/web/static/tests/helpers/test_utils.js b/addons/web/static/tests/helpers/test_utils.js index bc2cf05f360..fafe2dee1c6 100644 --- a/addons/web/static/tests/helpers/test_utils.js +++ b/addons/web/static/tests/helpers/test_utils.js @@ -369,6 +369,7 @@ function createModel(params) { * @param {jqueryElement} $to * @param {Object} [options] * @param {string} [options.position=center] target position + * @param {string} [options.disableDrop=false] whether to trigger the drop action */ function dragAndDrop($el, $to, options) { var position = (options && options.position) || 'center'; @@ -396,11 +397,13 @@ function dragAndDrop($el, $to, options) { pageY: toOffset.top })); - $el.trigger($.Event("mouseup", { - which: 1, - pageX: toOffset.left, - pageY: toOffset.top - })); + if (!(options && options.disableDrop)) { + $el.trigger($.Event("mouseup", { + which: 1, + pageX: toOffset.left, + pageY: toOffset.top + })); + } } /**