<?xml version="1.0" encoding="UTF-8"?>

<templates>
    <t t-name="hr_calendar.CalendarCommonRendererHeader" t-inherit="web.CalendarCommonRendererHeader" t-inherit-mode="primary">
        <xpath expr="//span[hasclass('o_cw_day_number')]" position="after">
            <t t-if="scale != 'month'" t-call="hr_calendar.CalendarCommonRenderer.buttonWorklocation"/>
        </xpath>
    </t>

    <t t-name="hr_calendar.CalendarCommonRenderer.buttonWorklocation">
        <t t-if="multiCalendar">
            <t t-call="hr_calendar.MultiCalendarButtonWorkLocation"/>
        </t>
        <t t-else="">
            <t t-call="hr_calendar.SingleCalendarButtonWorkLocation"/>
        </t>
    </t>

    <div t-name="hr_calendar.MultiCalendarButtonWorkLocation" class="o_worklocation_btn my-2 opacity-75 w-100 d-flex align-items-center cursor-default">
        <div t-if="Object.keys(worklocation).length &gt; 0" class="d-flex gap-1 ms-1 flex-wrap w-75">
            <t t-set="iconClass" t-value="`o_homework_content d-flex align-items-center justify-content-center flex-wrap border border-1 rounded-circle me-0 fa`"/>
            <t t-if="scale === 'month'">
                <div class="o_homework_multi d-flex align-items-center gap-1 ms-1 w-100 overflow-hidden">
                    <t t-foreach="Object.keys(worklocation)" t-as="location" t-key="location">
                        <t t-foreach="worklocation[location]" t-as="wl" t-key="wl.id">
                            <div class="o_homeworking_content o_worklocation_action cursor-pointer" t-att-data-location="location" t-att-data-id="wl.id" t-att-data-employee="wl.employeeId">
                                <i t-att-title="wl.title" t-attf-class="{{iconClass}} {{iconMap[wl.icon] || 'fa-map-marker'}} o_worklocation_color_{{wl.colorIndex}} o_worklocation_outline_{{wl.colorIndex}}"/>
                            </div>
                        </t>
                        <span t-if="worklocation[location].length === 1 &amp;&amp; location.length === 1" class="fw-bolder me-3 text-truncate" t-out="worklocation[location][0].title"/>
                    </t>
                </div>
            </t>
            <t t-else="">
                <div t-foreach="Object.keys(worklocation)" t-as="location" t-key="location" class="o_homework_multi d-flex gap-1 ms-1 w-100">
                    <t t-foreach="worklocation[location]" t-as="wl" t-key="wl.id">
                        <div class="o_homeworking_content o_worklocation_action cursor-pointer" t-att-data-location="location" t-att-data-id="wl.id" t-att-data-employee="wl.employeeId">
                            <i t-att-title="wl.title" t-attf-class="{{iconClass}} {{iconMap[wl.icon] || 'fa-map-marker'}} o_worklocation_color_{{wl.colorIndex}} o_worklocation_outline_{{wl.colorIndex}}"/>
                        </div>
                    </t>
                    <span class="fw-bolder me-3 text-truncate" t-out="worklocation[location][0].title"/>
                </div>
            </t>
        </div>
        <div t-if="userFilterActive and !workLocationSetForCurrentUser" class="w-100 d-flex align-items-center opacity-0 opacity-100-hover o_worklocation_action cursor-pointer" data-create="1">
            <button class="o_worklocation_text d-flex justify-content-center align-items-center bg-info bg-opacity-25 border-0 rounded-pill px-lg-2 py-0 text-nowrap mw-100">
                <i class="add_wl fa fa-map-marker" title="Set location" aria-hidden="true"></i>
                <span t-if="Object.keys(worklocation).length &lt; 1" class="d-lg-inline fw-bold location_xs_hide ms-lg-1">Set<span class="d-none d-xl-inline"> Location</span></span>
            </button>
            <button t-if="Object.keys(worklocation).length &lt; 1" class="o_worklocation_line d-lg-block w-100 bg-info bg-opacity-25 border-0 p-0"/>
        </div>
    </div>

    <div t-name="hr_calendar.SingleCalendarButtonWorkLocation" class="o_worklocation_btn my-2 opacity-75 w-100 d-flex align-items-center">
        <div t-if="workLocationSetForCurrentUser" class="w-100 d-flex align-items-center o_worklocation_action cursor-pointer o_homework_single">
            <t t-if="worklocation.display">
                <button t-attf-class='o_worklocation_text mw-100 d-flex justify-content-center align-items-center align-items-center border-0 rounded-pill px-lg-2 py-0 text-nowrap o_worklocation_color_{{worklocation.colorIndex}} o_worklocation_outline_{{worklocation.colorIndex}}'>
                    <i t-attf-class="fa {{iconMap[worklocation.icon] || 'fa-map-marker'}} me-lg-1" aria-hidden="true"></i>
                    <span class="d-none d-lg-inline-block fw-bold text-truncate me-3" t-out="worklocation.title"/>
                </button>
                <button t-if="showLine" t-attf-class="o_worklocation_line d-lg-block w-100 border-0 p-0 o_worklocation_color_{{worklocation.colorIndex}}"/>
            </t>
            <t t-else="">
                <button t-if="showLine" t-attf-class="o_worklocation_line d-lg-block w-100 border-0 p-0 o_worklocation_color_{{worklocation.colorIndex}}"/>
            </t>
        </div>
        <div t-elif="userFilterActive" class="w-100 d-flex align-items-center opacity-0 opacity-100-hover o_worklocation_action cursor-pointer" data-create="1">
            <button class="o_worklocation_text d-flex justify-content-center align-items-center align-items-center bg-info bg-opacity-25 border-0 rounded-pill px-lg-2 py-0 text-nowrap">
                <i class="fa fa-map-marker me-1" aria-hidden="true"></i>
                <span class="d-lg-inline fw-bold">Set<span class="location_xs_hide"> Location</span></span>
            </button>
            <button t-if="showLine" class="o_worklocation_line d-lg-block w-100 bg-info bg-opacity-25 border-0 p-0"/>
        </div>
    </div>
</templates>
