odoo18/addons/lunch/static/src/components/lunch_dashboard.xml

213 lines
8.8 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="lunch.LunchCurrency">
<div class="text-end d-flex" >
<span class="col-4" t-if="props.currency.position == 'before'" t-esc="props.currency.symbol"/>
<span class="col-8" t-esc="amount"/>
<span class="col-4" t-if="props.currency.position == 'after'" t-esc="props.currency.symbol"/>
</div>
</t>
<t t-name="lunch.LunchOrderLine">
<tr>
<td class="text-center">
<span
t-if="canEdit"
type="button"
class="btn btn-sm btn-icon btn-link fa fa-minus-circle px-0"
t-on-click="() => this.updateQuantity(-1)"/>
<span
t-else=""
type="button"
class="btn btn-sm btn-icon btn-link disabled fa fa-minus-circle px-0"/>
</td>
<td t-esc="line.quantity" class="text-center"/>
<td class="text-center">
<span
t-if="canAdd"
type="button"
class="btn btn-sm btn-icon btn-link fa fa-plus-circle px-0"
t-on-click="() => this.updateQuantity(1)"/>
<span
t-else=""
type="button"
class="btn btn-sm btn-icon btn-link disabled fa fa-plus-circle px-0"/>
</td>
<td
t-if="canEdit"
t-esc="line.product[1]"
t-on-click="() => props.openOrderLine(line.product[0], line.id)"
role="button"
title="Edit order"/>
<td t-else="" t-esc="line.product[1]"/>
<td>
<span t-esc="line.state" t-attf-class="badge rounded-pill text-bg-#{badgeClass} border-#{badgeClass}" style="vertical-align: bottom;"/>
</td>
<td t-esc="line.location"/>
<td t-esc="line.date" class="mx-4"/>
<td>
<LunchCurrency currency="props.currency" amount="line.product[2]"/>
</td>
</tr>
<t t-if="hasToppings" t-foreach="line.toppings" t-as="topping" t-key="topping">
<tr>
<td/>
<td/>
<td/>
<td class="lunch_topping" t-esc="topping[0]"/>
<td/>
<td/>
<td/>
<td>
<LunchCurrency currency="props.currency" amount="topping[1]"/>
</td>
</tr>
</t>
<tr t-if="line.note">
<td/>
<td/>
<td/>
<td t-esc="line.note" class="text-muted"/>
</tr>
</t>
<t t-name="lunch.LunchAlerts">
<div class="alert alert-warning mb-0" t-if="props.alerts.length !== 0" role="alert">
<t t-foreach="props.alerts" t-as="alert" t-key="alert.id">
<LunchAlert message="alert.message" />
</t>
</div>
</t>
<t t-name="lunch.LunchUser">
<div class="lunch_user pb-1">
<span t-if="!props.isManager" t-esc="props.username"/>
<Many2XAutocomplete
t-else=""
value="props.username"
resModel="'res.users'"
getDomain="getDomain"
fieldString="props.username"
activeActions="{}"
update.bind="props.onUpdateUser"
/>
</div>
</t>
<t t-name="lunch.LunchLocation">
<div class="lunch_location pb-1">
<t t-if="props.location">
<Many2XAutocomplete
value="props.location"
resModel="'lunch.location'"
fieldString="props.location"
getDomain="getDomain"
activeActions="{}"
update.bind="props.onUpdateLunchLocation"
/>
</t>
<t t-else="">
<p>No lunch location available.</p>
</t>
</div>
</t>
<t t-name="lunch.LunchDashboardOrder">
<LunchAlerts alerts="state.infos.alerts"/>
<div class="o_lunch_banner container-fluid mt-3 mt-md-0 py-md-4 bg-view">
<div class="row row-gap-3 h-100">
<div class="col-12 col-lg-3">
<div class="d-flex gap-2 align-content-center h-100">
<div>
<img class="o_image_64_cover rounded" t-att-src="state.infos.userimage"/>
</div>
<div class="w-100">
<LunchUser
isManager="state.infos.is_manager"
username="state.infos.username"
onUpdateUser.bind="onUpdateUser"/>
<LunchLocation
location="location"
onUpdateLunchLocation.bind="onUpdateLunchLocation"/>
<div id="lunch_order_date">
<DateTimeInput
type="'date'"
placeholder.translate="Today"
onChange.bind="onUpdateLunchTime"/>
</div>
<div class="d-flex pb-1">
<span class="flex-grow-1">Your Account</span>
<span>
<LunchCurrency currency="currency" amount="state.infos.wallet"/>
</span>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6" t-if="hasLines">
<h4 class="">
Your Order
<button
t-if="(['new', 'ordered'].includes(state.infos.raw_state))"
class="btn btn-sm btn-icon btn-link fa fa-trash"
t-on-click.prevent="emptyCart"/>
</h4>
<table class="o_lunch_widget_lines w-100">
<t t-foreach="state.infos.lines" t-as="line" t-key="line.id">
<LunchOrderLine line="line" currency="currency" onUpdateQuantity.bind="onUpdateQuantity" openOrderLine.bind="props.openOrderLine" infos="state.infos"/>
</t>
</table>
</div>
<div class="col-12 col-lg-2 offset-lg-1 d-flex flex-column row-gap-1" t-if="hasLines">
<span class="d-flex flex-row text-muted">
<span class="flex-grow-1 column-gap-1">
Total
</span>
<span class="col-5">
<LunchCurrency currency="currency" amount="state.infos.total"/>
</span>
</span>
<span class="d-flex column-gap-1 text-muted">
<span class="flex-grow-1">
Already Paid
</span>
<span class="col-5">
<LunchCurrency currency="currency" amount="state.infos.paid_subtotal"/>
</span>
</span>
<h4 class="d-flex column-gap-1 mt-auto">
<span class="flex-grow-1">
To Pay
</span>
<span class="col-5">
<LunchCurrency currency="currency" amount="state.infos.unpaid_subtotal"/>
</span>
</h4>
<button class="btn btn-primary" t-if="canOrder" t-on-click="orderNow">Order Now</button>
</div>
</div>
</div>
</t>
<t t-name="lunch.LunchDashboard">
<t t-set="currency" t-value="state.infos.currency"/>
<t t-if="!env.isSmall">
<t t-call="lunch.LunchDashboardOrder"/>
</t>
<t t-else="">
<details class="fixed-bottom mh-100 bg-view p-2 overflow-y-auto" t-att-open="state.mobileOpen">
<summary class="btn btn-primary w-100" t-on-click="() => state.mobileOpen = !state.mobileOpen">
<i class="fa fa-fw fa-shopping-cart"/>
Your Cart (<LunchCurrency currency="currency" amount="state.infos.total || 0"/>)
</summary>
<t t-call="lunch.LunchDashboardOrder"/>
</details>
</t>
</t>
</templates>