<?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">
	
	<grid name="appraisal-grid" title="Appraisals" model="com.axelor.apps.talent.db.Appraisal">
		<field name="employee" />
		<field name="company" if="__config__.app.getApp('base').getEnableMultiCompany()"/>
		<field name="appraisalType" />
		<field name="toDate" />
		<field name="reviewerEmployee" />
		<field name="statusSelect" />
	</grid>
	
	<grid name="appraisal-template-grid" title="Appraisal templates" model="com.axelor.apps.talent.db.Appraisal">
		<field name="company" if="__config__.app.getApp('base').getEnableMultiCompany()"/>
		<field name="appraisalType" />
		<field name="toDate" />
		<field name="reviewerEmployee" />
	</grid>
	
	<form name="appraisal-form" title="Appraisal" model="com.axelor.apps.talent.db.Appraisal" width="large">
		<panel name="actionPanel">
			<field name="statusSelect" colSpan="8"  widget="NavSelect" showTitle="false" />
			<panel name="subActionPanel" colSpan="4" stacked="true">
				<button name="sendAppraisalBtn" title="Send" showIf="statusSelect == 0" onClick="save,action-appraisal-method-send-appraisal"/>
				<button name="realizeAppraisalBtn" title="Realize" showIf="statusSelect == 1" css="btn-success" onClick="save,action-appraisal-method-realize-appraisal"/>
				<button name="cancelAppraisalBtn" title="Cancel" showIf="statusSelect &lt; 2" css="btn-danger" onClick="save,action-appraisal-method-cancel-appraisal"/>
				<button name="draftAppraisalBtn" title="Draft" showIf="statusSelect == 3" onClick="save,action-appraisal-method-draft-appraisal"/>
			</panel>
		</panel>
		<panel name="detailPanel">
			<field name="employee" required="true" canView="false" onChange="action-appraisal-record-set-company-employee-onchange"/>
			<field name="company" canEdit="false" canNew="false"/>
			<field name="appraisalType" canEdit="false" canNew="false"/>
			<field name="toDate" />
			<field name="reviewerEmployee" canEdit="false" canNew="false"/>
			<field name="description" colSpan="12" widget="html"/>
			<field name="attrs" colSpan="12"/>
		</panel>
		<panel-mail name="mailPanel">
		  <mail-messages limit="4" />
		  <mail-followers />
	    </panel-mail>
	</form>
	
	<form name="appraisal-template-form" title="Appraisal template" model="com.axelor.apps.talent.db.Appraisal" width="large" onNew="action-appraisal-template-defaults">
		<panel name="mainPanel">
			<field name="company" />
			<field name="appraisalType" />
			<field name="toDate" />
			<field name="reviewerEmployee" />
			<field name="description" colSpan="12" widget="html"/>
			<field name="attrs" colSpan="12"/>
			<button name="openEmployeeSelectBtn" title="Create Appraisals" onClick="save,action-appraisal-template-open-employee-selection" colSpan="3" />
			<field name="isTemplate" hidden="true" />
		</panel>
	</form>
	
	<form name="appraisal-employee-select-form" title="Create Appraisals(Select Employees)" model="com.axelor.apps.talent.db.Appraisal"
		onNew="action-appraisal-employee-select-default" width="large">
		<panel name="mainPanel">
			<field name="$employeeSet" type="many-to-many" colSpan="12" target="com.axelor.apps.hr.db.Employee" title="Employees"/>
			<field name="sendAppraisals" type="boolean" title="Send" colSpan="2"/>
			<button name="createAppraisalsBtn" title="Create" onClick="action-appraisal-template-method-create-appraisals" showIf="$employeeSet.length > 0" colSpan="3"/>
			<field name="templateId" type="long" hidden="true" />
		</panel>
	</form>
	
	<calendar name="appraisal-calendar" model="com.axelor.apps.talent.db.Appraisal" eventStart="toDate" title="Appraisals" colorBy="statusSelect">
		<field name="employee"/>
	</calendar>
	
	<action-method name="action-appraisal-method-send-appraisal">
		<call class="com.axelor.apps.talent.web.AppraisalController" method="send"/>
	</action-method>
	
	<action-method name="action-appraisal-method-realize-appraisal">
		<call class="com.axelor.apps.talent.web.AppraisalController" method="realize"/>
	</action-method>
	
	<action-method name="action-appraisal-method-cancel-appraisal">
		<call class="com.axelor.apps.talent.web.AppraisalController" method="cancel"/>
	</action-method>
	
	<action-method name="action-appraisal-method-draft-appraisal">
		<call class="com.axelor.apps.talent.web.AppraisalController" method="draft"/>
	</action-method>
	
	<action-view name="action-appraisal-template-open-employee-selection" model="com.axelor.apps.talent.db.Appraisal" title="Create Appraisal(Select Employees)">
		<view type="form" name="appraisal-employee-select-form"/>
		<view-param name="popup" value="reload"/>
		<view-param name="popup-save" value="false"/>
		<view-param name="show-toolbar" value="false" />
		<view-param name="show-confirm" value="false"/>
		<context name="_templateId" expr="eval:id"/>
	</action-view>
	
	<action-method name="action-appraisal-template-method-create-appraisals">
		<call class="com.axelor.apps.talent.web.AppraisalController" method="createAppraisals" />
	</action-method>
	
	<action-record name="action-appraisal-employee-select-default" model="com.axelor.apps.talent.db.Appraisal">
		<field name="templateId" expr="eval:_templateId"/>
	</action-record>
	
	<action-record name="action-appraisal-template-defaults" model="com.axelor.apps.talent.db.Appraisal">
		<field name="isTemplate" expr="eval:true"/>
	</action-record>
	
	<action-record name="action-appraisal-record-set-company-employee-onchange" model="com.axelor.apps.talent.db.Appraisal">
		<field name="company" expr="eval:employee?.mainEmploymentContract?.payCompany"/>
	</action-record>
	

	<search-filters name="appraisal-fitlers" model="com.axelor.apps.talent.db.Appraisal" title="Appraisal filters">
		<filter title="New appraisal">
			<domain>self.isTemplate = false and self.statusSelect = 0</domain>
		</filter>
		<filter title="Upcoming appraisal">
			<domain>self.isTemplate = false and self.statusSelect = 1</domain>
		</filter>
		<filter title="My upcoming appraisal">
			<domain>self.employee.user.id = :_userId and self.isTemplate = false and self.statusSelect = 1</domain>
		</filter>
		<filter title="My completed appraisals">
			<domain>self.employee.user.id = :_userId and self.isTemplate = false and self.statusSelect = 2</domain>
		</filter>
		<filter title="Upcoming appraisals of all employees of a team">
			<domain>self.employee.user.id in :_teamUserIds and self.isTemplate = false and self.statusSelect = 1</domain>
		</filter>
		<filter title="Completed trainings of all employees of a team">
			<domain>self.employee.user.id in :_teamUserIds and self.isTemplate = false and self.statusSelect = 2</domain>
		</filter>
	</search-filters>
	
</object-views>
