From a5f5358cf2f0240852d2fd90d5b9beaafe0e6304 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 4 Apr 2012 13:00:16 +0530 Subject: [PATCH 01/11] [IMP] improved code for make the list record bold depends on state bzr revid: tpa@tinyerp.com-20120404073016-ro6wuybho7npp9k4 --- addons/web/static/src/js/view_editor.js | 5 +++-- addons/web/static/src/js/view_list.js | 11 +++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 2c0dc3d70b4..e0953ae5ef6 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -873,7 +873,8 @@ openerp.web.ViewEditor = openerp.web.OldWidget.extend({ 'widget' : {'name':'widget', 'string': 'widget', 'type': 'selection'}, 'colors' : {'name':'colors', 'string': 'Colors', 'type': 'char'}, 'editable' : {'name':'editable', 'string': 'Editable', 'type': 'selection', 'selection': [["",""],["top","Top"],["bottom", "Bottom"]]}, - 'groups' : {'name':'groups', 'string': 'Groups', 'type': 'selection_multi'} + 'groups' : {'name':'groups', 'string': 'Groups', 'type': 'selection_multi'}, + 'fontbold' : {'name':'fontbold', 'string': 'fontbold', 'type': 'char'}, }; var arch_val = self.get_object_by_id(this.one_object.clicked_tr_id,this.one_object['main_object'], []); this.edit_node_dialog.$element.append('
'); @@ -1149,7 +1150,7 @@ var _PROPERTIES = { 'board': ['style'], 'column' : [], 'action' : ['name', 'string', 'colspan', 'groups'], - 'tree' : ['string', 'colors', 'editable', 'link', 'limit', 'min_rows'], + 'tree' : ['string', 'colors', 'editable', 'link', 'limit', 'min_rows', 'fontbold'], 'graph' : ['string', 'type'], 'calendar' : ['string', 'date_start', 'date_stop', 'date_delay', 'day_length', 'color', 'mode'] }; diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index e8fff450c6e..cab916bbc32 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -56,6 +56,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# this.view_id = view_id; this.previous_colspan = null; this.colors = null; + this.fontbold = null; this.columns = []; @@ -154,16 +155,21 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# current_date: new Date().toString('yyyy-MM-dd') // TODO: time, datetime, relativedelta }); + var style= ''; + if(record.attributes.state == this.fontbold) { + style = 'font-weight: bold;'; + } for(var i=0, len=this.colors.length; i Date: Wed, 4 Apr 2012 14:46:13 +0530 Subject: [PATCH 02/11] [IMP] improved code for more than one states bzr revid: tpa@tinyerp.com-20120404091613-fp7el2lal3qb190r --- addons/web/static/src/js/view_list.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index cab916bbc32..122d4ee76d5 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -156,9 +156,12 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# // TODO: time, datetime, relativedelta }); var style= ''; - if(record.attributes.state == this.fontbold) { - style = 'font-weight: bold;'; + for(var i=0, len=this.fontbold.length; i Date: Wed, 4 Apr 2012 17:32:11 +0530 Subject: [PATCH 03/11] [IMP] improved code for font-bold feature bzr revid: tpa@tinyerp.com-20120404120211-0b1l1zvjx5550hqa --- addons/web/static/src/js/view_editor.js | 4 +-- addons/web/static/src/js/view_list.js | 36 ++++++++++++++++--------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index e0953ae5ef6..ae531c8c925 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -874,7 +874,7 @@ openerp.web.ViewEditor = openerp.web.OldWidget.extend({ 'colors' : {'name':'colors', 'string': 'Colors', 'type': 'char'}, 'editable' : {'name':'editable', 'string': 'Editable', 'type': 'selection', 'selection': [["",""],["top","Top"],["bottom", "Bottom"]]}, 'groups' : {'name':'groups', 'string': 'Groups', 'type': 'selection_multi'}, - 'fontbold' : {'name':'fontbold', 'string': 'fontbold', 'type': 'char'}, + 'fonts' : {'name':'fonts', 'string': 'fonts', 'type': 'char'}, }; var arch_val = self.get_object_by_id(this.one_object.clicked_tr_id,this.one_object['main_object'], []); this.edit_node_dialog.$element.append('
'); @@ -1150,7 +1150,7 @@ var _PROPERTIES = { 'board': ['style'], 'column' : [], 'action' : ['name', 'string', 'colspan', 'groups'], - 'tree' : ['string', 'colors', 'editable', 'link', 'limit', 'min_rows', 'fontbold'], + 'tree' : ['string', 'colors', 'editable', 'link', 'limit', 'min_rows', 'fonts'], 'graph' : ['string', 'type'], 'calendar' : ['string', 'date_start', 'date_stop', 'date_delay', 'day_length', 'color', 'mode'] }; diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 122d4ee76d5..b2a23ac5451 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -56,7 +56,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# this.view_id = view_id; this.previous_colspan = null; this.colors = null; - this.fontbold = null; + this.fonts = null; this.columns = []; @@ -149,19 +149,26 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# * @returns {String} CSS color declaration */ color_for: function (record) { - if (!this.colors) { return ''; } - var context = _.extend({}, record.attributes, { + var style= ''; + + var context = _.extend({}, record.attributes, { uid: this.session.uid, current_date: new Date().toString('yyyy-MM-dd') // TODO: time, datetime, relativedelta }); - var style= ''; - for(var i=0, len=this.fontbold.length; i Date: Wed, 4 Apr 2012 18:59:30 +0530 Subject: [PATCH 04/11] [IMP] improved code. bzr revid: tpa@tinyerp.com-20120404132930-gqlw6a4f5y9ng0pd --- addons/web/static/src/js/view_list.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index b2a23ac5451..29569a43a62 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -163,7 +163,9 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# font = pair[0], expression = pair[1]; if (py.evaluate(expression, context).toJSON()) { - style = 'font-weight: bold;'; + if (font == 'bold'){style = 'font-weight: bold;';} + if (font == 'italic'){style = 'font-style: italic;';} + if (font == 'underline'){style = 'text-decoration: underline;';} } } } From aca7ed80a5a00f6034fa774b63d83c51f17a34a5 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 18 Apr 2012 14:52:54 +0530 Subject: [PATCH 05/11] [IMP] Improved code. bzr revid: tpa@tinyerp.com-20120418092254-2htqligvh8ov0qkr --- addons/web/static/src/js/view_list.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index de8b25fafe8..57268cb947c 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -148,9 +148,9 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi * @returns {String} CSS color declaration */ color_for: function (record) { - var style= ''; + var style= ''; - var context = _.extend({}, record.attributes, { + var context = _.extend({}, record.attributes, { uid: this.session.uid, current_date: new Date().toString('yyyy-MM-dd') // TODO: time, datetime, relativedelta @@ -162,9 +162,17 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi font = pair[0], expression = pair[1]; if (py.evaluate(expression, context).toJSON()) { - if (font == 'bold'){style = 'font-weight: bold;';} - if (font == 'italic'){style = 'font-style: italic;';} - if (font == 'underline'){style = 'text-decoration: underline;';} + switch(font) { + case 'bold': + style += 'font-weight: bold;'; + break; + case 'italic': + style += 'font-style: italic;'; + break; + case 'underline': + style += 'text-decoration: underline;'; + break; + } } } } @@ -175,8 +183,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi color = pair[0], expression = pair[1]; if (py.evaluate(expression, context).toJSON()) { - style += 'color: ' + color + ';' - return style; + return style += 'color: ' + color + ';'; } // TODO: handle evaluation errors } From a133899580a090e2e5b782bb5c0e4338301409a2 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 18 Apr 2012 15:12:25 +0530 Subject: [PATCH 06/11] [IMP] Improved code bzr revid: tpa@tinyerp.com-20120418094225-slnzultyxctu5n4r --- addons/web/static/src/js/view_list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 57268cb947c..0b9792e2760 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -229,7 +229,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi } if (this.fields_view.arch.attrs.fonts) { - this.fonts = _(this.fields_view.arch.attrs.fonts.split(',')).chain().compact() + this.fonts = _(this.fields_view.arch.attrs.fonts.split(';')).chain().compact() .map(function(font_pair) { var pair = font_pair.split(':'), font = pair[0], From 9fdb49c897e73428573198cd01949b833646dc66 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 18 Apr 2012 15:15:24 +0530 Subject: [PATCH 07/11] [IMP] set indentation bzr revid: tpa@tinyerp.com-20120418094524-l2nqten0ngq78957 --- addons/web/static/src/js/view_list.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 0b9792e2760..ea8898f8751 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -174,8 +174,8 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi break; } } - } - } + } + } if (!this.colors) { return style; } for(var i=0, len=this.colors.length; i Date: Wed, 18 Apr 2012 17:23:16 +0530 Subject: [PATCH 08/11] [IMP] Improved name of function and comment bzr revid: tpa@tinyerp.com-20120418115316-bndil056lk25ni3g --- addons/web/static/src/js/view_list.js | 8 ++++---- addons/web/static/src/xml/base.xml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index ea8898f8751..b1e8fe3a958 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -141,13 +141,13 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi return this.reload_view(null, null, true); }, /** - * Returns the color for the provided record in the current view (from the - * ``@colors`` attribute) + * Returns the style for the provided record in the current view (from the + * ``@colors`` attribute and ``@fonts`` attribute) * * @param {Record} record record for the current row - * @returns {String} CSS color declaration + * @returns {String} CSS style declaration */ - color_for: function (record) { + style_for: function (record) { var style= ''; var context = _.extend({}, record.attributes, { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index f365abf8856..3291aef0398 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -670,7 +670,7 @@ + t-att-style="view.style_for(record)"> From 8f5521955c0c6f08127661b231fe373cb17bdb97 Mon Sep 17 00:00:00 2001 From: "Sbh (Openerp)" Date: Thu, 19 Apr 2012 10:36:14 +0530 Subject: [PATCH 09/11] [ADD] Add the rst file for fontstyle feature bzr revid: sbh@tinyerp.com-20120419050614-i1y33qfnkyoicngc --- doc/font_style.rst | 22 ++++++++++++++++++++++ doc/index.rst | 1 + 2 files changed, 23 insertions(+) create mode 100644 doc/font_style.rst diff --git a/doc/font_style.rst b/doc/font_style.rst new file mode 100644 index 00000000000..f0261e9d144 --- /dev/null +++ b/doc/font_style.rst @@ -0,0 +1,22 @@ +Font style Feature +===================== + + +This revision adds font style feature in List view. + +Font style feature can be used by List view able to define the style of fonts based on the state of records. +we can set the style of fonts bold , italic and underline by defining in the view. + +Rng modification ++++++++++++++++++ + +This revision adds attribute fonts in view.rng + +Addon implementation example +++++++++++++++++++++++++++++ + +In your ``foo`` module, you want to specify that when it is in state ``pending`` then fons of the record should bold in list view + +:: + + diff --git a/doc/index.rst b/doc/index.rst index 815633aed54..187dd5ad009 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -19,6 +19,7 @@ Contents: addons development project + font_style old-version Indices and tables From 7636eb0254395f0b22214e06c2a5a14564b3d2f7 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Thu, 19 Apr 2012 10:47:56 +0530 Subject: [PATCH 10/11] [IMP] remove rst file bzr revid: tpa@tinyerp.com-20120419051756-1pwvzli1yi3jgzi8 --- doc/font_style.rst | 22 ---------------------- doc/index.rst | 1 - 2 files changed, 23 deletions(-) delete mode 100644 doc/font_style.rst diff --git a/doc/font_style.rst b/doc/font_style.rst deleted file mode 100644 index f0261e9d144..00000000000 --- a/doc/font_style.rst +++ /dev/null @@ -1,22 +0,0 @@ -Font style Feature -===================== - - -This revision adds font style feature in List view. - -Font style feature can be used by List view able to define the style of fonts based on the state of records. -we can set the style of fonts bold , italic and underline by defining in the view. - -Rng modification -+++++++++++++++++ - -This revision adds attribute fonts in view.rng - -Addon implementation example -++++++++++++++++++++++++++++ - -In your ``foo`` module, you want to specify that when it is in state ``pending`` then fons of the record should bold in list view - -:: - - diff --git a/doc/index.rst b/doc/index.rst index 187dd5ad009..815633aed54 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -19,7 +19,6 @@ Contents: addons development project - font_style old-version Indices and tables From 217cf2e14bdb78f77138872b8f9ea0ba0baff050 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Thu, 19 Apr 2012 15:26:46 +0530 Subject: [PATCH 11/11] [IMP] set proper indentation bzr revid: tpa@tinyerp.com-20120419095646-p1q0u7jny2740ms3 --- addons/web/static/src/js/view_list.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index b1e8fe3a958..9e749009ebc 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -157,10 +157,10 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi }); if (this.fonts) { - for(var i=0, len=this.fonts.length; i