From 918123cd0663803a6e392c6c9ce209d10c8e5603 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 17 Dec 2006 14:22:09 +0000 Subject: [PATCH] * 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 --- app/controllers/projects_controller.rb | 7 +- app/helpers/application_helper.rb | 3 +- app/helpers/custom_fields_helper.rb | 2 +- app/models/custom_field.rb | 12 ++-- app/views/account/show.rhtml | 2 +- app/views/custom_fields/_form.rhtml | 96 +++++++++++++++----------- app/views/custom_fields/edit.rhtml | 8 +-- app/views/custom_fields/list.rhtml | 2 +- app/views/custom_fields/new.rhtml | 11 ++- app/views/issues/show.rhtml | 2 +- app/views/my/blocks/_documents.rhtml | 1 + app/views/my/blocks/_latest_news.rhtml | 1 + app/views/projects/changelog.rhtml | 4 +- app/views/projects/list_files.rhtml | 2 +- app/views/projects/move_issues.rhtml | 2 +- app/views/projects/show.rhtml | 2 +- doc/CHANGELOG | 3 + 17 files changed, 93 insertions(+), 67 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 4151e734c..b0b00bebf 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -293,8 +293,11 @@ class ProjectsController < ApplicationController new_project = Project.find(params[:new_project_id]) new_tracker = Tracker.find(params[:new_tracker_id]) @issues.each { |i| - # category is project dependent - i.category = nil unless i.project_id == new_project.id + # project dependent properties + unless i.project_id == new_project.id + i.category = nil + i.fixed_version = nil + end # move the issue i.project = new_project i.tracker = new_tracker diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 196d91fca..0ca2568ae 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -161,6 +161,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder (field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector| src = <<-END_SRC 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 = @template.content_tag("label", label_text, :class => (@object.errors[field] ? "error" : nil), @@ -171,7 +172,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder class_eval src, __FILE__, __LINE__ 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 = @template.content_tag("label", label_text, :class => (@object.errors[field] ? "error" : nil), diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index 9df5c50a3..75b8a45cd 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -72,6 +72,6 @@ module CustomFieldsHelper # Return an array of custom field formats which can be used in select_tag 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 diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index 2f5f2749f..7dab23392 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -18,12 +18,12 @@ class CustomField < ActiveRecord::Base has_many :custom_values, :dependent => true - FIELD_FORMATS = { "list" => :label_list, - "date" => :label_date, - "bool" => :label_boolean, - "int" => :label_integer, - "string" => :label_string, - "text" => :label_text + FIELD_FORMATS = { "string" => { :name => :label_string, :order => 1 }, + "text" => { :name => :label_text, :order => 2 }, + "int" => { :name => :label_integer, :order => 3 }, + "list" => { :name => :label_list, :order => 4 }, + "date" => { :name => :label_date, :order => 5 }, + "bool" => { :name => :label_boolean, :order => 6 } }.freeze validates_presence_of :name, :field_format diff --git a/app/views/account/show.rhtml b/app/views/account/show.rhtml index 985238951..c686b709c 100644 --- a/app/views/account/show.rhtml +++ b/app/views/account/show.rhtml @@ -6,7 +6,7 @@
  • <%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %>
  • <% for custom_value in @custom_values %> <% if !custom_value.value.empty? %> -
  • <%= custom_value.custom_field.name%>: <%= show_value(custom_value) %>
  • +
  • <%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %>
  • <% end %> <% end %> diff --git a/app/views/custom_fields/_form.rhtml b/app/views/custom_fields/_form.rhtml index f7f968e33..cf658fb2a 100644 --- a/app/views/custom_fields/_form.rhtml +++ b/app/views/custom_fields/_form.rhtml @@ -1,52 +1,70 @@ <%= error_messages_for 'custom_field' %> + +
    -

    -<%= text_field 'custom_field', 'name' %>

    - -

    -<%= select("custom_field", "field_format", custom_field_formats_for_select) %>

    - +

    <%= f.text_field :name, :required => true %>

    +

    <%= f.select :field_format, custom_field_formats_for_select, {}, :onchange => "toggle_custom_field_format();" %>

    -<%= text_field 'custom_field', 'min_length', :size => 5 %> - -<%= text_field 'custom_field', 'max_length', :size => 5 %>
    (<%=l(:text_min_max_length_info)%>)

    - -

    -<%= text_field 'custom_field', 'regexp', :size => 50 %>
    (<%=l(:text_regexp_info)%>)

    - -

    -<%= text_area 'custom_field', 'possible_values', :rows => 5, :cols => 60 %>
    (<%=l(:text_possible_values_info)%>)

    + <%= f.text_field :min_length, :size => 5, :no_label => true %> - + <%= f.text_field :max_length, :size => 5, :no_label => true %>
    (<%=l(:text_min_max_length_info)%>)

    +

    <%= f.text_field :regexp, :size => 50 %>
    (<%=l(:text_regexp_info)%>)

    +

    <%= f.text_area :possible_values, :rows => 5, :cols => 60 %>
    (<%=l(:text_possible_values_info)%>)

    +<%= javascript_tag "toggle_custom_field_format();" %>
    -<% case type.to_s - when "IssueCustomField" %> - -
    <%=l(:label_tracker_plural)%> -<% for tracker in @trackers %> - checked="checked"<%end%> - > <%= tracker.name %> -<% end %>
    -  - -

    -<%= check_box 'custom_field', 'is_required' %>

    - -

    -<%= check_box 'custom_field', 'is_for_all' %>

    - -<% when "UserCustomField" %> -

    -<%= check_box 'custom_field', 'is_required' %>

    +<% case @custom_field.type.to_s +when "IssueCustomField" %> + +
    <%=l(:label_tracker_plural)%> + <% for tracker in @trackers %> + <%= check_box_tag "tracker_ids[]", tracker.id, (@custom_field.trackers.include? tracker) %> <%= tracker.name %> + <% end %> +
    +   +

    <%= f.check_box :is_required %>

    +

    <%= f.check_box :is_for_all %>

    + +<% when "UserCustomField" %> +

    <%= f.check_box :is_required %>

    -<% when "ProjectCustomField" %> -

    -<%= check_box 'custom_field', 'is_required' %>

    +<% when "ProjectCustomField" %> +

    <%= f.check_box :is_required %>

    <% end %>
    diff --git a/app/views/custom_fields/edit.rhtml b/app/views/custom_fields/edit.rhtml index 201047a8d..ef056fa41 100644 --- a/app/views/custom_fields/edit.rhtml +++ b/app/views/custom_fields/edit.rhtml @@ -1,6 +1,6 @@

    <%=l(:label_custom_field)%> (<%=l(@custom_field.type_name)%>)

    -<%= start_form_tag({:action => 'edit', :id => @custom_field}, :class => "tabular") %> - <%= render :partial => 'form', :locals => { :type => @custom_field.type } %> - <%= submit_tag l(:button_save) %> -<%= end_form_tag %> +<% labelled_tabular_form_for :custom_field, @custom_field, :url => { :action => "edit", :id => @custom_field } do |f| %> +<%= render :partial => 'form', :locals => { :f => f } %> +<%= submit_tag l(:button_save) %> +<% end %> diff --git a/app/views/custom_fields/list.rhtml b/app/views/custom_fields/list.rhtml index 858590c49..8e4573aed 100644 --- a/app/views/custom_fields/list.rhtml +++ b/app/views/custom_fields/list.rhtml @@ -14,7 +14,7 @@ "> <%= link_to custom_field.name, :action => 'edit', :id => custom_field %> <%= l(custom_field.type_name) %> - <%= l(CustomField::FIELD_FORMATS[custom_field.field_format]) %> + <%= l(CustomField::FIELD_FORMATS[custom_field.field_format][:name]) %> <%= image_tag 'true' if custom_field.is_required? %> <%= image_tag 'true' if custom_field.is_for_all? %> <%= 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? %> diff --git a/app/views/custom_fields/new.rhtml b/app/views/custom_fields/new.rhtml index 3b215dc9f..2e8aa2750 100644 --- a/app/views/custom_fields/new.rhtml +++ b/app/views/custom_fields/new.rhtml @@ -1,8 +1,7 @@

    <%=l(:label_custom_field_new)%> (<%=l(@custom_field.type_name)%>)

    -<%= start_form_tag({:action => 'new'}, :class => "tabular") %> - <%= render :partial => 'form', :locals => { :type => @custom_field.type } %> - <%= hidden_field_tag 'type', @custom_field.type %> - <%= submit_tag l(:button_save) %> -<%= end_form_tag %> - +<% labelled_tabular_form_for :custom_field, @custom_field, :url => { :action => "new" } do |f| %> +<%= render :partial => 'form', :locals => { :f => f } %> +<%= hidden_field_tag 'type', @custom_field.type %> +<%= submit_tag l(:button_save) %> +<% end %> diff --git a/app/views/issues/show.rhtml b/app/views/issues/show.rhtml index 93b8cd008..8390f8282 100644 --- a/app/views/issues/show.rhtml +++ b/app/views/issues/show.rhtml @@ -60,7 +60,7 @@ end %> <%= submit_tag l(:button_change) %> <%= end_form_tag %> <% end %> - + 
    diff --git a/app/views/my/blocks/_documents.rhtml b/app/views/my/blocks/_documents.rhtml index 8e7f6bc50..eb8c16a58 100644 --- a/app/views/my/blocks/_documents.rhtml +++ b/app/views/my/blocks/_documents.rhtml @@ -3,5 +3,6 @@ <%= render(:partial => 'documents/document', :collection => Document.find(:all, :limit => 10, + :order => 'documents.created_on DESC', :conditions => "documents.project_id in (#{@user.projects.collect{|m| m.id}.join(',')})", :include => [:project])) unless @user.projects.empty? %> \ No newline at end of file diff --git a/app/views/my/blocks/_latest_news.rhtml b/app/views/my/blocks/_latest_news.rhtml index 625603ac0..4bad9a542 100644 --- a/app/views/my/blocks/_latest_news.rhtml +++ b/app/views/my/blocks/_latest_news.rhtml @@ -3,5 +3,6 @@ <%= render (:partial => 'news/news', :collection => News.find(:all, :limit => 10, + :order => 'news.created_on DESC', :conditions => "news.project_id in (#{@user.projects.collect{|m| m.id}.join(',')})", :include => [:project, :author])) unless @user.projects.empty? %> \ No newline at end of file diff --git a/app/views/projects/changelog.rhtml b/app/views/projects/changelog.rhtml index e59df059d..250957a8c 100644 --- a/app/views/projects/changelog.rhtml +++ b/app/views/projects/changelog.rhtml @@ -17,12 +17,12 @@ @fixed_issues.each do |issue| %> <% unless ver_id == issue.fixed_version_id %> <% if ver_id %><% end %> -

    <%= l(:label_version) %>: <%= issue.fixed_version.name %>

    +

    <%= issue.fixed_version.name %>

    <%= format_date(issue.fixed_version.effective_date) %>
    <%=h issue.fixed_version.description %>

    \ No newline at end of file diff --git a/app/views/projects/list_files.rhtml b/app/views/projects/list_files.rhtml index 881829a44..61c6d2c80 100644 --- a/app/views/projects/list_files.rhtml +++ b/app/views/projects/list_files.rhtml @@ -31,7 +31,7 @@ <% if delete_allowed %>
    - <%= 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' %>
    <% end %> diff --git a/app/views/projects/move_issues.rhtml b/app/views/projects/move_issues.rhtml index 380d47fd5..772cdeb0d 100644 --- a/app/views/projects/move_issues.rhtml +++ b/app/views/projects/move_issues.rhtml @@ -6,7 +6,7 @@

    <% for issue in @issues %> - <%= link_to issue.long_id, :controller => 'issues', :action => 'show', :id => issue %> - <%= issue.subject %> + <%= link_to issue.long_id, :controller => 'issues', :action => 'show', :id => issue %> - <%=h issue.subject %> <%= hidden_field_tag "issue_ids[]", issue.id %>
    <% end %> (<%= @issues.length%> <%= lwr(:label_issue, @issues.length)%>)

    diff --git a/app/views/projects/show.rhtml b/app/views/projects/show.rhtml index 46f17d9b9..d5da126e2 100644 --- a/app/views/projects/show.rhtml +++ b/app/views/projects/show.rhtml @@ -1,7 +1,7 @@

    <%=l(:label_overview)%>

    - <%= simple_format(auto_link(h @project.description)) %> + <%= simple_format(auto_link(h(@project.description))) %>
      <% unless @project.homepage.empty? %>
    • <%=l(:field_homepage)%>: <%= auto_link @project.homepage %>
    • <% end %>
    • <%=l(:field_created_on)%>: <%= format_date(@project.created_on) %>
    • diff --git a/doc/CHANGELOG b/doc/CHANGELOG index ce9d933ac..4c4ba17c7 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -9,6 +9,7 @@ http://redmine.org/ * comments can now be added on news * "my page" is now customizable +* more powerfull and savable filters for issues lists * improved issues change history * new functionality: move an issue to another project or tracker * new functionality: add a note to an issue @@ -29,8 +30,10 @@ http://redmine.org/ * csv output encoded to ISO-8859-1 * user custom field displayed on account/show * 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: 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 -- 2.39.5