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>
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 Toastify from "toastify-js";
import ScansEmptyState from "./ScansEmptyState.svelte";
$: searchvalue = "";
$: active_deletes = [];
export let current_scans = [];
const scans_promise = ScanService.scanControllerGetAll().then(
(val) => {
current_scans = val;
}
);
const scans_promise = ScanService.scanControllerGetAll().then((val) => {
current_scans = val;
console.log(current_scans);
});
function should_display_based_on_id(id) {
if (searchvalue.toString().slice(-1) === "*") {
return id.toString().startsWith(searchvalue.replace("*", ""));
@ -75,20 +78,11 @@
</thead>
<tbody class="divide-y divide-gray-200">
{#each current_scans as scan}
<!-- TODO: Build the real filter -->
{#if scan.donor.firstname
{#if scan.track?.name
.toLowerCase()
.includes(
searchvalue.toLowerCase()
) || scan.donor.middlename
.toLowerCase()
.includes(
searchvalue.toLowerCase()
) || scan.donor.lastname
.toLowerCase()
.includes(
searchvalue.toLowerCase()
) || scan.runner?.firstname
) || scan.runner?.firstname
.toLowerCase()
.includes(
searchvalue.toLowerCase()
@ -114,22 +108,20 @@
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm font-medium text-gray-900">
{#if scan.distance < 1000}
{scan.distance}m
{:else}
{(scan.distance / 1000)}km
{/if}
{scan.distance}m
{:else}{scan.distance / 1000}km{/if}
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
{#if scan.valid}
<span
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">Valid</span>
{:else}
<span
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">Invalid</span>
{/if}
</div>
<span
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">Valid</span>
{:else}
<span
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">Invalid</span>
{/if}
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
{#if scan.track}
@ -137,6 +129,7 @@
<a
href="../tracks"
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">{scan.track.name}
</a>
</div>
{:else}
<div class="text-sm font-medium text-gray-900">
@ -149,7 +142,8 @@
<div class="text-sm font-medium text-gray-900">
<a
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>
{:else}
<div class="text-sm font-medium text-gray-900">