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

    <!-- ============================================================ -->
    <!--                       Passage Views                          -->
    <!-- ============================================================ -->

    <record id="view_passage_form" model="ir.ui.view">
        <field name="name">encoach.passage.form</field>
        <field name="model">encoach.passage</field>
        <field name="arch" type="xml">
            <form string="Reading Passage">
                <sheet>
                    <div class="oe_title">
                        <h1>
                            <field name="topic_category" placeholder="Topic Category"/>
                        </h1>
                    </div>
                    <group>
                        <group>
                            <field name="exam_type"/>
                            <field name="section_num"/>
                            <field name="difficulty"/>
                            <field name="status"/>
                        </group>
                        <group>
                            <field name="cefr_level"/>
                            <field name="word_count"/>
                            <field name="ai_generated"/>
                            <field name="approved"/>
                            <field name="ielts_certified"/>
                        </group>
                    </group>
                    <notebook>
                        <page string="Body Text" name="body_text">
                            <field name="body_text" widget="text" placeholder="Paste or write the passage text..."/>
                        </page>
                        <page string="Validation" name="validation">
                            <group>
                                <field name="generation_brief"/>
                                <field name="validation_errors"/>
                            </group>
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>

    <record id="view_passage_list" model="ir.ui.view">
        <field name="name">encoach.passage.list</field>
        <field name="model">encoach.passage</field>
        <field name="arch" type="xml">
            <list string="Passages" decoration-success="approved == True" decoration-muted="status == 'retired'">
                <field name="topic_category"/>
                <field name="exam_type"/>
                <field name="difficulty"/>
                <field name="status"/>
                <field name="word_count"/>
                <field name="approved"/>
            </list>
        </field>
    </record>

    <record id="view_passage_search" model="ir.ui.view">
        <field name="name">encoach.passage.search</field>
        <field name="model">encoach.passage</field>
        <field name="arch" type="xml">
            <search string="Search Passages">
                <field name="topic_category"/>
                <separator/>
                <filter string="Academic" name="filter_academic" domain="[('exam_type', '=', 'academic')]"/>
                <filter string="General Training" name="filter_general" domain="[('exam_type', '=', 'general_training')]"/>
                <filter string="General English" name="filter_general_eng" domain="[('exam_type', '=', 'general_english')]"/>
                <separator/>
                <filter string="Draft" name="filter_draft" domain="[('status', '=', 'draft')]"/>
                <filter string="Active" name="filter_active" domain="[('status', '=', 'active')]"/>
                <filter string="Flagged" name="filter_flagged" domain="[('status', '=', 'flagged')]"/>
                <separator/>
                <filter string="Easy" name="filter_easy" domain="[('difficulty', '=', 'easy')]"/>
                <filter string="Medium" name="filter_medium" domain="[('difficulty', '=', 'medium')]"/>
                <filter string="Hard" name="filter_hard" domain="[('difficulty', '=', 'hard')]"/>
                <separator/>
                <filter string="Approved" name="filter_approved" domain="[('approved', '=', True)]"/>
                <filter string="Not Approved" name="filter_not_approved" domain="[('approved', '=', False)]"/>
                <filter string="Exam Type" name="group_exam_type" context="{'group_by': 'exam_type'}"/>
                <filter string="Status" name="group_status" context="{'group_by': 'status'}"/>
                <filter string="Difficulty" name="group_difficulty" context="{'group_by': 'difficulty'}"/>
            </search>
        </field>
    </record>

    <record id="action_passage" model="ir.actions.act_window">
        <field name="name">Passages</field>
        <field name="res_model">encoach.passage</field>
        <field name="view_mode">list,form</field>
        <field name="search_view_id" ref="view_passage_search"/>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                Create your first reading passage
            </p>
        </field>
    </record>

</odoo>
