parent
107360cd93
commit
284bdc6e33
@ -3,8 +3,6 @@
|
|||||||
import { clickOutside } from "../base/outsideclick";
|
import { clickOutside } from "../base/outsideclick";
|
||||||
import { focusTrap } from "svelte-focus-trap";
|
import { focusTrap } from "svelte-focus-trap";
|
||||||
import {
|
import {
|
||||||
DonationService,
|
|
||||||
DonorService,
|
|
||||||
RunnerService,
|
RunnerService,
|
||||||
ScanService,
|
ScanService,
|
||||||
} from "@odit/lfk-client-js";
|
} from "@odit/lfk-client-js";
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
$: original_data = {};
|
$: original_data = {};
|
||||||
$: editable = {};
|
$: editable = {};
|
||||||
$: current_runners = [];
|
$: current_runners = [];
|
||||||
|
$: is_distance_valid = editable.distance > 0;
|
||||||
$: is_everything_set =
|
$: is_everything_set =
|
||||||
editable.donor != null &&
|
editable.donor != null &&
|
||||||
((original_data.responseType == "TRACKSCAN" && editable?.runner != null) ||
|
((original_data.responseType == "TRACKSCAN" && editable?.runner != null) ||
|
||||||
@ -23,7 +24,7 @@
|
|||||||
$: changes_performed = !(
|
$: changes_performed = !(
|
||||||
JSON.stringify(original_data) === JSON.stringify(editable)
|
JSON.stringify(original_data) === JSON.stringify(editable)
|
||||||
);
|
);
|
||||||
$: save_enabled = changes_performed && is_everything_set;
|
$: save_enabled = changes_performed && is_everything_set && is_distance_valid;
|
||||||
const runner_promise = RunnerService.runnerControllerGetAll().then((val) => {
|
const runner_promise = RunnerService.runnerControllerGetAll().then((val) => {
|
||||||
current_runners = val;
|
current_runners = val;
|
||||||
});
|
});
|
||||||
@ -99,7 +100,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#await donor_promise && runner_promise && promise}
|
{#await runner_promise && promise}
|
||||||
Loading scan details
|
Loading scan details
|
||||||
{:then}
|
{:then}
|
||||||
<section class="container p-5 select-none">
|
<section class="container p-5 select-none">
|
||||||
@ -180,8 +181,10 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<div class="w-full">
|
<div class="w-full inline-flex">
|
||||||
<label for="valid" class="block font-medium text-gray-700">Status</label>
|
<label for="valid" class="block font-medium text-gray-700">Status:
|
||||||
|
</label>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
id="valid"
|
id="valid"
|
||||||
on:change={() => {
|
on:change={() => {
|
||||||
@ -190,15 +193,33 @@
|
|||||||
name="valid"
|
name="valid"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={editable.valid}
|
checked={editable.valid}
|
||||||
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded" />
|
class="focus:ring-indigo-500 align-bottom h-7 w-5font-medium text-indigo-600 border-gray-300 rounded" />
|
||||||
{#if editable.valid}
|
|
||||||
<span
|
<p class="font-medium">
|
||||||
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">Invalid</span>
|
{#if editable.valid}Valid{:else}Invalid{/if}
|
||||||
{:else}
|
</p>
|
||||||
<span
|
|
||||||
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">Invalid</span>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
|
{#if editable.responseType === "TRACKSCAN"}
|
||||||
|
<div class="w-full inline-flex">
|
||||||
|
<label for="valid" class="block font-semibold text-gray-700">Track: </label>
|
||||||
|
<a
|
||||||
|
href="../tracks"
|
||||||
|
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">{editable.track.name}
|
||||||
|
</a>
|
||||||
|
|
|
||||||
|
<label for="valid" class="block font-semibold text-gray-700">Station: </label>
|
||||||
|
<a
|
||||||
|
href="../scanstations/{editable.station.id}"
|
||||||
|
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">#{editable.station.id}
|
||||||
|
</a>
|
||||||
|
|
|
||||||
|
<label for="valid" class="block font-semibold text-gray-700">Card: </label>
|
||||||
|
<a
|
||||||
|
href="TODO:"
|
||||||
|
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">#{editable.card.id}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
<div class=" w-full">
|
<div class=" w-full">
|
||||||
<label
|
<label
|
||||||
for="runner"
|
for="runner"
|
||||||
@ -210,12 +231,40 @@
|
|||||||
itemFilter={(label, filterText, option) => filterRunners(label, filterText, option)}
|
itemFilter={(label, filterText, option) => filterRunners(label, filterText, option)}
|
||||||
items={current_runners}
|
items={current_runners}
|
||||||
showChevron={true}
|
showChevron={true}
|
||||||
isDisabled={(editable.responseType === "TRACKSCAN")}
|
isDisabled={editable.responseType === 'TRACKSCAN'}
|
||||||
placeholder={$_('search-for-runner-by-name-or-id')}
|
placeholder={$_('search-for-runner-by-name-or-id')}
|
||||||
noOptionsMessage={$_('no-runners-found')}
|
noOptionsMessage={$_('no-runners-found')}
|
||||||
bind:selectedValue={editable.runner}
|
bind:selectedValue={editable.runner}
|
||||||
on:clear={() => (editable.runner = null)} />
|
on:clear={() => (editable.runner = null)} />
|
||||||
</div>
|
</div>
|
||||||
|
<div class=" w-full">
|
||||||
|
<label
|
||||||
|
for="scan_distance"
|
||||||
|
class="block text-sm font-medium text-gray-700">
|
||||||
|
Distance</label>
|
||||||
|
<div class="mt-1 flex rounded-md shadow-sm">
|
||||||
|
<input
|
||||||
|
autocomplete="off"
|
||||||
|
class:border-red-500={!is_distance_valid}
|
||||||
|
class:focus:border-red-500={!is_distance_valid}
|
||||||
|
class:focus:ring-red-500={!is_distance_valid}
|
||||||
|
bind:value={editable.distance}
|
||||||
|
disabled={editable.responseType === 'TRACKSCAN'}
|
||||||
|
type="number"
|
||||||
|
step="1"
|
||||||
|
name="scan_distance"
|
||||||
|
class="focus:ring-indigo-500 focus:border-indigo-500 flex-1 block w-full rounded-none rounded-l-md sm:text-sm border-gray-300 border bg-gray-50 text-gray-500 p-2"
|
||||||
|
placeholder="400" />
|
||||||
|
<span
|
||||||
|
class="inline-flex items-center px-3 rounded-r-md border border-gray-300 bg-gray-50 text-gray-500 text-sm">m</span>
|
||||||
|
</div>
|
||||||
|
{#if !is_distance_valid}
|
||||||
|
<span
|
||||||
|
class="flex items-center font-medium tracking-wide text-red-500 text-xs mt-1 ml-1">
|
||||||
|
The scan's distance must be greater than 0m
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
{:catch error}
|
{:catch error}
|
||||||
<PromiseError {error} />
|
<PromiseError {error} />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user