<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<object-views xmlns="http://axelor.com/xml/ns/object-views"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://axelor.com/xml/ns/object-views http://axelor.com/xml/ns/object-views/object-views_5.2.xsd">

	<form model="com.axelor.apps.crm.db.RecurrenceConfiguration" title="Recurrence assistant" name="recurrence-assistant-form" 
    	onNew="action-recurrence-assistant-on-new, action-recurrence-assistant-method-compute-recurrence-name"
    	onLoad="action-recurrence-assistant-method-compute-recurrence-name">
    	<panel name="mainPanel" >
    		<field name="recurrenceType" title="Recurrence" colSpan="12" width="25%" onChange="action-recurrence-assistant-attrs-title-period, action-recurrence-assistant-method-compute-recurrence-name"/>
    		<field name="periodicity" title="Repeat every" min="1" colSpan="3" onChange="action-recurrence-assistant-method-compute-recurrence-name"/>
    		<label name="periodLabel" title="Days" colSpan="9"/>
    		<label name="repeatLabel" title="Repeat the:" colSpan="2" hidden="true" showIf="recurrenceType == 2"/>
    		<field name="sunday" title="Su" css="small center" hidden="true" showIf="recurrenceType == 2" colSpan="1" onChange="action-recurrence-assistant-method-compute-recurrence-name"/>
    		<field name="monday" title="Mo" css="small center" hidden="true" showIf="recurrenceType == 2" colSpan="1" onChange="action-recurrence-assistant-method-compute-recurrence-name"/>
    		<field name="tuesday" title="Tu" css="small center" hidden="true" showIf="recurrenceType == 2" colSpan="1" onChange="action-recurrence-assistant-method-compute-recurrence-name"/>
    		<field name="wednesday" title="We" css="small center" hidden="true" showIf="recurrenceType == 2" colSpan="1" onChange="action-recurrence-assistant-method-compute-recurrence-name"/>
    		<field name="thursday" title="Th" css="small center" hidden="true" showIf="recurrenceType == 2" colSpan="1" onChange="action-recurrence-assistant-method-compute-recurrence-name"/>
    		<field name="friday" title="Fr" css="small center" hidden="true" showIf="recurrenceType == 2" colSpan="1" onChange="action-recurrence-assistant-method-compute-recurrence-name"/>
    		<field name="saturday" title="Sa" css="small center" hidden="true" showIf="recurrenceType == 2" colSpan="1" onChange="action-recurrence-assistant-method-compute-recurrence-name"/>
    		<field name="monthRepeatType" title="Repeat every:" selection="crm.event.recurrence.month.repeat.type" hidden="true" showIf="recurrenceType == 3" widget="RadioSelect" css="small" colSpan="12" onChange="action-recurrence-assistant-method-compute-recurrence-name"/>
    		<field name="startDate" title="Start date" readonly="true" colSpan="12"/>
    		<field name="endType" colSpan="3" title="End" selection="crm.event.recurrence.end.type" widget="RadioSelect" css="small" onChange="action-recurrence-assistant-method-compute-recurrence-name"/>
    		<panel name="otherDetailsPanel" colSpan="6">
    			<field name="repetitionsNumber" min="1" title="Repetitions number" hidden="true" showIf="endType == 1" colSpan="12" onChange="action-recurrence-assistant-method-compute-recurrence-name"/>
    			<field name="endDate" title="End date" hidden="true" showIf="endType == 2" colSpan="12" onChange="action-recurrence-assistant-method-compute-recurrence-name"/>
    		</panel>
    		<field name="recurrenceName" showTitle="false" colSpan="12" css="bold" readonly="true"/>
    	</panel>
    	<panel name="deletePanel" sidebar="true" hidden="true" showIf="id &gt; 0">
    		<button name="modifToAllBtn" title="Apply modifications for all" onClick="save, action-recurrence-assistant-method-change-all"/>
    		<button name="deleteThisBtn" title="Delete only this event" onClick="action-recurrence-assistant-method-delete-this"/>
    		<button name="deleteNextBtn" title="Delete this and next events" onClick="action-recurrence-assistant-method-delete-next"/>
    		<button name="deleteAllBtn" title="Delete all events" onClick="action-recurrence-assistant-method-delete-all"/>
    	</panel>
    </form>
	
	<action-record name="action-recurrence-assistant-on-new" model="com.axelor.apps.crm.db.RecurrenceConfiguration">
		<field name="recurrenceType" expr="1"/>
		<field name="periodicity" expr="1"/>
		<field name="endType" expr="1"/>
		<field name="startDate" expr="eval: _parent?.startDateTime"/>
		<field name="monthRepeatType" expr="1"/>
		<field name="repetitionsNumber" expr="1"/>
	</action-record>
	
	<action-attrs name="action-recurrence-assistant-attrs-title-period">
		<attribute name="title" for="periodLabel" expr="eval: com.axelor.i18n.I18n.get('Days')" if="recurrenceType == 1"/>
		<attribute name="title" for="periodLabel" expr="eval: com.axelor.i18n.I18n.get('Weeks')" if="recurrenceType == 2"/>
		<attribute name="title" for="periodLabel" expr="eval: com.axelor.i18n.I18n.get('Months')" if="recurrenceType == 3"/>
		<attribute name="title" for="periodLabel" expr="eval: com.axelor.i18n.I18n.get('Years')" if="recurrenceType == 4"/>
	</action-attrs>
	
	<action-method name="action-recurrence-assistant-method-delete-this">
		<call class="com.axelor.apps.crm.web.EventController" method="deleteThis"/>
	</action-method>
	
	<action-method name="action-recurrence-assistant-method-delete-next">
		<call class="com.axelor.apps.crm.web.EventController" method="deleteNext"/>
	</action-method>
	
	<action-method name="action-recurrence-assistant-method-delete-all">
		<call class="com.axelor.apps.crm.web.EventController" method="deleteAll"/>
	</action-method>
	
	<action-method name="action-recurrence-assistant-method-change-all">
		<call class="com.axelor.apps.crm.web.EventController" method="changeAll"/>
	</action-method>
	
	<action-method name="action-recurrence-assistant-method-compute-recurrence-name">
		<call class="com.axelor.apps.crm.web.EventController" method="computeRecurrenceName"/>
	</action-method>
	
</object-views>