* code and views cleaning

* javascript added on custom field form to show/hide fields according to the format of custom field

git-svn-id: http://redmine.rubyforge.org/svn/trunk@100 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2006-12-17 14:22:09 +00:00
parent 2b86ef8e28
commit 918123cd06
17 changed files with 93 additions and 67 deletions

View File

@ -293,8 +293,11 @@ class ProjectsController < ApplicationController
new_project = Project.find(params[:new_project_id]) new_project = Project.find(params[:new_project_id])
new_tracker = Tracker.find(params[:new_tracker_id]) new_tracker = Tracker.find(params[:new_tracker_id])
@issues.each { |i| @issues.each { |i|
# category is project dependent # project dependent properties
i.category = nil unless i.project_id == new_project.id unless i.project_id == new_project.id
i.category = nil
i.fixed_version = nil
end
# move the issue # move the issue
i.project = new_project i.project = new_project
i.tracker = new_tracker i.tracker = new_tracker

View File

@ -161,6 +161,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
(field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector| (field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector|
src = <<-END_SRC src = <<-END_SRC
def #{selector}(field, options = {}) def #{selector}(field, options = {})
return super if options.delete :no_label
label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "") label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
label = @template.content_tag("label", label_text, label = @template.content_tag("label", label_text,
:class => (@object.errors[field] ? "error" : nil), :class => (@object.errors[field] ? "error" : nil),
@ -171,7 +172,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
class_eval src, __FILE__, __LINE__ class_eval src, __FILE__, __LINE__
end end
def select(field, choices, options = {}) def select(field, choices, options = {}, html_options = {})
label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "") label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
label = @template.content_tag("label", label_text, label = @template.content_tag("label", label_text,
:class => (@object.errors[field] ? "error" : nil), :class => (@object.errors[field] ? "error" : nil),

View File

@ -72,6 +72,6 @@ module CustomFieldsHelper
# Return an array of custom field formats which can be used in select_tag # Return an array of custom field formats which can be used in select_tag
def custom_field_formats_for_select def custom_field_formats_for_select
CustomField::FIELD_FORMATS.keys.collect { |k| [ l(CustomField::FIELD_FORMATS[k]), k ] } CustomField::FIELD_FORMATS.sort {|a,b| a[1][:order]<=>b[1][:order]}.collect { |k| [ l(k[1][:name]), k[0] ] }
end end
end end

View File

@ -18,12 +18,12 @@
class CustomField < ActiveRecord::Base class CustomField < ActiveRecord::Base
has_many :custom_values, :dependent => true has_many :custom_values, :dependent => true
FIELD_FORMATS = { "list" => :label_list, FIELD_FORMATS = { "string" => { :name => :label_string, :order => 1 },
"date" => :label_date, "text" => { :name => :label_text, :order => 2 },
"bool" => :label_boolean, "int" => { :name => :label_integer, :order => 3 },
"int" => :label_integer, "list" => { :name => :label_list, :order => 4 },
"string" => :label_string, "date" => { :name => :label_date, :order => 5 },
"text" => :label_text "bool" => { :name => :label_boolean, :order => 6 }
}.freeze }.freeze
validates_presence_of :name, :field_format validates_presence_of :name, :field_format

View File

@ -6,7 +6,7 @@
<li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li> <li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li>
<% for custom_value in @custom_values %> <% for custom_value in @custom_values %>
<% if !custom_value.value.empty? %> <% if !custom_value.value.empty? %>
<li><%= custom_value.custom_field.name%>: <%= show_value(custom_value) %></li> <li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
<% end %> <% end %>
<% end %> <% end %>
</ul> </ul>

View File

@ -1,52 +1,70 @@
<%= error_messages_for 'custom_field' %> <%= error_messages_for 'custom_field' %>
<script>
function toggle_custom_field_format() {
format = $("custom_field_field_format");
p_length = $("custom_field_min_length");
p_regexp = $("custom_field_regexp");
p_values = $("custom_field_possible_values");
switch (format.value) {
case "list":
Element.hide(p_length.parentNode);
Element.hide(p_regexp.parentNode);
Element.show(p_values.parentNode);
break;
case "int":
case "string":
case "text":
Element.show(p_length.parentNode);
Element.show(p_regexp.parentNode);
Element.hide(p_values.parentNode);
break;
case "date":
case "bool":
Element.hide(p_length.parentNode);
Element.hide(p_regexp.parentNode);
Element.hide(p_values.parentNode);
break;
default:
Element.show(p_length.parentNode);
Element.show(p_regexp.parentNode);
Element.show(p_values.parentNode);
break;
}
}
</script>
<!--[form:custom_field]--> <!--[form:custom_field]-->
<div class="box"> <div class="box">
<p><label for="custom_field_name"><%=l(:field_name)%><span class="required"> *</span></label> <p><%= f.text_field :name, :required => true %></p>
<%= text_field 'custom_field', 'name' %></p> <p><%= f.select :field_format, custom_field_formats_for_select, {}, :onchange => "toggle_custom_field_format();" %></p>
<p><label for="custom_field_field_format"><%=l(:field_field_format)%></label>
<%= select("custom_field", "field_format", custom_field_formats_for_select) %></p>
<p><label for="custom_field_min_length"><%=l(:label_min_max_length)%></label> <p><label for="custom_field_min_length"><%=l(:label_min_max_length)%></label>
<%= text_field 'custom_field', 'min_length', :size => 5 %> - <%= f.text_field :min_length, :size => 5, :no_label => true %> -
<%= text_field 'custom_field', 'max_length', :size => 5 %><br>(<%=l(:text_min_max_length_info)%>)</p> <%= f.text_field :max_length, :size => 5, :no_label => true %><br>(<%=l(:text_min_max_length_info)%>)</p>
<p><%= f.text_field :regexp, :size => 50 %><br>(<%=l(:text_regexp_info)%>)</p>
<p><label for="custom_field_regexp"><%=l(:field_regexp)%></label> <p><%= f.text_area :possible_values, :rows => 5, :cols => 60 %><br>(<%=l(:text_possible_values_info)%>)</p>
<%= text_field 'custom_field', 'regexp', :size => 50 %><br>(<%=l(:text_regexp_info)%>)</p>
<p><label for="custom_field_possible_values"><%=l(:field_possible_values)%></label>
<%= text_area 'custom_field', 'possible_values', :rows => 5, :cols => 60 %><br>(<%=l(:text_possible_values_info)%>)</p>
</div> </div>
<%= javascript_tag "toggle_custom_field_format();" %>
<!--[eoform:custom_field]--> <!--[eoform:custom_field]-->
<div class="box"> <div class="box">
<% case type.to_s <% case @custom_field.type.to_s
when "IssueCustomField" %> when "IssueCustomField" %>
<fieldset><legend><%=l(:label_tracker_plural)%></legend> <fieldset><legend><%=l(:label_tracker_plural)%></legend>
<% for tracker in @trackers %> <% for tracker in @trackers %>
<input type="checkbox" <%= check_box_tag "tracker_ids[]", tracker.id, (@custom_field.trackers.include? tracker) %> <%= tracker.name %>
name="tracker_ids[]" <% end %>
value="<%= tracker.id %>" </fieldset>
<%if @custom_field.trackers.include? tracker%>checked="checked"<%end%> &nbsp;
> <%= tracker.name %> <p><%= f.check_box :is_required %></p>
<% end %></fieldset> <p><%= f.check_box :is_for_all %></p>
&nbsp;
<% when "UserCustomField" %>
<p><%= f.check_box :is_required %></p>
<p><label for="custom_field_is_required"><%=l(:field_is_required)%></label> <% when "ProjectCustomField" %>
<%= check_box 'custom_field', 'is_required' %></p> <p><%= f.check_box :is_required %></p>
<p><label for="custom_field_is_for_all"><%=l(:field_is_for_all)%></label>
<%= check_box 'custom_field', 'is_for_all' %></p>
<% when "UserCustomField" %>
<p><label for="custom_field_is_required"><%=l(:field_is_required)%></label>
<%= check_box 'custom_field', 'is_required' %></p>
<% when "ProjectCustomField" %>
<p><label for="custom_field_is_required"><%=l(:field_is_required)%></label>
<%= check_box 'custom_field', 'is_required' %></p>
<% end %> <% end %>
</div> </div>

View File

@ -1,6 +1,6 @@
<h2><%=l(:label_custom_field)%> (<%=l(@custom_field.type_name)%>)</h2> <h2><%=l(:label_custom_field)%> (<%=l(@custom_field.type_name)%>)</h2>
<%= start_form_tag({:action => 'edit', :id => @custom_field}, :class => "tabular") %> <% labelled_tabular_form_for :custom_field, @custom_field, :url => { :action => "edit", :id => @custom_field } do |f| %>
<%= render :partial => 'form', :locals => { :type => @custom_field.type } %> <%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %> <%= submit_tag l(:button_save) %>
<%= end_form_tag %> <% end %>

View File

@ -14,7 +14,7 @@
<tr class="<%= cycle("odd", "even") %>"> <tr class="<%= cycle("odd", "even") %>">
<td><%= link_to custom_field.name, :action => 'edit', :id => custom_field %></td> <td><%= link_to custom_field.name, :action => 'edit', :id => custom_field %></td>
<td align="center"><%= l(custom_field.type_name) %></td> <td align="center"><%= l(custom_field.type_name) %></td>
<td align="center"><%= l(CustomField::FIELD_FORMATS[custom_field.field_format]) %></td> <td align="center"><%= l(CustomField::FIELD_FORMATS[custom_field.field_format][:name]) %></td>
<td align="center"><%= image_tag 'true' if custom_field.is_required? %></td> <td align="center"><%= image_tag 'true' if custom_field.is_required? %></td>
<td align="center"><%= image_tag 'true' if custom_field.is_for_all? %></td> <td align="center"><%= image_tag 'true' if custom_field.is_for_all? %></td>
<td align="center"><%= custom_field.projects.count.to_s + ' ' + lwr(:label_project, custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td> <td align="center"><%= custom_field.projects.count.to_s + ' ' + lwr(:label_project, custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td>

View File

@ -1,8 +1,7 @@
<h2><%=l(:label_custom_field_new)%> (<%=l(@custom_field.type_name)%>)</h2> <h2><%=l(:label_custom_field_new)%> (<%=l(@custom_field.type_name)%>)</h2>
<%= start_form_tag({:action => 'new'}, :class => "tabular") %> <% labelled_tabular_form_for :custom_field, @custom_field, :url => { :action => "new" } do |f| %>
<%= render :partial => 'form', :locals => { :type => @custom_field.type } %> <%= render :partial => 'form', :locals => { :f => f } %>
<%= hidden_field_tag 'type', @custom_field.type %> <%= hidden_field_tag 'type', @custom_field.type %>
<%= submit_tag l(:button_save) %> <%= submit_tag l(:button_save) %>
<%= end_form_tag %> <% end %>

View File

@ -60,7 +60,7 @@ end %>
<%= submit_tag l(:button_change) %> <%= submit_tag l(:button_change) %>
<%= end_form_tag %> <%= end_form_tag %>
<% end %> <% end %>
&nbsp;
</div> </div>
<div id="history" class="box"> <div id="history" class="box">

View File

@ -3,5 +3,6 @@
<%= render(:partial => 'documents/document', <%= render(:partial => 'documents/document',
:collection => Document.find(:all, :collection => Document.find(:all,
:limit => 10, :limit => 10,
:order => 'documents.created_on DESC',
:conditions => "documents.project_id in (#{@user.projects.collect{|m| m.id}.join(',')})", :conditions => "documents.project_id in (#{@user.projects.collect{|m| m.id}.join(',')})",
:include => [:project])) unless @user.projects.empty? %> :include => [:project])) unless @user.projects.empty? %>

View File

@ -3,5 +3,6 @@
<%= render (:partial => 'news/news', <%= render (:partial => 'news/news',
:collection => News.find(:all, :collection => News.find(:all,
:limit => 10, :limit => 10,
:order => 'news.created_on DESC',
:conditions => "news.project_id in (#{@user.projects.collect{|m| m.id}.join(',')})", :conditions => "news.project_id in (#{@user.projects.collect{|m| m.id}.join(',')})",
:include => [:project, :author])) unless @user.projects.empty? %> :include => [:project, :author])) unless @user.projects.empty? %>

View File

@ -17,12 +17,12 @@
@fixed_issues.each do |issue| %> @fixed_issues.each do |issue| %>
<% unless ver_id == issue.fixed_version_id %> <% unless ver_id == issue.fixed_version_id %>
<% if ver_id %></ul><% end %> <% if ver_id %></ul><% end %>
<h3><%= l(:label_version) %>: <%= issue.fixed_version.name %></h3> <h3><%= issue.fixed_version.name %></h3>
<p><%= format_date(issue.fixed_version.effective_date) %><br /> <p><%= format_date(issue.fixed_version.effective_date) %><br />
<%=h issue.fixed_version.description %></p> <%=h issue.fixed_version.description %></p>
<ul> <ul>
<% ver_id = issue.fixed_version_id <% ver_id = issue.fixed_version_id
end %> end %>
<li><%= link_to issue.long_id, :controller => 'issues', :action => 'show', :id => issue %> [<%= issue.tracker.name %>]: <%=h issue.subject %></li> <li><%= link_to "#{issue.tracker.name} #{issue.id}", :controller => 'issues', :action => 'show', :id => issue %>: <%=h issue.subject %></li>
<% end %> <% end %>
</div> </div>

View File

@ -31,7 +31,7 @@
<% if delete_allowed %> <% if delete_allowed %>
<td align="center"> <td align="center">
<div class="contextual"> <div class="contextual">
<%= link_to_if_authorized l(:button_delete), {:controller => 'versions', :action => 'destroy_file', :id => version, :attachment_id => file}, :confirm => l(:text_are_you_sure), :post => true, :class => 'pic picDelete' %> <%= link_to_if_authorized '', {:controller => 'versions', :action => 'destroy_file', :id => version, :attachment_id => file}, :confirm => l(:text_are_you_sure), :post => true, :class => 'pic picDelete' %>
</div> </div>
</td> </td>
<% end %> <% end %>

View File

@ -6,7 +6,7 @@
<div class="box"> <div class="box">
<p><label><%= l(:label_issue_plural) %>:</label> <p><label><%= l(:label_issue_plural) %>:</label>
<% for issue in @issues %> <% for issue in @issues %>
<b><%= link_to issue.long_id, :controller => 'issues', :action => 'show', :id => issue %></b> - <%= issue.subject %> <b><%= link_to issue.long_id, :controller => 'issues', :action => 'show', :id => issue %></b> - <%=h issue.subject %>
<%= hidden_field_tag "issue_ids[]", issue.id %><br /> <%= hidden_field_tag "issue_ids[]", issue.id %><br />
<% end %> <% end %>
<i>(<%= @issues.length%> <%= lwr(:label_issue, @issues.length)%>)</i></p> <i>(<%= @issues.length%> <%= lwr(:label_issue, @issues.length)%>)</i></p>

View File

@ -1,7 +1,7 @@
<h2><%=l(:label_overview)%></h2> <h2><%=l(:label_overview)%></h2>
<div class="splitcontentleft"> <div class="splitcontentleft">
<%= simple_format(auto_link(h @project.description)) %> <%= simple_format(auto_link(h(@project.description))) %>
<ul> <ul>
<% unless @project.homepage.empty? %><li><%=l(:field_homepage)%>: <%= auto_link @project.homepage %></li><% end %> <% unless @project.homepage.empty? %><li><%=l(:field_homepage)%>: <%= auto_link @project.homepage %></li><% end %>
<li><%=l(:field_created_on)%>: <%= format_date(@project.created_on) %></li> <li><%=l(:field_created_on)%>: <%= format_date(@project.created_on) %></li>

View File

@ -9,6 +9,7 @@ http://redmine.org/
* comments can now be added on news * comments can now be added on news
* "my page" is now customizable * "my page" is now customizable
* more powerfull and savable filters for issues lists
* improved issues change history * improved issues change history
* new functionality: move an issue to another project or tracker * new functionality: move an issue to another project or tracker
* new functionality: add a note to an issue * new functionality: add a note to an issue
@ -29,8 +30,10 @@ http://redmine.org/
* csv output encoded to ISO-8859-1 * csv output encoded to ISO-8859-1
* user custom field displayed on account/show * user custom field displayed on account/show
* default configuration improved (default roles, trackers, status, permissions and workflows) * default configuration improved (default roles, trackers, status, permissions and workflows)
* javascript added on custom field form to show/hide fields according to the format of custom field
* fixed: custom fields not in csv exports * fixed: custom fields not in csv exports
* fixed: project settings now displayed according to user's permissions * fixed: project settings now displayed according to user's permissions
* fixed: application error when no version is selected on projects/add_file
== 10/08/2006 v0.3.0 == 10/08/2006 v0.3.0