From f7b3dbe8c7445d7b9517b691b9bfe1a74f137ad6 Mon Sep 17 00:00:00 2001 From: rambowm Date: Mon, 22 Oct 2018 14:30:26 +0200 Subject: [PATCH 1/2] added ISO format target (eg. 20181022) --- lib/format.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/format.rb b/lib/format.rb index 1524be0..32c9dc5 100644 --- a/lib/format.rb +++ b/lib/format.rb @@ -10,6 +10,7 @@ class Format < Redmine::FieldFormat::Base MATCHERS = { :TOW_DIGIT_NUMBER => /\d{2}/, :FOUR_DIGIT_NUMBER => /\d{4}/, + :THREE_DIGIT_NUMBER => /\d{3}/, :FORMAT_WRAPPER => /\{(.+?)\}/ } @@ -17,7 +18,8 @@ class Format < Redmine::FieldFormat::Base :'yyyy' => { :strftime => '%Y', :financial_year => false, :regexp => MATCHERS[:FOUR_DIGIT_NUMBER] }, :'yy' => { :strftime => '%y', :financial_year => false, :regexp => MATCHERS[:TOW_DIGIT_NUMBER] }, :'YYYY' => { :strftime => '%Y', :financial_year => true, :regexp => MATCHERS[:FOUR_DIGIT_NUMBER] }, - :'YY' => { :strftime => '%y', :financial_year => true, :regexp => MATCHERS[:TOW_DIGIT_NUMBER] } + :'YY' => { :strftime => '%y', :financial_year => true, :regexp => MATCHERS[:TOW_DIGIT_NUMBER] }, + :'ISO' => { :strftime => '%Y%m%d', :financial_year => false, :regexp => MATCHERS[:THREE_DIGIT_NUMBER] } } def validate_custom_field(custom_field) From d95f9a3a55566e91409eebe3000e03bcb6f3a15c Mon Sep 17 00:00:00 2001 From: rambowm Date: Mon, 22 Oct 2018 14:35:22 +0200 Subject: [PATCH 2/2] added example for ISO format target --- app/views/custom_fields/formats/_serial_number.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/custom_fields/formats/_serial_number.html.erb b/app/views/custom_fields/formats/_serial_number.html.erb index 626b98e..0f26ebb 100644 --- a/app/views/custom_fields/formats/_serial_number.html.erb +++ b/app/views/custom_fields/formats/_serial_number.html.erb @@ -5,6 +5,7 @@ {yy}-{0000} #=> 15-0001 {YYYY}-{0000} #=> 2014-0001 {YY}-{0000} #=> 14-0001 + {ISO}-{0000} #=> 20150331-0001

<%= f.hidden_field :is_required, :value => '0' %>