[ADD] web_help

[FIX] web_help: Run pre-commit

[FIX] web_help: Run pre-commit

[FIX] web_help: Run pre-commit

[FIX] web_help: Run pre-commit

[IMP] Easy changeable template and buttons texts, more demo, fixed readme.

[IMP] Easy changeable template and buttons texts, more demo, fixed readme.

[IMP] Easy changeable template and buttons texts, more demo, fixed readme.

[FIX] Grammar
This commit is contained in:
tarteo
2023-02-22 14:50:32 +01:00
parent 72c420f5ed
commit d6068076d7
21 changed files with 529 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
/** @odoo-module **/
import LegacyControlPanel from "web.ControlPanel";
import {ControlPanel} from "@web/search/control_panel/control_panel";
import {findTrip} from "@web_help/helpers.esm";
import {Component, useState} from "@odoo/owl";
import {ActionDialog} from "@web/webclient/actions/action_dialog";
export class HelpButton extends Component {
setup() {
const foundTrip = findTrip(this.props.resModel, this.props.viewType);
this.state = useState({
TripClass: foundTrip,
});
}
onClick() {
const TripClass = this.state.TripClass;
const trip = new TripClass(this.env);
trip.setup();
trip.start();
}
}
HelpButton.template = "web_help.HelpButton";
Object.assign(ControlPanel.components, {HelpButton});
Object.assign(LegacyControlPanel.components, {HelpButton});
Object.assign(ActionDialog.components, {HelpButton});

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="web_help.HelpButton" owl="1">
<button
class="btn ml-2 js_web_help_btn"
t-att-class="props.btnClass || 'btn-secondary'"
t-on-click="onClick"
t-if="state.TripClass"
>
<i class="fa fa-question" />
</button>
</t>
<t t-inherit="web.ControlPanel.Regular" t-inherit-mode="extension">
<xpath expr="//div[hasclass('o_cp_bottom')]" t-operation="inside">
<nav class="btn-group">
<HelpButton
resModel="env.searchModel.resModel"
viewType="env.config.viewType"
/>
</nav>
</xpath>
</t>
<t t-inherit="web.ControlPanel.Small" t-inherit-mode="extension">
<xpath expr="//div[hasclass('o_cp_bottom')]" t-operation="inside">
<nav class="btn-group">
<HelpButton
resModel="env.searchModel.resModel"
viewType="env.config.viewType"
/>
</nav>
</xpath>
</t>
<t t-inherit="web.ActionDialog.header" t-inherit-mode="extension">
<xpath expr="//h4[hasclass('modal-title')]" t-operation="after">
<HelpButton
resModel="props.actionProps.resModel"
viewType="props.actionProps.type"
btnClass="'btn-link p-1'"
/>
</xpath>
</t>
</templates>