forked from Archives/Athou_commafeed
display parent category name in category selects (fixes #1045)
This commit is contained in:
@@ -38,6 +38,7 @@ export interface ApplicationSettings {
|
|||||||
export interface Category {
|
export interface Category {
|
||||||
id: string
|
id: string
|
||||||
parentId?: string
|
parentId?: string
|
||||||
|
parentName?: string
|
||||||
name: string
|
name: string
|
||||||
children: Category[]
|
children: Category[]
|
||||||
feeds: Subscription[]
|
feeds: Subscription[]
|
||||||
|
|||||||
@@ -4,16 +4,20 @@ import { Constants } from "app/constants"
|
|||||||
import { useAppSelector } from "app/store"
|
import { useAppSelector } from "app/store"
|
||||||
import { flattenCategoryTree } from "app/utils"
|
import { flattenCategoryTree } from "app/utils"
|
||||||
|
|
||||||
type CategorySelectProps = Partial<SelectProps> & { withAll?: boolean }
|
type CategorySelectProps = Partial<SelectProps> & {
|
||||||
|
withAll?: boolean
|
||||||
|
withoutCategoryIds?: string[]
|
||||||
|
}
|
||||||
|
|
||||||
export function CategorySelect(props: CategorySelectProps) {
|
export function CategorySelect(props: CategorySelectProps) {
|
||||||
const rootCategory = useAppSelector(state => state.tree.rootCategory)
|
const rootCategory = useAppSelector(state => state.tree.rootCategory)
|
||||||
const categories = rootCategory && flattenCategoryTree(rootCategory)
|
const categories = rootCategory && flattenCategoryTree(rootCategory)
|
||||||
const selectData: SelectItem[] | undefined = categories
|
const selectData: SelectItem[] | undefined = categories
|
||||||
?.filter(c => c.id !== Constants.categories.all.id)
|
?.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))
|
.sort((c1, c2) => c1.name.localeCompare(c2.name))
|
||||||
.map(c => ({
|
.map(c => ({
|
||||||
label: c.name,
|
label: c.parentName ? t`${c.name} (in ${c.parentName})` : c.name,
|
||||||
value: c.id,
|
value: c.id,
|
||||||
}))
|
}))
|
||||||
if (props.withAll) {
|
if (props.withAll) {
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "الملف مطلوب"
|
msgstr "الملف مطلوب"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "el fitxer és necessari"
|
msgstr "el fitxer és necessari"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "mae angen y ffeil"
|
msgstr "mae angen y ffeil"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "fil er påkrævet"
|
msgstr "fil er påkrævet"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "Datei ist erforderlich"
|
msgstr "Datei ist erforderlich"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr "Your feeds have been queued for refresh."
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "file is required"
|
msgstr "file is required"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr "{0} (in {1})"
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "archivo requerido"
|
msgstr "archivo requerido"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "فایل مورد نیاز است"
|
msgstr "فایل مورد نیاز است"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "tiedosto vaaditaan"
|
msgstr "tiedosto vaaditaan"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "fichier requis"
|
msgstr "fichier requis"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "é necesario o ficheiro"
|
msgstr "é necesario o ficheiro"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "fájl szükséges"
|
msgstr "fájl szükséges"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "file diperlukan"
|
msgstr "file diperlukan"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "è richiesto il file"
|
msgstr "è richiesto il file"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "ファイルが必要です"
|
msgstr "ファイルが必要です"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "파일이 필요합니다"
|
msgstr "파일이 필요합니다"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "fail diperlukan"
|
msgstr "fail diperlukan"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "fil kreves"
|
msgstr "fil kreves"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "bestand is vereist"
|
msgstr "bestand is vereist"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "fil kreves"
|
msgstr "fil kreves"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "plik jest wymagany"
|
msgstr "plik jest wymagany"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "o arquivo é obrigatório"
|
msgstr "o arquivo é obrigatório"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "требуется файл"
|
msgstr "требуется файл"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "fil krävs"
|
msgstr "fil krävs"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "dosya gerekli"
|
msgstr "dosya gerekli"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -795,3 +795,7 @@ msgstr ""
|
|||||||
#: src/components/content/add/ImportOpml.tsx
|
#: src/components/content/add/ImportOpml.tsx
|
||||||
msgid "file is required"
|
msgid "file is required"
|
||||||
msgstr "文件是必需的"
|
msgstr "文件是必需的"
|
||||||
|
|
||||||
|
#: src/components/content/add/CategorySelect.tsx
|
||||||
|
msgid "{0} (in {1})"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -109,7 +109,12 @@ export function CategoryDetailsPage() {
|
|||||||
{editable && (
|
{editable && (
|
||||||
<>
|
<>
|
||||||
<TextInput label={t`Name`} {...form.getInputProps("name")} required />
|
<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} />
|
<NumberInput label={t`Position`} {...form.getInputProps("position")} required min={0} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ public class Category implements Serializable {
|
|||||||
@ApiModelProperty(value = "parent category id")
|
@ApiModelProperty(value = "parent category id")
|
||||||
private String parentId;
|
private String parentId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "parent category name")
|
||||||
|
private String parentName;
|
||||||
|
|
||||||
@ApiModelProperty(value = "category id", required = true)
|
@ApiModelProperty(value = "category id", required = true)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|||||||
@@ -454,17 +454,13 @@ public class CategoryREST {
|
|||||||
child.setPosition(c.getPosition());
|
child.setPosition(c.getPosition());
|
||||||
if (c.getParent() != null && c.getParent().getId() != null) {
|
if (c.getParent() != null && c.getParent().getId() != null) {
|
||||||
child.setParentId(String.valueOf(c.getParent().getId()));
|
child.setParentId(String.valueOf(c.getParent().getId()));
|
||||||
|
child.setParentName(c.getParent().getName());
|
||||||
}
|
}
|
||||||
child.setExpanded(!c.isCollapsed());
|
child.setExpanded(!c.isCollapsed());
|
||||||
category.getChildren().add(child);
|
category.getChildren().add(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(category.getChildren(), new Comparator<Category>() {
|
Collections.sort(category.getChildren(), (o1, o2) -> ObjectUtils.compare(o1.getPosition(), o2.getPosition()));
|
||||||
@Override
|
|
||||||
public int compare(Category o1, Category o2) {
|
|
||||||
return ObjectUtils.compare(o1.getPosition(), o2.getPosition());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (FeedSubscription subscription : subscriptions) {
|
for (FeedSubscription subscription : subscriptions) {
|
||||||
if (id == null && subscription.getCategory() == null
|
if (id == null && subscription.getCategory() == null
|
||||||
@@ -474,12 +470,8 @@ public class CategoryREST {
|
|||||||
category.getFeeds().add(sub);
|
category.getFeeds().add(sub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(category.getFeeds(), new Comparator<Subscription>() {
|
Collections.sort(category.getFeeds(), (o1, o2) -> ObjectUtils.compare(o1.getPosition(), o2.getPosition()));
|
||||||
@Override
|
|
||||||
public int compare(Subscription o1, Subscription o2) {
|
|
||||||
return ObjectUtils.compare(o1.getPosition(), o2.getPosition());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return category;
|
return category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user