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

Make connection/line not deletable #523

Closed
angelostiffy opened this issue Sep 12, 2022 · 4 comments
Closed

Make connection/line not deletable #523

angelostiffy opened this issue Sep 12, 2022 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@angelostiffy
Copy link

@jerosoler I'm currently developing a workflow application using your library. I have below a picture of a sample workflow. Is there a way on how to make connections/line not deletable? If it's possible, if i click on a connection, the green X will not appear.

Untitled

@jerosoler
Copy link
Owner

@jerosoler jerosoler self-assigned this Sep 12, 2022
@jerosoler jerosoler added the question Further information is requested label Sep 12, 2022
@angelostiffy
Copy link
Author

I just included the code from #203 now when I right click a diagram the delete functionality does not work. Is there a way that only connections don't have the right click functionality?

const dataToImport = workflowInstructions;
this.editor = new DrawflowLocal(drawflowId);
this.editor.reroute = false;
this.editor.curvature = 0;
this.editor.reroute_curvature_start_end = 0;
this.editor.reroute_curvature = 0;
this.editor.createCurvature =  (start_pos_x, start_pos_y, end_pos_x, end_pos_y, curvature_value) => {
   let center_x = ((end_pos_x - start_pos_x) / 2) + start_pos_x;
   return ' M ' + start_pos_x + ' ' + start_pos_y + ' L ' + center_x + ' ' + start_pos_y + ' L ' + center_x + ' ' + end_pos_y + ' L ' + end_pos_x + ' ' + end_pos_y;
}
this.editor.contextmenu = (e) => {
   this.editor.drag = false;
   this.editor.drag_point = false;
   this.editor.connection = false;
   this.editor.ele_selected = null;
   this.editor.editor_selected = false;
   this.editor.dispatch('contextmenu', e);
}
this.editor.start();
this.editor.import(dataToImport);  

@jerosoler
Copy link
Owner

Try:

    editor.contextmenu = (e) => {
      editor.dispatch('contextmenu', e);
      e.preventDefault();
      if(editor.editor_mode === 'fixed' || editor.editor_mode === 'view') {
        return false;
      }
      if(editor.precanvas.getElementsByClassName("drawflow-delete").length) {
        editor.precanvas.getElementsByClassName("drawflow-delete")[0].remove()
      };
      if(editor.node_selected || editor.connection_selected) {
        var deletebox = document.createElement('div');
        deletebox.classList.add("drawflow-delete");
        deletebox.innerHTML = "x";
        if(editor.node_selected) {
          editor.node_selected.appendChild(deletebox);

        }
      }
    }

@angelostiffy
Copy link
Author

Thank you it works now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants