<?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="action-builder-line-grid" title="Fields" model="com.axelor.studio.db.ActionBuilderLine" >
      <field name="name" />
      <field name="value" />
      <field name="conditionText" />
      <field name="filter" />
      <field name="dummy" />
  </grid>
  
  <form name="action-builder-line-form" title="Field" model="com.axelor.studio.db.ActionBuilderLine"
  	  onNew="action-builder-line-set-default-attrs" onLoad="action-builder-line-set-default-attrs">
      <panel name="mainPanel">
      	<field name="dummy"/>
      	<spacer name="dummySpacer"/>
      	<panel name="metaFieldsPanel" colSpan="6" itemSpan="12" hideIf="dummy">
      		<field name="metaJsonField" onSelect="action-action-builder-line-meta-json-field-domain" onChange="action-action-builder-line-set-name-json"/>
      		<field name="metaField" onSelect="action-action-builder-line-meta-field-domain" onChange="action-action-builder-line-set-name-meta"/>
      	</panel>
      	<panel name="valuePanel" colSpan="6" itemSpan="12" hideIf="dummy">
      		<field name="valueJson" onSelect="action-action-builder-line-value-json-domain" onChange="action-action-builder-line-set-src-field-json" />
      		<field name="valueField" onSelect="action-action-builder-line-value-field-domain" onChange="action-action-builder-line-set-src-field-meta" />
      	</panel>
      	<field name="name" showIf="dummy" colSpan="6" required="true" />
      	<field name="value" colSpan="12"/>
      	<field name="conditionText" hideIf="dummy" />
      	<field name="filter" showIf="!dummy &amp;&amp; (metaField.relationship != null || metaJsonField.targetModel != null || metaJsonField.targetJsonModel != null)"/>
      	<field name="metaJsonField.type" hidden="true" />
      	<field name="metaJsonField.targetJsonModel" hidden="true" />
      	<field name="metaJsonField.targetModel" hidden="true"/>
      	<field name="metaField.typeName" hidden="true" />
      	<field name="metaField.relationship" hidden="true" />
      	<field name="valueJson.type" hidden="true" />
      	<field name="valueJson.targetJsonModel" hidden="true" />
      	<field name="valueJson.targetModel" hidden="true"/>
      	<field name="valueField.typeName" hidden="true" />
      	<panel-related name="subLinesPanel" field="subLines" colSpan="12" hideIf="dummy" showIf="!dummy &amp;&amp; (metaField.relationship != null || metaJsonField.targetModel != null || metaJsonField.targetJsonModel != null)" grid-view="action-builder-line-grid" form-view="action-builder-line-form"/>
	  </panel>
  </form>
  
  <grid name="action-builder-line-simple-grid" title="Field" model="com.axelor.studio.db.ActionBuilderLine" editable="true" >
      <field name="name" title="Name" />
      <field name="value" />
  </grid>
  
  <form name="action-builder-line-simple-form" title="Field" model="com.axelor.studio.db.ActionBuilderLine">
  	  <panel name="mainPanel">
	      <field name="name" title="Name" />
	      <field name="value" />
      </panel>
  </form>
  
  <action-attrs name="action-action-builder-line-meta-json-field-domain">
  	<attribute name="domain" for="metaJsonField" expr="eval:&quot;self.jsonModel.name = '${_parent.model}'  and self.model = 'com.axelor.meta.db.MetaJsonRecord'&quot;" if="_parent.typeSelect == 1"/>
  	<attribute name="domain" for="metaJsonField" expr="eval:&quot;self.jsonModel.name = '${_parent.targetModel}'  and self.model = 'com.axelor.meta.db.MetaJsonRecord'&quot;" if="_parent.typeSelect == 0"/>
  	<attribute name="domain" for="metaJsonField" expr="eval:&quot;self.jsonModel.id = ${_parent.metaJsonField?.targetJsonModel?.id} and self.model = 'com.axelor.meta.db.MetaJsonRecord'&quot;" if="_parent._model == 'com.axelor.studio.db.ActionBuilderLine'"/>
  </action-attrs>
  
  <action-attrs name="action-action-builder-line-value-json-domain">
  	<attribute name="domain" for="valueJson" expr="eval:&quot;self.jsonModel.name = '${_parent.model}' and self.model = 'com.axelor.meta.db.MetaJsonRecord'&quot;"/>
  	<attribute name="domain" for="valueJson" expr="eval:&quot;self.jsonModel.id = ${_parent.valueJson?.targetJsonModel?.id} and self.model = 'com.axelor.meta.db.MetaJsonRecord'&quot;" if="_parent._model == 'com.axelor.studio.db.ActionBuilderLine'"/>
  </action-attrs>
  
  <action-attrs name="action-action-builder-line-meta-field-domain">
  	<attribute name="domain" for="metaField" expr="eval:&quot;self.metaModel.fullName = '${_parent.targetModel}'&quot;"  if="_parent.typeSelect == 0"/>
  	<attribute name="domain" for="metaField" expr="eval:&quot;self.metaModel.fullName = '${_parent.model}'&quot;"  if="_parent.typeSelect == 1"/>
  	<attribute name="domain" for="metaField" expr="eval:&quot;self.metaModel.fullName = '${_parent.metaJsonField?.targetModel}'&quot;" if="_parent.metaJsonField != null &amp;&amp; _parent._model == 'com.axelor.studio.db.ActionBuilderLine'"/>
  	<attribute name="domain" for="metaField" expr="eval:&quot;self.metaModel.name = '${_parent.metaField?.typeName}'&quot;" if="_parent.metaField != null &amp;&amp; _parent._model == 'com.axelor.studio.db.ActionBuilderLine'"/>
  </action-attrs>
  
  <action-attrs name="action-action-builder-line-value-field-domain">
    <attribute name="domain" for="valueField" expr="eval:&quot;self.metaModel.fullName = '${_parent.model}'&quot;" />
  	<attribute name="domain" for="valueField" expr="eval:&quot;self.metaModel.fullName = '${_parent.valueJson?.targetModel}'&quot;" if="_parent.valueJson != null &amp;&amp; _parent._model == 'com.axelor.studio.db.ActionBuilderLine'"/>
  	<attribute name="domain" for="valueField" expr="eval:&quot;self.metaModel.name = '${_parent.valueField?.typeName}'&quot;" if="_parent.valueField != null &amp;&amp; _parent._model == 'com.axelor.studio.db.ActionBuilderLine'"/>
  </action-attrs>
  
  <action-record name="action-action-builder-line-set-name-meta" model="com.axelor.studio.db.ActionBuilderLine">
  	<field name="name" expr="eval:metaField?.name"/>
  </action-record>
  
  <action-record name="action-action-builder-line-set-name-json" model="com.axelor.studio.db.ActionBuilderLine">
  	<field name="name" expr="eval:metaJsonField?.name"/>
  </action-record>
  
  <action-record name="action-action-builder-line-set-src-field-meta" model="com.axelor.studio.db.ActionBuilderLine">
  	<field name="value" expr="eval:valueField != null ? '$.' + valueField.name : null"/>
  </action-record>
  
  <action-record name="action-action-builder-line-set-src-field-json" model="com.axelor.studio.db.ActionBuilderLine">
  	<field name="value" expr="eval:valueJson != null ? '$.' + valueJson.name : null"/>
  </action-record>
  
  <action-attrs name="action-builder-line-set-default-attrs">
  	<attribute name="hidden" for="metaJsonField" expr="eval:true" if="_parent._model == 'com.axelor.studio.db.ActionBuilder' &amp;&amp; !_parent.isJson"/>
  	<attribute name="hidden" for="metaJsonField" expr="eval:true" if="_parent._model == 'com.axelor.studio.db.ActionBuilderLine' &amp;&amp; (_parent.metaField != null || _parent.metaJsonField?.targetModel != null)"/>
  	<attribute name="hidden" for="metaField" expr="eval:true" if="_parent._model == 'com.axelor.studio.db.ActionBuilder' &amp;&amp; _parent.isJson"/>
  	<attribute name="hidden" for="metaField" expr="eval:true" if="_parent._model == 'com.axelor.studio.db.ActionBuilderLine' &amp;&amp; _parent.metaField == null &amp;&amp; _parent.metaJsonField?.targetModel == null" />
  	<attribute name="hidden" for="valueJson" expr="eval:true" if="_parent._model == 'com.axelor.studio.db.ActionBuilder' &amp;&amp; !_parent.isJson"/>
  	<attribute name="hidden" for="valueJson" expr="eval:true" if="_parent._model == 'com.axelor.studio.db.ActionBuilderLine' &amp;&amp;(_parent.valueField != null || _parent.valueJson?.targetModel != null)"/>
  	<attribute name="hidden" for="valueField" expr="eval:true" if="_parent._model == 'com.axelor.studio.db.ActionBuilder' &amp;&amp; _parent.isJson"/>
  	<attribute name="hidden" for="valueField" expr="eval:true" if="_parent._model == 'com.axelor.studio.db.ActionBuilderLine' &amp;&amp; _parent.valueField == null &amp;&amp; _parent.valueJson?.targetModel == null"/>
  </action-attrs>
  
</object-views>


