control_panel.xml 6.06 KB
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2021 Sergey Shebanin
     License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<templates>
    <t t-inherit="web.ControlPanel" t-inherit-mode="extension" owl="1">
        <xpath expr="//nav[hasclass('o_cp_switch_buttons')]" position="replace">
            <nav
                t-if="props.views.length gt 1"
                class="btn-group o_cp_switch_buttons"
                role="toolbar"
                aria-label="View switcher"
            >
                <t
                    t-set="collapse_switchview"
                    t-value="device.size_class &lt;= device.SIZES.LG"
                />
                <button
                    t-if="collapse_switchview"
                    class="btn btn-link btn-sm"
                    data-toggle="dropdown"
                    aria-expanded="false"
                >
                    <span
                        t-attf-class="fa fa-lg o_switch_view o_{{ env.view.type }} {{ props.views.filter(view => view.type === env.view.type)[0].icon }}"
                    />
                </button>
                <ul
                    t-if="collapse_switchview"
                    class="dropdown-menu dropdown-menu-right list-inline"
                >
                    <li t-foreach="props.views" t-as="view" t-key="view.type">
                        <t t-call="web.ViewSwitcherButton" />
                    </li>
                </ul>
                <t
                    t-if="!collapse_switchview"
                    t-foreach="props.views"
                    t-as="view"
                    t-key="view.type"
                >
                    <t t-call="web.ViewSwitcherButton" />
                </t>
            </nav>
        </xpath>
        <xpath expr="//div[hasclass('o_searchview')]" position="replace">
            <div
                t-if="props.withSearchBar"
                class="o_searchview"
                t-att-class="state.mobileSearchMode == 'quick' ? 'o_searchview_quick' : 'o_searchview_mobile'"
                role="search"
                aria-autocomplete="list"
                t-on-click.self="state.mobileSearchMode = device.isMobile ? 'quick' : ''"
            >
                <t t-if="!device.isMobile">
                    <i
                        class="o_searchview_icon fa fa-search"
                        title="Search..."
                        role="img"
                        aria-label="Search..."
                    />
                    <SearchBar fields="fields" />
                </t>
                <t t-if="device.isMobile and state.mobileSearchMode == 'quick'">
                    <button
                        class="btn btn-link fa fa-arrow-left"
                        t-on-click.stop="state.mobileSearchMode = ''"
                    />
                    <SearchBar fields="fields" />
                    <button
                        class="btn fa fa-filter"
                        t-on-click.stop="state.mobileSearchMode = 'full'"
                    />
                </t>
                <t
                    t-if="device.isMobile and state.mobileSearchMode == 'full'"
                    t-call="web_responsive.MobileSearchView"
                />
                <t t-if="device.isMobile and state.mobileSearchMode == ''">
                    <button
                        class="btn btn-link fa fa-search"
                        t-on-click.stop="state.mobileSearchMode = 'quick'"
                    />
                </t>
            </div>
        </xpath>
        <xpath expr="//div[hasclass('o_cp_top_left')]" position="attributes">
            <attribute
                name="t-att-class"
                t-translation="off"
            >device.isMobile and state.mobileSearchMode == 'quick' ? 'o_hidden' : ''</attribute>
        </xpath>
        <xpath expr="//div[hasclass('o_search_options')]" position="attributes">
            <attribute name="t-if" t-translation="off">!device.isMobile</attribute>
            <attribute
                name="t-att-class"
                t-translation="off"
            >device.size_class == device.SIZES.MD ? 'o_search_options_hide_labels' : ''</attribute>
        </xpath>
    </t>
    <t t-name="web_responsive.MobileSearchView" owl="1">
        <div class="o_mobile_search">
            <div class="o_mobile_search_header">
                <span
                    class="o_mobile_search_close float-left mt16 mb16 mr8 ml16"
                    t-on-click.stop="state.mobileSearchMode = 'quick'"
                >
                    <i class="fa fa-arrow-left" />
                    <strong class="float-right ml8">FILTER</strong>
                </span>
                <span
                    class="float-right o_mobile_search_clear_facets mt16 mr16"
                    t-on-click.stop="model.dispatch('clearQuery')"
                >
                    <t>CLEAR</t>
                </span>
            </div>
            <SearchBar fields="fields" />
            <div class="o_mobile_search_filter o_search_options mb8 mt8 ml16 mr16">
                <FilterMenu
                    t-if="props.searchMenuTypes.includes('filter')"
                    class="o_filter_menu"
                    fields="fields"
                />
                <GroupByMenu
                    t-if="props.searchMenuTypes.includes('groupBy')"
                    class="o_group_by_menu"
                    fields="fields"
                />
                <ComparisonMenu
                    t-if="props.searchMenuTypes.includes('comparison') and model.get('filters', f => f.type === 'comparison').length"
                    class="o_comparison_menu"
                />
                <FavoriteMenu
                    t-if="props.searchMenuTypes.includes('favorite')"
                    class="o_favorite_menu"
                />
            </div>
            <div
                class="btn btn-primary o_mobile_search_show_result fixed-bottom"
                t-on-click.stop="state.mobileSearchMode = ''"
            >
                <t>SEE RESULT</t>
            </div>
        </div>
    </t>
</templates>