mirror of https://github.com/OCA/web.git
[MIG] web_environment_ribbon
parent
6a40699aa2
commit
dd9d985eb2
|
@ -1,6 +1,8 @@
|
||||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||||
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
:alt: License: AGPL-3
|
:alt: License: AGPL-3
|
||||||
|
|
||||||
|
======================
|
||||||
Web Environment Ribbon
|
Web Environment Ribbon
|
||||||
======================
|
======================
|
||||||
|
|
||||||
|
@ -30,14 +32,17 @@ Usage
|
||||||
To use this module, you need only to install it. After installation, a red
|
To use this module, you need only to install it. After installation, a red
|
||||||
ribbon will be visible on top left corner of every Odoo backend page
|
ribbon will be visible on top left corner of every Odoo backend page
|
||||||
|
|
||||||
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||||
|
:alt: Try me on Runbot
|
||||||
|
:target: https://runbot.odoo-community.org/runbot/162/9.0
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
|
Bugs are tracked on `GitHub Issues
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
<https://github.com/OCA/web/issues>`_. In case of trouble, please
|
||||||
If you spotted it first, help us smashing it by providing a detailed and
|
check there if your issue has already been reported. If you spotted it first,
|
||||||
welcomed feedback
|
help us smashing it by providing a detailed and welcomed feedback.
|
||||||
`here <https://github.com/OCA/web/issues/new?body=module:%20web_environment_ribbon%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
=======
|
=======
|
||||||
|
@ -47,6 +52,7 @@ Contributors
|
||||||
|
|
||||||
* Francesco Apruzzese <cescoap@gmail.com>
|
* Francesco Apruzzese <cescoap@gmail.com>
|
||||||
* Javi Melendez <javimelex@gmail.com>
|
* Javi Melendez <javimelex@gmail.com>
|
||||||
|
* Antonio Espinosa <antonio.espinosa@tecnativa.com>
|
||||||
|
|
||||||
Maintainer
|
Maintainer
|
||||||
----------
|
----------
|
||||||
|
@ -61,4 +67,4 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.
|
promote its widespread use.
|
||||||
|
|
||||||
To contribute to this module, please visit http://odoo-community.org.
|
To contribute to this module, please visit https://odoo-community.org.
|
||||||
|
|
|
@ -1,20 +1,4 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com>
|
||||||
#
|
# Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com>
|
||||||
# Copyright (C) 2015 Francesco OpenCode Apruzzese (<cescoap@gmail.com>)
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
# All Rights Reserved
|
|
||||||
#
|
|
||||||
# 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/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
|
@ -1,29 +1,15 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com>
|
||||||
#
|
# Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com>
|
||||||
# Copyright (C) 2015 Francesco OpenCode Apruzzese (<cescoap@gmail.com>)
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
# All Rights Reserved
|
|
||||||
#
|
|
||||||
# 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/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': "Web Environment Ribbon",
|
'name': "Web Environment Ribbon",
|
||||||
'version': '8.0.1.0.0',
|
'version': '9.0.1.0.0',
|
||||||
'category': 'Web',
|
'category': 'Web',
|
||||||
'author': 'Francesco OpenCode Apruzzese,Odoo Community Association (OCA)',
|
'author': 'Francesco OpenCode Apruzzese, '
|
||||||
|
'Tecnativa, '
|
||||||
|
'Odoo Community Association (OCA)',
|
||||||
'website': 'https://it.linkedin.com/in/francescoapruzzese',
|
'website': 'https://it.linkedin.com/in/francescoapruzzese',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
"depends": [
|
"depends": [
|
||||||
|
@ -36,5 +22,5 @@
|
||||||
"update_xml": [],
|
"update_xml": [],
|
||||||
"demo_xml": [],
|
"demo_xml": [],
|
||||||
"auto_install": False,
|
"auto_install": False,
|
||||||
'installable': False
|
"installable": True
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<openerp>
|
<!-- Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com>
|
||||||
<data noupdate="1">
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||||
|
<odoo noupdate="1">
|
||||||
|
|
||||||
<!-- Add ribbon name default configuration parameter -->
|
<!-- Add ribbon name default configuration parameter -->
|
||||||
<record id="default_ribbon_name" model="ir.config_parameter">
|
<record id="default_ribbon_name" model="ir.config_parameter">
|
||||||
<field name="key">ribbon.name</field>
|
<field name="key">ribbon.name</field>
|
||||||
<field name="value">TEST</field>
|
<field name="value">TEST</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Add ribbon color configuration parameter -->
|
<!-- Add ribbon color configuration parameter -->
|
||||||
<record id="set_ribbon_color" model="ir.config_parameter">
|
<record id="set_ribbon_color" model="ir.config_parameter">
|
||||||
<field name="key">ribbon.color</field>
|
<field name="key">ribbon.color</field>
|
||||||
<field name="value">#f0f0f0</field>
|
<field name="value">#f0f0f0</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Add ribbon background color configuration parameter -->
|
<!-- Add ribbon background color configuration parameter -->
|
||||||
<record id="set_ribbon_background_color" model="ir.config_parameter">
|
<record id="set_ribbon_background_color" model="ir.config_parameter">
|
||||||
<field name="key">ribbon.background.color</field>
|
<field name="key">ribbon.background.color</field>
|
||||||
<field name="value">rgba(255,0,0,.6)</field>
|
<field name="value">rgba(255,0,0,.6)</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
</odoo>
|
||||||
</openerp>
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
/* Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com>
|
||||||
|
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||||
|
|
||||||
.test-ribbon{
|
.test-ribbon{
|
||||||
width: 200px;
|
width: 200px;
|
||||||
top: 50px;
|
top: 50px;
|
||||||
|
|
|
@ -1,59 +1,19 @@
|
||||||
/******************************************************************************
|
/* Copyright 2015 Sylvain Calador <sylvain.calador@akretion.com>
|
||||||
Copyright (C) 2015 Akretion (http://www.akretion.com)
|
Copyright 2015 Javi Melendez <javi.melendez@algios.com>
|
||||||
@author Sylvain Calador <sylvain.calador@akretion.com>
|
Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com>
|
||||||
|
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||||
|
|
||||||
Copyright (C) 2016 Algi Open Source Solutions (http://www.algios.com)
|
odoo.define('web_environment_ribbon.ribbon', function(require) {
|
||||||
@author Javi Melendez <javi.melendez@algios.com>
|
"use strict";
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
var $ = require('$');
|
||||||
it under the terms of the GNU Affero General Public License as
|
var Model = require('web.Model');
|
||||||
published by the Free Software Foundation, either version 3 of the
|
var core = require('web.core');
|
||||||
License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
var model = new Model('ir.config_parameter');
|
||||||
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
|
// Code from: http://jsfiddle.net/WK_of_Angmar/xgA5C/
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
function validStrColour(strToTest) {
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
openerp.web_environment_ribbon = function(instance) {
|
|
||||||
|
|
||||||
var ribbon = $(document).find('.test-ribbon');
|
|
||||||
ribbon.hide();
|
|
||||||
|
|
||||||
var model = new instance.web.Model('ir.config_parameter');
|
|
||||||
|
|
||||||
var res = model.call('get_param', ['ribbon.name']).then(
|
|
||||||
function (name) {
|
|
||||||
if (name && name != 'False') {
|
|
||||||
ribbon.html(name);
|
|
||||||
ribbon.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get ribbon color from system parameters
|
|
||||||
var res = model.call('get_param', ['ribbon.color']).then(
|
|
||||||
function (strColor) {
|
|
||||||
if (strColor && validStrColour(strColor)) {
|
|
||||||
ribbon.css('color', strColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get ribbon background color from system parameters
|
|
||||||
var res = model.call('get_param', ['ribbon.background.color']).then(
|
|
||||||
function (strBackgroundColor) {
|
|
||||||
if (strBackgroundColor && validStrColour(strBackgroundColor)) {
|
|
||||||
ribbon.css('background-color', strBackgroundColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
// Code from: http://jsfiddle.net/WK_of_Angmar/xgA5C/
|
|
||||||
function validStrColour(strToTest) {
|
|
||||||
if (strToTest === "") { return false; }
|
if (strToTest === "") { return false; }
|
||||||
if (strToTest === "inherit") { return true; }
|
if (strToTest === "inherit") { return true; }
|
||||||
if (strToTest === "transparent") { return true; }
|
if (strToTest === "transparent") { return true; }
|
||||||
|
@ -64,5 +24,38 @@ openerp.web_environment_ribbon = function(instance) {
|
||||||
image.style.color = "rgb(255, 255, 255)";
|
image.style.color = "rgb(255, 255, 255)";
|
||||||
image.style.color = strToTest;
|
image.style.color = strToTest;
|
||||||
return image.style.color !== "rgb(255, 255, 255)";
|
return image.style.color !== "rgb(255, 255, 255)";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
core.bus.on('web_client_ready', null, function () {
|
||||||
|
var ribbon = $('.test-ribbon');
|
||||||
|
// If ribbon is found in DOM
|
||||||
|
if (ribbon.length) {
|
||||||
|
ribbon.hide();
|
||||||
|
model.call('get_param', ['ribbon.name']).then(
|
||||||
|
function (name) {
|
||||||
|
if (name && name != 'False') {
|
||||||
|
ribbon.html(name);
|
||||||
|
ribbon.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
// Get ribbon color from system parameters
|
||||||
|
model.call('get_param', ['ribbon.color']).then(
|
||||||
|
function (strColor) {
|
||||||
|
if (strColor && validStrColour(strColor)) {
|
||||||
|
ribbon.css('color', strColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
// Get ribbon background color from system parameters
|
||||||
|
model.call('get_param', ['ribbon.background.color']).then(
|
||||||
|
function (strBackgroundColor) {
|
||||||
|
if (strBackgroundColor && validStrColour(strBackgroundColor)) {
|
||||||
|
ribbon.css('background-color', strBackgroundColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}); // odoo.define
|
||||||
|
|
|
@ -1,21 +1,26 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<openerp>
|
<!-- Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com>
|
||||||
<data>
|
Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com>
|
||||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||||
|
<odoo>
|
||||||
|
|
||||||
<!-- Load css for ribbons -->
|
<!-- Load css for ribbons -->
|
||||||
<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"
|
||||||
<script type="text/javascript" src="/web_environment_ribbon/static/src/js/ribbon.js"/>
|
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"
|
||||||
<xpath expr="//div[@class='openerp openerp_webclient_container']" position="before">
|
inherit_id="web.webclient_bootstrap">
|
||||||
|
<xpath expr="//div[@class='openerp openerp_webclient_container oe_webclient']" position="before">
|
||||||
<div class="test-ribbon"/>
|
<div class="test-ribbon"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</data>
|
</odoo>
|
||||||
</openerp>
|
|
||||||
|
|
Loading…
Reference in New Issue