Enable event player reordering
This commit is contained in:
@@ -226,6 +226,18 @@ table.widefat select.sp-outcome {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.widefat.sp-sortable-table tbody tr {
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
table.widefat.sp-sortable-table tr {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
table.widefat.sp-sortable-table tr:nth-child(2n-1) {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
.sp-admin-config-table th,
|
||||
.sp-admin-config-table td {
|
||||
padding: 8px 10px;
|
||||
|
||||
@@ -24,6 +24,7 @@ jQuery(document).ready(function($){
|
||||
|
||||
// Activate auto key placeholder
|
||||
$("#poststuff #title").keyup();
|
||||
|
||||
// Table switcher
|
||||
$(".sp-table-panel").siblings(".sp-table-bar").find("a").click(function() {
|
||||
$(this).closest("li").find("a").addClass("current").closest("li").siblings().find("a").removeClass("current").closest(".sp-table-bar").siblings($(this).attr("href")).show().siblings(".sp-table-panel").hide();
|
||||
@@ -233,6 +234,11 @@ jQuery(document).ready(function($){
|
||||
// Trigger check check
|
||||
$(".sp-data-table").trigger("checkCheck");
|
||||
|
||||
// Sortable tables
|
||||
$(".sp-sortable-table tbody").sortable({
|
||||
axis: "y"
|
||||
});
|
||||
|
||||
// Video embed
|
||||
$(".sp-add-video").click(function() {
|
||||
$(this).closest("fieldset").hide().siblings(".sp-video-field").show();
|
||||
|
||||
@@ -55,7 +55,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
public static function table( $labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false ) {
|
||||
?>
|
||||
<div class="sp-data-table-container">
|
||||
<table class="widefat sp-data-table sp-performance-table">
|
||||
<table class="widefat sp-data-table sp-performance-table sp-sortable-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
@@ -77,12 +77,11 @@ class SP_Meta_Box_Event_Performance {
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ( $data as $player_id => $player_performance ):
|
||||
if ( !$player_id ) continue;
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>" data-player="<?php echo $player_id; ?>">
|
||||
<tr class="sp-row sp-post" data-player="<?php echo $player_id; ?>">
|
||||
<td><?php echo ( $number ? $number : ' ' ); ?></td>
|
||||
<td><?php echo get_the_title( $player_id ); ?></td>
|
||||
<?php foreach( $labels as $column => $label ):
|
||||
@@ -98,10 +97,11 @@ class SP_Meta_Box_Event_Performance {
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$i++;
|
||||
endforeach;
|
||||
?>
|
||||
<tr class="sp-row sp-total<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="sp-row sp-total">
|
||||
<td> </td>
|
||||
<td><strong><?php _e( 'Total', 'sportspress' ); ?></strong></td>
|
||||
<?php foreach( $labels as $column => $label ):
|
||||
@@ -113,7 +113,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
<?php endforeach; ?>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
@@ -252,13 +252,22 @@ if ( !function_exists( 'sp_array_value' ) ) {
|
||||
|
||||
if ( !function_exists( 'sp_array_combine' ) ) {
|
||||
function sp_array_combine( $keys = array(), $values = array() ) {
|
||||
if ( ! is_array( $keys ) ) return array();
|
||||
if ( ! is_array( $values ) ) $values = array();
|
||||
|
||||
$output = array();
|
||||
|
||||
foreach ( $values as $key => $value ):
|
||||
if ( in_array( $key, $keys ) ):
|
||||
$output[ $key ] = $value;
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
foreach ( $keys as $key ):
|
||||
if ( is_array( $values ) && array_key_exists( $key, $values ) )
|
||||
$output[ $key ] = $values[ $key ];
|
||||
else
|
||||
if ( ! array_key_exists( $key, $output ) )
|
||||
$output[ $key ] = array();
|
||||
endforeach;
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,15 +13,15 @@ if ( ! isset( $id ) )
|
||||
$id = get_the_ID();
|
||||
|
||||
$event = new SP_Event( $id );
|
||||
$data = $event->performance();
|
||||
$performance = $event->performance();
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
$labels = $performance[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
unset( $performance[0] );
|
||||
|
||||
$data = array_filter( $data );
|
||||
$performance = array_filter( $performance );
|
||||
|
||||
$teams = (array)get_post_meta( $id, 'sp_team', false );
|
||||
$status = $event->status();
|
||||
@@ -41,7 +41,7 @@ foreach( $teams as $index => $team_id ):
|
||||
|
||||
$totals = array();
|
||||
|
||||
$data = sp_array_combine( $players, sp_array_value( $data, $team_id, array() ) );
|
||||
$data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) );
|
||||
?>
|
||||
<h3><?php echo get_the_title( $team_id ); ?></h3>
|
||||
<?php
|
||||
|
||||
Reference in New Issue
Block a user