<?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="alarm-engine-batch-grid" title="Alarm engine batches" model="com.axelor.apps.base.db.AlarmEngineBatch">
		<field name="code" x-bind="{{code|unaccent|uppercase}}" />
		<field name="metaModelSet" form-view="meta-model-form" grid-view="meta-model-grid"/>
		<field name="alarmEngineSet" grid-view="alarm-engine-grid" form-view="alarm-engine-form" />
	</grid>

	<form name="alarm-engine-batch-form" title="Alarm engine" model="com.axelor.apps.base.db.AlarmEngineBatch" width="large">
		<toolbar>
			<button name="runBtn" title="Run" onClick="save,alarm-engine-batch-method-run" />
		</toolbar>
		<panel name="mainPanel" x-stack="true">
			<field name="code" x-bind="{{code|unaccent|uppercase}}"  colSpan="4" onChange="action-base-batch-condition-check-unique-code"/>
		</panel>
		<panel-tabs name="mainPanelTab">
			<panel name="configurationPanel" title="Configuration">
				<panel-related name="metaModelSetPanel" field="metaModelSet" colSpan="12" form-view="meta-model-form" grid-view="meta-model-grid"/>
				<panel-related name="alarmEngineSetPanel" field="alarmEngineSet" onSelect="alarm-engine-batch-attrs-alarm-engine-domain" colSpan="12" grid-view="alarm-engine-grid" form-view="alarm-engine-form" />
			</panel>
			<panel name="batchesPanel" title="Batches">
				<field name="description" showTitle="false" colSpan="12" />
				<panel-related name="batchListPanel" field="batchList" colSpan="12" form-view="batch-form" grid-view="batch-grid" readonly="true" />
			</panel>
		</panel-tabs>
	</form>

	<action-method name="alarm-engine-batch-method-run">
		<call class="com.axelor.apps.base.web.AlarmEngineBatchController" method="launch" />
	</action-method>

	<action-attrs name="alarm-engine-batch-attrs-alarm-engine-domain">
		<attribute name="domain" for="alarmEngineSet" if="metaModelSet ?: false"
			expr="eval: &quot;self.externalOk = false AND self.metaModel.id IN (${metaModelSet?.collect{it.id}?.join(',')})&quot;" />
	</action-attrs>

</object-views>