@@ -3,7 +3,7 @@ import FilterInput from "@/components/FilterInput.vue";
33import { storeToRefs } from " pinia" ;
44import { FieldNames , useAuditStore } from " @/stores/AuditStore.ts" ;
55import ListFilterSelector from " @/components/audit/ListFilterSelector.vue" ;
6- import { computed , ref , watch } from " vue" ;
6+ import { computed } from " vue" ;
77import DatePickerRange from " @/components/audit/DatePickerRange.vue" ;
88
99const store = useAuditStore ();
@@ -20,8 +20,28 @@ const sortByItemsMap = new Map([
2020]);
2121const numberOfItemsPerPage = [" 50" , " 100" , " 250" , " 500" ];
2222const 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
2646function 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