diff --git a/addons/web/static/src/js/widgets/ribbon.js b/addons/web/static/src/js/widgets/ribbon.js new file mode 100644 index 00000000000..719b98e21b6 --- /dev/null +++ b/addons/web/static/src/js/widgets/ribbon.js @@ -0,0 +1,35 @@ +odoo.define('web.ribbon', function (require) { + 'use strict'; + + /** + * This widget adds a ribbon on the top right side of the form + * + * - You can specify the text with the text attribute. + * - You can specify a background color for the ribbon with the bg_color attribute + * using bootstrap classes : + * (bg-primary, bg-secondary, bg-success, bg-danger, bg-warning, bg-info, + * bg-light, bg-dark, bg-white) + * + * If you don't specify the bg_color attribute the bg-success class will be used + * by default. + */ + + var widgetRegistry = require('web.widget_registry'); + var Widget = require('web.Widget'); + + var RibbonWidget = Widget.extend({ + template: 'web.ribbon', + xmlDependencies: ['/web/static/src/xml/ribbon.xml'], + + init: function (parent, data, options) { + this._super.apply(this, arguments); + this.text = options.attrs.text; + this.bgColor = options.attrs.bg_color; + } + + }); + + widgetRegistry.add('web_ribbon', RibbonWidget); + + return RibbonWidget; +}); \ No newline at end of file diff --git a/addons/web/static/src/xml/ribbon.xml b/addons/web/static/src/xml/ribbon.xml new file mode 100644 index 00000000000..f8d3efdbb72 --- /dev/null +++ b/addons/web/static/src/xml/ribbon.xml @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml index 82464dc9dba..fc805284ffc 100644 --- a/addons/web/views/webclient_templates.xml +++ b/addons/web/views/webclient_templates.xml @@ -273,6 +273,7 @@ +