<?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 name="mail-account-form" id="base-mail-account-form" title="Mail account" model="com.axelor.apps.message.db.EmailAccount"
    	onNew="action-mail-account-default-record" onSave="action-mail-account-method-check-default-mail-account,action-method-mail-account-validate-password">
    	<panel name="informationsPanel" title="Informations" >
            <field name="name" />
			<field name="isDefault" onChange="action-mail-account-method-check-default-mail-account" />
        	<field name="signature" widget="Html" x-lite="true" height="7" colSpan="12"/>
        </panel>
        <panel name="configPanel" title="Configurations" readonlyIf="isValid">
        	<field name="serverTypeSelect" onChange="action-mail-account-onchange-security-select"/>
        	<field name="host"/>
        	<field name="securitySelect" onChange="action-mail-account-onchange-security-select"/>
        	<field name="port"/>
        </panel>
        <panel name="loginPanel" title="Login" readonlyIf="isValid" >
       	 	<field name="login"/>
        	<field name="change" title="Change password?" showIf="id &amp;&amp; !$readonly()" widget="boolean"/>
        	<panel name="passwordPanel" colSpan="12" showIf="change || !id">
		        <field name="newPassword" title="Password" placeholder="new password" widget="password" requiredIf="!id || change" validIf="(!change &amp;&amp; id) || confirm == newPassword"/>
		    	<field name="confirm" title="Confirm" placeholder="confirm password" widget="password"/>
		    	<field name="password" hidden="true"/>
		    </panel>
        </panel>
		<panel name="userPanel" title="User" sidebar="true" if="__config__.app.getApp('base').getEmailAccountByUser()">
        	<field name="user" required="true" showTitle="false" colSpan="12" form-view="user-form" grid-view="user-grid" canNew="false" canEdit="false" canView="false"/>
		</panel>
		<panel name="actionsPanel" sidebar="true" >
			<button name="testConnectionBtn" onClick="save,action-method-mail-account-validate-password,save,action-method-mail-account-validate,save" title="Test connection" colSpan="10"/>
			<field name="isValid" colSpan="2" readonlyIf="!isValid"/>
			<spacer name="isValidSpacer"/>
			<button name="fetchEmailsBtn" onClick="save,action-mail-account-metho-fetch-emails" title="Fetch emails" showIf="isValid &amp;&amp; serverTypeSelect != null &amp;&amp; serverTypeSelect &gt; 1"/>
		</panel>
    </form>
    
	<action-record name="action-mail-account-default-record" model="com.axelor.apps.message.db.EmailAccount">
    	<field name="user" expr="eval:__user__" if="__config__.app.getApp('base').getEmailAccountByUser()"/>
    </action-record>
    
</object-views>
