From 73e16860b1c96d8c786835dcf78ee717659b99a9 Mon Sep 17 00:00:00 2001 From: Akira Saito Date: Tue, 14 Apr 2015 21:22:05 +0900 Subject: [PATCH] add settings --- app/helpers/application_helper.rb | 12 ++++++++++ app/views/hooks/_quick_edit_context.html.erb | 5 ++++- app/views/quick_edit_issues/_input_dialog.html.erb | 25 +++++++++++++-------- app/views/quick_edit_issues/_settings.html.erb | 26 ++++++++++++++++++++++ init.rb | 7 +++++- 5 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 app/views/quick_edit_issues/_settings.html.erb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 92af536..4b3e464 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -85,5 +85,17 @@ module ApplicationHelper :date end end + + def parse_size(size, width_range, width_default, height_range, height_default) + size = size.split(",") + size[0] = width_default if size.length != 2 || !size[0].match(/\d{1,9}/) + size[1] = height_default if size.length != 2 || !size[1].match(/\d{1,9}/) + size[0] = size[0].to_i + size[1] = size[1].to_i + size[0] = width_default unless width_range.include?(size[0]) + size[1] = height_default unless height_range.include?(size[1]) + + size + end end diff --git a/app/views/hooks/_quick_edit_context.html.erb b/app/views/hooks/_quick_edit_context.html.erb index 9512231..71ec075 100644 --- a/app/views/hooks/_quick_edit_context.html.erb +++ b/app/views/hooks/_quick_edit_context.html.erb @@ -1,8 +1,11 @@ <% extend ApplicationHelper extend IssueRelationsHelper + + excludes = Setting.plugin_quick_edit['custom_field_exclude_names'].split(/,/).map {|v| Regexp.new(v)} + custom_fields = @issues.map(&:available_custom_fields).reduce(:&).select do |f| - %w(string date int text link float).include?(f.field_format) + %w{string date int text link float}.include?(f.field_format) && ( excludes.empty? || excludes.none? {|ex| ex.match(f.name)} ) end first_issue = @issues.first diff --git a/app/views/quick_edit_issues/_input_dialog.html.erb b/app/views/quick_edit_issues/_input_dialog.html.erb index 010acf5..3e9ae23 100644 --- a/app/views/quick_edit_issues/_input_dialog.html.erb +++ b/app/views/quick_edit_issues/_input_dialog.html.erb @@ -1,3 +1,12 @@ +<% + dialog_size = parse_size(Setting.plugin_quick_edit['input_dialog_base_size'], 480...2048, 480, 280...2048,280) + dialog_size[0] += 227 if @dialog_params[:field_type] == :text || @dialog_params[:field_type] == :string + dialog_size[1] += 134 if @dialog_params[:field_type] == :text + dialog_size[1] += 31 if @dialog_params[:attribute_name]==:description + dialog_size[1] += 50 unless @dialog_params[:description].nil? + + textarea_size = parse_size(Setting.plugin_quick_edit['textarea_size'], 10...256, 80, 10...256, 10) +%>
<%= form_tag({:controller=>'issues', :action=>:bulk_update}) do %>
@@ -5,8 +14,8 @@ for: <% @issues.each do |issue| %><%= "\##{issue.id}" %> <% end %>
-
- <%= @dialog_params[:caption] %>:
+ <%= @dialog_params[:caption] %>: +
<% case @dialog_params[:field_type] %> <% when :date %> <% if @dialog_params[:attribute_name].to_sym == :description %> <%= wikitoolbar_for 'new_value' %> @@ -59,13 +68,11 @@ diff --git a/app/views/quick_edit_issues/_settings.html.erb b/app/views/quick_edit_issues/_settings.html.erb new file mode 100644 index 0000000..c7c859e --- /dev/null +++ b/app/views/quick_edit_issues/_settings.html.erb @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + +
Dialog base size: + + +
Textarea size: + + +
Pattern of name for exclude custom fields: + + +
diff --git a/init.rb b/init.rb index 47a2309..8ec94e4 100644 --- a/init.rb +++ b/init.rb @@ -6,7 +6,7 @@ require_dependency File.expand_path('../hooks', __FILE__) # plugin name depends to plugin directory plugin_name = File.dirname(File.expand_path(__FILE__)) -plugin_name = File.basename(plugin_name) +plugin_name = File.basename(plugin_name).to_sym Redmine::Plugin.register plugin_name do name 'Quick Edit plugin' @@ -15,4 +15,9 @@ Redmine::Plugin.register plugin_name do version '0.0.7.1' permission :manage_quick_edit_relations, {:quick_edit_relations => [:create, :destroy]}, :public => true + + settings :default => {'custom_field_exclude_names'=>'', + 'textarea_size'=>'80,10', + 'input_dialog_base_size'=>'480,280'}, + :partial => 'quick_edit_issues/settings' end -- 2.11.0