Project

General

Profile

Patch #41827 » v2_01_cf_name_limit_and_ui_fixes.patch

Leonid Murin, 2025-05-23 10:25

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
520 520
#list-definition > div .field{
521 521
  width: 160px;
522 522
}
523
.query-columns { max-width: min(58vw, 500px); }
523 524
.query-columns label {
524 525
  display:block;
525 526
}
......
529 530
}
530 531
.query-columns select {
531 532
  min-width:150px;
533
  width: 100%;
534
}
535
.query-columns select option {
536
  overflow: hidden;
537
  text-overflow: ellipsis;
538
}
539
#query_form fieldset#options select#group_by,
540
#query-form fieldset#options select#query_group_by {
541
  max-width: 500px;
542
  width: 100%;
543
}
544
#query-form fieldset#sort select {
545
  max-width:min(36vw, 500px);
532 546
}
533 547

  
534 548
.query-totals {text-align:right; margin-top:-2.3em; font-size: 93%;}
......
762 776
}
763 777

  
764 778
.add-filter {width:35%; float:right; text-align: right; vertical-align: top;}
779
.add-filter select { max-width: 70%; }
765 780

  
766 781
#issue_is_private_wrap {float:right; margin-right:1em;}
767 782
.toggle-multiselect { margin-right:5px; cursor:pointer;}
768
- 
app/assets/javascripts/application-legacy.js
128 128

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

  
134 135
function moveOptionUp(theSel) {
......
1225 1226
}
1226 1227

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

  
1228 1238
  $(container || 'body').find("[title]:not(.no-tooltip)").tooltip({
1229 1239
    show: {
1230 1240
      delay: 400
......
1392 1402
    button.click(function(e){
1393 1403
      main.addClass("animate");
1394 1404
      main.toggleClass('collapsedsidebar');
1405
      setupHoverTooltips();
1395 1406
      applyState();
1396 1407
      e.preventDefault();
1397 1408
      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
545 545
  max-width:min(36vw, 500px);
546 546
}
547 547

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