[IMP] mrp_subcontracting: convert portal to OWL
The subcontracting portal was already mainly written in OWL, but a couple of small tweaks are needed to match the latest implementation. Used for reference: https://github.com/odoo/odoo/blob/b8ef0cc4f22827f684cf3361ee9fd526d27cb72a/addons/project/static/src/project_sharing/project_sharing.js i.e. the OWL changes to the code that this portal was originally "inspired" by closes odoo/odoo#104024 Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
This commit is contained in:
+21
-18
@@ -4,13 +4,11 @@ import { useService } from '@web/core/utils/hooks';
|
||||
import { ActionContainer } from '@web/webclient/actions/action_container';
|
||||
import { MainComponentsContainer } from "@web/core/main_components_container";
|
||||
import { useOwnDebugContext } from "@web/core/debug/debug_context";
|
||||
import { ErrorHandler } from "@web/core/utils/components";
|
||||
import { session } from '@web/session';
|
||||
import { LegacyComponent } from "@web/legacy/legacy_component";
|
||||
|
||||
const { useEffect} = owl;
|
||||
const { Component, useEffect, useExternalListener } = owl;
|
||||
|
||||
export class SubcontractingPortalWebClient extends LegacyComponent {
|
||||
export class SubcontractingPortalWebClient extends Component {
|
||||
setup() {
|
||||
window.parent.document.body.style.margin = "0"; // remove the margin in the parent body
|
||||
this.actionService = useService('action');
|
||||
@@ -23,19 +21,7 @@ export class SubcontractingPortalWebClient extends LegacyComponent {
|
||||
},
|
||||
() => []
|
||||
);
|
||||
}
|
||||
|
||||
handleComponentError(error, C) {
|
||||
// remove the faulty component
|
||||
this.Components.splice(this.Components.indexOf(C), 1);
|
||||
/**
|
||||
* we rethrow the error to notify the user something bad happened.
|
||||
* We do it after a tick to make sure owl can properly finish its
|
||||
* rendering
|
||||
*/
|
||||
Promise.resolve().then(() => {
|
||||
throw error;
|
||||
});
|
||||
useExternalListener(window, "click", this.onGlobalClick, { capture: true });
|
||||
}
|
||||
|
||||
async _showView() {
|
||||
@@ -54,7 +40,24 @@ export class SubcontractingPortalWebClient extends LegacyComponent {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {MouseEvent} ev
|
||||
*/
|
||||
onGlobalClick(ev) {
|
||||
// When a ctrl-click occurs inside an <a href/> element
|
||||
// we let the browser do the default behavior and
|
||||
// we do not want any other listener to execute.
|
||||
if (
|
||||
ev.ctrlKey &&
|
||||
((ev.target instanceof HTMLAnchorElement && ev.target.href) ||
|
||||
(ev.target instanceof HTMLElement && ev.target.closest("a[href]:not([href=''])")))
|
||||
) {
|
||||
ev.stopImmediatePropagation();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SubcontractingPortalWebClient.components = { ActionContainer, ErrorHandler, MainComponentsContainer };
|
||||
SubcontractingPortalWebClient.components = { ActionContainer, MainComponentsContainer };
|
||||
SubcontractingPortalWebClient.template = 'mrp_subcontracting.SubcontractingPortalWebClient';
|
||||
|
||||
Reference in New Issue
Block a user