mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
35 lines
793 B
JavaScript
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;
|