Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22396450
shared-crud-form-fields.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
shared-crud-form-fields.ts
View Options
import
{
toPascalCase
}
from
"js-convert-case"
;
import
_locreq
from
"locreq"
;
import
extract_fields_from_collection
from
"../../utils/extract-fields-from-collection.js"
;
import
{
formatWithPrettier
}
from
"../../utils/prettier.js"
;
import
{
wrapAttribute
}
from
"../../utils/wrap-attributes.js"
;
export
async
function
sharedCrudFormFields
(
collection_name
:
string
,
newfilefullpath
:
string
)
{
const
collection_fields
=
await
extract_fields_from_collection
(
collection_name
);
const
uppercase_collection
=
toPascalCase
(
collection_name
);
const
result
=
`import { Controls, Fields } from "@sealcode/sealgen";
import {
${
uppercase_collection
}
} from "src/back/collections/collections.js";
export const
${
toPascalCase
(
collection_name
)
}
FormFields = <const>{
${
collection_fields
.
map
((
field_info
)
=>
{
return
`
${
field_info
.
name
}
:
${
field_info
.
form_field
.
generateFieldDeclaration
(
field_info
,
{
form_field_types
:
"Fields"
,
sealious_field
:
`
${
uppercase_collection
}
.fields
${
wrapAttribute
(
field_info
.
name
)
}
`
,
}
)}`
;
}
)
.join(",\n")}
};
const fields =
${
toPascalCase
(
collection_name
)
}
FormFields
export const get
${
toPascalCase
(
collection_name
)
}
FormControls = ()=> [
${
collection_fields
.
map
(({
name
}
) => `
fields$
{
wrapAttribute
(
name
)}.
getControl
()
`)
.join(",\n")}
];
`
;
return
formatWithPrettier
(
result
);
}
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 16:46 (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1229146
Default Alt Text
shared-crud-form-fields.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline