Skip to content

Commit

Permalink
fixed missing structures in KWIC.
Browse files Browse the repository at this point in the history
+ new Query-Store-persistence-name since the structure changed
  • Loading branch information
lmoertl committed Sep 12, 2024
1 parent 7450bf0 commit a3d220c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/components/DataDisplay/DataDisplayKeywordInContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ function open(item: KeywordInContext) {
const selectedKWIC: Ref<KeywordInContext | null> = ref(null);
const columns = getKWICColumns(t as unknown as (s: string) => string, open);
const columns = computed(() => {
return getKWICColumns(t as unknown as (s: string) => string, open);
});
</script>

<template>
Expand Down
51 changes: 43 additions & 8 deletions src/components/KWIC/KWICAttributeSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ const props = defineProps<{ query: CorpusQuery }>();
const queryStore = useQueryStore();
const _query = queryStore.queries.find((q) => q.id === props.query.id);
const structureOptions = computed(() => {
const options: Array<string> = [];
_query?.KWICAttrsStructsOptions.structures.forEach((structure) => {
if (!structure.name) return;
options.push(structure.name);
if (structure.attributes && _query.KWICAttrsStructs.structures.includes(structure.name)) {
structure.attributes.forEach((attribute) => {
options.push(`${structure.name}.${attribute.name}`);
});
}
});
return options ?? [];
});
const attributeOptions = computed(
() => _query?.KWICAttrsStructsOptions.attributes.map((structure) => structure.name) ?? [],
);
</script>

<template>
Expand All @@ -20,28 +38,45 @@ const _query = queryStore.queries.find((q) => q.id === props.query.id);
<VAutocomplete
v-model="_query.KWICAttrsStructs.attributes"
chips
class="flex-1"
closable-chips
dese
density="compact"
item-title="name"
:items="_query.KWICAttrsStructsOptions.attributes"
:items="attributeOptions"
:label="t('Attributes')"
multiple
placeholer="please select"
return-object
/>
>
<template #item="{ props, item }">

Check warning on line 50 in src/components/KWIC/KWICAttributeSelect.vue

View workflow job for this annotation

GitHub Actions / Validate (20.x, ubuntu-latest)

Variable 'props' is already declared in the upper scope
<VListItem
:class="{ 'ml-4': item.raw.includes('.') }"
density="compact"
v-bind="props"
></VListItem>
</template>
</VAutocomplete>

<VAutocomplete
v-model="_query.KWICAttrsStructs.structures"
chips
class="flex-1"
closable-chips
dese
density="compact"
item-title="name"
:items="_query.KWICAttrsStructsOptions.structures"
:items="structureOptions"
:label="t('Structures')"
multiple
placeholer="please select"
return-object
/>
>
<template #item="{ props, item }">

Check warning on line 71 in src/components/KWIC/KWICAttributeSelect.vue

View workflow job for this annotation

GitHub Actions / Validate (20.x, ubuntu-latest)

Variable 'props' is already declared in the upper scope
<VListItem
checkbox
:class="{ 'ml-4': item.raw.includes('.') }"
density="compact"
v-bind="props"
></VListItem>
</template>
</VAutocomplete>
</div>
</div>
</template>
6 changes: 3 additions & 3 deletions src/stores/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const emptySelectedCorpusKWICViewInfo: KWICAttrsStructs = {
};

export const useQueryStore = defineStore(
"newQueryStore",
"QueryStoreWithNewStructure",
() => {
const nextQueryId = ref(0);
const queries = ref([]) as Ref<Array<CorpusQuery>>;
Expand Down Expand Up @@ -85,8 +85,8 @@ export const useQueryStore = defineStore(
}

const getKWICqueryAttrStrcs = (query: CorpusQuery) => ({
attrs: query.KWICAttrsStructs.attributes.map((attr) => attr.name).join(","),
structs: query.KWICAttrsStructs.structures.map((struct) => struct.name).join(","),
attrs: query.KWICAttrsStructs.attributes.join(","),
structs: query.KWICAttrsStructs.structures.join(","),
});

const getQueryWithFacetting = (query: CorpusQuery) => {
Expand Down
8 changes: 6 additions & 2 deletions src/types/query.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,14 @@ interface KWICStructure {
size?: number | undefined;
}
interface KWICAttrsStructs {
attributes: Array<string>;
structures: Array<string>;
}

interface KWICAttrsStructsOptions {
attributes: Array<KWICAttribute>;
structures: Array<KWICStructure>;
}

type ConcordanceQuery = Record<"queryselector", CorpusQueryType> &
Record<CorpusQueryTypeValue, string>;

Expand All @@ -87,7 +91,7 @@ interface CorpusQuery {
subCorpus: string;
concordance_query: ConcordanceQuery;
KWICAttrsStructs: KWICAttrsStructs;
KWICAttrsStructsOptions: KWICAttrsStructs; // ToDo: this might be refactored to come via requesat whenever needed.
KWICAttrsStructsOptions: KWICAttrsStructsOptions; // ToDo: this might be refactored to come via requesat whenever needed.
facettingValues: FacettingValues;
loading: {
yearlyFrequencies: boolean;
Expand Down

0 comments on commit a3d220c

Please sign in to comment.