Project

General

Profile

Patch #39050 » new_design_calendar.patch

UTF-8 - Yasu Saku, 2023-09-09 10:27

View differences:

app/controllers/calendars_controller.rb
48 48
        @query.issues(
49 49
          :include => [:tracker, :assigned_to, :priority],
50 50
          :conditions => [
51
            "((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?) OR ((start_date < ?) AND (due_date > ?)))",
52
            @calendar.startdt, @calendar.enddt,
53
            @calendar.startdt, @calendar.enddt,
51
            "((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?))",
54 52
            @calendar.startdt, @calendar.enddt,
53
            @calendar.startdt, @calendar.enddt
55 54
          ]
56 55
        )
57 56
      events +=
app/models/issue.rb
1450 1450

  
1451 1451
  # Returns a string of css classes that apply to the issue
1452 1452
  def css_classes(user=User.current)
1453
    s = +"issue issue-#{id} tracker-#{tracker_id} status-#{status_id} #{priority.try(:css_classes)}"
1453
    s = +"issue tracker-#{tracker_id} status-#{status_id} #{priority.try(:css_classes)}"
1454 1454
    s << ' closed' if closed?
1455 1455
    s << ' overdue' if overdue?
1456 1456
    s << ' child' if child?
app/views/common/_calendar.html.erb
6 6
    <li scope="col" class="calhead"><%= day_name((calendar.first_wday + i) % 7) %></li>
7 7
  <% end %>
8 8
  <% calendar.format_month.each_slice(7) do |week| %>
9
    <% weekly_events = calendar.events_on_week(week[0]) %>
10 9
    <li class='week-number'>
11 10
      <span class="label-week"><%= l(:label_week) %></span> <%= calendar.week_number week.first %>
12 11
    </li>
......
15 14
      <p class="day-num"><%= day.day %>
16 15
        <span class="abbr-day">(<%= abbr_day_name(day.cwday) %>)</span>
17 16
      </p>
18
      <div class="cal-events">
19
      <% weekly_events.each do |i| %>
20
        <div class="cal-event <%= "event-" + i.class.name.downcase %>">
21
          <% if i.is_a? Issue %>
22
            <% if ((day == week[0] && (i.start_date.nil? || i.start_date < week[0])) || day == i.start_date || day == i.due_date) %>
23
              <% duration = ((i.due_date.nil? ? week[6] : [i.due_date, week[6]].min) - day).to_i + 1 %>
24
              <%= tag.div class: [ i.css_classes, 'tooltip hascontextmenu', day == week[0] ? 'week-0' : '', 'duration-' + duration.to_s, starting: day == i.start_date, ending: day == i.due_date ] do %>
25
                <span class="text">
26
                  <%= "#{i.project} -" unless @project && @project == i.project %>
27
                  <%= link_to_issue i %>
28
                </span>
29
                <span class="tip"><%= render_issue_tooltip i %></span>
30
                <%= check_box_tag 'ids[]', i.id, false, :style => 'display:none;', :id => nil %>
31
              <% end %>
32
            <% end %>
33
          <% elsif i.due_date == day %>
34
            <span class="icon icon-package">
35
              <%= "#{i.project} -" unless @project && @project == i.project %>
36
              <%= link_to_version i %>
37
            </span>
17
      <% calendar.events_on(day).each do |i| %>
18
        <% if i.is_a? Issue %>
19
          <%= tag.div class: [ i.css_classes, 'tooltip hascontextmenu', starting: day == i.start_date, ending: day == i.due_date] do %>
20
            <%= "#{i.project} -" unless @project && @project == i.project %>
21
            <%= link_to_issue i, :truncate => 30 %>
22
            <span class="tip"><%= render_issue_tooltip i %></span>
23
            <%= check_box_tag 'ids[]', i.id, false, :style => 'display:none;', :id => nil %>
38 24
          <% end %>
39
        </div>
25
        <% else %>
26
          <span class="icon icon-package">
27
            <%= "#{i.project} -" unless @project && @project == i.project %>
28
            <%= link_to_version i %>
29
          </span>
30
        <% end %>
40 31
      <% end %>
