Yannick Vaucher
7 years ago
9 changed files with 258 additions and 20 deletions
-
29web_notify/README.rst
-
5web_notify/__manifest__.py
-
26web_notify/models/res_users.py
-
5web_notify/static/src/css/notification.less
-
57web_notify/static/src/js/notification.js
-
59web_notify/static/src/js/web_client.js
-
38web_notify/static/src/xml/notification.xml
-
57web_notify/tests/test_res_users.py
-
2web_notify/views/web_notify.xml
@ -0,0 +1,5 @@ |
|||||
|
.o_notification { |
||||
|
.o_notification_action { |
||||
|
padding: 10px; |
||||
|
} |
||||
|
} |
@ -0,0 +1,57 @@ |
|||||
|
/* Copyright 2018 Camptocamp |
||||
|
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
|
||||
|
odoo.define('web_notify.notification', function (require) { |
||||
|
"use strict"; |
||||
|
|
||||
|
var base_notification = require('web.notification'), |
||||
|
WebClient = require('web.WebClient'), |
||||
|
Notification = base_notification.Notification; |
||||
|
|
||||
|
var InteractiveNotification = Notification.extend({ |
||||
|
template: 'InteractiveNotification', |
||||
|
events: _.extend( |
||||
|
{}, |
||||
|
Notification.prototype.events, |
||||
|
{'click .o_notification_reload_view': function(e){ |
||||
|
e.preventDefault(); |
||||
|
this.reload_active_view(); |
||||
|
}, |
||||
|
'click .o_notification_do_action': function(e){ |
||||
|
e.preventDefault(); |
||||
|
this.button_do_action(); |
||||
|
} |
||||
|
} |
||||
|
), |
||||
|
init: function(parent, title, text, options) { |
||||
|
this.options = options || {}; |
||||
|
var sticky = this.options.sticky; |
||||
|
this._super.apply(this, [parent, title, text, sticky]); |
||||
|
}, |
||||
|
reload_active_view: function() { |
||||
|
this.trigger_up('reload_active_view'); |
||||
|
}, |
||||
|
button_do_action: function() { |
||||
|
this.getParent().do_action(this.options.action); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
var InteractiveWarning = InteractiveNotification.extend({ |
||||
|
template: 'InteractiveWarning', |
||||
|
}); |
||||
|
|
||||
|
base_notification.NotificationManager.include({ |
||||
|
interactive_notify(title, text, options) { |
||||
|
return this.display(new InteractiveNotification(this, title, text, options)); |
||||
|
}, |
||||
|
interactive_warn(title, text, options) { |
||||
|
return this.display(new InteractiveWarning(this, title, text, options)); |
||||
|
} |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
return { |
||||
|
InteractiveNotification: InteractiveNotification, |
||||
|
InteractiveWarning: InteractiveWarning |
||||
|
}; |
||||
|
|
||||
|
}); |
@ -0,0 +1,38 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<templates id="template" xml:space="preserve"> |
||||
|
|
||||
|
<t t-name="Notification.reload"> |
||||
|
<div class="o_notification_action" t-if="widget.options.show_reload"> |
||||
|
<a href="#" class="o_notification_reload_view"> |
||||
|
<span class="fa fa-refresh"/> Reload current view |
||||
|
</a> |
||||
|
</div> |
||||
|
</t> |
||||
|
|
||||
|
<t t-name="Notification.do_action"> |
||||
|
<div class="o_notification_action" t-if="widget.options.action"> |
||||
|
<a href="#" class="o_notification_do_action"> |
||||
|
<span t-att-class="'fa ' + (widget.options.action_fa_icon ? widget.options.action_fa_icon : 'fa-arrow-circle-left')"/> |
||||
|
<t t-if="widget.options.action_link_name"> |
||||
|
<t t-esc="widget.options.action_link_name"/> |
||||
|
</t> |
||||
|
<t t-else="">Open</t> |
||||
|
</a> |
||||
|
</div> |
||||
|
</t> |
||||
|
|
||||
|
<t t-name="InteractiveNotification" t-extend="Notification"> |
||||
|
<t t-jquery=".o_notification_content" t-operation="after"> |
||||
|
<t t-call="Notification.reload"/> |
||||
|
<t t-call="Notification.do_action"/> |
||||
|
</t> |
||||
|
</t> |
||||
|
|
||||
|
<t t-name="InteractiveWarning" t-extend="Warning"> |
||||
|
<t t-jquery=".o_notification_content" t-operation="after"> |
||||
|
<t t-call="Notification.reload"/> |
||||
|
<t t-call="Notification.do_action"/> |
||||
|
</t> |
||||
|
</t> |
||||
|
|
||||
|
</templates> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue