mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 22:16:00 +00:00
43 lines
992 B
Svelte
43 lines
992 B
Svelte
<script lang="ts" context="module">
|
|
import { getContext, setContext } from 'svelte';
|
|
|
|
const contextKey = 'formProviderContextKey';
|
|
|
|
export function getFormContext(): any {
|
|
return getContext(contextKey);
|
|
}
|
|
</script>
|
|
|
|
<script lang="ts">
|
|
import FormFieldTemplateLarge from './FormFieldTemplateLarge.svelte';
|
|
import createRef from '../utility/createRef';
|
|
import { apiCall } from '../utility/api';
|
|
import { useSettings } from '../utility/metadataLoaders';
|
|
import { derived } from 'svelte/store';
|
|
|
|
export let template = FormFieldTemplateLarge;
|
|
|
|
const settings = useSettings();
|
|
const values = derived(settings, $settings => {
|
|
if (!$settings) {
|
|
return {};
|
|
}
|
|
return $settings;
|
|
});
|
|
|
|
const setFieldValue = (name, value) => {
|
|
apiCall('config/update-settings', { [name]: value });
|
|
};
|
|
|
|
const context = {
|
|
values,
|
|
template,
|
|
setFieldValue,
|
|
submitActionRef: createRef(null),
|
|
};
|
|
|
|
setContext(contextKey, context);
|
|
</script>
|
|
|
|
<slot />
|