@@ -1,83 +1,83 | |||
|
1 | 1 | <%= labelled_fields_for :issue, @issue do |f| %> |
|
2 | 2 | |
|
3 | 3 | <div class="splitcontent"> |
|
4 | 4 | <div class="splitcontentleft"> |
|
5 | 5 | <% if @issue.safe_attribute?('status_id') && @allowed_statuses.present? %> |
|
6 | 6 | <p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), {:required => true}, |
|
7 | 7 | :onchange => "updateIssueFrom('#{escape_javascript update_issue_form_path(@project, @issue)}', this)" %></p> |
|
8 | 8 | <%= hidden_field_tag 'was_default_status', @issue.status_id, :id => nil if @issue.status == @issue.default_status %> |
|
9 | 9 | <% else %> |
|
10 | 10 | <p><label><%= l(:field_status) %></label> <%= @issue.status %></p> |
|
11 | 11 | <% end %> |
|
12 | 12 | |
|
13 | 13 | <% if @issue.safe_attribute? 'priority_id' %> |
|
14 | 14 | <p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), {:required => true} %></p> |
|
15 | 15 | <% end %> |
|
16 | 16 | |
|
17 | 17 | <% if @issue.safe_attribute? 'assigned_to_id' %> |
|
18 | 18 | <p><%= f.select :assigned_to_id, principals_options_for_select(@issue.assignable_users, @issue.assigned_to), :include_blank => true, :required => @issue.required_attribute?('assigned_to_id') %></p> |
|
19 | 19 | <% end %> |
|
20 | 20 | |
|
21 | 21 | <% if @issue.safe_attribute?('category_id') && @issue.project.issue_categories.any? %> |
|
22 | 22 | <p><%= f.select :category_id, (@issue.project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true, :required => @issue.required_attribute?('category_id') %> |
|
23 | 23 | <%= link_to(l(:label_issue_category_new), |
|
24 | 24 | new_project_issue_category_path(@issue.project), |
|
25 | 25 | :remote => true, |
|
26 | 26 | :method => 'get', |
|
27 | 27 | :title => l(:label_issue_category_new), |
|
28 | 28 | :tabindex => 200, |
|
29 | 29 | :class => 'icon-only icon-add' |
|
30 | 30 | ) if User.current.allowed_to?(:manage_categories, @issue.project) %></p> |
|
31 | 31 | <% end %> |
|
32 | 32 | |
|
33 | 33 | <% if @issue.safe_attribute?('fixed_version_id') && @issue.assignable_versions.any? %> |
|
34 | 34 | <p><%= f.select :fixed_version_id, version_options_for_select(@issue.assignable_versions, @issue.fixed_version), :include_blank => true, :required => @issue.required_attribute?('fixed_version_id') %> |
|
35 | 35 | <%= link_to(l(:label_version_new), |
|
36 | 36 | new_project_version_path(@issue.project), |
|
37 | 37 | :remote => true, |
|
38 | 38 | :method => 'get', |
|
39 | 39 | :title => l(:label_version_new), |
|
40 | 40 | :tabindex => 200, |
|
41 | 41 | :class => 'icon-only icon-add' |
|
42 | 42 | ) if User.current.allowed_to?(:manage_versions, @issue.project) %> |
|
43 | 43 | </p> |
|
44 | 44 | <% end %> |
|
45 | 45 | </div> |
|
46 | 46 | |
|
47 | 47 | <div class="splitcontentright"> |
|
48 | 48 | <% if @issue.safe_attribute? 'parent_issue_id' %> |
|
49 | 49 | <p id="parent_issue"><%= f.text_field :parent_issue_id, :size => 10, :required => @issue.required_attribute?('parent_issue_id') %></p> |
|
50 | 50 | <%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @issue.project, :scope => Setting.cross_project_subtasks)}')" %> |
|
51 | 51 | <% end %> |
|
52 | 52 | |
|
53 | 53 | <% if @issue.safe_attribute? 'start_date' %> |
|
54 | 54 | <p id="start_date_area"> |
|
55 | 55 | <%= f.date_field(:start_date, :size => 10, :required => @issue.required_attribute?('start_date')) %> |
|
56 | 56 | <%= calendar_for('issue_start_date') %> |
|
57 | 57 | </p> |
|
58 | 58 | <% end %> |
|
59 | 59 | |
|
60 | 60 | <% if @issue.safe_attribute? 'due_date' %> |
|
61 | 61 | <p id="due_date_area"> |
|
62 | 62 | <%= f.date_field(:due_date, :size => 10, :required => @issue.required_attribute?('due_date')) %> |
|
63 | 63 | <%= calendar_for('issue_due_date') %> |
|
64 | 64 | </p> |
|
65 | 65 | <% end %> |
|
66 | 66 | |
|
67 | 67 | <% if @issue.safe_attribute? 'estimated_hours' %> |
|
68 |
<p><%= f. |
|
|
68 | <p><%= f.hours_field :estimated_hours, :size => 3, :required => @issue.required_attribute?('estimated_hours') %> <%= l(:field_hours) %></p> | |
|
69 | 69 | <% end %> |
|
70 | 70 | |
|
71 | 71 | <% if @issue.safe_attribute?('done_ratio') && Issue.use_field_for_done_ratio? %> |
|
72 | 72 | <p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }), :required => @issue.required_attribute?('done_ratio') %></p> |
|
73 | 73 | <% end %> |
|
74 | 74 | </div> |
|
75 | 75 | </div> |
|
76 | 76 | |
|
77 | 77 | <% if @issue.safe_attribute? 'custom_field_values' %> |
|
78 | 78 | <%= render :partial => 'issues/form_custom_fields' %> |
|
79 | 79 | <% end %> |
|
80 | 80 | |
|
81 | 81 | <% end %> |
|
82 | 82 | |
|
83 | 83 | <% include_calendar_headers_tags %> |
@@ -1,80 +1,80 | |||
|
1 | 1 | <%= labelled_form_for @issue, :html => {:id => 'issue-form', :multipart => true} do |f| %> |
|
2 | 2 | <%= error_messages_for 'issue', 'time_entry' %> |
|
3 | 3 | <%= render :partial => 'conflict' if @conflict %> |
|
4 | 4 | <div class="box"> |
|
5 | 5 | <% if @issue.attributes_editable? %> |
|
6 | 6 | <fieldset class="tabular"><legend><%= l(:label_change_properties) %></legend> |
|
7 | 7 | <div id="all_attributes"> |
|
8 | 8 | <%= render :partial => 'form', :locals => {:f => f} %> |
|
9 | 9 | </div> |
|
10 | 10 | </fieldset> |
|
11 | 11 | <% end %> |
|
12 | 12 | <% if User.current.allowed_to?(:log_time, @project) %> |
|
13 | 13 | <fieldset class="tabular"><legend><%= l(:button_log_time) %></legend> |
|
14 | 14 | <%= labelled_fields_for :time_entry, @time_entry do |time_entry| %> |
|
15 | 15 | <div class="splitcontent"> |
|
16 | 16 | <div class="splitcontentleft"> |
|
17 |
<p><%= time_entry. |
|
|
17 | <p><%= time_entry.hours_field :hours, :size => 6, :label => :label_spent_time %> <%= l(:field_hours) %></p> | |
|
18 | 18 | </div> |
|
19 | 19 | <div class="splitcontentright"> |
|
20 | 20 | <p><%= time_entry.select :activity_id, activity_collection_for_select_options %></p> |
|
21 | 21 | </div> |
|
22 | 22 | </div> |
|
23 | 23 | <p><%= time_entry.text_field :comments, :size => 60 %></p> |
|
24 | 24 | <% @time_entry.custom_field_values.each do |value| %> |
|
25 | 25 | <p><%= custom_field_tag_with_label :time_entry, value %></p> |
|
26 | 26 | <% end %> |
|
27 | 27 | <% end %> |
|
28 | 28 | </fieldset> |
|
29 | 29 | <% end %> |
|
30 | 30 | <% if @issue.notes_addable? %> |
|
31 | 31 | <fieldset><legend><%= l(:field_notes) %></legend> |
|
32 | 32 | <%= f.text_area :notes, :cols => 60, :rows => 10, :class => 'wiki-edit', :no_label => true %> |
|
33 | 33 | <%= wikitoolbar_for 'issue_notes' %> |
|
34 | 34 | |
|
35 | 35 | <% if @issue.safe_attribute? 'private_notes' %> |
|
36 | 36 | <%= f.check_box :private_notes, :no_label => true %> <label for="issue_private_notes"><%= l(:field_private_notes) %></label> |
|
37 | 37 | <% end %> |
|
38 | 38 | |
|
39 | 39 | <%= call_hook(:view_issues_edit_notes_bottom, { :issue => @issue, :notes => @notes, :form => f }) %> |
|
40 | 40 | </fieldset> |
|
41 | 41 | |
|
42 | 42 | <fieldset><legend><%= l(:label_attachment_plural) %></legend> |
|
43 | 43 | <% if @issue.attachments.any? && @issue.safe_attribute?('deleted_attachment_ids') %> |
|
44 | 44 | <div class="contextual"><%= link_to l(:label_edit_attachments), '#', :onclick => "$('#existing-attachments').toggle(); return false;" %></div> |
|
45 | 45 | <div id="existing-attachments" style="<%= @issue.deleted_attachment_ids.blank? ? 'display:none;' : '' %>"> |
|
46 | 46 | <% @issue.attachments.each do |attachment| %> |
|
47 | 47 | <span class="existing-attachment"> |
|
48 | 48 | <%= text_field_tag '', attachment.filename, :class => "filename", :disabled => true %> |
|
49 | 49 | <label> |
|
50 | 50 | <%= check_box_tag 'issue[deleted_attachment_ids][]', |
|
51 | 51 | attachment.id, |
|
52 | 52 | @issue.deleted_attachment_ids.include?(attachment.id), |
|
53 | 53 | :id => nil, :class => "deleted_attachment" %> <%= l(:button_delete) %> |
|
54 | 54 | </label> |
|
55 | 55 | </span> |
|
56 | 56 | <% end %> |
|
57 | 57 | <hr /> |
|
58 | 58 | </div> |
|
59 | 59 | <% end %> |
|
60 | 60 | |
|
61 | 61 | <div id="new-attachments" style="display:inline-block;"> |
|
62 | 62 | <%= render :partial => 'attachments/form', :locals => {:container => @issue} %> |
|
63 | 63 | </div> |
|
64 | 64 | </fieldset> |
|
65 | 65 | <% end %> |
|
66 | 66 | </div> |
|
67 | 67 | |
|
68 | 68 | <%= f.hidden_field :lock_version %> |
|
69 | 69 | <%= hidden_field_tag 'last_journal_id', params[:last_journal_id] || @issue.last_journal_id %> |
|
70 | 70 | <%= submit_tag l(:button_submit) %> |
|
71 | 71 | <%= preview_link preview_edit_issue_path(:project_id => @project, :id => @issue), 'issue-form' %> |
|
72 | 72 | | <%= link_to l(:button_cancel), {}, :onclick => "$('#update').hide(); return false;" %> |
|
73 | 73 | |
|
74 | 74 | <%= hidden_field_tag 'prev_issue_id', @prev_issue_id if @prev_issue_id %> |
|
75 | 75 | <%= hidden_field_tag 'next_issue_id', @next_issue_id if @next_issue_id %> |
|
76 | 76 | <%= hidden_field_tag 'issue_position', @issue_position if @issue_position %> |
|
77 | 77 | <%= hidden_field_tag 'issue_count', @issue_count if @issue_count %> |
|
78 | 78 | <% end %> |
|
79 | 79 | |
|
80 | 80 | <div id="preview" class="wiki"></div> |
@@ -1,47 +1,47 | |||
|
1 | 1 | <%= error_messages_for 'time_entry' %> |
|
2 | 2 | <%= back_url_hidden_field_tag %> |
|
3 | 3 | |
|
4 | 4 | <div class="box tabular"> |
|
5 | 5 | <% if @time_entry.new_record? %> |
|
6 | 6 | <% if params[:project_id] %> |
|
7 | 7 | <%= hidden_field_tag 'project_id', params[:project_id] %> |
|
8 | 8 | <% elsif params[:issue_id] %> |
|
9 | 9 | <%= hidden_field_tag 'issue_id', params[:issue_id] %> |
|
10 | 10 | <% else %> |
|
11 | 11 | <p><%= f.select :project_id, project_tree_options_for_select(Project.allowed_to(:log_time).to_a, :selected => @time_entry.project, :include_blank => true), :required => true %></p> |
|
12 | 12 | <% end %> |
|
13 | 13 | <% end %> |
|
14 | 14 | <p> |
|
15 | 15 | <%= f.text_field :issue_id, :size => 6 %> |
|
16 | 16 | <span id="time_entry_issue"> |
|
17 | 17 | <%= link_to_issue(@time_entry.issue) if @time_entry.issue.try(:visible?) %> |
|
18 | 18 | </span> |
|
19 | 19 | </p> |
|
20 | 20 | <p><%= f.date_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p> |
|
21 |
<p><%= f. |
|
|
21 | <p><%= f.hours_field :hours, :size => 6, :required => true %></p> | |
|
22 | 22 | <p><%= f.text_field :comments, :size => 100, :maxlength => 1024 %></p> |
|
23 | 23 | <p><%= f.select :activity_id, activity_collection_for_select_options(@time_entry), :required => true %></p> |
|
24 | 24 | <% @time_entry.custom_field_values.each do |value| %> |
|
25 | 25 | <p><%= custom_field_tag_with_label :time_entry, value %></p> |
|
26 | 26 | <% end %> |
|
27 | 27 | <%= call_hook(:view_timelog_edit_form_bottom, { :time_entry => @time_entry, :form => f }) %> |
|
28 | 28 | </div> |
|
29 | 29 | |
|
30 | 30 | <%= javascript_tag do %> |
|
31 | 31 | $(document).ready(function(){ |
|
32 | 32 | $('#time_entry_project_id, #time_entry_issue_id').change(function(){ |
|
33 | 33 | $.ajax({ |
|
34 | 34 | url: '<%= escape_javascript(@time_entry.new_record? ? new_time_entry_path(:format => 'js') : edit_time_entry_path(:format => 'js')) %>', |
|
35 | 35 | type: 'post', |
|
36 | 36 | data: $(this).closest('form').serialize() |
|
37 | 37 | }); |
|
38 | 38 | }); |
|
39 | 39 | }); |
|
40 | 40 | |
|
41 | 41 | observeAutocompleteField('time_entry_issue_id', '<%= escape_javascript auto_complete_issues_path(:project_id => @project, :scope => (@project ? nil : 'all'))%>', { |
|
42 | 42 | select: function(event, ui) { |
|
43 | 43 | $('#time_entry_issue').text(''); |
|
44 | 44 | $('#time_entry_issue_id').val(ui.item.value).change(); |
|
45 | 45 | } |
|
46 | 46 | }); |
|
47 | 47 | <% end %> |
@@ -1,55 +1,64 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2016 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require 'action_view/helpers/form_helper' |
|
19 | 19 | |
|
20 | 20 | class Redmine::Views::LabelledFormBuilder < ActionView::Helpers::FormBuilder |
|
21 | 21 | include Redmine::I18n |
|
22 | 22 | |
|
23 | 23 | (field_helpers.map(&:to_s) - %w(radio_button hidden_field fields_for check_box label) + |
|
24 | 24 | %w(date_select)).each do |selector| |
|
25 | 25 | src = <<-END_SRC |
|
26 | 26 | def #{selector}(field, options = {}) |
|
27 | 27 | label_for_field(field, options) + super(field, options.except(:label)).html_safe |
|
28 | 28 | end |
|
29 | 29 | END_SRC |
|
30 | 30 | class_eval src, __FILE__, __LINE__ |
|
31 | 31 | end |
|
32 | 32 | |
|
33 | 33 | def check_box(field, options={}, checked_value="1", unchecked_value="0") |
|
34 | 34 | label_for_field(field, options) + super(field, options.except(:label), checked_value, unchecked_value).html_safe |
|
35 | 35 | end |
|
36 | 36 | |
|
37 | 37 | def select(field, choices, options = {}, html_options = {}) |
|
38 | 38 | label_for_field(field, options) + super(field, choices, options, html_options.except(:label)).html_safe |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | def time_zone_select(field, priority_zones = nil, options = {}, html_options = {}) |
|
42 | 42 | label_for_field(field, options) + super(field, priority_zones, options, html_options.except(:label)).html_safe |
|
43 | 43 | end |
|
44 | 44 | |
|
45 | # A field for entering hours value | |
|
46 | def hours_field(field, options={}) | |
|
47 | # display the value before type cast when the entered value is not valid | |
|
48 | if @object.errors[field].blank? | |
|
49 | options = options.merge(:value => format_hours(@object.send field)) | |
|
50 | end | |
|
51 | text_field field, options | |
|
52 | end | |
|
53 | ||
|
45 | 54 | # Returns a label tag for the given field |
|
46 | 55 | def label_for_field(field, options = {}) |
|
47 | 56 | return ''.html_safe if options.delete(:no_label) |
|
48 | 57 | text = options[:label].is_a?(Symbol) ? l(options[:label]) : options[:label] |
|
49 | 58 | text ||= l(("field_" + field.to_s.gsub(/\_id$/, "")).to_sym) |
|
50 | 59 | text += @template.content_tag("span", " *", :class => "required") if options.delete(:required) |
|
51 | 60 | @template.content_tag("label", text.html_safe, |
|
52 | 61 | :class => (@object && @object.errors[field].present? ? "error" : nil), |
|
53 | 62 | :for => (@object_name.to_s + "_" + field.to_s)) |
|
54 | 63 | end |
|
55 | 64 | end |
General Comments 0
You need to be logged in to leave comments.
Login now