summaryrefslogtreecommitdiff
path: root/addons/point_of_sale/static/src/js/ComponentRegistry.js
blob: 1e820782e15a6b2c3c018ab100d080c4bd82c113 (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
odoo.define('point_of_sale.ComponentRegistry', function(require) {
    'use strict';

    const PosComponent = require('point_of_sale.PosComponent');
    const ClassRegistry = require('point_of_sale.ClassRegistry');

    class ComponentRegistry extends ClassRegistry {
        freeze() {
            super.freeze();
            // Make sure PosComponent has the compiled classes.
            // This way, we don't need to explicitly declare that
            // a set of components is children of another.
            PosComponent.components = {};
            for (let [base, compiledClass] of this.cache.entries()) {
                PosComponent.components[base.name] = compiledClass;
            }
        }
        _recompute(base, old) {
            const res = super._recompute(base, old);
            if (typeof base === 'string') {
                base = this.baseNameMap[base];
            }
            PosComponent.components[base.name] = res;
            return res;
        }
    }

    return ComponentRegistry;
});