@@ -19,4 +19,5 @@ |
||
| 19 | 19 |
//= require summernote |
| 20 | 20 |
//= require turbolinks |
| 21 | 21 |
//= require google_analytics |
| 22 |
+//= require jquery_nested_form |
|
| 22 | 23 |
//= require_tree . |
@@ -0,0 +1,22 @@ |
||
| 1 |
+// Mission Editor |
|
| 2 |
+ |
|
| 3 |
+function attachHandler(jQuery) {
|
|
| 4 |
+ |
|
| 5 |
+ $(document).on('nested:fieldAdded', function(event){
|
|
| 6 |
+ |
|
| 7 |
+ var field = event.field; |
|
| 8 |
+ var acordion_toggle = field.find('.accordion-toggle');
|
|
| 9 |
+ var panel_body = field.find('.panel-body');
|
|
| 10 |
+ field.find(".panel").removeClass("hidden");
|
|
| 11 |
+ |
|
| 12 |
+ var timestamp = new Date().getUTCMilliseconds(); |
|
| 13 |
+ var new_id = "collapse_step_" + timestamp; |
|
| 14 |
+ acordion_toggle.attr("href", "#" + new_id);
|
|
| 15 |
+ panel_body.attr("id", new_id);
|
|
| 16 |
+ //alert(panel_body.id) |
|
| 17 |
+ }) |
|
| 18 |
+ |
|
| 19 |
+} |
|
| 20 |
+ |
|
| 21 |
+$(document).ready(attachHandler); |
|
| 22 |
+$(document).load(attachHandler); |
@@ -1,4 +1,4 @@ |
||
| 1 |
-# Missions JS |
|
| 1 |
+// Missions JS |
|
| 2 | 2 |
|
| 3 | 3 |
function attachHandler(jQuery) {
|
| 4 | 4 |
|
@@ -25,6 +25,8 @@ |
||
| 25 | 25 |
display: inline-block; |
| 26 | 26 |
padding: 4px 12px; |
| 27 | 27 |
margin-bottom: 0; |
| 28 |
+ margin-left: 5px; |
|
| 29 |
+ margin-right: 5px; |
|
| 28 | 30 |
text-align: center; |
| 29 | 31 |
vertical-align: middle; |
| 30 | 32 |
cursor: pointer; |
@@ -7,6 +7,20 @@ |
||
| 7 | 7 |
.box-theme; |
| 8 | 8 |
} |
| 9 | 9 |
|
| 10 |
+.panel.panel-white {
|
|
| 11 |
+ margin-top: 15px; |
|
| 12 |
+ .box-theme; |
|
| 13 |
+ background-color: @white; |
|
| 14 |
+ .panel-heading { background-color: @white; }
|
|
| 15 |
+} |
|
| 16 |
+ |
|
| 17 |
+.panel.panel-dashed {
|
|
| 18 |
+ margin-top: 15px; |
|
| 19 |
+ .box-theme; |
|
| 20 |
+ border: 2px dashed #AFB4BF; |
|
| 21 |
+ padding: 6px; |
|
| 22 |
+} |
|
| 23 |
+ |
|
| 10 | 24 |
.panel {
|
| 11 | 25 |
.panel-heading {
|
| 12 | 26 |
background-color: @light-gray; |
@@ -7,6 +7,14 @@ |
||
| 7 | 7 |
line-height: 17px; |
| 8 | 8 |
} |
| 9 | 9 |
|
| 10 |
+.banner-text {
|
|
| 11 |
+ font-family: Avenir-Black; |
|
| 12 |
+ font-size: 21px; |
|
| 13 |
+ color: #0F2105; |
|
| 14 |
+ line-height: 29px; |
|
| 15 |
+ text-transform: uppercase; |
|
| 16 |
+} |
|
| 17 |
+ |
|
| 10 | 18 |
// Typography Hacks |
| 11 | 19 |
|
| 12 | 20 |
.all-caps { text-transform: uppercase;}
|
@@ -131,4 +131,47 @@ span.btn-file .form-group {
|
||
| 131 | 131 |
p { margin-top: -15px;}
|
| 132 | 132 |
i { font-size: 210px;}
|
| 133 | 133 |
} |
| 134 |
+} |
|
| 135 |
+ |
|
| 136 |
+.mission-editor-agents-list {
|
|
| 137 |
+ margin-left: 0px; |
|
| 138 |
+ list-style: none; |
|
| 139 |
+ li.agent-box {
|
|
| 140 |
+ background-color: @white; |
|
| 141 |
+ margin-bottom: 35px; |
|
| 142 |
+ .thumbnail {
|
|
| 143 |
+ height: 315px; |
|
| 144 |
+ .thumbnail-agent-description {
|
|
| 145 |
+ height: 125px; |
|
| 146 |
+ } |
|
| 147 |
+ .thumbnail-banner {
|
|
| 148 |
+ text-align: center; |
|
| 149 |
+ background-color: @green; |
|
| 150 |
+ height: 50px; |
|
| 151 |
+ padding-top: 25px; |
|
| 152 |
+ p { .banner-text }
|
|
| 153 |
+ } |
|
| 154 |
+ } |
|
| 155 |
+ } |
|
| 156 |
+ .editor-reward {
|
|
| 157 |
+ height: 315px; |
|
| 158 |
+ border: @theme-border; |
|
| 159 |
+ border-radius: @theme-border-radius; |
|
| 160 |
+ background-color: @white; |
|
| 161 |
+ .theme-box-padding |
|
| 162 |
+ } |
|
| 163 |
+ .editor-reward-new {
|
|
| 164 |
+ height: 315px; |
|
| 165 |
+ border: 2px dashed #AFB4BF; |
|
| 166 |
+ border-radius: 10px; |
|
| 167 |
+ text-align: center; |
|
| 168 |
+ i { font-size: 220px; color: #AFB4BF; }
|
|
| 169 |
+ } |
|
| 170 |
+ .centered-editor-new {
|
|
| 171 |
+ width: 350px; |
|
| 172 |
+ margin-left: auto; |
|
| 173 |
+ margin-right: auto; |
|
| 174 |
+ p { margin-top: -15px;}
|
|
| 175 |
+ i { font-size: 210px;}
|
|
| 176 |
+ } |
|
| 134 | 177 |
} |
@@ -171,7 +171,7 @@ |
||
| 171 | 171 |
} |
| 172 | 172 |
|
| 173 | 173 |
.reward-blank {
|
| 174 |
- height: 120px; |
|
| 174 |
+ height: 130px; |
|
| 175 | 175 |
font-family: Avenir-MediumOblique; |
| 176 | 176 |
font-size: 14px; |
| 177 | 177 |
color: #3C3F47; |
@@ -1,13 +1,12 @@ |
||
| 1 |
-class MissionEditor::MissionAgentsController < MissionEditorController |
|
| 2 |
- |
|
| 3 |
- MissionAgentsController.append_view_path("views/mission_editor/mission_agents")
|
|
| 1 |
+class MissionEditor::AgentsController < ApplicationController |
|
| 4 | 2 |
|
| 5 | 3 |
before_action :set_mission_agent, only: [:show, :edit, :update, :destroy] |
| 4 |
+ before_action :set_mission |
|
| 6 | 5 |
|
| 7 | 6 |
# GET /mission_agents |
| 8 | 7 |
# GET /mission_agents.json |
| 9 | 8 |
def index |
| 10 |
- @mission_agents = MissionAgent.all |
|
| 9 |
+ @mission_agents = MissionAgent.where(mission: @mission) |
|
| 11 | 10 |
end |
| 12 | 11 |
|
| 13 | 12 |
# GET /mission_agents/1 |
@@ -18,6 +17,8 @@ class MissionEditor::MissionAgentsController < MissionEditorController |
||
| 18 | 17 |
# GET /mission_agents/new |
| 19 | 18 |
def new |
| 20 | 19 |
@mission_agent = MissionAgent.new |
| 20 |
+ @mission_agent.agent_steps.build |
|
| 21 |
+ |
|
| 21 | 22 |
end |
| 22 | 23 |
|
| 23 | 24 |
# GET /mission_agents/1/edit |
@@ -28,10 +29,10 @@ class MissionEditor::MissionAgentsController < MissionEditorController |
||
| 28 | 29 |
# POST /mission_agents.json |
| 29 | 30 |
def create |
| 30 | 31 |
@mission_agent = MissionAgent.new(mission_agent_params) |
| 31 |
- |
|
| 32 |
+ @mission_agent.mission = @mission |
|
| 32 | 33 |
respond_to do |format| |
| 33 | 34 |
if @mission_agent.save |
| 34 |
- format.html { redirect_to @mission_agent, notice: 'Mission agent was successfully created.' }
|
|
| 35 |
+ format.html { redirect_to mission_agents_path(@mission), notice: 'Mission agent was successfully created.' }
|
|
| 35 | 36 |
format.json { render action: 'show', status: :created, location: @mission_agent }
|
| 36 | 37 |
else |
| 37 | 38 |
format.html { render action: 'new' }
|
@@ -45,7 +46,7 @@ class MissionEditor::MissionAgentsController < MissionEditorController |
||
| 45 | 46 |
def update |
| 46 | 47 |
respond_to do |format| |
| 47 | 48 |
if @mission_agent.update(mission_agent_params) |
| 48 |
- format.html { redirect_to @mission_agent, notice: 'Mission agent was successfully updated.' }
|
|
| 49 |
+ format.html { redirect_to mission_agents_path(@mission), notice: 'Mission agent was successfully updated.' }
|
|
| 49 | 50 |
format.json { head :no_content }
|
| 50 | 51 |
else |
| 51 | 52 |
format.html { render action: 'edit' }
|
@@ -67,11 +68,15 @@ class MissionEditor::MissionAgentsController < MissionEditorController |
||
| 67 | 68 |
private |
| 68 | 69 |
# Use callbacks to share common setup or constraints between actions. |
| 69 | 70 |
def set_mission_agent |
| 70 |
- @mission_agent = MissionAgent.find(params[:id]) |
|
| 71 |
+ @mission_agent = MissionAgent.friendly.find(params[:id]) |
|
| 72 |
+ end |
|
| 73 |
+ |
|
| 74 |
+ def set_mission |
|
| 75 |
+ @mission = Mission.friendly.find(params[:mission]) |
|
| 71 | 76 |
end |
| 72 | 77 |
|
| 73 | 78 |
# Never trust parameters from the scary internet, only allow the white list through. |
| 74 | 79 |
def mission_agent_params |
| 75 |
- params[:mission_agent] |
|
| 80 |
+ params.require(:mission_agent).permit! |
|
| 76 | 81 |
end |
| 77 | 82 |
end |
@@ -1,7 +1,5 @@ |
||
| 1 | 1 |
class MissionEditor::RewardsController < ApplicationController |
| 2 |
- |
|
| 3 |
- |
|
| 4 |
- |
|
| 2 |
+ |
|
| 5 | 3 |
before_action :set_reward, only: [:edit, :update, :destroy] |
| 6 | 4 |
before_action :set_mission |
| 7 | 5 |
|
@@ -68,7 +66,7 @@ class MissionEditor::RewardsController < ApplicationController |
||
| 68 | 66 |
end |
| 69 | 67 |
|
| 70 | 68 |
def set_mission |
| 71 |
- @mission = Mission.friendly.find(params[:id]) |
|
| 69 |
+ @mission = Mission.friendly.find(params[:mission]) |
|
| 72 | 70 |
end |
| 73 | 71 |
|
| 74 | 72 |
# Never trust parameters from the scary internet, only allow the white list through. |
@@ -0,0 +1,28 @@ |
||
| 1 |
+<%= bootstrap_nested_form_for(@mission_agent, url: {action: form_action, mission: @mission.slug, id: @mission_agent.slug}) do |f| %>
|
|
| 2 |
+ <%= f.alert_message "Please fix the errors below." %> |
|
| 3 |
+ <%= content_tag(:div, class: 'panel panel-default') do %> |
|
| 4 |
+ <%= content_tag(:div, class: 'panel-body white-bg') do %> |
|
| 5 |
+ <%= content_tag(:div, class: "panel-content") do %> |
|
| 6 |
+ <%= content_tag(:div, class: "panel-text") do %> |
|
| 7 |
+ <%= content_tag(:div, class: "form-inputs") do %> |
|
| 8 |
+ <%= f.text_field :role, label: (t 'mission_editor.agents.role'), class: 'input-block-level' %> |
|
| 9 |
+ <%= f.text_area :objective, label: (t 'mission_editor.agents.objective'), class: 'input-block-level', rows: 5 %> |
|
| 10 |
+ <%= f.text_area :briefing, label: (t 'mission_editor.mission_details.briefing'), class: 'input-block-level', rows: 10 %> |
|
| 11 |
+ <% end %> |
|
| 12 |
+ <% end %> |
|
| 13 |
+ <% end %> |
|
| 14 |
+ <% end %> |
|
| 15 |
+ <% end %> |
|
| 16 |
+ |
|
| 17 |
+ <%= render :partial => 'form_step', locals: { mission_agent: @mission_agent, f: f } %>
|
|
| 18 |
+ |
|
| 19 |
+ |
|
| 20 |
+ <%= content_tag(:div, class: "form-submit-center") do %> |
|
| 21 |
+ <%= content_tag(:p) do %> |
|
| 22 |
+ <%= f.submit (t 'mission_editor.agents.save_agent'), class: 'btn btn-large btn-success spacer-left-small' %> |
|
| 23 |
+ <% end %> |
|
| 24 |
+ <%= content_tag(:p) do %> |
|
| 25 |
+ <%= link_to (t'nav.cancel'), mission_agents_path(@mission), class: 'btn btn-link btn-danger' %> |
|
| 26 |
+ <% end %> |
|
| 27 |
+ <% end %> |
|
| 28 |
+<% end %> |
@@ -0,0 +1,33 @@ |
||
| 1 |
+<%= content_tag(:div, id: 'steps_container') do %> |
|
| 2 |
+ <% step_number = 0 %> |
|
| 3 |
+ <%= f.fields_for :agent_steps, show_empty: false do |ff| %> |
|
| 4 |
+ <% step_number = step_number + 1%> |
|
| 5 |
+ <%= content_tag(:div, class: 'panel panel-white hidden') do %> |
|
| 6 |
+ <%= content_tag(:div, class: 'panel-heading') do %> |
|
| 7 |
+ <%= content_tag(:h3, class: 'panel-title') do %> |
|
| 8 |
+ <%= content_tag(:span, (ff.object.step.to_s != '' ? ff.object.step.to_s : '#'), class: 'task-number') %> |
|
| 9 |
+ <a class="accordion-toggle" data-toggle="collapse" data-parent="#colapse_steps" href="#collapse_step_<%= step_number.to_s %>"> |
|
| 10 |
+ <span class="caret"></span> |
|
| 11 |
+ <%= content_tag(:span, (t 'mission_editor.agents.step'), class: 'task-text') %> |
|
| 12 |
+ <%= content_tag(:span, ff.object.step.to_s, class: 'task-text') do %> |
|
| 13 |
+ <%= ff.link_to_remove "Remove", class: 'pull-right btn btn-danger btn-small' %> |
|
| 14 |
+ <% end %> |
|
| 15 |
+ </a> |
|
| 16 |
+ |
|
| 17 |
+ <% end %> |
|
| 18 |
+ <% end %> |
|
| 19 |
+ <%= content_tag(:div, class: 'panel-body collapse', id: ('collapse_step_' + step_number.to_s)) do %>
|
|
| 20 |
+ <%= content_tag(:div, class: "panel-content") do %> |
|
| 21 |
+ <%= content_tag(:div, class: "panel-text") do %> |
|
| 22 |
+ <%= ff.text_field :title, label: (t 'mission_editor.agents.step_title'), class: 'input-block-level' %> |
|
| 23 |
+ <%= ff.text_area :description, label: (t 'mission_editor.agents.description'), class: 'input-block-level', rows: 10 %> |
|
| 24 |
+ <% end %> |
|
| 25 |
+ |
|
| 26 |
+ <% end %> |
|
| 27 |
+ <% end %> |
|
| 28 |
+ <% end %> |
|
| 29 |
+ <% end %> |
|
| 30 |
+<% end %> |
|
| 31 |
+ <%= content_tag(:div, class: 'panel panel-dashed centered') do %> |
|
| 32 |
+ <%= f.link_to_add "Add a step", :agent_steps, class: 'btn', :data => { :target => "#steps_container" } %>
|
|
| 33 |
+<% end %> |
@@ -0,0 +1,20 @@ |
||
| 1 |
+<%= content_tag(:li, class: 'span4 agent-box') do %> |
|
| 2 |
+ <% content_tag(:div, class: 'thumbnail') do %> |
|
| 3 |
+ <%= content_tag(:div, class: 'thumbnail-content') do%> |
|
| 4 |
+ <%= content_tag(:h3, (link_to agent.role, mission_agent_details_path(mission, agent))) %> |
|
| 5 |
+ <%= content_tag(:p, agent.objective, class: 'thumbnail-agent-description') %> |
|
| 6 |
+ <% end %> |
|
| 7 |
+ <%= content_tag(:div, class: 'thumbnail-banner') do%> |
|
| 8 |
+ <%= content_tag(:p, (t 'mission_editor.agents.ok'), class: 'banner-text') %> |
|
| 9 |
+ <% end %> |
|
| 10 |
+ |
|
| 11 |
+ <% # Edit Agent %> |
|
| 12 |
+ <%= content_tag(:div, class: 'thumbnail-content thumbnail-line-top') do%> |
|
| 13 |
+ <%= content_tag(:div, class: 'centered') do %> |
|
| 14 |
+ <%= link_to (t'nav.edit'), url_for(controller: 'mission_editor/agents', action: 'edit', mission: @mission.slug, id: agent.slug, only_path: true), class: 'btn'%> |
|
| 15 |
+ <%= link_to (t'mission_editor.agents.view'), mission_agent_path(mission, agent), class: 'btn' %> |
|
| 16 |
+ <%= link_to (t'mission_editor.agents.destroy'), mission_agent_path(mission, agent), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %>
|
|
| 17 |
+ <% end %> |
|
| 18 |
+ <% end %> |
|
| 19 |
+ <% end %> |
|
| 20 |
+<% end %> |
@@ -0,0 +1,41 @@ |
||
| 1 |
+<% title "#{t 'mission_editor.agents.edit_agent'} - #{@config.website_name}" %>
|
|
| 2 |
+ |
|
| 3 |
+<%= render :partial => 'missions/mission_editor_tabs' %> |
|
| 4 |
+ |
|
| 5 |
+<%= content_tag(:div, class: 'container-bg') do %> |
|
| 6 |
+ <%= content_tag(:div, class: 'container container-bg mission-detail-container') do %> |
|
| 7 |
+ <%= content_tag(:div, class: 'row') do %> |
|
| 8 |
+ <%= content_tag(:div, class: 'span12') do %> |
|
| 9 |
+ |
|
| 10 |
+ <%= content_tag(:div, class: 'page-header page-header-type') do %> |
|
| 11 |
+ <%= content_tag(:small, @mission.title + ':') %> |
|
| 12 |
+ <%= content_tag(:h1) do %> |
|
| 13 |
+ <%= t 'mission_editor.agents.edit_agent' %> |
|
| 14 |
+ <% end %> |
|
| 15 |
+ <% end %> |
|
| 16 |
+ |
|
| 17 |
+ <% end%> |
|
| 18 |
+ <% end %> |
|
| 19 |
+ <%= content_tag(:div, class: 'row') do %> |
|
| 20 |
+ <%= content_tag(:div, class: 'span8') do %> |
|
| 21 |
+ |
|
| 22 |
+ <%= render :partial => 'form', locals: {form_action: 'update'} %>
|
|
| 23 |
+ |
|
| 24 |
+ <% end %> |
|
| 25 |
+ <% # Sidebar %> |
|
| 26 |
+ <%= content_tag(:div, class: 'span4 sidebar') do %> |
|
| 27 |
+ <%= content_tag(:div, class: 'panel panel-default sidebar-carret') do %> |
|
| 28 |
+ <%= content_tag(:div, class: 'panel-body white-bg') do %> |
|
| 29 |
+ <%= content_tag(:div, class: "panel-content") do %> |
|
| 30 |
+ <%= content_tag(:div, class: "panel-text") do %> |
|
| 31 |
+ <%= content_tag(:h3, (t 'mission_editor.agents.agent_details_help_title')) %> |
|
| 32 |
+ <%= content_tag(:div, (t 'mission_editor.agents.agent_details_help').html_safe, class: 'small-text') %> |
|
| 33 |
+ <% end %> |
|
| 34 |
+ <% end %> |
|
| 35 |
+ <% end %> |
|
| 36 |
+ <% end %> |
|
| 37 |
+ <% end %> |
|
| 38 |
+ |
|
| 39 |
+ <% end %> |
|
| 40 |
+ <% end %> |
|
| 41 |
+<% end %> |
@@ -0,0 +1,53 @@ |
||
| 1 |
+<%= render :partial => 'missions/mission_editor_tabs' %> |
|
| 2 |
+ |
|
| 3 |
+<%= content_tag(:div, class: 'container-bg') do %> |
|
| 4 |
+ <%= content_tag(:div, class: 'container container-bg mission-detail-container') do %> |
|
| 5 |
+ <%= content_tag(:div, class: 'row') do %> |
|
| 6 |
+ <%= content_tag(:div, class: 'span12') do %> |
|
| 7 |
+ |
|
| 8 |
+ <%= content_tag(:div, class: 'page-header page-header-type') do %> |
|
| 9 |
+ <%= content_tag(:small, @mission.title + ':') %> |
|
| 10 |
+ <%= content_tag(:h1) do %> |
|
| 11 |
+ <%= t 'mission_editor.agents.page_title' %> |
|
| 12 |
+ <% end %> |
|
| 13 |
+ <% end %> |
|
| 14 |
+ |
|
| 15 |
+ <% end%> |
|
| 16 |
+ <% end %> |
|
| 17 |
+ <%= content_tag(:div, class: 'row') do %> |
|
| 18 |
+ <%= content_tag(:ul, class: 'mission-editor-agents-list') do %> |
|
| 19 |
+ <% @mission_agents.each do |agent| %> |
|
| 20 |
+ <%= render :partial => 'mission_editor_agent', locals: {mission: @mission, agent: agent} %>
|
|
| 21 |
+ <% end %> |
|
| 22 |
+ |
|
| 23 |
+ <% if @mission_agents.count == 0 %> |
|
| 24 |
+ <% centered = ['span12', 'centered-editor-new', "<p>#{t'mission_editor.agents.no_agents'}</p>"] %>
|
|
| 25 |
+ <% else %> |
|
| 26 |
+ <% centered = ['span4', '', '<br>'] %> |
|
| 27 |
+ <% end %> |
|
| 28 |
+ <%= content_tag(:li, class: centered[0] ) do %> |
|
| 29 |
+ <%= content_tag(:div, class: "editor-reward-new #{centered[1]}") do %>
|
|
| 30 |
+ <i class="icon-agent"></i><br> |
|
| 31 |
+ <%= centered[2].html_safe %> |
|
| 32 |
+ <%= link_to (t'mission_editor.agents.add'), new_mission_agent_path(@mission), class: 'btn' %> |
|
| 33 |
+ <% end %> |
|
| 34 |
+ <% end %> |
|
| 35 |
+ <% end %> |
|
| 36 |
+ <% end %> |
|
| 37 |
+ <%= content_tag(:div, class: 'row') do %> |
|
| 38 |
+ <%= content_tag(:div, class: 'span12') do %> |
|
| 39 |
+ <%= content_tag(:div, class: "form-submit-center") do %> |
|
| 40 |
+ <%= content_tag(:p) do %> |
|
| 41 |
+ <%= link_to (t'nav.back'), rewards_path(@mission), class: 'btn spacer-right-small' %> |
|
| 42 |
+ <%= link_to((t'nav.next'), '#', class: 'btn btn-success')%> |
|
| 43 |
+ <% end %> |
|
| 44 |
+ <%= content_tag(:p) do %> |
|
| 45 |
+ <%= link_to (t'mission_editor.continue_later'), missions_path, class: 'btn btn-link btn-danger' %> |
|
| 46 |
+ <% end %> |
|
| 47 |
+ <% end %> |
|
| 48 |
+ <% end %> |
|
| 49 |
+ <% end %> |
|
| 50 |
+ |
|
| 51 |
+ |
|
| 52 |
+ <% end %> |
|
| 53 |
+<% end %> |
@@ -0,0 +1,41 @@ |
||
| 1 |
+<% title "#{t 'mission_editor.agents.add_agent'} - #{@config.website_name}" %>
|
|
| 2 |
+ |
|
| 3 |
+<%= render :partial => 'missions/mission_editor_tabs' %> |
|
| 4 |
+ |
|
| 5 |
+<%= content_tag(:div, class: 'container-bg') do %> |
|
| 6 |
+ <%= content_tag(:div, class: 'container container-bg mission-detail-container') do %> |
|
| 7 |
+ <%= content_tag(:div, class: 'row') do %> |
|
| 8 |
+ <%= content_tag(:div, class: 'span12') do %> |
|
| 9 |
+ |
|
| 10 |
+ <%= content_tag(:div, class: 'page-header page-header-type') do %> |
|
| 11 |
+ <%= content_tag(:small, @mission.title + ':') %> |
|
| 12 |
+ <%= content_tag(:h1) do %> |
|
| 13 |
+ <%= t 'mission_editor.agents.add_agent' %> |
|
| 14 |
+ <% end %> |
|
| 15 |
+ <% end %> |
|
| 16 |
+ |
|
| 17 |
+ <% end%> |
|
| 18 |
+ <% end %> |
|
| 19 |
+ <%= content_tag(:div, class: 'row') do %> |
|
| 20 |
+ <%= content_tag(:div, class: 'span8') do %> |
|
| 21 |
+ |
|
| 22 |
+ <%= render :partial => 'form', locals: {form_action: 'create'} %>
|
|
| 23 |
+ |
|
| 24 |
+ <% end %> |
|
| 25 |
+ <% # Sidebar %> |
|
| 26 |
+ <%= content_tag(:div, class: 'span4 sidebar') do %> |
|
| 27 |
+ <%= content_tag(:div, class: 'panel panel-default sidebar-carret') do %> |
|
| 28 |
+ <%= content_tag(:div, class: 'panel-body white-bg') do %> |
|
| 29 |
+ <%= content_tag(:div, class: "panel-content") do %> |
|
| 30 |
+ <%= content_tag(:div, class: "panel-text") do %> |
|
| 31 |
+ <%= content_tag(:h3, (t 'mission_editor.agents.agent_details_help_title')) %> |
|
| 32 |
+ <%= content_tag(:div, (t 'mission_editor.agents.agent_details_help').html_safe, class: 'small-text') %> |
|
| 33 |
+ <% end %> |
|
| 34 |
+ <% end %> |
|
| 35 |
+ <% end %> |
|
| 36 |
+ <% end %> |
|
| 37 |
+ <% end %> |
|
| 38 |
+ |
|
| 39 |
+ <% end %> |
|
| 40 |
+ <% end %> |
|
| 41 |
+<% end %> |
@@ -1,10 +0,0 @@ |
||
| 1 |
-<%= simple_form_for(@mission_agent) do |f| %> |
|
| 2 |
- <%= f.error_notification %> |
|
| 3 |
- |
|
| 4 |
- <div class="form-inputs"> |
|
| 5 |
- </div> |
|
| 6 |
- |
|
| 7 |
- <div class="form-actions"> |
|
| 8 |
- <%= f.button :submit %> |
|
| 9 |
- </div> |
|
| 10 |
-<% end %> |
@@ -1,6 +0,0 @@ |
||
| 1 |
-<h1>Editing mission_agent</h1> |
|
| 2 |
- |
|
| 3 |
-<%= render 'form' %> |
|
| 4 |
- |
|
| 5 |
-<%= link_to 'Show', @mission_agent %> | |
|
| 6 |
-<%= link_to 'Back', mission_agents_path %> |
@@ -1,25 +0,0 @@ |
||
| 1 |
-<h1>Listing mission_agents</h1> |
|
| 2 |
- |
|
| 3 |
-<table> |
|
| 4 |
- <thead> |
|
| 5 |
- <tr> |
|
| 6 |
- <th></th> |
|
| 7 |
- <th></th> |
|
| 8 |
- <th></th> |
|
| 9 |
- </tr> |
|
| 10 |
- </thead> |
|
| 11 |
- |
|
| 12 |
- <tbody> |
|
| 13 |
- <% @mission_agents.each do |mission_agent| %> |
|
| 14 |
- <tr> |
|
| 15 |
- <td><%= link_to 'Show', mission_agent %></td> |
|
| 16 |
- <td><%= link_to 'Edit', edit_mission_agent_path(mission_agent) %></td> |
|
| 17 |
- <td><%= link_to 'Destroy', mission_agent, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
|
| 18 |
- </tr> |
|
| 19 |
- <% end %> |
|
| 20 |
- </tbody> |
|
| 21 |
-</table> |
|
| 22 |
- |
|
| 23 |
-<br> |
|
| 24 |
- |
|
| 25 |
-<%= link_to 'New Mission agent', new_mission_agent_path %> |
@@ -1,5 +0,0 @@ |
||
| 1 |
-<h1>New mission_agent</h1> |
|
| 2 |
- |
|
| 3 |
-<%= render 'form' %> |
|
| 4 |
- |
|
| 5 |
-<%= link_to 'Back', mission_agents_path %> |
@@ -1,4 +1,4 @@ |
||
| 1 |
-<%= bootstrap_form_for(@reward, id: @mission.slug) do |f| %> |
|
| 1 |
+<%= bootstrap_form_for(@reward, url: {action: 'update', mission: @mission.slug, id: @reward.id}) do |f| %>
|
|
| 2 | 2 |
<%= f.alert_message "Please fix the errors below." %> |
| 3 | 3 |
<%= content_tag(:div, class: 'panel panel-default') do %> |
| 4 | 4 |
<%= content_tag(:div, class: 'panel-body white-bg') do %> |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 |
<% end %> |
| 26 | 26 |
<%= content_tag(:p, reward.description) %> |
| 27 | 27 |
<%= content_tag(:p, class: 'centered') do %> |
| 28 |
- <%= link_to( (t 'nav.edit'), edit_reward_path(reward), class: 'btn')%> |
|
| 28 |
+ <%= link_to( (t 'nav.edit'), edit_reward_path(reward, mission: @mission.slug), class: 'btn')%> |
|
| 29 | 29 |
<% end %> |
| 30 | 30 |
<% end %> |
| 31 | 31 |
<% end %> |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 |
<%= content_tag(:div, class: "form-submit-center") do %> |
| 46 | 46 |
<%= content_tag(:p) do %> |
| 47 | 47 |
<%= link_to (t'nav.back'), edit_mission_path(@mission), class: 'btn spacer-right-small' %> |
| 48 |
- <%= link_to((t'nav.next'), '#', class: 'btn btn-success')%> |
|
| 48 |
+ <%= link_to((t'nav.next'), mission_agents_path(@mission), class: 'btn btn-success')%> |
|
| 49 | 49 |
<% end %> |
| 50 | 50 |
<%= content_tag(:p) do %> |
| 51 | 51 |
<%= link_to (t'mission_editor.continue_later'), missions_path, class: 'btn btn-link btn-danger' %> |
@@ -30,4 +30,15 @@ en: |
||
| 30 | 30 |
rewards: |
| 31 | 31 |
page_title: 'Rewards' |
| 32 | 32 |
save_reward: 'Save Reward' |
| 33 |
- add: 'Add Reward' |
|
| 33 |
+ add: 'Add Reward' |
|
| 34 |
+ agents: |
|
| 35 |
+ page_title: 'Agents' |
|
| 36 |
+ add_agent: 'Add Agent' |
|
| 37 |
+ no_agents: 'No agents' |
|
| 38 |
+ add: 'Add Agent Role' |
|
| 39 |
+ role: 'Agent Role' |
|
| 40 |
+ objective: 'Objective' |
|
| 41 |
+ briefing: 'Briefing' |
|
| 42 |
+ save_agent: 'Save Agent' |
|
| 43 |
+ agent_details_help_title: 'Agent Details' |
|
| 44 |
+ agent_details_help: 'Some tips about agents... coming soon' |
@@ -30,4 +30,15 @@ pt-BR: |
||
| 30 | 30 |
rewards: |
| 31 | 31 |
page_title: 'Recompensas' |
| 32 | 32 |
save_reward: 'Salvar Recompensa' |
| 33 |
- add: 'Adicionar Recompensa' |
|
| 33 |
+ add: 'Adicionar Recompensa' |
|
| 34 |
+ agents: |
|
| 35 |
+ page_title: 'Agentes' |
|
| 36 |
+ add_agent: 'Criar agente' |
|
| 37 |
+ no_agents: 'Nenhum agente' |
|
| 38 |
+ add: 'Adicionar agente' |
|
| 39 |
+ role: 'Papel do agente' |
|
| 40 |
+ objective: 'Objetivo' |
|
| 41 |
+ briefing: 'Briefing' |
|
| 42 |
+ save_agent: 'Salvar agente' |
|
| 43 |
+ agent_details_help_title: 'Detalhes do agente' |
|
| 44 |
+ agent_details_help: 'Algumas dicas sobre como criar agentes em breve...' |
@@ -1,15 +1,15 @@ |
||
| 1 |
-pt-BR: |
|
| 1 |
+en: |
|
| 2 | 2 |
simple_form: |
| 3 |
- "sim": 'Sim' |
|
| 4 |
- "não": 'Não' |
|
| 3 |
+ "yes": 'Yes' |
|
| 4 |
+ "no": 'No' |
|
| 5 | 5 |
required: |
| 6 |
- text: 'necessario' |
|
| 6 |
+ text: 'required' |
|
| 7 | 7 |
mark: '*' |
| 8 | 8 |
# You can uncomment the line below if you need to overwrite the whole required html. |
| 9 | 9 |
# When using html, text and mark won't be used. |
| 10 | 10 |
# html: '<abbr title="required">*</abbr>' |
| 11 | 11 |
error_notification: |
| 12 |
- default_message: "Por favor revise os problemas abaixo:" |
|
| 12 |
+ default_message: "Please review the problems below:" |
|
| 13 | 13 |
# Labels and hints examples |
| 14 | 14 |
# labels: |
| 15 | 15 |
# defaults: |
@@ -36,9 +36,9 @@ Avalanche2::Application.routes.draw do |
||
| 36 | 36 |
|
| 37 | 37 |
# Mission Editor |
| 38 | 38 |
get 'missions/:id/editor' => 'missions#edit', as: :mission_editor |
| 39 |
- scope 'missions/:id/editor' do |
|
| 39 |
+ scope 'missions/:mission/editor' do |
|
| 40 | 40 |
resources :rewards, :controller => "mission_editor/rewards" |
| 41 |
- resources :mission_agents, :controller => "mission_editor/agents" |
|
| 41 |
+ resources :mission_agents, :controller => "mission_editor/agents", path: '/agents' |
|
| 42 | 42 |
end |
| 43 | 43 |
|
| 44 | 44 |
# get 'missions/:id/editor/rewards' => 'rewards#index', as: :mission_editor_rewards_list |
@@ -0,0 +1,114 @@ |
||
| 1 |
+(function($) {
|
|
| 2 |
+ window.NestedFormEvents = function() {
|
|
| 3 |
+ this.addFields = $.proxy(this.addFields, this); |
|
| 4 |
+ this.removeFields = $.proxy(this.removeFields, this); |
|
| 5 |
+ }; |
|
| 6 |
+ |
|
| 7 |
+ NestedFormEvents.prototype = {
|
|
| 8 |
+ addFields: function(e) {
|
|
| 9 |
+ // Setup |
|
| 10 |
+ var link = e.currentTarget; |
|
| 11 |
+ var assoc = $(link).data('association'); // Name of child
|
|
| 12 |
+ var blueprint = $('#' + $(link).data('blueprint-id'));
|
|
| 13 |
+ var content = blueprint.data('blueprint'); // Fields template
|
|
| 14 |
+ |
|
| 15 |
+ // Make the context correct by replacing <parents> with the generated ID |
|
| 16 |
+ // of each of the parent objects |
|
| 17 |
+ var context = ($(link).closest('.fields').closestChild('input, textarea, select').eq(0).attr('name') || '').replace(new RegExp('\[[a-z_]+\]$'), '');
|
|
| 18 |
+ |
|
| 19 |
+ // context will be something like this for a brand new form: |
|
| 20 |
+ // project[tasks_attributes][1255929127459][assignments_attributes][1255929128105] |
|
| 21 |
+ // or for an edit form: |
|
| 22 |
+ // project[tasks_attributes][0][assignments_attributes][1] |
|
| 23 |
+ if (context) {
|
|
| 24 |
+ var parentNames = context.match(/[a-z_]+_attributes(?=\]\[(new_)?\d+\])/g) || []; |
|
| 25 |
+ var parentIds = context.match(/[0-9]+/g) || []; |
|
| 26 |
+ |
|
| 27 |
+ for(var i = 0; i < parentNames.length; i++) {
|
|
| 28 |
+ if(parentIds[i]) {
|
|
| 29 |
+ content = content.replace( |
|
| 30 |
+ new RegExp('(_' + parentNames[i] + ')_.+?_', 'g'),
|
|
| 31 |
+ '$1_' + parentIds[i] + '_'); |
|
| 32 |
+ |
|
| 33 |
+ content = content.replace( |
|
| 34 |
+ new RegExp('(\\[' + parentNames[i] + '\\])\\[.+?\\]', 'g'),
|
|
| 35 |
+ '$1[' + parentIds[i] + ']'); |
|
| 36 |
+ } |
|
| 37 |
+ } |
|
| 38 |
+ } |
|
| 39 |
+ |
|
| 40 |
+ // Make a unique ID for the new child |
|
| 41 |
+ var regexp = new RegExp('new_' + assoc, 'g');
|
|
| 42 |
+ var new_id = this.newId(); |
|
| 43 |
+ content = $.trim(content.replace(regexp, new_id)); |
|
| 44 |
+ |
|
| 45 |
+ var field = this.insertFields(content, assoc, link); |
|
| 46 |
+ // bubble up event upto document (through form) |
|
| 47 |
+ field |
|
| 48 |
+ .trigger({ type: 'nested:fieldAdded', field: field })
|
|
| 49 |
+ .trigger({ type: 'nested:fieldAdded:' + assoc, field: field });
|
|
| 50 |
+ return false; |
|
| 51 |
+ }, |
|
| 52 |
+ newId: function() {
|
|
| 53 |
+ return new Date().getTime(); |
|
| 54 |
+ }, |
|
| 55 |
+ insertFields: function(content, assoc, link) {
|
|
| 56 |
+ var target = $(link).data('target');
|
|
| 57 |
+ if (target) {
|
|
| 58 |
+ return $(content).appendTo($(target)); |
|
| 59 |
+ } else {
|
|
| 60 |
+ return $(content).insertBefore(link); |
|
| 61 |
+ } |
|
| 62 |
+ }, |
|
| 63 |
+ removeFields: function(e) {
|
|
| 64 |
+ var $link = $(e.currentTarget), |
|
| 65 |
+ assoc = $link.data('association'); // Name of child to be removed
|
|
| 66 |
+ |
|
| 67 |
+ var hiddenField = $link.prev('input[type=hidden]');
|
|
| 68 |
+ hiddenField.val('1');
|
|
| 69 |
+ |
|
| 70 |
+ var field = $link.closest('.fields');
|
|
| 71 |
+ field.hide(); |
|
| 72 |
+ |
|
| 73 |
+ field |
|
| 74 |
+ .trigger({ type: 'nested:fieldRemoved', field: field })
|
|
| 75 |
+ .trigger({ type: 'nested:fieldRemoved:' + assoc, field: field });
|
|
| 76 |
+ return false; |
|
| 77 |
+ } |
|
| 78 |
+ }; |
|
| 79 |
+ |
|
| 80 |
+ window.nestedFormEvents = new NestedFormEvents(); |
|
| 81 |
+ $(document) |
|
| 82 |
+ .delegate('form a.add_nested_fields', 'click', nestedFormEvents.addFields)
|
|
| 83 |
+ .delegate('form a.remove_nested_fields', 'click', nestedFormEvents.removeFields);
|
|
| 84 |
+})(jQuery); |
|
| 85 |
+ |
|
| 86 |
+// http://plugins.jquery.com/project/closestChild |
|
| 87 |
+/* |
|
| 88 |
+ * Copyright 2011, Tobias Lindig |
|
| 89 |
+ * |
|
| 90 |
+ * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) |
|
| 91 |
+ * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. |
|
| 92 |
+ * |
|
| 93 |
+ */ |
|
| 94 |
+(function($) {
|
|
| 95 |
+ $.fn.closestChild = function(selector) {
|
|
| 96 |
+ // breadth first search for the first matched node |
|
| 97 |
+ if (selector && selector != '') {
|
|
| 98 |
+ var queue = []; |
|
| 99 |
+ queue.push(this); |
|
| 100 |
+ while(queue.length > 0) {
|
|
| 101 |
+ var node = queue.shift(); |
|
| 102 |
+ var children = node.children(); |
|
| 103 |
+ for(var i = 0; i < children.length; ++i) {
|
|
| 104 |
+ var child = $(children[i]); |
|
| 105 |
+ if (child.is(selector)) {
|
|
| 106 |
+ return child; //well, we found one |
|
| 107 |
+ } |
|
| 108 |
+ queue.push(child); |
|
| 109 |
+ } |
|
| 110 |
+ } |
|
| 111 |
+ } |
|
| 112 |
+ return $();//nothing found |
|
| 113 |
+ }; |
|
| 114 |
+})(jQuery); |
@@ -1,4 +1,12 @@ |
||
| 1 |
-# Avalanche Network (avalanche2) |
|
| 1 |
+ ___ _ __ ___ __ ___ _ __ ______ __ __ ______ |
|
| 2 |
+ / || | / // | / / / | / | / // ____// / / // ____/ |
|
| 3 |
+ / /| || | / // /| | / / / /| | / |/ // / / /_/ // __/ |
|
| 4 |
+ / ___ || |/ // ___ | / /___ / ___ | / /| // /___ / __ // /___ |
|
| 5 |
+ /_/ |_||___//_/ |_|/_____//_/ |_|/_/ |_/ \____//_/ /_//_____/ |
|
| 6 |
+ |
|
| 7 |
+ |
|
| 8 |
+ |
|
| 9 |
+# avl2 system |
|
| 2 | 10 |
|
| 3 | 11 |
Second prototype source code of the avalanche network web app. |
| 4 | 12 |
|
@@ -44,10 +52,10 @@ Second prototype source code of the avalanche network web app. |
||
| 44 | 52 |
|
| 45 | 53 |
--------------- |
| 46 | 54 |
|
| 47 |
- |
|
| 48 | 55 |
# Avalanche2 Dev Notes |
| 49 | 56 |
|
| 50 | 57 |
## System Scaffolding |
| 58 |
+ |
|
| 51 | 59 |
|
| 52 | 60 |
# Mission |
| 53 | 61 |
rails g scaffold mission mission_agents:references title:string objective:string briefing:text owner:references status:integer launched:boolean |
@@ -97,9 +105,11 @@ Second prototype source code of the avalanche network web app. |
||
| 97 | 105 |
|
| 98 | 106 |
|
| 99 | 107 |
## Undone Commands |
| 108 |
+ |
|
| 100 | 109 |
|
| 101 | 110 |
# Mailers |
| 102 | 111 |
rails g mailer MissionMailer |
| 112 |
+ |
|
| 103 | 113 |
|
| 104 | 114 |
## To dos |
| 105 | 115 |
|
@@ -147,6 +157,8 @@ The *submission_content* class is also responsible for triggering the automatic |
||
| 147 | 157 |
* Enviar uma imagem para cada tela do app |
| 148 | 158 |
* Espere a validação pelo diretor da missão |
| 149 | 159 |
|
| 160 |
+---------------------- |
|
| 161 |
+ |
|
| 150 | 162 |
<!-- Highlight syntax for Mou.app, insert at the bottom of the markdown document --> |
| 151 | 163 |
|
| 152 | 164 |
<script src="http://yandex.st/highlightjs/7.3/highlight.min.js"></script> |