-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
<script setup lang="ts"> | ||
import { computed } from "vue"; | ||
import { useI18n } from "vue-i18n"; | ||
import { useRouter } from "vue-router"; | ||
import Yaml from "js-yaml"; | ||
import { FormEvent } from "react"; | ||
Check failure on line 4 in src/corpus/config/SchemaConfig.vue GitHub Actions / build (18.x)
Check failure on line 4 in src/corpus/config/SchemaConfig.vue GitHub Actions / build (20.x)
|
||
import schema from "@/assets/sparvconfig.schema.json"; | ||
import useCorpusIdParam from "@/corpus/corpusIdParam.composable"; | ||
import useMessenger from "@/message/messenger.composable"; | ||
import useConfig from "@/corpus/config/config.composable"; | ||
import JsonSchemaForm from "@/components/JsonSchemaForm.vue"; | ||
const router = useRouter(); | ||
const corpusId = useCorpusIdParam(); | ||
const { config, uploadConfig } = useConfig(corpusId); | ||
const { alert, alertError } = useMessenger(); | ||
const { t } = useI18n(); | ||
const { config, uploadConfigRaw } = useConfig(corpusId); | ||
const configParsed = computed(() => | ||
config.value ? Yaml.load(config.value) : undefined, | ||
); | ||
async function onSubmit(event: FormEvent) { | ||
const configYaml = Yaml.dump(event.formData); | ||
await uploadConfigRaw(configYaml); | ||
} | ||
</script> | ||
|
||
<template> | ||
<JsonSchemaForm v-if="configParsed" :schema="schema" :data="configParsed" /> | ||
<JsonSchemaForm | ||
v-if="configParsed" | ||
:schema="schema" | ||
:data="configParsed" | ||
:on-submit="onSubmit" | ||
/> | ||
</template> |