[CHG]Web widgets, migration to v10
This commit is contained in:
parent
c6f2c4a292
commit
9997e55208
@ -1,7 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Author: Fabien Bourgeois. Copyright Yaltik
|
||||
# Copyright (C)
|
||||
# Copyright 2017 Fabien Bourgeois <fabien@yaltik.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- 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
|
||||
# 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',
|
@ -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
|
||||
* 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 <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';
|
||||
|
||||
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));
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?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
|
||||
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/>.
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="assets_backend" name="web_widget_email_check_assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/web_widget_email_check/static/src/js/web_widget_email_check.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
||||
<odoo>
|
||||
<data>
|
||||
<template id="assets_backend" name="web_widget_email_check_assets"
|
||||
inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript"
|
||||
src="/web_widget_email_check/static/src/js/web_widget_email_check.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</odoo>
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- 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
|
||||
# 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',
|
@ -1,30 +1,32 @@
|
||||
/*
|
||||
* Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||
*
|
||||
*
|
||||
* 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 <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';
|
||||
|
||||
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);
|
||||
});
|
||||
|
@ -18,8 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
<templates>
|
||||
<t t-name="FieldPhoneFr">
|
||||
<span class="oe_form_field oe_form_field_email" t-att-style="widget.node.attrs.style">
|
||||
<a t-if="widget.get('effective_readonly')" href="#" class="oe_form_uri" target="_blank"/>
|
||||
<span class="oe_form_field oe_form_field_email"
|
||||
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')">
|
||||
<div>
|
||||
<input type="text"
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?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
|
||||
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/>.
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="assets_backend" name="web_widget_phone_check_fr_assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/web_widget_phone_check_fr/static/src/js/web_widget_phone_check_fr.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
||||
<odoo>
|
||||
<data>
|
||||
<template id="assets_backend" name="web_widget_phone_check_fr_assets"
|
||||
inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript"
|
||||
src="/web_widget_phone_check_fr/static/src/js/web_widget_phone_check_fr.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</odoo>
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- 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
|
||||
# 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',
|
@ -1,28 +1,31 @@
|
||||
/*
|
||||
* Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||
*
|
||||
*
|
||||
* 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 <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';
|
||||
|
||||
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));
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?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
|
||||
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/>.
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="assets_backend" name="web_widget_url_check_assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/web_widget_url_check/static/src/js/web_widget_url_check.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
||||
<odoo>
|
||||
<data>
|
||||
<template id="assets_backend" name="web_widget_url_check_assets"
|
||||
inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript"
|
||||
src="/web_widget_url_check/static/src/js/web_widget_url_check.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</odoo>
|
||||
|
Loading…
Reference in New Issue
Block a user