coton_app/app/views/qi/_qi_ordered_table.html.haml
Nicolas Bally 0b9daf14b2 migration
2020-03-19 00:53:22 +01:00

262 lines
6.1 KiB
Plaintext

-qi_ordered_table_name = qi_ordered_table_collection.klass.to_s.tableize
-qi_ordered_table_model = qi_ordered_table_collection.klass
=render :partial => "qi/qi_ordered_table_head", :locals => {:qi_ordered_table_name => qi_ordered_table_name, :qi_ordered_table_model => qi_ordered_table_model}
-@qi_table_orders = @qi_table_orders || {}
-if current_admin
-if ap = current_admin.admin_preferences.where(:key => "sort_table_"+qi_ordered_table_name).first
-qi_ordered_table_personalised = ap.value
-if ap = current_admin.admin_preferences.where(:key => "sort_table_"+qi_ordered_table_name+"_nbr_col").first
-qi_ordered_table_nbr_col = ap.value
-else
-qi_ordered_table_nbr_col = 1
-else
-qi_ordered_table_personalised = session[:qi_sort_string][qi_ordered_table_name]
-qi_ordered_table_nbr_col = session[:qi_sort_string][qi_ordered_table_name+"_nbr_col"] || 1
%span.qi_ordered_table_column{:onclick => "$(this).next('.qi_ordered_table_sort_select_wrapper').toggle();"}
=ic :columns
.qi_ordered_table_sort_select_wrapper{:style => "display:none;"}
=form_tag request.url, :method => "get", :onsubmit => "", :remote => false do
=hidden_field_tag "qi_sort_string[class]",qi_ordered_table_name
=hidden_field_tag "qi_sort_string[list]", "", :class => "qi_sort_string"
.qi_ordered_table_sort_select
-my_keys = []
-@qi_table_orders[qi_ordered_table_name.to_sym].each do |key, value|
.qi_order_item{:"data-ref" => "#{key}", :class => "active", :onclick => "$(this).toggleClass('active');"}
-if value.instance_of? Hash
=value[:name]
-else
=value
-my_keys << key
-qi_ordered_table_collection.klass.qi_table_order.each do |key, value|
-if !my_keys.include?(key)
.qi_order_item{:"data-ref" => "#{key}", :onclick => "$(this).toggleClass('active');"}
-if value.instance_of? Hash
=value[:name]
-else
=value
%hr{:style => "margin:3px 0;"}
-if false
Colonnes fixes :
=select_tag "qi_sort_string[nbr_colonnes]", options_for_select([0,1,2,3], qi_ordered_table_nbr_col)
=link_to "Mettre à jour", "#", :class => "btn btn-primary update_table_order_link"
:scss
.qi_ordered_table_column{
position:absolute;
color:rgba(0,0,0,0.2);
font-size:1.2em;
padding-top:3px;
padding-left:10px;
cursor:pointer;
&:hover{
color:rgba(0,0,0,0.6);
}
}
.qi_ordered_table_sort_select_wrapper{
background:rgba(white, 0.98);
box-shadow:0 0 10px rgba(0,0,0,0.2);
width:auto;
position:absolute;
margin-left:15px;
margin-top:25px;
z-index:5;
padding:5px 10px;
.qi_order_item{
padding:2px 0;
cursor:pointer;
}
.active{
font-weight:bold;
}
}
:coffeescript
$(".update_table_order_link").click ->
r = []
$(this).closest('.qi_ordered_table_sort_select_wrapper').find(".qi_order_item").each ->
if $(this).hasClass("active")
r.push $(this).data("ref")
$(this).closest("form").find(".qi_sort_string").val(r.join(','))
$.ajax
type: "GET",
url: "/",
data: $(this).closest("form").serialize(),
success: ->
location.reload()
$( ".qi_ordered_table_sort_select" ).sortable
axis: "y"
.qi_pannel.padding.new_table_container
.table-slider
.inner
<form class="range-field">
<input type="range" min="0" max="100" step="0.1" class="range" value="0" />
</form>
.table-area
.table-area-inner
.freezeTable
%table.table.table-striped.table-hover.table-bordered.data_table
%thead.header
%tr
-@qi_table_orders[qi_ordered_table_name.to_sym].each do |key, value|
-if value.instance_of? Hash
-if value[:reorder]
-sort_name = value[:sort_name] ? value[:sort_name] : key
%th=raw sort_link sort_name.to_s, value[:name]
-else
%th=raw value[:name]
-else
%th=raw value
=#sort_link "code", "Code"
-if false
%th
%tbody{:id => "#{qi_ordered_table_name}_rows"}
=render qi_ordered_table_collection
.qi_pagination
= paginate qi_ordered_table_collection #, :remote => true
:scss
.table-slider{
position:fixed;
bottom:0;
width:200px;
right:0;
z-index:2;
background:rgba(black,0.3);
padding:10px 20px;
padding-left:20px;
border-radius:40px 0 0 0;
opacity:0.4;
&:hover{
opacity:1;
background:rgba(black,0.7);
box-shadow:0 0 5px rgba(black,0.2);
}
}
:javascript
resize();
$('.freezeTable').freezeTable({columnNum:#{qi_ordered_table_nbr_col},fixedNavbar:'#qi_header_wrapper'});
:coffeescript
#mousemove
lastScrollLeft = 0
$(".freezeTable").scroll ->
#alert("t")
documentScrollLeft = $(this).scrollLeft()
if (lastScrollLeft != documentScrollLeft)
lastScrollLeft = documentScrollLeft
size = ($(this).find(".table").outerWidth() - $(this).outerWidth())
value = ( $(this).scrollLeft() / size)*100
$(this).closest(".new_table_container").find(".range").val(value)
$(".freezeTable").each ->
freeze = $(this)
$("document").on "scroll", ->
if ($(this).scrollTop() < freeze.offset[0] + freeze.outerHeight())
freeze.closest(".new_table_container").find(".table-slider").show()
else
freeze.closest(".new_table_container").find(".table-slider").hide()
$(".range").on 'input change mousemove', ->
freeze = $(this).closest(".new_table_container").find(".freezeTable")
size = (freeze.find(".table").outerWidth() - freeze.outerWidth())
value = size*($(this).val() / 100)
freeze.scrollLeft(value);
=#1