Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Create validation on node drop #273

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

Open
maslunde wants to merge 1 commit into dabeng:master
base: master
Choose a base branch
Loading
from maslunde:master
Open

Conversation

@maslunde
Copy link

@maslunde maslunde commented Sep 21, 2017

If a backend service return an rejected promise, node should not be moved.

Example of usage from an agular directive:

oc.$chart
.on('validate.nodedropped.orgchart', event => {
let defer = $q.defer();
CustomerHierarchyService
.moveSection(event.draggedNode[0].id, event.dropZone[0].id)
.then(() => {
Message.showSuccess("Section was successfully moved!");
defer.resolve();
})
.catch((error) => {
Message.showError(error.data.responseStatus.message);
defer.reject();
});

 return defer.promise;
 })
 .on('click','.node', function () {
 var $this = $(this);
 $('#selected-node').val($this.find('.title').text()).data('node', $this);
 })
 .on('dblclick','.node', function () {
 editNode($(this));
 })
 .on('click', '.orgchart', event => {
 if (!$(event.target).closest('.node').length) {
 $('#selected-node').val('');
 }
 });

If a backend service return an rejected promise, node should not be moved.
Example of usage from an agular directive:
 oc.$chart
 .on('validate.nodedropped.orgchart', event => {
 let defer = $q.defer();
 CustomerHierarchyService
 .moveSection(event.draggedNode[0].id, event.dropZone[0].id)
 .then(() => {
 Message.showSuccess("Section was successfully moved!");
 defer.resolve();
 })
 .catch((error) => {
 Message.showError(error.data.responseStatus.message);
 defer.reject();
 });
 return defer.promise;
 })
 .on('click','.node', function () {
 var $this = $(this);
 $('#selected-node').val($this.find('.title').text()).data('node', $this);
 })
 .on('dblclick','.node', function () {
 editNode($(this));
 })
 .on('click', '.orgchart', event => {
 if (!$(event.target).closest('.node').length) {
 $('#selected-node').val('');
 }
 });
Copy link
Author

maslunde commented Nov 2, 2017
edited
Loading

It would be nice to get some feedback on this PR. I saw it was not merged into the latest release.

Copy link
Owner

dabeng commented Nov 3, 2017

Hi @maslunde , sorry for late replay. I guess I got your points. I still have the following concerns:

  1. We already have dropCriteria option. Please try out this demo and drag/drop one node with "manager" word.
  2. Is it a good practice to check whether a node is droppable depending on deferred object?

Copy link
Author

maslunde commented Nov 3, 2017

Hi @dabeng, thank you for your answer. Let me be more precise in our need.
The dropCriteria option is a good thing when you know the valid dropZones nodes when you start dragging the node. In our case we don't know. It`s based on a lot of rules in another system, so the client must rely on the response it get. That happens asynchronous. Of course this could be implied to add, remove, edit as well. For now drop criteria is enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /