Browse Source

[MIG] web_environment_ribbon: Migration to 11.0

pull/1071/head
xavierjimenez 7 years ago
committed by Dennis Sluijk
parent
commit
4f6c813c10
  1. 15
      web_environment_ribbon/README.rst
  2. 1
      web_environment_ribbon/__init__.py
  3. 6
      web_environment_ribbon/__manifest__.py
  4. 1
      web_environment_ribbon/models/web_environment_ribbon_backend.py
  5. 85
      web_environment_ribbon/static/src/js/ribbon.js

15
web_environment_ribbon/README.rst

@ -1,5 +1,5 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3 :alt: License: AGPL-3
====================== ======================
@ -8,14 +8,6 @@ Web Environment Ribbon
Mark a Test Environment with a red ribbon on the top left corner in every page Mark a Test Environment with a red ribbon on the top left corner in every page
.. image:: /web_environment_ribbon/static/description/screenshot.png
:alt: Screenshot
Installation
============
No special setup
Configuration Configuration
============= =============
@ -36,7 +28,7 @@ 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 .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/162/10.0
:target: https://runbot.odoo-community.org/runbot/162/11.0
Bug Tracker Bug Tracker
=========== ===========
@ -56,6 +48,7 @@ Contributors
* Javi Melendez <javimelex@gmail.com> * Javi Melendez <javimelex@gmail.com>
* Antonio Espinosa <antonio.espinosa@tecnativa.com> * Antonio Espinosa <antonio.espinosa@tecnativa.com>
* Thomas Binsfeld <thomas.binsfeld@acsone.eu> * Thomas Binsfeld <thomas.binsfeld@acsone.eu>
* Xavier Jiménez <xavier.jimenez@qubiq.es>
Maintainer Maintainer
---------- ----------

1
web_environment_ribbon/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com> # Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com>
# Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com> # Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2017 Thomas Binsfeld <thomas.binsfeld@acsone.eu> # Copyright 2017 Thomas Binsfeld <thomas.binsfeld@acsone.eu>

6
web_environment_ribbon/__manifest__.py

@ -1,17 +1,17 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com> # Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com>
# Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com> # Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2017 Thomas Binsfeld <thomas.binsfeld@acsone.eu> # Copyright 2017 Thomas Binsfeld <thomas.binsfeld@acsone.eu>
# Copyright 2017 Xavier Jiménez <xavier.jimenez@qubiq.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
'name': "Web Environment Ribbon", 'name': "Web Environment Ribbon",
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'category': 'Web', 'category': 'Web',
'author': 'Francesco OpenCode Apruzzese, ' 'author': 'Francesco OpenCode Apruzzese, '
'Tecnativa, ' 'Tecnativa, '
'Odoo Community Association (OCA)', 'Odoo Community Association (OCA)',
'website': 'https://it.linkedin.com/in/francescoapruzzese',
'website': 'https://github.com/OCA/web',
'license': 'AGPL-3', 'license': 'AGPL-3',
"depends": [ "depends": [
'web', 'web',

1
web_environment_ribbon/models/web_environment_ribbon_backend.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 ACSONE SA/NV # Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

85
web_environment_ribbon/static/src/js/ribbon.js

@ -2,53 +2,54 @@
Copyright 2015 Javi Melendez <javi.melendez@algios.com> Copyright 2015 Javi Melendez <javi.melendez@algios.com>
Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com> Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com>
Copyright 2017 Thomas Binsfeld <thomas.binsfeld@acsone.eu> Copyright 2017 Thomas Binsfeld <thomas.binsfeld@acsone.eu>
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
Copyright 2017 Xavier Jiménez <xavier.jimenez@qubiq.es>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
odoo.define('web_environment_ribbon.ribbon', function(require) { odoo.define('web_environment_ribbon.ribbon', function(require) {
"use strict"; "use strict";
var $ = require('jquery');
var Model = require('web.Model');
var core = require('web.core');
var $ = require('jquery');
var rpc = require('web.rpc');
var core = require('web.core');
var backend_model = new Model('web.environment.ribbon.backend');
// Code from: http://jsfiddle.net/WK_of_Angmar/xgA5C/
function validStrColour(strToTest) {
if (strToTest === "") { return false; }
if (strToTest === "inherit") { return true; }
if (strToTest === "transparent") { return true; }
var image = document.createElement("img");
image.style.color = "rgb(0, 0, 0)";
image.style.color = strToTest;
if (image.style.color !== "rgb(0, 0, 0)") { return true; }
image.style.color = "rgb(255, 255, 255)";
image.style.color = strToTest;
return image.style.color !== "rgb(255, 255, 255)";
}
// Code from: http://jsfiddle.net/WK_of_Angmar/xgA5C/
function validStrColour(strToTest) {
if (strToTest === "") { return false; }
if (strToTest === "inherit") { return true; }
if (strToTest === "transparent") { return true; }
var image = document.createElement("img");
image.style.color = "rgb(0, 0, 0)";
image.style.color = strToTest;
if (image.style.color !== "rgb(0, 0, 0)") { return true; }
image.style.color = "rgb(255, 255, 255)";
image.style.color = strToTest;
return image.style.color !== "rgb(255, 255, 255)";
}
core.bus.on('web_client_ready', null, function () {
var ribbon = $('<div class="test-ribbon"/>');
$('body').append(ribbon);
ribbon.hide();
// Get ribbon data from backend
backend_model.call('get_environment_ribbon').then(
function (ribbon_data) {
// Ribbon name
if (ribbon_data.name && ribbon_data.name != 'False') {
ribbon.html(ribbon_data.name);
ribbon.show();
}
// Ribbon color
if (ribbon_data.color && validStrColour(ribbon_data.color)) {
ribbon.css('color', ribbon_data.color);
core.bus.on('web_client_ready', null, function () {
var ribbon = $('<div class="test-ribbon"/>');
$('body').append(ribbon);
ribbon.hide();
// Get ribbon data from backend
rpc.query({
model: 'web.environment.ribbon.backend',
method: 'get_environment_ribbon',
}).then(
function (ribbon_data) {
// Ribbon name
if (ribbon_data.name && ribbon_data.name != 'False') {
ribbon.html(ribbon_data.name);
ribbon.show();
}
// Ribbon color
if (ribbon_data.color && validStrColour(ribbon_data.color)) {
ribbon.css('color', ribbon_data.color);
}
// Ribbon background color
if (ribbon_data.background_color && validStrColour(ribbon_data.background_color)) {
ribbon.css('background-color', ribbon_data.background_color);
}
} }
// Ribbon background color
if (ribbon_data.background_color && validStrColour(ribbon_data.background_color)) {
ribbon.css('background-color', ribbon_data.background_color);
}
}
);
});
);
});
}); // odoo.define }); // odoo.define
Loading…
Cancel
Save