Enable multiselect outcomes close #8

This commit is contained in:
Brian Miyaji
2014-03-11 13:52:12 +11:00
parent d6fa4fc79e
commit dd92b6384c
5 changed files with 70 additions and 67 deletions

View File

@@ -22,6 +22,6 @@ function sportspress_admin_enqueue_scripts( $hook ) {
wp_enqueue_script( 'sportspress-admin', SPORTSPRESS_PLUGIN_URL .'assets/js/admin.js', array( 'jquery' ), time(), true );
// Localize scripts.
wp_localize_script( 'sportspress-admin', 'localized_strings', array( 'remove_text' => __( '— Remove —', 'sportspress' ), 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ) ) );
wp_localize_script( 'sportspress-admin', 'localized_strings', array( 'none' => __( 'None', 'sportspress' ), 'remove_text' => __( '— Remove —', 'sportspress' ), 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ) ) );
}
add_action( 'admin_enqueue_scripts', 'sportspress_admin_enqueue_scripts' );

View File

@@ -54,23 +54,7 @@ function sportspress_manage_posts_custom_column( $column, $post_id ) {
endif;
if ( $team_result != null ):
echo ' — ' . $team_result;
endif;
$outcome_slug = sportspress_array_value( $team_results, 'outcome', null );
if ( $outcome_slug && $outcome_slug != '-1' ):
$args=array(
'name' => $outcome_slug,
'post_type' => 'sp_outcome',
'post_status' => 'publish',
'posts_per_page' => 1
);
$outcomes = get_posts( $args );
if ( sizeof( $outcomes ) ):
$outcome = reset( $outcomes );
echo ' (' . $outcome->post_title . ')';
endif;
echo ' <strong>' . $team_result . '</strong>';
endif;
echo '<br>';

View File

@@ -181,10 +181,6 @@
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
}
.postbox .inside .sp-data-table-container {
overflow: auto;
}
.wp-media-buttons .button.sp-insert {
padding-left: 5px;
}

View File

