mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-03-30 18:26:27 +02:00
Merge pull request #518 from patriceac/patch-6
Fix duplicate custom modifiers activation states
This commit is contained in:
commit
f74fa8657b
@ -90,9 +90,7 @@ function createModifierGroup(modifierGroup, initiallyExpanded) {
|
|||||||
if (activeTags.map(x => x.name).includes(modifierName)) {
|
if (activeTags.map(x => x.name).includes(modifierName)) {
|
||||||
// remove modifier from active array
|
// remove modifier from active array
|
||||||
activeTags = activeTags.filter(x => x.name != modifierName)
|
activeTags = activeTags.filter(x => x.name != modifierName)
|
||||||
modifierCard.classList.remove(activeCardClass)
|
toggleCardState(modifierName, false)
|
||||||
|
|
||||||
modifierCard.querySelector('.modifier-card-image-overlay').innerText = '+'
|
|
||||||
} else {
|
} else {
|
||||||
// add modifier to active array
|
// add modifier to active array
|
||||||
activeTags.push({
|
activeTags.push({
|
||||||
@ -101,10 +99,7 @@ function createModifierGroup(modifierGroup, initiallyExpanded) {
|
|||||||
'originElement': modifierCard,
|
'originElement': modifierCard,
|
||||||
'previews': modifierPreviews
|
'previews': modifierPreviews
|
||||||
})
|
})
|
||||||
|
toggleCardState(modifierName, true)
|
||||||
modifierCard.classList.add(activeCardClass)
|
|
||||||
|
|
||||||
modifierCard.querySelector('.modifier-card-image-overlay').innerText = '-'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshTagsList()
|
refreshTagsList()
|
||||||
@ -222,8 +217,7 @@ function refreshTagsList() {
|
|||||||
let idx = activeTags.indexOf(tag)
|
let idx = activeTags.indexOf(tag)
|
||||||
|
|
||||||
if (idx !== -1 && activeTags[idx].originElement !== undefined) {
|
if (idx !== -1 && activeTags[idx].originElement !== undefined) {
|
||||||
activeTags[idx].originElement.classList.remove(activeCardClass)
|
toggleCardState(activeTags[idx].name, false)
|
||||||
activeTags[idx].originElement.querySelector('.modifier-card-image-overlay').innerText = '+'
|
|
||||||
|
|
||||||
activeTags.splice(idx, 1)
|
activeTags.splice(idx, 1)
|
||||||
refreshTagsList()
|
refreshTagsList()
|
||||||
@ -236,6 +230,22 @@ function refreshTagsList() {
|
|||||||
editorModifierTagsList.appendChild(brk)
|
editorModifierTagsList.appendChild(brk)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleCardState(modifierName, makeActive) {
|
||||||
|
document.querySelector('#editor-modifiers').querySelectorAll('.modifier-card').forEach(card => {
|
||||||
|
const name = card.querySelector('.modifier-card-label').innerText
|
||||||
|
if (modifierName == name) {
|
||||||
|
if(makeActive) {
|
||||||
|
card.classList.add(activeCardClass)
|
||||||
|
card.querySelector('.modifier-card-image-overlay').innerText = '-'
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
card.classList.remove(activeCardClass)
|
||||||
|
card.querySelector('.modifier-card-image-overlay').innerText = '+'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function changePreviewImages(val) {
|
function changePreviewImages(val) {
|
||||||
const previewImages = document.querySelectorAll('.modifier-card-image-container img')
|
const previewImages = document.querySelectorAll('.modifier-card-image-container img')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user