@@ -182,4 +182,27 @@ span.btn-file .form-group { |
||
182 | 182 |
|
183 | 183 |
.steps-validation-title { |
184 | 184 |
padding-top: 5px; |
185 |
+} |
|
186 |
+ |
|
187 |
+.text-validation-form { |
|
188 |
+ .form-group { |
|
189 |
+ margin-top: 0px; |
|
190 |
+ margin-bottom: 0px; |
|
191 |
+ .control-label { |
|
192 |
+ margin: 0px; |
|
193 |
+ height: 0px; |
|
194 |
+ } |
|
195 |
+ } |
|
196 |
+ .text-validation-input { |
|
197 |
+ margin-top: -4px; |
|
198 |
+ font-size: 18px; |
|
199 |
+ margin-left: 14px; |
|
200 |
+ width: 85%; |
|
201 |
+ height: 20px; |
|
202 |
+ } |
|
203 |
+ .remove_nested_fields { |
|
204 |
+ margin-top: -38px; |
|
205 |
+ margin-left: 10px; |
|
206 |
+ padding-right: 0px; |
|
207 |
+ } |
|
185 | 208 |
} |
@@ -1,8 +1,10 @@ |
||
1 | 1 |
class AgentStep < ActiveRecord::Base |
2 | 2 |
belongs_to :mission_agent |
3 |
- has_many :step_validations |
|
3 |
+ has_many :step_validations, :dependent => :destroy |
|
4 | 4 |
has_many :step_submissions |
5 | 5 |
|
6 |
+ accepts_nested_attributes_for :step_validations, allow_destroy:true |
|
7 |
+ |
|
6 | 8 |
def create_submission(step_submission, contents) |
7 | 9 |
submission = StepSubmission.new(step_submission) |
8 | 10 |
submission.agent_step = self |
@@ -3,6 +3,10 @@ class StepValidation < ActiveRecord::Base |
||
3 | 3 |
has_many :submission_contents |
4 | 4 |
belongs_to :validation, polymorphic: true |
5 | 5 |
|
6 |
+ after_save :create_validation |
|
7 |
+ |
|
8 |
+ attr_writer :description |
|
9 |
+ |
|
6 | 10 |
def icon |
7 | 11 |
case self.validation_type |
8 | 12 |
when 'ValidationText' |
@@ -14,4 +18,23 @@ class StepValidation < ActiveRecord::Base |
||
14 | 18 |
end |
15 | 19 |
end |
16 | 20 |
|
21 |
+ def description |
|
22 |
+ @description || validation.description if validation |
|
23 |
+ end |
|
24 |
+ |
|
25 |
+ def description=(val) |
|
26 |
+ if self.validation_id == nil |
|
27 |
+ validation = ValidationText.create(step_validation_id: self.id, description: val) |
|
28 |
+ self.validation_id = validation.id |
|
29 |
+ self.validation_type = validation.class.to_s |
|
30 |
+ else |
|
31 |
+ validation = ValidationText.find(self.validation_id) |
|
32 |
+ validation.update(step_validation_id: self.id, description: val) |
|
33 |
+ end |
|
34 |
+ end |
|
35 |
+ |
|
36 |
+ def create_validation |
|
37 |
+ |
|
38 |
+ end |
|
39 |
+ |
|
17 | 40 |
end |
@@ -23,27 +23,8 @@ |
||
23 | 23 |
<%= ff.text_area :description, label: (t 'mission_editor.agents.description'), class: 'input-block-level', rows: 10 %> |
24 | 24 |
<% end %> |
25 | 25 |
<% end %> |
26 |
- <%= content_tag(:div, class: "panel-content panel-divider-top steps-validation") do %> |
|
27 |
- <%= content_tag(:div, class: "panel-text") do %> |
|
28 |
- <%= content_tag(:span, (t 'mission_editor.agents.step_validations'), class: "steps-validation-title pull-left") %> |
|
29 |
- <div class="nav btn pull-right validation_dropdown"> |
|
30 |
- <li class="dropdown"> |
|
31 |
- <a class="dropdown-toggle" data-toggle="dropdown" href="#"> |
|
32 |
- <%= (t 'mission_editor.agents.add_validation') %> |
|
33 |
- <span class="caret"></span> |
|
34 |
- </a> |
|
35 |
- <ul class="dropdown-menu dropdown-menu-right" role="menu"> |
|
36 |
- <li> |
|
37 |
- <%= link_to t('landing_page.en'), change_locale_path(:en) %> |
|
38 |
- </li> |
|
39 |
- <li> |
|
40 |
- <%= link_to t('landing_page.pt-BR'), change_locale_path(:"pt-BR") %> |
|
41 |
- </li> |
|
42 |
- </ul> |
|
43 |
- </li> |
|
44 |
- </div> |
|
45 |
- <% end %> |
|
46 |
- <% end %> |
|
26 |
+ <%= render :partial => 'form_step_validation', locals: {ff: ff} %> |
|
27 |
+ |
|
47 | 28 |
<% end %> |
48 | 29 |
<% end %> |
49 | 30 |
<% end %> |
@@ -0,0 +1,34 @@ |
||
1 |
+<% # Validation Type Dropdown Menu %> |
|
2 |
+<%= content_tag(:div, class: "panel-content panel-divider-top steps-validation") do %> |
|
3 |
+ <%= content_tag(:div, class: "panel-text") do %> |
|
4 |
+ <%= content_tag(:span, (t 'mission_editor.agents.step_validations'), class: "steps-validation-title pull-left") %> |
|
5 |
+ <div class="nav btn pull-right validation_dropdown"> |
|
6 |
+ <li class="dropdown"> |
|
7 |
+ <a class="dropdown-toggle" data-toggle="dropdown" href="#"> |
|
8 |
+ <%= (t 'mission_editor.agents.add_validation') %> |
|
9 |
+ <span class="caret"></span> |
|
10 |
+ </a> |
|
11 |
+ <ul class="dropdown-menu dropdown-menu-right" role="menu"> |
|
12 |
+ <li> |
|
13 |
+ <%= ff.link_to_add "Text Validation", :step_validations, :data => { :target => "#validations-container-#{ff.object.id.to_s}" } %> |
|
14 |
+ </li> |
|
15 |
+ </ul> |
|
16 |
+ </li> |
|
17 |
+ </div> |
|
18 |
+ <% end %> |
|
19 |
+<% end %> |
|
20 |
+ |
|
21 |
+<% # Text Validation Form %> |
|
22 |
+<%= content_tag(:div, id: "validations-container-#{ff.object.id.to_s}") do %> |
|
23 |
+ <%= ff.fields_for :step_validations, show_empty: false do |f_validation| %> |
|
24 |
+ <%= content_tag(:div, class: "panel-content panel-divider-top steps-validation") do %> |
|
25 |
+ <%= content_tag(:div, class: 'panel-heading') do %> |
|
26 |
+ <%= content_tag(:h3, class: 'panel-title text-validation-form') do %> |
|
27 |
+ <%= content_tag(:span, ('<i class="icon-chat"></i>'.html_safe), class: 'task-number') %> |
|
28 |
+ <%= f_validation.text_field :description, hide_label: true, placeholder: (t 'mission_editor.agents.text_validation_description'), class: 'text-validation-input' %> |
|
29 |
+ <%= f_validation.link_to_remove "X", class: 'pull-right btn btn-link' %> |
|
30 |
+ <% end %> |
|
31 |
+ <% end%> |
|
32 |
+ <% end%> |
|
33 |
+ <% end%> |
|
34 |
+<% end%> |
@@ -45,4 +45,5 @@ en: |
||
45 | 45 |
briefing: 'Briefing' |
46 | 46 |
save_agent: 'Save Agent' |
47 | 47 |
agent_details_help_title: 'Agent Details' |
48 |
- agent_details_help: 'Some tips about agents... coming soon' |
|
48 |
+ agent_details_help: 'Some tips about agents... coming soon' |
|
49 |
+ text_validation_description: 'Validation description' |
@@ -45,4 +45,5 @@ pt-BR: |
||
45 | 45 |
briefing: 'Briefing' |
46 | 46 |
save_agent: 'Salvar agente' |
47 | 47 |
agent_details_help_title: 'Detalhes do agente' |
48 |
- agent_details_help: 'Algumas dicas sobre como criar agentes em breve...' |
|
48 |
+ agent_details_help: 'Algumas dicas sobre como criar agentes em breve...' |
|
49 |
+ text_validation_description: 'Descreva a validação' |
@@ -0,0 +1,5 @@ |
||
1 |
+class AddValidationToAgentSteps < ActiveRecord::Migration |
|
2 |
+ def change |
|
3 |
+ add_reference :agent_steps, :step_validations, index: true |
|
4 |
+ end |
|
5 |
+end |
@@ -11,7 +11,7 @@ |
||
11 | 11 |
# |
12 | 12 |
# It's strongly recommended that you check this file into your version control system. |
13 | 13 |
|
14 |
-ActiveRecord::Schema.define(version: 20150227021951) do |
|
14 |
+ActiveRecord::Schema.define(version: 20150314233050) do |
|
15 | 15 |
|
16 | 16 |
# These are extensions that must be enabled in order to support this database |
17 | 17 |
enable_extension "plpgsql" |
@@ -26,10 +26,12 @@ ActiveRecord::Schema.define(version: 20150227021951) do |
||
26 | 26 |
t.datetime "created_at" |
27 | 27 |
t.datetime "updated_at" |
28 | 28 |
t.integer "step_submissions_id" |
29 |
+ t.integer "step_validations_id" |
|
29 | 30 |
end |
30 | 31 |
|
31 | 32 |
add_index "agent_steps", ["mission_agent_id"], name: "index_agent_steps_on_mission_agent_id", using: :btree |
32 | 33 |
add_index "agent_steps", ["step_submissions_id"], name: "index_agent_steps_on_step_submissions_id", using: :btree |
34 |
+ add_index "agent_steps", ["step_validations_id"], name: "index_agent_steps_on_step_validations_id", using: :btree |
|
33 | 35 |
|
34 | 36 |
create_table "blog_posts", force: true do |t| |
35 | 37 |
t.string "title" |