diff options
| author | Aaron Bohy <aab@odoo.com> | 2018-03-28 11:37:48 +0200 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2018-04-03 15:19:42 +0200 |
| commit | 409e7c18c3186ffdac78c109b762edd040bb1805 (patch) | |
| tree | 1ffbb9803db02077b3a24920dc18c474355e66fc /addons/web/static/src | |
| parent | 69c9500e355be8ae605294c9f0453e91e4b73a2e (diff) | |
[REF] FormRenderer: renderOuterGroup
This rev. extracts the part of the rendering that renders outer
groups (i.e. groups that contain groups) in its own function. This
allows extentions of the FormRenderer to use it (for instance, the
renderer of the new Dashboard view).
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/form/form_renderer.js | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/addons/web/static/src/js/views/form/form_renderer.js b/addons/web/static/src/js/views/form/form_renderer.js index f6430d4a251..61576832ff5 100644 --- a/addons/web/static/src/js/views/form/form_renderer.js +++ b/addons/web/static/src/js/views/form/form_renderer.js @@ -503,6 +503,32 @@ var FormRenderer = BasicRenderer.extend({ return this._renderGenericTag(node); }, /** + * Renders a 'group' node, which contains 'group' nodes in its children. + * + * @param {Object} node] + * @returns {JQueryElement} + */ + _renderOuterGroup: function (node) { + var self = this; + var $result = $('<div/>', {class: 'o_group'}); + var colSize = Math.max(1, Math.round(12 / (parseInt(node.attrs.col, 10) || 2))); + if (node.attrs.string) { + var $sep = $('<div/>', {class: 'o_horizontal_separator'}).text(node.attrs.string); + $result.append($sep); + } + $result.append(_.map(node.children, function (child) { + if (child.tag === 'newline') { + return $('<br/>'); + } + var $child = self._renderNode(child); + $child.addClass('o_group_col_' + (colSize * (parseInt(child.attrs.colspan, 10) || 1))); + return $child; + })); + this._handleAttributes($result, node); + this._registerModifiers(node, this.state, $result); + return $result; + }, + /** * @private * @param {Object} node * @returns {jQueryElement} @@ -603,31 +629,13 @@ var FormRenderer = BasicRenderer.extend({ * @returns {jQueryElement} */ _renderTagGroup: function (node) { - var self = this; var isOuterGroup = _.some(node.children, function (child) { return child.tag === 'group'; }); if (!isOuterGroup) { return this._renderInnerGroup(node); } - - var $result = $('<div/>', {class: 'o_group'}); - var colSize = Math.max(1, Math.round(12 / (parseInt(node.attrs.col, 10) || 2))); - if (node.attrs.string) { - var $sep = $('<div/>', {class: 'o_horizontal_separator'}).text(node.attrs.string); - $result.append($sep); - } - $result.append(_.map(node.children, function (child) { - if (child.tag === 'newline') { - return $('<br/>'); - } - var $child = self._renderNode(child); - $child.addClass('o_group_col_' + (colSize * (parseInt(child.attrs.colspan, 10) || 1))); - return $child; - })); - this._handleAttributes($result, node); - this._registerModifiers(node, this.state, $result); - return $result; + return this._renderOuterGroup(node); }, /** * @private |
