<?xml version="1.0"?>
<odoo>

    <!-- History Tree view -->
    <record model="ir.ui.view" id="view_wiki_history_tree">
        <field name="name">document.page.history.tree</field>
        <field name="model">document.page.history</field>
        <field name="arch" type="xml">
            <tree string="Document History">
                <field name="id"/>
                <field name="page_id"/>
                <field name="summary"/>
                <field name="create_uid"/>
                <field name="create_date"/>
            </tree>
        </field>
    </record>

    <!-- History Search view  -->
    <record id="view_wiki_history_filter" model="ir.ui.view">
        <field name="name">document.page.history.search</field>
        <field name="model">document.page.history</field>
        <field name="arch" type="xml">
            <search string="Document Page History">
                <field name="page_id"/>
                <field name="content"/>
                <field name="create_uid"/>
                <group expand="0" string="Group By...">
                    <filter name="group_author" string="Author" context="{'group_by':'create_uid'}" />
                </group>
            </search>
        </field>
    </record>

    <!-- History Form view  -->
    <record model="ir.ui.view" id="wiki_history_form">
        <field name="name">document.page.history.form</field>
        <field name="model">document.page.history</field>
        <field name="arch" type="xml">
            <form string="Document Page History">
                <sheet>
                    <h1><field name="page_id"/></h1>
                    <group>
                        <group>
                            <field name="create_uid" readonly="1"/>
                            <field name="create_date" readonly="1"/>
                        </group>
                    </group>
                    <notebook>
                        <page name="content" string="Content">
                            <label for="summary"/>
                            <field name="summary" placeholder="eg: Changed ... for ..."/>
                            <label for="content"/>
                            <field name="content" widget="html" placeholder="e.g. Once upon a time..." options="{'safe': True}"/>
                        </page>
                        <page name="diff" string="Changes">
                            <field name="diff" widget="html" style="overflow-x: scroll" />
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>

    <!-- History Action  -->
    <record model="ir.actions.act_window" id="action_history">
        <field name="name">Page history</field>
        <field name="res_model">document.page.history</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>

    <menuitem id="menu_page_history"
        parent="menu_wiki"
        name="Pages history"
        action="action_history"
        sequence="30"
        groups="base.group_no_one" />

    <act_window id="action_related_page_history"
        context="{'search_default_page_id': [active_id], 'default_page_id': active_id}"
        domain="[('page_id','=',active_id)]"
        name="Page History"
        res_model="document.page.history"
        src_model="document.page"/>


</odoo>
