Skip to content

Commit

Permalink
Merge pull request #113 from berti92/redmine-5.0.6
Browse files Browse the repository at this point in the history
Redmine 5.0.6
  • Loading branch information
berti92 authored Nov 14, 2023
2 parents ed9d03f + 6544b4f commit 7c5d489
Show file tree
Hide file tree
Showing 314 changed files with 55,906 additions and 15,187 deletions.
11 changes: 6 additions & 5 deletions app/controllers/calendar_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def query_filter(model, filters)
filters.keys.each do |x|
filter_param = filters[x]
filter = $mc_filters[x]
if((filter_param[:enabled] != 'true') || ((model == 'Holiday' && filter[:db_field_holiday].blank?) || (model == 'Issue' && filter[:db_field].blank?)))
if((filter_param[:enabled].to_s != 'true') || ((model == 'Holiday' && filter[:db_field_holiday].blank?) || (model == 'Issue' && filter[:db_field].blank?)))
next
end
condition[0] << ' AND '
Expand Down Expand Up @@ -181,6 +181,7 @@ def get_events
fbegin = params[:start].to_date rescue nil
fend = params[:end].to_date rescue nil
fuser = params[:user].to_s == 'true'
params[:filter] = JSON.parse(params[:filter])
if params[:save_values].to_s == 'true'
session[:mega_calendar_js_user_query] = fuser
if fbegin.to_date == fbegin.to_date.beginning_of_month
Expand Down Expand Up @@ -272,14 +273,14 @@ def change_issue
unless params[:event_end].include?(':')
event_end = event_end.to_date - 1.day
end

begin
i.init_journal(User.current)
i.update({:start_date => params[:event_begin].to_date.to_s, :due_date => event_end.to_date.to_s})
i.update({:start_date => params[:event_begin].to_date.to_s, :due_date => event_end.to_date.to_s})
rescue nil
end
if params[:allDay] != 'true'

if params[:allDay].to_s != 'true'
tt = TicketTime.where(:issue_id => params[:id]).first
if tt.blank?
tt = TicketTime.new(:issue_id => params[:id])
Expand Down
8 changes: 4 additions & 4 deletions app/views/calendar/_filter_panel.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</td>
<td class="mega_calendar__filter_td">
<% if filter[:type] == 'lookup' %>
<%
<%
lookup_query = filter[:lookup_query_model].constantize.send(filter[:lookup_query_method])
if filter[:lookup_query_order]
lookup_query = lookup_query.order(filter[:lookup_query_order])
Expand All @@ -38,7 +38,7 @@
</tr>
<% end %>
</table>
<a href="#" class="icon icon-checked" onclick="$('#calendar').fullCalendar( 'refetchEvents' );"><%= translate 'button_apply' %></a> &nbsp; <a href="#" class="icon icon-reload" onclick="reset_and_reload_filters();"><%= translate 'button_reset' %></a>
<a href="#" class="icon icon-checked" onclick="window.calendar.refetchEvents();"><%= translate 'button_apply' %></a> &nbsp; <a href="#" class="icon icon-reload" onclick="reset_and_reload_filters();"><%= translate 'button_reset' %></a>
<div>
<hr>
<table>
Expand Down Expand Up @@ -76,7 +76,7 @@
$('#calendar_filter input[type="checkbox"]').prop( "checked", false );
$('#calendar_filter select[data-sel="filter_operator"] option:first-child').attr("selected", "selected");
$('#calendar_filter select[data-sel="filter_value_select"] option:selected').removeAttr("selected");
$('#calendar').fullCalendar( 'refetchEvents' );
calendar.refetchEvents();
}
function save_filters() {
form_data = {
Expand All @@ -97,7 +97,7 @@
});
$("#inp_filter_name").val(data["name"]);
$("#inp_filter_global").prop('checked', data["global"]);
$('#calendar').fullCalendar( 'refetchEvents' );
calendar.refetchEvents();
});
}
</script>
222 changes: 150 additions & 72 deletions app/views/calendar/_megacalendar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@
%>

