Permalink
Browse files

team approve

  • Loading branch information...
1 parent 3a90d23 commit 0f3be06f4b98eeea88086c9bb41df4020bb1c10e @wooki committed Dec 13, 2012
Showing with 29 additions and 7 deletions.
  1. +6 −3 application/models/game.php
  2. +6 −2 application/views/missions/approve.php
  3. +3 −1 css/application.css
  4. +14 −1 js/application.js
@@ -95,12 +95,13 @@ static function all_players_state($game, $state) {
// set current team
static function set_team($game, $team) {
+ foreach ($game->players as &$player) {
+ $player->team = false;
+ }
foreach ($team as $p) {
foreach ($game->players as &$player) {
if ($player->slug === $p->slug) {
$player->team = true;
- } else {
- $player->team = false;
}
}
}
@@ -139,6 +140,7 @@ static function update_player($game, $player) {
$p->role = $player->role;
$p->state = $player->state;
$p->team = $player->team;
+ $p->vote = $player->vote;
}
}
}
@@ -164,7 +166,8 @@ static function add_player($game, $name) {
'leader' => false,
'role' => '',
'state' => 'joining',
- 'team' => false
+ 'team' => false,
+ 'vote' => ''
);
return $guid;
}
@@ -18,8 +18,10 @@
<?= player_label($p->name) ?>
<?php } ?>
+ <? if ($player->vote == '') { ?>
<?= form_open('missions/vote/'.$game->slug, array('class' => 'vote')) ?>
-
+ <?= form_hidden('vote', ''); ?>
+
<p>Vote to approve or reject the leaders team</p>
<div class="btn-group" data-toggle="buttons-radio">
@@ -32,7 +34,9 @@
<button type="submit" class="btn btn-primary btn-large">Vote</button>
</form>
-
+ <? } else { ?>
+ <p>Voted: <span class="label label-info"><?= $player->vote ?></span></p>
+ <? } ?>
</div>
</div>
View
@@ -22,12 +22,14 @@ body {
}
form {
- padding: 0 15px 0 15px;
+ /* padding: 0 15px 0 15px; */
}
p {
+ /*
margin-left: 1em;
margin-right: 1em;
+ */
font-size: 1.2em;
color: #000;
}
View
@@ -29,6 +29,19 @@ var covertmission = function() {
$.backstretch("/img/bg.jpg");
}
+ // vote requires one of approve/reject button
+ $('form.vote').submit(function(event) {
+ var selected_count = $('.btn-group button.active').length;
+ if (selected_count != 1) {
+ event.preventDefault();
+ $('.validation-message').addClass('alert alert-error').html("Please select either Accept or Reject");
+ } else {
+ $('.btn-group button.active').each(function(key, item) {
+ $('input[name=vote]').val($(item).text());
+ });
+ }
+ });
+
// set team - require team leader to set correct number of players
// and keeps the hidden field updated
$('form.set-team').submit(function(event) {
@@ -37,7 +50,7 @@ var covertmission = function() {
event.preventDefault();
$('.validation-message').addClass('alert alert-error').html("Please select the correct number of players for your team");
} else {
- var $team_data = []
+ var $team_data = [];
$('button[data-toggle].active').each(function(key, item) {
$team_data.push($(item).attr('data-player-slug'));
});

0 comments on commit 0f3be06

Please sign in to comment.