refactor(ui): replace NativeSelectCtrl with Boxer for project selection
Some checks failed
CI / build-and-test (push) Failing after -31m20s
Some checks failed
CI / build-and-test (push) Failing after -31m20s
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import {
|
||||||
|
Boxer,
|
||||||
|
BoxerResolveSpecAdapter,
|
||||||
ErrorBoundary,
|
ErrorBoundary,
|
||||||
FormerResolveSpecAPI,
|
FormerResolveSpecAPI,
|
||||||
GridlerFull,
|
GridlerFull,
|
||||||
NativeSelectCtrl,
|
|
||||||
type GridColumnFilters,
|
type GridColumnFilters,
|
||||||
type GridlerColumn,
|
type GridlerColumn,
|
||||||
type GridlerContextMenuItem,
|
type GridlerContextMenuItem,
|
||||||
} from "@warkypublic/svelix";
|
} from "@warkypublic/svelix";
|
||||||
import FormerShell from "../shared/FormerShell.svelte";
|
import FormerShell from "../shared/FormerShell.svelte";
|
||||||
import { onMount } from "svelte";
|
|
||||||
import { api } from "../../api";
|
import { api } from "../../api";
|
||||||
import { adminGridTheme } from "../../gridTheme";
|
import { adminGridTheme } from "../../gridTheme";
|
||||||
import { GlobalStateStore } from "../../shellState";
|
import { GlobalStateStore } from "../../shellState";
|
||||||
@@ -34,16 +34,21 @@
|
|||||||
let editorValues = $state<{ id?: string; content: string }>({ content: '' });
|
let editorValues = $state<{ id?: string; content: string }>({ content: '' });
|
||||||
let contextRow = $state<Record<string, unknown> | null>(null);
|
let contextRow = $state<Record<string, unknown> | null>(null);
|
||||||
let refreshKey = $state(0);
|
let refreshKey = $state(0);
|
||||||
let projectOptions = $state<{ label: string; value: string }[]>([]);
|
|
||||||
const authToken = GlobalStateStore.getState().session.authToken ?? '';
|
const authToken = GlobalStateStore.getState().session.authToken ?? '';
|
||||||
const thoughtOnAPICall = $derived(FormerResolveSpecAPI({
|
const thoughtOnAPICall = $derived(FormerResolveSpecAPI({
|
||||||
authToken,
|
authToken,
|
||||||
url: '/api/rs/public/thoughts'
|
url: '/api/rs/public/thoughts'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
onMount(async () => {
|
const projectBoxerAdapter = new BoxerResolveSpecAdapter({
|
||||||
const projects = await api.projects.list();
|
baseUrl: '/api/rs',
|
||||||
projectOptions = projects.map((p) => ({ label: p.name, value: p.id }));
|
token: authToken,
|
||||||
|
schema: 'public',
|
||||||
|
entity: 'projects',
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'guid',
|
||||||
|
columns: ['guid', 'name'],
|
||||||
|
sort: [{ column: 'name', direction: 'asc' }],
|
||||||
});
|
});
|
||||||
|
|
||||||
const menuItems: GridlerContextMenuItem[] = [
|
const menuItems: GridlerContextMenuItem[] = [
|
||||||
@@ -563,13 +568,16 @@
|
|||||||
disabled={state.request === 'delete'}
|
disabled={state.request === 'delete'}
|
||||||
onchange={(v) => state.setState('values', { ...state.values, content: v })}
|
onchange={(v) => state.setState('values', { ...state.values, content: v })}
|
||||||
/>
|
/>
|
||||||
<NativeSelectCtrl
|
<Boxer
|
||||||
label="Project"
|
label="Project"
|
||||||
name="project_id"
|
name="project_id"
|
||||||
disabled={state.request === 'delete'}
|
disabled={state.request === 'delete'}
|
||||||
value={state.values?.project_id ?? ''}
|
dataSource="server"
|
||||||
options={[{ label: '— None —', value: '' }, ...projectOptions]}
|
adapter={projectBoxerAdapter}
|
||||||
onchange={(v) => state.setState('values', { ...state.values, project_id: v || undefined })}
|
value={state.values?.project_id ?? null}
|
||||||
|
clearable
|
||||||
|
searchable
|
||||||
|
onChange={(v) => state.setState('values', { ...state.values, project_id: v || undefined })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|||||||
Reference in New Issue
Block a user