[MIG] web_time_range_menu_custom: Migration to 15.0

This commit is contained in:
Carlos Roca
2023-03-22 16:54:19 +01:00
parent a2f20904b8
commit ab4dd9a465
19 changed files with 605 additions and 702 deletions

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-inherit="web.ComparisonMenu" t-inherit-mode="extension" owl="1">
<xpath expr="//t[@t-foreach='items']" position="after">
<DropdownItemCustomPeriod comparisonItems="items" type="'comparison'" />
</xpath>
</t>
</templates>

View File

@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="web_time_range_menu_custom.DropdownItemCustomPeriod" owl="1">
<div class="o_menu_item dropdown-item" data-id="__computed__">
<a href="#" role="menuitem" t-on-click="onClickCustomPeriod">
Custom period
<span class="o_submenu_switcher" data-id="__computed__">
<span
t-att-class="isOpen.value ? 'fa fa-caret-down' : 'fa fa-caret-right'"
/>
</span>
</a>
<t t-if="isOpen.value">
<div id="add_custom_period_wrapper" class="d-table">
<div class="d-table-row" t-if="props.type === 'comparison'">
<div class="d-table-cell">
<select
id="field_comparison"
class="o_input o_date_field_selector"
t-model="field.value"
>
<t
t-foreach="fields_selected"
t-as="field_item"
t-key="field_item"
>
<option t-att-value="field_item"><span
t-esc="env.searchModel.searchItems[field_item].description"
/></option>
</t>
</select>
</div>
</div>
<div class="d-table-row">
<div class="d-table-cell" style="width: 50%">
<input
type="number"
min="0"
id="period_quantity"
class="o_input"
t-model="quantity.value"
/>
</div>
<div class="d-table-cell">
<select
id="period_type"
class="o_input o_date_field_selector"
t-model="type.value"
>
<option value="day">Day</option>
<option value="week">Week</option>
<option value="month">Month</option>
<option value="year">Year</option>
</select>
</div>
</div>
<div class="d-table-row">
<div class="d-table-cell">
<button
class="btn btn-primary o_add_computed_measure"
type="button"
t-on-click="onClickAdd"
>Add</button>
</div>
</div>
</div>
</t>
</div>
</t>
</templates>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-inherit="web.FilterMenu" t-inherit-mode="extension" owl="1">
<xpath
expr="//t[@t-if='item.options']//t[@t-foreach='item.options']"
position="after"
>
<t t-if="item.type === 'dateFilter'">
<DropdownItemCustomPeriod field="item" type="'filter'" />
</t>
</xpath>
</t>
</templates>

View File

@@ -1,53 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<template>
<t t-name="web_time_range_menu_custom.CustomZone">
<div class="d-flex">
<input type="number" min="1" t-att-id="field_value" class="o_input" />
<select t-att-id="field_type" class="o_input o_date_field_selector">
<option value="days">Day</option>
<option value="weeks">Week</option>
<option value="months">Month</option>
<option value="years">Year</option>
</select>
</div>
</t>
<t t-extend="web.TimeRangeMenu">
<t
t-jquery="div.dropdown-item-text:has(#time_range_selector)"
t-operation="after"
>
<div class="dropdown-item-text d-none" id="time_range_selector_custom">
<t t-call="web_time_range_menu_custom.CustomZone">
<t
t-set="field_value"
t-value="'date_field_selector_custom_value'"
/>
<t t-set="field_type" t-value="'date_field_selector_custom_type'" />
</t>
</div>
</t>
<t
t-jquery="div.dropdown-item-text:has(.o_comparison_checkbox)"
t-operation="after"
>
<div
class="dropdown-item-text d-none"
id="comparison_time_range_selector_custom"
>
<t t-call="web_time_range_menu_custom.CustomZone">
<t
t-set="field_value"
t-value="'date_field_selector_comparison_custom_value'"
/>
<t
t-set="field_type"
t-value="'date_field_selector_comparison_custom_type'"
/>
</t>
</div>
</t>
</t>
</template>