mirror of
https://github.com/bringout/oca-ocb-web.git
synced 2026-04-20 23:12:01 +02:00
Initial commit: Web packages
This commit is contained in:
commit
cd458d4b85
791 changed files with 410049 additions and 0 deletions
|
|
@ -0,0 +1,49 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { browser } from "@web/core/browser/browser";
|
||||
import { registry } from "@web/core/registry";
|
||||
import ToursDialog from "@web_tour/debug/tour_dialog_component";
|
||||
import utils from "web_tour.utils";
|
||||
|
||||
export function disableTours({ env }) {
|
||||
if (!env.services.user.isSystem) {
|
||||
return null;
|
||||
}
|
||||
const activeTours = env.services.tour.getActiveTours();
|
||||
if (activeTours.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
type: "item",
|
||||
description: env._t("Disable Tours"),
|
||||
callback: async () => {
|
||||
const tourNames = activeTours.map(tour => tour.name);
|
||||
await env.services.orm.call("web_tour.tour", "consume", [tourNames]);
|
||||
for (const tourName of tourNames) {
|
||||
browser.localStorage.removeItem(utils.get_debugging_key(tourName));
|
||||
}
|
||||
browser.location.reload();
|
||||
},
|
||||
sequence: 50,
|
||||
};
|
||||
}
|
||||
|
||||
export function startTour({ env }) {
|
||||
if (!env.services.user.isSystem) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
type: "item",
|
||||
description: env._t("Start Tour"),
|
||||
callback: async () => {
|
||||
env.services.dialog.add(ToursDialog);
|
||||
},
|
||||
sequence: 60,
|
||||
};
|
||||
}
|
||||
|
||||
registry
|
||||
.category("debug")
|
||||
.category("default")
|
||||
.add("web_tour.startTour", startTour)
|
||||
.add("web_tour.disableTours", disableTours);
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { Dialog } from "@web/core/dialog/dialog";
|
||||
import { _lt } from "@web/core/l10n/translation";
|
||||
|
||||
import { Component } from "@odoo/owl";
|
||||
|
||||
export default class ToursDialog extends Component {
|
||||
setup() {
|
||||
this.tourService = useService("tour");
|
||||
this.onboardingTours = this.tourService.getOnboardingTours();
|
||||
this.testingTours = this.tourService.getTestingTours();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Handlers
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Resets the given tour to its initial step, in onboarding mode.
|
||||
*
|
||||
* @private
|
||||
* @param {MouseEvent} ev
|
||||
*/
|
||||
_onStartTour(ev) {
|
||||
this.tourService.reset(ev.target.dataset.name);
|
||||
this.props.close();
|
||||
}
|
||||
/**
|
||||
* Starts the given tour in test mode.
|
||||
*
|
||||
* @private
|
||||
* @param {MouseEvent} ev
|
||||
*/
|
||||
_onTestTour(ev) {
|
||||
this.tourService.run(ev.target.dataset.name);
|
||||
this.props.close();
|
||||
}
|
||||
}
|
||||
ToursDialog.template = "web_tour.ToursDialog";
|
||||
ToursDialog.components = { Dialog };
|
||||
ToursDialog.title = _lt("Tours");
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="web_tour.ToursDialog" owl="1">
|
||||
<Dialog title="this.constructor.title">
|
||||
<t t-call="web_tour.ToursDialog.Table">
|
||||
<t t-set="caption">Onboarding tours</t>
|
||||
<t t-set="tours" t-value="onboardingTours"/>
|
||||
</t>
|
||||
<t t-if="testingTours.length" t-call="web_tour.ToursDialog.Table">
|
||||
<t t-set="caption">Testing tours</t>
|
||||
<t t-set="tours" t-value="testingTours"/>
|
||||
</t>
|
||||
</Dialog>
|
||||
</t>
|
||||
|
||||
<t t-name="web_tour.ToursDialog.Table" owl="1">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-striped">
|
||||
<caption style="caption-side: top; font-size: 14px">
|
||||
<t t-esc="caption"/>
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sequence</th>
|
||||
<th width="50%">Name</th>
|
||||
<th width="50%">Path</th>
|
||||
<th>Start</th>
|
||||
<th>Test</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr t-foreach="tours" t-as="tour" t-key="tour.name">
|
||||
<td><t t-esc="tour.sequence"/></td>
|
||||
<td><t t-esc="tour.name"/></td>
|
||||
<td><t t-esc="tour.url"/></td>
|
||||
<td>
|
||||
<button type="button"
|
||||
class="btn btn-primary fa fa-play o_start_tour"
|
||||
t-on-click.prevent="_onStartTour"
|
||||
t-att-data-name="tour.name"
|
||||
aria-label="Start tour"
|
||||
title="Start tour"/>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button"
|
||||
class="btn btn-primary fa fa-cogs o_test_tour"
|
||||
t-on-click.prevent="_onTestTour"
|
||||
t-att-data-name="tour.name"
|
||||
aria-label="Test tour"
|
||||
title="Test tour"/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
Loading…
Add table
Add a link
Reference in a new issue