OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix duplicating the row default-value
Oliver Güntherfe3cf855d300
diff --git a/app/views/custom_fields/_custom_options.html.erb b/app/views/custom_fields/_custom_options.html.erbindex 044c8fdf8fe..9b4c03b89ce 100644--- a/app/views/custom_fields/_custom_options.html.erb+++ b/app/views/custom_fields/_custom_options.html.erb@@ -40,58 +40,58 @@ See docs/COPYRIGHT.rdoc for more details.<col></colgroup><thead>- <tr>- <th>- <div class="generic-table--sort-header-outer">- <div class="generic-table--sort-header">+ <tr>+ <th>+ <div class="generic-table--sort-header-outer">+ <div class="generic-table--sort-header"><span><%= t('activerecord.attributes.custom_value.value') %></span>- </div></div>- </th>- <th>- <div class="generic-table--sort-header-outer">- <div class="generic-table--sort-header">+ </div>+ </th>+ <th>+ <div class="generic-table--sort-header-outer">+ <div class="generic-table--sort-header"><span><%= t(:label_default) %></span>- </div></div>- </th>- <th>- <div class="generic-table--sort-header-outer">- <div class="generic-table--sort-header">+ </div>+ </th>+ <th>+ <div class="generic-table--sort-header-outer">+ <div class="generic-table--sort-header"><span><%= t(:button_sort) %></span>- </div></div>- </th>- <th style="max-width:200px;">- <div class="generic-table--empty-header">- </div>- </th>- </tr>+ </div>+ </th>+ <th style="max-width:200px;">+ <div class="generic-table--empty-header">+ </div>+ </th>+ </tr></thead><tbody id="custom-field-dragula-container">- <% custom_field.custom_options.each_with_index do |custom_option, i| %>- <%= f.fields_for :custom_options, custom_option do |co_f| %>- <tr class="dragula-element custom-option-row">- <td>- <span class="dragula-handle icon icon-table icon-drag-handle"></span>- <%= co_f.hidden_field :id, class: 'custom-option-id' %>- <%= co_f.text_field :value,- container_class: 'custom-option-value',- no_label: true %>- </td>- <td>- <%= co_f.check_box :default_value,- container_class: 'custom-option-default-value',+ <% custom_field.custom_options.each_with_index do |custom_option, i| %>+ <%= f.fields_for :custom_options, custom_option do |co_f| %>+ <tr class="dragula-element custom-option-row">+ <td>+ <span class="dragula-handle icon icon-table icon-drag-handle"></span>+ <%= co_f.hidden_field :id, class: 'custom-option-id' %>+ <%= co_f.text_field :value,+ container_class: 'custom-option-value',no_label: true %>- </td>- <td>+ </td>+ <td>+ <%= co_f.check_box :default_value,+ container_class: 'custom-option-default-value',+ no_label: true %>+ </td>+ <td><span class="reorder-icons"><a title="<%= t(:label_sort_highest) %>" rel="nofollow" href="#" class="sort-up-custom-option"><%= op_icon('icon-context icon-sort-up icon-small') %>@@ -106,18 +106,18 @@ See docs/COPYRIGHT.rdoc for more details.<%= op_icon('icon-context icon-sort-down icon-small') %></a></span>- </td>- <td>- <%= link_to '',- delete_option_of_custom_field_path(id: custom_field.id || 0, option_id: custom_option.id || 0),- method: :delete,- data: { confirm: t(:'custom_fields.confirm_destroy_option') },- class: 'icon icon-delete delete-custom-option',- title: t(:button_delete) %>- </td>- </tr>- <% end %>+ </td>+ <td>+ <%= link_to '',+ delete_option_of_custom_field_path(id: custom_field.id || 0, option_id: custom_option.id || 0),+ method: :delete,+ data: { confirm: t(:'custom_fields.confirm_destroy_option') },+ class: 'icon icon-delete delete-custom-option',+ title: t(:button_delete) %>+ </td>+ </tr><% end %>+ <% end %></tbody></table>diff --git a/frontend/src/app/modules/augmenting/dynamic-scripts/custom_fields.js b/frontend/src/app/modules/augmenting/dynamic-scripts/custom_fields.jsindex b0a11955f86..fbd0659cbf2 100644--- a/frontend/src/app/modules/augmenting/dynamic-scripts/custom_fields.js+++ b/frontend/src/app/modules/augmenting/dynamic-scripts/custom_fields.js@@ -200,12 +200,16 @@value.attr("id", "custom_field_custom_options_attributes_" + count + "_value");value.val("");- var defaultValue = dup.find(".custom-option-default-value");+ var defaultValueContainer = dup.find(".custom-option-default-value");+ var defaultValueCheckbox = defaultValueContainer.find('input[type="checkbox"]');+ var defaultValueHidden = defaultValueContainer.find('input[type="hidden"]');- defaultValue.attr("name", "custom_field[custom_options_attributes][" + count + "][default_value]");- defaultValue.prop("checked", false);+ defaultValueHidden.attr("name", "custom_field[custom_options_attributes][" + count + "][default_value]");+ defaultValueCheckbox.attr("name", "custom_field[custom_options_attributes][" + count + "][default_value]");+ defaultValueCheckbox.attr("id", "custom_field_custom_options_attributes_" + count + "_default_value]");+ defaultValueCheckbox.prop("checked", false);- dup.find(".custom-option-id").remove()+ dup.find(".custom-option-id").remove();dup.find(".move-up-custom-option").click(moveUpRow);dup.find(".sort-up-custom-option").click(moveRowToTheTop);