[DONE] Event cloning

Request new features or modifications for Extensible components

[DONE] Event cloning

Postby feyyaz » Wed Jan 19, 2011 5:40 am

It would be nice if it would be possible to clone an existing event to another time and/or calendar, to save repetitiv input.

for example over the context menu, like the move to command.
feyyaz
 
Posts: 28
Joined: Wed Dec 22, 2010 7:49 am

Re: Event cloning

Postby feyyaz » Fri Jan 28, 2011 5:00 am

I added through some hacks the abbility to copy/clone an event by holding alt key during dragging an event on DayView. The following code alone is not enough to run the new feature, it only shows where i added changes to get this working (i left out all the code changes for this.cloneText):

DayViewDD.js

Ext.ensible.cal.DayViewDragZone.getDragData()
Code: Select all
return {
  type: 'eventdrag',
  ddel: t,
  // FOLLOWING LINE IS NEW
  clone: e.altKey,
  eventStart: rec.data[Ext.ensible.cal.EventMappings.StartDate.name],
  eventEnd: rec.data[Ext.ensible.cal.EventMappings.EndDate.name],
  proxy: this.proxy
};


Ext.ensible.cal.DayViewDropZone.onNodeOver()
Code: Select all
if(data.type == 'eventdrag') {
  ...
 
  dt = n.date.format(this.dateFormat + ' ' + timeFormat);
  box.x = n.el.getLeft();

  this.shim(n.date, box);
 
  // CHANGES START
  // text = this.moveText;
  if(data.clone) text = this.cloneText;
  else text = this.moveText;
  // CHANGES END
}


Ext.ensible.cal.DayViewDropZone.onNodeDrop()
Code: Select all
onNodeDrop : function(n, dd, e, data) {
  if(n && data){
    if(data.type == 'eventdrag') {
      var rec = this.view.getEventRecordFromEl(data.ddel);

      // CHANGE START
      // this.view.onEventDrop(rec, n.date);
      if(data.clone) {
        this.view.onEventClone(rec, n.date);
      }
      else {
        this.view.onEventDrop(rec, n.date);
      }
      // CHANGE END

      this.onCalendarDragComplete();
      ...
    }
  }
}


CalendarView.js

add following new function
Code: Select all
onEventClone: function(src_rec, dt) {
  var rec = new Ext.ensible.cal.EventRecord();

  var M = Ext.ensible.cal.EventMappings;
  Ext.iterate(M,function(n,o) {
   if(n==M.EventId.name) return;
    rec.data[o.name]=src_rec.data[o.name];
  });

  // set new date
  var diff = dt.getTime() - rec.data[Ext.ensible.cal.EventMappings.StartDate.name].getTime();
  rec.beginEdit();
  rec.set(Ext.ensible.cal.EventMappings.StartDate.name, dt);
  rec.set(Ext.ensible.cal.EventMappings.EndDate.name, rec.data[Ext.ensible.cal.EventMappings.EndDate.name].add(Date.MILLI, diff));
  rec.endEdit();

  this.store.add(rec);
  this.fireEvent('eventadd', this, rec);
}
feyyaz
 
Posts: 28
Joined: Wed Dec 22, 2010 7:49 am

Re: Event cloning

Postby brian.moeskau » Fri Jan 28, 2011 9:52 am

Cool! I had a similar idea but have not looked into it yet. I'll revisit this once I start adding new features again after 1.0 is done.
Personal Blog: Extraneous / Twitter: @bmoeskau / Meetup: Austin Bleeding Edge Web
User avatar
brian.moeskau
Site Admin
Site Admin
 
Posts: 1344
Joined: Sat Sep 18, 2010 5:00 pm
Location: Austin, Texas

Re: [COMPLETE] Event cloning

Postby brian.moeskau » Wed Nov 28, 2012 12:16 pm

Just noticed this open thread. This has been implemented in 1.6 and will be available when 1.6 is released (it's currently in the beta release).
Personal Blog: Extraneous / Twitter: @bmoeskau / Meetup: Austin Bleeding Edge Web
User avatar
brian.moeskau
Site Admin
Site Admin
 
Posts: 1344
Joined: Sat Sep 18, 2010 5:00 pm
Location: Austin, Texas


Return to Feature Requests

Who is online

Users browsing this forum: No registered users and 1 guest

cron