Skip to content

Drag fails if drop model doesn't already exist #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RobHudson72 opened this issue Jun 26, 2014 · 0 comments
Closed

Drag fails if drop model doesn't already exist #111

RobHudson72 opened this issue Jun 26, 2014 · 0 comments

Comments

@RobHudson72
Copy link

I have two data sources.... I drag data (addresses) from a simple array, and place them onto a complex document that stores delivery route sequencing. To minimize the size of the json, the destination objects do not already exist in the object.

Addresses may be either placed on the left or right side of the document (indicating you are delivering to the left or right side of the street).

My documents look like this

address list:

[{"address": "123 Anywhere Lane"},
{"address: "123 James Place"},
{address: " 123 Gotham City Dr"}]

the document looks like this:

array of lines. Each line can have a "left" or "right" attribute, or maybe both, which are addresses. If a left or right attribute are missing, then we can drag an address to the missing attribute.

{"lines": [
{"left":{address: "123 park ave"},
"right":{address: "123 park ave"}}, --this line already has deliveries on both sides
{}, - this line has no left or right deliveries. We can add a new delivery to either side
{"left":{address: "123 park ave"}}, this line has no right delivery. We can drag something new there.
])

What I found is that your code expects the destination ngModel to already exist as at least {}. If it doesn't, then the value is not removed from the addresses list correctly. In order to fix that, I made a small change to the mutateDraggable function:

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

        //6/26/2014 Rob:  Changed isEmpty to also check for undefined
        var isEmpty = (angular.equals(dropItem, {}) || dropItem == undefined),
                 dragModelValue = scope.$eval(dragModel);

It now works the way you intend it, as far as I can tell.

codef0rmer pushed a commit that referenced this issue Oct 1, 2014
  - Closes #125, #121, #99 - Fix paradox of choice ($ vs jQuery)
  - Closes #122 - Update jQueryUI depedency in demos and tests
  - Closes #130 - Restore display value if set, else use block
  - Closes #128, #36, #30 - Restore zIndex value always
  - Closes #117, #110 - Fix destroying widgets prior to initialization
  - Closes #111 - Allow dropping without ngModel similar to dragging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant