<%
block_name ||= ''; uniq_id ||= ''; attributes ||= {}; selected_values ||= []
user ||= User.current
modal_selector = (options[:modal_selector].to_s == 'true')
easy_query = present(easy_query, block_name: block_name, modul_uniq_id: uniq_id, options: options)
entities ||= easy_query.entities(fetch: true)
%>
<% easy_query_entity_list(entities) do |entity, level| %>
<%
  if @limit && (@limit % 2 == 1) && params['page'].to_i > 1 && params['page'].to_i % 2 == 0
    row_color = cycle('odd', 'even')
  end
  row_color ||= cycle('even', 'odd')
%>
  <tr id="entity-<%= entity.id %>"
      class="
        <%= dom_id(entity) %>
        <%= row_color %>
        <%= ' hascontextmenu' if easy_query.has_contextmenu? || modal_selector -%>
        <%= easy_query.entity_css_classes(entity, {:level => level, :uniq_prefix => nil, :display_tree => easy_query.display_as_tree?, :inline_editable => !modal_selector}) %>
        <%= ' context-menu-selection' if modal_selector && selected_values && selected_values.detect{|a,b| a == entity.id.to_s} -%>
        <%= ' selectable' if modal_selector -%><%= ' easy-to-do-list-source' if entity.is_a?(Issue) -%>
        <%= easy_query_custom_formatting_css(easy_query, entity) %>
      "
      <%= detect_hide_elements(uniq_id, user) -%> data-url="<%= url_to_entity(entity, :format => 'json') %>">
  <%# TODO zavisi na pravech easy_cache ['easy_que easy_query_row', entity, block_name, I18n.locale], !block_name.blank? do %>
    <% if modal_selector %>
      <td class="checkbox hide-when-print">
        <%= entity_modal_selector_checker(entity, selected_values, options[:multiple]) %>
      </td>
    <% end %>
    <%= content_tag :td, easy_query.has_contextmenu? ? check_box_tag('ids[]', entity.id, false, :id => nil) : '', :class => 'checkbox hide-when-print' -%>
    <td class="easy-query-additional-beginning-buttons hide-when-print"><%= easy_query_additional_beginning_buttons(easy_query, entity, options) -%></td>
    <% easy_query.inline_columns.each do |column| -%>
      <%= content_tag :td, format_html_entity_attribute(entity.class, column, column.value(entity, {:params => params}), {:entity => entity, :allow_avatar => easy_query.show_avatars?, :editable => options[:editable], :modal => modal_selector}), :class => column.css_classes, :rowspan => (column.full_rows_column? ? 2 : nil) -%>
    <% end %>
    <% unless modal_selector %>
      <% buttons = easy_query_additional_ending_buttons(easy_query, entity, options) %>
      <td class="easy-query-additional-ending-buttons hide-when-print">
        <div class="ending-buttons-fixed <%= 'hidden' if buttons.blank? %>">
          <%= buttons -%>
        </div>
      </td>
    <% end %>
  <%# end -%>
  </tr>
  <% easy_query.block_columns.each do |column|
    if (text = format_html_entity_attribute(entity.class, column, column.value(entity, {:params => params}), {:entity => entity})) && text.present? -%>
      <tr class="<%= current_cycle  %>
                <%= easy_query.entity_css_classes(entity, {:level => level, :uniq_prefix => nil, :display_tree => easy_query.display_as_tree?, :inline_editable => !modal_selector}) %>
                " data-url="<%= url_to_entity(entity, :format => 'json') %>">
        <% if modal_selector %>
          <td class="hide-when-print"></td>
        <% end %>
        <%= content_tag :td, '', :class => 'checkbox hide-when-print' -%>
        <td class="easy-query-additional-beginning-buttons hide-when-print"></td>
        <td colspan="<%= easy_query.inline_columns.size + 1 %>" class="<%= column.css_classes %>"><%= text %></td>
      </tr>
    <% end -%>
  <% end #block columns %>
<% end #entities %>
<%= easy_query_summary_row(easy_query, attributes[:sums] || {}, :bottom, options) if easy_query.grouped? %>

<% if modal_selector %>
  <script type="text/javascript">
    $(function() {
      EASY.contextMenu.init('', $('#easy_modal .easy-query-list'));
      $('div.modal-selected-values .easy-lookup-selected-value-wrapper input[type="hidden"]').each(function(i, e){
        $('tr#entity-'+e.value).addClass('context-menu-selection');
        $('tr#entity-'+e.value+' input[type="checkbox"], tr#entity-'+e.value+' input[type="radio"]').prop('checked', true);
      });
    });
  </script>
<% end %>
