@@ -10,6 +10,7 @@ class MissionsController < ApplicationController |
||
| 10 | 10 |
def index |
| 11 | 11 |
@user = User.find(current_user.id) |
| 12 | 12 |
@missions = @user.mission_agent_invites.where(:status => 'accepted') |
| 13 |
+ @mission_control = Mission.where(:owner => @user) |
|
| 13 | 14 |
end |
| 14 | 15 |
|
| 15 | 16 |
def list |
@@ -65,7 +66,7 @@ class MissionsController < ApplicationController |
||
| 65 | 66 |
|
| 66 | 67 |
|
| 67 | 68 |
|
| 68 |
- format.html { redirect_to @mission, notice: 'Mission was successfully updated.' }
|
|
| 69 |
+ format.html { redirect_to mission_control_path(@mission), notice: 'Mission was successfully updated.' }
|
|
| 69 | 70 |
format.json { head :no_content }
|
| 70 | 71 |
else |
| 71 | 72 |
format.html { render action: 'edit' }
|
@@ -122,6 +123,16 @@ class MissionsController < ApplicationController |
||
| 122 | 123 |
format.json { head :no_content }
|
| 123 | 124 |
end |
| 124 | 125 |
end |
| 126 |
+ |
|
| 127 |
+ def validate_agent_step |
|
| 128 |
+ @step = MissionAgentStep.find(params[:mission_agent_step][:id]) |
|
| 129 |
+ @step.proof = params[:mission_agent_step][:proof] |
|
| 130 |
+ @step.completed = true |
|
| 131 |
+ @mission = @step.mission_agent.mission |
|
| 132 |
+ if @step.save |
|
| 133 |
+ redirect_to mission_path(@mission), notice: 'Step completed!' |
|
| 134 |
+ end |
|
| 135 |
+ end |
|
| 125 | 136 |
|
| 126 | 137 |
private |
| 127 | 138 |
# Use callbacks to share common setup or constraints between actions. |
@@ -131,6 +142,6 @@ class MissionsController < ApplicationController |
||
| 131 | 142 |
|
| 132 | 143 |
# Never trust parameters from the scary internet, only allow the white list through. |
| 133 | 144 |
def mission_params |
| 134 |
- params.require(:mission).permit(:title, :description, :status, :agent_search_start, :agent_search_end, :mission_agents_attributes => [:id, :mission_id, :description, :_destroy], :mission_agent_steps_attributes => [:id, :mission_agent_id, :description, :_destroy]) |
|
| 145 |
+ params.require(:mission).permit(:title, :description, :status, :agent_search_start, :agent_search_end, :mission_agents_attributes => [:id, :mission_id, :description, :_destroy], :mission_agent_steps_attributes => [:id, :mission_agent_id, :description, :proof, :_destroy]) |
|
| 135 | 146 |
end |
| 136 | 147 |
end |
@@ -62,9 +62,8 @@ |
||
| 62 | 62 |
</div> |
| 63 | 63 |
</div><!--/row--> |
| 64 | 64 |
|
| 65 |
- <footer> |
|
| 66 |
- <p>© Company 2014</p> |
|
| 67 |
- </footer> |
|
| 65 |
+ <%= render 'layouts/partials/footer' %> |
|
| 66 |
+ |
|
| 68 | 67 |
|
| 69 | 68 |
</div> <!-- /container --> |
| 70 | 69 |
|
@@ -0,0 +1,4 @@ |
||
| 1 |
+<footer> |
|
| 2 |
+ <hr> |
|
| 3 |
+ <p style="text-align: center;">© Avalanche 2014</p> |
|
| 4 |
+</footer> |
@@ -0,0 +1,6 @@ |
||
| 1 |
+<span class="label <%= @status_label %> pull-right" style="margin-top: 2px; padding-left: 20px; padding-right: 20px"> |
|
| 2 |
+ <h4 style="text-align: center"> |
|
| 3 |
+ <small style="color: white">status:</small><br> |
|
| 4 |
+ <%= @mission.status %> |
|
| 5 |
+ </h4> |
|
| 6 |
+ </span> |
@@ -4,4 +4,3 @@ |
||
| 4 | 4 |
|
| 5 | 5 |
<%= link_to 'Show', @mission %> | |
| 6 | 6 |
<%= link_to 'Back', missions_path %> |
| 7 |
-<%= link_to 'Launch', mission_launch_path %> |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 |
<div class="page-header"> |
| 2 |
- <h1>Current Missions</h1> |
|
| 2 |
+ <h1>Assigned Missions</h1> |
|
| 3 | 3 |
</div> |
| 4 | 4 |
<ul class="thumbnails"> |
| 5 | 5 |
<% @missions.each do |invite| %> |
@@ -10,4 +10,17 @@ |
||
| 10 | 10 |
</div> |
| 11 | 11 |
</li> |
| 12 | 12 |
<% end %> |
| 13 |
+</ul> |
|
| 14 |
+<div class="page-header"> |
|
| 15 |
+ <h1>Missions Control</h1> |
|
| 16 |
+</div> |
|
| 17 |
+<ul class="thumbnails"> |
|
| 18 |
+<% @mission_control.each do |mission| %> |
|
| 19 |
+ <li class="span4"> |
|
| 20 |
+ <div class="thumbnail" style= "padding: 5px;"> |
|
| 21 |
+ <h3 style= "padding: 5px;"><%= link_to mission.title, mission_control_path(mission) %></h3> |
|
| 22 |
+ <p style= "padding: 5px; height: 50px;"><%= mission.description %></p> |
|
| 23 |
+ </div> |
|
| 24 |
+ </li> |
|
| 25 |
+<% end %> |
|
| 13 | 26 |
</ul> |
@@ -1,60 +1,91 @@ |
||
| 1 | 1 |
<div class="page-header"> |
| 2 | 2 |
<h1> |
| 3 |
- Mission Control <small>(<%= @mission.title %>)</small> |
|
| 3 |
+ Mission Control |
|
| 4 |
+ <%= link_to 'Edit', edit_mission_path(@mission), :class => 'btn btn-mini btn-default' %> |
|
| 5 |
+ <%= link_to 'Launch', mission_launch_path, :class => 'btn btn-mini btn-danger' %> |
|
| 4 | 6 |
<% if @mission.status == 'Initializing' %> |
| 5 | 7 |
<% @status_label = 'label'%> |
| 6 | 8 |
<% end%> |
| 7 | 9 |
<% if @mission.status == 'Launched' %> |
| 8 | 10 |
<% @status_label = 'label-success'%> |
| 9 | 11 |
<% end%> |
| 10 |
- <span class="label <%= @status_label %> pull-right" style="margin-top: 2px;"><h4><%= @mission.status %><h4></span> |
|
| 12 |
+ <%= render 'mission_status' %> |
|
| 13 |
+ |
|
| 11 | 14 |
</h1> |
| 15 |
+ <small>Director: <%= link_to @mission.owner.username, agent_profile_path(@mission.owner.id) %></small> |
|
| 12 | 16 |
</div> |
| 13 | 17 |
|
| 14 |
-<p id="notice"><%= notice %></p> |
|
| 15 |
- |
|
| 16 |
-<p> |
|
| 17 |
- <strong>Owner: </strong> |
|
| 18 |
- <%= @mission.owner.username %> |
|
| 19 |
- |
|
| 20 |
-<p> |
|
| 21 |
- <strong>Description:</strong> |
|
| 22 |
- <%= @mission.description %> |
|
| 23 |
-</p> |
|
| 24 |
- |
|
| 25 |
-<p> |
|
| 26 |
- <strong>Status:</strong> |
|
| 27 |
- <%= @mission.status %> |
|
| 28 |
-</p> |
|
| 29 |
- |
|
| 30 |
-<p> |
|
| 31 |
- <strong>Agent search start:</strong> |
|
| 32 |
- <%= @mission.agent_search_start %> |
|
| 33 |
-</p> |
|
| 34 |
- |
|
| 35 |
-<p> |
|
| 36 |
- <strong>Agent search end:</strong> |
|
| 37 |
- <%= @mission.agent_search_end %> |
|
| 38 |
-</p> |
|
| 39 |
- |
|
| 40 |
-<% @agent_number = 1 %> |
|
| 41 |
-<% @mission.mission_agents.each do |agent| %> |
|
| 42 |
- <div class="well well-small"> |
|
| 43 |
- <h3>Agent <%= @agent_number %></h3> |
|
| 44 |
- <% if agent.user != nil %> |
|
| 45 |
- Name: <%= agent.user.email %><br> |
|
| 46 |
- Status: |
|
| 47 |
- <% agent.mission_agent_invites.each do |invite| %> |
|
| 48 |
- <% if invite.user = agent.user %> |
|
| 49 |
- <%= invite.status %> |
|
| 50 |
- <% end %> |
|
| 18 |
+<p class="lead"><strong>Mission: </strong><%= @mission.title %></p> |
|
| 19 |
+<p class="lead"><strong>Details: </strong><%= @mission.description %></p> |
|
| 20 |
+<hr> |
|
| 21 |
+<h2>Agent List</h2> |
|
| 22 |
+<% if @mission.mission_agents.length > 0 %> |
|
| 23 |
+ <div class="accordion" id="accordion_agents"> |
|
| 24 |
+ <% @agent_number = 1 %> |
|
| 25 |
+ <% @mission.mission_agents.each do |agent| %> |
|
| 26 |
+ <% if agent.mission_agent_invites.last != nil %> |
|
| 27 |
+ <% if agent.mission_agent_invites.last.status == 'accepted' %> |
|
| 28 |
+ <% @status_label = 'label-success'%> |
|
| 29 |
+ <% elsif agent.mission_agent_invites.last.status == 'denied' %> |
|
| 30 |
+ <% @status_label = 'label-important'%> |
|
| 31 |
+ <% else%> |
|
| 32 |
+ <% @status_label = 'label-default'%> |
|
| 33 |
+ <% end %> |
|
| 34 |
+ <% if agent.mission_agent_steps.length == 0 %> |
|
| 35 |
+ <% @agent_status = 'empty'%> |
|
| 51 | 36 |
<% end %> |
| 52 | 37 |
<% else %> |
| 53 |
- Agent not found! |
|
| 38 |
+ <% @status_label = 'label-important'%> |
|
| 39 |
+ <% @agent_status = 'missing'%> |
|
| 54 | 40 |
<% end %> |
| 41 |
+ <div class="accordion-group" style="margin-bottom: 10px;"> |
|
| 42 |
+ <div class="accordion-heading"> |
|
| 43 |
+ <a class="accordion-toggle pull-left" data-toggle="collapse" href="#collapse_<%= agent.id %>" > |
|
| 44 |
+ Agent <%= @agent_number %> |
|
| 45 |
+ <% if agent.user != nil %> |
|
| 46 |
+ <% if agent.user.username != nil %> |
|
| 47 |
+ - <%= agent.user.username %> |
|
| 48 |
+ <% else %> |
|
| 49 |
+ - <%= agent.user.email %> |
|
| 50 |
+ <% end %> |
|
| 51 |
+ <% agent.mission_agent_invites.each do |invite| %> |
|
| 52 |
+ <% if invite.user = agent.user %> |
|
| 53 |
+ <% end %> |
|
| 54 |
+ <% end %> |
|
| 55 |
+ <% end %> |
|
| 56 |
+ </a> |
|
| 57 |
+ <span class="label <%= @status_label %> pull-right" style="margin-top: 8px; margin-right: 10px"> |
|
| 58 |
+ |
|
| 59 |
+ <% if @agent_status != 'missing'%> |
|
| 60 |
+ <%= agent.mission_agent_invites.last.status %> |
|
| 61 |
+ <% else %> |
|
| 62 |
+ Agent not found! |
|
| 63 |
+ <% end %> |
|
| 64 |
+ </span> |
|
| 65 |
+ <div class="clearfix"></div> |
|
| 66 |
+ </div> |
|
| 67 |
+ <div id="collapse_<%= agent.id %>" class="accordion-body collapse <% if @agent_status == 'missing' || @agent_status == 'empty' %> out <% else %> in <% end %>"> |
|
| 68 |
+ <div class="accordion-inner"> |
|
| 69 |
+ <div class="row-fluid"> |
|
| 70 |
+ <ul class="thumbnails"> |
|
| 71 |
+ <% @step = 1 %> |
|
| 72 |
+ <% agent.mission_agent_steps.each do |step| %> |
|
| 73 |
+ <li class="span4"> |
|
| 74 |
+ <div class="thumbnail" style= "padding: 5px;"> |
|
| 75 |
+ <h3 style= "padding: 5px;">Step <%= @step %></h3> |
|
| 76 |
+ <p style= "padding: 5px; height: 50px;"><%= step.description %></p> |
|
| 77 |
+ </li> |
|
| 78 |
+ <% @step = @step + 1 %> |
|
| 79 |
+ <% end %> |
|
| 80 |
+ </ul> |
|
| 81 |
+ </div> |
|
| 82 |
+ </div> |
|
| 83 |
+ </div> |
|
| 84 |
+ </div> |
|
| 85 |
+ <% @agent_number = @agent_number + 1 %> |
|
| 86 |
+ <% end %> |
|
| 55 | 87 |
</div> |
| 56 |
- <% @agent_number = @agent_number + 1 %> |
|
| 57 |
-<% end %> |
|
| 58 |
- |
|
| 59 |
-<%= link_to 'Edit', edit_mission_path(@mission) %> | |
|
| 60 |
-<%= link_to 'Back', missions_path %> |
|
| 88 |
+<% else %> |
|
| 89 |
+<br> |
|
| 90 |
+<em>No agents were assigned for this mission! Please edit mission settings and add agents in the form.</em> |
|
| 91 |
+<% end %> |
@@ -1,34 +1,55 @@ |
||
| 1 | 1 |
<div class="page-header"> |
| 2 | 2 |
<h1> |
| 3 |
- Mission Details <small>(<%= @mission.title %>)</small> |
|
| 3 |
+ <%= @mission.title %> <small>(Mission Details)</small> |
|
| 4 | 4 |
<% if @mission.status == 'Initializing' %> |
| 5 | 5 |
<% @status_label = 'label'%> |
| 6 | 6 |
<% end%> |
| 7 | 7 |
<% if @mission.status == 'Launched' %> |
| 8 | 8 |
<% @status_label = 'label-success'%> |
| 9 | 9 |
<% end%> |
| 10 |
- <span class="label <%= @status_label %> pull-right" style="margin-top: 2px;"><h4><%= @mission.status %><h4></span> |
|
| 10 |
+ <%= render 'mission_status' %> |
|
| 11 | 11 |
</h1> |
| 12 |
+ <small>Director: <%= link_to @mission.owner.username, agent_profile_path(@mission.owner.id) %></small> |
|
| 12 | 13 |
</div> |
| 13 |
- |
|
| 14 |
-<p> |
|
| 15 |
- <%= @mission.description %> |
|
| 16 |
-</p> |
|
| 17 |
- |
|
| 18 |
-<p> |
|
| 19 |
- <strong>Mission Director: </strong> |
|
| 20 |
- <%= @mission.owner.username %> |
|
| 21 |
-</p> |
|
| 14 |
+<p class="lead"><strong>Details: </strong><%= @mission.description %></p> |
|
| 15 |
+<p class="lead"><strong>Objective: </strong><%= @agent.first.description %></p> |
|
| 16 |
+<ul class="thumbnails"> |
|
| 22 | 17 |
<% @step = 1 %> |
| 23 | 18 |
<% if @agent.length > 0 %> |
| 24 | 19 |
<% @agent.first.mission_agent_steps.each do |step| %> |
| 25 |
- <div> |
|
| 26 |
- <h3>Step <%= @step %></h3> |
|
| 27 |
- <%= step.description %> |
|
| 28 |
- <div> |
|
| 20 |
+ <li class="span4"> |
|
| 21 |
+ <div class="thumbnail" style= "padding: 5px;"> |
|
| 22 |
+ <h3 style= "padding: 5px;">Step <%= @step %></h3> |
|
| 23 |
+ <p style= "padding: 5px; height: 50px;"><%= step.description %></p> |
|
| 24 |
+ <a href="#myModal<%= @step %>" role="button" class="btn btn-block btn-default" data-toggle="modal">Validate</a> |
|
| 25 |
+ </li> |
|
| 29 | 26 |
<% @step = @step + 1 %> |
| 30 | 27 |
<% end %> |
| 31 | 28 |
<% end %> |
| 32 |
-<hr> |
|
| 29 |
+</ul> |
|
| 30 |
+ |
|
| 31 |
+<% @step = 1 %> |
|
| 32 |
+<% @agent.first.mission_agent_steps.each do |step| %> |
|
| 33 | 33 |
|
| 34 |
-<%= link_to 'Back', missions_path %> |
|
| 34 |
+<!-- Modal --> |
|
| 35 |
+<div id="myModal<%= @step %>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> |
|
| 36 |
+ <div class="modal-header"> |
|
| 37 |
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> |
|
| 38 |
+ <h3 id="myModalLabel">Validate Step <%= @step %> </h3> |
|
| 39 |
+ </div> |
|
| 40 |
+ <%= simple_form_for(step) do |f| %> |
|
| 41 |
+ <div class="modal-body"> |
|
| 42 |
+ <%= f.error_notification %> |
|
| 43 |
+ <div class="form-inputs"> |
|
| 44 |
+ <%= f.hidden_field :id %> |
|
| 45 |
+ <%= f.input :proof, :label => 'Answer', :input_html => { :class => 'span5'} %>
|
|
| 46 |
+ </div> |
|
| 47 |
+ </div> |
|
| 48 |
+ <div class="modal-footer"> |
|
| 49 |
+ <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button> |
|
| 50 |
+ <%= f.button :submit, 'Validate', :class => 'btn btn-success' %> |
|
| 51 |
+ </div> |
|
| 52 |
+ <% end %> |
|
| 53 |
+</div> |
|
| 54 |
+<% @step = @step + 1 %> |
|
| 55 |
+<% end %> |
@@ -10,6 +10,7 @@ AvalancheGame::Application.routes.draw do |
||
| 10 | 10 |
get "missions/:id/launch" => "missions#launch", :as => :mission_launch |
| 11 | 11 |
get "mission_control/:id" => "missions#mission_control", :as => :mission_control |
| 12 | 12 |
get "mission_list" => "missions#list", :as => :mission_list |
| 13 |
+ patch "mission_agent_step" => "missions#validate_agent_step", :as => :mission_agent_step |
|
| 13 | 14 |
resources :missions |
| 14 | 15 |
|
| 15 | 16 |
devise_for :users, :skip => [:sessions, :passwords, :confirmations, :registrations] |