[CHG]Web widgets, migration to v10

This commit is contained in:
Fabien BOURGEOIS 2017-05-01 11:43:54 +02:00
parent c6f2c4a292
commit 9997e55208
11 changed files with 79 additions and 64 deletions

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Author: Fabien Bourgeois. Copyright Yaltik # Copyright 2017 Fabien Bourgeois <fabien@yaltik.com>
# Copyright (C)
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com> # Copyright 2017 Fabien Bourgeois <fabien@yaltik.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -18,7 +18,7 @@
{ {
'name': 'Email widget check syntax', 'name': 'Email widget check syntax',
'summary': 'Extends Web Email widget to ensure valid syntax', 'summary': 'Extends Web Email widget to ensure valid syntax',
'version': '0.1', 'version': '10.0.1.0.1',
'category': 'Usability', 'category': 'Usability',
'author': 'Fabien Bourgeois', 'author': 'Fabien Bourgeois',
'license': 'AGPL-3', 'license': 'AGPL-3',

View File

@ -1,31 +1,34 @@
/* /*
* Copyright 2016 Fabien Bourgeois <fabien@yaltik.com> * Copyright 2017 Fabien Bourgeois <fabien@yaltik.com>
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details. * License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* global openerp */ /* global odoo */
openerp.web_widget_email_check = function (instance) { odoo.define('web.web_widget_email_check', function(require) {
'use strict'; '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,}))$/; 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 () { is_syntax_valid: function () {
var val = this.$('input').val() || ''; var val = this.$('input').val() || '';
return ((val.length === 0) || reEmail.test(val)); return ((val.length === 0) || reEmail.test(val));
} }
}); });
}; });

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright 2016 Fabien Bourgeois <fabien@yaltik.com> Copyright 2017 Fabien Bourgeois <fabien@yaltik.com>
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU Affero General Public License as published by
@ -16,12 +16,14 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<openerp> <odoo>
<data> <data>
<template id="assets_backend" name="web_widget_email_check_assets" inherit_id="web.assets_backend"> <template id="assets_backend" name="web_widget_email_check_assets"
<xpath expr="." position="inside"> inherit_id="web.assets_backend">
<script type="text/javascript" src="/web_widget_email_check/static/src/js/web_widget_email_check.js"></script> <xpath expr="." position="inside">
</xpath> <script type="text/javascript"
</template> src="/web_widget_email_check/static/src/js/web_widget_email_check.js"></script>
</data> </xpath>
</openerp> </template>
</data>
</odoo>

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com> # Copyright 2017 Fabien Bourgeois <fabien@yaltik.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -18,7 +18,7 @@
{ {
'name': 'French format phone widget check', 'name': 'French format phone widget check',
'summary': 'Extends Web Char widget to handle french format phone', 'summary': 'Extends Web Char widget to handle french format phone',
'version': '0.1', 'version': '10.0.1.0.1',
'category': 'Usability', 'category': 'Usability',
'author': 'Fabien Bourgeois', 'author': 'Fabien Bourgeois',
'license': 'AGPL-3', 'license': 'AGPL-3',

View File

@ -1,30 +1,32 @@
/* /*
* Copyright 2016 Fabien Bourgeois <fabien@yaltik.com> * Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details. * License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* global openerp */ /* global odoo */
openerp.web_widget_phone_check_fr = function (instance) { odoo.define('web.web_widget_phone_check', function(require) {
'use strict'; 'use strict';
var core = require('web.core');
var widget = require('web.form_widgets');
var rePhone = /^\d{10}$/; var rePhone = /^\d{10}$/;
openerp.web.form.FieldPhoneFr = var FieldPhoneFr = widget.FieldChar.extend({
instance.web.form.FieldChar.extend({ template: 'FieldPhoneFr',
template: 'FieldEmail',
is_syntax_valid: function () { is_syntax_valid: function () {
var val = this.$('input').val() || ''; var val = this.$('input').val() || '';
return ((val.length === 0) || rePhone.test(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);
}; });

View File

@ -18,8 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<templates> <templates>
<t t-name="FieldPhoneFr"> <t t-name="FieldPhoneFr">
<span class="oe_form_field oe_form_field_email" t-att-style="widget.node.attrs.style"> <span class="oe_form_field oe_form_field_email"
<a t-if="widget.get('effective_readonly')" href="#" class="oe_form_uri" target="_blank"/> t-att-style="widget.node.attrs.style">
<a t-if="widget.get('effective_readonly')" href="#"
class="oe_form_uri" target="_blank"/>
<t t-if="!widget.get('effective_readonly')"> <t t-if="!widget.get('effective_readonly')">
<div> <div>
<input type="text" <input type="text"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright 2016 Fabien Bourgeois <fabien@yaltik.com> Copyright 2017 Fabien Bourgeois <fabien@yaltik.com>
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU Affero General Public License as published by
@ -16,12 +16,14 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<openerp> <odoo>
<data> <data>
<template id="assets_backend" name="web_widget_phone_check_fr_assets" inherit_id="web.assets_backend"> <template id="assets_backend" name="web_widget_phone_check_fr_assets"
<xpath expr="." position="inside"> inherit_id="web.assets_backend">
<script type="text/javascript" src="/web_widget_phone_check_fr/static/src/js/web_widget_phone_check_fr.js"></script> <xpath expr="." position="inside">
</xpath> <script type="text/javascript"
</template> src="/web_widget_phone_check_fr/static/src/js/web_widget_phone_check_fr.js"></script>
</data> </xpath>
</openerp> </template>
</data>
</odoo>

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com> # Copyright 2017 Fabien Bourgeois <fabien@yaltik.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -18,7 +18,7 @@
{ {
'name': 'URL widget check syntax', 'name': 'URL widget check syntax',
'summary': 'Extends Web URL widget to ensure valid syntax', 'summary': 'Extends Web URL widget to ensure valid syntax',
'version': '0.1', 'version': '10.0.1.0.1',
'category': 'Usability', 'category': 'Usability',
'author': 'Fabien Bourgeois', 'author': 'Fabien Bourgeois',
'license': 'AGPL-3', 'license': 'AGPL-3',

View File

@ -1,28 +1,31 @@
/* /*
* Copyright 2016 Fabien Bourgeois <fabien@yaltik.com> * Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details. * License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* global openerp */ /* global odoo */
openerp.web_widget_url_check = function (instance) { odoo.define('web.web_widget_url_check', function(require) {
'use strict'; 'use strict';
var core = require('web.core');
var widget = require('web.form_widgets');
var reUrl = /(?:https?:\/\/)?(?:[\w]+\.)([a-zA-Z\.]{2,6})([\/\w\.-]*)*\/?/; var reUrl = /(?:https?:\/\/)?(?:[\w]+\.)([a-zA-Z\.]{2,6})([\/\w\.-]*)*\/?/;
instance.web.form.FieldUrl.include({ widget.FieldUrl.include({
is_syntax_valid: function () { is_syntax_valid: function () {
var val = this.$('input').val() || ''; var val = this.$('input').val() || '';
return ((val.length === 0) || reUrl.test(val)); return ((val.length === 0) || reUrl.test(val));

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright 2016 Fabien Bourgeois <fabien@yaltik.com> Copyright 2017 Fabien Bourgeois <fabien@yaltik.com>
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU Affero General Public License as published by
@ -16,12 +16,14 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<openerp> <odoo>
<data> <data>
<template id="assets_backend" name="web_widget_url_check_assets" inherit_id="web.assets_backend"> <template id="assets_backend" name="web_widget_url_check_assets"
<xpath expr="." position="inside"> inherit_id="web.assets_backend">
<script type="text/javascript" src="/web_widget_url_check/static/src/js/web_widget_url_check.js"></script> <xpath expr="." position="inside">
</xpath> <script type="text/javascript"
</template> src="/web_widget_url_check/static/src/js/web_widget_url_check.js"></script>
</data> </xpath>
</openerp> </template>
</data>
</odoo>