diff options
| author | Julien Mougenot <jum@odoo.com> | 2020-03-11 09:38:28 +0000 |
|---|---|---|
| committer | Julien Mougenot <jum@odoo.com> | 2020-03-13 14:08:33 +0000 |
| commit | 18e5416636b19b0953b1e6e26bfaeab1ebecce4c (patch) | |
| tree | 5be75af26f1707a5b8b2184545719f3628d2980f /addons/web/static/src/js/views/search_panel.js | |
| parent | fbf347498f1cc7b74ef373179b7bcae201715c24 (diff) | |
[REF] web: Adapt views/actions to new control panel
Some web actions/controllers/viewsl have been adapted to properly instantiate the
newly refactored control panel and update it accordingly. We needed to adapt the
starting mechanism of actions and controllers to ensure that the control panel
instantiation did not delay the loading of any widget.
Part of task 2196029
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/views/search_panel.js')
| -rw-r--r-- | addons/web/static/src/js/views/search_panel.js | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/addons/web/static/src/js/views/search_panel.js b/addons/web/static/src/js/views/search_panel.js index 4f8c42325db..590d52e4941 100644 --- a/addons/web/static/src/js/views/search_panel.js +++ b/addons/web/static/src/js/views/search_panel.js @@ -165,27 +165,26 @@ var SearchPanel = Widget.extend({ * @params {string} viewType the type of the current view (e.g. 'kanban') * @returns {Object|undefined} */ - computeSearchPanelParams: function (viewInfo, viewType) { + computeSearchPanelParams: function (arch, fields, viewType) { var searchPanelSections; var classes; - if (viewInfo) { - var arch = viewUtils.parseArch(viewInfo.arch); + if (arch && fields) { viewType = viewType === 'list' ? 'tree' : viewType; - arch.children.forEach(function (node) { - if (node.tag === 'searchpanel') { - var attrs = node.attrs; - var viewTypes = defaultViewTypes; - if (attrs.view_types) { - viewTypes = attrs.view_types.split(','); - } - if (attrs.class) { - classes = attrs.class.split(' '); - } - if (viewTypes.indexOf(viewType) !== -1) { - searchPanelSections = _processSearchPanelNode(node, viewInfo.fields); - } + arch = viewUtils.parseArch(arch); + const searchPanelNode = arch.children.find(child => child.tag === 'searchpanel'); + if (searchPanelNode) { + var attrs = searchPanelNode.attrs; + var viewTypes = defaultViewTypes; + if (attrs.view_types) { + viewTypes = attrs.view_types.split(','); } - }); + if (attrs.class) { + classes = attrs.class.split(' '); + } + if (viewTypes.includes(viewType)) { + searchPanelSections = _processSearchPanelNode(searchPanelNode, fields); + } + } } return { sections: searchPanelSections, |
