[IMP] web_pwa_oca: black, isort, prettier

pre-commit fixes

pre-commit fixes 2
This commit is contained in:
AntoniRomera
2020-06-19 12:42:27 +02:00
committed by sergio-teruel
parent 4ec8d1ab8b
commit 402ca37b14
5 changed files with 128 additions and 127 deletions

View File

@@ -1,45 +1,43 @@
odoo.define('web_pwa_oca.systray.install', function (require) {
"use strict";
odoo.define("web_pwa_oca.systray.install", function(require) {
"use strict";
var core = require('web.core');
var session = require('web.session');
var UserMenu = require('web.UserMenu');
var UserMenu = require("web.UserMenu");
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker.register('/service-worker.js')
.then(function (reg) {
console.log('Service worker registered.', reg);
});
});
}
var deferredInstallPrompt = null;
UserMenu.include({
start: function () {
window.addEventListener('beforeinstallprompt', this.saveBeforeInstallPromptEvent);
return this._super.apply(this, arguments);
},
saveBeforeInstallPromptEvent: function(evt) {
deferredInstallPrompt = evt;
this.$.find('#pwa_install_button')[0].removeAttribute('hidden');
},
_onMenuInstallpwa: function () {
deferredInstallPrompt.prompt();
// Hide the install button, it can't be called twice.
this.el.setAttribute('hidden', true);
// Log user response to prompt.
deferredInstallPrompt.userChoice
.then(function (choice) {
if (choice.outcome === 'accepted') {
console.log('User accepted the A2HS prompt', choice);
} else {
console.log('User dismissed the A2HS prompt', choice);
}
deferredInstallPrompt = null;
if ("serviceWorker" in navigator) {
window.addEventListener("load", function() {
navigator.serviceWorker.register("/service-worker.js").then(function(reg) {
console.log("Service worker registered.", reg);
});
},
});
});
}
var deferredInstallPrompt = null;
UserMenu.include({
start: function() {
window.addEventListener(
"beforeinstallprompt",
this.saveBeforeInstallPromptEvent
);
return this._super.apply(this, arguments);
},
saveBeforeInstallPromptEvent: function(evt) {
deferredInstallPrompt = evt;
this.$.find("#pwa_install_button")[0].removeAttribute("hidden");
},
_onMenuInstallpwa: function() {
deferredInstallPrompt.prompt();
// Hide the install button, it can't be called twice.
this.el.setAttribute("hidden", true);
// Log user response to prompt.
deferredInstallPrompt.userChoice.then(function(choice) {
if (choice.outcome === "accepted") {
console.log("User accepted the A2HS prompt", choice);
} else {
console.log("User dismissed the A2HS prompt", choice);
}
deferredInstallPrompt = null;
});
},
});
});

View File

@@ -1,14 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="web_pwa_oca.systray.install">
<a href="#" role="menuitem" id="pwa_install_button" data-menu="installpwa" class="dropdown-item" hidden="1">Install PWA</a>
<a
href="#"
role="menuitem"
id="pwa_install_button"
data-menu="installpwa"
class="dropdown-item"
hidden="1"
>Install PWA</a>
</t>
<t t-extend="UserMenu.Actions">
<t t-jquery="a[data-menu='settings']" t-operation="after">
<t t-call="web_pwa_oca.systray.install"/>
<t t-call="web_pwa_oca.systray.install" />
</t>
</t>
</templates>