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

    <record id="signifyd_case_form_view" model="ir.ui.view">
        <field name="name">signifyd.form.view</field>
        <field name="model">signifyd.case</field>
        <field name="arch" type="xml">
            <form string="Signifyd Case" class="o_signifyd_case">
                <header>
                    <button name="action_force_update_case" type="object"
                            string="Force Update" class="oe_highlight"/>
                </header>
                <sheet>
                    <field name="score" invisible="1"/>
                    <div class="oe_button_box" name="button_box">
                        <field name="score" invisible="1"/>
                        <button class="oe_stat_button text-success" icon="fa-flag-checkered"
                                attrs="{'invisible': [('score', '&lt;=', 600)]}">
                            <field string="Score" name="score" widget="statinfo"/>
                        </button>
                        <button class="oe_stat_button text-warning" icon="fa-flag"
                                attrs="{'invisible': [ '|', ('score', '&gt;', 600), ('score', '&lt;', 300)]}">
                            <field string="Score" name="score" widget="statinfo"/>
                        </button>
                        <button class="oe_stat_button text-danger" icon="fa-flag"
                                attrs="{'invisible': [('score', '&gt;', 300)]}">
                            <field string="Score" name="score" widget="statinfo"/>
                        </button>

                    </div>
                    <div class="oe_title">
                        <h1>
                            <field name="name" readonly="1"/>
                        </h1>
                        <field name="signifyd_url" widget="url"/>
                    </div>

                    <group>
                        <group>
                            <field name="checkpoint_action"/>
                            <field name="last_update"/>
                            <field name="uuid"/>
                            <field name="case_id"/>
                            <field name="status"/>
                            <field name="order_outcome"/>
                            <field name="review_disposition"/>
                            <field name="guarantee_disposition"/>
                            <field name="disposition_reason"/>
                        </group>

                    </group>
                </sheet>
            </form>
        </field>
    </record>


    <record id="action_signifyd_case_form" model="ir.actions.act_window">
        <field name="name">Signifyd Case Information</field>
        <field name="res_model">signifyd.case</field>
        <field name="view_mode">form</field>
        <field name="view_id" ref="website_sale_signifyd.signifyd_case_form_view"/>
    </record>

    <record id="signifyd_connector_form_view" model="ir.ui.view">
        <field name="name">signifyd.form.view</field>
        <field name="model">signifyd.connector</field>
        <field name="arch" type="xml">
            <form string="Signifyd Connector" class="o_signifyd_connector">
                <header>
                    <button name="action_register_webhooks" type="object"
                            string="Register Webhooks" class="oe_highlight"
                            attrs="{'invisible': [('webhooks_registered', '=', True)]}"/>
                    <button name="action_register_webhooks" type="object"
                            string="Re-register Webhooks"
                            attrs="{'invisible': [('webhooks_registered', '=', False)]}"/>
                </header>
                <sheet>

                    <div name="status_box">
                        <field name="webhooks_registered" invisible="1"/>
                        <div class="text-success float-right"
                             attrs="{'invisible': [('webhooks_registered', '=', False)]}">
                            <i class="fa fa-check-square" title="Webhooks Active"/>
                            <strong>
                                Webhooks Active
                            </strong>
                        </div>
                        <div class="text-danger float-right"
                             attrs="{'invisible': [('webhooks_registered', '=', True)]}">
                            <i class="fa fa-square" title="Webhooks Inactive"/>
                            <strong>
                                Webhooks Inactive
                            </strong>
                        </div>
                    </div>
                    <div class="oe_title">
                        <label for="test_mode"/>
                        <field name="test_mode"/>
                        <h1>
                            <field name="name"/>
                        </h1>
                    </div>

                    <group>
                        <group>
                            <field name="secret_key" attrs="{'invisible': [('test_mode', '=', True)]}"/>
                            <field name="secret_key_test" attrs="{'invisible': [('test_mode', '!=', True)]}"/>
                            <field name="signifyd_case_type" />
                            <p class="text-muted">
                                Optional: Add users to be notified if a sale order is declined by Signifyd.
                            </p>
                            <field name="notify_user_ids" widget="many2many_tags"/>
                            <field name="website_ids" widget="many2many_tags"/>
                        </group>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

    <record id="signifyd_connector_tree_view" model="ir.ui.view">
        <field name="name">signifyd.tree.view</field>
        <field name="model">signifyd.connector</field>
        <field name="arch" type="xml">
            <tree string="Signifyd Connectors">
                <field name="name"/>
                <field name="test_mode"/>
                <field name="webhooks_registered"/>
            </tree>
        </field>
    </record>

    <record id="action_signifyd_connector" model="ir.actions.act_window">
        <field name="name">Signifyd Connectors</field>
        <field name="res_model">signifyd.connector</field>
        <field name="view_mode">tree,form</field>
    </record>

    <menuitem
        name="Signifyd"
        parent="website.menu_website_global_configuration"
        action="action_signifyd_connector"
        id="menu_action_signifyd_connector"
        sequence="10" />

</odoo>