odoo/addons/web_calendar/static/lib/dhtmlxScheduler/codebase/ext/dhtmlxscheduler_collision.js

9 lines
1.8 KiB
JavaScript

/*
This software is allowed to use under GPL or you need to obtain Commercial or Enterise License
to use it in non-GPL project. Please contact sales@dhtmlx.com for details
*/
(function(){function h(b){var a=scheduler._props?scheduler._props[scheduler._mode]:null,i=scheduler.matrix?scheduler.matrix[scheduler._mode]:null,e=a||i;if(a)var f=e.map_to;if(i)f=e.y_property;e&&b&&(n=scheduler.getEvent(b)[f])}function g(b){var a=[],i=scheduler.config.collision_limit;if(b.rec_type)for(var e=scheduler.getRecDates(b),f=0;f<e.length;f++)for(var d=scheduler.getEvents(e[f].start_date,e[f].end_date),j=0;j<d.length;j++)(d[j].event_pid||d[j].id)!=b.id&&a.push(d[j]);else for(var a=scheduler.getEvents(b.start_date,
b.end_date),c=0;c<a.length;c++)if(a[c].id==b.id){a.splice(c,1);break}var g=scheduler._props?scheduler._props[scheduler._mode]:null,h=scheduler.matrix?scheduler.matrix[scheduler._mode]:null,m=g||h;if(g)var k=m.map_to;if(h)k=m.y_property;var l=!0;if(m){for(var o=0,c=0;c<a.length;c++)a[c][k]==b[k]&&a[c].id!=b.id&&o++;o>=i&&(l=!1)}else a.length>=i&&(l=!1);if(!l){var p=!scheduler.callEvent("onEventCollision",[b,a]);p||(b[k]=n||b[k]);return p}return l}var n,d;scheduler.config.collision_limit=1;scheduler.attachEvent("onBeforeDrag",
function(b){h(b);return!0});scheduler.attachEvent("onBeforeLightbox",function(b){var a=scheduler.getEvent(b);d=[a.start_date,a.end_date];h(b);return!0});scheduler.attachEvent("onEventChanged",function(b){if(!b)return!0;var a=scheduler.getEvent(b);if(!g(a)){if(!d)return!1;a.start_date=d[0];a.end_date=d[1];a._timed=this.is_one_day_event(a)}return!0});scheduler.attachEvent("onBeforeEventChanged",function(b){return g(b)});scheduler.attachEvent("onEventSave",function(b,a){a=scheduler._lame_clone(a);a.id=
b;a.rec_type&&scheduler._roll_back_dates(data_copy);return g(a)})})();