display parent category name in category selects (fixes #1045)

This commit is contained in:
Athou
2023-03-07 08:40:02 +01:00
parent 10bfbbec17
commit 5003c176a2
33 changed files with 132 additions and 15 deletions

View File

@@ -38,6 +38,7 @@ export interface ApplicationSettings {
export interface Category {
id: string
parentId?: string
parentName?: string
name: string
children: Category[]
feeds: Subscription[]

View File

@@ -4,16 +4,20 @@ import { Constants } from "app/constants"
import { useAppSelector } from "app/store"
import { flattenCategoryTree } from "app/utils"
type CategorySelectProps = Partial<SelectProps> & { withAll?: boolean }
type CategorySelectProps = Partial<SelectProps> & {
withAll?: boolean
withoutCategoryIds?: string[]
}
export function CategorySelect(props: CategorySelectProps) {
const rootCategory = useAppSelector(state => state.tree.rootCategory)
const categories = rootCategory && flattenCategoryTree(rootCategory)
const selectData: SelectItem[] | undefined = categories
?.filter(c => c.id !== Constants.categories.all.id)
.filter(c => !props.withoutCategoryIds || !props.withoutCategoryIds.includes(c.id))
.sort((c1, c2) => c1.name.localeCompare(c2.name))
.map(c => ({
label: c.name,
label: c.parentName ? t`${c.name} (in ${c.parentName})` : c.name,
value: c.id,
}))
if (props.withAll) {

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "الملف مطلوب"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "el fitxer és necessari"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr ""
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "mae angen y ffeil"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "fil er påkrævet"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "Datei ist erforderlich"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr "Your feeds have been queued for refresh."
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "file is required"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr "{0} (in {1})"

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "archivo requerido"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "فایل مورد نیاز است"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "tiedosto vaaditaan"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "fichier requis"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "é necesario o ficheiro"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "fájl szükséges"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "file diperlukan"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "è richiesto il file"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "ファイルが必要です"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "파일이 필요합니다"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "fail diperlukan"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "fil kreves"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "bestand is vereist"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "fil kreves"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "plik jest wymagany"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "o arquivo é obrigatório"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "требуется файл"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr ""
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "fil krävs"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "dosya gerekli"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -795,3 +795,7 @@ msgstr ""
#: src/components/content/add/ImportOpml.tsx
msgid "file is required"
msgstr "文件是必需的"
#: src/components/content/add/CategorySelect.tsx
msgid "{0} (in {1})"
msgstr ""

View File

@@ -109,7 +109,12 @@ export function CategoryDetailsPage() {
{editable && (
<>
<TextInput label={t`Name`} {...form.getInputProps("name")} required />
<CategorySelect label={t`Parent Category`} {...form.getInputProps("parentId")} clearable />
<CategorySelect
label={t`Parent Category`}
{...form.getInputProps("parentId")}
clearable
withoutCategoryIds={[id]}
/>
<NumberInput label={t`Position`} {...form.getInputProps("position")} required min={0} />
</>
)}