Add GoalController: #index, #new, #create
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
<div class="tabular">
|
||||
<%= fields_for 'measurement[routine_attributes]', routine do |ff| %>
|
||||
<%= ff.hidden_field :id %>
|
||||
<p>
|
||||
<label><%= l(:field_name) %><span class="required"> *</span></label>
|
||||
<%= ff.text_field :name, required: true, style: "width: 95%;" %>
|
||||
</p>
|
||||
<p>
|
||||
<label><%= l(:field_description) %></label>
|
||||
<%= ff.text_area :description, cols: 40, rows: 3, style: "width: 95%;" %>
|
||||
</p>
|
||||
<% end %>
|
||||
<%= error_messages_for @goal %>
|
||||
|
||||
<div class="box tabular">
|
||||
<p><%= goal_f.text_field :name, required: true, style: "width: 95%;" %></p>
|
||||
<p><%= goal_f.text_area :description, rows: 3, style: "width: 95%;" %></p>
|
||||
|
||||
<hr style="width: 95%;">
|
||||
|
||||
<%= render partial: 'targets/form', locals: {goal_f: goal_f} %>
|
||||
</div>
|
||||
|
||||
32
app/views/goals/_index.html.erb
Normal file
32
app/views/goals/_index.html.erb
Normal file
@@ -0,0 +1,32 @@
|
||||
<% if @goals.any? %>
|
||||
<table id="goals" class="list odd-even">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= l(:field_name) %></th>
|
||||
<th><%= l(:field_description) %></th>
|
||||
<th style="width:5%"><%= l(:field_action) %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @goals.each do |g| %>
|
||||
<tr id="goal-<%= g.id %>" class="primary goal">
|
||||
<td class="name unwrappable">
|
||||
<div style="float:left;">
|
||||
<%= checked_image g.is_binding %><%= link_to g.name, g %>
|
||||
</div>
|
||||
<div style="float:right;">
|
||||
<%# TODO: display # of active targets/targeted quantities %>
|
||||
<small><%#= " (#{pluralize(m.readouts.size, 'readout')})" %></small>
|
||||
</div>
|
||||
</td>
|
||||
<td class="description ellipsible"><%= g.description %></td>
|
||||
<td class="action unwrappable">
|
||||
<%= delete_link(g, {remote: true, data: {}}) unless g.is_binding %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% end %>
|
||||
16
app/views/goals/_new_form.html.erb
Normal file
16
app/views/goals/_new_form.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
<h2><%= t ".heading_new_goal" %></h2>
|
||||
|
||||
<%= labelled_form_for [@project, @goal], remote: true,
|
||||
html: {id: 'new-goal-form', name: 'new-goal-form'} do |goal_f| %>
|
||||
|
||||
<%= render partial: 'goals/form', locals: {goal_f: goal_f} %>
|
||||
|
||||
<div class="tabular">
|
||||
<p>
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<%= link_to l(:button_cancel), "#",
|
||||
onclick: "$('#new-goal').empty(); return false;" %>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
<hr>
|
||||
2
app/views/goals/create.js.erb
Normal file
2
app/views/goals/create.js.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
$('#new-goal').empty();
|
||||
$('#goals').html('<%= j render partial: 'goals/index' %>');
|
||||
13
app/views/goals/index.html.erb
Normal file
13
app/views/goals/index.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<div class="contextual">
|
||||
<%= link_to_if User.current.allowed_to?(:manage_body_trackers, @project),
|
||||
t(".link_new_goal"), new_project_goal_path(@project),
|
||||
{remote: true, class: 'icon icon-add'} %>
|
||||
</div>
|
||||
|
||||
<div id="new-goal">
|
||||
</div>
|
||||
|
||||
<%= title t(:body_trackers_title), t(".heading") %>
|
||||
<div id='goals'>
|
||||
<%= render partial: 'goals/index' %>
|
||||
</div>
|
||||
1
app/views/goals/new.js.erb
Normal file
1
app/views/goals/new.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$('#new-goal').html('<%= j render partial: 'goals/new_form' %>');
|
||||
Reference in New Issue
Block a user