aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/blubber/SearchWidget.vue
blob: 1a5ef525767700a4053444b77c7cd9a0eed0799b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<template>
    <SidebarWidget :title="$gettext('Suche')">
        <template #content>
            <form action="?#" method="get" class="sidebar-search">
                <input v-for="(val, key) in urlParams" :key="key" type="hidden" :name="key" :value="val">
                <ul class="needles">
                    <li>
                        <div class="input-group files-search">
                            <label :for="inputId" class="sr-only">{{ $gettext('Suche nach …') }}</label>
                            <input
                                type="text"
                                :id="inputId"
                                name="search"
                                :value="search"
                                :placeholder="$gettext('Suche nach …')"
                            />

                            <a
                                v-if="search"
                                class="reset-search"
                                :href="urlReset"
                                tabindex="0"
                                role="button"
                                :title="$gettext('Suche zurücksetzen')"
                            >
                                <studip-icon shape="decline" alt="" />
                            </a>

                            <button type="submit" class="submit-search" :title="$gettext('Suche ausführen')">
                                <studip-icon shape="search" alt="" />
                            </button>
                        </div>
                    </li>
                </ul>
            </form>
        </template>
    </SidebarWidget>
</template>

<script>
import SidebarWidget from '../SidebarWidget.vue';

let nextId = 0;

export default {
    props: {
        search: {
            type: String,
            default: '',
        },
    },
    components: {
        SidebarWidget,
    },
    data: () => ({
        inputId: ++nextId,
    }),
    computed: {
        urlReset() {
            return STUDIP.URLHelper.getURL('dispatch.php/blubber');
        },
        urlParams() {
            return STUDIP.URLHelper.parameters;
        }
    },
};
</script>