summaryrefslogtreecommitdiff
path: root/addons/web/static
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2016-09-30 17:23:30 +0200
committerChristophe Simonis <chs@odoo.com>2016-09-30 17:23:30 +0200
commitc8cc54559b75a621e4444ecdca6abd901b45e494 (patch)
tree92141325d4dbbf70bbfb8e0c040d4435c8d2378f /addons/web/static
parentb2804b1d2ae5fd7ec5c0eca79a8db77476badc84 (diff)
parent91a14488250bc2bb405cc6d300359aa272642484 (diff)
[MERGE] forward port branch 10.0 up to 91a1448
Diffstat (limited to 'addons/web/static')
-rw-r--r--addons/web/static/lib/jquery.mjs.nestedSortable/jquery.mjs.nestedSortable.js854
-rw-r--r--addons/web/static/src/js/abstract_web_client.js16
-rw-r--r--addons/web/static/src/js/action_manager.js25
-rw-r--r--addons/web/static/src/js/framework/data_manager.js47
-rw-r--r--addons/web/static/src/js/framework/dialog.js2
-rw-r--r--addons/web/static/src/js/views/form_relational_widgets.js2
-rw-r--r--addons/web/static/src/js/widgets/debug_manager.js27
-rw-r--r--addons/web/static/src/js/widgets/systray_menu.js7
-rw-r--r--addons/web/static/src/less/webclient_layout.less1
9 files changed, 765 insertions, 216 deletions
diff --git a/addons/web/static/lib/jquery.mjs.nestedSortable/jquery.mjs.nestedSortable.js b/addons/web/static/lib/jquery.mjs.nestedSortable/jquery.mjs.nestedSortable.js
index e6c0d62453a..bdde6b9d399 100644
--- a/addons/web/static/lib/jquery.mjs.nestedSortable/jquery.mjs.nestedSortable.js
+++ b/addons/web/static/lib/jquery.mjs.nestedSortable/jquery.mjs.nestedSortable.js
@@ -1,50 +1,139 @@
/*
* jQuery UI Nested Sortable
- * v 1.3.5 / 21 jun 2012
- * http://mjsarfatti.com/code/nestedSortable
+ * v 2.1a / 2016-02-04
+ * https://github.com/ilikenwf/nestedSortable
*
* Depends on:
- * jquery.ui.sortable.js 1.8+
+ * jquery.ui.sortable.js 1.10+
*
- * Copyright (c) 2010-2012 Manuele J Sarfatti
+ * Copyright (c) 2010-2016 Manuele J Sarfatti and contributors
* Licensed under the MIT License
* http://www.opensource.org/licenses/mit-license.php
*/
+(function( factory ) {
+ "use strict";
-(function($) {
+ if ( typeof define === "function" && define.amd ) {
+
+ // AMD. Register as an anonymous module.
+ define([
+ "jquery",
+ "jquery-ui/sortable"
+ ], factory );
+ } else {
+
+ // Browser globals
+ factory( window.jQuery );
+ }
+}(function($) {
+ "use strict";
+
+ function isOverAxis( x, reference, size ) {
+ return ( x > reference ) && ( x < ( reference + size ) );
+ }
$.widget("mjs.nestedSortable", $.extend({}, $.ui.sortable.prototype, {
options: {
- tabSize: 20,
- disableNesting: 'mjs-nestedSortable-no-nesting',
- errorClass: 'mjs-nestedSortable-error',
+ disableParentChange: false,
doNotClear: false,
- listType: 'ol',
+ expandOnHover: 700,
+ isAllowed: function() { return true; },
+ isTree: false,
+ listType: "ol",
maxLevels: 0,
protectRoot: false,
rootID: null,
rtl: false,
- isAllowed: function(item, parent) { return true; }
+ startCollapsed: false,
+ tabSize: 20,
+
+ branchClass: "mjs-nestedSortable-branch",
+ collapsedClass: "mjs-nestedSortable-collapsed",
+ disableNestingClass: "mjs-nestedSortable-no-nesting",
+ errorClass: "mjs-nestedSortable-error",
+ expandedClass: "mjs-nestedSortable-expanded",
+ hoveringClass: "mjs-nestedSortable-hovering",
+ leafClass: "mjs-nestedSortable-leaf",
+ disabledClass: "mjs-nestedSortable-disabled"
},
_create: function() {
- this.element.data('sortable', this.element.data('nestedSortable'));
+ var self = this,
+ err;
- if (!this.element.is(this.options.listType))
- throw new Error('nestedSortable: Please check the listType option is set to your actual list type');
+ this.element.data("ui-sortable", this.element.data("mjs-nestedSortable"));
- return $.ui.sortable.prototype._create.apply(this, arguments);
+ // mjs - prevent browser from freezing if the HTML is not correct
+ if (!this.element.is(this.options.listType)) {
+ err = "nestedSortable: " +
+ "Please check that the listType option is set to your actual list type";
+
+ throw new Error(err);
+ }
+
+ // if we have a tree with expanding/collapsing functionality,
+ // force 'intersect' tolerance method
+ if (this.options.isTree && this.options.expandOnHover) {
+ this.options.tolerance = "intersect";
+ }
+
+ $.ui.sortable.prototype._create.apply(this, arguments);
+
+ // prepare the tree by applying the right classes
+ // (the CSS is responsible for actual hide/show functionality)
+ if (this.options.isTree) {
+ $(this.items).each(function() {
+ var $li = this.item,
+ hasCollapsedClass = $li.hasClass(self.options.collapsedClass),
+ hasExpandedClass = $li.hasClass(self.options.expandedClass);
+
+ if ($li.children(self.options.listType).length) {
+ $li.addClass(self.options.branchClass);
+ // expand/collapse class only if they have children
+
+ if ( !hasCollapsedClass && !hasExpandedClass ) {
+ if (self.options.startCollapsed) {
+ $li.addClass(self.options.collapsedClass);
+ } else {
+ $li.addClass(self.options.expandedClass);
+ }
+ }
+ } else {
+ $li.addClass(self.options.leafClass);
+ }
+ });
+ }
},
- destroy: function() {
+ _destroy: function() {
this.element
- .removeData("nestedSortable")
- .unbind(".nestedSortable");
- return $.ui.sortable.prototype.destroy.apply(this, arguments);
+ .removeData("mjs-nestedSortable")
+ .removeData("ui-sortable");
+ return $.ui.sortable.prototype._destroy.apply(this, arguments);
},
_mouseDrag: function(event) {
+ var i,
+ item,
+ itemElement,
+ intersection,
+ self = this,
+ o = this.options,
+ scrolled = false,
+ $document = $(document),
+ previousTopOffset,
+ parentItem,
+ level,
+ childLevels,
+ itemAfter,
+ itemBefore,
+ newList,
+ method,
+ a,
+ previousItem,
+ nextItem,
+ helperIsNotSibling;
//Compute the helpers position
this.position = this._generatePosition(event);
@@ -54,72 +143,258 @@
this.lastPositionAbs = this.positionAbs;
}
- var o = this.options;
-
//Do scrolling
- if(this.options.scroll) {
- var scrolled = false;
- if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
-
- if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
- this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
- else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
- this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
+ if (this.options.scroll) {
+ if (this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
+
+ if (
+ (
+ this.overflowOffset.top +
+ this.scrollParent[0].offsetHeight
+ ) -
+ event.pageY <
+ o.scrollSensitivity
+ ) {
+ scrolled = this.scrollParent.scrollTop() + o.scrollSpeed;
+ this.scrollParent.scrollTop(scrolled);
+ } else if (
+ event.pageY -
+ this.overflowOffset.top <
+ o.scrollSensitivity
+ ) {
+ scrolled = this.scrollParent.scrollTop() - o.scrollSpeed;
+ this.scrollParent.scrollTop(scrolled);
+ }
- if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
- this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
- else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
- this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
+ if (
+ (
+ this.overflowOffset.left +
+ this.scrollParent[0].offsetWidth
+ ) -
+ event.pageX <
+ o.scrollSensitivity
+ ) {
+ scrolled = this.scrollParent.scrollLeft() + o.scrollSpeed;
+ this.scrollParent.scrollLeft(scrolled);
+ } else if (
+ event.pageX -
+ this.overflowOffset.left <
+ o.scrollSensitivity
+ ) {
+ scrolled = this.scrollParent.scrollLeft() - o.scrollSpeed;
+ this.scrollParent.scrollLeft(scrolled);
+ }
} else {
- if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
- scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
- else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
- scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
+ if (
+ event.pageY -
+ $document.scrollTop() <
+ o.scrollSensitivity
+ ) {
+ scrolled = $document.scrollTop() - o.scrollSpeed;
+ $document.scrollTop(scrolled);
+ } else if (
+ $(window).height() -
+ (
+ event.pageY -
+ $document.scrollTop()
+ ) <
+ o.scrollSensitivity
+ ) {
+ scrolled = $document.scrollTop() + o.scrollSpeed;
+ $document.scrollTop(scrolled);
+ }
- if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
- scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
- else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
- scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
+ if (
+ event.pageX -
+ $document.scrollLeft() <
+ o.scrollSensitivity
+ ) {
+ scrolled = $document.scrollLeft() - o.scrollSpeed;
+ $document.scrollLeft(scrolled);
+ } else if (
+ $(window).width() -
+ (
+ event.pageX -
+ $document.scrollLeft()
+ ) <
+ o.scrollSensitivity
+ ) {
+ scrolled = $document.scrollLeft() + o.scrollSpeed;
+ $document.scrollLeft(scrolled);
+ }
}
- if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
+ if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
$.ui.ddmanager.prepareOffsets(this, event);
+ }
}
//Regenerate the absolute position used for position checks
this.positionAbs = this._convertPositionTo("absolute");
- // Find the top offset before rearrangement,
- var previousTopOffset = this.placeholder.offset().top;
+ // mjs - find the top offset before rearrangement,
+ previousTopOffset = this.placeholder.offset().top;
//Set the helper position
- if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
- if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
+ if (!this.options.axis || this.options.axis !== "y") {
+ this.helper[0].style.left = this.position.left + "px";
+ }
+ if (!this.options.axis || this.options.axis !== "x") {
+ this.helper[0].style.top = (this.position.top) + "px";
+ }
+
+ // mjs - check and reset hovering state at each cycle
+ this.hovering = this.hovering ? this.hovering : null;
+ this.mouseentered = this.mouseentered ? this.mouseentered : false;
+
+ // mjs - let's start caching some variables
+ (function() {
+ var _parentItem = this.placeholder.parent().parent();
+ if (_parentItem && _parentItem.closest(".ui-sortable").length) {
+ parentItem = _parentItem;
+ }
+ }.call(this));
+
+ level = this._getLevel(this.placeholder);
+ childLevels = this._getChildLevels(this.helper);
+ newList = document.createElement(o.listType);
//Rearrange
- for (var i = this.items.length - 1; i >= 0; i--) {
+ for (i = this.items.length - 1; i >= 0; i--) {
//Cache variables and intersection, continue if no intersection
- var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
- if (!intersection) continue;
-
- if(itemElement != this.currentItem[0] //cannot intersect with itself
- && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
- && !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
- && (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
- //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
+ item = this.items[i];
+ itemElement = item.item[0];
+ intersection = this._intersectsWithPointer(item);
+ if (!intersection) {
+ continue;
+ }
+
+ // Only put the placeholder inside the current Container, skip all
+ // items form other containers. This works because when moving
+ // an item from one container to another the
+ // currentContainer is switched before the placeholder is moved.
+ //
+ // Without this moving items in "sub-sortables" can cause the placeholder to jitter
+ // beetween the outer and inner container.
+ if (item.instance !== this.currentContainer) {
+ continue;
+ }
+
+ // No action if intersected item is disabled
+ // and the element above or below in the direction we're going is also disabled
+ if (itemElement.className.indexOf(o.disabledClass) !== -1) {
+ // Note: intersection hardcoded direction values from
+ // jquery.ui.sortable.js:_intersectsWithPointer
+ if (intersection === 2) {
+ // Going down
+ itemAfter = this.items[i + 1];
+ if (itemAfter && itemAfter.item.hasClass(o.disabledClass)) {
+ continue;
+ }
+
+ } else if (intersection === 1) {
+ // Going up
+ itemBefore = this.items[i - 1];
+ if (itemBefore && itemBefore.item.hasClass(o.disabledClass)) {
+ continue;
+ }
+ }
+ }
+
+ method = intersection === 1 ? "next" : "prev";
+
+ // cannot intersect with itself
+ // no useless actions that have been done before
+ // no action if the item moved is the parent of the item checked
+ if (itemElement !== this.currentItem[0] &&
+ this.placeholder[method]()[0] !== itemElement &&
+ !$.contains(this.placeholder[0], itemElement) &&
+ (
+ this.options.type === "semi-dynamic" ?
+ !$.contains(this.element[0], itemElement) :
+ true
+ )
) {
- $(itemElement).mouseenter();
+ // mjs - we are intersecting an element:
+ // trigger the mouseenter event and store this state
+ if (!this.mouseentered) {
+ $(itemElement).mouseenter();
+ this.mouseentered = true;
+ }
+
+ // mjs - if the element has children and they are hidden,
+ // show them after a delay (CSS responsible)
+ if (o.isTree && $(itemElement).hasClass(o.collapsedClass) && o.expandOnHover) {
+ if (!this.hovering) {
+ $(itemElement).addClass(o.hoveringClass);
+ this.hovering = window.setTimeout(function() {
+ $(itemElement)
+ .removeClass(o.collapsedClass)
+ .addClass(o.expandedClass);
+
+ self.refreshPositions();
+ self._trigger("expand", event, self._uiHash());
+ }, o.expandOnHover);
+ }
+ }
- this.direction = intersection == 1 ? "down" : "up";
+ this.direction = intersection === 1 ? "down" : "up";
- if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
+ // mjs - rearrange the elements and reset timeouts and hovering state
+ if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
$(itemElement).mouseleave();
- this._rearrange(event, item);
+ this.mouseentered = false;
+ $(itemElement).removeClass(o.hoveringClass);
+ if (this.hovering) {
+ window.clearTimeout(this.hovering);
+ }
+ this.hovering = null;
+
+ // mjs - do not switch container if
+ // it's a root item and 'protectRoot' is true
+ // or if it's not a root item but we are trying to make it root
+ if (o.protectRoot &&
+ !(
+ this.currentItem[0].parentNode === this.element[0] &&
+ // it's a root item
+ itemElement.parentNode !== this.element[0]
+ // it's intersecting a non-root item
+ )
+ ) {
+ if (this.currentItem[0].parentNode !== this.element[0] &&
+ itemElement.parentNode === this.element[0]
+ ) {
+
+ if ( !$(itemElement).children(o.listType).length) {
+ itemElement.appendChild(newList);
+ if (o.isTree) {
+ $(itemElement)
+ .removeClass(o.leafClass)
+ .addClass(o.branchClass + " " + o.expandedClass);
+ }
+ }
+
+ if (this.direction === "down") {
+ a = $(itemElement).prev().children(o.listType);
+ } else {
+ a = $(itemElement).children(o.listType);
+ }
+
+ if (a[0] !== undefined) {
+ this._rearrange(event, null, a);
+ }
+
+ } else {
+ this._rearrange(event, item);
+ }
+ } else if (!o.protectRoot) {
+ this._rearrange(event, item);
+ }
} else {
break;
}
@@ -132,17 +407,24 @@
}
}
- var parentItem = (this.placeholder[0].parentNode.parentNode &&
- $(this.placeholder[0].parentNode.parentNode).closest('.ui-sortable').length)
- ? $(this.placeholder[0].parentNode.parentNode)
- : null,
- level = this._getLevel(this.placeholder),
- childLevels = this._getChildLevels(this.helper);
+ // mjs - to find the previous sibling in the list,
+ // keep backtracking until we hit a valid list item.
+ (function() {
+ var _previousItem = this.placeholder.prev();
+ if (_previousItem.length) {
+ previousItem = _previousItem;
+ } else {
+ previousItem = null;
+ }
+ }.call(this));
- // To find the previous sibling in the list, keep backtracking until we hit a valid list item.
- var previousItem = this.placeholder[0].previousSibling ? $(this.placeholder[0].previousSibling) : null;
if (previousItem != null) {
- while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0] || previousItem[0] == this.helper[0]) {
+ while (
+ previousItem[0].nodeName.toLowerCase() !== "li" ||
+ previousItem[0].className.indexOf(o.disabledClass) !== -1 ||
+ previousItem[0] === this.currentItem[0] ||
+ previousItem[0] === this.helper[0]
+ ) {
if (previousItem[0].previousSibling) {
previousItem = $(previousItem[0].previousSibling);
} else {
@@ -152,70 +434,131 @@
}
}
- // To find the next sibling in the list, keep stepping forward until we hit a valid list item.
- var nextItem = this.placeholder[0].nextSibling ? $(this.placeholder[0].nextSibling) : null;
- if (nextItem != null) {
- while (nextItem[0].nodeName.toLowerCase() != 'li' || nextItem[0] == this.currentItem[0] || nextItem[0] == this.helper[0]) {
- if (nextItem[0].nextSibling) {
- nextItem = $(nextItem[0].nextSibling);
- } else {
- nextItem = null;
- break;
- }
- }
- }
-
- var newList = document.createElement(o.listType);
+ // mjs - to find the next sibling in the list,
+ // keep stepping forward until we hit a valid list item.
+ (function() {
+ var _nextItem = this.placeholder.next();
+ if (_nextItem.length) {
+ nextItem = _nextItem;
+ } else {
+ nextItem = null;
+ }
+ }.call(this));
+
+ if (nextItem != null) {
+ while (
+ nextItem[0].nodeName.toLowerCase() !== "li" ||
+ nextItem[0].className.indexOf(o.disabledClass) !== -1 ||
+ nextItem[0] === this.currentItem[0] ||
+ nextItem[0] === this.helper[0]
+ ) {
+ if (nextItem[0].nextSibling) {
+ nextItem = $(nextItem[0].nextSibling);
+ } else {
+ nextItem = null;
+ break;
+ }
+ }
+ }
this.beyondMaxLevels = 0;
-
- // If the item is moved to the left, send it to its parent's level unless there are siblings below it.
- if (parentItem != null && nextItem == null &&
- (o.rtl && (this.positionAbs.left + this.helper.outerWidth() > parentItem.offset().left + parentItem.outerWidth()) ||
- !o.rtl && (this.positionAbs.left < parentItem.offset().left))) {
+
+ // mjs - if the item is moved to the left, send it one level up
+ // but only if it's at the bottom of the list
+ if (parentItem != null &&
+ nextItem == null &&
+ !(o.protectRoot && parentItem[0].parentNode == this.element[0]) &&
+ (
+ o.rtl &&
+ (
+ this.positionAbs.left +
+ this.helper.outerWidth() > parentItem.offset().left +
+ parentItem.outerWidth()
+ ) ||
+ !o.rtl && (this.positionAbs.left < parentItem.offset().left)
+ )
+ ) {
+
parentItem.after(this.placeholder[0]);
- this._clearEmpty(parentItem[0]);
+ helperIsNotSibling = !parentItem
+ .children(o.listItem)
+ .children("li:visible:not(.ui-sortable-helper)")
+ .length;
+ if (o.isTree && helperIsNotSibling) {
+ parentItem
+ .removeClass(this.options.branchClass + " " + this.options.expandedClass)
+ .addClass(this.options.leafClass);
+ }
+ if(typeof parentItem !== 'undefined')
+ this._clearEmpty(parentItem[0]);
this._trigger("change", event, this._uiHash());
- }
- // If the item is below a sibling and is moved to the right, make it a child of that sibling.
- else if (previousItem != null &&
- (o.rtl && (this.positionAbs.left + this.helper.outerWidth() < previousItem.offset().left + previousItem.outerWidth() - o.tabSize) ||
- !o.rtl && (this.positionAbs.left > previousItem.offset().left + o.tabSize))) {
- this._isAllowed(previousItem, level, level+childLevels+1);
+ // mjs - if the item is below a sibling and is moved to the right,
+ // make it a child of that sibling
+ } else if (previousItem != null &&
+ !previousItem.hasClass(o.disableNestingClass) &&
+ (
+ previousItem.children(o.listType).length &&
+ previousItem.children(o.listType).is(":visible") ||
+ !previousItem.children(o.listType).length
+ ) &&
+ !(o.protectRoot && this.currentItem[0].parentNode === this.element[0]) &&
+ (
+ o.rtl &&
+ (
+ this.positionAbs.left +
+ this.helper.outerWidth() <
+ previousItem.offset().left +
+ previousItem.outerWidth() -
+ o.tabSize
+ ) ||
+ !o.rtl &&
+ (this.positionAbs.left > previousItem.offset().left + o.tabSize)
+ )
+ ) {
+
+ this._isAllowed(previousItem, level, level + childLevels + 1);
+
if (!previousItem.children(o.listType).length) {
previousItem[0].appendChild(newList);
+ if (o.isTree) {
+ previousItem
+ .removeClass(o.leafClass)
+ .addClass(o.branchClass + " " + o.expandedClass);
+ }
}
- // If this item is being moved from the top, add it to the top of the list.
- if (previousTopOffset && (previousTopOffset <= previousItem.offset().top)) {
- previousItem.children(o.listType).prepend(this.placeholder);
- }
- // Otherwise, add it to the bottom of the list.
- else {
- previousItem.children(o.listType)[0].appendChild(this.placeholder[0]);
- }
+
+ // mjs - if this item is being moved from the top, add it to the top of the list.
+ if (previousTopOffset && (previousTopOffset <= previousItem.offset().top)) {
+ previousItem.children(o.listType).prepend(this.placeholder);
+ } else {
+ // mjs - otherwise, add it to the bottom of the list.
+ previousItem.children(o.listType)[0].appendChild(this.placeholder[0]);
+ }
+ if(typeof parentItem !== 'undefined')
+ this._clearEmpty(parentItem[0]);
this._trigger("change", event, this._uiHash());
- }
- else {
- this._isAllowed(parentItem, level, level+childLevels);
+ } else {
+ this._isAllowed(parentItem, level, level + childLevels);
}
//Post events to containers
this._contactContainers(event);
//Interconnect with droppables
- if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
+ if ($.ui.ddmanager) {
+ $.ui.ddmanager.drag(this, event);
+ }
//Call callbacks
- this._trigger('sort', event, this._uiHash());
+ this._trigger("sort", event, this._uiHash());
this.lastPositionAbs = this.positionAbs;
return false;
},
- _mouseStop: function(event, noPropagation) {
-
- // If the item is in a position not allowed, send it back
+ _mouseStop: function(event) {
+ // mjs - if the item is in a position not allowed, send it back
if (this.beyondMaxLevels) {
this.placeholder.removeClass(this.options.errorClass);
@@ -230,13 +573,87 @@
}
- // Clean last empty ul/ol
- for (var i = this.items.length - 1; i >= 0; i--) {
- var item = this.items[i].item[0];
- this._clearEmpty(item);
+ // mjs - clear the hovering timeout, just to be sure
+ $("." + this.options.hoveringClass)
+ .mouseleave()
+ .removeClass(this.options.hoveringClass);
+
+ this.mouseentered = false;
+ if (this.hovering) {
+ window.clearTimeout(this.hovering);
+ }
+ this.hovering = null;
+
+ this._relocate_event = event;
+ this._pid_current = $(this.domPosition.parent).parent().attr("id");
+ this._sort_current = this.domPosition.prev ? $(this.domPosition.prev).next().index() : 0;
+ $.ui.sortable.prototype._mouseStop.apply(this, arguments); //asybnchronous execution, @see _clear for the relocate event.
+ },
+
+ // mjs - this function is slightly modified
+ // to make it easier to hover over a collapsed element and have it expand
+ _intersectsWithSides: function(item) {
+
+ var half = this.options.isTree ? .8 : .5,
+ isOverBottomHalf = isOverAxis(
+ this.positionAbs.top + this.offset.click.top,
+ item.top + (item.height * half),
+ item.height
+ ),
+ isOverTopHalf = isOverAxis(
+ this.positionAbs.top + this.offset.click.top,
+ item.top - (item.height * half),
+ item.height
+ ),
+ isOverRightHalf = isOverAxis(
+ this.positionAbs.left + this.offset.click.left,
+ item.left + (item.width / 2),
+ item.width
+ ),
+ verticalDirection = this._getDragVerticalDirection(),
+ horizontalDirection = this._getDragHorizontalDirection();
+
+ if (this.floating && horizontalDirection) {
+ return (
+ (horizontalDirection === "right" && isOverRightHalf) ||
+ (horizontalDirection === "left" && !isOverRightHalf)
+ );
+ } else {
+ return verticalDirection && (
+ (verticalDirection === "down" && isOverBottomHalf) ||
+ (verticalDirection === "up" && isOverTopHalf)
+ );
+ }
+
+ },
+
+ _contactContainers: function() {
+
+ if (this.options.protectRoot && this.currentItem[0].parentNode === this.element[0] ) {
+ return;
+ }
+
+ $.ui.sortable.prototype._contactContainers.apply(this, arguments);
+
+ },
+
+ _clear: function() {
+ var i,
+ item;
+
+ $.ui.sortable.prototype._clear.apply(this, arguments);
+
+ //relocate event
+ if (!(this._pid_current === this._uiHash().item.parent().parent().attr("id") &&
+ this._sort_current === this._uiHash().item.index())) {
+ this._trigger("relocate", this._relocate_event, this._uiHash());
}
- $.ui.sortable.prototype._mouseStop.apply(this, arguments);
+ // mjs - clean last empty ul/ol
+ for (i = this.items.length - 1; i >= 0; i--) {
+ item = this.items[i].item[0];
+ this._clearEmpty(item);
+ }
},
@@ -244,38 +661,42 @@
var o = $.extend({}, this.options, options),
items = this._getItemsAsjQuery(o && o.connected),
- str = [];
+ str = [];
$(items).each(function() {
- var res = ($(o.item || this).attr(o.attribute || 'id') || '')
+ var res = ($(o.item || this).attr(o.attribute || "id") || "")
.match(o.expression || (/(.+)[-=_](.+)/)),
- pid = ($(o.item || this).parent(o.listType)
+ pid = ($(o.item || this).parent(o.listType)
.parent(o.items)
- .attr(o.attribute || 'id') || '')
+ .attr(o.attribute || "id") || "")
.match(o.expression || (/(.+)[-=_](.+)/));
if (res) {
- str.push(((o.key || res[1]) + '[' + (o.key && o.expression ? res[1] : res[2]) + ']')
- + '='
- + (pid ? (o.key && o.expression ? pid[1] : pid[2]) : o.rootID));
+ str.push(
+ (
+ (o.key || res[1]) +
+ "[" +
+ (o.key && o.expression ? res[1] : res[2]) + "]"
+ ) +
+ "=" +
+ (pid ? (o.key && o.expression ? pid[1] : pid[2]) : o.rootID));
}
});
- if(!str.length && o.key) {
- str.push(o.key + '=');
+ if (!str.length && o.key) {
+ str.push(o.key + "=");
}
- return str.join('&');
+ return str.join("&");
},
toHierarchy: function(options) {
var o = $.extend({}, this.options, options),
- sDepth = o.startDepthCount || 0,
- ret = [];
+ ret = [];
- $(this.element).children(o.items).each(function () {
+ $(this.element).children(o.items).each(function() {
var level = _recursiveItems(this);
ret.push(level);
});
@@ -283,9 +704,21 @@
return ret;
function _recursiveItems(item) {
- var id = ($(item).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
+ var id = ($(item).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[-=_](.+)/)),
+ currentItem;
+
+ var data = $(item).data();
+ if (data.nestedSortableItem) {
+ delete data.nestedSortableItem; // Remove the nestedSortableItem object from the data
+ }
+
if (id) {
- var currentItem = {"id" : id[2]};
+ currentItem = {
+ "id": id[2]
+ };
+
+ currentItem = $.extend({}, currentItem, data); // Combine the two objects
+
if ($(item).children(o.listType).children(o.items).length > 0) {
currentItem.children = [];
$(item).children(o.listType).children(o.items).each(function() {
@@ -302,78 +735,109 @@
var o = $.extend({}, this.options, options),
sDepth = o.startDepthCount || 0,
- ret = [],
- left = 2;
-
- ret.push({
- "item_id": o.rootID,
- "parent_id": 'none',
- "depth": sDepth,
- "left": '1',
- "right": ($(o.items, this.element).length + 1) * 2
- });
+ ret = [],
+ left = 1;
+
+ if (!o.excludeRoot) {
+ ret.push({
+ "item_id": o.rootID,
+ "parent_id": null,
+ "depth": sDepth,
+ "left": left,
+ "right": ($(o.items, this.element).length + 1) * 2
+ });
+ left++;
+ }
- $(this.element).children(o.items).each(function () {
- left = _recursiveArray(this, sDepth + 1, left);
+ $(this.element).children(o.items).each(function() {
+ left = _recursiveArray(this, sDepth, left);
});
- ret = ret.sort(function(a,b){ return (a.left - b.left); });
+ ret = ret.sort(function(a, b) { return (a.left - b.left); });
return ret;
- function _recursiveArray(item, depth, left) {
+ function _recursiveArray(item, depth, _left) {
- var right = left + 1,
- id,
- pid;
+ var right = _left + 1,
+ id,
+ pid,
+ parentItem;
if ($(item).children(o.listType).children(o.items).length > 0) {
- depth ++;
- $(item).children(o.listType).children(o.items).each(function () {
+ depth++;
+ $(item).children(o.listType).children(o.items).each(function() {
right = _recursiveArray($(this), depth, right);
});
- depth --;
+ depth--;
}
- id = ($(item).attr(o.attribute || 'id')).match(o.expression || (/(.+)[-=_](.+)/));
+ id = ($(item).attr(o.attribute || "id")).match(o.expression || (/(.+)[-=_](.+)/));
- if (depth === sDepth + 1) {
+ if (depth === sDepth) {
pid = o.rootID;
} else {
- var parentItem = ($(item).parent(o.listType)
- .parent(o.items)
- .attr(o.attribute || 'id'))
- .match(o.expression || (/(.+)[-=_](.+)/));
+ parentItem = ($(item).parent(o.listType)
+ .parent(o.items)
+ .attr(o.attribute || "id"))
+ .match(o.expression || (/(.+)[-=_](.+)/));
pid = parentItem[2];
}
if (id) {
- ret.push({"item_id": id[2], "parent_id": pid, "depth": depth, "left": left, "right": right});
+ var data = $(item).children('div').data();
+ var itemObj = $.extend( data, {
+ "id":id[2],
+ "parent_id":pid,
+ "depth":depth,
+ "left":_left,
+ "right":right
+ } );
+ ret.push( itemObj );
}
- left = right + 1;
- return left;
+ _left = right + 1;
+ return _left;
}
},
- _clearEmpty: function(item) {
+ _clearEmpty: function (item) {
+ function replaceClass(elem, search, replace, swap) {
+ if (swap) {
+ search = [replace, replace = search][0];
+ }
- var emptyList = $(item).children(this.options.listType);
- if (emptyList.length && !emptyList.children().length && !this.options.doNotClear) {
- emptyList.remove();
+ $(elem).removeClass(search).addClass(replace);
}
+ var o = this.options,
+ childrenList = $(item).children(o.listType),
+ hasChildren = childrenList.has('li').length;
+
+ var doNotClear =
+ o.doNotClear ||
+ hasChildren ||
+ o.protectRoot && $(item)[0] === this.element[0];
+
+ if (o.isTree) {
+ replaceClass(item, o.branchClass, o.leafClass, doNotClear);
+ }
+
+ if (!doNotClear) {
+ childrenList.parent().removeClass(o.expandedClass);
+ childrenList.remove();
+ }
},
_getLevel: function(item) {
- var level = 1;
+ var level = 1,
+ list;
if (this.options.listType) {
- var list = item.closest(this.options.listType);
- while (list && list.length > 0 &&
- !list.is('.ui-sortable')) {
+ list = item.closest(this.options.listType);
+ while (list && list.length > 0 && !list.is(".ui-sortable")) {
level++;
list = list.parent().closest(this.options.listType);
}
@@ -384,12 +848,12 @@
_getChildLevels: function(parent, depth) {
var self = this,
- o = this.options,
- result = 0;
+ o = this.options,
+ result = 0;
depth = depth || 0;
- $(parent).children(o.listType).children(o.items).each(function (index, child) {
- result = Math.max(self._getChildLevels(child, depth + 1), result);
+ $(parent).children(o.listType).children(o.items).each(function(index, child) {
+ result = Math.max(self._getChildLevels(child, depth + 1), result);
});
return depth ? result + 1 : result;
@@ -397,23 +861,33 @@
_isAllowed: function(parentItem, level, levels) {
var o = this.options,
- isRoot = $(this.domPosition.parent).hasClass('ui-sortable') ? true : false,
- maxLevels = this.placeholder.closest('.ui-sortable').nestedSortable('option', 'maxLevels'); // this takes into account the maxLevels set to the recipient list
-
- // Is the root protected?
- // Are we trying to nest under a no-nest?
- // Are we nesting too deep?
- if (!o.isAllowed(this.currentItem, parentItem) ||
- parentItem && parentItem.hasClass(o.disableNesting) ||
- o.protectRoot && (parentItem == null && !isRoot || isRoot && level > 1)) {
- this.placeholder.addClass(o.errorClass);
- if (maxLevels < levels && maxLevels != 0) {
- this.beyondMaxLevels = levels - maxLevels;
- } else {
- this.beyondMaxLevels = 1;
- }
+ // this takes into account the maxLevels set to the recipient list
+ maxLevels = this
+ .placeholder
+ .closest(".ui-sortable")
+ .nestedSortable("option", "maxLevels"),
+
+ // Check if the parent has changed to prevent it, when o.disableParentChange is true
+ oldParent = this.currentItem.parent().parent(),
+ disabledByParentchange = o.disableParentChange && (
+ //From somewhere to somewhere else, except the root
+ typeof parentItem !== 'undefined' && !oldParent.is(parentItem) ||
+ typeof parentItem === 'undefined' && oldParent.is("li") //From somewhere to the root
+ );
+ // mjs - is the root protected?
+ // mjs - are we nesting too deep?
+ if (
+ disabledByParentchange ||
+ !o.isAllowed(this.placeholder, parentItem, this.currentItem)
+ ) {
+ this.placeholder.addClass(o.errorClass);
+ if (maxLevels < levels && maxLevels !== 0) {
+ this.beyondMaxLevels = levels - maxLevels;
+ } else {
+ this.beyondMaxLevels = 1;
+ }
} else {
- if (maxLevels < levels && maxLevels != 0) {
+ if (maxLevels < levels && maxLevels !== 0) {
this.placeholder.addClass(o.errorClass);
this.beyondMaxLevels = levels - maxLevels;
} else {
@@ -425,5 +899,9 @@
}));
- $.mjs.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.mjs.nestedSortable.prototype.options);
-})(jQuery);
+ $.mjs.nestedSortable.prototype.options = $.extend(
+ {},
+ $.ui.sortable.prototype.options,
+ $.mjs.nestedSortable.prototype.options
+ );
+})); \ No newline at end of file
diff --git a/addons/web/static/src/js/abstract_web_client.js b/addons/web/static/src/js/abstract_web_client.js
index c3985f4cf5c..115a58a654f 100644
--- a/addons/web/static/src/js/abstract_web_client.js
+++ b/addons/web/static/src/js/abstract_web_client.js
@@ -30,6 +30,19 @@ var WebClient = Widget.extend({
toggle_fullscreen: function (event) {
this.toggle_fullscreen(event.data.fullscreen);
},
+ current_action_updated: function (e) {
+ this.current_action_updated(e.data.action);
+ },
+ perform_rpc: function(event) {
+ if (event.data.on_fail) {
+ event.data.on_fail();
+ }
+ },
+ perform_model_rpc: function(event) {
+ if (event.data.on_fail) {
+ event.data.on_fail();
+ }
+ },
},
init: function(parent) {
this.client_options = {};
@@ -220,6 +233,9 @@ var WebClient = Widget.extend({
this.connection_notification = false;
}
},
+ // Handler to be overwritten
+ current_action_updated: function () {
+ },
// --------------------------------------------------------------
// Scrolltop handling
// --------------------------------------------------------------
diff --git a/addons/web/static/src/js/action_manager.js b/addons/web/static/src/js/action_manager.js
index fe50fb65e90..b6a33e443d1 100644
--- a/addons/web/static/src/js/action_manager.js
+++ b/addons/web/static/src/js/action_manager.js
@@ -93,6 +93,12 @@ var Action = core.Class.extend({
get_fragment: function() {
return this.$fragment;
},
+ /**
+ * @return {string} the active view, i.e. empty for client actions
+ */
+ get_active_view: function() {
+ return '';
+ },
});
/**
* Specialization of Action for client actions that are Widgets
@@ -196,6 +202,12 @@ var ViewManagerAction = WidgetAction.extend({
get_nb_views: function() {
return this.widget.view_stack.length;
},
+ /**
+ * @return {string} the active view of the ViewManager
+ */
+ get_active_view: function() {
+ return this.widget.active_view.type;
+ }
});
var ActionManager = Widget.extend({
@@ -269,11 +281,15 @@ var ActionManager = Widget.extend({
var old_action_stack = this.action_stack;
var old_action = this.inner_action;
var old_widget = this.inner_widget;
+ var actions_to_destroy;
options = options || {};
- // Empty action_stack if requested
+ // Empty action_stack or replace last action if requested
if (options.clear_breadcrumbs) {
+ actions_to_destroy = this.action_stack;
this.action_stack = [];
+ } else if (options.replace_last_action && this.action_stack.length > 0) {
+ actions_to_destroy = [this.action_stack.pop()];
}
// Instantiate the new action
@@ -318,10 +334,11 @@ var ActionManager = Widget.extend({
in_DOM: self.is_in_DOM,
callbacks: [{widget: self.inner_widget}],
});
- if (options.clear_breadcrumbs) {
- self.clear_action_stack(old_action_stack);
+ if (actions_to_destroy) {
+ self.clear_action_stack(actions_to_destroy);
}
self.toggle_fullscreen();
+ self.trigger_up('current_action_updated', {action: new_action});
}).fail(function () {
// Destroy failed action and restore internal state
new_action.destroy();
@@ -404,6 +421,7 @@ var ActionManager = Widget.extend({
callbacks: [{widget: action.widget}],
});
}
+ self.trigger_up('current_action_updated', {action: action});
});
}).fail(function() {
return $.Deferred().reject();
@@ -561,6 +579,7 @@ var ActionManager = Widget.extend({
do_action: function(action, options) {
options = _.defaults(options || {}, {
clear_breadcrumbs: false,
+ replace_last_action: false,
on_reverse_breadcrumb: function() {},
hide_breadcrumb: false,
on_close: function() {},
diff --git a/addons/web/static/src/js/framework/data_manager.js b/addons/web/static/src/js/framework/data_manager.js
index 29d6d585f6a..55a4b4da15b 100644
--- a/addons/web/static/src/js/framework/data_manager.js
+++ b/addons/web/static/src/js/framework/data_manager.js
@@ -6,9 +6,19 @@ var Model = require('web.DataModel');
var session = require('web.session');
var utils = require('web.utils');
+function traverse(tree, f) {
+ if (f(tree)) {
+ _.each(tree.children, function(c) { traverse(c, f); });
+ }
+}
+
return core.Class.extend({
init: function () {
this.Filters = new Model('ir.filters');
+ this._init_cache();
+ },
+
+ _init_cache: function () {
this._cache = {
actions: {},
fields_views: {},
@@ -19,6 +29,14 @@ return core.Class.extend({
},
/**
+ * Invalidates the whole cache
+ * Suggestion: could be refined to invalidate some part of the cache
+ */
+ invalidate: function () {
+ this._init_cache();
+ },
+
+ /**
* Loads an action from its id or xmlid.
*
* @param {int|string} [action_id] the action id or xmlid
@@ -196,19 +214,46 @@ return core.Class.extend({
*/
_postprocess_fvg: function (fields_view) {
var self = this;
+
+ // Parse and process arch
var doc = $.parseXML(fields_view.arch).documentElement;
+ var fields = fields_view.fields;
fields_view.arch = utils.xml_to_json(doc, (doc.nodeName.toLowerCase() !== 'kanban'));
+ traverse(fields_view.arch, function(node) {
+ if (typeof node === 'string') {
+ return false;
+ }
+ if (node.tag === 'field') {
+ fields[node.attrs.name].__attrs = node.attrs;
+ if (fields[node.attrs.name].type === 'many2one') { // FIXME: this shouldn't be done here
+ if (node.attrs.widget === 'statusbar' || node.attrs.widget === 'radio') {
+ fields[node.attrs.name].__fetch_status = true;
+ } else if (node.attrs.widget === 'selection') {
+ fields[node.attrs.name].__fetch_selection = true;
+ }
+ }
+ if (node.attrs.widget === 'many2many_checkboxes') {
+ fields[node.attrs.name].__fetch_many2manys = true;
+ }
+ return false;
+ }
+ return node.tag !== 'arch';
+ });
+
+ // Special case for id's
if ('id' in fields_view.fields) {
- // Special case for id's
var id_field = fields_view.fields.id;
id_field.original_type = id_field.type;
id_field.type = 'id';
}
+
+ // Process inner views (one2manys)
_.each(fields_view.fields, function(field) {
_.each(field.views || {}, function(view) {
self._postprocess_fvg(view);
});
});
+
return fields_view;
},
diff --git a/addons/web/static/src/js/framework/dialog.js b/addons/web/static/src/js/framework/dialog.js
index d527dcf31d8..f23de4f426f 100644
--- a/addons/web/static/src/js/framework/dialog.js
+++ b/addons/web/static/src/js/framework/dialog.js
@@ -69,6 +69,7 @@ var Dialog = Widget.extend({
if(this.$content) {
this.setElement(this.$content);
}
+ this.$el.addClass('modal-body ' + this.dialogClass);
},
set_buttons: function(buttons) {
@@ -118,7 +119,6 @@ var Dialog = Widget.extend({
var self = this;
this.replace(this.$modal.find(".modal-body")).then(function() {
- self.$el.addClass('modal-body ' + self.dialogClass);
self.$modal.modal('show');
self._opened.resolve();
});
diff --git a/addons/web/static/src/js/views/form_relational_widgets.js b/addons/web/static/src/js/views/form_relational_widgets.js
index 4ce7ed6dbf3..dd4c4fb0fb6 100644
--- a/addons/web/static/src/js/views/form_relational_widgets.js
+++ b/addons/web/static/src/js/views/form_relational_widgets.js
@@ -955,7 +955,7 @@ var X2ManyListView = ListView.extend({
field.no_rerender = true;
current_values[field.name] = field.get('value');
});
- var cached_records = _.filter(this.dataset.cache, function(item){return !_.isEmpty(item.values);});
+ var cached_records = _.filter(this.dataset.cache, function(item){return !_.isEmpty(item.values) && !item.to_delete;});
var valid = _.every(cached_records, function(record){
_.each(fields, function(field){
var value = record.values[field.name];
diff --git a/addons/web/static/src/js/widgets/debug_manager.js b/addons/web/static/src/js/widgets/debug_manager.js
index f191eb739ea..f7ddd008e1d 100644
--- a/addons/web/static/src/js/widgets/debug_manager.js
+++ b/addons/web/static/src/js/widgets/debug_manager.js
@@ -48,7 +48,6 @@ var DebugManager = Widget.extend({
}
},
start: function () {
- core.bus.on('current_action_updated', this, this.update.bind(this, 'action'));
core.bus.on('rpc:result', this, function (req, resp) {
this._debug_events(resp.debug);
});
@@ -647,26 +646,12 @@ if (core.debug) {
SystrayMenu.Items.push(DebugManager);
WebClient.include({
- start: function() {
- var self = this;
- return this._super().then(function () {
- // Override push_action and select_action so that it triggers
- // an event each time a new action is pushed.
- // The DebugManager listens to this event to keep itself up-to-date
- var push_action = self.action_manager.push_action;
- self.action_manager.push_action = function(widget, descr) {
- return push_action.apply(self.action_manager, arguments).then(function () {
- core.bus.trigger('current_action_updated', descr, widget);
- });
- };
- var select_action = self.action_manager.select_action;
- self.action_manager.select_action = function() {
- return select_action.apply(self.action_manager, arguments).then(function () {
- var action = self.action_manager.get_inner_action();
- core.bus.trigger('current_action_updated', action.action_descr, action.widget);
- });
- };
- });
+ current_action_updated: function(action) {
+ this._super.apply(this, arguments);
+ var action_descr = action && action.action_descr;
+ var action_widget = action && action.widget;
+ var debug_manager = _.find(this.systray_menu.widgets, function(item) {return item instanceof DebugManager; });
+ debug_manager.update('action', action_descr, action_widget);
},
});
diff --git a/addons/web/static/src/js/widgets/systray_menu.js b/addons/web/static/src/js/widgets/systray_menu.js
index 131954de15f..0d0e18476b0 100644
--- a/addons/web/static/src/js/widgets/systray_menu.js
+++ b/addons/web/static/src/js/widgets/systray_menu.js
@@ -11,6 +11,7 @@ var SystrayMenu = Widget.extend({
init: function(parent) {
this._super(parent);
this.items = [];
+ this.widgets = [];
this.load = $.Deferred();
},
start: function() {
@@ -24,9 +25,13 @@ var SystrayMenu = Widget.extend({
},
load_items: function() {
var self = this;
+ SystrayMenu.Items = _.sortBy(SystrayMenu.Items, function (item) {
+ return !_.isUndefined(item.prototype.sequence) ? item.prototype.sequence : 50;
+ });
_.each(SystrayMenu.Items, function(widgetCls) {
var cur_systray_item = new widgetCls(self);
- self.items.push(cur_systray_item.appendTo(self.$el));
+ self.widgets.push(cur_systray_item);
+ self.items.push(cur_systray_item.prependTo(self.$el));
});
},
});
diff --git a/addons/web/static/src/less/webclient_layout.less b/addons/web/static/src/less/webclient_layout.less
index 3355f4f791f..034f00ad3d9 100644
--- a/addons/web/static/src/less/webclient_layout.less
+++ b/addons/web/static/src/less/webclient_layout.less
@@ -34,6 +34,7 @@
.o-flex(1, 1, auto);
.o-flex-display();
min-height: 0; // Allow flex to shrink this element as much as it wants
+ height: 100%;
.o_sub_menu {
.o-flex(0, 0, @odoo-submenu-width);