Skip to content

Commit 591cbad

Browse files
committed
Replace "Add new composite" row with icon
1 parent ffc1577 commit 591cbad

2 files changed

Lines changed: 34 additions & 23 deletions

File tree

js/composite_table.js

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,45 @@ const compositeTable = class {
33
if (document.getElementById(elementID) === null) {
44
throw "Element ID " + elementID + " not found"
55
};
6-
this.table = d3.select("#" + elementID).append("table").append("tbody");
7-
this.rows = [];
8-
this.nRows = 0;
96
const self = this;
10-
this.addRow_ = this.table.append("tr")
11-
.attr("id", "add-row")
12-
.append("td")
13-
.attr("colspan", 11)
14-
.append("div")
15-
.classed("add-row-text", true)
16-
.text("Add new composite")
17-
.on("click", function() {
18-
const compositeDataObj = dataObj.addCompositeData({idx: self.nRows});
19-
self.addRow(compositeDataObj)
20-
});
7+
8+
this.container = d3.select("#" + elementID)
9+
this.addRowContainer = this.container.append("div")
10+
.attr("id", "add-row");
11+
this.addRowIcon = this.addRowContainer.append("svg")
12+
.classed("add-row-icon", true)
13+
.attr("title", "Add new composite")
14+
.attr("xmlns", "http://www.w3.org/2000/svg")
15+
.attr("viewbox", "0 0 185 30")
16+
.attr("width", "185")
17+
.attr("height", "30")
18+
.on("click", function() {
19+
const compositeDataObj = dataObj.addCompositeData({idx: self.nRows});
20+
self.addRow(compositeDataObj)
21+
});
22+
this.addRowIcon.append("circle")
23+
.attr("cx", 15)
24+
.attr("cy", 15)
25+
.attr("r", 15)
26+
.attr("fill", "#468C00");
27+
this.addRowIcon.append("path")
28+
.attr("d", "m 15 5 l 0 20 M 5 15 l 20 0")
29+
.attr("stroke", "#FFFFFF")
30+
.attr("stroke-width", 4);
31+
this.addRowIcon.append("text")
32+
.attr("x", 40)
33+
.attr("y", 21)
34+
.attr("font-size", 16)
35+
.text("Add new composite");
36+
this.table = this.container.append("table").append("tbody");
37+
this.rows = [];
38+
this.nRows = 0
2139
}
2240

2341
addRow(compositeDataObj) {
2442
// Add the row
2543
this.rows.push(new compositeRow(
26-
this.table.insert("tr", "#add-row").classed("composite-row", true),
44+
this.table.append("tr").classed("composite-row", true),
2745
this.nRows,
2846
compositeDataObj
2947
));

style.css

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,8 @@
187187
}
188188

189189
#add-row {
190-
cursor: pointer !important;
191-
}
192-
193-
.add-row-text {
194190
padding-left: 10px;
195-
}
196-
197-
#add-row div {
198-
width: 100%;
191+
padding-bottom: 5px;
199192
}
200193

201194
.mouse-highlight {

0 commit comments

Comments
 (0)