<link rel='stylesheet' href='<%= Setting.plugin_mega_calendar['sub_path'] %>plugin_assets/mega_calendar/stylesheets/mega_calendar.css' />
<link rel='stylesheet' href='<%= Setting.plugin_mega_calendar['sub_path'] %>plugin_assets/mega_calendar/javascripts/fullcalendar/fullcalendar.css' />
<link rel='stylesheet' href='<%= Setting.plugin_mega_calendar['sub_path'] %>plugin_assets/mega_calendar/javascripts/qtip2/jquery.qtip.min.css' />
<script src='<%= Setting.plugin_mega_calendar['sub_path'] %>plugin_assets/mega_calendar/javascripts/fullcalendar/lib/jquery.min.js'></script>
<script src='<%= Setting.plugin_mega_calendar['sub_path'] %>plugin_assets/mega_calendar/javascripts/fullcalendar/lib/moment.min.js'></script>
<script src='<%= Setting.plugin_mega_calendar['sub_path'] %>plugin_assets/mega_calendar/javascripts/fullcalendar/fullcalendar.js'></script>
<script src='<%= Setting.plugin_mega_calendar['sub_path'] %>plugin_assets/mega_calendar/javascripts/qtip2/jquery.qtip.min.js'></script>
<script src='<%= Setting.plugin_mega_calendar['sub_path'] %>plugin_assets/mega_calendar/javascripts/fullcalendar/lang-all.js'></script>
<script src='<%= Setting.plugin_mega_calendar['sub_path'] %>plugin_assets/mega_calendar/javascripts/fullcalendar-6.1.9/dist/index.global.min.js'></script>
<script src='<%= Setting.plugin_mega_calendar['sub_path'] %>plugin_assets/mega_calendar/javascripts/fullcalendar-6.1.9/packages/core/locales-all.global.min.js'></script>
<script src='<%= Setting.plugin_mega_calendar['sub_path'] %>plugin_assets/mega_calendar/javascripts/moment-with-locales.js'></script>
<script src='<%= Setting.plugin_mega_calendar['sub_path'] %>plugin_assets/mega_calendar/javascripts/jquery-serialize-object.min.js'></script>
<h2><%= translate 'calendar' %></h2>
<%= render :partial => 'calendar/filter_panel', :locals => {} %>
Expand All @@ -42,91 +38,173 @@
var btn_mytickets = $('.fc-myTickets-button');
var btn_alltickets = $('.fc-allTickets-button');
if(user === true) {
btn_mytickets.addClass('fc-state-active');
btn_alltickets.removeClass('fc-state-active');
btn_mytickets.addClass('fc-button-active');
btn_alltickets.removeClass('fc-button-active');
} else {
btn_mytickets.removeClass('fc-state-active');
btn_alltickets.addClass('fc-state-active');
btn_mytickets.removeClass('fc-button-active');
btn_alltickets.addClass('fc-button-active');
}
}
$(document).ready(function() {
$('#mega_calendar__calendar').fullCalendar({
lang: '<%= js_locale %>',
defaultView: '<%= default_view %>',
height: <%= calendar_height %>,
selectable: true,
customButtons: {
myTickets: {
text: '<%= translate 'my_issues' %>',
click: function() {
user_query = true;
set_active_button(user_query);
$('#calendar').fullCalendar( 'refetchEvents' );
}
},
allTickets: {
text: '<%= translate 'all_issues' %>',
click: function() {
user_query = false;
set_active_button(user_query);
$('#calendar').fullCalendar( 'refetchEvents' );
}
}
var calendarEl = document.getElementById('mega_calendar__calendar');

window.calendar = new FullCalendar.Calendar(calendarEl, {
initialView: '<%= default_view %>',
locale: '<%= js_locale %>',
selectable: true,
editable: true,
eventDurationEditable: true,
eventOverlap: true,
height: <%= calendar_height %>,
displayEventEnd: true,
dayMaxEventRows: true,
eventDisplay: 'block',
firstDay: <%= (Setting.plugin_mega_calendar['week_start'].blank? ? '1' : Setting.plugin_mega_calendar['week_start'].to_s ) %>,
customButtons: {
myTickets: {
text: '<%= translate 'my_issues' %>',
click: function() {
user_query = true;
set_active_button(user_query);
calendar.refetchEvents();
}
},
header: {
left: '<%= (show_view_buttons == false ? '' : 'prev,next today ') %>allTickets,myTickets',
center: 'title',
right: '<%= (show_view_buttons == false ? '' : 'month,agendaWeek,agendaDay') %>'
},
displayEventEnd: true,
defaultDate: '<%= js_default_date %>',
firstDay: <%= (Setting.plugin_mega_calendar['week_start'].blank? ? '1' : Setting.plugin_mega_calendar['week_start'].to_s ) %>,
events: function(start, end, timezone, callback) {
$.ajax({
url: '<%= Setting.plugin_mega_calendar['sub_path'] %>calendar/get_events',
dataType: 'json',
data: {
start: start.format("YYYY-MM-DD HH:MM"),
end: end.format("YYYY-MM-DD HH:MM"),
allTickets: {
text: '<%= translate 'all_issues' %>',
click: function() {
user_query = false;
set_active_button(user_query);
calendar.refetchEvents();
}
}
},
headerToolbar: {
left: '<%= (show_view_buttons == false ? '' : 'prev,next today ') %>allTickets,myTickets',
center: 'title',
right: '<%= (show_view_buttons == false ? '' : 'dayGridMonth,timeGridWeek,timeGridDay') %>'
},
eventSources: [
{
url: '<%= Setting.plugin_mega_calendar['sub_path'] %>calendar/get_events',
extraParams: function() {
return {
// start: start.format("YYYY-MM-DD HH:MM"),
// end: end.format("YYYY-MM-DD HH:MM"),
user: user_query,
save_values: <%= use_values_from_session %>,
filter: $('#calendar_filter').serializeObject()["filter"]
},
success: function(doc) {
var events = [];
$(doc).each(function() { events.push(this); });
callback(events);
}
filter: JSON.stringify($('#calendar_filter').serializeObject()["filter"])
};
}
}
],
eventDidMount: function(info) {
info.el.title = info.event.extendedProps.description;
$(info.el).tooltip({
content: function () {
return $(this).prop('title');
}
});
},
eventRender: function(event, element) {
element.qtip({ content: event.description, position: { target: 'mouse', adjust: { x: 5, y: 5}} });
select: function(info) {
calendar.unselect();
window.open('<%= Setting.plugin_mega_calendar['sub_path'] %>issues/new?issue[start_date]='+moment(info.start).format("YYYY-MM-DD")+'&issue[due_date]='+moment(info.end).format("YYYY-MM-DD")+'&issue[time_begin]='+moment(info.start).format("HH:mm")+'&issue[time_end]='+moment(info.end).format("HH:mm"), '_blank');
},
eventLimit: true,
editable: true,
eventDrop: function(event, delta, revertFunc) {
eventResize: function(info) {
if(!confirm("<%= (translate 'save_question') %>")) {
revertFunc();
info.revert();
} else {
var event_begin = event.start.format();
var event_end = (event.end !== null ? event.end.format() : null);
var allDay = event.allDay;
$.get('<%= Setting.plugin_mega_calendar['sub_path'] %>calendar/change_' + event.controller_name, { id: event.id, event_begin: event_begin, event_end: event_end, allDay: allDay });
$.get('<%= Setting.plugin_mega_calendar['sub_path'] %>calendar/change_' + info.event.extendedProps.controller_name, { id: info.event.id, event_begin: moment(info.event.start).format("YYYY-MM-DD HH:mm"), event_end: moment(info.event.end).format("YYYY-MM-DD HH:mm") });
}
},
eventResize: function(event, delta, revertFunc) {
eventDrop: function(info) {
if(!confirm("<%= (translate 'save_question') %>")) {
revertFunc();
info.revert();
} else {
$.get('<%= Setting.plugin_mega_calendar['sub_path'] %>calendar/change_' + event.controller_name, { id: event.id, event_begin: event.start.format(), event_end: event.end.format() });
var event_begin = moment(info.event.start).format();
var event_end = (info.event.end !== null ? moment(info.event.end).format() : null);
var allDay = info.event.allDay;
$.get('<%= Setting.plugin_mega_calendar['sub_path'] %>calendar/change_' + info.event.extendedProps.controller_name, { id: info.event.id, event_begin: moment(event_begin).format("YYYY-MM-DD HH:mm"), event_end: moment(event_end).format("YYYY-MM-DD HH:mm"), allDay: allDay });
}
},
select: function(start, end) {
$('#calendar').fullCalendar('unselect');
window.open('<%= Setting.plugin_mega_calendar['sub_path'] %>issues/new?issue[start_date]='+start.format("YYYY-MM-DD")+'&issue[due_date]='+end.format("YYYY-MM-DD")+'&issue[time_begin]='+start.format("HH:mm")+'&issue[time_end]='+end.format("HH:mm"), '_blank');
},
});
calendar.render();
set_active_button(user_query);
// $('#mega_calendar__calendar').fullCalendar({
// lang: '<%= js_locale %>',
// defaultView: '<%= default_view %>',
// height: <%= calendar_height %>,
// selectable: true,
// customButtons: {
// myTickets: {
// text: '<%= translate 'my_issues' %>',
// click: function() {
// user_query = true;
// set_active_button(user_query);
// $('#calendar').fullCalendar( 'refetchEvents' );
// }
// },
// allTickets: {
// text: '<%= translate 'all_issues' %>',
// click: function() {
// user_query = false;
// set_active_button(user_query);
// $('#calendar').fullCalendar( 'refetchEvents' );
// }
// }

// },
// header: {
// left: '<%= (show_view_buttons == false ? '' : 'prev,next today ') %>allTickets,myTickets',
// center: 'title',
// right: '<%= (show_view_buttons == false ? '' : 'month,agendaWeek,agendaDay') %>'
// },
// displayEventEnd: true,
// defaultDate: '<%= js_default_date %>',
// firstDay: <%= (Setting.plugin_mega_calendar['week_start'].blank? ? '1' : Setting.plugin_mega_calendar['week_start'].to_s ) %>,
// events: function(start, end, timezone, callback) {
// $.ajax({
// url: '<%= Setting.plugin_mega_calendar['sub_path'] %>calendar/get_events',
// dataType: 'json',
// data: {
// start: start.format("YYYY-MM-DD HH:MM"),
// end: end.format("YYYY-MM-DD HH:MM"),
// user: user_query,
// save_values: <%= use_values_from_session %>,
// filter: $('#calendar_filter').serializeObject()["filter"]
// },
// success: function(doc) {
// var events = [];
// $(doc).each(function() { events.push(this); });
// callback(events);
// }
// });
// },
// eventRender: function(event, element) {
// // element.qtip({ content: event.description, position: { target: 'mouse', adjust: { x: 5, y: 5}} });
// },
// eventLimit: true,
// editable: true,
// eventDrop: function(event, delta, revertFunc) {
// if(!confirm("<%= (translate 'save_question') %>")) {
// revertFunc();
// } else {
// var event_begin = event.start.format();
// var event_end = (event.end !== null ? event.end.format() : null);
// var allDay = event.allDay;
// $.get('<%= Setting.plugin_mega_calendar['sub_path'] %>calendar/change_' + event.controller_name, { id: event.id, event_begin: event_begin, event_end: event_end, allDay: allDay });
// }
// },
// eventResize: function(event, delta, revertFunc) {
// if(!confirm("<%= (translate 'save_question') %>")) {
// revertFunc();
// } else {
// $.get('<%= Setting.plugin_mega_calendar['sub_path'] %>calendar/change_' + event.controller_name, { id: event.id, event_begin: event.start.format(), event_end: event.end.format() });
// }
// },
// select: function(start, end) {
// $('#calendar').fullCalendar('unselect');
// window.open('<%= Setting.plugin_mega_calendar['sub_path'] %>issues/new?issue[start_date]='+start.format("YYYY-MM-DD")+'&issue[due_date]='+end.format("YYYY-MM-DD")+'&issue[time_begin]='+start.format("HH:mm")+'&issue[time_end]='+end.format("HH:mm"), '_blank');
// },
// });
});
</script>
4 changes: 2 additions & 2 deletions app/views/calendar/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
end
%>

<%= render :partial => 'calendar/megacalendar', :locals => {:show_view_buttons => true, :default_view => 'month', :use_values_from_session => true, :calendar_height => '700', :calendar_style => 'padding: 0px 100px;'} %>
<%= render :partial => 'calendar/megacalendar', :locals => {:show_view_buttons => true, :default_view => 'dayGridMonth', :use_values_from_session => true, :calendar_height => '700', :calendar_style => 'padding: 0px 100px;'} %>

<link rel='stylesheet' href='<%= Setting.plugin_mega_calendar['sub_path'] %>plugin_assets/mega_calendar/javascripts/datetimepicker/jquery.datetimepicker.css' />
<script src='<%= Setting.plugin_mega_calendar['sub_path'] %>plugin_assets/mega_calendar/javascripts/datetimepicker/build/jquery.datetimepicker.full.min.js'></script>
Expand Down Expand Up @@ -48,7 +48,7 @@
$("#inp_export_end").datetimepicker(options);
});
function show_time_range() {
$('#div_export_time_range').fadeIn();
$('#div_export_time_range').fadeIn();
}
function remove_time_range() {
$('#div_export_time_range').fadeOut();
Expand Down
2 changes: 1 addition & 1 deletion app/views/my/blocks/_megacalendar.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% if !Setting.plugin_mega_calendar['allowed_users'].blank? && Setting.plugin_mega_calendar['allowed_users'].include?(User.current.id.to_s) %>
<%= render :partial => 'calendar/megacalendar', :locals => {:show_view_buttons => false, :default_view => 'basicWeek', :use_values_from_session => false, :calendar_height => '300', :calendar_style => ''} %>
<%= render :partial => 'calendar/megacalendar', :locals => {:show_view_buttons => false, :default_view => 'timeGridWeek', :use_values_from_session => false, :calendar_height => '300', :calendar_style => ''} %>
<% else %>
<%= translate 'no_right' %>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Copyright (c) 2015 Adam Shaw
MIT License

Copyright (c) 2021 Adam Shaw

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
Loading

0 comments on commit 7c5d489

Please sign in to comment.