41
      </div>
42 32
    </li>
43 33
    <% end %>
44 34
  <% end %>
lib/redmine/helpers/calendar.rb
66 66

  
67 67
      # Sets calendar events
68 68
      def events=(events)
69
        @events = events.sort_by do |e|
70
          [
71
            e.is_a?(Issue) ? 0 : 1,
72
            e.start_date || @enddt,
73
            e.due_date || @enddt,
74
            (e.start_date.nil? || e.start_date < @startdt) ? 0 : 1,
75
          ]
76
        end
69
        @events = events
77 70
        @ending_events_by_days = @events.group_by {|event| event.due_date}
78 71
        @starting_events_by_days = @events.group_by {|event| event.start_date}
79 72
      end
......
83 76
        ((@ending_events_by_days[day] || []) + (@starting_events_by_days[day] || [])).uniq
84 77
      end
85 78

  
86
      def events_on_week(week_start_date)
87
        @events.filter do |e|
88
          if e.is_a? Issue
89
            if e.start_date.nil? || e.due_date.nil?
90
              (!e.start_date.nil? && e.due_date.nil? && e.start_date < week_start_date+7) ||
91
              (e.start_date.nil? && !e.due_date.nil? && e.due_date >= week_start_date+7)
92
            else
93
              e.start_date < week_start_date+7 && e.due_date >= week_start_date
94
            end
95
          else
96
            e.due_date >= week_start_date && e.due_date < week_start_date+7
97
          end
98
        end
99
      end
100

  
101 79
      # Calendar current month
102 80
      def month
103 81
        @date.month
