From 8e216c1efb31c2aa13f9494cfaabb4514e29e4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Subiabre=20Garc=C3=ADa?= Date: Thu, 29 Oct 2026 15:08:16 +0100 Subject: [PATCH 1/3] fix: categories not selectable (#564) * fix: make extractId return last numeric piece in IRI for ID * fix: make CategorySelect component also take Theme SDK type * fix: make getTerritoryDisplayName log errors * fix: code style issues by prettier --- .../admin/projects/ProjectsDetailsRow.svelte | 4 ++-- .../library/inputs/CategorySelect.svelte | 16 +++++++-------- src/utils/extractId.ts | 20 ++++++++++++------- src/utils/territory.ts | 2 ++ 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/components/admin/projects/ProjectsDetailsRow.svelte b/src/components/admin/projects/ProjectsDetailsRow.svelte index 7c4b3d67..3c524a41 100644 --- a/src/components/admin/projects/ProjectsDetailsRow.svelte +++ b/src/components/admin/projects/ProjectsDetailsRow.svelte @@ -2,9 +2,9 @@ import Comments from "../../../components/icons/Comments.svelte"; import { t, locale } from "../../../i18n/store"; import { formatDate } from "../../../utils/dates"; - import DetailsRow, { type DetailsField } from "../DetailsRow.svelte"; - import ProjectPreviewModal from "../../project/edit/ProjectPreviewModal.svelte"; import { extractId } from "../../../utils/extractId"; + import ProjectPreviewModal from "../../project/edit/ProjectPreviewModal.svelte"; + import DetailsRow, { type DetailsField } from "../DetailsRow.svelte"; import type { ProjectRow } from "./ProjectsTable.svelte"; diff --git a/src/components/library/inputs/CategorySelect.svelte b/src/components/library/inputs/CategorySelect.svelte index 6cbef598..7b3ca49f 100644 --- a/src/components/library/inputs/CategorySelect.svelte +++ b/src/components/library/inputs/CategorySelect.svelte @@ -1,7 +1,7 @@
-
+ event.preventDefault()}>
{$t("pages.project.create.title")} @@ -178,6 +216,8 @@ <div class="relative"> <TextArea bind:value={form.subtitle} + onInput={() => validate("subtitle")} + error={getValidationMessage("subtitle")} helperText={$t("pages.project.create.description.subtitlePrompt")} placeholder={$t("pages.project.create.description.subtitlePlaceholder")} /> @@ -201,6 +241,15 @@ </p> <CategorySelect max={2} options={categories} onChange={handleCategories} /> </div> + <div class="flex flex-col gap-4"> + <Title level={2} variant="subsection"> + {$t("pages.project.create.themes.title")} + +

+ {$t("pages.project.create.themes.subtitle")} +

