Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
5aefd6cd
Commit
5aefd6cd
authored
Apr 02, 2023
by
pythongosssss
Browse files
Support numeric settings, tooltip, extra attrs
parent
27fc64ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
28 deletions
+58
-28
web/scripts/ui.js
web/scripts/ui.js
+58
-28
No files found.
web/scripts/ui.js
View file @
5aefd6cd
...
...
@@ -198,7 +198,7 @@ class ComfySettingsDialog extends ComfyDialog {
localStorage
[
settingId
]
=
JSON
.
stringify
(
value
);
}
addSetting
({
id
,
name
,
type
,
defaultValue
,
onChange
})
{
addSetting
({
id
,
name
,
type
,
defaultValue
,
onChange
,
attrs
=
{},
tooltip
=
""
,
})
{
if
(
!
id
)
{
throw
new
Error
(
"
Settings must have an ID
"
);
}
...
...
@@ -225,42 +225,72 @@ class ComfySettingsDialog extends ComfyDialog {
value
=
v
;
};
let
element
;
if
(
typeof
type
===
"
function
"
)
{
return
type
(
name
,
setter
,
value
);
element
=
type
(
name
,
setter
,
value
,
attrs
);
}
else
{
switch
(
type
)
{
case
"
boolean
"
:
element
=
$el
(
"
div
"
,
[
$el
(
"
label
"
,
{
textContent
:
name
||
id
},
[
$el
(
"
input
"
,
{
type
:
"
checkbox
"
,
checked
:
!!
value
,
oninput
:
(
e
)
=>
{
setter
(
e
.
target
.
checked
);
},
...
attrs
}),
]),
]);
break
;
case
"
number
"
:
element
=
$el
(
"
div
"
,
[
$el
(
"
label
"
,
{
textContent
:
name
||
id
},
[
$el
(
"
input
"
,
{
type
,
value
,
oninput
:
(
e
)
=>
{
setter
(
e
.
target
.
value
);
},
...
attrs
}),
]),
]);
break
;
default
:
console
.
warn
(
"
Unsupported setting type, defaulting to text
"
);
element
=
$el
(
"
div
"
,
[
$el
(
"
label
"
,
{
textContent
:
name
||
id
},
[
$el
(
"
input
"
,
{
value
,
oninput
:
(
e
)
=>
{
setter
(
e
.
target
.
value
);
},
...
attrs
}),
]),
]);
break
;
}
}
switch
(
type
)
{
case
"
boolean
"
:
return
$el
(
"
div
"
,
[
$el
(
"
label
"
,
{
textContent
:
name
||
id
},
[
$el
(
"
input
"
,
{
type
:
"
checkbox
"
,
checked
:
!!
value
,
oninput
:
(
e
)
=>
{
setter
(
e
.
target
.
checked
);
},
}),
]),
]);
default
:
console
.
warn
(
"
Unsupported setting type, defaulting to text
"
);
return
$el
(
"
div
"
,
[
$el
(
"
label
"
,
{
textContent
:
name
||
id
},
[
$el
(
"
input
"
,
{
value
,
oninput
:
(
e
)
=>
{
setter
(
e
.
target
.
value
);
},
}),
]),
]);
if
(
tooltip
)
{
element
.
title
=
tooltip
;
}
return
element
;
},
});
}
show
()
{
super
.
show
();
Object
.
assign
(
this
.
textElement
.
style
,
{
display
:
"
flex
"
,
flexDirection
:
"
column
"
,
gap
:
"
10px
"
});
this
.
textElement
.
replaceChildren
(...
this
.
settings
.
map
((
s
)
=>
s
.
render
()));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment