From 9997e552085e0882d66d1fa31325fe03592da973 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Mon, 1 May 2017 11:43:54 +0200 Subject: [PATCH] [CHG]Web widgets, migration to v10 --- web_widget_email_check/__init__.py | 3 +-- .../{__openerp__.py => __manifest__.py} | 4 ++-- .../static/src/js/web_widget_email_check.js | 19 +++++++++------- web_widget_email_check/view.xml | 22 ++++++++++--------- .../{__openerp__.py => __manifest__.py} | 4 ++-- .../src/js/web_widget_phone_check_fr.js | 22 ++++++++++--------- .../static/src/xml/qweb.xml | 6 +++-- web_widget_phone_check_fr/view.xml | 22 ++++++++++--------- .../{__openerp__.py => __manifest__.py} | 4 ++-- .../static/src/js/web_widget_url_check.js | 15 ++++++++----- web_widget_url_check/view.xml | 22 ++++++++++--------- 11 files changed, 79 insertions(+), 64 deletions(-) rename web_widget_email_check/{__openerp__.py => __manifest__.py} (92%) rename web_widget_phone_check_fr/{__openerp__.py => __manifest__.py} (92%) rename web_widget_url_check/{__openerp__.py => __manifest__.py} (91%) diff --git a/web_widget_email_check/__init__.py b/web_widget_email_check/__init__.py index daa4ccf..099b2ba 100644 --- a/web_widget_email_check/__init__.py +++ b/web_widget_email_check/__init__.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- -# Author: Fabien Bourgeois. Copyright Yaltik -# Copyright (C) +# Copyright 2017 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as diff --git a/web_widget_email_check/__openerp__.py b/web_widget_email_check/__manifest__.py similarity index 92% rename from web_widget_email_check/__openerp__.py rename to web_widget_email_check/__manifest__.py index 2c23524..7a295a3 100644 --- a/web_widget_email_check/__openerp__.py +++ b/web_widget_email_check/__manifest__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Fabien Bourgeois +# Copyright 2017 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -18,7 +18,7 @@ { 'name': 'Email widget check syntax', 'summary': 'Extends Web Email widget to ensure valid syntax', - 'version': '0.1', + 'version': '10.0.1.0.1', 'category': 'Usability', 'author': 'Fabien Bourgeois', 'license': 'AGPL-3', diff --git a/web_widget_email_check/static/src/js/web_widget_email_check.js b/web_widget_email_check/static/src/js/web_widget_email_check.js index 3ba387d..c141e9c 100644 --- a/web_widget_email_check/static/src/js/web_widget_email_check.js +++ b/web_widget_email_check/static/src/js/web_widget_email_check.js @@ -1,31 +1,34 @@ /* -* Copyright 2016 Fabien Bourgeois -* +* Copyright 2017 Fabien Bourgeois +* * 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 . */ -/* global openerp */ +/* global odoo */ -openerp.web_widget_email_check = function (instance) { +odoo.define('web.web_widget_email_check', function(require) { 'use strict'; + var core = require('web.core'); + var widget = require('web.form_widgets'); + var reEmail = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; - instance.web.form.FieldEmail.include({ + widget.FieldEmail.include({ is_syntax_valid: function () { var val = this.$('input').val() || ''; return ((val.length === 0) || reEmail.test(val)); } }); -}; +}); diff --git a/web_widget_email_check/view.xml b/web_widget_email_check/view.xml index 88c39db..dcdf44f 100644 --- a/web_widget_email_check/view.xml +++ b/web_widget_email_check/view.xml @@ -1,6 +1,6 @@ - - - - - + + + + + diff --git a/web_widget_phone_check_fr/__openerp__.py b/web_widget_phone_check_fr/__manifest__.py similarity index 92% rename from web_widget_phone_check_fr/__openerp__.py rename to web_widget_phone_check_fr/__manifest__.py index 8cd1da4..d4ccaad 100644 --- a/web_widget_phone_check_fr/__openerp__.py +++ b/web_widget_phone_check_fr/__manifest__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Fabien Bourgeois +# Copyright 2017 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -18,7 +18,7 @@ { 'name': 'French format phone widget check', 'summary': 'Extends Web Char widget to handle french format phone', - 'version': '0.1', + 'version': '10.0.1.0.1', 'category': 'Usability', 'author': 'Fabien Bourgeois', 'license': 'AGPL-3', diff --git a/web_widget_phone_check_fr/static/src/js/web_widget_phone_check_fr.js b/web_widget_phone_check_fr/static/src/js/web_widget_phone_check_fr.js index 8cf2735..41165e2 100644 --- a/web_widget_phone_check_fr/static/src/js/web_widget_phone_check_fr.js +++ b/web_widget_phone_check_fr/static/src/js/web_widget_phone_check_fr.js @@ -1,30 +1,32 @@ /* * Copyright 2016 Fabien Bourgeois -* +* * 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 . */ -/* global openerp */ +/* global odoo */ -openerp.web_widget_phone_check_fr = function (instance) { +odoo.define('web.web_widget_phone_check', function(require) { 'use strict'; + var core = require('web.core'); + var widget = require('web.form_widgets'); + var rePhone = /^\d{10}$/; - openerp.web.form.FieldPhoneFr = - instance.web.form.FieldChar.extend({ - template: 'FieldEmail', + var FieldPhoneFr = widget.FieldChar.extend({ + template: 'FieldPhoneFr', is_syntax_valid: function () { var val = this.$('input').val() || ''; return ((val.length === 0) || rePhone.test(val)); @@ -39,5 +41,5 @@ openerp.web_widget_phone_check_fr = function (instance) { } }); - instance.web.form.widgets.add('phonefr', 'instance.web.form.FieldPhoneFr'); -}; + core.form_widget_registry.add('phonefr', FieldPhoneFr); +}); diff --git a/web_widget_phone_check_fr/static/src/xml/qweb.xml b/web_widget_phone_check_fr/static/src/xml/qweb.xml index 98a9ab5..8f1afc0 100644 --- a/web_widget_phone_check_fr/static/src/xml/qweb.xml +++ b/web_widget_phone_check_fr/static/src/xml/qweb.xml @@ -18,8 +18,10 @@ along with this program. If not, see . - - + +
- - - - - + + + + + diff --git a/web_widget_url_check/__openerp__.py b/web_widget_url_check/__manifest__.py similarity index 91% rename from web_widget_url_check/__openerp__.py rename to web_widget_url_check/__manifest__.py index 0908fed..4f202f3 100644 --- a/web_widget_url_check/__openerp__.py +++ b/web_widget_url_check/__manifest__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Fabien Bourgeois +# Copyright 2017 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -18,7 +18,7 @@ { 'name': 'URL widget check syntax', 'summary': 'Extends Web URL widget to ensure valid syntax', - 'version': '0.1', + 'version': '10.0.1.0.1', 'category': 'Usability', 'author': 'Fabien Bourgeois', 'license': 'AGPL-3', diff --git a/web_widget_url_check/static/src/js/web_widget_url_check.js b/web_widget_url_check/static/src/js/web_widget_url_check.js index a46dc6c..1ec0881 100644 --- a/web_widget_url_check/static/src/js/web_widget_url_check.js +++ b/web_widget_url_check/static/src/js/web_widget_url_check.js @@ -1,28 +1,31 @@ /* * Copyright 2016 Fabien Bourgeois -* +* * 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 . */ -/* global openerp */ +/* global odoo */ -openerp.web_widget_url_check = function (instance) { +odoo.define('web.web_widget_url_check', function(require) { 'use strict'; + var core = require('web.core'); + var widget = require('web.form_widgets'); + var reUrl = /(?:https?:\/\/)?(?:[\w]+\.)([a-zA-Z\.]{2,6})([\/\w\.-]*)*\/?/; - instance.web.form.FieldUrl.include({ + widget.FieldUrl.include({ is_syntax_valid: function () { var val = this.$('input').val() || ''; return ((val.length === 0) || reUrl.test(val)); diff --git a/web_widget_url_check/view.xml b/web_widget_url_check/view.xml index 7df5bfd..b43aea7 100644 --- a/web_widget_url_check/view.xml +++ b/web_widget_url_check/view.xml @@ -1,6 +1,6 @@ - - - - - + + + + +