mirror of
https://github.com/bringout/oca-web.git
synced 2026-04-18 23:52:02 +02:00
Add oca-web submodule with 68 web modules
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
af56672c08
commit
53fddf87c8
2469 changed files with 101716 additions and 0 deletions
|
|
@ -0,0 +1,15 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import {AutoComplete} from "@web/core/autocomplete/autocomplete";
|
||||
|
||||
const _extractProps = AutoComplete.extractProps;
|
||||
AutoComplete.extractProps = ({attrs, field}) => {
|
||||
return Object.assign(_extractProps({attrs, field}), {
|
||||
pattern: attrs.pattern || field.pattern,
|
||||
});
|
||||
};
|
||||
|
||||
AutoComplete.props = {
|
||||
...AutoComplete.props,
|
||||
pattern: {type: String, optional: true},
|
||||
};
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-inherit="web.AutoComplete" t-inherit-mode="extension" owl="1">
|
||||
<input position="attributes">
|
||||
<attribute name="t-att-pattern">props.pattern</attribute>
|
||||
</input>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import {CharField} from "@web/views/fields/char/char_field";
|
||||
import {_lt} from "@web/core/l10n/translation";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
import {sprintf} from "@web/core/utils/strings";
|
||||
|
||||
patch(CharField.prototype, "web_widget_pattern", {
|
||||
parse(value) {
|
||||
const result = this._super(...arguments);
|
||||
const pattern = this.props.pattern;
|
||||
if (pattern) {
|
||||
const regex = new RegExp(pattern, "v");
|
||||
const match = regex.exec(result);
|
||||
if (!match || match[0] !== value) {
|
||||
throw new Error(
|
||||
_lt(
|
||||
sprintf("%s does not match required pattern %s", value, pattern)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
});
|
||||
|
||||
const _extractProps = CharField.extractProps;
|
||||
CharField.extractProps = ({attrs, field}) => {
|
||||
return Object.assign(_extractProps({attrs, field}), {
|
||||
pattern: attrs.pattern || field.pattern,
|
||||
});
|
||||
};
|
||||
|
||||
CharField.props = {
|
||||
...CharField.props,
|
||||
pattern: {type: String, optional: true},
|
||||
};
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-inherit="web.CharField" t-inherit-mode="extension" owl="1">
|
||||
<input position="attributes">
|
||||
<attribute name="t-att-pattern">props.pattern</attribute>
|
||||
</input>
|
||||
</t>
|
||||
</templates>
|
||||
Loading…
Add table
Add a link
Reference in a new issue