From 6c597c64cec6ce5d199abed892ed7af9ab849c51 Mon Sep 17 00:00:00 2001 From: ZitRos Date: Tue, 3 Jan 2017 19:55:36 +0200 Subject: [PATCH] Ability to delete classes from the diagram add --- package.json | 2 +- web/css/classView.css | 9 +++++++++ web/js/ClassView.js | 21 ++++++++++++++++++++- web/jsLib/joint.shapes.uml.js | 1 + 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2bd64a2..f92698a 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "CacheClassExplorer", - "version": "1.17.2", + "version": "1.18.0", "description": "Class Explorer for InterSystems Caché", "directories": { "test": "test" }, "dependencies": {}, diff --git a/web/css/classView.css b/web/css/classView.css index ef76575..dd29322 100644 --- a/web/css/classView.css +++ b/web/css/classView.css @@ -124,6 +124,15 @@ text { outline: 4px solid rgba(255, 0, 0, 0.6); } +.element.uml.Class .tool-remove { + display: none; + cursor: pointer; +} + +.element.uml.Class:hover .tool-remove { + display: block; +} + .marker-source, .marker-target { vector-effect: none !important; } diff --git a/web/js/ClassView.js b/web/js/ClassView.js index f84393f..7068277 100755 --- a/web/js/ClassView.js +++ b/web/js/ClassView.js @@ -824,7 +824,7 @@ ClassView.prototype.confirmRender = function (data) { connector.on("all", function (e) { if (e !== "remove") return; self.cacheClassExplorer.setSubLabel( - "*Some links are removed on this diagram.", + "*Some elements are removed on this diagram.", "color:red" ); }); @@ -862,6 +862,25 @@ ClassView.prototype.confirmRender = function (data) { q.options.height/2 - Math.min(q.options.height/2 - 100, bb.height/2) ); + this.paper.on('cell:pointerclick', function(cellView, evt, x, y) { + var e = evt.target || evt.srcElement; + // https://upload.wikimedia.org/wikipedia/commons/a/ae/Elleboogkruk.jpg + if (!((e && e.getAttribute("event") === "remove") || + (e.parentNode && e.parentNode.getAttribute("event") === "remove"))) + return; + cellView.remove(); + for (var p in self.links) { + if (self.paper.getModelById(self.links[p].attributes.source) === cellView.model + || self.paper.getModelById(self.links[p].attributes.target) === cellView.model) { + self.links[p].remove(); + } + } + self.cacheClassExplorer.setSubLabel( + "*Some elements are removed on this diagram.", + "color:red" + ); + }); + if (data.savedView) this.restoreView(data.savedView); this.onRendered(); diff --git a/web/jsLib/joint.shapes.uml.js b/web/jsLib/joint.shapes.uml.js index c5ae191..337fc48 100644 --- a/web/jsLib/joint.shapes.uml.js +++ b/web/jsLib/joint.shapes.uml.js @@ -33,6 +33,7 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({ '', '', '', + 'Remove class', '' ].join(''),