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

Proposed by Étienne Beaudry Auger
Status: Needs review
Proposed branch: lp:~openerp-community/openerp-web/web_color
Merge into: lp:openerp-web/6.1
Diff against target: 145 lines (+111/-0)
4 files modified
addons/web/static/src/js/formats.js (+6/-0)
addons/web_color/__openerp__.py (+11/-0)
addons/web_color/static/src/js/lib.js (+88/-0)
addons/web_color/static/src/xml/lib.xml (+6/-0)
To merge this branch: bzr merge lp:~openerp-community/openerp-web/web_color
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+130606@code.launchpad.net

Description of the change

[ADD] web_color module to use with widget="color"

To post a comment you must log in.

Unmerged revisions

2468. By Étienne Beaudry Auger

[IMP] web_color case patch

2467. By Étienne Beaudry Auger

[ADD] web_color module

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web/static/src/js/formats.js'
2--- addons/web/static/src/js/formats.js 2012-07-03 14:02:51 +0000
3+++ addons/web/static/src/js/formats.js 2012-10-19 16:38:22 +0000
4@@ -338,6 +338,12 @@
5 });
6 case 'progressbar':
7 return QWeb.render('ListView.ProgressBar', {value: _.str.sprintf("%.0f", row_data[column.id].value || 0)})
8+
9+ case 'color':
10+ console.log(row_data[column.id].value)
11+ return _.template('<div style="background-color: <%-data%>"><%-data%></div>', {
12+ data: row_data[column.id].value
13+ });
14 }
15
16 return _.escape(openerp.web.format_value(
17
18=== added directory 'addons/web_color'
19=== added file 'addons/web_color/__init__.py'
20=== added file 'addons/web_color/__openerp__.py'
21--- addons/web_color/__openerp__.py 1970-01-01 00:00:00 +0000
22+++ addons/web_color/__openerp__.py 2012-10-19 16:38:22 +0000
23@@ -0,0 +1,11 @@
24+{
25+ "name": "web color",
26+ "category" : "Hidden",
27+ "description":'Show color in view',
28+ "version": "1.0",
29+ "depends": ['web'],
30+ "js": ['static/src/js/lib.js'],
31+ "css": ['static/src/css/*.css'],
32+ 'qweb' : ['static/src/xml/lib.xml'],
33+ "auto_install": True
34+}
35
36=== added directory 'addons/web_color/static'
37=== added directory 'addons/web_color/static/lib'
38=== added directory 'addons/web_color/static/src'
39=== added directory 'addons/web_color/static/src/css'
40=== added directory 'addons/web_color/static/src/js'
41=== added file 'addons/web_color/static/src/js/lib.js'
42--- addons/web_color/static/src/js/lib.js 1970-01-01 00:00:00 +0000
43+++ addons/web_color/static/src/js/lib.js 2012-10-19 16:38:22 +0000
44@@ -0,0 +1,88 @@
45+
46+openerp.web_color = function(instance) {
47+ var _t = openerp.web._t;
48+ var QWeb = openerp.web.qweb;
49+
50+ instance.web.form.widgets.add('color', 'openerp.web_color');
51+ /*instance.web_color = instance.web.format_cell.extend({
52+ init: function() {
53+ //console.log(parent);
54+ //this._super(parent);
55+ }
56+ });*/
57+ /* instance.web_color = instance.web.form.Widget.extend({
58+ template: 'FieldCharColor',
59+ init: function(view, node) {
60+ console.log(view);
61+ this._super(view, node);
62+ this.renderElement();
63+ },
64+ start: function() {
65+ this._super();
66+ //this.$element.find('.')
67+ console.log(this.$element);
68+ this.$element.find('.oe-field-cell[data-field="color"]').each(function(){
69+ var color = $(this).val();
70+ console.log(color);
71+ $(this).class('background-color', color);
72+ });
73+ //this.draw_color(element));
74+ //fields.earch()
75+ //console.log('set_value');
76+ //console.log(this.$element);
77+ //console.log(QWeb.render('FieldCharColor', {hexa:"#AA"}));
78+ //console.log(arguments);
79+ },
80+ draw_color: function(element){
81+ var color = element.val();
82+ element.class('backgroundColor', color);
83+ }
84+ });*/
85+}
86+
87+
88+/*
89+var FieldColor = openerp.base.Widget.extend({
90+ // QWeb template to use when rendering the object
91+ template: "FieldCharColor",
92+
93+ init: function(parent) {
94+ this._super(parent);
95+ // insert code to execute before rendering, for object
96+ // initialization
97+ },
98+ start: function() {
99+ this._super();
100+ // post-rendering initialization code, at this point
101+ // ``this.$element`` has been initialized
102+ //this.$element.find(".my_button").click(*/
103+/* an example of event binding * /);
104+ aloert('w00t!');
105+ // if ``start`` is asynchronous, return a promise object so callers
106+ // know when the object is done initializing
107+ //return this.rpc(*/
108+/* … *//*
109+)
110+ }
111+});
112+*/
113+
114+//var color_instance = new FieldColor(this);
115+//color_instance.appendTo(".oe-field-cell[data-field='color'']");
116+/*
117+openerp.web.web_color = function(openerp) {
118+
119+ openerp.web.page.FieldCharReadonly = openerp.web.page.FieldReadonly.extend({
120+ template: "FieldChar.color",
121+ init: function(view, node){
122+ this._super(view, node);
123+ },
124+ start: function(view, node) {
125+ this._super.apply(this, arguments);
126+ this.$element.find('div').color({
127+ value: this.value;
128+ disabled: this.readonly;
129+ });
130+ }
131+ });
132+}*/
133
134=== added directory 'addons/web_color/static/src/xml'
135=== added file 'addons/web_color/static/src/xml/lib.xml'
136--- addons/web_color/static/src/xml/lib.xml 1970-01-01 00:00:00 +0000
137+++ addons/web_color/static/src/xml/lib.xml 2012-10-19 16:38:22 +0000
138@@ -0,0 +1,6 @@
139+<?xml version="1.0" encoding="UTF-8"?>
140+<templates id="template" xml:space="preserve">
141+ <t t-name="FieldCharColor">
142+ <div t-att-style="'background-color : ' + hexa + ';'"></div>
143+ </t>
144+</templates>
145\ No newline at end of file