← Back to team overview

openerp-community team mailing list archive

[Merge] lp:~openerp-community/openerp-web/web_color into lp:openerp-web/6.1

 

Étienne Beaudry Auger has proposed merging lp:~openerp-community/openerp-web/web_color into lp:openerp-web/6.1.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-community/openerp-web/web_color/+merge/130606

[ADD] web_color module to use with widget="color"
-- 
https://code.launchpad.net/~openerp-community/openerp-web/web_color/+merge/130606
Your team OpenERP Community is subscribed to branch lp:~openerp-community/openerp-web/web_color.
=== modified file 'addons/web/static/src/js/formats.js'
--- addons/web/static/src/js/formats.js	2012-07-03 14:02:51 +0000
+++ addons/web/static/src/js/formats.js	2012-10-19 16:38:22 +0000
@@ -338,6 +338,12 @@
         });
     case 'progressbar': 
         return QWeb.render('ListView.ProgressBar', {value: _.str.sprintf("%.0f", row_data[column.id].value || 0)})
+    
+    case 'color':
+        console.log(row_data[column.id].value)
+        return _.template('<div style="background-color: <%-data%>"><%-data%></div>', {
+            data: row_data[column.id].value
+        });
     }
 
     return _.escape(openerp.web.format_value(

=== added directory 'addons/web_color'
=== added file 'addons/web_color/__init__.py'
=== added file 'addons/web_color/__openerp__.py'
--- addons/web_color/__openerp__.py	1970-01-01 00:00:00 +0000
+++ addons/web_color/__openerp__.py	2012-10-19 16:38:22 +0000
@@ -0,0 +1,11 @@
+{
+    "name": "web color",
+    "category" : "Hidden",
+    "description":'Show color in view',
+    "version": "1.0",
+    "depends": ['web'],
+    "js": ['static/src/js/lib.js'],
+    "css": ['static/src/css/*.css'],
+    'qweb' : ['static/src/xml/lib.xml'],
+    "auto_install": True
+}

=== added directory 'addons/web_color/static'
=== added directory 'addons/web_color/static/lib'
=== added directory 'addons/web_color/static/src'
=== added directory 'addons/web_color/static/src/css'
=== added directory 'addons/web_color/static/src/js'
=== added file 'addons/web_color/static/src/js/lib.js'
--- addons/web_color/static/src/js/lib.js	1970-01-01 00:00:00 +0000
+++ addons/web_color/static/src/js/lib.js	2012-10-19 16:38:22 +0000
@@ -0,0 +1,88 @@
+
+openerp.web_color = function(instance) {
+    var _t = openerp.web._t;
+    var QWeb = openerp.web.qweb;
+    
+    instance.web.form.widgets.add('color', 'openerp.web_color');
+    /*instance.web_color = instance.web.format_cell.extend({
+        init: function() {
+            //console.log(parent);
+            //this._super(parent);
+        }
+    });*/
+  /*  instance.web_color = instance.web.form.Widget.extend({
+        template: 'FieldCharColor',
+        init: function(view, node) {
+            console.log(view);
+            this._super(view, node);
+            this.renderElement();
+        },
+        start: function() {
+            this._super();
+            //this.$element.find('.')
+            console.log(this.$element);
+            this.$element.find('.oe-field-cell[data-field="color"]').each(function(){
+             var color = $(this).val();
+             console.log(color);
+             $(this).class('background-color', color);
+             });
+            //this.draw_color(element));
+            //fields.earch()
+            //console.log('set_value');
+            //console.log(this.$element);
+            //console.log(QWeb.render('FieldCharColor', {hexa:"#AA"}));
+            //console.log(arguments);
+        },
+        draw_color: function(element){
+          var color = element.val();
+          element.class('backgroundColor', color);
+        }
+    });*/
+}
+
+
+/*
+var FieldColor = openerp.base.Widget.extend({
+    // QWeb template to use when rendering the object
+    template: "FieldCharColor",
+
+    init: function(parent) {
+        this._super(parent);
+        // insert code to execute before rendering, for object
+        // initialization
+    },
+    start: function() {
+        this._super();
+        // post-rendering initialization code, at this point
+        // ``this.$element`` has been initialized
+        //this.$element.find(".my_button").click(*/
+/* an example of event binding * /);
+        aloert('w00t!');
+         // if ``start`` is asynchronous, return a promise object so callers
+         // know when the object is done initializing
+         //return this.rpc(*/
+/* … *//*
+)
+    }
+});
+*/
+
+//var color_instance = new FieldColor(this);
+//color_instance.appendTo(".oe-field-cell[data-field='color'']");
+/*
+openerp.web.web_color = function(openerp) {
+
+    openerp.web.page.FieldCharReadonly = openerp.web.page.FieldReadonly.extend({
+        template: "FieldChar.color",
+        init: function(view, node){
+            this._super(view, node);
+        },
+        start: function(view, node) {
+            this._super.apply(this, arguments);
+            this.$element.find('div').color({
+                value: this.value;
+                disabled: this.readonly;
+            });
+        }
+    });
+}*/

=== added directory 'addons/web_color/static/src/xml'
=== added file 'addons/web_color/static/src/xml/lib.xml'
--- addons/web_color/static/src/xml/lib.xml	1970-01-01 00:00:00 +0000
+++ addons/web_color/static/src/xml/lib.xml	2012-10-19 16:38:22 +0000
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates id="template" xml:space="preserve">
+	<t t-name="FieldCharColor">
+        <div t-att-style="'background-color : ' + hexa + ';'"></div>
+	</t>
+</templates>
\ No newline at end of file