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

    <!-- ============================================================ -->
    <!--                   Writing Prompt Views                       -->
    <!-- ============================================================ -->

    <record id="view_writing_prompt_form" model="ir.ui.view">
        <field name="name">encoach.writing.prompt.form</field>
        <field name="model">encoach.writing.prompt</field>
        <field name="arch" type="xml">
            <form string="Writing Prompt">
                <sheet>
                    <group>
                        <group>
                            <field name="exam_type"/>
                            <field name="task"/>
                            <field name="writing_type"/>
                            <field name="min_words"/>
                        </group>
                        <group>
                            <field name="rubric_id"/>
                            <field name="visual_url" widget="url"/>
                            <field name="ai_generated"/>
                            <field name="approved"/>
                            <field name="ielts_certified"/>
                        </group>
                    </group>
                    <notebook>
                        <page string="Prompt" name="prompt">
                            <field name="prompt_text" widget="text" placeholder="Write the prompt instructions..."/>
                        </page>
                        <page string="Model Answer" name="model_answer">
                            <field name="model_answer" widget="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_writing_prompt_list" model="ir.ui.view">
        <field name="name">encoach.writing.prompt.list</field>
        <field name="model">encoach.writing.prompt</field>
        <field name="arch" type="xml">
            <list string="Writing Prompts" decoration-success="approved == True">
                <field name="exam_type"/>
                <field name="task"/>
                <field name="writing_type"/>
                <field name="min_words"/>
                <field name="rubric_id"/>
                <field name="approved"/>
            </list>
        </field>
    </record>

    <record id="view_writing_prompt_search" model="ir.ui.view">
        <field name="name">encoach.writing.prompt.search</field>
        <field name="model">encoach.writing.prompt</field>
        <field name="arch" type="xml">
            <search string="Search Writing Prompts">
                <field name="writing_type"/>
                <separator/>
                <filter string="Academic" name="filter_academic" domain="[('exam_type', '=', 'academic')]"/>
                <filter string="General Training" name="filter_general" domain="[('exam_type', '=', 'general_training')]"/>
                <separator/>
                <filter string="Task 1" name="filter_task1" domain="[('task', '=', 'task1')]"/>
                <filter string="Task 2" name="filter_task2" domain="[('task', '=', 'task2')]"/>
                <separator/>
                <filter string="Approved" name="filter_approved" domain="[('approved', '=', True)]"/>
                <filter string="Exam Type" name="group_exam_type" context="{'group_by': 'exam_type'}"/>
                <filter string="Task" name="group_task" context="{'group_by': 'task'}"/>
            </search>
        </field>
    </record>

    <record id="action_writing_prompt" model="ir.actions.act_window">
        <field name="name">Writing Prompts</field>
        <field name="res_model">encoach.writing.prompt</field>
        <field name="view_mode">list,form</field>
        <field name="search_view_id" ref="view_writing_prompt_search"/>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                Create your first writing prompt
            </p>
        </field>
    </record>

</odoo>
