- <%= f.label :login ,t("admin.user_new_interface.email")%>
- <%= f.text_field :login, :placeholder => t("admin.user_new_interface.email"), :style => "width: 330px;" %>
+ <%= f.label :email ,t("admin.user_new_interface.email")%>
+ <%= f.text_field :email, :placeholder => t("admin.user_new_interface.email"), :style => "width: 330px;" %>
Please correct the error
diff --git a/app/views/shared/_address_modal_dialog.html.erb b/app/views/shared/_address_modal_dialog.html.erb
new file mode 100644
index 00000000..6e241074
--- /dev/null
+++ b/app/views/shared/_address_modal_dialog.html.erb
@@ -0,0 +1,13 @@
+
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 525d6808..88a39f42 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -58,6 +58,8 @@ Orbit::Application.routes.draw do
end
member do
post 'edit_file' => 'designs#edit_file'
+ post 'update_file' => 'designs#update_file'
+ post 'upload_image' => 'designs#upload_image'
end
end
resources :infos do
diff --git a/lib/parsers/parser_layout.rb b/lib/parsers/parser_layout.rb
index 3379c487..817bf327 100644
--- a/lib/parsers/parser_layout.rb
+++ b/lib/parsers/parser_layout.rb
@@ -22,7 +22,7 @@ module ParserLayout
body.css('.page_image').each do |page_image|
image = design.images.where( file: File.basename(page_image['src']))[0]
- image.update_attributes(:name => File.basename(page_image['src']), :html_id => page_image['id'], :html_class => page_image['class']) if image
+ image.update_attributes(:html_id => page_image['id'], :html_class => page_image['class'], :in_html => true) if image
end
end
diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake
index 70776ed9..60a7ec93 100644
--- a/lib/tasks/dev.rake
+++ b/lib/tasks/dev.rake
@@ -71,7 +71,7 @@ namespace :dev do
design = Design.new(:title => "Fraisier", :author => "Paul", :intro => "Strawberry cake")
- design.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
+ design.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
# image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif"))
#
@@ -89,7 +89,7 @@ namespace :dev do
design_1 = Design.new(:title => "Bob", :author => "Me", :intro => "Moran")
- design_1.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
+ design_1.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
# image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif"))
#
diff --git a/lib/tasks/pages.rake b/lib/tasks/pages.rake
index 8a43f420..598d4b53 100644
--- a/lib/tasks/pages.rake
+++ b/lib/tasks/pages.rake
@@ -13,7 +13,7 @@ namespace :pages do
design = Design.new(:title => "Fraisier", :author => "Paul", :intro => "Strawberry cake")
- design.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
+ design.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
# image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif"))
#
@@ -37,7 +37,7 @@ namespace :pages do
design_1 = Design.new(:title => "Bob", :author => "Me", :intro => "Moran")
- design_1.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
+ design_1.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
# image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif"))
#
diff --git a/spec/models/attribute_field_spec.rb b/spec/models/attribute_field_spec.rb
new file mode 100644
index 00000000..6fb01ba8
--- /dev/null
+++ b/spec/models/attribute_field_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+describe AttributeField do
+ describe "#list field" do
+ context "when field is in type text_field(without add more)" do
+ before(:each) do
+ @attribute_field = AttributeField.new(:key=>'test',:markup=>"text_field")
+
+
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/spec/models/attribute_value_spec.rb b/spec/models/attribute_value_spec.rb
new file mode 100644
index 00000000..9488121e
--- /dev/null
+++ b/spec/models/attribute_value_spec.rb
@@ -0,0 +1,63 @@
+#encoding: UTF-8
+require 'spec_helper'
+
+describe AttributeValue do
+ describe "#attribute_value" do
+ context "Data should be able to input and out put as aspect"
+
+ before(:each) do
+ @af = AttributeField.find '5052cf9f2b5c49a742000005'
+ @user = User.where(email:'chris@rulingcom.com').first
+ @av = AttributeValue.last
+ end #end before
+
+
+ [true,false].each do |locale_sat|
+ LIST[:markups].each do |markup|
+ @av = nil
+ it "[#{markup[0]}]Input: should save data at right way when local is set to #{locale_sat}" do
+ @af.markup = markup[0]
+ @av = nil
+ @input_value = assume_result = case markup[0]
+ when 'text_field','text_area'
+ (locale_sat ? {"en"=> "lalala","zh_tw"=>"拉拉拉"} : "hahaha")
+ when 'select','radio_button'
+ "1"
+ when 'date'
+ {"(1i)"=>Date.today.year.to_s,"(2i)"=>Date.today.month.to_s,"(3i)"=>Date.today.day.to_s}
+ when 'checkbox'
+ {"1"=>"true", "3"=>"true"}
+ end #end of case
+ assume_result = ["1","3"] if markup[0] == 'checkbox'
+ @af.locale = locale_sat
+ @af.save
+ @data_hash = {"attribute_field_id" => @af.id,"value" => @input_value}
+ @av = @user.attribute_values.build(@data_hash)
+ @av.save
+ @av.value.should == assume_result
+ # @av.destroy
+ end
+
+ it "[#{markup[0]}]Output(just for show): should output data at right way when local is set to #{locale_sat}" do
+ locale = I18n.locale
+ assume_result = case markup[0]
+ when 'text_area'
+ (locale_sat ? "拉拉拉" : "hahaha")
+ when 'text_field'
+ (locale_sat ? "拉拉拉" : "hahaha")
+ when 'select','radio_button'
+ (locale_sat ? "男性" : "男性")
+ when 'date'
+ Date.today
+ when 'checkbox'
+ (locale_sat ? "男性,不公開" : "男性,不公開")
+ end #end of case
+
+ @av.get_value_by_locale(locale).should == assume_result
+ end
+
+ end #end of LIST loop
+ end
+
+ end
+end
\ No newline at end of file
diff --git a/vendor/built_in_modules/calendar/app/assets/javascripts/calendarAPI.js.erb b/vendor/built_in_modules/calendar/app/assets/javascripts/calendarAPI.js.erb
index 64eb8f8a..d023a0fa 100644
--- a/vendor/built_in_modules/calendar/app/assets/javascripts/calendarAPI.js.erb
+++ b/vendor/built_in_modules/calendar/app/assets/javascripts/calendarAPI.js.erb
@@ -27,6 +27,13 @@ Date.prototype.getWeek = function (dowOffset) {
return weeknum;
};
+Date.prototype.daysInMonth = function(){
+ var daysArray = [31,28,31,30,31,30,31,31,30,31,30,31];
+ if(this.getFullYear()%4 == 0)
+ daysArray[1] = 29;
+
+ return daysArray[this.getMonth()];
+}
var calendarAPI = function(){
c = this;
@@ -36,17 +43,20 @@ var calendarAPI = function(){
this.cur_month = c.today.getMonth()+1;
this.cur_year = c.today.getFullYear();
this.cur_week = c.today.getWeek();
+ this.cur_date = c.today.getDate();
this.view = null;
this.monthlist = ["","January","February","March","April","May","June","July","August","September","October","November","December"];
this.initialize = function(){
$(window).load(function(){
// c.loadMonthView(c.cur_month,c.cur_year);
- c.loadWeekView(c.cur_week,c.cur_year);
+ // c.loadWeekView(c.cur_week,c.cur_year);
+ c.loadDayView(c.cur_date,c.cur_month,c.cur_year);
bindHandlers();
})
var bindHandlers = function(){
- $(".event").live("click",function(){
- c.displayEvent($(this));
+ $(".event").live("click",function(e){
+ var pos = {"x":e.clientX,"y":e.clientY};
+ c.displayEvent($(this),pos);
})
$("#create_event_btn").click(function(){
@@ -73,7 +83,7 @@ var calendarAPI = function(){
c.loadWeekView(c.cur_week,c.cur_year);
break;
case 'day':
- c.loadDayView();
+ c.loadDayView(c.cur_date,c.cur_month,c.cur_year);
break;
case 'agenda':
c.loadAgendaView();
@@ -104,6 +114,22 @@ var calendarAPI = function(){
}
c.loadWeekView(w,y);
break;
+ case "day":
+ var d,w,y;
+ d = c.cur_date - 1;
+ m = c.cur_month;
+ y = c.cur_year;
+ if(d == 0){
+ var dx = new Date(c.cur_year,c.cur_month-2);
+ d = dx.daysInMonth();
+ m--;
+ }
+ if(m == 0){
+ m = 12;
+ y = y - 1;
+ }
+ c.loadDayView(d,m,y);
+ break;
}
})
@@ -132,10 +158,40 @@ var calendarAPI = function(){
}
c.loadWeekView(w,y);
break;
+ case "day":
+ var d,w,y;
+ var dx = new Date(c.cur_year,c.cur_month-1);
+ if(c.cur_date == dx.daysInMonth()){
+ d = 1;
+ m = c.cur_month + 1;
+ }else{
+ d = c.cur_date + 1;
+ m = c.cur_month;
+ }
+
+ if(m == 13){
+ m = 1;
+ y = c.cur_year + 1;
+ }else{
+ y = c.cur_year;
+ }
+
+ c.loadDayView(d,m,y);
+ break;
}
})
$("button#today_btn").click(function(){
- c.loadMonthView();
+ switch (c.view){
+ case "week":
+ c.loadWeekView();
+ break;
+ case "month":
+ c.loadMonthView();
+ break;
+ case "day":
+ c.loadDayView();
+ break;
+ }
})
}
}
@@ -156,7 +212,7 @@ var calendarAPI = function(){
if($('#calendar_month').length > 0){
var $c_table = $('#calendar_month');
var sum_h = 0;
- var context_h = $('#main-sidebar').outerHeight();
+ var context_h = $(window).height() - $('#orbit-bar').height();
$('#main-wrap > *').not('#orbit_calendar, .modal').each(function(){
sum_h += $(this).outerHeight();
});
@@ -215,6 +271,8 @@ var calendarAPI = function(){
var recordcurdate = true;
if(allow){
+ if(evnt.title=="Navratri")
+ console.log(pos);
if(pos == 1){
var colspan = 0;
if(evnt.total_days>7){
@@ -231,13 +289,13 @@ var calendarAPI = function(){
$eventrow.html('
'+evnt.title+' | ');
}else{
if($eventrow.html()==""){
- $eventrow.append('
');
+ $eventrow.append(' | | ');
}else{
if((lastno+1)!=thisno){
var inposition = parseInt($eventrow.find("td.main_td:last").attr("pos"));
var curcolspan = $eventrow.find("td.main_td:last").attr("colspan");
var colspan = pos - (inposition+parseInt(curcolspan));
- $eventrow.append('
');
+ $eventrow.append(' | | ');
}
}
var colspan = 0;
@@ -297,16 +355,182 @@ 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 = $("
|
");
+ var pre = true;
+ $.each(events,function(i,evnt){
+ // console.log("rowcount: "+rowcount);
+ // console.log("start:"+evnt.start);
+ if(rowcount >= (7 - evnt.total_days)){
+ if(tr.html()!=""){
+ if(rowcount != 7){
+ tr.append("
| ");
+ }
+ $("table.all_day_event_holder").append(tr);
+ }
+ tr = null;
+ tr = $('
|
');
+ pre = true;
+ }
+
+ if(evnt.all_day){
+ 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('
| ');
+ if(precountspan != 0){
+ tr.append('
| ');
+ pre = false;
+ }
+ }
+ var colcount = evnt.total_days;
+ if(evnt.colcount != 0){
+ colcount = evnt.colcount;
+ }
+
+ rowcount = precountspan + colcount;
+
+ tr.append('
| ');
+
+ // $(".week_day_header[date="+evnt.start_date+"]").append('
');
+ }else{
+
+ var starttime,endtime,displaystarttime,displayendtime;
+ if(evnt.start_am_pm == "AM"){
+ starttime = evnt.start_time;
+ if(starttime == 12)
+ starttime = 0;
+ if(starttime == 12.5)
+ starttime = 0.5;
+ }else
+ starttime = evnt.start_time + 12;
+
+ if(evnt.end_am_pm == "AM"){
+ endtime = evnt.end_time;
+ if(endtime == 12)
+ endtime = 0;
+ if(endtime == 12.5)
+ endtime = 0.5;
+ }else
+ endtime = evnt.end_time + 12;
+
+ var temp = parseInt(evnt.start_time);
+
+ if (evnt.start_time > temp)
+ displaystarttime = temp + ":30 " + evnt.start_am_pm;
+ else
+ displaystarttime = temp + ":00 " + evnt.start_am_pm;
+
+ temp = parseInt(evnt.end_time);
+
+ if (evnt.end_time > temp)
+ displayendtime = temp + ":30 " + evnt.end_am_pm;
+ else
+ displayendtime = temp + ":00 " + evnt.end_am_pm;
+
+ 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 = $('
- '+displaystarttime+' - '+displayendtime+'
- '+evnt.title+'
');
+ $(".week_day_body[date="+evnt.start_date+"] .inner").append(eventdom);
+ }
+ if(full_day_count == 0){
+ tr.append('
');
+ $("table.all_day_event_holder").append(tr);
+ }
+
+ })
+ if(tr.html()!=""){
+ if(rowcount != 7){
+ tr.append(" | | ");
+ }
+ $("table.all_day_event_holder").append(tr);
+ }
})
}
- this.loadDayView = function(){
- $('#view_holder').load("cals/day_view", function() {
- $('.current_day_title').text('September 2, 2012');
+ this.loadDayView = function(day,month,year){
+ c.view = "day";
+ if(!day){
+ var dt = new Date();
+ week = dt.getWeek();
+ year = dt.getFullYear();
+ day = dt.getDate();
+ month = dt.getMonth()+1;
+ }
+
+ c.cur_date = day;
+ c.cur_month = month;
+ c.cur_year = year;
+
+ $('#view_holder').load("cals/day_view?date="+day+"&month="+month+"&year="+year, function() {
+ $('.current_day_title').text($("#day_header").text());
+ c.getEventsForDay(day,month,year);
+ })
+ }
+ this.getEventsForDay = function(day,month,year){
+ $.getJSON("cals/getDayEvents",{"date":day,"month":month,"year":year},function(events){
+ $.each(events,function(i,evnt){
+ if(evnt.all_day){
+ $(".all_day_event").append('
'+evnt.title+'
')
+ }else{
+ var starttime,endtime,displaystarttime,displayendtime;
+ if(evnt.start_am_pm == "AM"){
+ starttime = evnt.start_time;
+ if(starttime == 12)
+ starttime = 0;
+ if(starttime == 12.5)
+ starttime = 0.5;
+ }else
+ starttime = evnt.start_time + 12;
+
+ if(evnt.end_am_pm == "AM"){
+ endtime = evnt.end_time;
+ if(endtime == 12)
+ endtime = 0;
+ if(endtime == 12.5)
+ endtime = 0.5;
+ }else
+ endtime = evnt.end_time + 12;
+
+ var temp = parseInt(evnt.start_time);
+
+ if (evnt.start_time > temp)
+ displaystarttime = temp + ":30 " + evnt.start_am_pm;
+ else
+ displaystarttime = temp + ":00 " + evnt.start_am_pm;
+
+ temp = parseInt(evnt.end_time);
+
+ if (evnt.end_time > temp)
+ displayendtime = temp + ":30 " + evnt.end_am_pm;
+ else
+ displayendtime = temp + ":00 " + evnt.end_am_pm;
+
+ 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 = $('
- '+displaystarttime+' - '+displayendtime+'
- '+evnt.title+'
');
+ $(".event_holder").append(eventdom);
+ }
+
+ })
+
})
}
this.loadAgendaView = function(){
- $('#view_holder').load("cals/week_view", function() {
+ $('#view_holder').load("cals/agenda_view", function() {
$('.current_day_title').text('September 2, 2012');
})
}
@@ -338,11 +562,27 @@ var calendarAPI = function(){
var domfor = $(this).attr("data-content");
$("tr[for="+domfor+"]").remove();
})
+ $(".btn-edit-a").live("ajax:success",function(evt,form){
+ $("#edit_area_" + $(this).attr("for")).html(form).slideDown();
+ $("#edit_area_" + $(this).attr("for")).find(".color-picker").miniColors();
+ })
+ $(".bt-cancel").live("click",function(){
+ $("#edit_area_" + $(this).attr("for")).html("").slideUp();
+ })
}
- this.displayEvent = function(dom){
+ this.displayEvent = function(dom,pos){
var url = dom.attr("link");
c.event_quick_view_div.load(url,function(){
- c.event_quick_view_div.show()
+ var x = pos.x;
+ var y = pos.y;
+ var winheight = $(window).height()
+ if((x+c.event_quick_view_div.width()) > $(window).width()){
+ x = x - c.event_quick_view_div.width();
+ }
+ if((y+c.event_quick_view_div.height()) > winheight){
+ y = y - c.event_quick_view_div.height();
+ }
+ c.event_quick_view_div.css({"left":x+"px","top":y+"px"}).show()
c.event_quick_view_div.find(".event-close-btn").click(function(){
c.event_quick_view_div.empty().hide();
})
diff --git a/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css b/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css
index 85b0390f..874904a5 100644
--- a/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css
+++ b/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css
@@ -32,22 +32,26 @@
border-radius: 3px;
cursor: pointer;
padding: 1px 3px;
+ font-weight: bold;
box-shadow: inset 0 0 1px black;
-webkit-box-shadow: inset 0 0 1px black;
-moz-box-shadow: inset 0 0 1px black;
}
+.event_list_wrapper {
+ position: relative;
+}
.event_list .cell {
- height: 38px;
+ height: 39px;
border: solid 1px #ddd;
border-top: 0;
}
.event_list .divide {
- height: 18px;
+ height: 19px;
margin-bottom: 18px;
border-bottom: solid 1px #eee;
}
.event_list .day_time {
- height: 30px;
+ height: 31px;
border-bottom: solid 1px #ddd;
border-left: solid 1px #ddd;
text-align: right;
@@ -189,7 +193,7 @@
}
#calendar_day .all_day_event {
background: #eee;
- border: solid 1px #ddd
+ border: solid 1px #ddd;
}
#calendar_day .event_list .table {
border-top: solid 1px #ddd;
@@ -223,14 +227,14 @@
}
#calendar_week .header td {
border: solid 1px #ddd;
- background-color: #eee;
+ /*background-color: #eee;*/
}
#calendar_week .week_day {
padding: 0 2px;
border: solid 1px #ddd;
}
#calendar_week .header .week_day {
- padding: 1px 2px 10px 2px;
+ padding: 2px 4px 0px 2px;
}
#calendar_week .event_list .event {
position: absolute;
@@ -250,7 +254,18 @@
#calendar_week .event_holder .inner {
margin: 0 8px 0 0;
}
-
+#calendar_week .all_day_event_holder {
+ position: relative;
+ width: 100%;
+ table-layout: fixed;
+}
+#calendar_week .all_day_event_holder td {
+ border: 0;
+ background-color: transparent;
+}
+#calendar_week .all_day_event {
+ background: #eee;
+}
diff --git a/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/cals_controller.rb b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/cals_controller.rb
index 2c171895..fdf712aa 100644
--- a/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/cals_controller.rb
+++ b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/cals_controller.rb
@@ -11,6 +11,19 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController
@calendars = Cal.all
end
+ def edit
+ @calendar = Cal.find(params[:id])
+ render :layout=>false
+ end
+
+ def update
+ @calendar = Cal.find(params[:id])
+ @calendar.update_attributes(params[:cal])
+ respond_to do |h|
+ h.js
+ end
+ end
+
def create
@calendar = Cal.new(params[:cal])
@calendar.save!
@@ -26,14 +39,30 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController
end
def day_view
- render :layout => false
+ date = params[:date].to_i
+ month = params[:month].to_i
+ year = params[:year].to_i
+ @cur_day = getDayName(date,month,year) + " " + month.to_s + "/" + date.to_s + " - " + year.to_s
+ @hours = getHours(12)
+ render :layout => false
end
def week_view
- week = params[:week]
- year = params[:year]
+ week = params[:week].to_i
+ year = params[:year].to_i
@dates = week_dates(week,year)
@range = week_range(week,year)
+ @d = getWeekDataSet(week,year)
+ t = Time.now
+ dt = Date.new(t.year,t.month,t.day)
+ today_cur_week = dt.strftime("%U").to_i
+
+ if week == today_cur_week && t.year == year
+ @today = @d.index(t.day.to_s)
+ else
+ @today = 20
+ end
+ @hours = getHours(12)
render :layout => false
end
@@ -59,48 +88,172 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController
end
def get_month_events
- month = params[:month]
- year = params[:year]
- month = month.to_i
- year = year.to_i
- events = Event.where(:start_month.lt => month).and(:start_year => year).and(:end_month.gte => month).asc(:start_date).desc(:total_days)
+ month = params[:month].to_i
+ year = params[:year].to_i
+
+ # events = Event.where(:start_month.lt => month).and(:start_year => year).and(:end_month.gte => month).asc(:start_date).desc(:total_days)
@events = Array.new
no_of_days_in_month = getMonthDays(year)
- events.each_with_index do |event,i|
- no_of_days = event.total_days
+ # events.each_with_index do |event,i|
+ # no_of_days = event.total_days
- if event.end_month > month
- no_of_days = no_of_days_in_month[month]
- elsif event.end_month == month
- no_of_days = event.end_date
- end
+ # if event.end_month > month
+ # no_of_days = no_of_days_in_month[month]
+ # elsif event.end_month == month
+ # no_of_days = event.end_date
+ # end
- no_of_days = no_of_days.to_i
+ # no_of_days = no_of_days.to_i
- color = Cal.find(event.cal_id).color
- @events << {"id"=>event.id,"index"=>i,"start_date"=>"1", "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event)}
- end
- events = Event.where(:start_month => month).and(:start_year => year).asc(:start_date).desc(:total_days)
+ # color = Cal.find(event.cal_id).color
+ # @events << {"id"=>event.id,"index"=>i,"start_date"=>"1", "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event)}
+ # end
+ # events = Event.where(:start_month => month).and(:start_year => year).asc(:start_date).desc(:total_days)
+ # events.each_with_index do |event,i|
+ # # @temp = Array.new
+ # no_of_days = event.total_days
+ # if event.end_month > month
+ # no_of_days = no_of_days_in_month[month] - event.start_date
+ # end
+ # no_of_days = no_of_days.to_i
+ # no_of_days += 1
+
+ # color = Cal.find(event.cal_id).color
+ # @events << {"id"=>event.id,"index"=>i,"start_date"=>event.start_date, "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event)}
+ # end
+ events = Event.all.asc(:start_date).desc(:total_days)
events.each_with_index do |event,i|
# @temp = Array.new
- no_of_days = event.total_days
- if event.end_month > month
- no_of_days = no_of_days_in_month[month] - event.start_date
- end
- no_of_days = no_of_days.to_i
- no_of_days += 1
- color = Cal.find(event.cal_id).color
- @events << {"id"=>event.id,"index"=>i,"start_date"=>event.start_date, "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event)}
+ startdt = Date.new(event.start_year,event.start_month)
+ enddt = Date.new(event.end_year,event.end_month)
+ range = startdt..enddt
+
+ dt = Date.new(year,month)
+ if range === dt
+ no_of_days = event.total_days
+ start_date = event.start_date
+
+ if event.start_year < year
+ no_of_days = no_of_days_in_month[month] - event.start_date
+ no_of_days += 1
+ temp = month + 12
+ if event.start_month < temp
+ start_date = 1
+ end
+ end
+ if event.end_year > year
+ no_of_days = no_of_days_in_month[month] - event.start_date
+ no_of_days += 1
+ temp = month + 12
+ end
+ if event.end_month > month
+ no_of_days = no_of_days_in_month[month] - event.start_date
+ no_of_days += 1
+ elsif event.end_month == month
+ no_of_days = event.end_date
+ end
+
+ if event.start_month == month && event.end_month == month
+ no_of_days = event.total_days
+ no_of_days += 1
+ end
+
+ if event.start_month < month
+ start_date = 1
+ end
+
+ color = Cal.find(event.cal_id).color
+ @events << {"start_year"=>event.start_year, "id"=>event.id,"index"=>i,"start_date"=>start_date, "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event)}
+ end
+
end
render :json => @events.to_json
end
def get_week_events
- week = params[:week]
- year = params[:year]
- events = Event.where(:start_week => week).and(:start_year => year)
- render :json => events.to_json
+ 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).asc(:start_week).asc(:start_date)
+ @events = Array.new
+ events.each_with_index do |event,i|
+ # @temp = Array.new
+ days = event.total_days.to_i + 1
+ colcount = 0
+ startdt = event.start_date
+
+ all_day = event.all_day
+
+ 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,"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
+
+ def get_day_events
+ day = params[:date].to_i
+ month = params[:month].to_i
+ year = params[:year].to_i
+ dt = Date.new(year,month,day)
+ week = dt.strftime("%U")
+ events = Event.where(:start_month.lte => month).and(:start_year => year).and(:end_month.gte => month)
+ @events = Array.new
+ events.each_with_index do |event,i|
+ days = event.total_days.to_i + 1
+ colcount = 0
+
+ all_day = event.all_day
+
+ if days > 1
+ all_day = true
+ end
+ startdt = Date.new(event.start_year,event.start_month,event.start_date)
+ enddt = Date.new(event.end_year,event.end_month,event.end_date)
+
+ range = startdt..enddt
+
+ if range === dt
+ color = Cal.find(event.cal_id).color
+ @events << {"id"=>event.id,"index"=>i,"start_date"=>event.start_date,"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}
+ end
+ end
+ render :json => @events.to_json
end
def week_number_test
diff --git a/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/events_controller.rb b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/events_controller.rb
index 519d84f4..41ffa151 100644
--- a/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/events_controller.rb
+++ b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/events_controller.rb
@@ -42,6 +42,13 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController
# if end_am_pm == "PM"
# temp_end_time = $endtime + 12
# end
+ if params[:all_day]
+ all_day = true
+ $starttime = 0
+ $endtime = 0
+ else
+ all_day = false
+ end
final_start_time = Date.new(start_year.to_i,start_month.to_i,start_date.to_i)
final_end_time = Date.new(end_year.to_i,end_month.to_i,end_date.to_i)
@@ -67,6 +74,7 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController
@event.total_days = total_days
@event.start_week = start_week
@event.end_week = end_week
+ @event.all_day = all_day
@event.save!
respond_to do |h|
@@ -81,6 +89,12 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController
@end_day_name = getDayName(@event.end_date,@event.end_month,@event.end_year)
render :layout=>false
end
+
+ def destroy
+ event = Event.find(params[:id])
+ event.delete
+ render :json => {"success"=>"true"}.to_json
+ end
end
diff --git a/vendor/built_in_modules/calendar/app/helpers/panel/calendar/back_end/cals_helper.rb b/vendor/built_in_modules/calendar/app/helpers/panel/calendar/back_end/cals_helper.rb
index 8b4d61d8..fc349ecd 100644
--- a/vendor/built_in_modules/calendar/app/helpers/panel/calendar/back_end/cals_helper.rb
+++ b/vendor/built_in_modules/calendar/app/helpers/panel/calendar/back_end/cals_helper.rb
@@ -131,6 +131,55 @@ module Panel::Calendar::BackEnd::CalsHelper
end
range
end
+
+ def getWeekDataSet(week_num,year)
+ year = year.to_i
+ week_num = week_num.to_i
+ dates = Array.new
+
+ if week_num == 1
+ weekstartday = monthStartDay(1,year)
+ d = 31
+ x = 0
+ for i in d - (weekstartday - 2)..d
+ dates << i.to_s
+ x = x + 1
+ end
+ for i in 1..8 - weekstartday
+ dates << i.to_s
+ x = x + 1
+ end
+ else
+ week_start = Date.commercial(year, week_num-1, 7)
+ month = week_start.strftime("%m")
+ month_days = getMonthDays(year)
+ date = week_start.strftime("%d")
+ x = date.to_i
+ for i in 0..6
+ d = x + i
+ if d > month_days[month.to_i]
+ d = d - month_days[month.to_i]
+ end
+ dates << d.to_s
+ end
+ end
+ dates
+ end
+
+ def getHours(format)
+ hours = Array.new
+ if format == 12
+ hours << 12
+ for i in 1..11
+ hours << i
+ end
+ elsif format == 24
+ for i in 0..23
+ hours << i
+ end
+ end
+ hours
+ end
end
diff --git a/vendor/built_in_modules/calendar/app/models/event.rb b/vendor/built_in_modules/calendar/app/models/event.rb
index cff01fcc..5c53b1c1 100644
--- a/vendor/built_in_modules/calendar/app/models/event.rb
+++ b/vendor/built_in_modules/calendar/app/models/event.rb
@@ -19,6 +19,7 @@ class Event
field :final_start_time, type: Date
field :final_end_time, type: Date
field :total_days, type: Integer
+ field :all_day, type: Boolean
belongs_to :cal
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/_calendar.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/_calendar.html.erb
index 9accb75a..c03b0d18 100644
--- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/_calendar.html.erb
+++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/_calendar.html.erb
@@ -1,10 +1,12 @@
+
+
- - Edit
- - <%= link_to t("calendar.delete"), panel_calendar_back_end_cal_path(calendar), :method => "delete",:remote => true, :confirm => t("gallery.sure?"),:class=>"btn-del-a", "data-content"=>calendar.id.to_s %>
+ - <%= link_to t("calendar.edit"), edit_panel_calendar_back_end_cal_path(calendar), :remote => true, :class=>"btn-edit-a", :for => calendar.id %>
+ - <%= link_to t("calendar.delete"), panel_calendar_back_end_cal_path(calendar), :method => "delete",:remote => true, :confirm => t("calendar.sure?"),:class=>"btn-del-a", "data-content"=>calendar.id.to_s %>
|
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/agenda_view.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/agenda_view.html.erb
index b7726e4c..57bb1bf9 100644
--- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/agenda_view.html.erb
+++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/agenda_view.html.erb
@@ -45,4 +45,223 @@
-