dabeng / OrgChart

It's a simple and direct organization chart plugin. Anytime you want a tree-like chart, you can turn to OrgChart.
MIT License
2.86k stars 768 forks source link

getHierarchy( includeNodeData =true ) returns edited hierarchy but not edited node content #629

Open Monkeytactics opened 3 years ago

Monkeytactics commented 3 years ago

I've implemented a 'b2t' version of this and it mostly works great. However, I added contentEditable =true to two node div's:

  1. content
  2. note (this is an extra div/JSON element I added to allow users to comment on a relationship)

Unfortunately getHierarchy( includeNodeData ) only returns modified structure detail, this I am able to save just fine, but the modified node content is seemingly ignored by this method.

I can't find any reference to editing and saving content in addition to hierarchy, perhaps other users aren't doing this - perhaps I am missing something - is there a way to do this in the current codebase or do I need to add this functionality myself?

Monkeytactics commented 3 years ago

For clarity here - this method does return node data for me, as opposed to just id's with the 'includeNodeData' omitted - but it ignores any data content additions or edits and returns only data state at the point the orgchart was generated (including structure changes, if applicable).

Monkeytactics commented 3 years ago

For the benefit of others, I'm now using this to get node elements (that may have been edited) from the node tree:

var updates = $('div.node').map(function() { return { id: $(this).attr("id"), content: $(this).find('div.content').text(), note: $(this).find('div.note').text() }; }).get();

This gives me node content as it currently stands, you then just need to parse the getHierarchy(includeNodeData) result and update values with the result of above.

iPFT commented 1 year ago

Hi Monkey. I am fashionably late to this party with developing something similar and have hit the same issue. Outputting to PNG and PDF works fine, but the hierarchy remains unchanged. Would be great if the changed content could be reflected automatically.

Been doing some digging and came across your issue. Just wondering how you implement the merging of the updates variable into the main hierarchy. Did you just identify the changed nodes or update the whole hierarchy?