Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,15 @@ type AudioSlice {
}


"""
Enum to represent whether a chapter in a collection's table of contents is a page or a document
"""
enum ChapterContents {
DOCUMENT
PAGE
UNKNOWN
}

"""
One representation of Cherokee phonology.
There are several different writing systems for Cherokee phonology and we
Expand Down Expand Up @@ -382,6 +391,7 @@ type CollectionChapter {
Breadcrumbs from the top-level archive down to where this document lives.
"""
breadcrumbs: [DocumentCollection!]!
contentType: ChapterContents!
}

"""
Expand Down
20 changes: 20 additions & 0 deletions types/src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ pub enum CollectionSection {
Credit,
}

/// Enum to represent whether a chapter in a collection's table of contents is a page or a document
#[derive(
async_graphql::Enum, Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize,
)]
pub enum ChapterContents {
Document,
Page,
Unknown,
}

#[async_graphql::ComplexObject]
impl EditedCollection {
/// URL slug for the collection, like "cwkw"
Expand Down Expand Up @@ -122,6 +132,16 @@ impl CollectionChapter {
.chapter_breadcrumbs(self.path.clone())
.await?)
}

async fn content_type(&self, context: &Context<'_>) -> FieldResult<ChapterContents> {
match (self.document_id.is_some(), self.wordpress_id.is_some()) {
(true, false) => Ok(ChapterContents::Document),
(false, true) => Ok(ChapterContents::Page),
(false, false) => Ok(ChapterContents::Unknown),
// having both ids is an impossible case as of 2/19/2026, but just to make sure
(true, true) => Ok(ChapterContents::Unknown),
}
}
}

/// Input for creating an edited collection
Expand Down
20 changes: 18 additions & 2 deletions website/src/graphql/dailp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,13 @@ export type AudioSlice = {
readonly startTime: Maybe<Scalars["Int"]>
}

/** Enum to represent whether a chapter in a collection's table of contents is a page or a document */
export enum ChapterContents {
Document = "DOCUMENT",
Page = "PAGE",
Unknown = "UNKNOWN",
}

/**
* One representation of Cherokee phonology.
* There are several different writing systems for Cherokee phonology and we
Expand All @@ -306,6 +313,7 @@ export type CollectionChapter = {
readonly __typename?: "CollectionChapter"
/** Breadcrumbs from the top-level archive down to where this document lives. */
readonly breadcrumbs: ReadonlyArray<DocumentCollection>
readonly contentType: ChapterContents
readonly document: Maybe<AnnotatedDoc>
/** UUID for the chapter */
readonly id: Scalars["UUID"]
Expand Down Expand Up @@ -2199,7 +2207,13 @@ export type EditedCollectionQuery = { readonly __typename?: "Query" } & {
ReadonlyArray<
{ readonly __typename?: "CollectionChapter" } & Pick<
CollectionChapter,
"id" | "title" | "indexInParent" | "section" | "path" | "slug"
| "id"
| "title"
| "indexInParent"
| "section"
| "path"
| "slug"
| "contentType"
>
>
>
Expand Down Expand Up @@ -2569,7 +2583,7 @@ export type CollectionChapterQuery = { readonly __typename?: "Query" } & {
readonly chapter: Maybe<
{ readonly __typename?: "CollectionChapter" } & Pick<
CollectionChapter,
"id" | "title" | "wordpressId" | "slug"
"id" | "title" | "wordpressId" | "slug" | "contentType"
> & {
readonly breadcrumbs: ReadonlyArray<
{ readonly __typename?: "DocumentCollection" } & Pick<
Expand Down Expand Up @@ -3848,6 +3862,7 @@ export const EditedCollectionDocument = gql`
section
path
slug
contentType
}
}
}
Expand Down Expand Up @@ -4165,6 +4180,7 @@ export const CollectionChapterDocument = gql`
title
wordpressId
slug
contentType
breadcrumbs {
name
slug
Expand Down
2 changes: 2 additions & 0 deletions website/src/graphql/dailp/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ query EditedCollection($slug: String!) {
section
path
slug
contentType
}
}
}
Expand Down Expand Up @@ -472,6 +473,7 @@ query CollectionChapter($collectionSlug: String!, $chapterSlug: String!) {
title
wordpressId
slug
contentType
breadcrumbs {
name
slug
Expand Down
71 changes: 42 additions & 29 deletions website/src/pages/dailp.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import Markdown from "react-markdown"
import { UserRole, useUserRole } from "src/auth"
import { Link } from "src/components"
import {
ChapterContents,
CollectionSection,
MenuUpdate,
useEditedCollectionQuery,
useEditedCollectionsQuery,
useMenuBySlugQuery,
usePageByPathQuery,
Expand Down Expand Up @@ -53,10 +55,15 @@ export const DailpPageContents = (props: { path: string }) => {
// check if page belongs in a collection
const collectionSlug = props.path.split("/")[1]

// todo: need way to differentiate between documents and pages in chapters
// const collectionChapters = collectionData?.editedCollection?.chapters?.filter((chapter) =>
// (chapter.))
const [{ data: collectionPagesData }] = useEditedCollectionQuery({
variables: { slug: collectionSlug || "" },
pause: fetching || !collectionSlug,
})

const collectionPageChapters =
collectionPagesData?.editedCollection?.chapters?.filter(
(ch) => ch.contentType === ChapterContents.Page
)
const page = data?.pageByPath
const collectionSections = [
CollectionSection.Intro,
Expand Down Expand Up @@ -101,15 +108,18 @@ export const DailpPageContents = (props: { path: string }) => {
const handlePublishClick = (e: React.MouseEvent<HTMLButtonElement>) => {
const action = isPublished && !isLocationSelected ? "unpublish" : "publish"
const confirm = window.confirm(
`Are you sure you want to ${action} this page?`
`Are you sure you want to ${action} this page? (Publishing feature for collections is still in development.)`
)
if (!confirm) {
e.preventDefault()
return
}
if (isInCollection) {
// update table of contents method here
// publish page code not merged yet
// todo: add collections publishing backend
alert(
"Action failed: Publishing feature for collections is still in development."
)
return
} else {
const toMenuItemInput = (
nodes: any[] | undefined
Expand Down Expand Up @@ -165,7 +175,10 @@ export const DailpPageContents = (props: { path: string }) => {
}

const locationList = isInCollection
? collectionSections?.map((item) => (
? [
...(collectionSections ?? []),
...(collectionPageChapters?.map((ch) => ch.title) ?? []),
].map((item) => (
<option key={item} value={item}>
Copy link
Copy Markdown
Collaborator

@nole2701 nole2701 Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would there be a way to distinguish between sections and chapter titles that have the same name when in the menu dropdown?

{item}
</option>
Expand All @@ -176,27 +189,27 @@ export const DailpPageContents = (props: { path: string }) => {
</option>
))

// katie todo: delete this after backend method to change collection table of contents is implemented
if (isInCollection) {
return (
<>
<header>
<h1>{page.title}</h1>
{/* dennis todo: should be admin in the future */}
{userRole === UserRole.Editor && (
<div>
<Link href={`/edit?path=${props.path}`}>Edit</Link>
</div>
)}
</header>
{content.charAt(0) === "<" ? (
<div dangerouslySetInnerHTML={{ __html: content }} />
) : (
<Markdown>{content}</Markdown>
)}
</>
)
}
// // katie todo: delete this after backend method to change collection table of contents is implemented
// if (isInCollection) {
// return (
// <>
// <header>
// <h1>{page.title}</h1>
// {/* dennis todo: should be admin in the future */}
// {userRole === UserRole.Editor && (
// <div>
// <Link href={`/edit?path=${props.path}`}>Edit</Link>
// </div>
// )}
// </header>
// {content.charAt(0) === "<" ? (
// <div dangerouslySetInnerHTML={{ __html: content }} />
// ) : (
// <Markdown>{content}</Markdown>
// )}
// </>
// )
// }

return (
<>
Expand All @@ -214,7 +227,7 @@ export const DailpPageContents = (props: { path: string }) => {
<div>
<div>
<label>
Set Page Location:
Set New Page Location:
<select
value={selectedLocation}
onChange={(e) => setSelectedLocation(e.target.value)}
Expand Down
Loading