{extends $parent}

{block css append}
   <style>
      .edit_list_item { overflow: visible !important; }

.chosen-container-multi .chosen-choices li.search-field {
   width: auto !important;
}

   </style>
{/block}

{block "js-entry" append}
    {encore_entry_script_tags entry='listEdit' build='admin'}
    {$isEditing = true}
{/block}

{block "js" append}
   <script src="/admin/static/js/wpj.actions.modal.js"></script>
{/block}

{block content}
   <form method="post" class="massEditForm">
       {$smarty.block.parent}
   </form>
    <script>
      $('select[name="selectedAction"]').change(function (e) {
         const $trigger = $(this);
         const action = $(this).val();
         if (action == -1000) {
            return;
         }

         openActionConfig($trigger, action, '{$filtersStorage.listName}');

         $('#saveBtn').attr('data-dismiss', "modal")
         $('#saveBtn').val('Uložit');

         $('#saveBtn').click(function (e) {
            e.preventDefault();
            if (typeof CKEDITOR !== 'undefined') {
               $.each(CKEDITOR.instances, function () {
                  this.updateElement();
               });
            }
            const formData = $('#modalForm').serialize();

            $('#actionsConfig').val(formData);
         });
      });
   </script>
{/block}


{block 'list-rows' prepend}
   <tr>
       {$table = $object->getTableDef()}

       {foreach $table.fields as $column}
          {if $column.visible == 'N'}{continue}{/if}
          <td class="editFirstRow">
             <div class="list_item {if $column.fieldType}edit_list_item{/if}">
                 {if $column.fieldType}
                     {$object->printListFirstRowItem($column)}
                 {elseif $column@iteration == 1}
                    <b>Upravit vše</b>
                 {else}
                    -
                 {/if}

             </div>
          </td>
       {/foreach}

   </tr>
{/block}

{block "list-filter-item"}{/block}

{block bottomPagination}
   <div class="pagination-sticky">
       {call paginationList pager=$pager}

      <div class="pagination-buttons">
         {block bottomPaginationDivide}
            <div style="width: 100px">
               <input type="hidden" name="divide_url" value="{$pager->getUrl(['divide' => 0])}">
                {print_select name="divide_items" var=$divide.items selected=$divide.item param='data-width="auto"'}
            </div>
         {/block}

          {block "list-filter-mass-edit"}
             <div class="filter-item filter-item-border">
                <a title="Zrušit změny" href="{$pager->getUrl(['s'=>'list.php'])}{if $listQueryString}&{$listQueryString}{/if}"
                   class="btn btn-danger"> Zrušit změny
                </a>
             </div>
          {/block}

         <div>
            <input type="hidden" name="acn" value="save">
            <input type="submit" name="submitMassEdit" value="Uložit" class="btn btn-success">
         </div>
      </div>
   </div>
{/block}

{block js_autoreload}
{/block}
