Skip to content

Commit 116c6e5

Browse files
committed
Resolved issue #4, adding the capability to register time on issue update
1 parent 6b3c64b commit 116c6e5

File tree

4 files changed

+114
-9
lines changed

4 files changed

+114
-9
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<%
2+
# TODO concettualmente questi metodi sono helper e andrebbero quindi definiti
3+
# nel file helper
4+
5+
# Aggiunge uno "0" davanti al numero passato se è minore di 10
6+
def hours_min_string(number)
7+
str = number.to_s
8+
str = "0#{number}" if number < 10
9+
str
10+
end
11+
12+
# Restituisce un array di interi da 0 a 55 andando di 5 in 5
13+
def minutes
14+
mins = Array.new
15+
(0..3).each { |i| mins << 15 * i}
16+
mins
17+
end
18+
%>
19+
20+
<p>
21+
<%= time_entry.select :start_hour, (0..23).to_a.collect {|a| [hours_min_string(a), a]}, { :include_blank => true, :required => true } -%>:<%= time_entry.select :start_minute, minutes.collect {|m| [hours_min_string(m), m]}, { :include_blank => true } -%>
22+
</p>
23+
<p>
24+
<%= time_entry.select :end_hour, (0..23).to_a.collect {|a| [hours_min_string(a), a]}, { :include_blank => true, :required => true } -%>:<%= time_entry.select :end_minute, minutes.collect {|m| [hours_min_string(m), m]}, { :include_blank => true } -%>
25+
</p>
26+
<p><%= time_entry.text_field :billed_hours, :size => 6 %></p>
27+
28+
<%= render :partial => "common/auto_completion" %>

app/views/issues/_edit.rhtml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<%
2+
=begin
3+
XXX questa logica serve per vedere come integrare i nuovi campi della registrazione
4+
del tempo nell'update di una issue. da cancellare (deve stare nel partial comune
5+
con l'altra vista di edit).
6+
=end
7+
%>
8+
<%
9+
# TODO concettualmente questi metodi sono helper e andrebbero quindi definiti
10+
# nel file helper
11+
12+
# Aggiunge uno "0" davanti al numero passato se è minore di 10
13+
def hours_min_string(number)
14+
str = number.to_s
15+
str = "0#{number}" if number < 10
16+
str
17+
end
18+
19+
# Restituisce un array di interi da 0 a 55 andando di 5 in 5
20+
def minutes
21+
mins = Array.new
22+
(0..3).each { |i| mins << 15 * i}
23+
mins
24+
end
25+
%>
26+
27+
28+
<% labelled_tabular_form_for :issue, @issue,
29+
:url => {:action => 'update', :id => @issue},
30+
:html => {:id => 'issue-form',
31+
:class => nil,
32+
:method => :put,
33+
:multipart => true} do |f| %>
34+
<%= error_messages_for 'issue', 'time_entry' %>
35+
<div class="box">
36+
<% if @edit_allowed || !@allowed_statuses.empty? %>
37+
<fieldset class="tabular"><legend><%= l(:label_change_properties) %>
38+
<% if !@issue.new_record? && !@issue.errors.any? && @edit_allowed %>
39+
<small>(<%= link_to l(:label_more), {}, :onclick => 'Effect.toggle("issue_descr_fields", "appear", {duration:0.3}); return false;' %>)</small>
40+
<% end %>
41+
</legend>
42+
<%= render :partial => (@edit_allowed ? 'form' : 'form_update'), :locals => {:f => f} %>
43+
</fieldset>
44+
<% end %>
45+
<% if authorize_for('timelog', 'edit') %>
46+
<fieldset class="tabular"><legend><%= l(:button_log_time) %></legend>
47+
<% fields_for :time_entry, @time_entry, { :builder => TabularFormBuilder, :lang => current_language} do |time_entry| %>
48+
<div class="splitcontentleft">
49+
<p><%= time_entry.text_field :hours, :size => 6, :label => :label_spent_time %> <%= l(:field_hours) %></p>
50+
</div>
51+
<div class="splitcontentright">
52+
<p><%= time_entry.select :activity_id, activity_collection_for_select_options %></p>
53+
</div>
54+
<div class="splitcontentleft">
55+
<%= render :partial => 'common/custom_fields', :locals => {:time_entry => time_entry} %>
56+
</div>
57+
<p><%= time_entry.text_field :comments, :size => 60 %></p>
58+
<% @time_entry.custom_field_values.each do |value| %>
59+
<p><%= custom_field_tag_with_label :time_entry, value %></p>
60+
<% end %>
61+
<% end %>
62+
</fieldset>
63+
<% end %>
64+
65+
<fieldset><legend><%= l(:field_notes) %></legend>
66+
<%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %>
67+
<%= wikitoolbar_for 'notes' %>
68+
<%= call_hook(:view_issues_edit_notes_bottom, { :issue => @issue, :notes => @notes, :form => f }) %>
69+
70+
<p><%=l(:label_attachment_plural)%><br /><%= render :partial => 'attachments/form' %></p>
71+
</fieldset>
72+
</div>
73+
74+
<%= f.hidden_field :lock_version %>
75+
<%= submit_tag l(:button_submit) %>
76+
<%= link_to_remote l(:label_preview),
77+
{ :url => { :controller => 'issues', :action => 'preview', :project_id => @project, :id => @issue },
78+
:method => 'post',
79+
:update => 'preview',
80+
:with => 'Form.serialize("issue-form")',
81+
:complete => "Element.scrollTo('preview')"
82+
}, :accesskey => accesskey(:preview) %>
83+
<% end %>
84+
85+
<div id="preview" class="wiki"></div>

app/views/timelog/edit.rhtml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,9 @@
3636
<%# CPRS-MO %>
3737

3838
<div class="custom_time_fields">
39-
<p>
40-
<%= f.select :start_hour, (0..23).to_a.collect {|a| [hours_min_string(a), a]}, { :include_blank => true, :required => true } -%>:<%= f.select :start_minute, minutes.collect {|m| [hours_min_string(m), m]}, { :include_blank => true } -%>
41-
</p>
42-
<p>
43-
<%= f.select :end_hour, (0..23).to_a.collect {|a| [hours_min_string(a), a]}, { :include_blank => true, :required => true } -%>:<%= f.select :end_minute, minutes.collect {|m| [hours_min_string(m), m]}, { :include_blank => true } -%>
44-
</p>
45-
<p><%= f.text_field :billed_hours, :size => 6 %></p>
39+
<%= render :partial => 'common/custom_fields', :locals => {:time_entry => f} %>
4640
</div>
4741

48-
<%= render :partial => "auto_completion" %>
49-
5042
<%
5143
# FIXME
5244
# questa vista sovrascrive una vista esistente e si trova in un plugin:

0 commit comments

Comments
 (0)