@@ -12,7 +12,8 @@ jQuery(document).ready(function($){
// Chosen select
$(".chosen-select").chosen({
allow_single_deselect: true,
single_backstroke_delete: false
single_backstroke_delete: false,
placeholder_text_multiple: localized_strings.none
});
// Auto key placeholder

View File

@@ -1046,15 +1046,20 @@ if ( !function_exists( 'sportspress_edit_event_results_table' ) ) {
<?php endforeach; ?>
<td>
<?php
$value = sportspress_array_value( $team_results, 'outcome', '' );
$values = sportspress_array_value( $team_results, 'outcome', '' );
if ( ! is_array( $values ) )
$values = array( $values );
$args = array(
'post_type' => 'sp_outcome',
'name' => 'sp_results[' . $team_id . '][outcome]',
'show_option_none' => __( '-- Not set --', 'sportspress' ),
'name' => 'sp_results[' . $team_id . '][outcome][]',
'option_none_value' => '',
'sort_order' => 'ASC',
'sort_column' => 'menu_order',
'selected' => $value
'selected' => $values,
'class' => 'sp-outcome',
'property' => 'multiple',
'chosen' => true,
);
sportspress_dropdown_pages( $args );
?>
@@ -1534,33 +1539,42 @@ if ( !function_exists( 'sportspress_get_team_columns_data' ) ) {
if ( $team_id == $post_id ):
if ( $key == 'outcome' ):
// Increment events played and outcome count
if ( array_key_exists( $value, $totals ) ):
$totals['eventsplayed']++;
$totals[ $value ]++;
// Convert to array
if ( ! is_array( $value ) ):
$value = array( $value );
endif;
if ( $value && $value != '-1' ):
foreach( $value as $outcome ):
// Add to streak counter
if ( $streak['fire'] && ( $streak['name'] == '' || $streak['name'] == $value ) ):
$streak['name'] = $value;
$streak['count'] ++;
else:
$streak['fire'] = 0;
// Increment events played and outcome count
if ( array_key_exists( $outcome, $totals ) ):
$totals['eventsplayed']++;
$totals[ $outcome ]++;
endif;
// Add to last 5 counter if sum is less than 5
if ( array_key_exists( $value, $last5 ) && array_sum( $last5 ) < 5 ):
$last5[ $value ] ++;
if ( $outcome && $outcome != '-1' ):
// Add to streak counter
if ( $streak['fire'] && ( $streak['name'] == '' || $streak['name'] == $outcome ) ):
$streak['name'] = $outcome;
$streak['count'] ++;
else:
$streak['fire'] = 0;
endif;
// Add to last 5 counter if sum is less than 5
if ( array_key_exists( $outcome, $last5 ) && array_sum( $last5 ) < 5 ):
$last5[ $outcome ] ++;
endif;
// Add to last 10 counter if sum is less than 10
if ( array_key_exists( $outcome, $last10 ) && array_sum( $last10 ) < 10 ):
$last10[ $outcome ] ++;
endif;
endif;
// Add to last 10 counter if sum is less than 10
if ( array_key_exists( $value, $last10 ) && array_sum( $last10 ) < 10 ):
$last10[ $value ] ++;
endif;
endif;
endforeach;
else:
if ( array_key_exists( $key . 'for', $totals ) ):
@@ -1747,33 +1761,41 @@ if ( !function_exists( 'sportspress_get_league_table_data' ) ) {
if ( $key == 'outcome' ):
// Increment events played and outcome count
if ( array_key_exists( $team_id, $totals ) && is_array( $totals[ $team_id ] ) && array_key_exists( $value, $totals[ $team_id ] ) ):
$totals[ $team_id ]['eventsplayed']++;
$totals[ $team_id ][ $value ]++;
if ( ! is_array( $value ) ):
$value = array( $value );
endif;
if ( $value && $value != '-1' ):
foreach ( $value as $outcome ):
// Add to streak counter
if ( $streaks[ $team_id ]['fire'] && ( $streaks[ $team_id ]['name'] == '' || $streaks[ $team_id ]['name'] == $value ) ):
$streaks[ $team_id ]['name'] = $value;
$streaks[ $team_id ]['count'] ++;
else:
$streaks[ $team_id ]['fire'] = 0;
// Increment events played and outcome count
if ( array_key_exists( $team_id, $totals ) && is_array( $totals[ $team_id ] ) && array_key_exists( $outcome, $totals[ $team_id ] ) ):
$totals[ $team_id ]['eventsplayed']++;
$totals[ $team_id ][ $outcome ]++;
endif;
// Add to last 5 counter if sum is less than 5
if ( array_key_exists( $team_id, $last5s ) && array_key_exists( $value, $last5s[ $team_id ] ) && array_sum( $last5s[ $team_id ] ) < 5 ):
$last5s[ $team_id ][ $value ] ++;
if ( $outcome && $outcome != '-1' ):
// Add to streak counter
if ( $streaks[ $team_id ]['fire'] && ( $streaks[ $team_id ]['name'] == '' || $streaks[ $team_id ]['name'] == $outcome ) ):
$streaks[ $team_id ]['name'] = $outcome;
$streaks[ $team_id ]['count'] ++;
else:
$streaks[ $team_id ]['fire'] = 0;
endif;
// Add to last 5 counter if sum is less than 5
if ( array_key_exists( $team_id, $last5s ) && array_key_exists( $outcome, $last5s[ $team_id ] ) && array_sum( $last5s[ $team_id ] ) < 5 ):
$last5s[ $team_id ][ $outcome ] ++;
endif;
// Add to last 10 counter if sum is less than 10
if ( array_key_exists( $team_id, $last10s ) && array_key_exists( $outcome, $last10s[ $team_id ] ) && array_sum( $last10s[ $team_id ] ) < 10 ):
$last10s[ $team_id ][ $outcome ] ++;
endif;
endif;
// Add to last 10 counter if sum is less than 10
if ( array_key_exists( $team_id, $last10s ) && array_key_exists( $value, $last10s[ $team_id ] ) && array_sum( $last10s[ $team_id ] ) < 10 ):
$last10s[ $team_id ][ $value ] ++;
endif;
endif;
endforeach;
else:
if ( array_key_exists( $team_id, $totals ) && is_array( $totals[ $team_id ] ) && array_key_exists( $key . 'for', $totals[ $team_id ] ) ):