Accept or canBeAccepted not working with isContainer and IsModel : Dragular

50 Views Asked by At

Scenario 1 : Using two container lets say A(Drag Source) and B(Drop Source).

Code snippet :

 dragularService(containerLeft, {
      containersModel: [DragularconTainer],
      copy: true,
      canBeAccepted: function(el, source) {
        var elementDrag = angular.element(el)
        return false;
      },
      revertOnSpill: true,
      isContainer: function isContainer(el) {
        return el.id === 'filler';
      },
      isContainerModel: function getModel() {
        return $scope.TestModel;
      },
      scope: $scope
    });  

Scenario 2 : Using B(Drop Source) for nested drag and drop in between.

     var container = containerRight,
          parentContainers = container.children(),
          nestedContainers = [];
        console.log(parentContainers);
        console.log($element.children());
        dragularService(container, {
          revertOnSpill: true,
          moves: function(el, container, handle) {
            return handle.classList.contains('row-handle');
          },
          containersModel: $scope.object,
          nameSpace: 'rows'
        });

        // collect nested contianers
        for (var i = 0; i < parentContainers.length; i++) {
          nestedContainers.push(parentContainers.eq(i).children()[1]);
        }

        dragularService(nestedContainers, {
          revertOnSpill: true,
          moves: function(el, container, handle) {
            return !handle.classList.contains('row-handle');
          },
          containersModel: (function getNestedContainersModel() {
            var parent = $scope.objects,
              containersModel = [];
            for (var i = 0; i < parent.length; i++) {
              containersModel.push(parent[i].test);
            }
            return containersModel;
          })(),
          nameSpace: 'cells'
        });

Issues : Scenario 1 "canBeAccepted : " is not working when used along with isContainerModel. It should work according to Boolean values returned to the function.

Validation: 1. The approach for using container B as drop zone and nested drag.

Please suggest.

1

There are 1 best solutions below

0
On

Solved on github issue here. There was a bug in canBeAccepted! Now fixed.