Skip to content
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

Tree: CSS customization when dropRestrict=sibling is enable #7248

Closed
zakhdar opened this issue Apr 22, 2021 · 2 comments
Closed

Tree: CSS customization when dropRestrict=sibling is enable #7248

zakhdar opened this issue Apr 22, 2021 · 2 comments
Labels
Resolution: Wontfix Issue will not be fixed due to technical limitations

Comments

@zakhdar
Copy link

zakhdar commented Apr 22, 2021

Description

When drag&drop is activated on a p:tree with the dropRestrict = sibling attribute, when we click on a node to move it, it would be interesting to change the color of the drop point if it is a valid drop point or not, that would allow for a more intuitive interaction.

Describe the solution you would like
A solution would be to have a attribute like siblingClass when we can define for example the color of drop point if drag&drop is authorized or not

Example when drag&drop is in same parent node

image
Example when drag&drop is out of parent node

image

@melloware
Copy link
Member

This is pretty tricky since PF doesn't evaluate whether the drop is allowed until AFTER you actually drop the node.

/**
     * After a drag&drop, validates if the drop is allowed.
     * @private
     * @param {JQuery} dragNode Node that was dragged.
     * @param {JQuery} dropPoint Element where the node was dropped.
     * @return {boolean} Whether the drop is allowed.
     */
    validateDropPoint: function(dragNode, dropPoint) {
        //dropped before or after
        if(dragNode.next().get(0) === dropPoint.get(0)||dragNode.prev().get(0) === dropPoint.get(0)) {
            return false;
        }

        //descendant of dropnode
        if(dragNode.has(dropPoint.get(0)).length) {
            return false;
        }

        //drop restriction
        if(this.cfg.dropRestrict) {
            if(this.cfg.dropRestrict === 'sibling' && dragNode.parent().get(0) !== dropPoint.parent().get(0)) {
                return false;
            }
        }

        return true;
    },

So it will be tough to preemptively tell its not allowed to drop and change the helper css to a different style. At least not without some major rework of the tree drag and drop.

@melloware
Copy link
Member

Going to mark this as won't fix only because it is not currently possible

@melloware melloware closed this as not planned Won't fix, can't repro, duplicate, stale Dec 26, 2023
@melloware melloware added Resolution: Wontfix Issue will not be fixed due to technical limitations and removed new feature labels Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Wontfix Issue will not be fixed due to technical limitations
Projects
None yet
Development

No branches or pull requests

2 participants