From 079402cb2f65ea52f256453b7439e43db19ebbc3 Mon Sep 17 00:00:00 2001 From: patriceac <48073125+patriceac@users.noreply.github.com> Date: Mon, 13 Mar 2023 22:06:21 -0700 Subject: [PATCH] Fix restoration of weighted tasks with truncated modifiers (#956) * Fix restoration of weighted tasks with truncated modifiers * Reverting this change Will create a separate PR for this as needed. Doesn't impact the other bug fix. * Update utils.js --- ui/media/js/image-modifiers.js | 4 ++-- ui/plugins/ui/Modifiers-wheel.plugin.js | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ui/media/js/image-modifiers.js b/ui/media/js/image-modifiers.js index 5ec6b271..b8282782 100644 --- a/ui/media/js/image-modifiers.js +++ b/ui/media/js/image-modifiers.js @@ -176,9 +176,9 @@ function refreshModifiersState(newTags) { // add modifier to active array if (!activeTags.map(x => x.name).includes(tag)) { // only add each tag once even if several custom modifier cards share the same tag const imageModifierCard = modifierCard.cloneNode(true) - imageModifierCard.querySelector('.modifier-card-label p').innerText = shortModifierName + imageModifierCard.querySelector('.modifier-card-label p').innerText = tag.replace(modifierName, shortModifierName) activeTags.push({ - 'name': modifierName, + 'name': tag, 'element': imageModifierCard, 'originElement': modifierCard }) diff --git a/ui/plugins/ui/Modifiers-wheel.plugin.js b/ui/plugins/ui/Modifiers-wheel.plugin.js index 6639873d..322cca8f 100644 --- a/ui/plugins/ui/Modifiers-wheel.plugin.js +++ b/ui/plugins/ui/Modifiers-wheel.plugin.js @@ -26,15 +26,25 @@ const delta = Math.sign(event.deltaY) let s = i.parentElement.getElementsByClassName('modifier-card-label')[0].getElementsByTagName("p")[0].innerText + let t + // find the corresponding tag + for (let it = 0; it < overlays.length; it++) { + if (i == overlays[it]) { + t = activeTags[it].name + break + } + } if (delta < 0) { // wheel scrolling up if (s.substring(0, 1) == '[' && s.substring(s.length-1) == ']') { s = s.substring(1, s.length - 1) + t = t.substring(1, t.length - 1) } else { if (s.substring(0, 10) !== '('.repeat(10) && s.substring(s.length-10) !== ')'.repeat(10)) { s = '(' + s + ')' + t = '(' + t + ')' } } } @@ -42,11 +52,13 @@ // wheel scrolling down if (s.substring(0, 1) == '(' && s.substring(s.length-1) == ')') { s = s.substring(1, s.length - 1) + t = t.substring(1, t.length - 1) } else { if (s.substring(0, 10) !== '['.repeat(10) && s.substring(s.length-10) !== ']'.repeat(10)) { s = '[' + s + ']' + t = '[' + t + ']' } } } @@ -54,7 +66,7 @@ // update activeTags for (let it = 0; it < overlays.length; it++) { if (i == overlays[it]) { - activeTags[it].name = s + activeTags[it].name = t break } }