[IMP] website(_blog/_slides): show a toaster when a record is published

This commit shows a toaster when publishing a record through the toggle in the
topbar.
The `_description` field is used to do that, as it is supposed to contains a
'business oriented' descriptive name, see task-37311. Indeed, this field is
used in studio and in mail templates.

task-2144335
This commit is contained in:
Romain Derie
2020-02-03 15:25:20 +00:00
committed by Jeremy Kersten
parent 9725e61969
commit d92f76592c
5 changed files with 12 additions and 5 deletions
@@ -161,6 +161,13 @@ var WebsiteRoot = publicRootData.PublicRoot.extend({
$data.toggleClass("css_unpublished css_published");
$data.find('input').prop("checked", result);
$data.parents("[data-publish]").attr("data-publish", +result ? 'on' : 'off');
if (result) {
self.displayNotification({
type: 'success',
title: _t("Congratulation"),
message: _t("You've published your ") + $data.data('description'),
});
}
})
.guardedCatch(function (err, data) {
data = data || {statusText: err.message.message};
@@ -63,7 +63,7 @@
</ul>
<ul class="o_menu_systray d-none d-md-block" groups="website.group_website_publisher">
<li t-if="'website_published' in main_object.fields_get() and ('can_publish' not in main_object.fields_get() or main_object.can_publish)" t-attf-class="js_publish_management #{main_object.website_published and 'css_published' or 'css_unpublished'}" t-att-data-id="main_object.id" t-att-data-object="main_object._name" t-att-data-controller="publish_controller">
<li t-if="'website_published' in main_object.fields_get() and ('can_publish' not in main_object.fields_get() or main_object.can_publish)" t-attf-class="js_publish_management #{main_object.website_published and 'css_published' or 'css_unpublished'}" t-att-data-id="main_object.id" t-att-data-object="main_object._name" t-att-data-description="env['ir.model']._get(main_object._name).display_name" t-att-data-controller="publish_controller">
<label class="o_switch o_switch_danger js_publish_btn" for="id">
<input type="checkbox" t-att-checked="main_object.website_published" id="id"/>
<span/>
+1 -1
View File
@@ -13,7 +13,7 @@ from odoo.tools import html2plaintext
class Blog(models.Model):
_name = 'blog.blog'
_description = 'Blogs'
_description = 'Blog'
_inherit = ['mail.thread', 'website.seo.metadata', 'website.multi.mixin']
_order = 'name'
@@ -6,7 +6,7 @@ from odoo import fields, models
class SlideChannelTagGroup(models.Model):
_name = 'slide.channel.tag.group'
_description = 'Channel/Course tags'
_description = 'Channel/Course Tag'
_inherit = 'website.published.mixin'
_order = 'sequence asc'
@@ -20,7 +20,7 @@ class SlideChannelTagGroup(models.Model):
class SlideChannelTag(models.Model):
_name = 'slide.channel.tag'
_description = 'Channel/Course tags'
_description = 'Channel/Course Tag'
_order = 'group_sequence asc, sequence asc'
name = fields.Char('Name', required=True, translate=True)
@@ -49,7 +49,7 @@ class SlideQuestion(models.Model):
class SlideAnswer(models.Model):
_name = "slide.answer"
_rec_name = "text_value"
_description = "Answer for a slide question"
_description = "Slide Question's Answer"
_order = 'question_id, sequence'
sequence = fields.Integer("Sequence")