This commit is contained in:
BoHung Chiu 2022-11-24 23:15:17 +08:00
parent 014f114574
commit d95998c70b
2 changed files with 16 additions and 10 deletions

View File

@ -341,6 +341,11 @@ var Calendar = function(dom){
c.success_event = success_event; c.success_event = success_event;
var dview = (c.currentView == "agenda" ? "dayGridMonth" : c.currentView); var dview = (c.currentView == "agenda" ? "dayGridMonth" : c.currentView);
c.calendar_dom.css("overflow","visible"); c.calendar_dom.css("overflow","visible");
// try{
// c.source_url = window.location.href.replace(/.(?=\?|$)/, function(f){return f + '.json'});
// }catch(e){
// c.source_url = window.location.origin + window.location.pathname + '.json' + window.location.search;
// }
c.calendar_dom.fullCalendar({ c.calendar_dom.fullCalendar({
themeSystem: 'bootstrap', themeSystem: 'bootstrap',
editable: false, editable: false,
@ -584,8 +589,8 @@ var Calendar = function(dom){
} }
this.get_single_event = function(id, callback){ this.get_single_event = function(id, callback){
var activeRange = c.calendar_dom.calendar.currentData.dateProfile.activeRange; var activeRange = c.calendar_dom.calendar.currentData.dateProfile.activeRange;
var start = activeRange.start, var start = correct_date(activeRange.start),
end = activeRange.end; end = correct_date(activeRange.end);
$.get("/admin/calendars/get_single_event", { $.get("/admin/calendars/get_single_event", {
start: Math.round(start.getTime() / 1000), start: Math.round(start.getTime() / 1000),
end: Math.round(end.getTime() / 1000), end: Math.round(end.getTime() / 1000),
@ -597,13 +602,14 @@ var Calendar = function(dom){
}) })
} }
this.renderEvent = function(eventStick){ this.renderEvent = function(eventStick){
var event_source = this.calendar_dom.calendar.getEventSources()[0];
if(eventStick.recurring === true){ if(eventStick.recurring === true){
this.get_single_event(eventStick.id, function(eventData){ this.get_single_event(eventStick.id, function(eventData){
eventData = c.eventDataTransform(eventData); eventData = c.eventDataTransform(eventData);
c.calendar_dom.calendar.addEvent(eventData); c.calendar_dom.calendar.addEvent(eventData, event_source);
}); });
}else{ }else{
c.calendar_dom.calendar.addEvent(eventStick); c.calendar_dom.calendar.addEvent(eventStick, event_source);
} }
}; };
this.updateEvent = function(eventStick){ this.updateEvent = function(eventStick){

View File

@ -256,19 +256,18 @@ class Event
tmp_hide_start = re.hide_start.clone tmp_hide_start = re.hide_start.clone
if is_month if is_month
add_interval = ((start_date.year * 12 + start_date.month) - (@start_date.year * 12 + @start_date.month)) add_interval = ((start_date.year * 12 + start_date.month) - (@start_date.year * 12 + @start_date.month))
add_interval = 0 if add_interval < 0
elsif is_year elsif is_year
add_interval = (start_date.year - @start_date.year) add_interval = (start_date.year - @start_date.year)
add_interval = 0 if add_interval < 0
else else
add_interval = (start_date_utc_mjd - @start_date.new_offset(0).mjd) add_interval = (start_date_utc_mjd - @start_date.new_offset(0).mjd)
if add_interval < 0 if add_interval < 0
add_interval = -(-add_interval / days) add_interval = 0
else else
add_interval = add_interval / days add_interval = add_interval / days
end end
end end
if add_interval < 0
add_interval = add_interval % freq
end
rest = add_interval % freq rest = add_interval % freq
if rest != 0 if rest != 0
add_interval += (freq - rest) add_interval += (freq - rest)
@ -316,13 +315,14 @@ class Event
next next
end end
if new_start != org_start if new_start != org_start
new_end = @end_date + w.day
hide = need_check_hide && tmp_hide_start2.include?(new_start.strftime("%Y-%m-%d")) hide = need_check_hide && tmp_hide_start2.include?(new_start.strftime("%Y-%m-%d"))
if hide if hide
if preserve_hide if preserve_hide
@recurring << data.merge({:start => new_start.to_json.gsub('"',''), :end => (@end_date + w.day).to_json.gsub('"',''), :hide=>true, :color=>"#c0c0c0"}) @recurring << data.merge({:start => new_start.to_json.gsub('"',''), :end => new_end.to_json.gsub('"',''), :hide=>true, :color=>"#c0c0c0"})
end end
else else
@recurring << data.merge({:start => new_start.to_json.gsub('"',''), :end => (@end_date + w.day).to_json.gsub('"',''), :hide=>false, :color => data[:org_color]}) @recurring << data.merge({:start => new_start.to_json.gsub('"',''), :end => new_end.to_json.gsub('"',''), :hide=>false, :color => data[:org_color]})
end end
end end
end end