+ +
{$t("pages.project.create.address.title")} @@ -231,14 +280,19 @@ error={getValidationMessage("calendar")} /> </div> - <Button type="submit" disabled={!isValid || isSubmitting}> - {#if isSubmitting} - <Spinner /> - {:else} - {$t("pages.project.create.submit")} - {/if} - </Button> + <ActionableButton + type="submit" + action={submit} + bind:state={submitState} + disabled={!isValid || submitState !== "actionable"} + class="w-fit" + > + {$t("pages.project.create.submit")} + </ActionableButton> </form> + <Toast floating variant="error" bind:showToast={showError}> + {$t("system.error.unknown")} + </Toast> <div class="ml-auto"> <BaseCard class="border-grey flex h-full max-h-126.5 w-full max-w-109.25 flex-col bg-white" diff --git a/src/components/library/buttons/ActionableButton.svelte b/src/components/library/buttons/ActionableButton.svelte index 7a6c4af3..28a6671e 100644 --- a/src/components/library/buttons/ActionableButton.svelte +++ b/src/components/library/buttons/ActionableButton.svelte @@ -40,11 +40,15 @@ state = "loading"; try { await action(); - } finally { - state = "actioned"; - if (autoreset !== undefined) { - setTimeout(() => (state = "actionable"), autoreset); - } + } catch (err) { + // A failed action can be retried, so it never reaches the actioned state + state = "actionable"; + console.error(err); + return; + } + state = "actioned"; + if (autoreset !== undefined) { + setTimeout(() => (state = "actionable"), autoreset); } } diff --git a/src/components/library/inputs/CategorySelect.svelte b/src/components/library/inputs/CategorySelect.svelte index 7b3ca49f..d5b161c5 100644 --- a/src/components/library/inputs/CategorySelect.svelte +++ b/src/components/library/inputs/CategorySelect.svelte @@ -1,4 +1,5 @@ <script lang="ts"> + import { t } from "../../../i18n/store"; import CategoryOption from "../tags/Category.svelte"; import type { Category, Theme } from "../../../openapi/client"; @@ -53,20 +54,24 @@ </script> <div> - <fieldset - class="m-0 flex flex-wrap gap-4 border-0 p-0" - aria-describedby={error ? "category-error" : undefined} - > - {#each options as option} - <CategoryOption - type={calcTagType(option)} - disabled={calcTagDisabled(option)} - onclick={() => handleClick(option)} - > - {option.name} - </CategoryOption> - {/each} - </fieldset> + {#if options.length === 0} + <p class="text-content">{$t("common.noOptions")}</p> + {:else} + <fieldset + class="m-0 flex flex-wrap gap-4 border-0 p-0" + aria-describedby={error ? "category-error" : undefined} + > + {#each options as option} + <CategoryOption + type={calcTagType(option)} + disabled={calcTagDisabled(option)} + onclick={() => handleClick(option)} + > + {option.name} + </CategoryOption> + {/each} + </fieldset> + {/if} {#if error} <p id="category-error" class="mt-2 ml-4 text-xs text-red-600" role="alert"> {error} diff --git a/src/i18n/locales/es.json b/src/i18n/locales/es.json index 063d5a50..b3c8cedd 100644 --- a/src/i18n/locales/es.json +++ b/src/i18n/locales/es.json @@ -1105,6 +1105,10 @@ "title": "¿Qué categoría se ajusta a tu proyecto?", "subtitle": "(Puedes elegir un máximo de 2)" }, + "themes": { + "title": "¿Qué tema se ajusta a tu proyecto?", + "subtitle": "(Opcional, puedes elegir uno)" + }, "address": { "title": "¿Cuál es la dirección del proyecto?", "subtitle": "Busca y selecciona la dirección completa del proyecto. Esto nos ayuda a ubicar tu iniciativa.", @@ -1125,7 +1129,9 @@ "titleBadFormat": "El título debe contener al menos una letra.", "categoriesNotEnough": "Debes seleccionar al menos {{ min }} categoría(s).", "territoryMissing": "Debes especificar un lugar.", - "releaseMissing": "Debes especificar una fecha de salida aproximada" + "releaseMissing": "Debes especificar una fecha de salida aproximada", + "titleInUse": "Ya existe un proyecto con este título.", + "subtitleMissing": "Debes añadir una breve descripción del proyecto." } }, "view": { diff --git a/src/pages/[...locale]/create/project.astro b/src/pages/[...locale]/create/project.astro index 7a378a47..536b83d9 100644 --- a/src/pages/[...locale]/create/project.astro +++ b/src/pages/[...locale]/create/project.astro @@ -2,9 +2,9 @@ import Layout from "../../../layouts/Layout.astro"; import App from "../../../layouts/App.svelte"; import CreateProjectForm from "../../../components/create/CreateProjectForm.svelte"; -import { apiCategoriesGetCollection } from "../../../openapi/client"; +import { apiCategoriesGetCollection, apiThemesGetCollection } from "../../../openapi/client"; import { toCollectionItems } from "../../../utils/hydra"; -import type { Category } from "../../../openapi/client"; +import type { Category, Theme } from "../../../openapi/client"; import { goto } from "../../../utils/navigation"; import { withoutCache } from "../../../openapi/cacheInterceptor"; @@ -14,16 +14,18 @@ if (!session) { return goto("/login", { query: { callback: "/create/project" } }); } -const { data: categoriesRaw } = await withoutCache(() => - apiCategoriesGetCollection({ - headers: { "Accept-Language": langs }, - }), +const [{ data: categoriesRaw }, { data: themesRaw }] = await withoutCache(() => + Promise.all([ + apiCategoriesGetCollection({ headers: { "Accept-Language": langs } }), + apiThemesGetCollection({ headers: { "Accept-Language": langs } }), + ]), ); const categories = toCollectionItems<Category>(categoriesRaw); +const themes = toCollectionItems<Theme>(themesRaw); --- <Layout title={t("pages.project.create.title")}> <App client:load locale={lang} session={session}> - <CreateProjectForm client:load {categories} /> + <CreateProjectForm client:load {categories} {themes} /> </App> </Layout> diff --git a/src/validation/projectValidation.ts b/src/validation/projectValidation.ts index f448e251..95ad3947 100644 --- a/src/validation/projectValidation.ts +++ b/src/validation/projectValidation.ts @@ -14,19 +14,24 @@ export const zProjectCampaignRelease = z params: { max: CAMPAIGN_MAX_END_DATE }, }); -export const zCreateProjectForm = zProjectProjectCreationDto.superRefine((form, ctx) => { - if (!form.calendar?.release) { - return; - } - - const release = zProjectCampaignRelease.safeParse(new Date(form.calendar.release)); - - if (!release.success) { - for (const issue of release.error.issues) { - ctx.addIssue({ - ...issue, - path: ["calendar"], - }); +// The API rejects a blank subtitle, the generated schema accepts it +export const zCreateProjectForm = zProjectProjectCreationDto + .extend({ + subtitle: z.string().trim().min(1), + }) + .superRefine((form, ctx) => { + if (!form.calendar?.release) { + return; } - } -}); + + const release = zProjectCampaignRelease.safeParse(new Date(form.calendar.release)); + + if (!release.success) { + for (const issue of release.error.issues) { + ctx.addIssue({ + ...issue, + path: ["calendar"], + }); + } + } + }); From 21bb7bccd24301782d92a185598d6e5fd1fc9788 Mon Sep 17 00:00:00 2001 From: OlivierSchulbaum <dev@goteo.org> Date: Thu, 29 Oct 2026 15:59:37 +0100 Subject: [PATCH 3/3] New Crowdin updates (#565) * New translations es.json (Catalan) [ci skip] * New translations es.json (English) [ci skip] --- src/i18n/locales/ca.json | 8 +++++++- src/i18n/locales/en.json | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/i18n/locales/ca.json b/src/i18n/locales/ca.json index 4ef039c2..ec338a2b 100644 --- a/src/i18n/locales/ca.json +++ b/src/i18n/locales/ca.json @@ -1105,6 +1105,10 @@ "title": "Quina categoria s'ajusta al teu projecte?", "subtitle": "(Pots triar un màxim de 2)" }, + "themes": { + "title": "Quin tema s'ajusta al teu projecte?", + "subtitle": "(Opcional, en pots triar un)" + }, "address": { "title": "Quina és l'adreça del projecte?", "subtitle": "Cerca i selecciona l'adreça completa del projecte. Això ens ajuda a ubicar la teva iniciativa.", @@ -1125,7 +1129,9 @@ "titleBadFormat": "El títol ha de contenir almenys una lletra.", "categoriesNotEnough": "Has de seleccionar almenys {{ min }} categoria/es.", "territoryMissing": "Has d'especificar un lloc.", - "releaseMissing": "Has d'especificar una data de llançament aproximada" + "releaseMissing": "Has d'especificar una data de llançament aproximada", + "titleInUse": "Ja existeix un projecte amb aquest títol.", + "subtitleMissing": "Has d'afegir una breu descripció del projecte." } }, "view": { diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 35181c4b..eb635440 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -1105,6 +1105,10 @@ "title": "Which category fits your project?", "subtitle": "(You can choose a maximum of 2)" }, + "themes": { + "title": "Which theme fits your project?", + "subtitle": "(Optional, you can choose one)" + }, "address": { "title": "What is the project address?", "subtitle": "Search for and select the project's full address. This helps us locate your initiative.", @@ -1125,7 +1129,9 @@ "titleBadFormat": "The title must contain at least one letter.", "categoriesNotEnough": "You must select at least {{ min }} category(ies).", "territoryMissing": "You must specify a location.", - "releaseMissing": "You must specify an approximate launch date" + "releaseMissing": "You must specify an approximate launch date", + "titleInUse": "A project with this title already exists.", + "subtitleMissing": "You must add a brief project description." } }, "view": {