summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/components/custom_checkbox.js
blob: bc98dd7bab26e99b64641e3cfeea8084da966860 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
odoo.define('web.CustomCheckbox', function (require) {
    "use strict";

    const utils = require('web.utils');

    const { Component } = owl;

    /**
     * Custom checkbox
     * 
     * Component that can be used in templates to render the custom checkbox of Odoo.
     * 
     * <CustomCheckbox
     *     value="boolean"
     *     disabled="boolean"
     *     text="'Change the label text'"
     *     t-on-change="_onValueChange"
     *     />
     * 
     * @extends Component
     */
    class CustomCheckbox extends Component {
        /**
         * @param {Object} [props]
         * @param {string | number | null} [props.id]
         * @param {boolean} [props.value=false]
         * @param {boolean} [props.disabled=false]
         * @param {string} [props.text]
         */
        constructor() {
            super(...arguments);
            this._id = `checkbox-comp-${utils.generateID()}`;
        }
    }

    CustomCheckbox.props = {
        id: {
            type: [String, Number],
            optional: 1,
        },
        disabled: {
            type: Boolean,
            optional: 1,
        },
        value: {
            type: Boolean,
            optional: 1,
        },
        text: {
            type: String,
            optional: 1,
        },
    };

    CustomCheckbox.template = 'web.CustomCheckbox';

    return CustomCheckbox;
});