feature_2096_adriano_crestani.patch

Patch for revision 2082 that adds a "User List" custom field to Redmine - Adriano Crestani Campos, 2008-12-02 10:39

Download (20.1 KB)

View differences:

app/helpers/issues_helper.rb (working copy)
97 97
    
98 98
    unless no_html
99 99
      label = content_tag('strong', label)
100
      old_value = content_tag("i", h(old_value)) if detail.old_value
100

  
101
      if !custom_field.nil? && custom_field.field_format == 'user_list'
102
        old_value = content_tag("i", old_value) if detail.old_value
103
      else
104
        old_value = content_tag("i", h(old_value)) if detail.old_value
105
      end
106

  
107
      
101 108
      old_value = content_tag("strike", old_value) if detail.old_value and (!detail.value or detail.value.empty?)
109

  
102 110
      if detail.property == 'attachment' && !value.blank? && a = Attachment.find_by_id(detail.prop_key)
103 111
        # Link to the attachment if it has not been removed
104 112
        value = link_to_attachment(a)
113
      elsif !custom_field.nil? && custom_field.field_format == 'user_list'
114
        value = content_tag("i", value) if value
105 115
      else
106 116
        value = content_tag("i", h(value)) if value
107 117
      end
app/helpers/custom_fields_helper.rb (working copy)
44 44
                       (custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" : '') : 
45 45
                       '<option></option>'
46 46
      select_tag(field_name, blank_option + options_for_select(custom_field.possible_values, custom_value.value), :id => field_id)
47

  
48
    when "user_list"
49
      users = @issue == nil ? User.find(:all) : @issue.assignable_users
50
      users.delete_if { |user| user.anonymous? }
51
      custom_field.possible_values.clear()
52
      users.each { |user| custom_field.possible_values << user unless user.anonymous?  }
53

  
54
      blank_option = custom_field.is_required? ?
55
                       (custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" : '') : 
56
                       '<option></option>'
57
      select_tag(field_name, blank_option + options_for_select(users.collect { |x| [x.name, x.login] }, custom_value.value), :id => field_id)
58

  
47 59
    else
48 60
      text_field_tag(field_name, custom_value.value, :id => field_id)
49 61
    end
......
76 88
      begin; format_date(value.to_date); rescue; value end
77 89
    when "bool"
78 90
      l_YesNo(value == "1")
91
    when "user_list"
92
      link_to_user(User.find(:first,  :conditions => [ "login = ?", value]))
79 93
    else
80 94
      value
81 95
    end
......
85 99
  def custom_field_formats_for_select
86 100
    CustomField::FIELD_FORMATS.sort {|a,b| a[1][:order]<=>b[1][:order]}.collect { |k| [ l(k[1][:name]), k[0] ] }
87 101
  end
102

  
103
# Return a string used to display a custom value on the issues view
104
  def format_value_for_view(value, field_format)
105
    return "-" unless value && !value.empty?
106
    case field_format
107
    when "user_list"
108
      link_to_user(User.find(:first,  :conditions => [ "login = ?", value]))
109
    else
110
      format_value(value, field_format)
111
    end
112
  end
113

  
114
  def show_value_on_view(custom_value)
115
    return "" unless custom_value
116
    format_value_for_view(custom_value.value, custom_value.custom_field.field_format)
117
  end
118

  
88 119
end
app/models/issue.rb (working copy)
213 213
    # Author and assignee are always notified unless they have been locked
214 214
    recipients << author.mail if author && author.active?
215 215
    recipients << assigned_to.mail if assigned_to && assigned_to.active?
216

  
217
    custom_users = Array.new()
218

  
219
    custom_values.each { |x| custom_users << User.find(:first,  :conditions => [ "login = ?", x.value]) }
220
    custom_users = custom_users.compact
221
    custom_users.each { |x| recipients << x.mail } 
222

  
216 223
    recipients.compact.uniq
217 224
  end
218 225
  
app/models/custom_field.rb (working copy)
25 25
                    "int" => { :name => :label_integer, :order => 3 },
26 26
                    "float" => { :name => :label_float, :order => 4 },
27 27
                    "list" => { :name => :label_list, :order => 5 },
28
			        "date" => { :name => :label_date, :order => 6 },
29
			        "bool" => { :name => :label_boolean, :order => 7 }
28
                    "user_list" => { :name => :label_user_list, :order => 6 },
29
                    "date" => { :name => :label_date, :order => 7 },
30
	        "bool" => { :name => :label_boolean, :order => 8 }
30 31
  }.freeze
31 32

  
32 33
  validates_presence_of :name, :field_format
app/views/custom_fields/_form.rhtml (working copy)
20 20
      if (p_searchable) Element.show(p_searchable.parentNode);
21 21
      Element.show(p_values);
22 22
      break;
23
    case "user_list":
24
      p_default.setAttribute('type','combolist');
25
      Element.hide(p_length.parentNode);
26
      Element.hide(p_regexp.parentNode);
27
      if (p_searchable) Element.show(p_searchable.parentNode);
28
      Element.hide(p_values);
29
      break;
23 30
    case "bool":
24 31
      p_default.setAttribute('type','checkbox');
25 32
      Element.hide(p_length.parentNode);
app/views/projects/show.rhtml (working copy)
12 12
	<% end %>
13 13
	<% @project.custom_values.each do |custom_value| %>
14 14
	<% if !custom_value.value.empty? %>
15
	   <li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
15
	   <li><%= custom_value.custom_field.name%>: <%= custom_value.custom_field.field_format == "user_list" ? show_value_on_view(custom_value) : h(show_value(custom_value)) %></li>
16 16
	<% end %>
17 17
	<% end %>
18 18
	</ul>	
app/views/account/show.rhtml (working copy)
11 11
	<% end %>
12 12
	<% for custom_value in @custom_values %>
13 13
	<% if !custom_value.value.empty? %>
14
    <li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
14
    <li><%= custom_value.custom_field.name%>: <%= custom_value.custom_field.field_format == "user_list" ? show_value_on_view(custom_value) : h(show_value(custom_value)) %></li>
15 15
	<% end %>
16 16
	<% end %>
17 17
    <li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li>
app/views/issues/show.rhtml (working copy)
46 46
<tr>
47 47
<% n = 0 -%>
48 48
<% @issue.custom_values.each do |value| -%>
49
    <td valign="top"><b><%=h value.custom_field.name %>:</b></td><td valign="top"><%= simple_format(h(show_value(value))) %></td>
49

  
50
    <td valign="top"><b><%= value.custom_field.name %> :</b></td><td valign="top"><%= value.custom_field.field_format == "user_list" ? show_value_on_view(value) : 
51
simple_format(h(show_value_on_issue(value))) %></td>
52

  
50 53
<% n = n + 1
51 54
   if (n > 1) 
52 55
        n = 0 %>
lang/lt.yml (working copy)
271 271
label_subproject_plural: Subprojektai 
272 272
label_min_max_length: Min - Maks ilgis 
273 273
label_list: Sąrašas 
274

  
275
# need to be translated
276
label_user_list: User List
277

  
274 278
label_date: Data 
275 279
label_integer: Sveikasis skaičius 
276 280
label_float: Float 
lang/ro.yml (working copy)
254 254
label_subproject_plural: Subproiecte
255 255
label_min_max_length: Lungime min-max
256 256
label_list: Lista
257

  
258
# need to be translated
259
label_user_list: User List
260

  
257 261
label_date: Data
258 262
label_integer: Numar intreg
259 263
label_boolean: Variabila logica
lang/zh.yml (working copy)
356 356
label_and_its_subprojects: %s 及其子项目
357 357
label_min_max_length: 最小 - 最大 长度
358 358
label_list: 列表
359

  
360
# need to be translated
361
label_user_list: User List
362

  
359 363
label_date: 日期
360 364
label_integer: 整数
361 365
label_float: 浮点数
lang/vn.yml (working copy)
304 304
label_and_its_subprojects: %s và dự án con
305 305
label_min_max_length: Min - Max length
306 306
label_list: List
307

  
308
# need to be translated
309
label_user_list: User List
310

  
307 311
label_date: Ngày
308 312
label_integer: Integer
309 313
label_float: Float
lang/pt.yml (working copy)
305 305
label_and_its_subprojects: %s e sub-projectos
306 306
label_min_max_length: Tamanho mínimo-máximo
307 307
label_list: Lista
308
label_user_list: Lista de Usuário
308 309
label_date: Data
309 310
label_integer: Inteiro
310 311
label_float: Decimal
lang/ca.yml (working copy)
304 304
label_and_its_subprojects: %s i els seus subprojectes
305 305
label_min_max_length: Longitud mín - max
306 306
label_list: Llist
307

  
308
# need to be translated
309
label_user_list: User List
310

  
307 311
label_date: Data
308 312
label_integer: Enter
309 313
label_float: Flotant
lang/pt-br.yml (working copy)
303 303
label_and_its_subprojects: %s e seus sub-projetos
304 304
label_min_max_length: Tamanho mín-máx
305 305
label_list: Lista
306
label_user_list: Lista de Usuário
306 307
label_date: Data
307 308
label_integer: Inteiro
308 309
label_float: Decimal
lang/tr.yml (working copy)
293 293
label_subproject_plural: Alt Projeler
294 294
label_min_max_length: Min - Maks uzunluk
295 295
label_list: Liste
296

  
297
# need to be translated
298
label_user_list: User List
299

  
296 300
label_date: Tarih
297 301
label_integer: Tam sayı
298 302
label_float: Noktalı sayı
lang/ru.yml (working copy)
383 383
label_ldap_authentication: Авторизация с помощью LDAP
384 384
label_less_than_ago: менее, чем дней(я) назад
385 385
label_list: Список
386

  
387
# need to be translated
388
label_user_list: User List
389

  
386 390
label_loading: Загрузка...
387 391
label_logged_as: Вошел как
388 392
label_login: Войти
lang/en.yml (working copy)
356 356
label_and_its_subprojects: %s and its subprojects
357 357
label_min_max_length: Min - Max length
358 358
label_list: List
359
label_user_list: User List
359 360
label_date: Date
360 361
label_integer: Integer
361 362
label_float: Float
lang/cs.yml (working copy)
297 297
label_subproject_plural: Podprojekty
298 298
label_min_max_length: Min - Max délka
299 299
label_list: Seznam
300

  
301
# need to be translated
302
label_user_list: User List
303

  
300 304
label_date: Datum
301 305
label_integer: Celé číslo
302 306
label_float: Desetiné číslo
lang/es.yml (working copy)
349 349
label_ldap_authentication: Autenticación LDAP
350 350
label_less_than_ago: hace menos de
351 351
label_list: Lista
352

  
353
# need to be translated
354
label_user_list: User List
355

  
352 356
label_loading: Cargando...
353 357
label_logged_as: Conectado como
354 358
label_login: Conexión
lang/zh-tw.yml (working copy)
355 355
label_and_its_subprojects: %s 與其子專案
356 356
label_min_max_length: 最小 - 最大 長度
357 357
label_list: 清單
358

  
359
# need to be translated
360
label_user_list: User List
361

  
358 362
label_date: 日期
359 363
label_integer: 整數
360 364
label_float: 福點數
lang/ko.yml (working copy)
260 260
label_subproject_plural: 서브 프로젝트
261 261
label_min_max_length: 최소 - 최대 길이
262 262
label_list: 리스트
263

  
264
# need to be translated
265
label_user_list: User List
266

  
263 267
label_date: 날짜
264 268
label_integer: 정수
265 269
label_float: 부동상수
lang/it.yml (working copy)
254 254
label_subproject_plural: Sottoprogetti
255 255
label_min_max_length: Lunghezza minima - massima
256 256
label_list: Elenco
257

  
258
# need to be translated
259
label_user_list: User List
260

  
257 261
label_date: Data
258 262
label_integer: Intero
259 263
label_boolean: Booleano
lang/sk.yml (working copy)
297 297
label_subproject_plural: Podprojekty
298 298
label_min_max_length: Min - Max dĺžka
299 299
label_list: Zoznam
300

  
301
# need to be translated
302
label_user_list: User List
303

  
300 304
label_date: Dátum
301 305
label_integer: Celé číslo
302 306
label_float: Desatinné číslo
lang/uk.yml (working copy)
268 268
label_subproject_plural: Підпроекти
269 269
label_min_max_length: Мінімальна - максимальна довжина
270 270
label_list: Список
271

  
272
# need to be translated
273
label_user_list: User List
274

  
271 275
label_date: Дата
272 276
label_integer: Цілий
273 277
label_float: З плаваючою крапкою
lang/da.yml (working copy)
304 304
label_and_its_subprojects: Projektet %s og dets underprojekter
305 305
label_min_max_length: Min.-maks.-længde
306 306
label_list: Liste
307

  
308
# need to be translated
309
label_user_list: User List
310

  
307 311
label_date: Dato
308 312
label_integer: Heltal
309 313
label_float: Kommatal
lang/sr.yml (working copy)
263 263
label_subproject_plural: Potprojekti
264 264
label_min_max_length: Min - Max veličina
265 265
label_list: Liste
266

  
267
# need to be translated
268
label_user_list: User List
269

  
266 270
label_date: Datum
267 271
label_integer: Integer
268 272
label_boolean: Boolean
lang/de.yml (working copy)
355 355
label_and_its_subprojects: %s und dessen Unterprojekte
356 356
label_min_max_length: Länge (Min. - Max.)
357 357
label_list: Liste
358

  
359
# need to be translated
360
label_user_list: User List
361

  
358 362
label_date: Datum
359 363
label_integer: Zahl
360 364
label_float: Fließkommazahl
lang/bg.yml (working copy)
253 253
label_auth_source_plural: Начини на оторизация
254 254
label_subproject_plural: Подпроекти
255 255
label_min_max_length: Мин. - Макс. дължина
256

  
257
# need to be translated
258
label_user_list: User List
259

  
256 260
label_list: Списък
257 261
label_date: Дата
258 262
label_integer: Целочислен
lang/sv.yml (working copy)
254 254
label_subproject_plural: Delprojekt
255 255
label_min_max_length: Min - Max längd
256 256
label_list: Lista
257

  
258
# need to be translated
259
label_user_list: User List
260

  
257 261
label_date: Datum
258 262
label_integer: Heltal
259 263
label_boolean: Boolean
lang/ja.yml (working copy)
255 255
label_subproject_plural: サブプロジェクト
256 256
label_min_max_length: 最小値 - 最大値の長さ
257 257
label_list: リストから選択
258

  
259
# need to be translated
260
label_user_list: User List
261

  
258 262
label_date: 日付
259 263
label_integer: 整数
260 264
label_boolean: 真偽値
lang/he.yml (working copy)
259 259
label_subproject_plural: תת-פרויקטים
260 260
label_min_max_length: אורך מינימאלי - מקסימאלי
261 261
label_list: רשימה
262

  
263
# need to be translated
264
label_user_list: User List
265

  
262 266
label_date: תאריך
263 267
label_integer: מספר שלם
264 268
label_boolean: ערך בוליאני
lang/fi.yml (working copy)
274 274
label_subproject_plural: Aliprojektit
275 275
label_min_max_length: Min - Max pituudet
276 276
label_list: Lista
277

  
278
# need to be translated
279
label_user_list: User List
280

  
277 281
label_date: Päivä
278 282
label_integer: Kokonaisluku
279 283
label_float: Liukuluku
lang/fr.yml (working copy)
356 356
label_and_its_subprojects: %s et ses sous-projets
357 357
label_min_max_length: Longueurs mini - maxi
358 358
label_list: Liste
359

  
360
# need to be translated
361
label_user_list: User List
362

  
359 363
label_date: Date
360 364
label_integer: Entier
361 365
label_float: Nombre décimal
lang/nl.yml (working copy)
254 254
label_subproject_plural: Subprojecten
255 255
label_min_max_length: Min-max lengte
256 256
label_list: Lijst
257

  
258
# need to be translated
259
label_user_list: User List
260

  
257 261
label_date: Datum
258 262
label_integer: Integer
259 263
label_boolean: Boolean
lang/pl.yml (working copy)
376 376
label_ldap_authentication: Autoryzacja LDAP
377 377
label_less_than_ago: dni mniej
378 378
label_list: Lista
379

  
380
# need to be translated
381
label_user_list: User List
382

  
379 383
label_loading: Ładowanie...
380 384
label_logged_as: Zalogowany jako
381 385
label_login: Login
lang/th.yml (working copy)
296 296
label_subproject_plural: โครงการย่อย
297 297
label_min_max_length: สั้น-ยาว สุดที่
298 298
label_list: รายการ
299

  
300
# need to be translated
301
label_user_list: User List
302

  
299 303
label_date: วันที่
300 304
label_integer: จำนวนเต็ม
301 305
label_float: จำนวนจริง
lang/hu.yml (working copy)
295 295
label_and_its_subprojects: %s és alprojektjei
296 296
label_min_max_length: Min - Max hossz
297 297
label_list: Lista
298

  
299
# need to be translated
300
label_user_list: User List
301

  
298 302
label_date: Dátum
299 303
label_integer: Egész
300 304
label_float: Lebegőpontos
lang/no.yml (working copy)
298 298
label_and_its_subprojects: %s og dets underprosjekter
299 299
label_min_max_length: Min.-maks. lengde
300 300
label_list: Liste
301

  
302
# need to be translated
303
label_user_list: User List
304

  
301 305
label_date: Dato
302 306
label_integer: Heltall
303 307
label_float: Kommatall