feat: Show nested document count on document list items on collection home
This commit is contained in:
@ -23,6 +23,7 @@ type Props = {|
|
|||||||
document: Document,
|
document: Document,
|
||||||
highlight?: ?string,
|
highlight?: ?string,
|
||||||
context?: ?string,
|
context?: ?string,
|
||||||
|
showNestedDocuments?: boolean,
|
||||||
showCollection?: boolean,
|
showCollection?: boolean,
|
||||||
showPublished?: boolean,
|
showPublished?: boolean,
|
||||||
showPin?: boolean,
|
showPin?: boolean,
|
||||||
@ -44,6 +45,7 @@ function DocumentListItem(props: Props) {
|
|||||||
const [menuOpen, setMenuOpen] = React.useState(false);
|
const [menuOpen, setMenuOpen] = React.useState(false);
|
||||||
const {
|
const {
|
||||||
document,
|
document,
|
||||||
|
showNestedDocuments,
|
||||||
showCollection,
|
showCollection,
|
||||||
showPublished,
|
showPublished,
|
||||||
showPin,
|
showPin,
|
||||||
@ -104,6 +106,7 @@ function DocumentListItem(props: Props) {
|
|||||||
document={document}
|
document={document}
|
||||||
showCollection={showCollection}
|
showCollection={showCollection}
|
||||||
showPublished={showPublished}
|
showPublished={showPublished}
|
||||||
|
showNestedDocuments={showNestedDocuments}
|
||||||
showLastViewed
|
showLastViewed
|
||||||
/>
|
/>
|
||||||
</Content>
|
</Content>
|
||||||
|
@ -27,6 +27,7 @@ type Props = {|
|
|||||||
showCollection?: boolean,
|
showCollection?: boolean,
|
||||||
showPublished?: boolean,
|
showPublished?: boolean,
|
||||||
showLastViewed?: boolean,
|
showLastViewed?: boolean,
|
||||||
|
showNestedDocuments?: boolean,
|
||||||
document: Document,
|
document: Document,
|
||||||
children: React.Node,
|
children: React.Node,
|
||||||
to?: string,
|
to?: string,
|
||||||
@ -36,6 +37,7 @@ function DocumentMeta({
|
|||||||
showPublished,
|
showPublished,
|
||||||
showCollection,
|
showCollection,
|
||||||
showLastViewed,
|
showLastViewed,
|
||||||
|
showNestedDocuments,
|
||||||
document,
|
document,
|
||||||
children,
|
children,
|
||||||
to,
|
to,
|
||||||
@ -123,6 +125,10 @@ function DocumentMeta({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const nestedDocumentsCount = collection
|
||||||
|
? collection.getDocumentChildren(document.id).length
|
||||||
|
: 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container align="center" {...rest}>
|
<Container align="center" {...rest}>
|
||||||
{updatedByMe ? t("You") : updatedBy.name}
|
{updatedByMe ? t("You") : updatedBy.name}
|
||||||
@ -135,6 +141,12 @@ function DocumentMeta({
|
|||||||
</strong>
|
</strong>
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
{showNestedDocuments && nestedDocumentsCount > 0 && (
|
||||||
|
<span>
|
||||||
|
· {nestedDocumentsCount}{" "}
|
||||||
|
{t("nested document", { count: nestedDocumentsCount })}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
{timeSinceNow()}
|
{timeSinceNow()}
|
||||||
{children}
|
{children}
|
||||||
</Container>
|
</Container>
|
||||||
|
@ -11,6 +11,7 @@ type Props = {|
|
|||||||
options?: Object,
|
options?: Object,
|
||||||
heading?: React.Node,
|
heading?: React.Node,
|
||||||
empty?: React.Node,
|
empty?: React.Node,
|
||||||
|
showNestedDocuments?: boolean,
|
||||||
showCollection?: boolean,
|
showCollection?: boolean,
|
||||||
showPublished?: boolean,
|
showPublished?: boolean,
|
||||||
showPin?: boolean,
|
showPin?: boolean,
|
||||||
|
@ -352,6 +352,7 @@ class CollectionScene extends React.Component<Props> {
|
|||||||
sort: collection.sort.field,
|
sort: collection.sort.field,
|
||||||
direction: "ASC",
|
direction: "ASC",
|
||||||
}}
|
}}
|
||||||
|
showNestedDocuments
|
||||||
showPin
|
showPin
|
||||||
/>
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
|
@ -32,15 +32,15 @@ class References extends React.Component<Props> {
|
|||||||
: [];
|
: [];
|
||||||
|
|
||||||
const showBacklinks = !!backlinks.length;
|
const showBacklinks = !!backlinks.length;
|
||||||
const showChildren = !!children.length;
|
const showNestedDocuments = !!children.length;
|
||||||
const isBacklinksTab =
|
const isBacklinksTab =
|
||||||
this.props.location.hash === "#backlinks" || !showChildren;
|
this.props.location.hash === "#backlinks" || !showNestedDocuments;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
(showBacklinks || showChildren) && (
|
(showBacklinks || showNestedDocuments) && (
|
||||||
<Fade>
|
<Fade>
|
||||||
<Tabs>
|
<Tabs>
|
||||||
{showChildren && (
|
{showNestedDocuments && (
|
||||||
<Tab to="#children" isActive={() => !isBacklinksTab}>
|
<Tab to="#children" isActive={() => !isBacklinksTab}>
|
||||||
Nested documents
|
Nested documents
|
||||||
</Tab>
|
</Tab>
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
"Never viewed": "Never viewed",
|
"Never viewed": "Never viewed",
|
||||||
"Viewed": "Viewed",
|
"Viewed": "Viewed",
|
||||||
"in": "in",
|
"in": "in",
|
||||||
|
"nested document": "nested document",
|
||||||
|
"nested document_plural": "nested documents",
|
||||||
"Insert column after": "Insert column after",
|
"Insert column after": "Insert column after",
|
||||||
"Insert column before": "Insert column before",
|
"Insert column before": "Insert column before",
|
||||||
"Insert row after": "Insert row after",
|
"Insert row after": "Insert row after",
|
||||||
|
Reference in New Issue
Block a user