<?xml version="1.0" encoding="UTF-8"?>
<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 model="com.axelor.apps.base.db.DataBackup" title="Create Backup"
		name="data-create-backup-grid">
		<field name="statusSelect" />
		<field name="backupMetaFile" widget="binary-link" />
		<field name="backupDate" />
	</grid>

	<form model="com.axelor.apps.base.db.DataBackup" title="Create Backup"
		name="data-create-backup-form" onNew="data.create.backup.load.today.date"
		width="large">
		<panel name="mainPanel">
			<field name="statusSelect" readonly="true" widget="NavSelect"
				selection-in="[0,1,2]" colSpan="12" />
			<field name="fetchLimit" widget="Integer" required="true" min="1"
				colSpan="4" />
			<field name="isRelativeDate" widget="boolean-switch"  onChange="action-data-backup-attrs-onchange-relativedate" colSpan="2"/>
			<field name="updateImportId" widget="boolean-switch" showIf="isRelativeDate"  colSpan="2"/>
			<spacer colSpan="4"/>
			<button-group name="mainBtnGroup" colSpan="3">
			<button name="backToDraftBtn" title="Return to draft status"
				showIf="backupMetaFile != null &amp;&amp; statusSelect == 1"
				colSpan="4" onClick="data.create.backup.set.draft.status" />
			<button name="createBtn" title="Create"
				showIf="backupMetaFile == null &amp;&amp; statusSelect != 1"
				colSpan="4" onClick="save,action.data.backup.call.createbackup,save" />
			</button-group>
			<spacer name="btnGrpSpacer" colSpan="12"/>
			<field name="backupMetaFile" readonly="true" widget="binary-link"
				colSpan="4" />
			<field name="backupDate" readonly="true" colSpan="4" />
		</panel>
	</form>

	<grid model="com.axelor.apps.base.db.DataBackup" title="Restore Backup"
		name="data-restore-backup-grid">
		<field name="statusSelect" />
		<field name="backupMetaFile" widget="binary-link" />
		<field name="restoreDate" />
	</grid>

	<form model="com.axelor.apps.base.db.DataBackup" title="Restore Backup"
		name="data-restore-backup-form" width="mid"
		onNew="data.restore.backup.load.today.date">
		<panel>
			<field name="statusSelect" selection-in="[0,1,3,4]" readonly="true"
				widget="NavSelect" colSpan="12" />
			<field name="backupMetaFile" required="true"
				domain="self.fileName LIKE '%.zip'" colSpan="3" widget="binary-link"/>
			<button name="restoreBtn" title="Restore"
				showIf="backupMetaFile != null &amp;&amp; statusSelect != 2"
				onClick="save,action.data.backup.call.restorebackup,save" colSpan="3" />
			<spacer name="restoreBtnSpacer" />
			<field name="restoreDate" readonly="true" colSpan="3" />
			<field name="logMetaFile" readonly="true" widget="binary-link"
				colSpan="3" />
		</panel>
	</form>

	<action-record name="data.create.backup.load.today.date"
		model="com.axelor.apps.base.db.DataBackup">
		<field name="backupDate" expr="eval: __datetime__" />
		<field name="fetchLimit" expr="100" />
	</action-record>

	<action-record name="data.restore.backup.load.today.date"
		model="com.axelor.apps.base.db.DataBackup">
		<field name="restoreDate" expr="eval: __datetime__" />
	</action-record>

	<action-record name="data.create.backup.set.draft.status"
		model="com.axelor.apps.base.db.DataBackup">
		<field name="statusSelect" expr="0" />
		<field name="backupMetaFile" expr="" />
	</action-record>

	<action-method name="action.data.backup.call.createbackup">
		<call class="com.axelor.apps.base.web.DataBackupController"
			method="CreateBackUp" />
	</action-method>

	<action-method name="action.data.backup.call.restorebackup">
		<call class="com.axelor.apps.base.web.DataBackupController"
			method="RestoreBackUp" />
	</action-method>
	
	<action-attrs name="action-data-backup-attrs-onchange-relativedate">
		<attribute name="value" for="updateImportId" expr="false" if="!isRelativeDate"/>
	</action-attrs>

</object-views>