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
@query.issues(
:include => [:tracker, :assigned_to, :priority],
:conditions => [
"((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?) OR ((start_date < ?) AND (due_date > ?)))",
@calendar.startdt, @calendar.enddt,
@calendar.startdt, @calendar.enddt,
"((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?))",
@calendar.startdt, @calendar.enddt,
@calendar.startdt, @calendar.enddt
]
)
events +=
app/models/issue.rb
# Returns a string of css classes that apply to the issue
def css_classes(user=User.current)
s = +"issue issue-#{id} tracker-#{tracker_id} status-#{status_id} #{priority.try(:css_classes)}"
s = +"issue tracker-#{tracker_id} status-#{status_id} #{priority.try(:css_classes)}"
s << ' closed' if closed?
s << ' overdue' if overdue?
s << ' child' if child?
app/views/common/_calendar.html.erb
<li scope="col" class="calhead"><%= day_name((calendar.first_wday + i) % 7) %></li>
<% end %>
<% calendar.format_month.each_slice(7) do |week| %>
<% weekly_events = calendar.events_on_week(week[0]) %>
<li class='week-number'>
<span class="label-week"><%= l(:label_week) %></span> <%= calendar.week_number week.first %>
</li>
......
<p class="day-num"><%= day.day %>
<span class="abbr-day">(<%= abbr_day_name(day.cwday) %>)</span>
</p>
<div class="cal-events">
<% weekly_events.each do |i| %>
<div class="cal-event <%= "event-" + i.class.name.downcase %>">
<% if i.is_a? Issue %>
<% if ((day == week[0] && (i.start_date.nil? || i.start_date < week[0])) || day == i.start_date || day == i.due_date) %>
<% duration = ((i.due_date.nil? ? week[6] : [i.due_date, week[6]].min) - day).to_i + 1 %>
<%= 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 %>
<span class="text">
<%= "#{i.project} -" unless @project && @project == i.project %>
<%= link_to_issue i %>
</span>
<span class="tip"><%= render_issue_tooltip i %></span>
<%= check_box_tag 'ids[]', i.id, false, :style => 'display:none;', :id => nil %>
<% end %>
<% end %>
<% elsif i.due_date == day %>
<span class="icon icon-package">
<%= "#{i.project} -" unless @project && @project == i.project %>
<%= link_to_version i %>
</span>
<% calendar.events_on(day).each do |i| %>
<% if i.is_a? Issue %>
<%= tag.div class: [ i.css_classes, 'tooltip hascontextmenu', starting: day == i.start_date, ending: day == i.due_date] do %>
<%= "#{i.project} -" unless @project && @project == i.project %>
<%= link_to_issue i, :truncate => 30 %>
<span class="tip"><%= render_issue_tooltip i %></span>
<%= check_box_tag 'ids[]', i.id, false, :style => 'display:none;', :id => nil %>
<% end %>
</div>
<% else %>
<span class="icon icon-package">
<%= "#{i.project} -" unless @project && @project == i.project %>
<%= link_to_version i %>
</span>
<% end %>
<% end %>
</div>
</li>
<% end %>
<% end %>
lib/redmine/helpers/calendar.rb
# Sets calendar events
def events=(events)
@events = events.sort_by do |e|
[
e.is_a?(Issue) ? 0 : 1,
e.start_date || @enddt,
e.due_date || @enddt,
(e.start_date.nil? || e.start_date < @startdt) ? 0 : 1,
]
end
@events = events
@ending_events_by_days = @events.group_by {|event| event.due_date}
@starting_events_by_days = @events.group_by {|event| event.start_date}
end
......
((@ending_events_by_days[day] || []) + (@starting_events_by_days[day] || [])).uniq
end
def events_on_week(week_start_date)
@events.filter do |e|
if e.is_a? Issue
if e.start_date.nil? || e.due_date.nil?
(!e.start_date.nil? && e.due_date.nil? && e.start_date < week_start_date+7) ||
(e.start_date.nil? && !e.due_date.nil? && e.due_date >= week_start_date+7)
else
e.start_date < week_start_date+7 && e.due_date >= week_start_date
end
else
e.due_date >= week_start_date && e.due_date < week_start_date+7
end
end
end
# Calendar current month
def month
@date.month
public/javascripts/context_menu.js
if (event.which == 1 || (navigator.appVersion.match(/\bMSIE\b/))) {
var tr = target.closest('.hascontextmenu').first();
if (tr.length > 0) {
if (tr.closest(".cal").length > 0) {
// Select the same issue id elements in the Calendar
var issueNumberClass = tr.attr("class").split(" ").filter((i) => i.startsWith("issue-"))[0];
if (issueNumberClass !== undefined) {
tr = tr.closest(".cal").find(".hascontextmenu" + "." + issueNumberClass);
}
}
// a row was clicked
if (target.is('td.checkbox')) {
// the td containing the checkbox was clicked, toggle the checkbox
public/stylesheets/application.css
border: 1px solid #c0c0c0;
border-spacing: 0;
border-radius: 3px;
position: relative;
}
.cal .calhead {
......
.cal .week-number .label-week {
display: none;
}
.cal .week-number .event-id {
visibility: hidden;
}
.cal .week-number .event-version {
height: 2rem;
}
.cal .calbody {
border: 1px solid #d7d7d7;
......
line-height: 1.2;
min-height: calc(1.2em * 6);
padding: 2px;
display: grid;
grid-template-rows: auto 1fr;
}
.cal .calbody p.day-num {font-size: 1.1em; text-align:right;}
......
.cal .calbody.odd p.day-num {color: #bbb;}
.cal .calbody.today {background:#ffd;}
.cal .calbody.today p.day-num {font-weight: bold;}
.cal .calbody .cal-event {
height: calc(1.2rem + 10px);
}
.cal .calbody .cal-event.event-version {
height: calc(2.2rem + 10px);
}
.cal .calbody .cal-event > .issue {
position: absolute;
}
.cal .calbody .cal-event > .issue > .text {
display: inline-block;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* ((ul.width - week-number.width) / 7 * n - div.issue.padding - div.issue.border - li.calbody.padding - li.calbody.border) */
.cal .calbody .cal-event > .issue.duration-1 {width: calc((100% - 2rem) / 7 * 1 - 12px - 2px - 2px - 2px);}
.cal .calbody .cal-event > .issue.duration-2 {width: calc((100% - 2rem) / 7 * 2 - 12px - 2px - 2px - 2px);}
.cal .calbody .cal-event > .issue.duration-3 {width: calc((100% - 2rem) / 7 * 3 - 12px - 2px - 2px - 2px);}
.cal .calbody .cal-event > .issue.duration-4 {width: calc((100% - 2rem) / 7 * 4 - 12px - 2px - 2px - 2px);}
.cal .calbody .cal-event > .issue.duration-5 {width: calc((100% - 2rem) / 7 * 5 - 12px - 2px - 2px - 2px);}
.cal .calbody .cal-event > .issue.duration-6 {width: calc((100% - 2rem) / 7 * 6 - 12px - 2px - 2px - 2px);}
.cal .calbody .cal-event > .issue.duration-7 {width: calc((100% - 2rem) / 7 * 7 - 12px - 2px - 2px - 2px);}
.cal .calbody .cal-event > .issue.ending:not(.week-0):not(.starting) {display:none;}
.cal .calbody .icon {padding-top: 2px; padding-bottom: 3px;}
.cal .calbody.nwday:not(.odd) {background-color:#f1f1f1;}
.cal .starting a.issue, p.cal.legend .starting {background: url(../images/bullet_go.png) no-repeat -1px -2px; padding-left:16px;}
.cal .ending a.issue, p.cal.legend .ending {background: url(../images/bullet_end.png) no-repeat -1px -2px; padding-left:16px;}
.cal .starting.ending a.issue, p.cal.legend .starting.ending {background: url(../images/bullet_diamond.png) no-repeat -1px -2px; padding-left:16px;}
p.cal.legend {display:none;}
p.cal.legend span {display:block;}
.controller-calendars p.buttons {margin-top: unset;}
public/stylesheets/responsive.css
display: inline;
}
.cal .calbody .cal-events > .cal-event {
height: auto;
}
.cal .calbody .cal-events > .cal-event > .issue {
width: auto;
position: relative;
overflow: visible;
white-space:normal;
}
div.tooltip:hover span.tip {
position: absolute;
}
.cal .week-number {
border: 1px solid #c0c0c0;
text-align: left;
......
font-size: 1.1em;
text-align: left;
}
.cal .calbody .cal-events > .cal-event > .issue.starting,
.cal .calbody .cal-events > .cal-event > .issue.ending {display: block;}
.cal .calbody .cal-events > .cal-event > .issue.week-0:not(.starting):not(.ending) {display:none;}
.cal .starting a.issue, p.cal.legend .starting {background: url(../images/bullet_go.png) no-repeat -1px -2px; padding-left:16px;}
.cal .ending a.issue, p.cal.legend .ending {background: url(../images/bullet_end.png) no-repeat -1px -2px; padding-left:16px;}
.cal .starting.ending a.issue, p.cal.legend .starting.ending {background: url(../images/bullet_diamond.png) no-repeat -1px -2px; padding-left:16px;}
p.cal.legend {display:block;}
}
@media all and (max-width: 599px) {
(4-4/4)