Adjusted filter

ref #92
This commit is contained in:
Nicolai Ort 2021-03-17 14:00:51 +01:00
parent 1ada5d9c2c
commit 53aa3bc3ae

View File

@ -1,17 +1,20 @@
<script> <script>
import { getLocaleFromNavigator, _ } from "svelte-i18n"; import { getLocaleFromNavigator, _ } from "svelte-i18n";
import { DonationService, DonorService, ScanService } from "@odit/lfk-client-js"; import {
DonationService,
DonorService,
ScanService,
} from "@odit/lfk-client-js";
import store from "../../store"; import store from "../../store";
import Toastify from "toastify-js"; import Toastify from "toastify-js";
import ScansEmptyState from "./ScansEmptyState.svelte"; import ScansEmptyState from "./ScansEmptyState.svelte";
$: searchvalue = ""; $: searchvalue = "";
$: active_deletes = []; $: active_deletes = [];
export let current_scans = []; export let current_scans = [];
const scans_promise = ScanService.scanControllerGetAll().then( const scans_promise = ScanService.scanControllerGetAll().then((val) => {
(val) => {
current_scans = val; current_scans = val;
} console.log(current_scans);
); });
function should_display_based_on_id(id) { function should_display_based_on_id(id) {
if (searchvalue.toString().slice(-1) === "*") { if (searchvalue.toString().slice(-1) === "*") {
return id.toString().startsWith(searchvalue.replace("*", "")); return id.toString().startsWith(searchvalue.replace("*", ""));
@ -75,16 +78,7 @@
</thead> </thead>
<tbody class="divide-y divide-gray-200"> <tbody class="divide-y divide-gray-200">
{#each current_scans as scan} {#each current_scans as scan}
<!-- TODO: Build the real filter --> {#if scan.track?.name
{#if scan.donor.firstname
.toLowerCase()
.includes(
searchvalue.toLowerCase()
) || scan.donor.middlename
.toLowerCase()
.includes(
searchvalue.toLowerCase()
) || scan.donor.lastname
.toLowerCase() .toLowerCase()
.includes( .includes(
searchvalue.toLowerCase() searchvalue.toLowerCase()
@ -115,9 +109,7 @@
<div class="text-sm font-medium text-gray-900"> <div class="text-sm font-medium text-gray-900">
{#if scan.distance < 1000} {#if scan.distance < 1000}
{scan.distance}m {scan.distance}m
{:else} {:else}{scan.distance / 1000}km{/if}
{(scan.distance / 1000)}km
{/if}
</div> </div>
</td> </td>
<td class="px-6 py-4 whitespace-nowrap"> <td class="px-6 py-4 whitespace-nowrap">
@ -137,6 +129,7 @@
<a <a
href="../tracks" href="../tracks"
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">{scan.track.name} class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">{scan.track.name}
</a>
</div> </div>
{:else} {:else}
<div class="text-sm font-medium text-gray-900"> <div class="text-sm font-medium text-gray-900">
@ -149,7 +142,8 @@
<div class="text-sm font-medium text-gray-900"> <div class="text-sm font-medium text-gray-900">
<a <a
href="../scanstations/{scan.station.id}" href="../scanstations/{scan.station.id}"
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">{scan.station.description || "#"+ scan.station.id} class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">{scan.station.description || '#' + scan.station.id}
</a>
</div> </div>
{:else} {:else}
<div class="text-sm font-medium text-gray-900"> <div class="text-sm font-medium text-gray-900">