Debian Codegraph @

addons/point_of_sale/static/src/app/components/inputs/t_model_input.js

raw
1 import { Component } from "@odoo/owl";
2
3 /**
4 * tModel is an array that represents the state variable that this component
5 * should read and write to.
6 * ex: normally you would write
7 * ```<input t-model="state.userValues[nThValue].searchString"/>```
8 * with this component you can write
9 * ```<Input tModel="[state.userValues[nThValue], "searchString"]"/>```
10 */
11 export class TModelInput extends Component {
12 static template = "";
13 static props = { tModel: Array };
14 getValue(tModel = this.props.tModel) {
15 const [obj, key] = tModel;
16 return obj[key];
17 }
18 setValue(newValue, tModel = this.props.tModel) {
19 const [obj, key] = tModel;
20 obj[key] = newValue;
21 }
22 }