-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial mtb domains, pages etc + initial type refactoring + fix…
… page schema generation
- Loading branch information
Showing
40 changed files
with
714 additions
and
86 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
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
Empty file.
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { URLQueryRecord } from '@dnpm-dip/core'; | ||
import { | ||
createResourceRecordManager, | ||
} from '@dnpm-dip/core'; | ||
import type { PropType } from 'vue'; | ||
import { defineComponent, toRef } from 'vue'; | ||
import { useMTBAPIClient } from '#imports'; | ||
|
||
export default defineComponent({ | ||
props: { | ||
queryId: { | ||
type: String, | ||
required: true, | ||
}, | ||
queryRecord: { | ||
type: Object as PropType<URLQueryRecord>, | ||
}, | ||
lazy: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}, | ||
async setup(props, setup) { | ||
const apiClient = useMTBAPIClient(); | ||
const id = toRef(props, 'queryId'); | ||
|
||
const manager = createResourceRecordManager({ | ||
load: (id) => apiClient.query.getSummary(id, props.queryRecord), | ||
slots: setup.slots, | ||
id, | ||
}); | ||
|
||
if (props.lazy) { | ||
Promise.resolve() | ||
.then(() => manager.load()); | ||
} else { | ||
await manager.load(); | ||
} | ||
|
||
return () => manager.render(); | ||
}, | ||
}); |
147 changes: 147 additions & 0 deletions
147
packages/mtb/src/runtime/components/core/MSearchForm.vue
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 |
---|---|---|
@@ -0,0 +1,147 @@ | ||
<script lang="ts"> | ||
import type { CodeSystemConcept, ValueSetCoding } from '@dnpm-dip/core'; | ||
import { | ||
QueryRequestMode, | ||
} from '@dnpm-dip/core'; | ||
import type { FormSelectOption } from '@vuecs/form-controls'; | ||
import type { PropType } from 'vue'; | ||
import { | ||
defineComponent, ref, | ||
} from 'vue'; | ||
import { useMTBAPIClient } from '#imports'; | ||
export default defineComponent({ | ||
props: { | ||
queryId: { | ||
type: String, | ||
}, | ||
queryMode: { | ||
type: String as PropType<QueryRequestMode>, | ||
}, | ||
}, | ||
emits: [ | ||
'failed', | ||
'preparedQueryCreated', | ||
'preparedQueryUpdated', | ||
'queryCreated', | ||
'queryUpdated', | ||
], | ||
async setup(props, { emit, expose }) { | ||
const apiClient = useMTBAPIClient(); | ||
const mode = ref<QueryRequestMode>(QueryRequestMode.FEDERATED); | ||
const modeOptions : FormSelectOption[] = [ | ||
{ id: QueryRequestMode.LOCAL, value: 'Lokal' }, | ||
{ id: QueryRequestMode.FEDERATED, value: 'Föderiert' }, | ||
]; | ||
const busy = ref(false); | ||
const reset = async () => { | ||
if (busy.value) return; | ||
busy.value = true; | ||
busy.value = false; | ||
}; | ||
expose({ | ||
reset, | ||
}); | ||
Promise.resolve() | ||
.then(() => reset()); | ||
const submit = async () => { | ||
if (busy.value) return; | ||
busy.value = true; | ||
const payload = {}; | ||
try { | ||
let query : any; | ||
if (props.queryId) { | ||
query = await apiClient.query.update(props.queryId, { | ||
criteria: payload, | ||
mode: { | ||
code: mode.value, | ||
}, | ||
}); | ||
emit('queryUpdated', query); | ||
} else { | ||
query = await apiClient.query.submit({ | ||
criteria: payload, | ||
mode: { | ||
code: mode.value, | ||
}, | ||
}); | ||
emit('queryCreated', query); | ||
} | ||
} catch (e) { | ||
if (e instanceof Error) { | ||
emit('failed', e); | ||
} | ||
} finally { | ||
busy.value = false; | ||
} | ||
}; | ||
const transformCodings = (coding: ValueSetCoding) => ({ | ||
id: coding.code, | ||
value: coding.display ? `${coding.code}: ${coding.display}` : coding.code, | ||
}); | ||
const transformConcepts = (concept: CodeSystemConcept) => ({ | ||
id: concept.code, | ||
value: `${concept.properties.Symbol}: ${concept.display}`, | ||
}); | ||
return { | ||
mode, | ||
modeOptions, | ||
busy, | ||
submit, | ||
}; | ||
}, | ||
}); | ||
</script> | ||
<template> | ||
<div> | ||
<form> | ||
<div> | ||
<h6>Suchmodus</h6> | ||
|
||
<VCFormSelect | ||
v-model="mode" | ||
:options="modeOptions" | ||
:option-default="false" | ||
/> | ||
</div> | ||
|
||
<hr> | ||
|
||
<div> | ||
<div class="row"> | ||
<div class="col"> | ||
<button | ||
:disabled="busy" | ||
type="button" | ||
class="btn btn-block btn-dark" | ||
@click.prevent="submit()" | ||
> | ||
<i class="fa fa-search me-1" /> Suchen | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</template> |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { APIClient } from '@dnpm-dip/core'; | ||
import { useNuxtApp } from '#imports'; | ||
import type { MTBAPIClient } from '../core/api-client'; | ||
|
||
export function useAPIClient() { | ||
return useNuxtApp().$api as APIClient; | ||
} | ||
export function useMTBAPIClient() { | ||
return useNuxtApp().$mtbApi as MTBAPIClient; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export { | ||
useAPIClient, | ||
useMTBAPIClient, | ||
} from './api-client'; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './module'; |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { APIClient } from '@dnpm-dip/core'; | ||
import { | ||
QueryAPI, | ||
} from '../../domains'; | ||
|
||
export class MTBAPIClient { | ||
readonly query : QueryAPI; | ||
|
||
constructor(client: APIClient) { | ||
this.query = new QueryAPI({ client }); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './query'; |
Oops, something went wrong.