public/javascripts/context_menu.js
30 30
  if (event.which == 1 || (navigator.appVersion.match(/\bMSIE\b/))) {
31 31
    var tr = target.closest('.hascontextmenu').first();
32 32
    if (tr.length > 0) {
33
      if (tr.closest(".cal").length > 0) {
34
        // Select the same issue id elements in the Calendar
35
        var issueNumberClass = tr.attr("class").split(" ").filter((i) => i.startsWith("issue-"))[0];
36
        if (issueNumberClass !== undefined) {
37
          tr = tr.closest(".cal").find(".hascontextmenu" + "." + issueNumberClass);
38
        }
39
      }
40 33
      // a row was clicked
41 34
      if (target.is('td.checkbox')) {
42 35
    	// the td containing the checkbox was clicked, toggle the checkbox
public/stylesheets/application.css
1110 1110
  border: 1px solid #c0c0c0;
1111 1111
  border-spacing: 0;
1112 1112
  border-radius: 3px;
1113
  position: relative;
1114 1113
}
1115 1114

  
1116 1115
.cal .calhead {
......
1131 1130
.cal .week-number .label-week {
1132 1131
  display: none;
1133 1132
}
1134
.cal .week-number .event-id {
1135
  visibility: hidden;
1136
}
1137
.cal .week-number .event-version {
1138
  height: 2rem;
1139
}
1140 1133

  
1141 1134
.cal .calbody {
1142 1135
  border: 1px solid #d7d7d7;
......
1147 1140
  line-height: 1.2;
1148 1141
  min-height: calc(1.2em * 6);
1149 1142
  padding: 2px;
1150
  display: grid;
1151
  grid-template-rows: auto 1fr;
1152 1143
}
1153 1144

  
1154 1145
.cal .calbody p.day-num {font-size: 1.1em; text-align:right;}
......
1156 1147
.cal .calbody.odd p.day-num {color: #bbb;}
1157 1148
.cal .calbody.today {background:#ffd;}
1158 1149
.cal .calbody.today p.day-num {font-weight: bold;}
1159
.cal .calbody .cal-event {
1160
  height: calc(1.2rem + 10px);
1161
}
1162
.cal .calbody .cal-event.event-version {
1163
  height: calc(2.2rem + 10px);
1164
}
1165
.cal .calbody .cal-event > .issue {
1166
  position: absolute;
1167
}
1168

  
1169
.cal .calbody .cal-event > .issue > .text {
1170
  display: inline-block;
1171
  width: 100%;
1172
  white-space: nowrap;
1173
  overflow: hidden;
1174
  text-overflow: ellipsis;
1175
}
1176

  
1177
/* ((ul.width - week-number.width) / 7 * n - div.issue.padding - div.issue.border - li.calbody.padding - li.calbody.border) */
1178
.cal .calbody .cal-event > .issue.duration-1 {width: calc((100% - 2rem) / 7 * 1 - 12px - 2px - 2px - 2px);}
1179
.cal .calbody .cal-event > .issue.duration-2 {width: calc((100% - 2rem) / 7 * 2 - 12px - 2px - 2px - 2px);}
1180
.cal .calbody .cal-event > .issue.duration-3 {width: calc((100% - 2rem) / 7 * 3 - 12px - 2px - 2px - 2px);}
1181
.cal .calbody .cal-event > .issue.duration-4 {width: calc((100% - 2rem) / 7 * 4 - 12px - 2px - 2px - 2px);}
1182
.cal .calbody .cal-event > .issue.duration-5 {width: calc((100% - 2rem) / 7 * 5 - 12px - 2px - 2px - 2px);}
1183
.cal .calbody .cal-event > .issue.duration-6 {width: calc((100% - 2rem) / 7 * 6 - 12px - 2px - 2px - 2px);}
1184
.cal .calbody .cal-event > .issue.duration-7 {width: calc((100% - 2rem) / 7 * 7 - 12px - 2px - 2px - 2px);}
1185

  
1186
.cal .calbody .cal-event > .issue.ending:not(.week-0):not(.starting) {display:none;}
1187 1150

  
1188 1151
.cal .calbody .icon {padding-top: 2px; padding-bottom: 3px;}
1189 1152
.cal .calbody.nwday:not(.odd) {background-color:#f1f1f1;}
1153
.cal .starting a.issue, p.cal.legend .starting {background: url(../images/bullet_go.png) no-repeat -1px -2px; padding-left:16px;}
1154
.cal .ending a.issue, p.cal.legend .ending {background: url(../images/bullet_end.png) no-repeat -1px -2px; padding-left:16px;}
1155
.cal .starting.ending a.issue, p.cal.legend .starting.ending {background: url(../images/bullet_diamond.png) no-repeat -1px -2px; padding-left:16px;}
1190 1156

  
1191
p.cal.legend {display:none;}
1192 1157
p.cal.legend span {display:block;}
1193 1158
.controller-calendars p.buttons {margin-top: unset;}
1194 1159

  
public/stylesheets/responsive.css
836 836
    display: inline;
837 837
  }
838 838

  
839
  .cal .calbody .cal-events > .cal-event {
840
    height: auto;
841
  }
842

  
843
  .cal .calbody .cal-events > .cal-event > .issue {
844
    width: auto;
845
    position: relative;
846
    overflow: visible;
847
    white-space:normal;
848
  }
849

  
850
  div.tooltip:hover span.tip {
851
    position: absolute;
852
  }
853

  
854 839
  .cal .week-number {
855 840
    border: 1px solid #c0c0c0;
856 841
    text-align: left;
......
866 851
    font-size: 1.1em;
867 852
    text-align: left;
868 853
  }
869

  
870
  .cal .calbody .cal-events > .cal-event > .issue.starting,
871
  .cal .calbody .cal-events > .cal-event > .issue.ending {display: block;}
872
  .cal .calbody .cal-events > .cal-event > .issue.week-0:not(.starting):not(.ending) {display:none;}
873

  
874
  .cal .starting a.issue, p.cal.legend .starting {background: url(../images/bullet_go.png) no-repeat -1px -2px; padding-left:16px;}
875
  .cal .ending a.issue, p.cal.legend .ending {background: url(../images/bullet_end.png) no-repeat -1px -2px; padding-left:16px;}
876
  .cal .starting.ending a.issue, p.cal.legend .starting.ending {background: url(../images/bullet_diamond.png) no-repeat -1px -2px; padding-left:16px;}
877

  
878
  p.cal.legend {display:block;}
879 854
}
880 855

  
881 856
@media all and (max-width: 599px) {
(4-4/4)