Changed modification indicator to button element

The setting value now resets to previous when clicking on the indicator.
Furthermore, when hovering over the indicator it also shows what the last value was.
This commit is contained in:
Alex Heller
2023-05-01 03:38:44 +02:00
parent ddfee28e7c
commit 2d82bc67d4
3 changed files with 33 additions and 14 deletions
+7 -3
View File
@@ -258,11 +258,15 @@ onOptionsChanged(function(){
})
function markIfModified(setting_name, value) {
elem = gradioApp().getElementById("setting_"+setting_name)
elem = gradioApp().getElementById("modification_indicator_"+setting_name)
if(elem == null) return;
// Use JSON.stringify to compare nested objects (e.g. arrays for checkbox-groups)
let is_new_value = JSON.stringify(value) != JSON.stringify(opts[setting_name])
elem.classList.toggle("modified", is_new_value)
let previous_value_json = JSON.stringify(opts[setting_name])
let is_new_value = JSON.stringify(value) != previous_value_json
elem.disabled = !is_new_value
if (is_new_value) {
elem.title = `Changed from previous value: ${previous_value_json}`
}
}
let txt2img_textarea, img2img_textarea = undefined;