Allow for selecting sites
This commit is contained in:
parent
35ab261ee8
commit
8514ec36d5
3 changed files with 13 additions and 12 deletions
|
|
@ -26,23 +26,20 @@
|
||||||
:class="{ active: selectedSite?.id === site.id }"
|
:class="{ active: selectedSite?.id === site.id }"
|
||||||
@click="doClick(site)"
|
@click="doClick(site)"
|
||||||
>
|
>
|
||||||
<div class="d-flex justify-content-between align-items-start">
|
<div class="d-flex">
|
||||||
<div>
|
<div>
|
||||||
<i class="bi bi-droplet"></i>
|
<i class="bi bi-house"></i>
|
||||||
<strong>Pool {{ site.id }}</strong>
|
|
||||||
</div>
|
</div>
|
||||||
<small class="text-muted">{{ site.created }}</small>
|
<strong>{{ formatAddress(site.address) }}</strong>
|
||||||
</div>
|
</div>
|
||||||
<small class="text-muted d-block mt-1">
|
|
||||||
{{ formatAddress(site.address) }}
|
|
||||||
</small>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Site } from "@/type/api";
|
import { Site } from "@/type/api";
|
||||||
import { formatAddress } from "@/format";
|
import { formatAddress } from "@/format";
|
||||||
interface Emits {
|
interface Emits {
|
||||||
(e: "doSelectTask", id: number): void;
|
(e: "doSiteDeselect", id: number): void;
|
||||||
|
(e: "doSiteSelect", id: number): void;
|
||||||
}
|
}
|
||||||
interface Props {
|
interface Props {
|
||||||
selectedSite: Site | undefined;
|
selectedSite: Site | undefined;
|
||||||
|
|
@ -51,6 +48,10 @@ interface Props {
|
||||||
const emit = defineEmits<Emits>();
|
const emit = defineEmits<Emits>();
|
||||||
const props = withDefaults(defineProps<Props>(), {});
|
const props = withDefaults(defineProps<Props>(), {});
|
||||||
function doClick(site: Site) {
|
function doClick(site: Site) {
|
||||||
console.log("click", site);
|
if (props.selectedSite && site.id == props.selectedSite.id) {
|
||||||
|
emit("doSiteDeselect", site.id);
|
||||||
|
} else {
|
||||||
|
emit("doSiteSelect", site.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ export function formatAddress(address?: Address): string {
|
||||||
if (address.number === "" && address.street === "") {
|
if (address.number === "" && address.street === "") {
|
||||||
return "no address provided";
|
return "no address provided";
|
||||||
}
|
}
|
||||||
return `${address.number} ${address.street}, ${address.locality}`;
|
return `${address.number.trim()} ${address.street.trim()}, ${address.locality}`;
|
||||||
}
|
}
|
||||||
export function formatBigNumber(n: number): string {
|
export function formatBigNumber(n: number): string {
|
||||||
// Convert the number to a string
|
// Convert the number to a string
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ body {
|
||||||
<ThreeColumn>
|
<ThreeColumn>
|
||||||
<template #left>
|
<template #left>
|
||||||
<ReviewSiteColumnList
|
<ReviewSiteColumnList
|
||||||
@doDeselectSite="siteDeselect"
|
@doSiteDeselect="siteDeselect"
|
||||||
@doSelectSite="siteSelect"
|
@doSiteSelect="siteSelect"
|
||||||
:selectedSite="selectedSite"
|
:selectedSite="selectedSite"
|
||||||
:sites="storeSite.all()"
|
:sites="storeSite.all()"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue