Skip to content

Commit

Permalink
route to documentview from query results now working as expected. How…
Browse files Browse the repository at this point in the history
…ever, 'clearQueryResults' isn't
  • Loading branch information
fmatthies committed Dec 13, 2023
1 parent 5c812da commit 27386ce
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 46 deletions.
4 changes: 3 additions & 1 deletion src/boot/axios.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { boot } from 'quasar/wrappers'
import axios, { AxiosInstance, AxiosStatic } from 'axios'
import { DocumentApi, PhraseApi, ConceptclusterApi, DefaultApi, EntityApi, OrganisationApi, QueryApi, RepositoryApi, UserApi, CodeApi } from '@onto-med/top-api'
import { DocumentApi, PhraseApi, ConceptclusterApi, DefaultApi, EntityApi, OrganisationApi, QueryApi, RepositoryApi, UserApi, CodeApi, ConceptgraphsApi } from '@onto-med/top-api'
import { InjectionKey } from 'vue'
import { Keycloak } from '@dsb-norge/vue-keycloak-js/dist/types'
import { env } from 'src/config'
Expand All @@ -20,6 +20,7 @@ export const QueryApiKey: InjectionKey<QueryApi> = Symbol('queryApi')
export const DocumentApiKey: InjectionKey<DocumentApi> = Symbol('documentApi')
export const PhraseApiKey: InjectionKey<PhraseApi> = Symbol('phraseApi')
export const ConceptClusterApiKey: InjectionKey<ConceptclusterApi> = Symbol('conceptClusterApi')
export const ConceptGraphApiKey: InjectionKey<ConceptgraphsApi> = Symbol('conceptGraphApi')
export const UserApiKey: InjectionKey<UserApi> = Symbol('userApi')
export const CodeApiKey: InjectionKey<CodeApi> = Symbol('codeApi')

Expand Down Expand Up @@ -47,6 +48,7 @@ export default boot(({ app }) => {
app.provide(DocumentApiKey, new DocumentApi(undefined, '', axiosInstance))
app.provide(PhraseApiKey, new PhraseApi(undefined, '', axiosInstance))
app.provide(ConceptClusterApiKey, new ConceptclusterApi(undefined, '', axiosInstance))
app.provide(ConceptGraphApiKey, new ConceptgraphsApi(undefined, '', axiosInstance))
app.provide(UserApiKey, new UserApi(undefined, '', axiosInstance))
app.provide(CodeApiKey, new CodeApi(undefined, '', axiosInstance))
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/Documents/SearchQueryForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ async function reload(filter: string|undefined = undefined, page = 1) {
queryDisplayName.value = ''
})
} else {
queryDisplayName.value = props.queryName? props.queryName: ''
await documentApi.getDocumentsForQuery(props.organisationId, props.repositoryId, props.queryId, page)
.then(r => documents.value = r.data)
.catch((e: Error) => renderError(e))
.finally(() => {
loading.value = false
querySearch.value = true
queryDisplayName.value = props.queryName? props.queryName: ''
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Query/QueryResultsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ export default defineComponent({
params: {
organisationId: organisationId.value,
repositoryId: repositoryId.value,
queryId: query.id
queryId: query.id,
queryName: query.name,
},
query: {
queryName: query.name,
searchType: SearchTypesEnum.SEARCH_QUERY
}
})
Expand Down
68 changes: 28 additions & 40 deletions src/pages/DocumentSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,38 @@
<script setup lang="ts">
import ConceptClusterForm from 'components/Documents/ConceptClusterForm.vue'
import SearchQueryForm from 'components/Documents/SearchQueryForm.vue'
import { useI18n } from 'vue-i18n'
import { computed, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { SearchTypesEnum } from 'src/config'
import { watch } from 'vue'
import {useI18n} from 'vue-i18n'
import {computed, ref, watch} from 'vue'
import {useRouter} from 'vue-router'
import {SearchTypesEnum} from 'src/config'
const props = defineProps({
initialSearchType: {
type: String as () => SearchTypesEnum,
default: SearchTypesEnum.CONCEPT_CLUSTER
}
},
organisationId: {
type: String,
default: undefined
},
repositoryId: {
type: String,
default: undefined
},
queryId: {
type: String,
default: undefined
},
queryName: {
type: String,
default: undefined
},
})
const { t } = useI18n()
const route = useRoute()
const router = useRouter()
const queryId = ref<string|undefined>(undefined)
const organisationId = ref<string|undefined>(undefined)
const repositoryId = ref<string|undefined>(undefined)
const queryName = ref<string|undefined>(undefined)
const searchType = ref(props.initialSearchType)
const searchTypeOptions = computed(() =>
const searchTypeOptions = computed(() =>
Object.values(SearchTypesEnum)
.map(st => ({ label: t(st), value: st }))
)
Expand All @@ -75,33 +85,11 @@ async function setSearchTypeInRouteQuery(searchType: SearchTypesEnum) {
await router.replace({ name: 'documentSearch', query: { searchType } })
}
function setSearchType(set?: SearchTypesEnum) {
organisationId.value = undefined
repositoryId.value = undefined
queryId.value = undefined
queryName.value = undefined
if (set) {
searchType.value = set
return
}
if (
route.params.hasOwnProperty('organisationId')
&& route.params.hasOwnProperty('repositoryId')
&& route.params.hasOwnProperty('queryId')
) {
organisationId.value = route.params.organisationId.toString()
repositoryId.value = route.params.repositoryId.toString()
queryId.value = route.params.queryId.toString()
queryName.value = route.query.queryName ? route.query.queryName.toString() : 'Query'
searchType.value = SearchTypesEnum.SEARCH_QUERY
} else {
searchType.value = SearchTypesEnum.CONCEPT_CLUSTER
}
}
function clearQueryResults() {
setSearchType(SearchTypesEnum.SEARCH_QUERY)
async function clearQueryResults() {
await router.replace(
{
name: 'documentSearch',
query: { searchType: SearchTypesEnum.SEARCH_QUERY },
})
}
</script>
4 changes: 2 additions & 2 deletions src/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const routes: RouteRecordRaw[] = [
},
{
name: 'documentSearchByQuery',
path: '/document/query/:organisationId/:repositoryId/:queryId',
path: '/document/query/:organisationId/:repositoryId/:queryId/:queryName',
component: () => import('pages/DocumentSearch.vue'),
meta: {
disabled: !env.DOCUMENTS_ENABLED
Expand All @@ -61,7 +61,7 @@ const routes: RouteRecordRaw[] = [
organisationId: params.organisationId,
repositoryId: params.repositoryId,
queryId: params.queryId,
queryName: query.queryName,
queryName: params.queryName,
initialSearchType: query.searchType
}
}
Expand Down

0 comments on commit 27386ce

Please sign in to comment.