<%
  define_admin_breadcrumbs do
    add_admin_breadcrumb('轮播图')
  end
%>

<div class="card mb-5 carousels-card">
  <div class="card-header d-flex justify-content-between align-items-center">
    <span class="flex-1">顶部轮播图<span class="text-secondary font-12">（拖动排序）</span></span>
    <%= javascript_void_link '添加', class: 'btn btn-primary btn-sm add-btn', data: { toggle: 'modal', target: '.admin-add-weapp-carousel-modal' } %>
  </div>
  <div class="card-body row" id="carousels-container" data-laboratory-id="<%= current_laboratory.id %>">
    <% @carousels.each_with_index do |carousel, index| %>
      <div class="col-12 custom-carousel-item custom-carousel-item-<%= carousel.id %>" data-id="<%= carousel.id %>">
        <div class="border rounded relative p-3 mb-3 drag row align-items-center <%= carousel.online? ? '' : 'not_active' %>">
          <div class="col-2 col-md-1 custom-carousel-item-no"><%= index + 1 %></div>
          <div class="col-10 col-md-3 custom-carousel-item-img" data-source-id="<%= carousel.id %>" data-source-type="WeappSettings::Carousel" data-toggle="modal" data-target=".admin-upload-file-modal">
            <img src="<%= Util::FileManage.exists?(carousel) ? Util::FileManage.source_disk_file_url(carousel) : '' %>" data-toggle="tooltip" data-title="重新上传"/>
          </div>
          <div class="col-10 col-md-7">
            <div class="input-group">
              <input type="text" value="<%= carousel.link %>" class="form-control link-input" placeholder="请输入跳转地址">
              <div class="input-group-prepend">
                <button class="input-group-text save-data-btn" data-id="<%= carousel.id %>">保存</button>
              </div>
            </div>
          </div>
          <div class="col-2 col-md-1 operate-box">
            <%= check_box_tag(:online, 1, carousel.online?, id: nil, class: 'online-check-box', data: { id: carousel.id, toggle: 'tooltip', title: '首页展示' }) %>
            <%= delete_link '删除', admins_weapp_carousel_path(carousel, element: ".custom-carousel-item-#{carousel.id}", not_refresh: true), class: 'delete-btn' do %>
              <i class="fa fa-trash-o" data-id="<%= carousel.id %>"></i>
            <% end %>
          </div>
        </div>
      </div>
    <% end %>
  </div>
</div>


<%= render partial: 'admins/weapp_carousels/shared/add_weapp_carousel_modal' %>
<%= render partial: 'admins/shared/modal/upload_file_modal' %>