disallow adding custom labels to state group

This commit is contained in:
Azgaar 2021-11-30 21:47:22 +03:00
parent 6d5c109d78
commit 19a8db4a17
2 changed files with 30 additions and 5 deletions

View file

@ -60,10 +60,18 @@ function editLabel() {
function selectLabelGroup(text) { function selectLabelGroup(text) {
const group = text.parentNode.id; const group = text.parentNode.id;
if (group === "states" || group === "burgLabels") {
document.getElementById("labelGroupShow").style.display = "none";
return;
}
hideGroupSection();
const select = document.getElementById("labelGroupSelect"); const select = document.getElementById("labelGroupSelect");
select.options.length = 0; // remove all options select.options.length = 0; // remove all options
labels.selectAll(":scope > g").each(function () { labels.selectAll(":scope > g").each(function () {
if (this.id === "states") return;
if (this.id === "burgLabels") return; if (this.id === "burgLabels") return;
select.options.add(new Option(this.id, this.id, false, this.id === group)); select.options.add(new Option(this.id, this.id, false, this.id === group));
}); });
@ -89,7 +97,15 @@ function editLabel() {
} }
function addControlPoint(point) { function addControlPoint(point) {
debug.select("#controlPoints").append("circle").attr("cx", point.x).attr("cy", point.y).attr("r", 2.5).attr("stroke-width", 0.8).call(d3.drag().on("drag", dragControlPoint)).on("click", clickControlPoint); debug
.select("#controlPoints")
.append("circle")
.attr("cx", point.x)
.attr("cy", point.y)
.attr("r", 2.5)
.attr("stroke-width", 0.8)
.call(d3.drag().on("drag", dragControlPoint))
.on("click", clickControlPoint);
} }
function dragControlPoint() { function dragControlPoint() {
@ -141,7 +157,15 @@ function editLabel() {
} }
const before = ":nth-child(" + (index + 2) + ")"; const before = ":nth-child(" + (index + 2) + ")";
debug.select("#controlPoints").insert("circle", before).attr("cx", point[0]).attr("cy", point[1]).attr("r", 2.5).attr("stroke-width", 0.8).call(d3.drag().on("drag", dragControlPoint)).on("click", clickControlPoint); debug
.select("#controlPoints")
.insert("circle", before)
.attr("cx", point[0])
.attr("cy", point[1])
.attr("r", 2.5)
.attr("stroke-width", 0.8)
.call(d3.drag().on("drag", dragControlPoint))
.on("click", clickControlPoint);
redrawLabelPath(); redrawLabelPath();
} }

View file

@ -470,9 +470,10 @@ function addLabelOnClick() {
const id = getNextId("label"); const id = getNextId("label");
// use most recently selected label group // use most recently selected label group
let selected = labelGroupSelect.value; const lastSelected = labelGroupSelect.value;
const symbol = selected ? "#" + selected : "#addedLabels"; const groupId = ["", "states", "burgLabels"].includes(lastSelected) ? "#addedLabels" : "#" + lastSelected;
let group = labels.select(symbol);
let group = labels.select(groupId);
if (!group.size()) if (!group.size())
group = labels group = labels
.append("g") .append("g")