app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

commit a7d0bcbd4436b862aa922436fdc9fba760521766
parent 498e4b9e1ad6389e0416c3f099294af71e5aa47b
Author: triesap <137732411+triesap@users.noreply.github.com>
Date:   Fri, 30 Aug 2024 09:16:07 +0000

Update `/models/location-gcs`, update layour trellis

Diffstat:
Msrc/lib/components/layout-trellis.svelte | 2+-
Msrc/routes/(app)/+page.svelte | 11+++++++++++
Msrc/routes/(app)/models/location-gcs/+page.svelte | 211+++++++++++++++++++++++++++++++++++++------------------------------------------
3 files changed, 112 insertions(+), 112 deletions(-)

diff --git a/src/lib/components/layout-trellis.svelte b/src/lib/components/layout-trellis.svelte @@ -5,6 +5,6 @@ </script> -<div class={`flex flex-col w-full pt-2 px-4 pb-12 gap-4`}> +<div class={`flex flex-col w-full pt-4 px-4 pb-12 gap-4`}> {@render children()} </div> diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte @@ -23,6 +23,17 @@ <button class={`button-simple`} onclick={async () => { + app_nav.set({ + prev: [ + { + label: `Home`, + route: `/`, + }, + ], + title: { + label: `Models`, + }, + }); await goto(`/models/location-gcs`); }} > diff --git a/src/routes/(app)/models/location-gcs/+page.svelte b/src/routes/(app)/models/location-gcs/+page.svelte @@ -1,7 +1,8 @@ <script lang="ts"> - import { goto } from "$app/navigation"; import { cl } from "$lib/client"; import LayoutTrellis from "$lib/components/layout-trellis.svelte"; + import LayoutView from "$lib/components/layout-view.svelte"; + import { app_tabs_visible } from "$lib/stores"; import { type LocationGcs, type LocationGcsFormFields } from "@radroots/client"; import { trellis as Trellis } from "@radroots/svelte-lib"; import { location_geohash } from "@radroots/utils"; @@ -9,6 +10,7 @@ let locations_all = $state<LocationGcs[]>([]); $effect(() => { + app_tabs_visible.set(false); (async () => { try { const res = await cl.db.location_gcs_get({ @@ -20,121 +22,108 @@ }); </script> -<LayoutTrellis> - <Trellis - basis={{ - args: { - layer: 1, - title: { - value: `Location GCS`, - }, - list: [ - { - offset: { - mod: { - key: `caret-left`, - }, - }, - touch: { - label: { - left: [ - { - value: "Back", - }, - ], - }, - callback: async () => { - await goto(`/`); - }, + +<LayoutView> + <LayoutTrellis> + <Trellis + basis={{ + args: { + layer: 1, + title: { + value: `Location GCS`, }, - }, - { - touch: { - label: { - left: [ - { - value: `Add Current Location`, - classes: `capitalize`, + list: [ + { + touch: { + label: { + left: [ + { + value: `Add Current Location`, + classes: `capitalize`, + }, + ], }, - ], - }, - callback: async () => { - const loc_gcs = await cl.geo.current(); - if (loc_gcs && typeof loc_gcs !== `string`) { - const loc_gcs_label = await cl.dialog.prompt({ - title: `Geolocation Label`, - message: `What is the name of the location.`, - input_placeholder: `Enter location name`, - }); - if(loc_gcs_label === false) return; + callback: async () => { + const loc_gcs = await cl.geo.current(); + if (loc_gcs && typeof loc_gcs !== `string`) { + const loc_gcs_label = await cl.dialog.prompt({ + title: `Geolocation Label`, + message: `What is the name of the location.`, + input_placeholder: `Enter location name`, + }); + if(loc_gcs_label === false) return; - const { lat, lng } = loc_gcs; - const geohash = location_geohash(lat, lng); - const fields: LocationGcsFormFields = { - lat: lat.toString(), - lng: lng.toString(), - geohash, - label: loc_gcs_label - }; - const exe_res = await cl.db.location_gcs_add(fields); - if(typeof exe_res !== `string` && `id` in exe_res) { - await cl.dialog.alert(`Added new location (${exe_res.id})`); - } else if(typeof exe_res === `string` && exe_res === `*-location-gcs-geohash-unique`) { - await cl.dialog.alert(`This location has already been added.`); - } - } else if (loc_gcs && typeof loc_gcs === `string`) { - const dcf_res = await cl.dialog.confirm(`Enable location permission is required.`); - if (dcf_res) { - await cl.settings.open( - cl.platform === `ios` - ? { ios: { setting: `LocationServices` } } - : { android: { setting: `Location` } }, - ); - } - } - }, - }, - }, - { - touch: { - label: { - left: [ - { - value: `Read Saved Locations`, - classes: `capitalize`, + const { lat, lng } = loc_gcs; + const geohash = location_geohash(lat, lng); + const fields: LocationGcsFormFields = { + lat: lat.toString(), + lng: lng.toString(), + geohash, + label: loc_gcs_label + }; + const exe_res = await cl.db.location_gcs_add(fields); + if(typeof exe_res !== `string` && `id` in exe_res) { + await cl.dialog.alert(`Added new location (${exe_res.id})`); + } else if(typeof exe_res === `string` && exe_res === `*-location-gcs-geohash-unique`) { + await cl.dialog.alert(`This location has already been added.`); + } + } else if (loc_gcs && typeof loc_gcs === `string`) { + const dcf_res = await cl.dialog.confirm(`Enable location permission is required.`); + if (dcf_res) { + await cl.settings.open( + cl.platform === `ios` + ? { ios: { setting: `LocationServices` } } + : { android: { setting: `Location` } }, + ); + } + } }, - ], + }, }, - callback: async () => { - const res = await cl.db.location_gcs_get({ - list: [`all`], - }); - if(typeof res !== `string`) locations_all = res; - + { + touch: { + label: { + left: [ + { + value: `Read Saved Locations`, + classes: `capitalize`, + }, + ], + }, + callback: async () => { + const res = await cl.db.location_gcs_get({ + list: [`all`], + }); + if(typeof res !== `string`) locations_all = res; + + }, + }, }, - }, + ], }, - ], - }, - }} - /> - <div class={`flex flex-col justify-center items-center`}> - {#if locations_all.length > 0} - {#each locations_all as location} - <div class={`flex flex-col justify-center items-center`}> - <pre - class={`font-sans font-[400] text-layer-0-glyph`}>{JSON.stringify( - location, - null, - 4, - )}</pre> - </div> - {/each} - {:else} - <p class={`font-sans font-[400] text-layer-0-glyph`}> - {"No locations saved"} - </p> - {/if} - </div> -</LayoutTrellis> + }} + /> + <div class={`flex flex-col justify-center items-center pt-4 px-4`}> + {#if locations_all.length > 0} + <p class={`font-sans font-[400] text-layer-0-glyph text-xs`}> + {"Your locations:"} + </p> + {#each locations_all as location} + <div class={`flex flex-col justify-center items-center`}> + <pre class={`font-sans font-[400] text-layer-0-glyph text-xs`}>{JSON.stringify( + location, + null, + 4, + )} + </pre> + </div> + {/each} + {:else} + <p class={`font-sans font-[400] text-layer-0-glyph text-xs`}> + {"No locations saved"} + </p> + {/if} + </div> + </LayoutTrellis> +</LayoutView>