Project

General

Profile

Patch #41827 » v3_01_cf_name_limit_and_ui_fixes.patch

Leonid Murin, 2025-12-22 09:38

View differences:

app/models/custom_field.rb
35 35

  
36 36
  validates_presence_of :name, :field_format
37 37
  validates_uniqueness_of :name, :scope => :type, :case_sensitive => true
38
  validates_length_of :name, :maximum => 30
38
  validates_length_of :name, maximum: 255
39 39
  validates_length_of :regexp, maximum: 255
40 40
  validates_inclusion_of :field_format,
41 41
                         :in => proc {Redmine::FieldFormat.available_formats}
/dev/null → db/migrate/20241016120800_change_custom_fields_name_limit.rb
1
class ChangeCustomFieldsNameLimit < ActiveRecord::Migration[7.2]
2
  def up
3
    change_column :custom_fields, :name, :string, limit: 255, default: ''
4
  end
5

  
6
  def down
7
    change_column :custom_fields, :name, :string, limit: 30, default: ''
8
  end
9
end
test/unit/custom_field_test.rb
48 48
    assert field.save
49 49
  end
50 50

  
51
  def test_name_should_be_validated
52
    field = CustomField.new(name: 'Very long custom field name' * 10, field_format: 'int')
53
    assert field.invalid?
54
  end
55

  
51 56
  def test_default_value_should_be_validated
52 57
    field = CustomField.new(:name => 'Test', :field_format => 'int')
53 58
    field.default_value = 'abc'
54
- 
app/assets/stylesheets/application.css
539 539
#list-definition > div .field{
540 540
  width: 160px;
541 541
}
542
.query-columns { max-width: min(58vw, 500px); }
542 543
.query-columns label {
543 544
  display:block;
544 545
}
......
548 549
}
549 550
.query-columns select {
550 551
  min-width:150px;
552
  width: 100%;
553
}
554
.query-columns select option {
555
  overflow: hidden;
556
  text-overflow: ellipsis;
557
}
558
#query_form fieldset#options select#group_by,
559
#query-form fieldset#options select#query_group_by {
560
  max-width: 500px;
561
  width: 100%;
562
}
563
#query-form fieldset#sort select {
564
  max-width:min(36vw, 500px);
551 565
}
552 566

  
553 567
.query-totals {text-align:right; margin-top:-2.3em; font-size: 93%;}
......
779 793
}
780 794

  
781 795
.add-filter {width:35%; float:right; text-align: right; vertical-align: top;}
796
.add-filter select { max-width: 70%; }
782 797

  
783 798
#issue_is_private_wrap {float:right; margin-right:1em;}
784 799
.toggle-multiselect { margin-right:5px; cursor:pointer;}
785
- 
app/assets/javascripts/application-legacy.js
129 129

  
130 130
// columns selection
131 131
function moveOptions(theSelFrom, theSelTo) {
132
  $(theSelFrom).find('option:selected').detach().prop("selected", false).appendTo($(theSelTo));
132
  $(theSelFrom).find('option:selected').detach().prop("selected", false).appendTo($(theSelTo)).
133
    filter('[title]').tooltip("close");
133 134
}
134 135

  
135 136
function moveOptionUp(theSel) {
......
1226 1227
}
1227 1228

  
1228 1229
function setupHoverTooltips(container) {
1230
  $(".js-overflow-to-tooltip").each(function () {
1231
      const currentTitle = this.getAttribute('title');
1232
      if ((this.scrollWidth > this.clientWidth ||
1233
              this.scrollHeight > this.clientHeight) &&
1234
          !currentTitle) {
1235
          this.setAttribute('title', this.textContent);
1236
      }
1237
  });
1238

  
1229 1239
  $(container || 'body').find("[title]:not(.no-tooltip)").tooltip({
1230 1240
    show: {
1231 1241
      delay: 400
......
1403 1413
    button.click(function(e){
1404 1414
      main.addClass("animate");
1405 1415
      main.toggleClass('collapsedsidebar');
1416
      setupHoverTooltips();
1406 1417
      applyState();
1407 1418
      e.preventDefault();
1408 1419
      return false;
app/helpers/queries_helper.rb
129 129

  
130 130
  def query_available_inline_columns_options(query)
131 131
    (query.available_inline_columns - query.columns).
132
      reject(&:frozen?).collect {|column| [column.caption, column.name]}
132
      reject(&:frozen?).collect {|column| column_select_option(column)}
133 133
  end
134 134

  
135 135
  def query_selected_inline_columns_options(query)
136 136
    (query.inline_columns & query.available_inline_columns).
137
      reject(&:frozen?).collect {|column| [column.caption, column.name]}
137
      reject(&:frozen?).collect {|column| column_select_option(column)}
138
  end
139

  
140
  def column_select_option(column)
141
    [column.caption, column.name, {class: 'js-overflow-to-tooltip'}]
138 142
  end
139 143

  
140 144
  def render_query_columns_selection(query, options={})
app/views/my/blocks/_issues.erb
1 1
<div class="contextual">
2
  <%= link_to_function sprite_icon('settings', l(:label_options)), "$('##{block}-settings').toggle();", :class => 'icon-only icon-settings', :title => l(:label_options) %>
2
  <%= link_to_function sprite_icon('settings', l(:label_options)), "$('##{block}-settings').toggle(); setupHoverTooltips();", :class => 'icon-only icon-settings', :title => l(:label_options) %>
3 3
</div>
4 4

  
5 5
<h3>
app/views/queries/_query_form.html.erb
16 16

  
17 17
  <% if @query.available_columns.any? %>
18 18
    <fieldset id="options" class="collapsible collapsed">
19
      <legend onclick="toggleFieldset(this);" class="icon icon-collapsed">
19
      <legend onclick="toggleFieldset(this); setupHoverTooltips();" class="icon icon-collapsed">
20 20
        <%= sprite_icon("angle-right", rtl: true) %>
21 21
        <%= l(:label_options) %>
22 22
      </legend>
......
83 83
  $('input[name=display_type]').change(function (e) {
84 84
    if ($("#display_type_list").is(':checked')) {
85 85
      $('table#list-definition').show();
86
      setupHoverTooltips();
86 87
    } else {
87 88
      $('table#list-definition').hide();
88 89
    }
89
- 
app/assets/stylesheets/application.css
564 564
  max-width:min(36vw, 500px);
565 565
}
566 566

  
567
.query-totals {text-align:right; margin-top:-2.3em; font-size: 93%;}
567
.query-totals {text-align:right; font-size: 93%;}
568 568
.query-totals>span:not(:first-child) {margin-left:0.6em;}
569 569
.query-totals .value {font-weight:bold;}
570 570
body.controller-timelog .query-totals {margin-top:initial;}
571
- 
app/assets/javascripts/application-legacy.js
1242 1242
    },
1243 1243
    position: {
1244 1244
      my: "center bottom-5",
1245
      at: "center top"
1245
      at: "center top",
1246
      collision: "flipfit flip"
1246 1247
    }
1247 1248
  });
1248 1249
}
1249
- 
(7-7/7)