Highlight foreign key relations
This commit is contained in:
@@ -12,6 +12,9 @@ var CONFIG = {
|
|||||||
RELATION_SPACING: 15,
|
RELATION_SPACING: 15,
|
||||||
RELATION_COLORS: ["#000", "#800", "#080", "#008", "#088", "#808", "#088"],
|
RELATION_COLORS: ["#000", "#800", "#080", "#008", "#088", "#808", "#088"],
|
||||||
|
|
||||||
|
RELATION_HIGHLIGHTED_COLOR: "#FF0000",
|
||||||
|
RELATION_HIGHLIGHTED_THICKNESS: 5,
|
||||||
|
|
||||||
STYLES: ["material-inspired", "original"],
|
STYLES: ["material-inspired", "original"],
|
||||||
MATERIAL_RELATION_COLORS: ["#323232", "#F44336", "#E91E63", "#9C27B0", "#3F51B5", "#673AB7", "#2196F3", "#03A9F4", "#00BCD4", "#009688", "#4CAF50", "#8BC34A", "#CDDC39", "#FFC107", "#FF5722", "#795548", "#607D8B"],
|
MATERIAL_RELATION_COLORS: ["#323232", "#F44336", "#E91E63", "#9C27B0", "#3F51B5", "#673AB7", "#2196F3", "#03A9F4", "#00BCD4", "#009688", "#4CAF50", "#8BC34A", "#CDDC39", "#FFC107", "#FF5722", "#795548", "#607D8B"],
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ SQL.Relation = function(owner, row1, row2) {
|
|||||||
this.color = "#000";
|
this.color = "#000";
|
||||||
this.hidden = false;
|
this.hidden = false;
|
||||||
this.relationColors = CONFIG.RELATION_COLORS;
|
this.relationColors = CONFIG.RELATION_COLORS;
|
||||||
|
this.highlighted = null;
|
||||||
SQL.Visual.apply(this);
|
SQL.Visual.apply(this);
|
||||||
|
|
||||||
this.style = SQL.Designer.getOption("style");
|
this.style = SQL.Designer.getOption("style");
|
||||||
@@ -62,6 +63,22 @@ SQL.Relation.prototype.getColor = function() {
|
|||||||
return this.color;
|
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() {
|
SQL.Relation.prototype.show = function() {
|
||||||
this.hidden = false;
|
this.hidden = false;
|
||||||
for (var i=0;i<this.dom.length;i++) {
|
for (var i=0;i<this.dom.length;i++) {
|
||||||
|
|||||||
@@ -46,12 +46,14 @@ SQL.Row.prototype._build = function() {
|
|||||||
SQL.Row.prototype.select = function() {
|
SQL.Row.prototype.select = function() {
|
||||||
if (this.selected) { return; }
|
if (this.selected) { return; }
|
||||||
this.selected = true;
|
this.selected = true;
|
||||||
|
for (var i = 0; i < this.relations.length; i++) { this.relations[i].highlight(); }
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
SQL.Row.prototype.deselect = function() {
|
SQL.Row.prototype.deselect = function() {
|
||||||
if (!this.selected) { return; }
|
if (!this.selected) { return; }
|
||||||
this.selected = false;
|
this.selected = false;
|
||||||
|
for (var i = 0; i < this.relations.length; i++) { this.relations[i].dehighlight(); }
|
||||||
this.redraw();
|
this.redraw();
|
||||||
this.collapse();
|
this.collapse();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user