Skip to content

Commit 37c96b1

Browse files
authored
Make calculated models clearer (#2349)
* simplify calculated models by using writable calculated * fix filterinput styling to use ems/rems * make item separator look the same as dashboard etc.
1 parent d3e8b60 commit 37c96b1

File tree

3 files changed

+41
-46
lines changed

3 files changed

+41
-46
lines changed

src/Frontend/src/components/FilterInput.vue

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
<script setup lang="ts">
2-
import { ref, watch } from "vue";
2+
import { computed } from "vue";
33
import debounce from "lodash/debounce";
44
55
const model = defineModel<string>({ required: true });
66
const props = withDefaults(defineProps<{ placeholder?: string; ariaLabel?: string }>(), { placeholder: "Filter by name...", ariaLabel: "Filter by name" });
7-
const localInput = ref<string>(model.value);
7+
const localInput = computed({
8+
get() {
9+
return model.value;
10+
},
11+
set(newValue) {
12+
debounceUpdateModel(newValue);
13+
},
14+
});
815
916
const debounceUpdateModel = debounce((value: string) => {
1017
model.value = value;
1118
}, 600);
12-
13-
watch(model, (newValue) => {
14-
localInput.value = newValue;
15-
});
16-
17-
watch(localInput, (newValue) => {
18-
debounceUpdateModel(newValue);
19-
});
2019
</script>
2120

2221
<template>
@@ -29,16 +28,16 @@ watch(localInput, (newValue) => {
2928
.filter-input input {
3029
display: inline-block;
3130
width: 100%;
32-
padding-right: 10px;
33-
padding-left: 30px;
31+
padding-right: 0.625rem;
32+
padding-left: 2em;
3433
border: 1px solid #aaa;
3534
border-radius: 4px;
3635
height: 100%;
3736
}
3837
3938
div.filter-input {
4039
position: relative;
41-
height: 36px;
40+
height: 2.6em;
4241
}
4342
4443
.filter-input:before {

src/Frontend/src/components/audit/AuditList.vue

+6-8
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ function setQuery() {
161161
<div class="processing-time"><span class="label-name">Processing Time:</span>{{ formatDotNetTimespan(message.processing_time) }}</div>
162162
<div class="delivery-time"><span class="label-name">Delivery Time:</span>{{ formatDotNetTimespan(message.delivery_time) }}</div>
163163
</div>
164-
<div class="spacer"></div>
165164
</template>
166165
</div>
167166
</div>
@@ -185,14 +184,10 @@ function setQuery() {
185184
margin-bottom: 5rem;
186185
background-color: #ffffff;
187186
}
188-
.spacer {
189-
border-bottom: 1px solid #b1afaf;
190-
margin-top: 0.1rem;
191-
margin-bottom: 0.1rem;
192-
}
193187
.item {
194-
padding: 3px;
188+
padding: 0.3rem 0.2rem;
195189
border: 1px solid #ffffff;
190+
border-bottom: 1px solid #eee;
196191
display: grid;
197192
grid-template-columns: 1.8em 1fr 1fr 1fr 1fr;
198193
grid-template-rows: 1fr 1fr;
@@ -201,8 +196,11 @@ function setQuery() {
201196
"status message-type message-type message-type time-sent"
202197
"status message-id processing-time critical-time delivery-time";
203198
}
199+
.item:not(:first-child) {
200+
border-top-color: #eee;
201+
}
204202
.item:hover {
205-
border: 1px solid #00a3c4;
203+
border-color: #00a3c4;
206204
background-color: #edf6f7;
207205
cursor: pointer;
208206
}

src/Frontend/src/components/audit/FiltersPanel.vue

+23-25
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import FilterInput from "@/components/FilterInput.vue";
33
import { storeToRefs } from "pinia";
44
import { FieldNames, useAuditStore } from "@/stores/AuditStore.ts";
55
import ListFilterSelector from "@/components/audit/ListFilterSelector.vue";
6-
import { computed, ref, watch } from "vue";
6+
import { computed } from "vue";
77
import DatePickerRange from "@/components/audit/DatePickerRange.vue";
88
99
const store = useAuditStore();
@@ -20,8 +20,28 @@ const sortByItemsMap = new Map([
2020
]);
2121
const numberOfItemsPerPage = ["50", "100", "250", "500"];
2222
const sortByItems = computed(() => [...sortByItemsMap.keys()]);
23-
const selectedSortByItem = ref(findKeyByValue(`${sortBy.value.property},${sortBy.value.isAscending ? "asc" : "desc"}`));
24-
const selectedItemsPerPage = ref(itemsPerPage.value.toString());
23+
const selectedSortByItem = computed({
24+
get() {
25+
return findKeyByValue(`${sortBy.value.property},${sortBy.value.isAscending ? "asc" : "desc"}`);
26+
},
27+
set(newValue) {
28+
const item = sortByItemsMap.get(newValue);
29+
if (item) {
30+
const strings = item.split(",");
31+
sortBy.value = { isAscending: strings[1] === "asc", property: strings[0] };
32+
} else {
33+
sortBy.value = { isAscending: true, property: FieldNames.TimeSent };
34+
}
35+
},
36+
});
37+
const selectedItemsPerPage = computed({
38+
get() {
39+
return itemsPerPage.value.toString();
40+
},
41+
set(newValue) {
42+
itemsPerPage.value = parseInt(newValue);
43+
},
44+
});
2545
2646
function findKeyByValue(searchValue: string) {
2747
for (const [key, value] of sortByItemsMap.entries()) {
@@ -31,28 +51,6 @@ function findKeyByValue(searchValue: string) {
3151
}
3252
return "";
3353
}
34-
35-
watch(itemsPerPage, (newValue) => {
36-
selectedItemsPerPage.value = newValue.toString();
37-
});
38-
39-
watch(sortBy, (newValue) => {
40-
selectedSortByItem.value = findKeyByValue(`${newValue.property},${newValue.isAscending ? "asc" : "desc"}`);
41-
});
42-
43-
watch(selectedItemsPerPage, (newValue) => {
44-
itemsPerPage.value = parseInt(newValue, 10);
45-
});
46-
47-
watch(selectedSortByItem, (newValue) => {
48-
const item = sortByItemsMap.get(newValue);
49-
if (item) {
50-
const strings = item.split(",");
51-
sortBy.value = { isAscending: strings[1] === "asc", property: strings[0] };
52-
} else {
53-
sortBy.value = { isAscending: true, property: FieldNames.TimeSent };
54-
}
55-
});
5654
</script>
5755

5856
<template>

0 commit comments

Comments
 (0)