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

// @codingStandardsIgnoreFile

/** @var $block \Magento\Swatches\Block\Adminhtml\Attribute\Edit\Options\Text */

$stores = $block->getStoresSortedBySortOrder();
?>
<fieldset class="fieldset">
    <legend class="legend"><span><?php /* @escapeNotVerified */ echo __('Manage Swatch (Values of Your Attribute)') ?></span></legend>
    <div id="swatch-text-options-panel">
        <table class="data-table clearfix" cellspacing="0">
            <thead>
            <tr id="swatch-text-options-table">
                <th class="col-draggable"></th>
                <th class="col-default"><span><?php /* @escapeNotVerified */ echo __('Is Default') ?></span></th>
                <?php foreach ($stores as $_store): ?>
                    <?php if ($_store->getId() != \Magento\Store\Model\Store::DEFAULT_STORE_ID): ?>
                    <th class="col-swatch col-<%- data.id %>"><span><?php /* @escapeNotVerified */ echo __('Swatch'); ?></span></th>
                    <?php endif; ?>
                    <th<?php if ($_store->getId() == \Magento\Store\Model\Store::DEFAULT_STORE_ID): ?> class="_required"<?php endif; ?>>
                        <span><?php /* @escapeNotVerified */ echo $_store->getName() ?></span>
                    </th>
                <?php endforeach; ?>
                <?php $colTotal = count($stores) * 2 + 3; ?>
                <th class="col-delete">&nbsp;</th>
            </tr>
            </thead>
            <tbody data-role="swatch-text-options-container" class="ignore-validate"></tbody>
            <tfoot>
            <tr>
                <th colspan="<?php echo (int)$colTotal; ?>">
                    <input type="hidden" class="required-text-swatch-entry" name="text_swatch_validation"/>
                </th>
            </tr>
            <tr>
                <th colspan="<?php /* @escapeNotVerified */ echo $colTotal; ?>" class="col-actions-add">
                    <?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()):?>
                        <button id="add_new_swatch_text_option_button" title="<?php /* @escapeNotVerified */ echo __('Add Swatch'); ?>"
                                type="button" class="action- scalable add">
                            <span><?php /* @escapeNotVerified */ echo __('Add Swatch'); ?></span>
                        </button>
                    <?php endif; ?>
                </th>
            </tr>
            </tfoot>
        </table>
        <input type="hidden" id="swatch-text-option-count-check" value="" />
    </div>
    <script id="swatch-text-row-template" type="text/x-magento-template">
        <tr>
            <td class="col-draggable">
                <?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()): ?>
                    <div data-role="draggable-handle" class="draggable-handle" title="<?php /* @escapeNotVerified */ echo __('Sort Option'); ?>"></div>
                <?php endif; ?>
                <input data-role="order" type="hidden" name="optiontext[order][<%- data.id %>]"  value="<%- data.sort_order %>" <?php if ($block->getReadOnly() || $block->canManageOptionDefaultOnly()): ?> disabled="disabled"<?php endif; ?>/>
            </td>
            <td class="col-default">
                <input class="input-radio" type="<%- data.intype %>" name="defaulttext[]" value="<%- data.id %>" <%- data.checked %><?php if ($block->getReadOnly()):?>disabled="disabled"<?php endif;?>/>
            </td>
            <?php foreach ($stores as $_store): ?>
                <?php if ($_store->getId() != \Magento\Store\Model\Store::DEFAULT_STORE_ID): ?>
                <td class="col-swatch col-<%- data.id %>">
                    <input class="input-text swatch-text-field-<?php /* @escapeNotVerified */ echo $_store->getId() ?> <?php if ($_store->getId() == \Magento\Store\Model\Store::DEFAULT_STORE_ID): ?>required-option<?php endif; ?>" name="swatchtext[value][<%- data.id %>][<?php /* @escapeNotVerified */ echo $_store->getId() ?>]" type="text" value="<%- data.swatch<?php /* @escapeNotVerified */ echo $_store->getId() ?> %>" />
                </td>
                <?php endif; ?>
                <td class="swatch-col-<%- data.id %>">
                    <input name="optiontext[value][<%- data.id %>][<?php /* @escapeNotVerified */ echo $_store->getId() ?>]" value="<%- data.store<?php /* @escapeNotVerified */ echo $_store->getId() ?> %>" class="input-text<?php if ($_store->getId() == \Magento\Store\Model\Store::DEFAULT_STORE_ID): ?> required-option<?php endif; ?>" type="text" <?php if ($block->getReadOnly() || $block->canManageOptionDefaultOnly()):?> disabled="disabled"<?php endif;?>/>
                </td>
            <?php endforeach; ?>
            <td id="delete_button_swatch_container_<%- data.id %>" class="col-delete">
                <input type="hidden" class="delete-flag" name="optiontext[delete][<%- data.id %>]" value="" />
                <?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()):?>
                    <button title="<?php /* @escapeNotVerified */ echo __('Delete') ?>" type="button"
                            class="action- scalable delete delete-option"
                        >
                        <span><?php /* @escapeNotVerified */ echo __('Delete') ?></span>
                    </button>
                <?php endif;?>
            </td>
        </tr>
    </script>
    <script type="text/x-magento-init">
        {
            "*": {
                "Magento_Swatches/js/text": <?php /* @escapeNotVerified */ echo $block->getJsonConfig(); ?>
            }
        }
    </script>
</fieldset>
