Plugin Directory

Changeset 1908890


Ignore:
Timestamp:
07/13/2018 05:00:12 PM (8 years ago)
Author:
cedche99
Message:

Update to 9.7 WP and add functionality which allows the update of the points and the position of all the team at the same time

Location:
slider-matches-results/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • slider-matches-results/trunk/assets/css/smr-admin.css

    r1877617 r1908890  
    11table.dataTable thead .sorting:before, table.dataTable thead .sorting_asc:before, table.dataTable thead .sorting_desc:before, table.dataTable thead .sorting_asc_disabled:before, table.dataTable thead .sorting_desc_disabled:before {
    22    right: 1.2em;
     3}
     4
     5.cursor-not-allowed{
     6    cursor : not-allowed;
     7}
     8
     9.cursor-grab{
     10    cursor : grab;
    311}
    412
     
    1119}
    1220
    13 #smr input[type="number"], #smr-create-team input[type="number"], #smr-update-team input[type="number"] {
     21#smr input[type="number"], #smr-create-team input[type="number"], #smr-update-team input[type="number"], #smr-update-teams input[type="number"] {
    1422    height: auto;
    1523}
  • slider-matches-results/trunk/assets/js/smr-admin-teams.js

    r1880323 r1908890  
    336336            }
    337337        });
     338
     339
     340        $(document).on("click", "#smr-button-update-teams", function () {
     341           
     342            var teams  = smrTeamsTable.rows().data();
     343
     344
     345            for (let index = 0; index < teams.length; index++) {
     346
     347                var html = '';
     348
     349                var id       = teams[index][0];
     350                var name     = teams[index][1];
     351                var position = teams[index][2];
     352                var points   = teams[index][3];
     353
     354                html =  ' \
     355                <div id="smr-update-teams-' + id + '" class="input-group mb-3 smr-update-teams-row"> \
     356                <input id="smr-update-teams-id-input" type="hidden" name="smr-update-teams-id-input" value="' + id + '" readonly> \
     357                <input id="smr-update-teams-name-input" class="form-control" type="text"  name="smr-update-teams-name-input" placeholder="' + translation['name'] + '" aria-label="Name" aria-describedby="smr-update-teams-name-label" value="' + name + '" readonly> \
     358                <input id="smr-update-teams-position-input" class="form-control" type="number" name="smr-update-teams-position-input" placeholder="' + translation['position'] + '" aria-label="Position" aria-describedby="smr-update-teams-position-label" value="' + position + '"> \
     359                <input id="smr-update-teams-points-input" class="form-control" type="number" name="smr-update-teams-points-input" placeholder="' + translation['points'] + '" aria-label="Points" aria-describedby="smr-update-teams-points-label" value="' + points + '"> \
     360                </div>';
     361
     362                $('#smr-update-teams #smr-form-update-teams .modal-body').append( html );
     363               
     364            };
     365
     366
     367           
     368        });
     369
     370        $("#smr-form-update-teams").submit(function(e){
     371           
     372            e.preventDefault();
     373
     374            var idArray         = [];
     375            var positionArray   = [];
     376            var pointsArray     = [];
     377
     378            $('input[name="smr-update-teams-id-input"]').each( function(){
     379                idArray.push( $(this).val() );
     380            });
     381
     382            $('input[name="smr-update-teams-position-input"]').each( function(){
     383                positionArray.push( $(this).val() );
     384            });
     385
     386            $('input[name="smr-update-teams-points-input"]').each( function(){
     387                pointsArray.push( $(this).val() );
     388            });
     389
     390            jQuery.post( smr_ajax_teams.ajax_url, {
     391                action  : smr_ajax_teams.update_teams,
     392                idArray : idArray,
     393                positionArray : positionArray,
     394                pointsArray : pointsArray   
     395            }, function(response) {
     396
     397
     398                console.log(response);
     399               
     400                var nbRowsInPage = $('.smr-row').length;
     401               
     402                for (let index = 0; index < nbRowsInPage ; index++) {
     403
     404                    var id          = idArray[index];
     405                    var name        = smrTeamsTable.rows(index).data()[0][1];
     406                    var logo        = smrTeamsTable.rows(index).data()[0][4];
     407                    var btnUpdate   = smrTeamsTable.rows(index).data()[0][5];
     408                    var btnDelete   = smrTeamsTable.rows(index).data()[0][6];
     409                    var checkbox    = smrTeamsTable.rows(index).data()[0][7];
     410
     411                    smrTeamsTable.row($('#smr-row-'+id)).data( [
     412                        id,
     413                        name,
     414                        positionArray[index],
     415                        pointsArray[index],
     416                        logo,
     417                        btnUpdate,
     418                        btnDelete,
     419                        checkbox
     420                    ] ).draw( false );
     421
     422                }
     423
     424                $('#smr-update-teams').modal('toggle');
     425
     426                swal({
     427                    title: translation['Updated !'],
     428                    html: translation['Your teams has been updated.\nThe page will be refreshed.'],
     429                    type: 'success'
     430                }).then((result) => {
     431                    location.reload();
     432                });
     433            })
     434            .fail(function(response) {
     435                swal({
     436                    title: translation['Not Updated !'],
     437                    text: translation['Your teams hasn\'t been updated.'],
     438                    type: 'error'
     439                })
     440            });
     441        });
    338442    }
    339443});
  • slider-matches-results/trunk/assets/js/smr-admin-translation.js

    r1877617 r1908890  
    4040        'Your team has been updated.':'Your team has been updated.',
    4141        'Your team hasn\'t been updated.':'Your team hasn\'t been updated.',
    42         'Upload image':'Upload image'
     42        'Your teams hasn\'t been updated.':'Your teams hasn\'t been updated.',
     43        'Your teams has been updated.\nThe page will be refreshed.':'Your teams has been updated.<br><br>The page will be refreshed.',
     44        'Upload image':'Upload image',
     45        'name':'Name',
     46        'position':'Position',
     47        'points':'Points'
    4348    },
    4449    'fr' : {
     
    6166        'Updated !' : 'Mise à jour !',
    6267        'Update' : 'Mettre à jour',
    63         'Not updated!' : 'N\'a pas été mise à jour !',
     68        'Not updated !' : 'N\'a pas été mise à jour !',
    6469        'Your match has been deleted.' : 'Votre match a été supprimé.',
    6570        'Your matches have been deleted.' : 'Vos matchs ont été supprimées.',
     
    8287        'Your team has been updated.':'Votre équipe a été mise à jour.',
    8388        'Your team hasn\'t been updated.':'Votre équipe n\'a pas été mise à jour.',
    84         'Upload image':'Importer une image'
     89        'Your teams hasn\'t been updated.':'Vos équipes n\'ont pas été mises à jour.',
     90        'Your teams has been updated.\nThe page will be refreshed.':'Vos équipes ont été mises à jour.<br><br>La page va être rafraîchie.',
     91        'Upload image':'Importer une image',
     92        'name':'Nom',
     93        'position':'Position',
     94        'points':'Points'
    8595    }
    8696}
  • slider-matches-results/trunk/inc/ajax/teams.php

    r1881529 r1908890  
    5050    }
    5151
     52    wp_die();
     53}
     54
     55/**
     56 * Ajax - Update Team.
     57 *
     58 * @since 1.0.3
     59 *
     60 */
     61add_action( 'wp_ajax_smr_update_teams', 'smr_update_teams' );
     62function smr_update_teams() {
     63   
     64    global $wpdb;
     65   
     66    $t_id       = $_POST['idArray'];
     67    $t_position = $_POST['positionArray'];
     68    $t_points   = $_POST['pointsArray'];
     69
     70    for($index = 0; $index < count( $t_id ); $index++) {
     71        if( !empty( $t_id[$index] ) ){
     72            $sql = "UPDATE ".$wpdb->prefix."smr_teams SET position = %d, points = %d WHERE id = %d";
     73            $wpdb->get_results( $wpdb->prepare( $sql,array( $t_position[$index], $t_points[$index], $t_id[$index] ) ) );
     74        }
     75    }
     76   
    5277    wp_die();
    5378}
  • slider-matches-results/trunk/languages/slider-matches-results-fr_FR.po

    r1877617 r1908890  
    22msgstr ""
    33"Project-Id-Version: Slider Matches Results\n"
    4 "POT-Creation-Date: 2018-05-12 11:44+0200\n"
    5 "PO-Revision-Date: 2018-05-12 11:45+0200\n"
     4"POT-Creation-Date: 2018-06-19 23:40+0200\n"
     5"PO-Revision-Date: 2018-06-20 00:00+0200\n"
    66"Last-Translator: \n"
    77"Language-Team: \n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 2.0.7\n"
     12"X-Generator: Poedit 2.0.8\n"
    1313"X-Poedit-Basepath: ..\n"
    1414"Plural-Forms: nplurals=2; plural=(n > 1);\n"
     
    2626msgstr "journée"
    2727
    28 #: slider-matches-results.php:793 templates/sliders.php:11
     28#: slider-matches-results.php:803 templates/sliders.php:11
    2929msgid "Sliders"
    3030msgstr "Curseurs"
    3131
    32 #: slider-matches-results.php:796 templates/settings.php:12
     32#: slider-matches-results.php:806 templates/settings.php:12
    3333#: templates/settings.php:458 templates/teams.php:11
    3434msgid "Teams"
    3535msgstr "Equipes"
    3636
    37 #: slider-matches-results.php:797 templates/matches.php:14
     37#: slider-matches-results.php:807 templates/matches.php:14
    3838#: templates/settings.php:13 templates/settings.php:515
    3939msgid "Matches"
    4040msgstr "Matchs"
    4141
    42 #: slider-matches-results.php:798 templates/settings.php:4
     42#: slider-matches-results.php:808 templates/settings.php:4
    4343#: templates/settings.php:21 templates/settings.php:329
    4444#: templates/settings.php:458 templates/settings.php:515
     
    7979msgstr "Curseur"
    8080
    81 #: templates/create_slider.php:30 templates/teams.php:28 templates/teams.php:83
    82 #: templates/teams.php:133 templates/update_slider.php:30
     81#: templates/create_slider.php:30 templates/teams.php:29 templates/teams.php:77
     82#: templates/teams.php:108 templates/teams.php:158
     83#: templates/update_slider.php:30
    8384msgid "Name"
    8485msgstr "Nom"
     
    248249
    249250#: templates/matches.php:53 templates/matches.php:130 templates/sliders.php:42
    250 #: templates/teams.php:50 templates/teams.php:109
     251#: templates/teams.php:51 templates/teams.php:83 templates/teams.php:134
    251252msgid "Update"
    252253msgstr "Mettre à jour"
    253254
    254 #: templates/matches.php:56 templates/sliders.php:45 templates/teams.php:53
     255#: templates/matches.php:56 templates/sliders.php:45 templates/teams.php:54
    255256msgid "Delete"
    256257msgstr "Supprimer"
     
    261262
    262263#: templates/matches.php:74 templates/matches.php:131 templates/matches.php:143
    263 #: templates/matches.php:199 templates/teams.php:71 templates/teams.php:110
    264 #: templates/teams.php:122 templates/teams.php:157
     264#: templates/matches.php:199 templates/teams.php:72 templates/teams.php:84
     265#: templates/teams.php:96 templates/teams.php:135 templates/teams.php:147
     266#: templates/teams.php:182
    265267msgid "Close"
    266268msgstr "Fermer"
     
    283285"et ces champs ne doivent pas être égaux pour valider l’ajout de votre match."
    284286
    285 #: templates/matches.php:198 templates/teams.php:156
     287#: templates/matches.php:198 templates/teams.php:181
    286288msgid "Create"
    287289msgstr "Créer"
     
    386388msgstr "Nom du curseur"
    387389
    388 #: templates/teams.php:17
     390#: templates/teams.php:17 templates/teams.php:146
    389391msgid "Add Team"
    390392msgstr "Ajouter une équipe"
     
    394396msgstr "Supprimer les équipes"
    395397
    396 #: templates/teams.php:29 templates/teams.php:89 templates/teams.php:139
     398#: templates/teams.php:19 templates/teams.php:71
     399msgid "Update Teams"
     400msgstr "Mettre à jour vos équipes"
     401
     402#: templates/teams.php:30 templates/teams.php:78 templates/teams.php:114
     403#: templates/teams.php:164
    397404msgid "Position"
    398405msgstr "Position"
    399406
    400 #: templates/teams.php:30 templates/teams.php:95 templates/teams.php:145
     407#: templates/teams.php:31 templates/teams.php:79 templates/teams.php:120
     408#: templates/teams.php:170
    401409msgid "Points"
    402410msgstr "Points"
    403411
    404 #: templates/teams.php:31
     412#: templates/teams.php:32
    405413msgid "Logo"
    406414msgstr "Logo"
    407415
    408 #: templates/teams.php:70
    409 msgid "Update team"
    410 msgstr "Mettre à jour l’équipe"
    411 
    412 #: templates/teams.php:76
    413 msgid ""
    414 "You must fill in the \"Name\" field to validate the updating of your team. "
     416#: templates/teams.php:95
     417msgid "Update Team"
     418msgstr "Mettre à jour votre équipe"
     419
     420#: templates/teams.php:101
     421msgid ""
     422"You must fill in the \"Name\" field to validate the updating of your team"
    415423msgstr ""
    416424"Vous devez remplir les champs « Équipe à domicile » et « Équipe extérieure » "
    417 "et ces champs ne doivent pas être égaux pour valider l’ajout de votre équipe."
    418 
    419 #: templates/teams.php:101 templates/teams.php:151
     425"et ces champs ne doivent pas être égaux pour valider l’ajout de votre équipe"
     426
     427#: templates/teams.php:126 templates/teams.php:176
    420428msgid "Url"
    421429msgstr "Url"
    422430
    423 #: templates/teams.php:121
    424 msgid "Add team"
    425 msgstr "Ajouter un équipe"
    426 
    427 #: templates/teams.php:127
     431#: templates/teams.php:152
    428432msgid ""
    429433"You must fill in the \"Name\" field to validate the addition of your team."
     
    468472msgid "https://www.cedricchevillard.fr"
    469473msgstr ""
     474
     475#~ msgid "Add team"
     476#~ msgstr "Ajouter un équipe"
  • slider-matches-results/trunk/readme.txt

    r1881075 r1908890  
    33Tags: Slider, Matches, Results, Club
    44Requires at least: 3.6
    5 Tested up to: 4.9.6
     5Tested up to: 4.9.7
    66Requires PHP: 5.4
    77License: GPL2
     
    6161== changelog ==
    6262
    63 - Adjust CSS of slider / ranking
    64 - Correction - Topic : "Errors"
     63- Correction - Ajax request
     64- Correction - Topic : "Errors" (second)
    6565
    6666== Screenshots ==
  • slider-matches-results/trunk/slider-matches-results.php

    r1881529 r1908890  
    44Plugin URI:
    55Description: Allows you to create specific sliders for your sports team (Football, Handball ...)
    6 Version: 1.0.2
     6Version: 1.0.3
    77Author: Cédric Chevillard
    88Author URI: https://www.cedricchevillard.fr
     
    1717class Slider_Matches_Results
    1818{
    19     const VERSION                  = '1.0.2';
     19    const VERSION                  = '1.0.3';
    2020    const SMR_DB_VERSION           = '1.0';
    2121    const OPTION_NAME              = 'smr_options_settings';
     
    734734            $settings_teams_json = $this->get_option_settings_teams();
    735735
    736             wp_localize_script( 'smr_admin_script', 'smr_ajax_teams',array( 'ajax_url' => admin_url( 'admin-ajax.php'), 'language' => $this->get_language(), 'dataTableLanguage' => plugins_url( 'languages/js/datatables/'.$this->get_language().'.json', __FILE__ ), 'create_team' => 'smr_create_team', 'delete_team' => 'smr_delete_team', 'update_team' => 'smr_update_team','delete_teams' => 'smr_delete_teams', 'table_order_by' => $settings_teams_json->order_by, 'table_nb_elements' => $settings_teams_json->nb_elements ) );
     736            wp_localize_script( 'smr_admin_script', 'smr_ajax_teams',array( 'ajax_url' => admin_url( 'admin-ajax.php'), 'language' => $this->get_language(), 'dataTableLanguage' => plugins_url( 'languages/js/datatables/'.$this->get_language().'.json', __FILE__ ), 'create_team' => 'smr_create_team', 'delete_team' => 'smr_delete_team', 'update_teams' => 'smr_update_teams', 'update_team' => 'smr_update_team','delete_teams' => 'smr_delete_teams', 'table_order_by' => $settings_teams_json->order_by, 'table_nb_elements' => $settings_teams_json->nb_elements ) );
    737737
    738738        }elseif( $page_admin == 'smr_plugin_matches' ){
  • slider-matches-results/trunk/templates/teams.php

    r1877617 r1908890  
    1717                <button id="smr-button-create-team" class="btn btn-primary" type="button" data-toggle="modal" data-target="#smr-create-team"><?php _e( 'Add Team', 'slider-matches-results' ); ?></button>
    1818                <button id='smr-button-delete-multiple' class="btn btn-danger" type="button" disabled><?php _e( 'Delete Teams', 'slider-matches-results' ); ?></button>
     19                <button id="smr-button-update-teams" class="btn btn-success" type="button" data-toggle="modal" data-target="#smr-update-teams"><?php _e( 'Update Teams', 'slider-matches-results' ); ?></button>
    1920            </div>
    2021        </div>
     
    3738                <tbody>
    3839                    <?php foreach( $teams as $team ) { ?>
    39                     <tr id="smr-row-<?php echo $team->get_id(); ?>">
     40                    <tr id="smr-row-<?php echo $team->get_id(); ?>" class="smr-row">
    4041                        <td class="smr-cell-id"><?php echo $team->get_id(); ?></td>
    4142                        <td class="smr-cell-name"><?php echo stripslashes( $team->get_name() ); ?></td>
     
    6465</div>
    6566
     67<div class="modal fade" id="smr-update-teams" tabindex="-1" role="dialog"  aria-hidden="true">
     68    <div class="modal-dialog modal-dialog-centered" role="document">
     69        <div class="modal-content">
     70            <div class="modal-header">
     71                <h4 class="modal-title"><?php _e( 'Update Teams', 'slider-matches-results' ); ?></h4>
     72                <button class="close" type="button" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only"><?php _e( 'Close', 'slider-matches-results' ); ?></span></button>
     73            </div>
     74            <form id="smr-form-update-teams" role="form">
     75                <div class="modal-body">
     76                    <div id="smr-update-teams-<?php echo $team->get_id(); ?>" class="input-group mb-3">
     77                        <label class="form-control text-center cursor-grab"> <?php _e( 'Name', 'slider-matches-results' ); ?> </label>
     78                        <label class="form-control text-center cursor-grab"> <?php _e( 'Position', 'slider-matches-results' ); ?> </label>
     79                        <label class="form-control text-center cursor-grab"> <?php _e( 'Points', 'slider-matches-results' ); ?> </label>
     80                    </div>
     81                </div>
     82                <div class="modal-footer">
     83                    <button class="btn btn-success" type="submit" name="smr-update-teams" formmethod="post" ><?php _e( 'Update', 'slider-matches-results' ); ?></button>
     84                    <button class="btn btn-danger" type="button" data-dismiss="modal"><?php _e( 'Close', 'slider-matches-results' ); ?></button>
     85                </div>
     86            </form>
     87        </div>
     88    </div>
     89</div>
     90
    6691<div class="modal fade" id="smr-update-team" tabindex="-1" role="dialog"  aria-hidden="true">
    6792    <div class="modal-dialog modal-dialog-centered" role="document">
    6893        <div class="modal-content">
    6994            <div class="modal-header">
    70                 <h4 class="modal-title"><?php _e( 'Update team', 'slider-matches-results' ); ?></h4>
     95                <h4 class="modal-title"><?php _e( 'Update Team', 'slider-matches-results' ); ?></h4>
    7196                <button class="close" type="button" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only"><?php _e( 'Close', 'slider-matches-results' ); ?></span></button>
    7297            </div>
     
    7499                <div class="modal-body">
    75100                    <div class="alert alert-info ">                 
    76                         <p> <?php _e( 'You must fill in the "Name" field to validate the updating of your team. ', 'slider-matches-results' ); ?></p>
     101                        <p> <?php _e( 'You must fill in the "Name" field to validate the updating of your team', 'slider-matches-results' ); ?>.</p>
    77102                    </div>
    78103                    <input id="smr-update-team-id-input" type="hidden" name="smr-update-team-id-input">
     
    119144        <div class="modal-content">
    120145            <div class="modal-header">
    121                 <h4 class="modal-title"><?php _e( 'Add team', 'slider-matches-results' ); ?></h4>
     146                <h4 class="modal-title"><?php _e( 'Add Team', 'slider-matches-results' ); ?></h4>
    122147                <button class="close" type="button" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only"><?php _e( 'Close', 'slider-matches-results' ); ?></span></button>
    123148            </div>
Note: See TracChangeset for help on using the changeset viewer.