From 0a71d06be3909cfde8e3bd41752af2ba84dae023 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 12 Mar 2014 14:22:13 +0100 Subject: [PATCH 01/67] [IMP] work in progress on stats buttons. The goal is to allow buttons with dynamic/statistical informations in form views (addon web) bzr revid: ged@openerp.com-20140312132213-hclaw6jc87u220zq --- addons/web/static/src/css/base.css | 17 ++++++++++++ addons/web/static/src/css/base.sass | 14 ++++++++++ addons/web/static/src/js/view_form.js | 37 +++++++++++++++++++++++++-- addons/web/static/src/xml/base.xml | 10 ++++++++ 4 files changed, 76 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index e43a2fb654e..263a867390e 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -462,6 +462,23 @@ .openerp .oe_button_box button { margin: 4px; } +.openerp .oe_button_box .oe_stat_button { + font-weight: normal; + display: inline-table; + width: 48% !important; + height: 45px; + margin: 1px; +} +.openerp .oe_button_box .oe_stat_button > div { + display: table-cell; + vertical-align: middle; + padding: 0; +} +.openerp .oe_button_box .oe_stat_button .stat_button_icon { + color: #7c7bad; + font-size: 24px; + padding: 4px; +} .openerp .oe_avatar > img { max-height: 90px; max-width: 90px; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index b19db9e4ebd..2d5ae82135e 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -433,6 +433,20 @@ $sheet-padding: 16px text-align: right button margin: 4px + .oe_stat_button + font-weight: normal + display: inline-table + width: 48% !important + height: 45px + margin: 1px + > div + display: table-cell + vertical-align: middle + padding: 0 + .stat_button_icon + color: #7C7BAD + font-size: 24px + padding: 4px .oe_avatar > img max-height: 90px diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index f1fc377fa94..a8973d760fa 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1218,6 +1218,9 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt $('button', doc).each(function() { $(this).attr('data-button-type', $(this).attr('type')).attr('type', 'button'); }); + $('statbutton', doc).each(function() { + $(this).attr('data-button-type', $(this).attr('type')).attr('type', 'button'); + }); // IE's html parser is also a css parser. How convenient... $('board', doc).each(function() { $(this).attr('layout', $(this).attr('style')); @@ -1277,6 +1280,9 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt var defs = []; _.each(this.to_replace, function(el) { defs.push(el[0].replace(el[1])); + if (el[1].children().length) { + el[0].$el.append(el[1].children()); + } }); this.to_replace = []; return $.when.apply($, defs); @@ -1304,7 +1310,7 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt var tagname = $tag[0].nodeName.toLowerCase(); if (this.tags_registry.contains(tagname)) { this.tags_to_init.push($tag); - return $tag; + return (tagname === 'statbutton') ? this.process_statbutton($tag) : $tag; } var fn = self['process_' + tagname]; if (fn) { @@ -1321,6 +1327,17 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt return $tag; } }, + process_statbutton: function ($button) { + var self = this; + console.log('yenrst'); + if ($button.children().length) { + $button.children().each(function() { + self.process($(this)); + }); + } + return $button; + }, + process_widget: function($widget) { this.widgets_to_init.push($widget); return $widget; @@ -1976,7 +1993,6 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({ var self = this; var context = this.build_context(); - return this.view.do_execute_action( _.extend({}, this.node.attrs, {context: context}), this.view.dataset, this.view.datarecord.id, function () { @@ -1990,6 +2006,22 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({ } }); +instance.web.form.StatButton = instance.web.form.WidgetButton.extend({ + template: 'StatButton', + + init: function(field_manager, node) { + var icon = node.attrs.icon; + this._super(field_manager, node); + + // debugger; + if (icon) { + this.icon = ""; + } + + }, + +}); + /** * Interface to be implemented by fields. * @@ -5899,6 +5931,7 @@ instance.web.form.widgets = new instance.web.Registry({ */ instance.web.form.tags = new instance.web.Registry({ 'button' : 'instance.web.form.WidgetButton', + 'statbutton' : 'instance.web.form.StatButton', }); instance.web.form.custom_widgets = new instance.web.Registry({ diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 80b82c1f40b..fa96fe1ac8a 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1360,6 +1360,16 @@ + + +
From ee478106748e52b314ac80a69d34a9b50cc29e4f Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 12 Mar 2014 14:45:38 +0100 Subject: [PATCH 02/67] [IMP] css tweaks to stat buttons bzr revid: ged@openerp.com-20140312134538-7b3o22lakb8qk45a --- addons/web/static/src/css/base.css | 3 ++- addons/web/static/src/css/base.sass | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 263a867390e..524bd79cc52 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -467,7 +467,8 @@ display: inline-table; width: 48% !important; height: 45px; - margin: 1px; + margin: 0px; + color: #666666; } .openerp .oe_button_box .oe_stat_button > div { display: table-cell; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 2d5ae82135e..f81232b7ee8 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -438,7 +438,8 @@ $sheet-padding: 16px display: inline-table width: 48% !important height: 45px - margin: 1px + margin: 0px + color: #666 > div display: table-cell vertical-align: middle From d2637811dec84306ab80cc49f40a8b823d7984a6 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Thu, 13 Mar 2014 13:48:43 +0100 Subject: [PATCH 03/67] [IMP] adds PercentPie and X2Many widgets to formview. PercentPie takes a field 'float' and displays a read-only pie chart to visualize the corresponding percent. X2Many takes a 1tomany or a manytomany field and display a read only string '
- - - - + + + + + + @@ -1945,7 +1947,7 @@ - +
From af61fd53bc86583aca872d4d884e976fed885d30 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Fri, 14 Mar 2014 15:21:55 +0100 Subject: [PATCH 07/67] [IMP] removes the tooltip when mouse hovers over a 'percentpie' widget (addon web) bzr revid: ged@openerp.com-20140314142155-u8suij5tikxwd0zi --- addons/web/static/src/js/view_form.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index dcb15d3d16d..c4bddd90f34 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2837,6 +2837,7 @@ instance.web.form.FieldPercentPie = instance.web.form.AbstractField.extend({ .donut(true) .showLegend(false) .showLabels(false) + .tooltips(false) .color(['#7C7BAD','#DDD']) .donutRatio(0.62); From e8198d74b68c3f1fba677b596a2eedf60af8ad83 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Mon, 17 Mar 2014 16:27:10 +0100 Subject: [PATCH 08/67] [IMP] various tweaks to stat_button, to fix issues mentioned in code review. This is mostly cosmetic cleanups, only notable change is that stat_button is now a proper html button instead of a label (addon web) bzr revid: ged@openerp.com-20140317152710-c33q8kua33o001la --- addons/web/static/src/css/base.css | 9 +++++--- addons/web/static/src/css/base.sass | 10 +++++---- addons/web/static/src/js/view_form.js | 16 ++++++-------- addons/web/static/src/xml/base.xml | 31 +++++++++------------------ 4 files changed, 28 insertions(+), 38 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 0b432d0c145..1d843e7e250 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -460,6 +460,9 @@ width: 400px; text-align: left; } +.openerp .oe_button_box .oe_stat_button:hover { + background: #dddddd; +} .openerp .oe_button_box .oe_stat_button { font-weight: normal; display: inline-table; @@ -467,7 +470,8 @@ height: 45px; margin: 0px -1px -1px 0px; color: #666666; - border-color: #dddddd; + border: 1px solid #666666; + background: white; } .openerp .oe_button_box .oe_stat_button > div { display: table-cell; @@ -478,9 +482,8 @@ .openerp .oe_button_box .oe_stat_button .stat_button_icon { color: #7c7bad; font-size: 24px; - padding: 0px; + padding: 0px 3px; text-align: center; - width: 40px; } .openerp .oe_button_box .oe_stat_button svg { width: 38px; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 336f583e019..cca0deb4a1f 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -432,6 +432,8 @@ $sheet-padding: 16px .oe_button_box width: 400px text-align: left + .oe_stat_button:hover + background: #ddd .oe_stat_button font-weight: normal display: inline-table @@ -439,18 +441,18 @@ $sheet-padding: 16px height: 45px margin: 0px -1px -1px 0px color: #666 - border-color: #ddd + border: 1px solid #666 + background: white > div display: table-cell vertical-align: middle text-align: left - padding: 0 + padding: 0 .stat_button_icon color: #7C7BAD font-size: 24px - padding: 0px + padding: 0px 3px text-align: center - width: 40px svg width: 38px height: 38px diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index c4bddd90f34..969e0150737 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1916,8 +1916,8 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({ template: 'WidgetButton', init: function(field_manager, node) { node.attrs.type = node.attrs['data-button-type']; - this.is_stat_button = node.attrs.class ? _.include(node.attrs.class.split(' '), 'oe_stat_button') : false; - this.icon = ""; + this.is_stat_button = /\boe_stat_button\b/.test(node.attrs['class']); + this.icon = node.attrs.icon && ""; this._super(field_manager, node); this.force_disabled = false; this.string = (this.node.attrs.string || '').replace(/_/g, ''); @@ -2845,16 +2845,12 @@ instance.web.form.FieldPercentPie = instance.web.form.AbstractField.extend({ .datum([{'x': 'value', 'y': value}, {'x': 'complement', 'y': 100 - value}]) .transition() .call(chart) - .attr('width', size) - .attr('height',size); + .attr({width:size, height:size}); d3.select(svg) .append("text") - .attr("x", size/2) - .attr("y", size/2 + 3) - .style("font-size", "10px") - .style("font-weight", "bold") - .attr("text-anchor", "middle") + .attr({x: size/2, y: size/2 + 3, 'text-anchor': 'middle'}) + .style({"font-size": "10px", "font-weight": "bold"}) .text(formatted_value); return chart; @@ -5923,7 +5919,7 @@ instance.web.form.StatInfo = instance.web.form.AbstractField.extend({ }, render_value: function() { var text = _.str.sprintf("%d %s", this.get("value") || 0, this.string); - this.$().html(QWeb.render("StatInfo", {text: text})); + this.$el.html(QWeb.render("StatInfo", {text: text})); }, }); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index b24bd8642cc..cc56dc2de13 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1189,7 +1189,7 @@
- + @@ -1356,26 +1356,15 @@
- - - - - - + From 373cb908caf5792367e49050e3d4ae086a097d0c Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Tue, 18 Mar 2014 09:55:25 +0100 Subject: [PATCH 09/67] [FIX] correctly handle the case where a 'stat button' has a string attribute (it needs to be displayed in a div instead of a span) (addon web) bzr revid: ged@openerp.com-20140318085525-vllzeycht9841g41 --- addons/web/static/src/xml/base.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index cc56dc2de13..508c507d935 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1362,11 +1362,11 @@ t-att-autofocus="widget.node.attrs.autofocus" t-att-accesskey="widget.node.attrs.accesskey"> -
- +
+ +
-
- +
From c49befd59f5ab3ef50a061b29dcef36b55c79088 Mon Sep 17 00:00:00 2001 From: "Parth Gajjar (Open ERP)" Date: Tue, 18 Mar 2014 19:00:36 +0530 Subject: [PATCH 10/67] [ADD] added website_gengo module bzr revid: pga@tinyerp.com-20140318133036-j1hcrz7bybolw44u --- .../wizard/base_gengo_translations.py | 1 + addons/website/controllers/main.py | 2 + .../static/src/js/website.translator.js | 4 +- addons/website_gengo/__init__.py | 21 +++++ addons/website_gengo/__openerp__.py | 40 ++++++++ addons/website_gengo/controllers/__init__.py | 1 + addons/website_gengo/controllers/main.py | 0 .../static/src/js/website_gengo.js | 91 +++++++++++++++++++ .../static/src/xml/website.gengo.xml | 73 +++++++++++++++ addons/website_gengo/views/website_gengo.xml | 12 +++ 10 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 addons/website_gengo/__init__.py create mode 100644 addons/website_gengo/__openerp__.py create mode 100644 addons/website_gengo/controllers/__init__.py create mode 100644 addons/website_gengo/controllers/main.py create mode 100644 addons/website_gengo/static/src/js/website_gengo.js create mode 100644 addons/website_gengo/static/src/xml/website.gengo.xml create mode 100644 addons/website_gengo/views/website_gengo.xml diff --git a/addons/base_gengo/wizard/base_gengo_translations.py b/addons/base_gengo/wizard/base_gengo_translations.py index bfd51480141..00c175e1450 100644 --- a/addons/base_gengo/wizard/base_gengo_translations.py +++ b/addons/base_gengo/wizard/base_gengo_translations.py @@ -74,6 +74,7 @@ class base_gengo_translations(osv.osv_memory): gengo = MyGengo( public_key=user.company_id.gengo_public_key.encode('ascii'), private_key=user.company_id.gengo_private_key.encode('ascii'), + sandbox = True, ) gengo.getAccountStats() return (True, gengo) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index aee0997e4b4..4d20dd11d40 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -240,6 +240,8 @@ class Website(openerp.addons.web.controllers.main.Home): 'source': initial_content, 'value': new_content, } + if t.get('gengo_translation'): + new_trans['gengo_translation'] = t.get('gengo_translation') irt.create(request.cr, request.uid, new_trans) return True diff --git a/addons/website/static/src/js/website.translator.js b/addons/website/static/src/js/website.translator.js index 399e5e731b2..c330d511170 100644 --- a/addons/website/static/src/js/website.translator.js +++ b/addons/website/static/src/js/website.translator.js @@ -120,7 +120,9 @@ } else { node.className += ' oe_translatable_todo'; } - node.contentEditable = true; + if(!this.gengo_translate){ + node.contentEditable = true; + } var nid = _.uniqueId(); $(node).attr('data-oe-nodeid', nid); this.initial_content[nid] = content; diff --git a/addons/website_gengo/__init__.py b/addons/website_gengo/__init__.py new file mode 100644 index 00000000000..654cb5b6b1a --- /dev/null +++ b/addons/website_gengo/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013-Today OpenERP S.A. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + diff --git a/addons/website_gengo/__openerp__.py b/addons/website_gengo/__openerp__.py new file mode 100644 index 00000000000..6ebb5e8ed30 --- /dev/null +++ b/addons/website_gengo/__openerp__.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013-Today OpenERP S.A. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': 'Website Gengo Translator', + 'category': 'Website', + 'version': '1.0', + 'description': """ +Website Gengo Translator +======================== +""", + 'author': 'OpenERP SA', + 'depends': [ + 'website', + 'base_gengo' + ], + 'data': [ + 'views/website_gengo.xml', + ], + 'qweb': [], + 'installable': True, +} diff --git a/addons/website_gengo/controllers/__init__.py b/addons/website_gengo/controllers/__init__.py new file mode 100644 index 00000000000..8ee9bae18d9 --- /dev/null +++ b/addons/website_gengo/controllers/__init__.py @@ -0,0 +1 @@ +import main diff --git a/addons/website_gengo/controllers/main.py b/addons/website_gengo/controllers/main.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/addons/website_gengo/static/src/js/website_gengo.js b/addons/website_gengo/static/src/js/website_gengo.js new file mode 100644 index 00000000000..6c5c2903dc6 --- /dev/null +++ b/addons/website_gengo/static/src/js/website_gengo.js @@ -0,0 +1,91 @@ +(function () { + 'use strict'; + + var website = openerp.website; + website.add_template_file('/website_gengo/static/src/xml/website.gengo.xml'); + + website.EditorBar.include({ + events: _.extend({}, website.EditorBar.prototype.events, { + 'click a[data-action=translation_gengo]': 'translation_gengo', + 'click a[data-action=translation_gengo_post]': 'translation_gengo_post', + }), + start: function () { + this.gengo_translate = false; + this._super.apply(this, arguments); + var self = this; + self.$('button[data-action=edit]') + .after(openerp.qweb.render('website.ButtonGengoTranslator')); + }, + translation_gengo: function () { + var self = this; + var dialog = new website.GengoTranslatorDialog(); + dialog.appendTo($(document.body)); + self.gengo_translate = true; + dialog.on('activate', this, function () { + dialog.$el.modal('hide'); + self.translate().then(function () { + self.gengo_translate = false; + self.$el.find('.gengo_translate').addClass("hidden"); + self.$el.find('.gengo_post').removeClass("hidden"); + }); + }); + + }, + translation_gengo_post: function () { + var self = this; + var translatable_list = $.find('.oe_translatable_todo'); + var dialog = new website.GengoTranslatorPostDialog(); + dialog.appendTo($(document.body)); + dialog.on('service_level', this, function () { + var gengo_service_level = dialog.$el.find(".form-control").val(); + dialog.$el.modal('hide'); + var trans ={} + $('.oe_translatable_todo').each(function () { + var $node = $(this); + var data = $node.data(); + if (!trans[data.oeTranslationViewId]) { + trans[data.oeTranslationViewId] = []; + } + trans[data.oeTranslationViewId].push({ + initial_content: self.getInitialContent(this), + new_content:self.getInitialContent(this), + translation_id: data.oeTranslationId || null, + gengo_translation: gengo_service_level + }); + }); + openerp.jsonRpc('/website/set_translations', 'call', { + 'data': trans, + 'lang': website.get_context()['lang'], + }); + }); + + }, + }); + + website.GengoTranslatorDialog = openerp.Widget.extend({ + events: _.extend({}, website.EditorBar.prototype.events, { + 'hidden.bs.modal': 'destroy', + 'click button[data-action=activate]': function (ev) { + this.trigger('activate'); + }, + }), + template: 'website.GengoTranslatorDialog', + start: function () { + this.$el.modal(); + }, + }); + + website.GengoTranslatorPostDialog = openerp.Widget.extend({ + events: _.extend({}, website.EditorBar.prototype.events, { + 'hidden.bs.modal': 'destroy', + 'click button[data-action=service_level]': function (ev) { + this.trigger('service_level'); + }, + }), + template: 'website.GengoTranslatorPostDialog', + start: function () { + this.$el.modal(); + }, + }); + +})(); diff --git a/addons/website_gengo/static/src/xml/website.gengo.xml b/addons/website_gengo/static/src/xml/website.gengo.xml new file mode 100644 index 00000000000..25d0cf8e44c --- /dev/null +++ b/addons/website_gengo/static/src/xml/website.gengo.xml @@ -0,0 +1,73 @@ + + + + Buy Translation + + + + + + + + + + + \ No newline at end of file diff --git a/addons/website_gengo/views/website_gengo.xml b/addons/website_gengo/views/website_gengo.xml new file mode 100644 index 00000000000..56681df4c42 --- /dev/null +++ b/addons/website_gengo/views/website_gengo.xml @@ -0,0 +1,12 @@ + + + + + + + + From f4cfed3f0e89f8841b16ad578dd2c360f01d18ec Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 19 Mar 2014 09:57:18 +0100 Subject: [PATCH 11/67] [IMP] improves the look of the stat buttons in form view: the statinfo widget displays the information on two lines, the padding/margin/width have been adjusted. (addon web) bzr revid: ged@openerp.com-20140319085718-9v1l3pb43ee6qws6 --- addons/web/static/src/css/base.css | 14 +++++++++++--- addons/web/static/src/css/base.sass | 13 ++++++++++--- addons/web/static/src/js/view_form.js | 9 ++++++--- addons/web/static/src/xml/base.xml | 5 ++--- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 1d843e7e250..53043f2f4c5 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -461,16 +461,22 @@ text-align: left; } .openerp .oe_button_box .oe_stat_button:hover { - background: #dddddd; + background: #7c7bad; + color: white; +} +.openerp .oe_button_box .oe_stat_button:hover .fa { + color: white; } .openerp .oe_button_box .oe_stat_button { font-weight: normal; display: inline-table; width: 33% !important; - height: 45px; + height: 42px; margin: 0px -1px -1px 0px; + padding: 0; color: #666666; - border: 1px solid #666666; + border: 1px solid #dddddd; + border-radius: 0; background: white; } .openerp .oe_button_box .oe_stat_button > div { @@ -478,11 +484,13 @@ vertical-align: middle; text-align: left; padding: 0; + line-height: 120%; } .openerp .oe_button_box .oe_stat_button .stat_button_icon { color: #7c7bad; font-size: 24px; padding: 0px 3px; + width: 37px; text-align: center; } .openerp .oe_button_box .oe_stat_button svg { diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index cca0deb4a1f..466f60fa861 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -433,25 +433,32 @@ $sheet-padding: 16px width: 400px text-align: left .oe_stat_button:hover - background: #ddd + background: #7c7bad + color: white + .fa + color: white .oe_stat_button font-weight: normal display: inline-table width: 33% !important - height: 45px + height: 42px margin: 0px -1px -1px 0px + padding: 0 color: #666 - border: 1px solid #666 + border: 1px solid #dddddd + border-radius: 0 background: white > div display: table-cell vertical-align: middle text-align: left padding: 0 + line-height: 120% .stat_button_icon color: #7C7BAD font-size: 24px padding: 0px 3px + width: 37px text-align: center svg width: 38px diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 969e0150737..5840d718bf8 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1917,7 +1917,7 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({ init: function(field_manager, node) { node.attrs.type = node.attrs['data-button-type']; this.is_stat_button = /\boe_stat_button\b/.test(node.attrs['class']); - this.icon = node.attrs.icon && ""; + this.icon = node.attrs.icon && ""; this._super(field_manager, node); this.force_disabled = false; this.string = (this.node.attrs.string || '').replace(/_/g, ''); @@ -5918,8 +5918,11 @@ instance.web.form.StatInfo = instance.web.form.AbstractField.extend({ this.set("value", 0); }, render_value: function() { - var text = _.str.sprintf("%d %s", this.get("value") || 0, this.string); - this.$el.html(QWeb.render("StatInfo", {text: text})); + var options = { + value: this.get("value") || 0, + text: this.string, + }; + this.$el.html(QWeb.render("StatInfo", options)); }, }); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 508c507d935..e35d0c977b3 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1362,7 +1362,7 @@ t-att-autofocus="widget.node.attrs.autofocus" t-att-accesskey="widget.node.attrs.accesskey"> -
+
@@ -1937,6 +1937,5 @@
-
-
+
From b8d87606f0579bbdfdf75dee4669d5f0fd9bb279 Mon Sep 17 00:00:00 2001 From: "Parth Gajjar (Open ERP)" Date: Wed, 19 Mar 2014 19:01:21 +0530 Subject: [PATCH 12/67] [IMP] added gengo statistics, displayed inprogress elements bzr revid: pga@tinyerp.com-20140319133121-31umju0ea84sm93y --- addons/website/controllers/main.py | 2 +- addons/website/static/src/css/editor.css | 4 ++ addons/website/static/src/css/editor.sass | 2 + .../static/src/js/website.translator.js | 5 ++ addons/website_gengo/__init__.py | 1 + addons/website_gengo/controllers/main.py | 19 +++++++ .../static/src/js/website_gengo.js | 51 +++++++++++++++++-- .../static/src/xml/website.gengo.xml | 32 ++++++++++-- 8 files changed, 108 insertions(+), 8 deletions(-) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 4d20dd11d40..011a31e00e3 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -206,7 +206,7 @@ class Website(openerp.addons.web.controllers.main.Home): views_ids = [view.get('id') for view in views if view.get('active')] domain = [('type', '=', 'view'), ('res_id', 'in', views_ids), ('lang', '=', lang)] irt = request.registry.get('ir.translation') - return irt.search_read(request.cr, request.uid, domain, ['id', 'res_id', 'value'], context=request.context) + return irt.search_read(request.cr, request.uid, domain, ['id', 'res_id', 'value','state'], context=request.context) @http.route('/website/set_translations', type='json', auth='public', website=True) def set_translations(self, data, lang): diff --git a/addons/website/static/src/css/editor.css b/addons/website/static/src/css/editor.css index da0fad43caf..5755bb06b03 100644 --- a/addons/website/static/src/css/editor.css +++ b/addons/website/static/src/css/editor.css @@ -145,6 +145,10 @@ table.editorbar-panel td.selected { background: #ffffb6; } +.oe_translatable_inprogress { + background: #b7e4ff; +} + /* ---- MENU ---- {{{ */ div.oe_menu_buttons { top: -8px; diff --git a/addons/website/static/src/css/editor.sass b/addons/website/static/src/css/editor.sass index 4571dcd257e..21b43ac77f3 100644 --- a/addons/website/static/src/css/editor.sass +++ b/addons/website/static/src/css/editor.sass @@ -115,6 +115,8 @@ table.editorbar-panel padding: 0 10px .oe_translatable_todo background: rgb(255, 255, 182) +.oe_translatable_todo + background: rgb(183, 228, 255) // }}} diff --git a/addons/website/static/src/js/website.translator.js b/addons/website/static/src/js/website.translator.js index c330d511170..12c740300c6 100644 --- a/addons/website/static/src/js/website.translator.js +++ b/addons/website/static/src/js/website.translator.js @@ -115,8 +115,13 @@ var trans = this.translations.filter(function (t) { return t.res_id === view_id && t.value === content; }); + console.log(trans); + console.log(this.translations); if (trans.length) { node.setAttribute('data-oe-translation-id', trans[0].id); + if(trans[0].state && trans[0].state == 'inprogress'){ + node.className += ' oe_translatable_inprogress'; + } } else { node.className += ' oe_translatable_todo'; } diff --git a/addons/website_gengo/__init__.py b/addons/website_gengo/__init__.py index 654cb5b6b1a..6da11461444 100644 --- a/addons/website_gengo/__init__.py +++ b/addons/website_gengo/__init__.py @@ -19,3 +19,4 @@ # ############################################################################## +import controllers \ No newline at end of file diff --git a/addons/website_gengo/controllers/main.py b/addons/website_gengo/controllers/main.py index e69de29bb2d..167e3e7bd36 100644 --- a/addons/website_gengo/controllers/main.py +++ b/addons/website_gengo/controllers/main.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from openerp.addons.web import http +from openerp.addons.web.http import request +class website_gengo(http.Controller): + + @http.route('/website/get_gengo_info', type='json', auth='user', website=True) + def get_gengo_info(self, view_id, lang): + ir_translation_obj = request.registry['ir.translation'] + res_lang_obj = request.registry['res.lang'] + translation_ids = ir_translation_obj.search(request.cr, request.uid, [('res_id','=',view_id),('gengo_translation','!=', False),('lang','=',lang)]) + result={"total":0,"inprogess":0,"done":0} + for trans in ir_translation_obj.browse(request.cr, request.uid, translation_ids): + result['total'] += len(trans.source.split()) + if trans.state == 'translated': + result['done'] += len(trans.source.split()) + elif trans.state == 'inprogress': + result['inprogess'] += len(trans.source.split()) + return result diff --git a/addons/website_gengo/static/src/js/website_gengo.js b/addons/website_gengo/static/src/js/website_gengo.js index 6c5c2903dc6..94cc2ab5c11 100644 --- a/addons/website_gengo/static/src/js/website_gengo.js +++ b/addons/website_gengo/static/src/js/website_gengo.js @@ -8,13 +8,19 @@ events: _.extend({}, website.EditorBar.prototype.events, { 'click a[data-action=translation_gengo]': 'translation_gengo', 'click a[data-action=translation_gengo_post]': 'translation_gengo_post', + 'click a[data-action=translation_gengo_info]': 'translation_gengo_info', }), start: function () { this.gengo_translate = false; this._super.apply(this, arguments); var self = this; - self.$('button[data-action=edit]') - .after(openerp.qweb.render('website.ButtonGengoTranslator')); + var gengo_langs = ["ar_SA","id_ID","nl_NL","fr_CA","pl_PL","zh_TW","sv_SE","ko_KR","pt_PT","en_US","ja_JP","es_ES","zh_CN","de_DE","fr_FR","fr_BE","ru_RU","it_IT","pt_BR"]; + if (gengo_langs.indexOf(website.get_context()['lang']) != -1) + { + self.$('button[data-action=edit]') + .after(openerp.qweb.render('website.ButtonGengoTranslator')); + + } }, translation_gengo: function () { var self = this; @@ -25,8 +31,15 @@ dialog.$el.modal('hide'); self.translate().then(function () { self.gengo_translate = false; - self.$el.find('.gengo_translate').addClass("hidden"); - self.$el.find('.gengo_post').removeClass("hidden"); + if($('.oe_translatable_todo').length > 0){ + self.$el.find('.gengo_translate').addClass("hidden"); + self.$el.find('.gengo_post').removeClass("hidden"); + } + else{ + self.$el.find('.gengo_translate').addClass("hidden"); + self.$el.find('.gengo_inprogress').removeClass("hidden"); + + } }); }); @@ -39,6 +52,8 @@ dialog.on('service_level', this, function () { var gengo_service_level = dialog.$el.find(".form-control").val(); dialog.$el.modal('hide'); + self.$el.find('.gengo_post').addClass("hidden"); + self.$el.find('.gengo_inprogress').removeClass("hidden"); var trans ={} $('.oe_translatable_todo').each(function () { var $node = $(this); @@ -60,6 +75,18 @@ }); }, + translation_gengo_info: function () { + var repr = $(document.documentElement).data('mainObject') + var view_id = repr.match(/.+\((.+), (\d+)\)/)[2]; + openerp.jsonRpc('/website/get_gengo_info', 'call', { + 'view_id': view_id, + 'lang': website.get_context()['lang'], + }).done(function(res){ + var dialog = new website.GengoTranslatorStatisticDialog(res); + dialog.appendTo($(document.body)); + + }); + }, }); website.GengoTranslatorDialog = openerp.Widget.extend({ @@ -87,5 +114,21 @@ this.$el.modal(); }, }); + + website.GengoTranslatorStatisticDialog = openerp.Widget.extend({ + events: _.extend({}, website.EditorBar.prototype.events, { + 'hidden.bs.modal': 'destroy', + }), + template: 'website.GengoTranslatorStatisticDialog', + init:function(res){ + this.total = res.total; + this.inprogess = res.inprogess; + this.done = res.done; + return this._super.apply(this, arguments); + }, + start: function (res) { + this.$el.modal(this.res); + }, + }); })(); diff --git a/addons/website_gengo/static/src/xml/website.gengo.xml b/addons/website_gengo/static/src/xml/website.gengo.xml index 25d0cf8e44c..39338a15fca 100644 --- a/addons/website_gengo/static/src/xml/website.gengo.xml +++ b/addons/website_gengo/static/src/xml/website.gengo.xml @@ -1,8 +1,7 @@ - Buy Translation - + Buy Translation + + + + \ No newline at end of file From b7a68828edb5b12196f6fd7bc76bb0d63f39d61c Mon Sep 17 00:00:00 2001 From: "Parth Gajjar (Open ERP)" Date: Thu, 20 Mar 2014 12:40:28 +0530 Subject: [PATCH 13/67] [IMP] improved statistics, added sendbox options for testing, improved UI bzr revid: pga@tinyerp.com-20140320071028-adyh8d89o7dij81o --- addons/base_gengo/res_company.py | 1 + addons/base_gengo/res_company_view.xml | 9 +++++++-- .../wizard/base_gengo_translations.py | 2 +- .../static/src/js/website.translator.js | 2 +- addons/website_gengo/controllers/main.py | 2 +- .../static/src/js/website_gengo.js | 19 +++++++++++++++---- .../static/src/xml/website.gengo.xml | 15 ++++++++++----- 7 files changed, 36 insertions(+), 14 deletions(-) diff --git a/addons/base_gengo/res_company.py b/addons/base_gengo/res_company.py index 3d038ac0813..645564b4eeb 100644 --- a/addons/base_gengo/res_company.py +++ b/addons/base_gengo/res_company.py @@ -30,6 +30,7 @@ class res_company(osv.Model): "gengo_public_key": fields.text("Gengo Public Key"), "gengo_comment": fields.text("Comments", help="This comment will be automatically be enclosed in each an every request sent to Gengo"), "gengo_auto_approve": fields.boolean("Auto Approve Translation ?", help="Jobs are Automatically Approved by Gengo."), + "gengo_sandbox": fields.boolean("Sandbox", help="Enable if you using testing account"), } _defaults = { diff --git a/addons/base_gengo/res_company_view.xml b/addons/base_gengo/res_company_view.xml index 0f99efc8ad0..d08d809eb9c 100644 --- a/addons/base_gengo/res_company_view.xml +++ b/addons/base_gengo/res_company_view.xml @@ -17,8 +17,13 @@ - - + + + + + + + diff --git a/addons/base_gengo/wizard/base_gengo_translations.py b/addons/base_gengo/wizard/base_gengo_translations.py index 00c175e1450..9b96e8c91e3 100644 --- a/addons/base_gengo/wizard/base_gengo_translations.py +++ b/addons/base_gengo/wizard/base_gengo_translations.py @@ -74,7 +74,7 @@ class base_gengo_translations(osv.osv_memory): gengo = MyGengo( public_key=user.company_id.gengo_public_key.encode('ascii'), private_key=user.company_id.gengo_private_key.encode('ascii'), - sandbox = True, + sandbox = user.company_id.gengo_sandbox, ) gengo.getAccountStats() return (True, gengo) diff --git a/addons/website/static/src/js/website.translator.js b/addons/website/static/src/js/website.translator.js index 12c740300c6..a2893e61248 100644 --- a/addons/website/static/src/js/website.translator.js +++ b/addons/website/static/src/js/website.translator.js @@ -119,7 +119,7 @@ console.log(this.translations); if (trans.length) { node.setAttribute('data-oe-translation-id', trans[0].id); - if(trans[0].state && trans[0].state == 'inprogress'){ + if(trans[0].state && (trans[0].state == 'inprogress' || trans[0].state == 'to_translate')){ node.className += ' oe_translatable_inprogress'; } } else { diff --git a/addons/website_gengo/controllers/main.py b/addons/website_gengo/controllers/main.py index 167e3e7bd36..7c22829464e 100644 --- a/addons/website_gengo/controllers/main.py +++ b/addons/website_gengo/controllers/main.py @@ -14,6 +14,6 @@ class website_gengo(http.Controller): result['total'] += len(trans.source.split()) if trans.state == 'translated': result['done'] += len(trans.source.split()) - elif trans.state == 'inprogress': + elif trans.state in ['inprogress','to_translate']: result['inprogess'] += len(trans.source.split()) return result diff --git a/addons/website_gengo/static/src/js/website_gengo.js b/addons/website_gengo/static/src/js/website_gengo.js index 94cc2ab5c11..badb51f9296 100644 --- a/addons/website_gengo/static/src/js/website_gengo.js +++ b/addons/website_gengo/static/src/js/website_gengo.js @@ -9,6 +9,7 @@ 'click a[data-action=translation_gengo]': 'translation_gengo', 'click a[data-action=translation_gengo_post]': 'translation_gengo_post', 'click a[data-action=translation_gengo_info]': 'translation_gengo_info', + 'click a[data-action=reload]': 'reload', }), start: function () { this.gengo_translate = false; @@ -32,12 +33,12 @@ self.translate().then(function () { self.gengo_translate = false; if($('.oe_translatable_todo').length > 0){ - self.$el.find('.gengo_translate').addClass("hidden"); - self.$el.find('.gengo_post').removeClass("hidden"); + self.$el.find('form.navbar-form.navbar-left > *').addClass("hidden"); + self.$el.find('.gengo_post,.gengo_info,.gengo_discard').removeClass("hidden"); } else{ - self.$el.find('.gengo_translate').addClass("hidden"); - self.$el.find('.gengo_inprogress').removeClass("hidden"); + self.$el.find('form.navbar-form.navbar-left > *').addClass("hidden"); + self.$el.find('.gengo_inprogress,.gengo_info,.gengo_discard').removeClass("hidden"); } }); @@ -71,6 +72,8 @@ openerp.jsonRpc('/website/set_translations', 'call', { 'data': trans, 'lang': website.get_context()['lang'], + }).done(function(){ + $('.oe_translatable_todo').addClass('oe_translatable_inprogress').removeClass('oe_translatable_todo'); }); }); @@ -87,6 +90,9 @@ }); }, + reload: function () { + website.reload(); + }, }); website.GengoTranslatorDialog = openerp.Widget.extend({ @@ -121,9 +127,14 @@ }), template: 'website.GengoTranslatorStatisticDialog', init:function(res){ + var self = this; this.total = res.total; this.inprogess = res.inprogess; this.done = res.done; + this.new_words = 0; + $('.oe_translatable_todo').each(function () { + self.new_words += $(this).text().split(" ").length; + }); return this._super.apply(this, arguments); }, start: function (res) { diff --git a/addons/website_gengo/static/src/xml/website.gengo.xml b/addons/website_gengo/static/src/xml/website.gengo.xml index 39338a15fca..00733829d42 100644 --- a/addons/website_gengo/static/src/xml/website.gengo.xml +++ b/addons/website_gengo/static/src/xml/website.gengo.xml @@ -1,7 +1,9 @@ - Buy Translation + Gengo Translation + +