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

<!--

    Copyright (c) 2017-2019 MuK IT GmbH.

    This file is part of MuK Documents 
    (see https://mukit.at).

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program. If not, see <http://www.gnu.org/licenses/>.

  -->

<odoo>

<record id="view_dms_tag_search" model="ir.ui.view">
	<field name="name">muk_dms_tag.search</field>
	<field name="model">muk_dms.tag</field>
    <field name="arch" type="xml">
        <search string="Categories">
            <field name="name" filter_domain="[('name', 'ilike', self)]" />
            <filter string="All" name="all" domain="['|', ('active', '=', False), ('active', '=', True)]" />
            <group expand="0" name="group_by" string="Group By">
                <filter name="group_by_category" string="Category" domain="[]" context="{'group_by': 'category'}"/>
                <filter name="group_by_color" string="Color" domain="[]" context="{'group_by': 'color'}"/>
            </group>
        </search>
    </field>
</record>

<record id="view_dms_tag_kanban" model="ir.ui.view">
	<field name="name">muk_dms_tag.kanban</field>
	<field name="model">muk_dms.tag</field>
	<field name="arch" type="xml">
		<kanban class="o_kanban_small_column o_emphasize_colors" on_create="quick_create" >
			<field name="color" />
			<templates>
				<t t-name="kanban-box">
					<div t-attf-class="#{kanban_color(record.color.raw_value)} oe_kanban_global_click">
						<div class="o_dropdown_kanban dropdown">
						    <a class="dropdown-toggle o-no-caret btn" href="#" role="button" data-toggle="dropdown" aria-label="Dropdown menu" title="Dropdown menu">
						        <span class="fa fa-ellipsis-v"/>
						    </a>
						    <div class="dropdown-menu" role="menu">
						    	<a role="menuitem" type="open" class="dropdown-item">
									<i class="fa fa-external-link" /> Open
								</a>
						        <a role="menuitem" type="edit" class="dropdown-item">
									<i class="fa fa-pencil-square-o" /> Edit
								</a>
						        <a role="menuitem" type="delete" class="dropdown-item">
									<i class="fa fa-trash-o" /> Delete
								</a>
                                <ul class="oe_kanban_colorpicker" data-field="color"/>
							</div>
					    </div>

						<field name="name" />
					</div>
				</t>
			</templates>
		</kanban>
	</field>
</record>			
					
<record id="view_dms_tag_tree" model="ir.ui.view">
	<field name="name">muk_dms_tag.tree</field>
	<field name="model">muk_dms.tag</field>
	<field name="arch" type="xml">
		<tree string="Tags">
			<field name="active" />
			<field name="name" />
			<field name="category" />
			<field name="color" widget="color_index" />
		</tree>
	</field>
</record>

<record id="view_dms_tag_form" model="ir.ui.view">
	<field name="name">muk_dms_tag.form</field>
	<field name="model">muk_dms.tag</field>
	<field name="arch" type="xml">
		<form string="Tag">
			<sheet>
			    <div class="oe_button_box" name="button_box">
			        <button name="toggle_active" type="object" class="oe_stat_button" icon="fa-bell">
			            <field name="active" widget="boolean_button"/>
			        </button>
			    </div>
		        <div class="oe_title">
		            <label for="name" class="oe_edit_only"/>
		            <h1>
		            	<field name="name" placeholder="Customer"/>
		            </h1>
		        </div>
		        <group>
			        <group>
						<field name="category" />
						<field name="color" widget="color_index" />
			        </group>
			        <group>
						<field name="count_files" string="Files" />
						<field name="count_directories" string="Directories" />
			        </group>
		        </group>
		        <notebook>
		        	<page string="Directories">
		        		<field name="directories" widget="one2many" mode="tree" />
		        	</page>
		        	<page string="Files">
		        		<field name="files" widget="one2many" mode="tree" />
		        	</page>
		        </notebook>
        	</sheet>
		</form>
	</field>
</record>

<record id="action_dms_tag" model="ir.actions.act_window">
	<field name="name">Tags</field>
	<field name="res_model">muk_dms.tag</field>
	<field name="view_mode">kanban,tree,form</field>
	<field name="context">{'search_default_group_by_category': 1}</field>
	<field name="help" type="html">
	    <p class="o_view_nocontent_smiling_face">
	      	Click to create a new tag.
	    </p>
	    <p>
			Tags are used to categorize Documents. 
	    </p>
    </field>
</record>

<menuitem id="menu_dms_tag" name="Tags"
	parent="cat_menu_muk_dms_config_organizing" 
	action="action_dms_tag" />

</odoo>
