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

<templates>

    <t t-name="project.SubtaskKanbanList">
        <t t-if="props.record.displaySubtasks">
            <div class="subtask_list">
                <div t-foreach="closedList" t-as="record" t-key="record.id"  class="subtask_list_row">
                    <a t-attf-class="subtask_name_col {{ ['1_done', '1_canceled'].includes(record.data.state) ? 'text-muted opacity-50' : '' }}"
                        t-att-title="record.data.display_name"
                        t-esc="record.data.display_name"
                        t-on-click.prevent="() => this.goToSubtask(record.resId)"/>
                    <Field
                        class="`o_field_many2many_avatar_user subtask_user_widget_col d-inline-flex align-items-center justify-content-end me-1 ${['1_done', '1_canceled'].includes(record.data.state) ? 'opacity-50' : ''}`"
                        name="'user_ids'"
                        record="record"
                        readonly="false"
                        isEditable="true"
                        type="'kanban.many2many_avatar_user'"/>
                    <Field name="'state'"
                        class="`subtask_state_widget_col d-flex justify-content-center align-items-center`"
                        record="record"
                        type="'project_task_state_selection'"
                        fieldInfo="fieldInfo.state"/>
                </div>
                <div class="subtask_create" t-on-click.stop="(ev) => this.onSubTaskCreated(ev)"
                    t-on-keydown="(ev) => ev.code === 'Escape' ? this._onBlur(ev) : ()=>{}">
                    <t t-if="subtaskCreate.open">
                        <SubtaskCreate
                            name="subtaskCreate.name"
                            isReadonly="props.isReadonly" 
                            onSubtaskCreateNameChanged.bind="_onSubtaskCreateNameChanged"
                            onBlur.bind="_onBlur" />
                    </t>
                    <t t-else="">
                        <i class="fa fa-plus my-2"/> Add Sub-task
                    </t>
                </div>
            </div>
        </t>
    </t>

</templates>
