-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathControls.vue
More file actions
162 lines (150 loc) · 4.73 KB
/
Copy pathControls.vue
File metadata and controls
162 lines (150 loc) · 4.73 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<script setup>
import ActionButton from "@ogw_front/components/ActionButton.vue";
import SearchBar from "@ogw_front/components/SearchBar.vue";
const { search, sortType, filterOptions, availableFilterOptions, isCollapsed } = defineProps({
search: { type: String, required: true },
sortType: { type: String, required: true },
filterOptions: { type: Object, required: true },
availableFilterOptions: { type: Array, required: true },
isCollapsed: { type: Boolean, required: false, default: false },
});
const emit = defineEmits(["update:search", "toggle-sort", "collapse-all", "expand-all"]);
const showSearch = ref(false);
watch(
() => showSearch.value,
(val) => {
if (!val) {
emit("update:search", "");
}
},
);
</script>
<template>
<v-row dense align="center" class="pa-1 py-0">
<v-col cols="12">
<div
class="controls-capsule d-flex align-center rounded-pill px-1 overflow-hidden"
:class="{ 'is-expanded': showSearch }"
>
<ActionButton
data-testid="searchObjectsButton"
:tooltip="showSearch ? 'Hide search' : 'Show search'"
icon="mdi-magnify"
tooltipLocation="bottom"
variant="text"
color="black"
@click="showSearch = !showSearch"
/>
<v-expand-x-transition>
<div v-if="showSearch" class="flex-grow-1 ms-1 text-no-wrap overflow-hidden">
<SearchBar
data-testid="searchObjectsInput"
:model-value="search"
placeholder="Search objects..."
color="black"
base-color="black"
variant="plain"
density="compact"
prepend-inner-icon=""
autofocus
@update:model-value="emit('update:search', $event)"
/>
</div>
</v-expand-x-transition>
<div class="d-flex align-center">
<v-fade-transition>
<v-divider
v-if="!showSearch"
vertical
inset
class="mx-1 align-self-center"
style="height: 20px"
/>
</v-fade-transition>
<ActionButton
data-testid="sortObjectsButton"
:tooltip="'Sort by ' + (sortType === 'name' ? 'ID' : 'Name')"
:icon="
sortType === 'name' ? 'mdi-sort-alphabetical-ascending' : 'mdi-sort-numeric-ascending'
"
variant="text"
color="black"
tooltipLocation="bottom"
@click="emit('toggle-sort')"
/>
<v-menu :close-on-content-click="false">
<template #activator="{ props: menuProps }">
<ActionButton
data-testid="filterObjectsButton"
tooltip="Filter options"
icon="mdi-filter-variant"
variant="text"
color="black"
tooltipLocation="bottom"
v-bind="menuProps"
/>
</template>
<v-list class="mt-1">
<v-list-item v-for="category_id in availableFilterOptions" :key="category_id">
<v-checkbox
v-model="filterOptions[category_id]"
:label="category_id"
hide-details
density="compact"
:data-testid="'filterCheckbox-' + category_id"
/>
</v-list-item>
</v-list>
</v-menu>
<ActionButton
v-if="!isCollapsed"
data-testid="collapseAllObjectsButton"
tooltip="Collapse All"
icon="mdi-collapse-all-outline"
variant="text"
color="black"
tooltipLocation="bottom"
@click="emit('collapse-all')"
/>
<ActionButton
v-else
data-testid="expandAllObjectsButton"
tooltip="Expand All"
icon="mdi-expand-all-outline"
variant="text"
color="black"
tooltipLocation="bottom"
@click="emit('expand-all')"
/>
</div>
</div>
</v-col>
</v-row>
</template>
<style scoped>
.controls-capsule {
height: 32px;
border: 1px solid transparent;
transition: all 0.3s ease;
width: fit-content;
}
.controls-capsule.is-expanded {
width: 100%;
background-color: rgba(0, 0, 0, 0.05);
border: 1px solid rgba(0, 0, 0, 0.08);
}
.controls-capsule:hover:not(.is-expanded) {
background-color: rgba(0, 0, 0, 0.05);
border: 1px solid rgba(0, 0, 0, 0.08);
}
:deep(.v-field__input) {
padding-top: 0 !important;
padding-bottom: 0 !important;
min-height: 32px !important;
display: flex;
align-items: center;
}
:deep(.v-field__field) {
height: 32px !important;
}
</style>