Proper restoration of inactive image modifiers

Inactive image modifiers (right click on image tag) are not properly restored by Use Settings and Copy/Paste settings. This PR fixes that.
This commit is contained in:
patriceac 2022-12-28 13:41:36 -08:00
parent 451ab7e84c
commit ad8d1f77df
3 changed files with 29 additions and 1 deletions

View File

@ -59,6 +59,13 @@ const TASK_MAPPING = {
readUI: () => activeTags.map(x => x.name), readUI: () => activeTags.map(x => x.name),
parse: (val) => val parse: (val) => val
}, },
inactive_tags: { name: "Inactive Image Modifiers",
setUI: (inactive_tags) => {
refreshInactiveTags(inactive_tags)
},
readUI: () => activeTags.filter(tag => tag.inactive === true).map(x => x.name),
parse: (val) => val
},
width: { name: 'Width', width: { name: 'Width',
setUI: (width) => { setUI: (width) => {
const oldVal = widthField.value const oldVal = widthField.value

View File

@ -204,6 +204,26 @@ function refreshModifiersState(newTags) {
refreshTagsList() refreshTagsList()
} }
function refreshInactiveTags(inactiveTags) {
// update inactive tags
if (inactiveTags !== undefined && inactiveTags.length > 0) {
activeTags.forEach (tag => {
if (inactiveTags.find(element => element === tag.name) !== undefined) {
tag.inactive = true
}
})
}
// update cards
let overlays = document.querySelector('#editor-inputs-tags-list').querySelectorAll('.modifier-card-overlay')
overlays.forEach (i => {
let modifierName = i.parentElement.getElementsByClassName('modifier-card-label')[0].getElementsByTagName("p")[0].innerText
if (inactiveTags.find(element => element === modifierName) !== undefined) {
i.parentElement.classList.add('modifier-toggle-inactive')
}
})
}
function refreshTagsList() { function refreshTagsList() {
editorModifierTagsList.innerHTML = '' editorModifierTagsList.innerHTML = ''

View File

@ -940,7 +940,8 @@ function getCurrentUserRequest() {
output_quality: parseInt(outputQualityField.value), output_quality: parseInt(outputQualityField.value),
metadata_output_format: document.querySelector('#metadata_output_format').value, metadata_output_format: document.querySelector('#metadata_output_format').value,
original_prompt: promptField.value, original_prompt: promptField.value,
active_tags: (activeTags.map(x => x.name)) active_tags: (activeTags.map(x => x.name)),
inactive_tags: (activeTags.filter(tag => tag.inactive === true).map(x => x.name))
} }
} }
if (IMAGE_REGEX.test(initImagePreview.src)) { if (IMAGE_REGEX.test(initImagePreview.src)) {