@@ -3,7 +3,7 @@ import FilterInput from "@/components/FilterInput.vue";
3
3
import { storeToRefs } from " pinia" ;
4
4
import { FieldNames , useAuditStore } from " @/stores/AuditStore.ts" ;
5
5
import ListFilterSelector from " @/components/audit/ListFilterSelector.vue" ;
6
- import { computed , ref , watch } from " vue" ;
6
+ import { computed } from " vue" ;
7
7
import DatePickerRange from " @/components/audit/DatePickerRange.vue" ;
8
8
9
9
const store = useAuditStore ();
@@ -20,8 +20,28 @@ const sortByItemsMap = new Map([
20
20
]);
21
21
const numberOfItemsPerPage = [" 50" , " 100" , " 250" , " 500" ];
22
22
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
+ });
25
45
26
46
function findKeyByValue(searchValue : string ) {
27
47
for (const [key, value] of sortByItemsMap .entries ()) {
@@ -31,28 +51,6 @@ function findKeyByValue(searchValue: string) {
31
51
}
32
52
return " " ;
33
53
}
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
- });
56
54
</script >
57
55
58
56
<template >
0 commit comments