woocommerce-paypal-payments/modules/ppcp-wc-gateway/resources/js/common/display-manager/DisplayManager.js
Emili Castells Guasch 11105d913b Run eslint autofix
2024-07-12 12:58:34 +02:00

35 lines
793 B
JavaScript

import Rule from './Rule';
class DisplayManager {
constructor() {
this.rules = {};
this.ruleStatus = {}; // The current status for each rule. Maybe not necessary, for now just for logging.
document.ppcpDisplayManagerLog = () => {
console.log( 'DisplayManager', this );
};
}
addRule( ruleConfig ) {
const updateStatus = () => {
this.ruleStatus[ ruleConfig.key ] =
this.rules[ ruleConfig.key ].status;
//console.log('ruleStatus', this.ruleStatus);
};
this.rules[ ruleConfig.key ] = new Rule(
ruleConfig,
updateStatus.bind( this )
);
//console.log('Rule', this.rules[ruleConfig.key]);
}
register() {
this.ruleStatus = {};
for ( const [ key, rule ] of Object.entries( this.rules ) ) {
rule.register();
}
}
}
export default DisplayManager;