mirror of https://github.com/OCA/web.git
Merge pull request #230 from akretion/8.0-conditional-ribbon
[IMP] web_environment_ribbon: conditional ribbonpull/250/head
commit
0867977fe6
|
@ -17,7 +17,11 @@ Installation
|
||||||
Configuration
|
Configuration
|
||||||
=============
|
=============
|
||||||
|
|
||||||
* No special setup
|
* You can change the ribbon's name ("TEST") by editing
|
||||||
|
the default system parameter "ribbon.name"
|
||||||
|
(in the menu Settings > Parameters > System Parameters)
|
||||||
|
To hide the ribbon, set this parameter to "False" or
|
||||||
|
delete it.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
=====
|
=====
|
||||||
|
@ -30,7 +34,7 @@ Known issues / Roadmap
|
||||||
======================
|
======================
|
||||||
|
|
||||||
* Allow to define in some place (system parameter, configuration file...) the
|
* Allow to define in some place (system parameter, configuration file...) the
|
||||||
text for the ribbon and the ribbon color.
|
ribbon color.
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
],
|
],
|
||||||
"data": [
|
"data": [
|
||||||
'view/base_view.xml',
|
'view/base_view.xml',
|
||||||
|
'data/ribbon_data.xml',
|
||||||
],
|
],
|
||||||
"update_xml": [],
|
"update_xml": [],
|
||||||
"demo_xml": [],
|
"demo_xml": [],
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data noupdate="1">
|
||||||
|
|
||||||
|
<!-- Add ribbon name default configuration parameter -->
|
||||||
|
<record id="default_ribbon_name" model="ir.config_parameter">
|
||||||
|
<field name="key">ribbon.name</field>
|
||||||
|
<field name="value">TEST</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
|
@ -0,0 +1,35 @@
|
||||||
|
/******************************************************************************
|
||||||
|
Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||||
|
@author Sylvain Calador <sylvain.calador@akretion.com>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
openerp.web_environment_ribbon = function(instance) {
|
||||||
|
|
||||||
|
var ribbon = $(document).find('.test-ribbon');
|
||||||
|
ribbon.hide();
|
||||||
|
|
||||||
|
var model = new instance.web.Model('ir.config_parameter');
|
||||||
|
var key = 'ribbon.name';
|
||||||
|
|
||||||
|
var res = model.call('get_param', [key]).then(
|
||||||
|
function (name) {
|
||||||
|
if (name && name != 'False') {
|
||||||
|
ribbon.html(name);
|
||||||
|
ribbon.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
|
@ -6,16 +6,16 @@
|
||||||
<template id="assets_backend" name="ribbon_test assets" inherit_id="web.assets_backend">
|
<template id="assets_backend" name="ribbon_test assets" inherit_id="web.assets_backend">
|
||||||
<xpath expr="." position="inside">
|
<xpath expr="." position="inside">
|
||||||
<link rel="stylesheet" href="/web_environment_ribbon/static/src/css/ribbon.css"/>
|
<link rel="stylesheet" href="/web_environment_ribbon/static/src/css/ribbon.css"/>
|
||||||
|
<script type="text/javascript" src="/web_environment_ribbon/static/src/js/ribbon.js"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- Add ribbon to page -->
|
<!-- Add ribbon to page -->
|
||||||
<template id="body_with_ribbon_test" name="ribbon_test web.webclient_bootstrap" inherit_id="web.webclient_bootstrap">
|
<template id="body_with_ribbon_test" name="ribbon_test web.webclient_bootstrap" inherit_id="web.webclient_bootstrap">
|
||||||
<xpath expr="//div[@class='openerp openerp_webclient_container']" position="before">
|
<xpath expr="//div[@class='openerp openerp_webclient_container']" position="before">
|
||||||
<div class="test-ribbon"><b>TEST</b></div>
|
<div class="test-ribbon"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|
Loading…
Reference in New Issue