1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-22 07:52:43 +00:00

fix(front): fix TagInput display

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2024-01-05 15:18:18 +01:00
parent 48f57ec1cf
commit 790db906a6
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
3 changed files with 40 additions and 19 deletions

View file

@ -146,6 +146,9 @@ body {
.taginput-item { .taginput-item {
@apply bg-primary mr-2; @apply bg-primary mr-2;
} }
.taginput-autocomplete {
@apply flex-1 !drop-shadow-none;
}
.taginput-item:first-child { .taginput-item:first-child {
@apply ml-2; @apply ml-2;
@ -343,8 +346,8 @@ button.menubar__button {
.o-drop__menu--active { .o-drop__menu--active {
@apply z-50; @apply z-50;
} }
.o-dpck__box { .datepicker-box {
@apply px-4 py-1; @apply block px-4 py-1;
} }
.o-dpck__header { .o-dpck__header {
@apply pb-2 mb-2; @apply pb-2 mb-2;
@ -352,7 +355,7 @@ button.menubar__button {
} }
.o-dpck__header__next, .o-dpck__header__next,
.o-dpck__header__previous { .o-dpck__header__previous {
@apply justify-center text-center no-underline cursor-pointer items-center shadow-none inline-flex relative select-none leading-6 border rounded h-10 p-2 m-1 dark:text-white; @apply justify-center text-center no-underline cursor-pointer items-center shadow-none inline-flex relative select-none leading-6 border rounded h-10 p-2 m-1 dark:text-white hover:px-2;
min-width: 2.25em; min-width: 2.25em;
} }
.o-dpck__header__list { .o-dpck__header__list {

View file

@ -1,15 +1,17 @@
<template> <template>
<o-field :label-for="id"> <o-field :label-for="id" class="taginput-field">
<template #label> <template #label>
{{ $t("Add some tags") }} <p class="inline-flex items-center gap-0.5">
<o-tooltip {{ t("Add some tags") }}
variant="dark" <o-tooltip
:label=" variant="dark"
$t('You can add tags by hitting the Enter key or by adding a comma') :label="
" t('You can add tags by hitting the Enter key or by adding a comma')
> "
<HelpCircleOutline :size="16" /> >
</o-tooltip> <HelpCircleOutline :size="16" />
</o-tooltip>
</p>
</template> </template>
<o-taginput <o-taginput
v-model="tagsStrings" v-model="tagsStrings"
@ -20,8 +22,8 @@
icon="label" icon="label"
:maxlength="20" :maxlength="20"
:maxitems="10" :maxitems="10"
:placeholder="$t('Eg: Stockholm, Dance, Chess…')" :placeholder="t('Eg: Stockholm, Dance, Chess…')"
@input="debouncedGetFilteredTags" @input="getFilteredTags"
:id="id" :id="id"
dir="auto" dir="auto"
> >
@ -31,11 +33,11 @@
<script lang="ts" setup> <script lang="ts" setup>
import differenceBy from "lodash/differenceBy"; import differenceBy from "lodash/differenceBy";
import { ITag } from "../../types/tag.model"; import { ITag } from "../../types/tag.model";
import debounce from "lodash/debounce";
import { computed, onBeforeMount, ref } from "vue"; import { computed, onBeforeMount, ref } from "vue";
import HelpCircleOutline from "vue-material-design-icons/HelpCircleOutline.vue"; import HelpCircleOutline from "vue-material-design-icons/HelpCircleOutline.vue";
import { useFetchTags } from "@/composition/apollo/tags"; import { useFetchTags } from "@/composition/apollo/tags";
import { FILTER_TAGS } from "@/graphql/tags"; import { FILTER_TAGS } from "@/graphql/tags";
import { useI18n } from "vue-i18n";
const props = defineProps<{ const props = defineProps<{
modelValue: ITag[]; modelValue: ITag[];
@ -47,6 +49,8 @@ const text = ref("");
const tags = ref<ITag[]>([]); const tags = ref<ITag[]>([]);
const { t } = useI18n({ useScope: "global" });
let componentId = 0; let componentId = 0;
onBeforeMount(() => { onBeforeMount(() => {
@ -61,14 +65,16 @@ const { load: fetchTags } = useFetchTags();
const getFilteredTags = async (newText: string): Promise<void> => { const getFilteredTags = async (newText: string): Promise<void> => {
text.value = newText; text.value = newText;
const res = await fetchTags(FILTER_TAGS, { filter: newText }); const res = await fetchTags(
FILTER_TAGS,
{ filter: newText },
{ debounce: 200 }
);
if (res) { if (res) {
tags.value = res.tags; tags.value = res.tags;
} }
}; };
const debouncedGetFilteredTags = debounce(getFilteredTags, 200);
const filteredTags = computed((): ITag[] => { const filteredTags = computed((): ITag[] => {
return differenceBy(tags.value, props.modelValue, "id").filter( return differenceBy(tags.value, props.modelValue, "id").filter(
(option) => (option) =>
@ -95,3 +101,8 @@ const tagsStrings = computed({
}, },
}); });
</script> </script>
<style lang="scss" scoped>
:deep(.o-input__wrapper) {
display: initial;
}
</style>

View file

@ -27,6 +27,12 @@ export const orugaConfig = {
taginput: { taginput: {
itemClass: "taginput-item", itemClass: "taginput-item",
rootClass: "taginput", rootClass: "taginput",
autocompleteClasses: {
rootClass: "taginput-autocomplete",
inputClasses: {
inputClass: "taginput-input",
},
},
}, },
autocomplete: { autocomplete: {
rootClass: "autocomplete", rootClass: "autocomplete",
@ -57,6 +63,7 @@ export const orugaConfig = {
datepicker: { datepicker: {
iconNext: "ChevronRight", iconNext: "ChevronRight",
iconPrev: "ChevronLeft", iconPrev: "ChevronLeft",
boxClass: "datepicker-box",
}, },
modal: { modal: {
rootClass: "modal", rootClass: "modal",