[FIX] website: published/unpublished button + useless code

For some strange reason, two CSS rules had different priorities between
firefox and chrome (which forced chrome to always display published and
unpublished at the same time).

The chosen solution is to change the value of the button in published/
unpublished instead of toggling and relying on CSS classes (with this
method, the DOM looks better too).

There was also duplicated code in website for assets_backend.
This commit is contained in:
qsm-odoo
2015-09-15 13:17:43 +02:00
parent 2337f074bc
commit f22686fb4d
6 changed files with 19 additions and 28 deletions
-1
View File
@@ -19,7 +19,6 @@ OpenERP Website CMS
'security/ir.model.access.csv',
'security/ir_ui_view.xml',
'views/website_templates.xml',
'views/website.backend.xml',
'views/website_views.xml',
'views/snippets.xml',
'views/res_config.xml',
@@ -1,6 +0,0 @@
.oe_button_box .oe_stat_button .o_stat_info:not(.published) > .o_stat_text.oe_publish {
display: none;
}
.oe_button_box .oe_stat_button .o_stat_info.published > .o_stat_text.oe_unpublish {
display: none;
}
@@ -3,15 +3,28 @@ odoo.define('website.backend', function (require) {
var core = require('web.core');
var form_common = require('web.form_common');
var form_widgets = require('web.form_widgets'); // required to guarantee that
// the overrride of fieldtexthtml works
var form_widgets = require('web.form_widgets'); // required to guarantee
// that the overrride of fieldtexthtml works
var _t = core._t;
var WidgetWebsiteButton = form_common.AbstractField.extend({
template: 'WidgetWebsiteButton',
render_value: function() {
this._super();
this.$el.toggleClass("published", this.get_value() === true);
if (this.node.attrs.class) {
this._super.apply(this, arguments);
var $value = this.$('.o_value');
if(this.get_value() === true) {
$value.html(_t('Published'))
.removeClass('text-danger')
.addClass('text-success');
} else {
$value.html(_t('Not Published'))
.removeClass('text-success')
.addClass('text-danger');
}
if(this.node.attrs.class) {
this.$el.addClass(this.node.attrs.class);
}
},
@@ -1,10 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<div t-name="WidgetWebsiteButton" class="o_stat_info published">
<span class="o_stat_text oe_unpublish text-danger">Not Published</span>
<span class="o_stat_text oe_publish text-success">Published</span>
<span class="o_stat_text o_value"/>
<span class="o_stat_text">On Website</span>
</div>
</templates>
-11
View File
@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<template id="assets_backend" name="website assets for backend" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/website/static/src/css/website.backend.css"/>
<script type="text/javascript" src="/website/static/src/js/website.backend.js"></script>
</xpath>
</template>
</openerp>
@@ -26,7 +26,6 @@
<template id="assets_backend" name="website assets for backend" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/website/static/src/css/website.backend.css"/>
<script type="text/javascript" src="/website/static/src/js/website.backend.js"></script>
</xpath>
</template>