Project

General

Profile

Actions

Defect #35557

open

Fix position when rendering custom field enumerations

Added by Liane Hampe almost 3 years ago. Updated almost 3 years ago.

Status:
Confirmed
Priority:
Normal
Assignee:
-
Category:
Custom fields
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

The position of each custom field enumeration is integrated as hidden
field in the corresponding index.html.erb file.

When iterating over all enumerations for a certain field, the iteration
is done with an index information of the array, what contains all enumerations.

This index information again is used as the value for the position.

This is wrong, since the (array) index starts counting from zero whereas the position
numbers start counting from 1.

This is fixed now by increasing the position by 1 as stated below.

diff --git a/app/views/custom_field_enumerations/index.html.erb b/app/views/custom_field_enumerations/index.html.erb
index 83e9d59c9..45398728f 100755
--- a/app/views/custom_field_enumerations/index.html.erb
+++ b/app/views/custom_field_enumerations/index.html.erb
@@ -7,7 +7,7 @@
   <% @custom_field.enumerations.each_with_index do |value, position| %>
     <li>
       <span class="icon-only icon-sort-handle sort-handle"></span>
-      <%= hidden_field_tag "custom_field_enumerations[#{value.id}][position]", position, :class => 'position' %>
+      <%= hidden_field_tag "custom_field_enumerations[#{value.id}][position]", position + 1, :class => 'position' %>
       <%= text_field_tag "custom_field_enumerations[#{value.id}][name]", value.name, :size => 40 %>
       <%= hidden_field_tag "custom_field_enumerations[#{value.id}][active]", 0 %>
       <label>
Actions #1

Updated by Go MAEDA almost 3 years ago

  • Status changed from New to Confirmed

The topmost position value is 0 when you open /custom_fields/*/enumerations, but it changes to 1 if you reorder values by drag and drop.

Actions #2

Updated by Go MAEDA almost 3 years ago

  • Target version set to Candidate for next major release
Actions

Also available in: Atom PDF