<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php
$_element = $block->getElement();
$note = $_element->getNote() ? '<div class="note">' . $_element->getNote() . '</div>' : '';
$_elementBeforeLabel = $_element->getExtType() == 'checkbox' || $_element->getExtType() == 'radio';
$addOn = $_element->getBeforeElementHtml() || $_element->getAfterElementHtml();
$entity = $_element->getEntityAttribute();
$fieldId = ($_element->getHtmlContainerId()) ? ' id="' . $_element->getHtmlContainerId() . '"' : '';
$fieldClass = "admin__field field field-{$_element->getId()} {$_element->getCssClass()}";
$fieldClass .= ($_elementBeforeLabel) ? ' choice' : '';
$fieldClass .= ($addOn) ? ' with-addon' : '';
$fieldClass .= ($_element->getRequired()) ? ' _required' : '';
$fieldClass .= ($note) ? ' with-note' : '';
$fieldClass .= ($entity && $entity->getIsUserDefined()) ? ' user-defined type-' . $entity->getFrontendInput() : '';
$fieldAttributes = $fieldId . ' class="' . $fieldClass . '" '. $block->getUiId('form-field', $_element->getId());
$_elementToggleCode = $_element->getToggleCode() ? $_element->getToggleCode(): 'toggleValueElements(this, this.parentNode.parentNode.parentNode)';

?>
<?php $block->checkFieldDisable() ?>
<div class="rule-tree">
    <fieldset id="<?php echo $_element->getHtmlId() ?>" <?php /* @escapeNotVerified */ echo $_element->serialize(['class']) ?> class="fieldset">
        <legend class="legend"><span><?php /* @escapeNotVerified */ echo $_element->getLegend() ?></span></legend>
        <br>
    <?php if ($_element->getComment()): ?>
        <div class="messages">
            <div class="message message-notice"><?php echo $block->escapeHtml($_element->getComment()) ?></div>
        </div>
    <?php endif; ?>
    <div class="rule-tree-wrapper">
        <?php echo $_element->getChildrenHtml() ?>
    </div>
    </fieldset>
	
	<div class="field-service" value-scope="<?php /* @escapeNotVerified */ echo $block->getScopeLabel()?>">
		<?php if ($block->canDisplayUseDefault()): ?>
			<label for="<?php echo $_element->getHtmlId() ?>_default" class="choice use-default">
				<input <?php if ($_element->getReadonly()):?> disabled="disabled"<?php endif; ?>
						type="checkbox"
						name="use_default[]"
						class="use-default-control"
						id="<?php echo $_element->getHtmlId() ?>_default"
						<?php if ($block->usedDefault()): ?> checked="checked"<?php endif; ?>
						onclick="<?php /* @escapeNotVerified */ echo $_elementToggleCode; ?>"
						value="<?php /* @escapeNotVerified */ echo $block->getAttributeCode() ?>"/>
				<span class="use-default-label"><?php /* @escapeNotVerified */ echo __('Use Default Value') ?></span>
			</label>
		<?php endif; ?>
	</div>
	
</div>
<script>
require([
    "Magento_Rule/rules",
    "prototype"
], function(VarienRulesForm){

window.<?php echo $_element->getHtmlId() ?> = new VarienRulesForm('<?php echo $_element->getHtmlId() ?>', '<?php /* @escapeNotVerified */ echo $block->getNewChildUrl() ?>');
<?php if ($_element->getReadonly()): ?>
    <?php echo $_element->getHtmlId() ?>.setReadonly(true);
<?php endif; ?>
});
</script>
