[IMP] portal: prevent duplicate views of portal wizard

The portal's granting access / revoking access / reinvite actions
return the wizard modal opening action in order to keep it open
and allow the user to keep browsing and managing portal access.

However, this can return the modal opening several times and execute
them all, generating several (unsynchronized) modal view instances
that the user sees and has to close one at a time.

Therefore the user field in the portal wizard receives a small widget,
that only allows one of these actions at a time. Clicking on other
buttons in the list while an action is ongoing will not do anything
since buttons are disabled for the time the action is being done.

Buttons showing the email_state will not do actions when clicked.

A short scss file is also added to the widget in order to make the elements
of the user_ids tree view as close to each other as possible. This prevents
in most cases the loss of buttons going off the list's width view and
generating a scroll bar, a situation to avoid since it does not show the
user the (dyamically appeared) action buttons. (e.g. when hiding buttons
if no valid email, then editing to a valid email, button reappearing out
of visible range)

Task-2613780

Part-of: odoo/odoo#74911
This commit is contained in:
Noe Antoine
2022-08-30 15:50:55 +02:00
parent d6cc18cfdf
commit c28e7856e4
6 changed files with 45 additions and 2 deletions
+3
View File
@@ -32,6 +32,9 @@ a dependency towards website editing and customization capabilities.""",
'web._assets_frontend_helpers': [
('prepend', 'portal/static/src/scss/bootstrap_overridden.scss'),
],
'web.assets_backend': [
'portal/static/src/views/**/*',
],
'web.assets_frontend': [
'portal/static/src/scss/bootstrap.extend.scss',
'portal/static/src/scss/portal.scss',
@@ -0,0 +1,14 @@
/** @odoo-module **/
import { PortalWizardUserListRenderer } from "../list/portal_wizard_user_list_renderer";
import { X2ManyField } from "@web/views/fields/x2many/x2many_field";
import { registry } from "@web/core/registry";
export class PortalUserX2ManyField extends X2ManyField {
setup() {
super.setup();
this.Renderer = PortalWizardUserListRenderer;
}
}
registry.category("fields").add("portal_wizard_user_one2many", PortalUserX2ManyField);
@@ -0,0 +1,3 @@
.o_portal_wizard_user_one2many td {
width: 1%;
}
@@ -0,0 +1,23 @@
/** @odoo-module **/
import { ListRenderer } from "@web/views/list/list_renderer";
const { useSubEnv } = owl;
export class PortalWizardUserListRenderer extends ListRenderer {
setup() {
super.setup();
this.isPortalActionOngoing = false;
const defaultOnClickViewButton = this.env.onClickViewButton;
useSubEnv({
onClickViewButton: async (params) => {
if (params.clickParams.name === 'action_refresh_modal' || this.isPortalActionOngoing) {
return false;
}
this.isPortalActionOngoing = true;
await defaultOnClickViewButton(params);
this.isPortalActionOngoing = false;
},
});
}
}
+1 -1
View File
@@ -206,7 +206,7 @@ class PortalWizardUser(models.TransientModel):
return self.action_refresh_modal()
def action_refresh_modal(self):
"""Refresh the portal wizard modal and keep it open. Used as action of email state icon buttons,
"""Refresh the portal wizard modal and keep it open. Used as fallback action of email state icon buttons,
required as they must be non-disabled buttons to fire mouse events to show tooltips on email state."""
return self.wizard_id._action_open_modal()
+1 -1
View File
@@ -31,7 +31,7 @@
<field name="welcome_message"
placeholder="This text is included at the end of the email sent to new portal users."
class="mb-3"/>
<field name="user_ids">
<field name="user_ids" class="o_portal_wizard_user_one2many" widget="portal_wizard_user_one2many">
<tree string="Contacts" editable="bottom" create="false" delete="false">
<field name="partner_id" force_save="1"/>
<field name="email" attrs="{'readonly': [('is_internal', '=', True)]}"/>