Skip to content

Commit

Permalink
fix #68
Browse files Browse the repository at this point in the history
  • Loading branch information
gheorghelupu17 committed Jun 30, 2023
1 parent 8d3f180 commit 68b5739
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
23 changes: 19 additions & 4 deletions resources/js/Components/form/Select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class="flex gap-x-1"
>
<li v-if="selectedOption">
{{ selectedOption.name ? selectedOption.name : selectedOption }}
{{ computedName(selectedOption) }}
</li>
</ul>
</ComboboxButton>
Expand All @@ -34,8 +34,8 @@
v-slot="{ active, selected }"
>
<li :class="['relative cursor-default select-none py-2 pl-3 pr-9', active ? 'bg-primary-500 text-white' : 'text-gray-900']">
<span :class="['block truncate', selected && 'font-semibold']">
{{ option.name ? option.name : option }}
<span :class="['block truncate', selected && 'font-semibold']" >
{{ computedName(option)}}
</span>

<span v-if="selected" :class="['absolute inset-y-0 right-0 flex items-center pr-4', active ? 'text-white' : 'text-primary-500']">
Expand All @@ -53,11 +53,12 @@

<script setup>
/** Import form vue. */
import { computed, ref, watch } from 'vue';
import { computed, ref, watch } from 'vue';
/** Import plugins. */
import { CheckIcon, ChevronUpDownIcon } from '@heroicons/vue/20/solid';
import { Combobox, ComboboxButton, ComboboxInput, ComboboxLabel, ComboboxOption, ComboboxOptions } from '@headlessui/vue';
import {useI18n} from "vue-i18n";
/** Component props. */
const props = defineProps({
Expand All @@ -68,8 +69,13 @@
isDisabled: {
type: Boolean,
disabled: false
},
useTranslation: {
type: Boolean,
default: false
}
});
const { t } = useI18n();
/** Query input. */
const query = ref('');
Expand All @@ -87,6 +93,15 @@
})
);
const computedName = (option) => {
let name = option.name ? option.name : option
if (props.useTranslation) {
return t(name);
}
return name;
}
/** Watch changes in selected options. */
watch(selectedOption, (newVal, oldVal) => {
if (newVal != oldVal) {
Expand Down
1 change: 1 addition & 0 deletions resources/js/Pages/AdminOng/Projects/AddProject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
class="w-full xl:w-1/2"
:label="$t('project_category_label')"
:options="projectCategories"
use-translation="true"
v-model="form.category"
:error="form.errors.category"
/>
Expand Down
10 changes: 9 additions & 1 deletion resources/js/locales/ro.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,13 @@ export default {
"regional_winners": "Etapa desemnare castigatori",
"regional_finished": "Editie incheiata",
"articles_title": "Articole",
"article_title": "Articol"
"article_title": "Articol",
"social-entrepreneurship": "Antreprenoriat social",
"human-rights": "Drepturile omului",
"education": "Educație",
"health": "Sănătate",
"environment": "Mediu",
"social": "Social",
"animal-protection": "Protecția animalelor",
"sport": "Sport",
}

0 comments on commit 68b5739

Please sign in to comment.