Explorar o código

replace filter-related function props with a field prop, fix min-height

Jason Gorst hai 1 mes
pai
achega
43cbf9cc19
Modificáronse 1 ficheiros con 14 adicións e 20 borrados
  1. 14 20
      app/components/OptionsFilter.vue

+ 14 - 20
app/components/OptionsFilter.vue

@@ -1,11 +1,11 @@
 <template>
 <template>
-  <div class="flex min-h-56.5 flex-col justify-between gap-2">
+  <div class="flex min-h-57 flex-col justify-between gap-2">
     <Listbox
     <Listbox
       v-model="model"
       v-model="model"
       :options="options"
       :options="options"
       multiple
       multiple
       scrollHeight="12rem"
       scrollHeight="12rem"
-      @change="filterCallback"
+      @change="emit('filterCallback')"
     >
     >
       <!--suppress VueUnrecognizedSlot -->
       <!--suppress VueUnrecognizedSlot -->
       <template #option="{ option, selected, index }">
       <template #option="{ option, selected, index }">
@@ -37,10 +37,10 @@
       variant="outlined"
       variant="outlined"
       size="small"
       size="small"
       fluid
       fluid
-      :disabled="!hasFilter()"
-      @click="resetFilter"
+      :disabled="!hasFilterFor(props.field)"
+      @click="resetFilterFor(props.field)"
     >
     >
-      Clear
+      Reset
     </Button>
     </Button>
   </div>
   </div>
 </template>
 </template>
@@ -49,32 +49,26 @@
 const model = defineModel()
 const model = defineModel()
 
 
 const props = defineProps({
 const props = defineProps({
-  options: {
-    type: Array,
+  field: {
+    type: String,
     required: true
     required: true
   },
   },
 
 
-  filteredOptions: {
+  options: {
     type: Array,
     type: Array,
     required: true
     required: true
   },
   },
 
 
-  filterCallback: {
-    type: Function,
-    required: true
-  },
-
-  hasFilter: {
-    type: Function,
-    required: true
-  },
-
-  resetFilter: {
-    type: Function,
+  filteredOptions: {
+    type: Array,
     required: true
     required: true
   }
   }
 })
 })
 
 
+const emit = defineEmits(["filterCallback"])
+
+const { hasFilterFor, resetFilterFor } = useFiltersStore()
+
 function isFilteredOption(option) {
 function isFilteredOption(option) {
   return _includes(props.filteredOptions, option)
   return _includes(props.filteredOptions, option)
 }
 }