feat(saved-routes): require server capability
This commit is contained in:
@ -98,21 +98,23 @@
|
|||||||
|
|
||||||
<VehicleSelector />
|
<VehicleSelector />
|
||||||
|
|
||||||
{#await getSaved() then saved}
|
<RequiresCapability capability="saved-routes">
|
||||||
{#if saved.length != 0}
|
{#await getSaved() then saved}
|
||||||
<div>
|
{#if saved.length != 0}
|
||||||
<h2 style="margin: 5px; margin-left: 0; font-size: 1.2em;">Saved Routes</h2>
|
<div>
|
||||||
|
<h2 style="margin: 5px; margin-left: 0; font-size: 1.2em;">Saved Routes</h2>
|
||||||
|
|
||||||
<div style="display: flex; flex-direction: column; gap: 10px;">
|
<div style="display: flex; flex-direction: column; gap: 10px;">
|
||||||
{#each saved as save}
|
{#each saved as save}
|
||||||
<Button variant="secondary" onclick={() => {
|
<Button variant="secondary" onclick={() => {
|
||||||
view.switch("trip", { route: JSON.parse(save.data) })
|
view.switch("trip", { route: JSON.parse(save.data) })
|
||||||
}}>{save.name}</Button>
|
}}>{save.name}</Button>
|
||||||
{/each}
|
{/each}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{/if}
|
||||||
{/if}
|
{/await}
|
||||||
{/await}
|
</RequiresCapability>
|
||||||
|
|
||||||
<RequiresCapability capability="post">
|
<RequiresCapability capability="post">
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
import { m } from "$lang/messages";
|
import { m } from "$lang/messages";
|
||||||
import { deleteSaved, isSaved, putSaved } from "$lib/services/lnv";
|
import { deleteSaved, isSaved, putSaved } from "$lib/services/lnv";
|
||||||
import { view } from "../view.svelte";
|
import { view } from "../view.svelte";
|
||||||
|
import RequiresCapability from "../RequiresCapability.svelte";
|
||||||
|
|
||||||
let {
|
let {
|
||||||
route,
|
route,
|
||||||
@ -45,21 +46,23 @@
|
|||||||
<RouteIcon />
|
<RouteIcon />
|
||||||
{m["sidebar.trip.start"]()}
|
{m["sidebar.trip.start"]()}
|
||||||
</Button>
|
</Button>
|
||||||
{#await isSaved($state.snapshot(route)) then saved}
|
<RequiresCapability capability="saved-routes">
|
||||||
<Button variant="secondary" onclick={async () => {
|
{#await isSaved($state.snapshot(route)) then saved}
|
||||||
if(saved) {
|
<Button variant="secondary" onclick={async () => {
|
||||||
await deleteSaved(saved);
|
if(saved) {
|
||||||
view.back();
|
await deleteSaved(saved);
|
||||||
} else {
|
view.back();
|
||||||
const name = prompt("Trip name?");
|
} else {
|
||||||
if(!name) return;
|
const name = prompt("Trip name?");
|
||||||
await putSaved(name, route);
|
if(!name) return;
|
||||||
}
|
await putSaved(name, route);
|
||||||
}}>
|
}
|
||||||
<SaveIcon />
|
}}>
|
||||||
{saved ? m.unsave() : m["sidebar.trip.save"]()}
|
<SaveIcon />
|
||||||
</Button>
|
{saved ? m.unsave() : m["sidebar.trip.save"]()}
|
||||||
{/await}
|
</Button>
|
||||||
|
{/await}
|
||||||
|
</RequiresCapability>
|
||||||
<Button variant="secondary" disabled>
|
<Button variant="secondary" disabled>
|
||||||
<SendIcon />
|
<SendIcon />
|
||||||
{m["sidebar.trip.send"]()}
|
{m["sidebar.trip.send"]()}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { LNV_SERVER } from "./hosts";
|
import { LNV_SERVER } from "./hosts";
|
||||||
import type { OIDCUser } from "./oidc";
|
import type { OIDCUser } from "./oidc";
|
||||||
|
|
||||||
export type Capabilities = ("auth" | "reviews" | "ai" | "fuel" | "post")[];
|
export type Capabilities = ("auth" | "reviews" | "ai" | "fuel" | "post" | "saved-routes")[];
|
||||||
export let capabilities: Capabilities = [];
|
export let capabilities: Capabilities = [];
|
||||||
export let oidcConfig: {
|
export let oidcConfig: {
|
||||||
AUTH_URL: string;
|
AUTH_URL: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user