fix style error and let other model can connect to event
This commit is contained in:
parent
aa6df3a1bd
commit
3ac2655d72
|
@ -58,12 +58,16 @@ var Calendar = function(dom){
|
|||
}else{
|
||||
c.event_create_space.css("top",top_pos + "px");
|
||||
}
|
||||
}else{
|
||||
}else if(c.mousePosition["y"]+c.event_create_space.height()<$(window).height()){
|
||||
c.event_create_space.css("top",c.mousePosition["y"] + "px");
|
||||
}
|
||||
|
||||
if((create_space_width + c.mousePosition["x"]) >= $(window).width()){
|
||||
c.event_create_space.css("left",(c.mousePosition["x"] - create_space_width) + "px");
|
||||
if (c.mousePosition["x"] - create_space_width < 0){
|
||||
c.event_create_space.css("left",'0px')
|
||||
}else{
|
||||
c.event_create_space.css("left",(c.mousePosition["x"] - create_space_width) + "px");
|
||||
}
|
||||
}else{
|
||||
c.event_create_space.css("left",c.mousePosition["x"] + "px");
|
||||
}
|
||||
|
@ -388,14 +392,14 @@ var EventDialog = function(calendar,event){
|
|||
}
|
||||
|
||||
this.show = function(pos){
|
||||
if(pos){
|
||||
var pos = getPosition(pos);
|
||||
event_quick_view.css({"left":pos.x+"px","top":pos.y+"px"});
|
||||
}
|
||||
event_quick_view.html(template).appendTo("body").show();
|
||||
event_quick_view.find(".event-close-btn").one("click",function(){_t.dismiss();});
|
||||
event_quick_view.find("a.delete").one("click",function(){calendar.deleteEvent(_this_event.delete_url,_this_event._id);return false;});
|
||||
event_quick_view.find("a.edit").one("click",function(){calendar.editEvent(_this_event.edit_url,_this_event.allDay);return false;});
|
||||
if(pos){
|
||||
var pos = getPosition(pos);
|
||||
event_quick_view.css({"left":pos.x+"px","top":pos.y+"px"});
|
||||
}
|
||||
}
|
||||
|
||||
this.dismiss = function(){
|
||||
|
|
|
@ -9,6 +9,8 @@ class Event
|
|||
|
||||
field :title
|
||||
field :note
|
||||
field :title_translations,type: Hash,default: {}
|
||||
field :note_translations,type: Hash,default: {}
|
||||
field :start, type: DateTime
|
||||
field :end, type: DateTime
|
||||
field :all_day, type: Boolean,default: false
|
||||
|
@ -21,8 +23,39 @@ class Event
|
|||
belongs_to :calendar_type
|
||||
attr_accessor :agenda_start, :agenda_end, :get_agenda_events
|
||||
|
||||
|
||||
validates_presence_of :title, :message => "Please fill the title of the Event"
|
||||
#let other model can connect to this model
|
||||
field :key
|
||||
field :model_class
|
||||
field :model_id
|
||||
before_destroy do
|
||||
if !self.model_class.blank?
|
||||
m = eval(self.model_class).where(id: self.model_id).first rescue nil
|
||||
if !m.nil?
|
||||
if self.key.nil?
|
||||
m.event_id = nil
|
||||
else
|
||||
m.calendar_dict.delete(self.key)
|
||||
if !m['calendar_data'].nil?
|
||||
tmp = m['calendar_data']
|
||||
tmp['key'] = Array(tmp['key']) - [self.key]
|
||||
m['calendar_data'] = tmp
|
||||
end
|
||||
end
|
||||
m.save
|
||||
end
|
||||
end
|
||||
end
|
||||
########################################
|
||||
validates_presence_of :title, :message => "Please fill the title of the Event", :unless => lambda { self.title_translations.blank? }
|
||||
validates_presence_of :title_translations, :message => "Please fill the title of the Event", :unless => lambda { self.title.blank? }
|
||||
def title
|
||||
tp = self['title_translations'][I18n.locale]
|
||||
tp.blank? ? self['title'] : tp
|
||||
end
|
||||
def note
|
||||
tp = self['note_translations'][I18n.locale]
|
||||
tp.blank? ? self['note'] : tp
|
||||
end
|
||||
def self.with_categories(cat_ids=[])
|
||||
if cat_ids.blank?
|
||||
self.all
|
||||
|
|
Loading…
Reference in New Issue