Skip to content

Commit

Permalink
Collapse trivial date ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
dokempf committed Jul 19, 2024
1 parent 8a4a09d commit 151c866
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/components/fields/Daterange.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
<script>
import { fieldData } from "../../lib/easydbHelpers";
import { P } from "flowbite-svelte";
export let data;
export let field;
export let table;
import { fieldData } from "../../lib/easydbHelpers";
const fdata = fieldData(data, table, field);
</script>

<span class="easydb-daterange-field">{fdata["from"]} - {fdata["to"]}</span>
export let data;
export let field;
export let table;
const fdata = fieldData(data, table, field);
const from = Number(fdata["from"]);
const to = Number(fdata["to"]);
</script>

<!-- EasyDB seems to have a shortcut to collapse date ranges to actual dates if
start and end that coincide. We do the same here. -->
{#if from === to}
<span class="easydb-daterange-field">{from}</span>
{:else}
<span class="easydb-daterange-field">{from} - {to}</span>
{/if}

0 comments on commit 151c866

Please sign in to comment.