Hide warnings on linked sliders after save
This commit is contained in:
@@ -213,6 +213,10 @@ export function renderVotes() {
|
||||
const suggestionId = Number(e.target.dataset.id);
|
||||
const score = Number(e.target.value);
|
||||
const prevScore = votesMap[suggestionId];
|
||||
const linkedIds = (e.target.dataset.linked || "")
|
||||
.split(",")
|
||||
.filter(Boolean)
|
||||
.map((x) => Number(x));
|
||||
const resetUi = () => {
|
||||
const label = $("score-" + suggestionId);
|
||||
const emoji = $("emoji-" + suggestionId);
|
||||
@@ -231,6 +235,12 @@ export function renderVotes() {
|
||||
delete e.target.dataset.pending;
|
||||
const warn = $("warn-" + suggestionId);
|
||||
if (warn) warn.classList.add("hidden");
|
||||
linkedIds.forEach((id) => {
|
||||
const peerWarn = $("warn-" + id);
|
||||
if (peerWarn) peerWarn.classList.add("hidden");
|
||||
const peerSlider = document.querySelector(`input[type=range][data-id="${id}"]`);
|
||||
if (peerSlider) delete peerSlider.dataset.pending;
|
||||
});
|
||||
await window.loadVoteData();
|
||||
updateMissingBadgeFromDom();
|
||||
} catch (err) {
|
||||
@@ -252,10 +262,13 @@ export function syncVoteScores() {
|
||||
);
|
||||
const scoreLabel = $("score-" + id);
|
||||
const emoji = $("emoji-" + id);
|
||||
const warn = $("warn-" + id);
|
||||
if (slider && score != null) {
|
||||
slider.value = score;
|
||||
if (scoreLabel) scoreLabel.textContent = score;
|
||||
if (emoji) emoji.textContent = scoreToEmoji(score);
|
||||
if (warn) warn.classList.add("hidden");
|
||||
delete slider.dataset.pending;
|
||||
}
|
||||
});
|
||||
document
|
||||
@@ -266,8 +279,10 @@ export function syncVoteScores() {
|
||||
return;
|
||||
const scoreLabel = $("score-" + id);
|
||||
const emoji = $("emoji-" + id);
|
||||
const warn = $("warn-" + id);
|
||||
if (scoreLabel) scoreLabel.textContent = "—";
|
||||
if (emoji) emoji.textContent = neutralEmoji();
|
||||
if (warn) warn.classList.remove("hidden");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user