From 90f21f20ff4280742434ce245173309d4d172b9e Mon Sep 17 00:00:00 2001 From: Allan Lasser Date: Tue, 20 Feb 2024 14:31:39 -0500 Subject: [PATCH] Add "Private" checkbox to ProjectDialog --- src/api/project.ts | 9 ++++++++- src/common/dialog/ProjectDialog.svelte | 20 ++++++++++++++++++-- src/manager/projects.js | 13 +++++++++---- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/api/project.ts b/src/api/project.ts index a4b212524..880de374d 100644 --- a/src/api/project.ts +++ b/src/api/project.ts @@ -10,10 +10,15 @@ import { queryBuilder } from "../util/url.js"; import type { Page, Project, User, Document, DocumentAccess } from "./types"; // Create a project -export async function newProject(title, description): Promise { +export async function newProject( + title: string, + description: string, + isPrivate: boolean, +): Promise { const { data } = await session.post(apiUrl("projects/"), { title, description, + private: isPrivate, }); return data; } @@ -28,10 +33,12 @@ export async function updateProject( projectId: number, title: string, description: string, + isPrivate: boolean, ): Promise { const { data } = await session.patch(apiUrl(`projects/${projectId}/`), { title, description, + private: isPrivate, }); return data; } diff --git a/src/common/dialog/ProjectDialog.svelte b/src/common/dialog/ProjectDialog.svelte index f50d619ea..fcd6c8aad 100644 --- a/src/common/dialog/ProjectDialog.svelte +++ b/src/common/dialog/ProjectDialog.svelte @@ -30,6 +30,8 @@ let name = layout.projectEdit == null ? "" : layout.projectEdit.title; let description = layout.projectEdit == null ? "" : layout.projectEdit.description; + let isPrivate = + layout.projectEdit == null ? false : layout.projectEdit.private; let loading = writable(false); $: editing = $layout.projectEdit != null; @@ -46,11 +48,16 @@ if (editing) { await wrapLoadSeparate(loading, layout, async () => { - await editProject(layout.projectEdit, normalizedName, description); + await editProject( + layout.projectEdit, + normalizedName, + description, + isPrivate, + ); }); } else { await wrapLoadSeparate(loading, layout, async () => { - await createNewProject(normalizedName, description); + await createNewProject(normalizedName, description, isPrivate); }); } $lastUpdated = new Date(); @@ -101,6 +108,10 @@ use:textAreaResize />

+ {#if editing}