summaryrefslogtreecommitdiff
path: root/addons/web/static/src/xml
diff options
context:
space:
mode:
authorJulien Mougenot <jum@odoo.com>2019-11-22 11:36:52 +0000
committerJulien Mougenot <jum@odoo.com>2020-01-06 14:37:16 +0000
commit34bbdd88c0bc354b76b254bb78c4eb786f3d08c0 (patch)
treebb5b17494f521fb9a4a50869d32040273d1d5d47 /addons/web/static/src/xml
parentab37648cb1c3a4ab7db23e3a8cdef87008d5d1e0 (diff)
[ADD] web: Owl Dialog
New Owl component: Dialog. It does not rely on Bootstrap but behaves the same and does not conflict with legacy dialogs. To call this component, you need to define it in the XML parent template instead of calling it in the JS file, and put a flag in the parent state to toggle the dialog. Old dialog file has also been slightly updated to ensure compatibility between both versions. This commit also updates a list view test which did not wait for click events to properly trigger and would cause the new dialog system to crash.
Diffstat (limited to 'addons/web/static/src/xml')
-rw-r--r--addons/web/static/src/xml/base.xml48
-rw-r--r--addons/web/static/src/xml/dialog.xml28
2 files changed, 66 insertions, 10 deletions
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index a3fdb09611c..961c11cdc90 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -1,6 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
+<!-- Owl Templates -->
+
+<t t-name="DialogButton.tooltip" owl="1">
+ <div class="oe_tooltip_string" role="tooltip">
+ <div class="tooltip-inner">
+ Hit ENTER to <t t-esc="title"/>
+ </div>
+ </div>
+</t>
+
+<t t-name="OwlDialog" owl="1">
+ <Portal target="'body'">
+ <div class="o_dialog" t-on-focus="_onFocus">
+ <div t-if="props.backdrop" class="modal-backdrop show" t-on-click="_onBackdropClick"/>
+ <div role="dialog" class="modal"
+ tabindex="-1"
+ t-att-class="{ o_technical_modal: props.technical, o_modal_full: props.fullscreen }"
+ t-ref="modal"
+ t-on-close_dialog.stop="_close"
+ >
+ <div class="modal-dialog" t-att-class="size">
+ <div class="modal-content" t-att-class="props.contentClass">
+ <header t-if="props.renderHeader" class="modal-header">
+ <h4 class="modal-title">
+ <t t-esc="props.title"/>
+ <span t-if="props.subtitle" class="o_subtitle text-muted small" t-esc="props.subtitle"/>
+ </h4>
+ <button type="button" class="close" aria-label="Close" tabindex="-1" t-on-click="_close">×</button>
+ </header>
+ <main class="modal-body">
+ <t t-slot="default"/>
+ </main>
+ <footer t-if="props.renderFooter" class="modal-footer" t-ref="modal-footer">
+ <t t-slot="buttons">
+ <button class="btn btn-primary" t-on-click.prevent="_close">
+ Ok
+ </button>
+ </t>
+ </footer>
+ </div>
+ </div>
+ </div>
+ </div>
+ </Portal>
+</t>
+
+<!-- Legacy Templates -->
+
<div t-name="EmptyComponent"/>
<div t-name="Loading" class="o_loading"/>
diff --git a/addons/web/static/src/xml/dialog.xml b/addons/web/static/src/xml/dialog.xml
index 645e6e2391e..848f5a1e9b6 100644
--- a/addons/web/static/src/xml/dialog.xml
+++ b/addons/web/static/src/xml/dialog.xml
@@ -3,17 +3,25 @@
<!-- These templates are accessible in backend and frontend -->
-<div role="dialog" t-name="Dialog" t-attf-class="modal#{technical ? ' o_technical_modal' : ''}#{fullscreen ? ' o_modal_full': ''}" tabindex="-1" data-backdrop="static" t-att-id="_.uniqueId('modal_')" aria-hidden="true">
- <div class="modal-dialog">
- <div class="modal-content">
- <header t-if="renderHeader" class="modal-header">
- <h4 class="modal-title"><t t-raw="title"/><span class="o_subtitle text-muted small"><t t-esc="subtitle"/></span></h4>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close" tabindex="-1">×</button>
- </header>
- <main class="modal-body"/>
- <footer t-if="renderFooter" class="modal-footer"/>
+<t t-name="Dialog">
+ <div role="dialog"
+ t-attf-class="modal o_legacy_dialog #{ technical ? ' o_technical_modal' : '' } #{ fullscreen ? ' o_modal_full': '' }"
+ tabindex="-1"
+ data-backdrop="static"
+ t-att-id="_.uniqueId('modal_')"
+ aria-hidden="true"
+ >
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <header t-if="renderHeader" class="modal-header">
+ <h4 class="modal-title"><t t-raw="title"/><span class="o_subtitle text-muted small" t-esc="subtitle"/></h4>
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close" tabindex="-1">×</button>
+ </header>
+ <main class="modal-body"/>
+ <footer t-if="renderFooter" class="modal-footer"/>
+ </div>
</div>
</div>
-</div>
+</t>
</templates>