From f381b9630a7bc7220fd740204386c217c42b6656 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 21 Aug 2014 14:28:02 +0000 Subject: [PATCH] * Calendar/infolog events: Implement drag,drop and resize for integrated infolog events in all calendar views. --- calendar/inc/class.calendar_uiviews.inc.php | 4 +- calendar/js/app.js | 48 ++++++++++----------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/calendar/inc/class.calendar_uiviews.inc.php b/calendar/inc/class.calendar_uiviews.inc.php index c758dfd770..dfa5602b35 100644 --- a/calendar/inc/class.calendar_uiviews.inc.php +++ b/calendar/inc/class.calendar_uiviews.inc.php @@ -1868,10 +1868,8 @@ class calendar_uiviews extends calendar_ui $z_index = is_null($z_index) ? 20 : (int)$z_index; - // ATM we do not support whole day events or recurring events for dragdrop - $dd_emulation = ""; if ($this->use_time_grid && - (int)$event['id'] && $this->bo->check_perms(EGW_ACL_EDIT,$event)) + $event['id'] && $this->bo->check_perms(EGW_ACL_EDIT,$event)) { if (!$event['whole_day_on_top'] && !$event['whole_day'] && diff --git a/calendar/js/app.js b/calendar/js/app.js index e00baff19e..3c61281706 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -155,7 +155,7 @@ app.classes.calendar = AppJS.extend( if (match[1]== _id) do_refresh = true; } }); - if (jQuery('div [id^="infolog'+_id+'"]').length > 0) do_refresh = true; + if (jQuery('div [id^="infolog'+_id+'"],div [id^="drag_infolog'+_id+'"]').length > 0) do_refresh = true; switch (_type) { case 'add': @@ -566,12 +566,19 @@ app.classes.calendar = AppJS.extend( }, /** - * DropEvent + * This function tries to recognise the type of dropped event, and sends relative request to server accordingly + * -ATM we have three different requests: + * -1. Event part of series + * -2. Single Event (Normall Cal Event) + * -3. Integrated Infolog Event * * @param {string} _id dragged event id * @param {array} _date array of date,hour, and minute of dropped cell * @param {string} _duration description - * @param {string} _eventFlag Flag to distinguesh wheter the event is Whole Day, Series, or Single + * @param {string} _eventFlag Flag to distinguish whether the event is Whole Day, Series, or Single + * - S represents Series + * - WD represents Whole Day + * - '' represents Single */ dropEvent : function(_id, _date, _duration, _eventFlag) { @@ -579,7 +586,6 @@ app.classes.calendar = AppJS.extend( var calOwner = _id.substring(_id.lastIndexOf("_O")+2,_id.lastIndexOf("_C")); var eventOwner = _id.substring(_id.lastIndexOf("_C")+2,_id.lastIndexOf("")); var date = this.cal_dnd_tZone_converter(_date); - var moveOrder = false; if (_eventFlag == 'S') { @@ -587,32 +593,26 @@ app.classes.calendar = AppJS.extend( { if (_button_id == et2_dialog.OK_BUTTON) { - egw().json( - 'calendar.calendar_uiforms.ajax_moveEvent', - [eventId, - calOwner, - date, - eventOwner, - _duration] - ).sendRequest(); + egw().json('calendar.calendar_uiforms.ajax_moveEvent', [eventId, calOwner, date, eventOwner, _duration]).sendRequest(); } },this.egw.lang("Do you really want to change the start of this series? If you do, the original series will be terminated as of today and a new series for the future reflecting your changes will be created."), this.egw.lang("This event is part of a series"), {}, et2_dialog.BUTTONS_OK_CANCEL , et2_dialog.WARNING_MESSAGE); } else { - moveOrder = true; - } - if (moveOrder) - { - egw().json( - 'calendar.calendar_uiforms.ajax_moveEvent', - [eventId, - calOwner, - date, - eventOwner, - _duration] - ).sendRequest(); + //Get infologID if in case if it's an integrated infolog event + var infolog_id = eventId.split('infolog')[1]; + + if (infolog_id) + { + // If it is an integrated infolog event we need to edit infolog entry + egw().json('stylite_infolog_calendar_integration::ajax_moveInfologEvent', [infolog_id, date,_duration]).sendRequest(); + } + else + { + //Edit calendar event + egw().json('calendar.calendar_uiforms.ajax_moveEvent',[eventId, calOwner, date, eventOwner, _duration]).sendRequest(); + } } },