week view updates
This commit is contained in:
parent
98ef582e17
commit
79e0b8e383
|
@ -304,19 +304,74 @@ var calendarAPI = function(){
|
|||
}
|
||||
this.getEventsForWeek = function(week,year){
|
||||
$.getJSON("cals/getWeekEvents",{"week":week,"year":year},function(events){
|
||||
var height = 15;
|
||||
var full_day_count = 0;
|
||||
var rowcount = 7;
|
||||
var tr = $("<tr></tr>");
|
||||
var pre = true;
|
||||
$.each(events,function(i,evnt){
|
||||
// console.log("rowcount: "+rowcount);
|
||||
// console.log("start:"+evnt.start);
|
||||
console.log(rowcount);
|
||||
if(rowcount >= (7 - evnt.total_days)){
|
||||
if(tr.html()!=""){
|
||||
if(rowcount != 7){
|
||||
tr.append("<td colspan='"+(7-rowcount)+"'></td>");
|
||||
}
|
||||
$("table.all_day_event_holder").append(tr);
|
||||
}
|
||||
tr = null;
|
||||
tr = $('<tr></tr>');
|
||||
pre = true;
|
||||
}
|
||||
|
||||
if(evnt.all_day){
|
||||
$(".week_day_header[date="+evnt.start_date+"]").append('<div class="event half" link="'+evnt.show_link+'" style="background-color: '+evnt.color+';color:#fff;"><dl><dt>'+evnt.title+'</dt><dd></dd></dl></div>');
|
||||
full_day_count++;
|
||||
|
||||
var precountspan = 7 - evnt.total_days;
|
||||
if(pre){
|
||||
height+=20;
|
||||
$(".head_event_wrapper").height(height);
|
||||
$(".head_event_wrapper table").eq(0).height(height);
|
||||
tr.append('<td rowspan="1" style="width:60px;"> </td>');
|
||||
if(precountspan != 0){
|
||||
tr.append('<td colspan="'+precountspan+'"></td>');
|
||||
pre = false;
|
||||
}
|
||||
}
|
||||
var colcount = evnt.total_days;
|
||||
if(evnt.colcount != 0){
|
||||
colcount = evnt.colcount;
|
||||
}
|
||||
|
||||
rowcount = precountspan + colcount;
|
||||
if(evnt.title == "Yeah"){
|
||||
console.log("rowcount: "+rowcount);
|
||||
console.log("start:"+evnt.total_days);
|
||||
}
|
||||
|
||||
tr.append('<td colspan="'+colcount+'" class="all_day_event week_day" ><div class="event half" style="background-color: '+evnt.color+' ;color:#fff;" link="'+evnt.show_link+'"><dl><dt>'+evnt.title+'</dt><dd></dd></dl></div></td>');
|
||||
|
||||
// $(".week_day_header[date="+evnt.start_date+"]").append('<div class="event half" link="'+evnt.show_link+'" style="background-color: '+evnt.color+';color:#fff;"><dl><dt>'+evnt.title+'</dt><dd></dd></dl></div>');
|
||||
}else{
|
||||
|
||||
var starttime,endtime,displaystarttime,displayendtime;
|
||||
if(evnt.start_am_pm == "AM")
|
||||
if(evnt.start_am_pm == "AM"){
|
||||
starttime = evnt.start_time;
|
||||
else
|
||||
if(starttime == 12)
|
||||
starttime = 0;
|
||||
if(starttime == 12.5)
|
||||
starttime = 0.5;
|
||||
}else
|
||||
starttime = evnt.start_time + 12;
|
||||
|
||||
if(evnt.end_am_pm == "AM")
|
||||
if(evnt.end_am_pm == "AM"){
|
||||
endtime = evnt.end_time;
|
||||
else
|
||||
if(endtime == 12)
|
||||
endtime = 0;
|
||||
if(endtime == 12.5)
|
||||
endtime = 0.5;
|
||||
}else
|
||||
endtime = evnt.end_time + 12;
|
||||
|
||||
var temp = parseInt(evnt.start_time);
|
||||
|
@ -333,12 +388,27 @@ var calendarAPI = function(){
|
|||
else
|
||||
displayendtime = temp + ":00 " + evnt.end_am_pm;
|
||||
|
||||
var toppx = ((starttime * 2) * 19) + starttime;
|
||||
var eventdom = $('<div class="event" link="'+evnt.show_link+'" style="background-color: '+evnt.color+';color:#fff; top:'+toppx+'px;"><dl><dt>'+displaystarttime+' - '+displayendtime+'</dt><dd>'+evnt.title+'</dd></dl></div>');
|
||||
var toppx = ((starttime * 2) * 20) + 1;
|
||||
var h = endtime - starttime;
|
||||
var halfhour = "";
|
||||
if(h == 0.5)
|
||||
halfhour = "half";
|
||||
h = 17 + 20 + (((h-1) * 2) * 20) + 1;
|
||||
var eventdom = $('<div class="event '+halfhour+'" link="'+evnt.show_link+'" style="background-color: '+evnt.color+';color:#fff; top:'+toppx+'px; height:'+h+'px;"><dl><dt>'+displaystarttime+' - '+displayendtime+'</dt><dd>'+evnt.title+'</dd></dl></div>');
|
||||
$(".week_day_body[date="+evnt.start_date+"] .inner").append(eventdom);
|
||||
}
|
||||
if(full_day_count == 0){
|
||||
tr.append('<td rowspan="1" style="width:60px;">');
|
||||
$("table.all_day_event_holder").append(tr);
|
||||
}
|
||||
|
||||
})
|
||||
if(tr.html()!=""){
|
||||
if(rowcount != 7){
|
||||
tr.append("<td colspan='"+(7-rowcount)+"'></td>");
|
||||
}
|
||||
$("table.all_day_event_holder").append(tr);
|
||||
}
|
||||
})
|
||||
}
|
||||
this.loadDayView = function(){
|
||||
|
|
|
@ -111,26 +111,53 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController
|
|||
week = params[:week].to_i
|
||||
year = params[:year].to_i
|
||||
@d = getWeekDataSet(week,year)
|
||||
events = Event.where(:start_week.lte => week).and(:start_year => year).and(:end_week.gte => week).and(:start_year => year)
|
||||
events = Event.where(:start_week.lte => week).and(:start_year => year).and(:end_week.gte => week).and(:start_year => year).asc(:start_week).asc(:start_date)
|
||||
@events = Array.new
|
||||
events.each_with_index do |event,i|
|
||||
# @temp = Array.new
|
||||
no_of_days = event.total_days
|
||||
days = event.total_days.to_i + 1
|
||||
colcount = 0
|
||||
startdt = event.start_date
|
||||
if event.start_week < week
|
||||
startdt = @d[0].to_i
|
||||
event.all_day = true
|
||||
end
|
||||
|
||||
no_of_days = no_of_days.to_i
|
||||
no_of_days += 1
|
||||
all_day = event.all_day
|
||||
if no_of_days > 1
|
||||
|
||||
if days > 1
|
||||
all_day = true
|
||||
end
|
||||
|
||||
if event.end_week > week && event.start_week < week
|
||||
days = 7
|
||||
end
|
||||
|
||||
if event.end_week == week
|
||||
days = @d.index(event.end_date.to_s).to_i
|
||||
end
|
||||
|
||||
if event.start_week == week
|
||||
days = 7 - @d.index(event.start_date.to_s).to_i
|
||||
end
|
||||
|
||||
|
||||
if event.start_week == week && event.end_week == week
|
||||
x = @d.index(event.end_date.to_s).to_i
|
||||
y = @d.index(event.start_date.to_s).to_i
|
||||
colcount = x - y
|
||||
colcount+=1
|
||||
|
||||
end
|
||||
|
||||
if event.start_week < week
|
||||
startdt = @d[0].to_i
|
||||
event.all_day = true
|
||||
if event.end_week == week
|
||||
colcount = 7 - @d.index(event.end_date.to_s).to_i
|
||||
days = 7;
|
||||
startdt = event.start_date
|
||||
end
|
||||
end
|
||||
|
||||
color = Cal.find(event.cal_id).color
|
||||
@events << {"id"=>event.id,"index"=>i,"start_date"=>startdt,"all_day"=>all_day, "start_week" => event.start_week, "end_week" => event.end_week, "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event),"start_time"=>event.start_time,"end_time"=>event.end_time,"start_am_pm"=>event.start_am_pm,"end_am_pm"=>event.end_am_pm}
|
||||
@events << {"id"=>event.id,"index"=>i,"start_date"=>startdt,"end_date"=>event.end_date ,"all_day"=>all_day, "start_week" => event.start_week, "end_week" => event.end_week, "total_days" => days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event),"start_time"=>event.start_time,"end_time"=>event.end_time,"start_am_pm"=>event.start_am_pm,"end_am_pm"=>event.end_am_pm,"colcount"=>colcount}
|
||||
end
|
||||
render :json => @events.to_json
|
||||
end
|
||||
|
|
|
@ -3,12 +3,20 @@
|
|||
<table class="table header">
|
||||
<tr>
|
||||
<th style="width: 44px;"></th>
|
||||
<% @dates.each do |day| %>
|
||||
<% @dates.each_with_index do |day,i| %>
|
||||
<% if @today == i %>
|
||||
<th class='today'><%= day %></th>
|
||||
<% else %>
|
||||
<th><%= day %></th>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 0; background: none;"></td>
|
||||
<td colspan="8" style="border:0;">
|
||||
<div class="event_list_wrapper head_event_wrapper" style="height:50px;">
|
||||
<table style="position: absolute; width: 100%; height: 50px; top: 0;">
|
||||
<tr>
|
||||
<td style="border: 0; background: none; width: 60px;"></td>
|
||||
<% @d.each_with_index do |dt,i| %>
|
||||
<% if @today == i %>
|
||||
<td class="all_day_event week_day week_day_header today" date='<%= dt %>'></td>
|
||||
|
@ -16,6 +24,14 @@
|
|||
<td class="all_day_event week_day week_day_header" date='<%= dt %>'></td>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="all_day_event_holder">
|
||||
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
<!-- <div class="event half" style="background-color: #ccffee;">
|
||||
<dl>
|
||||
<dt>10:30am - template</dt>
|
||||
|
|
Reference in New Issue