diff options
Diffstat (limited to 'addons/web_editor/static/src')
| -rw-r--r-- | addons/web_editor/static/src/js/snippets.editor.js | 15 | ||||
| -rw-r--r-- | addons/web_editor/static/src/less/web_editor.ui.less | 15 |
2 files changed, 29 insertions, 1 deletions
diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js index e11e3205815..d0b6394ecd9 100644 --- a/addons/web_editor/static/src/js/snippets.editor.js +++ b/addons/web_editor/static/src/js/snippets.editor.js @@ -251,12 +251,25 @@ data.Class = Widget.extend({ $div.find('.oe_snippet_thumbnail_img').css('background-image', 'url(' + thumbnail + ')'); } // end + + var moduleID = $snippet.data('moduleId'); + if (moduleID) { + $snippet.addClass('o_snippet_install'); + var $installBtn = $('<a/>', { + class: 'btn btn-primary btn-sm o_install_btn', + target: '_blank', + href: '/web#id=' + moduleID + '&view_type=form&model=ir.module.module&action=base.open_module_tree', + text: _t("Install"), + }); + $div.append($installBtn); + } } if (!$snippet.data("selector")) { $("> *:not(.oe_snippet_thumbnail)", this).addClass('oe_snippet_body'); } number++; - }); + }) + .not('[data-module-id]'); // hide scroll if no snippets defined if (!number) { diff --git a/addons/web_editor/static/src/less/web_editor.ui.less b/addons/web_editor/static/src/less/web_editor.ui.less index 4f1eb7dc4be..f83a73984c4 100644 --- a/addons/web_editor/static/src/less/web_editor.ui.less +++ b/addons/web_editor/static/src/less/web_editor.ui.less @@ -86,6 +86,8 @@ html[lang] > body.editor_enable [data-oe-translation-state] { // SNIPPET PANEL #oe_snippets { + .o-w-preserve-btn(); + .o-flex-display(); .o-flex-flow(column, nowrap); .o-position-absolute(0, auto, 0, -@o-we-sidebar-width); @@ -173,6 +175,19 @@ html[lang] > body.editor_enable [data-oe-translation-state] { } } + &.o_snippet_install { + .oe_snippet_thumbnail_img { + opacity: 0.5; + } + .btn.o_install_btn { + display: none; + .o-position-absolute(16px, 4px, auto, 4px); + } + &:hover .btn.o_install_btn { + display: block; + } + } + &:nth-child(2n+1) { clear: left; } |
