Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F8922297
dropdown.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
dropdown.ts
View Options
import
{
Context
}
from
"koa"
;
import
{
tempstream
}
from
"tempstream"
;
import
{
FormField
,
PickFromListField
}
from
"../fields/field"
;
import
{
FormDataValue
}
from
"../form"
;
import
{
FormFieldControl
}
from
"./controls"
;
export
class
Dropdown
extends
FormFieldControl
{
constructor
(
public
field
:
PickFromListField
,
public
options
:
{
label
:
string
;
autosubmit
?:
boolean
;
autocomplete
?:
boolean
;
}
=
{
label
:
field
.
name
,
autosubmit
:
false
,
autocomplete
:
true
,
}
)
{
super
([
field
]);
}
async
render
<
Fields
extends
Record
<
string
,
FormField
>>
(
ctx
:
Context
,
data
:
Record
<
string
,
FormDataValue
>
)
{
const
{
parsed
:
picked_value
}
=
await
this
.
field
.
getValue
(
ctx
,
data
);
const
id
=
this
.
field
.
name
;
return
tempstream
/* HTML */
`<label for="
${
id
}
"
>
${
this
.
options
.
label
}
</label
><select
name="
${
this
.
field
.
name
}
"
id="
${
id
}
"
${
this
.
options
.
autosubmit
?
`onchange='this.form.submit()'`
:
""
}
${
!
this
.
options
.
autocomplete
?
`autocomplete="off"`
:
""
}
>
${
Promise
.
resolve
(
this
.
field
.
generateOptions
(
ctx
)).
then
(
(
options
)
=>
Object
.
entries
(
options
).
map
(
([
value
,
text
])
=>
`<option value="
${
value
}
"
${
(
value
||
""
)
==
picked_value
?
"selected"
:
""
}
>
${
text
}
</option>`
)
)
}
</select>`
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sat, Sep 20, 14:28 (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
932065
Default Alt Text
dropdown.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment