<?php
/**
 * Copyright © 2016 maijindou.com All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>

<?php
/** @var $block \Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Webapi */
?>

<?php echo $block->getChildHtml(); ?>

<fieldset class="fieldset form-inline entry-edit">
    <legend class="legend">
        <span><?php /* @escapeNotVerified */ echo __('Available APIs') ?></span>
    </legend><br />

    <div class="field">
        <label class="label" for="all_resources"><span><?php /* @escapeNotVerified */ echo __('Resource Access') ?></span></label>

        <div class="control">
            <select id="all_resources" name="all_resources" onchange="jQuery('[data-role=tree-resources-container]').toggle()" class="select">
                <option value="0" <?php echo($block->isEverythingAllowed() ? '' : 'selected="selected"'); ?>><?php /* @escapeNotVerified */ echo __('Custom') ?></option>
                <option value="1" <?php echo($block->isEverythingAllowed() ? 'selected="selected"' : ''); ?>><?php /* @escapeNotVerified */ echo __('All') ?></option>
            </select>
        </div>
    </div>

    <div class="field<?php if ($block->isEverythingAllowed()):?> no-display<?php endif?>" data-role="tree-resources-container">
        <label class="label"><span><?php /* @escapeNotVerified */ echo __('Resources') ?></span></label>

        <div class="control">
            <div class="tree x-tree" data-role="resource-tree" data-mage-init='<?php
            echo $block->escapeHtml($this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode([
                'rolesTree' => [
                    "treeInitData" => $block->getTree(),
                    "treeInitSelectedData" => $block->getSelectedResources(),
                ],
            ]));
            ?>'></div>
        </div>
    </div>
</fieldset>
