Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to get suggestion labels in Northern Sami #18

Open
wants to merge 3 commits into
base: update-2024
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ai.finto.fi/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ <h3>{{ $t('suggestions_label') }}</h3>

<project-select v-model="selected_project" :projects="projects"></project-select>
<limit-input v-model="limit"></limit-input><br>
<language-select v-model="language"></language-select>
<language-select v-model="language" :selected_project="selected_project"></language-select>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming selected_project to selectedProject did not affect the props name on line 439.


<div class="d-grid justify-content-end">
<button id="get-suggestions" type="button" class="btn btn-primary"
Expand Down
34 changes: 28 additions & 6 deletions ai.finto.fi/static/js/annif.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ mainApp.component('project-select', {
},
computed: {
vocabularyId() {
// TODO: This is a hack. We should expose the vocabulary id from Annif API.
// Assume vocabulary id is a prefix of project id
if (this.selectedProject && this.selectedProject.project_id) {
// Assume vocabulary id is a prefix of project id
Expand Down Expand Up @@ -435,23 +436,44 @@ mainApp.component('limit-input', {
})

mainApp.component('language-select', {
props: ['modelValue'], // modelValue: selected language
props: ['modelValue', 'selected_project'],
emits: ['update:modelValue'],
computed: {
vocabularyId() {
// TODO: This is a hack. We should expose the vocabulary id from Annif API.
// Why project is here the project_id string?
// Assume vocabulary id is a prefix
if (this.selected_project) {
return this.selected_project.split("-")[0];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not use camelCased name selectedProject in this method/component, but only selected_project worked.

}
return '';
},
disabledLanguages() {
// Map of languages and their enabling criteria based on vocabularyId
return {
se: this.vocabularyId !== 'yso', // 'se' enabled only if vocabularyId is 'yso'
};
}
},
methods: {
isOptionDisabled(language) {
return this.disabledLanguages[language] || false; // Default to false if not specified in map
}
},
template: `
<label class="suggest-form-label form-label" for="label-language">{{ $t('language_select_label') }}</label>
<div class="select-wrapper">
<select class="form-control" id="label-language"
:value="modelValue"
@change="$emit('update:modelValue', $event.target.value)"
>
<select class="form-control" id="label-language" :value="modelValue"
@change="$emit('update:modelValue', $event.target.value)">
<option value="project-language">{{ $t('language_select_project') }}</option>
<option value="fi">{{ $t('language_select_fi') }}</option>
<option value="sv">{{ $t('language_select_sv') }}</option>
<option value="en">{{ $t('language_select_en') }}</option>
<option :disabled="isOptionDisabled('se')" value="se">{{ $t('language_select_sm') }}</option>
</select>
</div>
`
})
});

mainApp.component('result-list', {
props: ['results', 'language', 'selected_project', 'projects'],
Expand Down
3 changes: 3 additions & 0 deletions ai.finto.fi/static/js/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const messages = {
language_select_fi: "suomi",
language_select_sv: "ruotsi",
language_select_en: "englanti",
language_select_sm: "pohjoissaame",
get_suggestions: "Anna aihe-ehdotukset",
suggestions_heading: "Ehdotukset",
copy_heading: "Kopioi",
Expand Down Expand Up @@ -126,6 +127,7 @@ const messages = {
language_select_fi: "Finnish",
language_select_sv: "Swedish",
language_select_en: "English",
language_select_sm: "Northern Sami",
get_suggestions: "Get subject suggestions",
suggestions_heading: "Suggestions",
copy_heading: "Copy",
Expand Down Expand Up @@ -207,6 +209,7 @@ const messages = {
language_select_fi: "finska",
language_select_sv: "svenska",
language_select_en: "engelska",
language_select_sm: "nordsamiska",
get_suggestions: "Ge förslag till ämnesord",
suggestions_heading: "Förslag",
copy_heading: "kopiera",
Expand Down