From ca243d0a99a403261e08f66bb03ed9b81c360404 Mon Sep 17 00:00:00 2001 From: Radovan Skolnik Date: Mon, 6 Jan 2020 22:31:13 +0100 Subject: [PATCH] Highlight foreign key relations --- js/config.js | 3 +++ js/relation.js | 17 +++++++++++++++++ js/row.js | 2 ++ 3 files changed, 22 insertions(+) diff --git a/js/config.js b/js/config.js index 49636ed..52dafa5 100644 --- a/js/config.js +++ b/js/config.js @@ -11,6 +11,9 @@ var CONFIG = { RELATION_THICKNESS: 2, RELATION_SPACING: 15, RELATION_COLORS: ["#000", "#800", "#080", "#008", "#088", "#808", "#088"], + + RELATION_HIGHLIGHTED_COLOR: "#FF0000", + RELATION_HIGHLIGHTED_THICKNESS: 5, STYLES: ["material-inspired", "original"], MATERIAL_RELATION_COLORS: ["#323232", "#F44336", "#E91E63", "#9C27B0", "#3F51B5", "#673AB7", "#2196F3", "#03A9F4", "#00BCD4", "#009688", "#4CAF50", "#8BC34A", "#CDDC39", "#FFC107", "#FF5722", "#795548", "#607D8B"], diff --git a/js/relation.js b/js/relation.js index 6a08156..025eece 100644 --- a/js/relation.js +++ b/js/relation.js @@ -7,6 +7,7 @@ SQL.Relation = function(owner, row1, row2) { this.color = "#000"; this.hidden = false; this.relationColors = CONFIG.RELATION_COLORS; + this.highlighted = null; SQL.Visual.apply(this); this.style = SQL.Designer.getOption("style"); @@ -62,6 +63,22 @@ SQL.Relation.prototype.getColor = function() { return this.color; } +SQL.Relation.prototype.highlight = function() { + if (this.highlighted) { return; } + this.highlighted = true; + this.dom[0].setAttribute("stroke", CONFIG.RELATION_HIGHLIGHTED_COLOR); + this.dom[0].setAttribute("stroke-width", CONFIG.RELATION_HIGHLIGHTED_THICKNESS); + this.redraw(); +} + +SQL.Relation.prototype.dehighlight = function() { + if (!this.highlighted) { return; } + this.highlighted = false; + this.dom[0].setAttribute("stroke", this.color); + this.dom[0].setAttribute("stroke-width", CONFIG.RELATION_THICKNESS); + this.redraw(); +} + SQL.Relation.prototype.show = function() { this.hidden = false; for (var i=0;i