ui-calendar icon indicating copy to clipboard operation
ui-calendar copied to clipboard

How to retrieve an object dropped on the ui-calendar

Open mehdiloup opened this issue 12 years ago • 5 comments

/*** RELATED QUESTION #43 ***/

Hi everyone,

Arshaw full-calendar offers the possibility to drop objects on the calendar. It is simple to retrieve the dropped element with the keyword this (http://arshaw.com/fullcalendar/docs/dropping/drop/)

Unfortunately, the keyword this in the $scope.uiConfig refers to window object as the ui-calendar is an angular directive.

Could anyone help figure out how to retrieve a dropped object in drop function of the $scope.uiConfig

Thank you!

Mehdi-Loup

mehdiloup avatar Mar 08 '14 19:03 mehdiloup

Hi Mehdi-Loup,

Can you please guide me how to fix the above issue,

Thanks in Advance Mani

manibhasuri avatar Apr 04 '14 14:04 manibhasuri

Hi Mani,

I used the following directive to handle the dragdrop elements: https://github.com/codef0rmer/angular-dragdrop

In the method mutateDraggable of the dragdrop service, i saved the dropped element in a scope variable. Not sure it is the best way to do, but it has been a woriking quick fix.

this.mutateDraggable = function(scope, dropSettings, dragSettings, dragModel, dropModel, dropItem, $draggable) { var isEmpty = angular.equals(angular.copy(dropItem), {}), dragModelValue = scope.$eval(dragModel);

  scope.dndDropItem = dropItem;

  if (dragSettings && dragSettings.placeholder) {
    if (dragSettings.placeholder != 'keep'){
      if (angular.isArray(dragModelValue) && dragSettings.index !== undefined) {
        dragModelValue[dragSettings.index] = dropItem;
      } else {
        $parse(dragModel + ' = dndDropItem')(scope);
      }
    }
  } else {
    if (angular.isArray(dragModelValue)) {
      if (isEmpty) {
        if (dragSettings && ( dragSettings.placeholder !== true && dragSettings.placeholder !== 'keep' )) {
          dragModelValue.splice(dragSettings.index, 1);
        }
      } else {
        dragModelValue[dragSettings.index] = dropItem;
      }
    } else {
      // Fix: LIST(object) to LIST(array) - model does not get updated using just scope[dragModel] = {...}
      // P.S.: Could not figure out why it happened
      $parse(dragModel + ' = dndDropItem')(scope);
      if (scope.$parent) {
        $parse(dragModel + ' = dndDropItem')(scope.$parent);
      }
    }
  }
  $draggable.css({'z-index': '', 'left': '', 'top': ''});
};

mehdiloup avatar Apr 04 '14 22:04 mehdiloup

I tried debugging even when i drop an external event on to a calender mutatedraggable is not hitting,

Here is what i tried

For draggable events

%lt ul class="btn btn-droppable" ng-repeat="item in extEvents" data-drop="true" ng-model='extEvents' data-jqyoui-options="{accept:'.btn-draggable:not([ng-model=extEvents])'}" jqyoui-droppable="{index: {{$index}}}"> %lt i class="btn btn-primary btn-draggable" data-drag="true" data-jqyoui-options="{revert: 'invalid',revertDuration:0}" data-ng-model="extEvents" jqyoui-draggable="{index: {{$index}},placeholder:true,animate:true}" ng-hide="!item.title">{{item.title}}

When i drop an event onto a calender it is not fetching the model. Can you tell me when mutatedragging is hit.

Thanks, Mani

manibhasuri avatar Apr 07 '14 12:04 manibhasuri

Hello,

I'm trying the same issue with my calendar, Am I missing something fundamental from the above thread?

Thanks Sandeep

snadakuduru avatar May 12 '14 19:05 snadakuduru

Has anyone managed to get this working with https://github.com/codef0rmer/angular-dragdrop? I can't get it to hit mutatedraggable at any point, and I'm guessing because of that, it's not hitting uiConfig.calendar.drop. @mehdiloup ?

andrew-burgess-motasoft avatar Mar 09 '18 17:03 andrew-burgess-motasoft