diff --git a/app/controllers/calendar_controller.rb b/app/controllers/calendar_controller.rb
index 8b956e4..278fe07 100644
--- a/app/controllers/calendar_controller.rb
+++ b/app/controllers/calendar_controller.rb
@@ -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 '
@@ -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
@@ -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])
diff --git a/app/views/calendar/_filter_panel.html.erb b/app/views/calendar/_filter_panel.html.erb
index 3a9408a..18586c8 100644
--- a/app/views/calendar/_filter_panel.html.erb
+++ b/app/views/calendar/_filter_panel.html.erb
@@ -21,7 +21,7 @@
<% 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])
@@ -38,7 +38,7 @@
<% end %>
- <%= translate 'button_apply' %> <%= translate 'button_reset' %>
+ <%= translate 'button_apply' %> <%= translate 'button_reset' %>
@@ -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 = {
@@ -97,7 +97,7 @@
});
$("#inp_filter_name").val(data["name"]);
$("#inp_filter_global").prop('checked', data["global"]);
- $('#calendar').fullCalendar( 'refetchEvents' );
+ calendar.refetchEvents();
});
}
diff --git a/app/views/calendar/_megacalendar.html.erb b/app/views/calendar/_megacalendar.html.erb
index 8eaa497..6a04e24 100644
--- a/app/views/calendar/_megacalendar.html.erb
+++ b/app/views/calendar/_megacalendar.html.erb
@@ -17,13 +17,9 @@
%>
plugin_assets/mega_calendar/stylesheets/mega_calendar.css' />
-plugin_assets/mega_calendar/javascripts/fullcalendar/fullcalendar.css' />
-plugin_assets/mega_calendar/javascripts/qtip2/jquery.qtip.min.css' />
-
-
-
-
-
+
+
+
<%= translate 'calendar' %>
<%= render :partial => 'calendar/filter_panel', :locals => {} %>
@@ -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');
+ // },
+ // });
});
diff --git a/app/views/calendar/index.html.erb b/app/views/calendar/index.html.erb
index f7783f3..2f271e7 100644
--- a/app/views/calendar/index.html.erb
+++ b/app/views/calendar/index.html.erb
@@ -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;'} %>
plugin_assets/mega_calendar/javascripts/datetimepicker/jquery.datetimepicker.css' />
@@ -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();
diff --git a/app/views/my/blocks/_megacalendar.html.erb b/app/views/my/blocks/_megacalendar.html.erb
index e038270..0a8ab74 100644
--- a/app/views/my/blocks/_megacalendar.html.erb
+++ b/app/views/my/blocks/_megacalendar.html.erb
@@ -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 %>
diff --git a/assets/javascripts/fullcalendar/license.txt b/assets/javascripts/fullcalendar-6.1.9/LICENSE.md
similarity index 96%
rename from assets/javascripts/fullcalendar/license.txt
rename to assets/javascripts/fullcalendar-6.1.9/LICENSE.md
index eafaf97..18ac667 100644
--- a/assets/javascripts/fullcalendar/license.txt
+++ b/assets/javascripts/fullcalendar-6.1.9/LICENSE.md
@@ -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
diff --git a/assets/javascripts/fullcalendar-6.1.9/README.md b/assets/javascripts/fullcalendar-6.1.9/README.md
new file mode 100644
index 0000000..8c95409
--- /dev/null
+++ b/assets/javascripts/fullcalendar-6.1.9/README.md
@@ -0,0 +1,74 @@
+
+# FullCalendar
+
+Full-sized drag & drop calendar in JavaScript
+
+- [Project Website](https://fullcalendar.io/)
+- [Documentation](https://fullcalendar.io/docs)
+- [Changelog](CHANGELOG.md)
+- [Support](https://fullcalendar.io/support)
+- [License](LICENSE.md)
+- [Roadmap](https://fullcalendar.io/roadmap)
+
+Connectors:
+
+- [React](https://github.com/fullcalendar/fullcalendar-react)
+- [Angular](https://github.com/fullcalendar/fullcalendar-angular)
+- [Vue 3](https://github.com/fullcalendar/fullcalendar-vue) |
+ [2](https://github.com/fullcalendar/fullcalendar-vue2)
+
+## Bundle
+
+The [FullCalendar Standard Bundle](bundle) is easier to install than individual plugins, though filesize will be larger. It works well with a CDN.
+
+## Installation
+
+Install the FullCalendar core package and any plugins you plan to use:
+
+```sh
+npm install @fullcalendar/core @fullcalendar/interaction @fullcalendar/daygrid
+```
+
+## Usage
+
+Instantiate a Calendar with plugins and options:
+
+```js
+import { Calendar } from '@fullcalendar/core'
+import interactionPlugin from '@fullcalendar/interaction'
+import dayGridPlugin from '@fullcalendar/daygrid'
+
+const calendarEl = document.getElementById('calendar')
+const calendar = new Calendar(calendarEl, {
+ plugins: [
+ interactionPlugin,
+ dayGridPlugin
+ ],
+ initialView: 'timeGridWeek',
+ editable: true,
+ events: [
+ { title: 'Meeting', start: new Date() }
+ ]
+})
+
+calendar.render()
+```
+
+## Development
+
+You must install this repo with [PNPM](https://pnpm.io/):
+
+```
+pnpm install
+```
+
+Available scripts (via `pnpm run
+
+
+
+
+
+
+
+
+ |