Skip to content

Commit

Permalink
feat(client): support const schema
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jun 23, 2022
1 parent e9c40cc commit e76c1ca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion plugins/frontend/client/client/components/form/primitive.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<template>
<el-switch v-if="schema.type === 'boolean'" v-model="value" :disabled="disabled"></el-switch>
<template v-if="schema.type === 'const'">
{{ schema.value }}
</template>

<el-switch v-else-if="schema.type === 'boolean'" v-model="value" :disabled="disabled"></el-switch>

<template v-else-if="schema.type === 'number'">
<el-slider v-if="schema.meta.role === 'slider'" style="width: 200px"
Expand Down
2 changes: 1 addition & 1 deletion plugins/frontend/client/client/components/form/schema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ watch(config, (value) => {
}, { deep: true })
function isPrimitive(schema: Schema) {
return ['string', 'number', 'boolean'].includes(schema.type)
return ['string', 'number', 'boolean', 'const'].includes(schema.type)
}
function handleCommand(action: string) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/frontend/client/client/components/form/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { clone } from 'cosmokit'
export * from 'cosmokit'
export { Schema }

const primitive = ['string', 'number', 'boolean']
const primitive = ['string', 'number', 'boolean', 'const']
const dynamic = ['function', 'transform']
const composite = ['array', 'dict']

Expand Down

0 comments on commit e76c1ca

Please sign in to comment.