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