Browse Source

Merge pull request #230 from akretion/8.0-conditional-ribbon

[IMP] web_environment_ribbon: conditional ribbon
pull/251/head
Pedro M. Baeza 9 years ago
parent
commit
0867977fe6
  1. 8
      web_environment_ribbon/README.rst
  2. 1
      web_environment_ribbon/__openerp__.py
  3. 12
      web_environment_ribbon/data/ribbon_data.xml
  4. 35
      web_environment_ribbon/static/src/js/ribbon.js
  5. 4
      web_environment_ribbon/view/base_view.xml

8
web_environment_ribbon/README.rst

@ -17,7 +17,11 @@ Installation
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
=====
@ -30,7 +34,7 @@ Known issues / Roadmap
======================
* Allow to define in some place (system parameter, configuration file...) the
text for the ribbon and the ribbon color.
ribbon color.
Bug Tracker
===========

1
web_environment_ribbon/__openerp__.py

@ -31,6 +31,7 @@
],
"data": [
'view/base_view.xml',
'data/ribbon_data.xml',
],
"update_xml": [],
"demo_xml": [],

12
web_environment_ribbon/data/ribbon_data.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>

35
web_environment_ribbon/static/src/js/ribbon.js

@ -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();
}
}
);
}

4
web_environment_ribbon/view/base_view.xml

@ -6,16 +6,16 @@
<template id="assets_backend" name="ribbon_test assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<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>
</template>
<!-- Add ribbon to page -->
<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">
<div class="test-ribbon"><b>TEST</b></div>
<div class="test-ribbon"/>
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save