Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22395943
coordinates.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
coordinates.ts
View Options
import
{
Context
}
from
"koa"
;
import
{
FormControl
,
FormControlContext
}
from
"../controls/form-control.js"
;
import
{
SimpleInput
}
from
"../controls/simple-input.js"
;
import
{
FormDataValue
}
from
"../form-types.js"
;
import
{
FieldParseResult
}
from
"./field.js"
;
import
{
SimpleFormField
}
from
"./simple-form-field.js"
;
export
class
Coordinates
<
Required
extends
boolean
,
DefaultControl
extends
FormControl
=
SimpleInput
,
>
extends
SimpleFormField
<
Required
,
DefaultControl
,
[
number
,
number
]
>
{
async
parse
(
_
:
Context
,
raw_value
:
FormDataValue
)
:
Promise
<
FieldParseResult
<
[
number
,
number
]
>>
{
if
(
typeof
raw_value
==
"string"
)
{
return
{
parsed_value
:
raw_value
?
.
split
(
","
)
.
map
((
e
)
=>
parseFloat
(
e
))
as
[
number
,
number
],
parsable
:
true
,
error
:
null
,
};
}
if
(
Array
.
isArray
(
raw_value
))
{
return
{
parsed_value
:
raw_value
.
map
((
e
)
=>
parseFloat
(
e
))
as
[
number
,
number
,
],
parsable
:
true
,
error
:
null
,
};
}
return
{
parsed_value
:
null
,
parsable
:
false
,
error
:
"should be an array or string"
,
};
}
async
getSealiousCreateValue
(
fctx
:
FormControlContext
)
:
Promise
<
[
number
,
number
]
|
undefined
>
{
const
{
parsed
}
=
await
this
.
getParsedValue
(
fctx
.
ctx
,
fctx
.
data
.
raw_values
);
return
parsed
||
undefined
;
}
async
postSealiousCreate
()
:
Promise
<
void
>
{}
async
postSealiousEdit
()
:
Promise
<
void
>
{}
getControl
()
:
DefaultControl
{
return
new
SimpleInput
(
this
,
{
label
:
this
.
label
||
this
.
name
,
type
:
this
.
type
,
})
as
unknown
as
DefaultControl
;
}
public
getEmptyValue
()
:
[
number
,
number
]
{
return
[
0
,
0
];
}
}
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 16:30 (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1200151
Default Alt Text
coordinates.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline