<?php
$form->prepare();
$escape = $this->plugin('escapeHtml');
$this->headScript()->appendFile($this->assetUrl('js/sortable.js', 'Omeka'));
$this->headScript()->appendFile($this->assetUrl('js/resource-template-form.js', 'Omeka'));
?>

<?php echo $this->form()->openTag($form); ?>

<div id="page-actions">
    <?php if (isset($resourceTemplate)): ?>
    <a href="#" class="delete button sidebar-content" data-sidebar-selector="#delete"><?php echo $this->translate('Delete'); ?></a>
    <?php endif; ?>
    <button><?php echo $escape($submitLabel); ?></button>
</div>
<?php $this->trigger("view.$action.form.before", ['form' => $form]); ?>
<?php echo $this->formCollection($form, false); ?>

<ul id="properties" data-add-new-property-row-url="<?php echo $escape($this->url(null, ['action' => 'add-new-property-row'], true)); ?>">
    <li>
        <div class="property-heading" id="original-label"><?php echo $this->translate('Label'); ?></div>
        <div class="property-heading" id="alternate-label"><?php echo $this->translate('Alternate Comment'); ?></div>
        <div class="property-heading" id="alternate-comment"><?php echo $this->translate('Data Type'); ?></div>
    </li>
    <?php foreach ($propertyRows as $propertyRow): ?>
    <?php echo $this->partial(
        'omeka/admin/resource-template/show-property-row',
        ['propertyRow' => $propertyRow]
    ) ?>
    <?php endforeach; ?>
</ul>
<?php $this->trigger("view.$action.form.after", ['form' => $form]); ?>
<?php echo $this->form()->closeTag(); ?>

<?php echo $this->propertySelector(); ?>
<?php if (isset($resourceTemplate)): ?>
    <?php echo $this->deleteConfirm($resourceTemplate, 'resource template'); ?>
<?php endif; ?>

<div id="details" class="sidebar">
    <a href="#"
        class="sidebar-close o-icon-close"
        aria-label="<?php echo $escape($this->translate('Close')); ?>"
        title="<?php echo $escape($this->translate('Close')); ?>"></a>
    <div class="sidebar-content"></div>
</div>
