Added JavaScript rl-vm-visible event so that demo extension can prefill passphrase

This commit is contained in:
the-djmaze 2024-07-07 16:28:29 +02:00
parent 7a1652972d
commit f8d358a4f3
3 changed files with 30 additions and 0 deletions

View file

@ -78,9 +78,11 @@ const
if (e.target === vmDom) { if (e.target === vmDom) {
if (vmDom.classList.contains('animate')) { if (vmDom.classList.contains('animate')) {
vm.afterShow?.(); vm.afterShow?.();
fireEvent('rl-vm-visible', vm);
} else { } else {
vmDom.close(); vmDom.close();
vm.afterHide?.(); vm.afterHide?.();
// fireEvent('rl-vm-hidden', vm);
} }
} }
}; };

View file

@ -0,0 +1,26 @@
(rl => {
if (rl) {
/*
addEventListener('rl-view-model', e => {
const view = e.detail;
if (view && 'Login' === view.viewModelTemplateID) {
view.email(rl.settings.get('DemoEmail'));
view.password('DemoPassword');
}
});
*/
addEventListener('rl-vm-visible', e => {
const view = e.detail;
/* Not working
if (view && 'PopupsCompose' === view.viewModelTemplateID) {
view.to(rl.settings.get('DemoEmail'));
// view.to(view.from());
}
*/
if (view && 'PopupsAsk' === view.viewModelTemplateID) {
view.passphrase('demo');
}
});
}
})(window.rl);

View file

@ -13,6 +13,8 @@ class DemoAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
*/ */
public function Init() : void public function Init() : void
{ {
$this->addJs('demo.js');
$this->addHook('filter.app-data', 'FilterAppData'); $this->addHook('filter.app-data', 'FilterAppData');
$this->addHook('filter.action-params', 'FilterActionParams'); $this->addHook('filter.action-params', 'FilterActionParams');
$this->addHook('json.before-accountsetup', 'BeforeAccountSetup'); $this->addHook('json.before-accountsetup', 'BeforeAccountSetup');