Added subtitle and pretitle to content

This commit is contained in:
DrMint 2022-02-08 09:44:17 +01:00
parent 676b73318e
commit 1d42821eed
5 changed files with 218 additions and 19 deletions

View File

@ -252,6 +252,24 @@ query getLibraryItem($slug: String, $language_code: String) {
} }
} }
} }
... on ComponentMetadataMerch {
merch_item {
data {
attributes {
slug
}
}
}
}
... on ComponentMetadataOther {
subtype {
data {
attributes {
slug
}
}
}
}
} }
subitem_of { subitem_of {
data { data {
@ -326,7 +344,9 @@ query getLibraryItem($slug: String, $language_code: String) {
titles( titles(
filters: { language: { code: { eq: $language_code } } } filters: { language: { code: { eq: $language_code } } }
) { ) {
pre_title
title title
subtitle
} }
text_set { text_set {
id id

View File

@ -50,10 +50,10 @@ export enum Enum_Componentmetadatavideo_Resolution {
} }
export enum Enum_Componenttranslationschronologyitem_Status { export enum Enum_Componenttranslationschronologyitem_Status {
Incomplete = 'Incomplete', Incomplete = "Incomplete",
Draft = 'Draft', Draft = "Draft",
Review = 'Review', Review = "Review",
Done = 'Done' Done = "Done",
} }
// __________________________________________________________________ // __________________________________________________________________
@ -397,6 +397,32 @@ export type GetLibraryItemQuery = {
}>; }>;
}; };
} }
| {
__typename: "ComponentMetadataMerch";
merch_item: {
__typename: "MerchItemEntityResponse";
data: {
__typename: "MerchItemEntity";
attributes: {
__typename: "MerchItem";
slug: string;
};
};
};
}
| {
__typename: "ComponentMetadataOther";
subtype: {
__typename: "OtherSubtypeEntityResponse";
data: {
__typename: "OtherSubtypeEntity";
attributes: {
__typename: "OtherSubtype";
slug: string;
};
};
};
}
| { __typename: "Error" } | { __typename: "Error" }
>; >;
subitem_of: { subitem_of: {
@ -496,7 +522,9 @@ export type GetLibraryItemQuery = {
}; };
titles: Array<{ titles: Array<{
__typename: "ComponentTranslationsTitle"; __typename: "ComponentTranslationsTitle";
pre_title: string;
title: string; title: string;
subtitle: string;
}>; }>;
text_set: Array<{ text_set: Array<{
__typename: "ComponentSetsTextSet"; __typename: "ComponentSetsTextSet";

View File

@ -482,6 +482,16 @@ type ComponentMetadataGame {
): LanguageRelationResponseCollection ): LanguageRelationResponseCollection
} }
type ComponentMetadataMerch {
id: ID!
merch_item: MerchItemEntityResponse
}
type ComponentMetadataOther {
id: ID!
subtype: OtherSubtypeEntityResponse
}
enum ENUM_COMPONENTMETADATAVIDEO_RESOLUTION { enum ENUM_COMPONENTMETADATAVIDEO_RESOLUTION {
SD_480p SD_480p
HD_720p HD_720p
@ -1398,6 +1408,7 @@ input ContentInput {
text_set: [ComponentSetsTextSetInput] text_set: [ComponentSetsTextSetInput]
video_set: [ComponentSetsVideoSetInput] video_set: [ComponentSetsVideoSetInput]
audio_set: [ComponentSetsAudioSetInput] audio_set: [ComponentSetsAudioSetInput]
thumbnail: ID
} }
type Content { type Content {
@ -1433,6 +1444,7 @@ type Content {
pagination: PaginationArg = {} pagination: PaginationArg = {}
sort: [String] = [] sort: [String] = []
): [ComponentSetsAudioSet] ): [ComponentSetsAudioSet]
thumbnail: UploadFileEntityResponse
createdAt: DateTime createdAt: DateTime
updatedAt: DateTime updatedAt: DateTime
} }
@ -1693,6 +1705,8 @@ union LibraryItemMetadataDynamicZone =
| ComponentMetadataVideo | ComponentMetadataVideo
| ComponentMetadataGame | ComponentMetadataGame
| ComponentMetadataAudio | ComponentMetadataAudio
| ComponentMetadataMerch
| ComponentMetadataOther
| Error | Error
scalar LibraryItemMetadataDynamicZoneInput scalar LibraryItemMetadataDynamicZoneInput
@ -1830,6 +1844,74 @@ type LibraryVariantEntityResponseCollection {
meta: ResponseCollectionMeta! meta: ResponseCollectionMeta!
} }
input MerchItemFiltersInput {
id: IDFilterInput
slug: StringFilterInput
createdAt: DateTimeFilterInput
updatedAt: DateTimeFilterInput
and: [MerchItemFiltersInput]
or: [MerchItemFiltersInput]
not: MerchItemFiltersInput
}
input MerchItemInput {
slug: String
}
type MerchItem {
slug: String!
createdAt: DateTime
updatedAt: DateTime
}
type MerchItemEntity {
id: ID
attributes: MerchItem
}
type MerchItemEntityResponse {
data: MerchItemEntity
}
type MerchItemEntityResponseCollection {
data: [MerchItemEntity!]!
meta: ResponseCollectionMeta!
}
input OtherSubtypeFiltersInput {
id: IDFilterInput
slug: StringFilterInput
createdAt: DateTimeFilterInput
updatedAt: DateTimeFilterInput
and: [OtherSubtypeFiltersInput]
or: [OtherSubtypeFiltersInput]
not: OtherSubtypeFiltersInput
}
input OtherSubtypeInput {
slug: String
}
type OtherSubtype {
slug: String!
createdAt: DateTime
updatedAt: DateTime
}
type OtherSubtypeEntity {
id: ID
attributes: OtherSubtype
}
type OtherSubtypeEntityResponse {
data: OtherSubtypeEntity
}
type OtherSubtypeEntityResponseCollection {
data: [OtherSubtypeEntity!]!
meta: ResponseCollectionMeta!
}
input PostFiltersInput { input PostFiltersInput {
id: IDFilterInput id: IDFilterInput
authors: RecorderFiltersInput authors: RecorderFiltersInput
@ -2225,6 +2307,8 @@ union GenericMorph =
| ComponentMetadataAudio | ComponentMetadataAudio
| ComponentMetadataBooks | ComponentMetadataBooks
| ComponentMetadataGame | ComponentMetadataGame
| ComponentMetadataMerch
| ComponentMetadataOther
| ComponentMetadataVideo | ComponentMetadataVideo
| ComponentPageBuilderComponentPane | ComponentPageBuilderComponentPane
| ComponentPageBuilderComponentTab | ComponentPageBuilderComponentTab
@ -2270,6 +2354,8 @@ union GenericMorph =
| Language | Language
| LibraryItem | LibraryItem
| LibraryVariant | LibraryVariant
| MerchItem
| OtherSubtype
| Post | Post
| RangedContent | RangedContent
| Recorder | Recorder
@ -2377,6 +2463,18 @@ type Query {
pagination: PaginationArg = {} pagination: PaginationArg = {}
sort: [String] = [] sort: [String] = []
): LibraryVariantEntityResponseCollection ): LibraryVariantEntityResponseCollection
merchItem(id: ID): MerchItemEntityResponse
merchItems(
filters: MerchItemFiltersInput
pagination: PaginationArg = {}
sort: [String] = []
): MerchItemEntityResponseCollection
otherSubtype(id: ID): OtherSubtypeEntityResponse
otherSubtypes(
filters: OtherSubtypeFiltersInput
pagination: PaginationArg = {}
sort: [String] = []
): OtherSubtypeEntityResponseCollection
post(id: ID): PostEntityResponse post(id: ID): PostEntityResponse
posts( posts(
filters: PostFiltersInput filters: PostFiltersInput
@ -2494,6 +2592,15 @@ type Mutation {
data: LibraryVariantInput! data: LibraryVariantInput!
): LibraryVariantEntityResponse ): LibraryVariantEntityResponse
deleteLibraryVariant(id: ID!): LibraryVariantEntityResponse deleteLibraryVariant(id: ID!): LibraryVariantEntityResponse
createMerchItem(data: MerchItemInput!): MerchItemEntityResponse
updateMerchItem(id: ID!, data: MerchItemInput!): MerchItemEntityResponse
deleteMerchItem(id: ID!): MerchItemEntityResponse
createOtherSubtype(data: OtherSubtypeInput!): OtherSubtypeEntityResponse
updateOtherSubtype(
id: ID!
data: OtherSubtypeInput!
): OtherSubtypeEntityResponse
deleteOtherSubtype(id: ID!): OtherSubtypeEntityResponse
createPost(data: PostInput!): PostEntityResponse createPost(data: PostInput!): PostEntityResponse
updatePost(id: ID!, data: PostInput!): PostEntityResponse updatePost(id: ID!, data: PostInput!): PostEntityResponse
deletePost(id: ID!): PostEntityResponse deletePost(id: ID!): PostEntityResponse

View File

@ -11,6 +11,7 @@ import {
convertMmToInch, convertMmToInch,
getAssetURL, getAssetURL,
prettyDate, prettyDate,
prettyinlineTitle,
prettyPrice, prettyPrice,
prettySlug, prettySlug,
} from "queries/helpers"; } from "queries/helpers";
@ -102,10 +103,11 @@ export default function Library(props: Props): JSX.Element {
<Button <Button
href={`/library/${item.subitem_of.data[0].attributes.slug}`} href={`/library/${item.subitem_of.data[0].attributes.slug}`}
> >
{item.subitem_of.data[0].attributes.title} {prettyinlineTitle(
{item.subitem_of.data[0].attributes.subtitle "",
? ` - ${item.subitem_of.data[0].attributes.subtitle}` item.subitem_of.data[0].attributes.title,
: ""} item.subitem_of.data[0].attributes.subtitle
)}
</Button> </Button>
</div> </div>
) : ( ) : (
@ -237,7 +239,7 @@ export default function Library(props: Props): JSX.Element {
<div className="grid place-content-start grid-flow-col gap-4"> <div className="grid place-content-start grid-flow-col gap-4">
<p className="font-bold">Type:</p> <p className="font-bold">Type:</p>
<Chip> <Chip>
{capitalizeString( {prettySlug(
item.metadata[0].subtype.data.attributes.slug item.metadata[0].subtype.data.attributes.slug
)} )}
</Chip> </Chip>
@ -255,7 +257,7 @@ export default function Library(props: Props): JSX.Element {
<div className="grid place-content-start grid-flow-col gap-4"> <div className="grid place-content-start grid-flow-col gap-4">
<p className="font-bold">Page order:</p> <p className="font-bold">Page order:</p>
<p>{item.metadata[0].page_order}</p> <p>{prettySlug(item.metadata[0].page_order)}</p>
</div> </div>
<div className="grid place-content-start grid-flow-col gap-4"> <div className="grid place-content-start grid-flow-col gap-4">
@ -267,6 +269,30 @@ export default function Library(props: Props): JSX.Element {
))} ))}
</div> </div>
</> </>
) : item.metadata[0].__typename ===
"ComponentMetadataAudio" ? (
<></>
) : item.metadata[0].__typename ===
"ComponentMetadataVideo" ? (
<></>
) : item.metadata[0].__typename ===
"ComponentMetadataGame" ? (
<></>
) : item.metadata[0].__typename ===
"ComponentMetadataMerch" ? (
<></>
) : item.metadata[0].__typename ===
"ComponentMetadataOther" ? (
<>
<div className="grid place-content-start grid-flow-col gap-4">
<p className="font-bold">Type:</p>
<Chip>
{prettySlug(
item.metadata[0].subtype.data.attributes.slug
)}
</Chip>
</div>
</>
) : ( ) : (
"" ""
)} )}
@ -279,9 +305,9 @@ export default function Library(props: Props): JSX.Element {
</div> </div>
{item.subitems.data.length > 0 ? ( {item.subitems.data.length > 0 ? (
<div id="subitems" className="grid place-items-center gap-8"> <div id="subitems" className="grid place-items-center gap-8 w-full">
<h2 className="text-2xl">Subitems</h2> <h2 className="text-2xl">Subitems</h2>
<div className="grid gap-8 items-end grid-cols-[repeat(auto-fill,minmax(15rem,1fr))]"> <div className="grid gap-8 items-end grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] w-full">
{item.subitems.data.map((subitem) => ( {item.subitems.data.map((subitem) => (
<LibraryItemComponent key={subitem.id} item={subitem} /> <LibraryItemComponent key={subitem.id} item={subitem} />
))} ))}
@ -304,9 +330,17 @@ export default function Library(props: Props): JSX.Element {
<div className="grid gap-4 place-items-center grid-cols-[auto_auto_1fr_auto_9em] "> <div className="grid gap-4 place-items-center grid-cols-[auto_auto_1fr_auto_9em] ">
<a href={`#${content.attributes.slug}`}> <a href={`#${content.attributes.slug}`}>
<h3> <h3>
{content.attributes.content.data {content.attributes.content.data &&
? content.attributes.content.data.attributes content.attributes.content.data.attributes.titles
.titles[0].title .length > 0
? prettyinlineTitle(
content.attributes.content.data.attributes
.titles[0].pre_title,
content.attributes.content.data.attributes
.titles[0].title,
content.attributes.content.data.attributes
.titles[0].subtitle
)
: prettySlug(content.attributes.slug, item.slug)} : prettySlug(content.attributes.slug, item.slug)}
</h3> </h3>
</a> </a>
@ -328,10 +362,10 @@ export default function Library(props: Props): JSX.Element {
</p> </p>
{content.attributes.content.data ? ( {content.attributes.content.data ? (
<Chip className="place-self-end"> <Chip className="place-self-end">
{ {prettySlug(
content.attributes.content.data.attributes.type.data content.attributes.content.data.attributes.type.data
.attributes.slug .attributes.slug
} )}
</Chip> </Chip>
) : ( ) : (
"" ""

View File

@ -31,10 +31,20 @@ export function prettyPrice(
export function prettySlug(slug: string, parentSlug?: string): string { export function prettySlug(slug: string, parentSlug?: string): string {
if (parentSlug && slug.startsWith(parentSlug)) if (parentSlug && slug.startsWith(parentSlug))
slug = slug.substring(parentSlug.length + 1); slug = slug.substring(parentSlug.length + 1);
return capitalizeString(slug.replace(new RegExp("-", 'g'), " ")) slug = slug.replace(new RegExp("-", 'g'), " ");
return slug; slug = slug.replace(new RegExp("_", 'g'), " ");
return capitalizeString(slug)
} }
export function prettyinlineTitle(pretitle:string, title: string, subtitle:string): string {
let result = "";
if (pretitle) result += pretitle + ": "
result += title;
if (subtitle) result += " - " + subtitle;
return result;
}
export function capitalizeString(string:string):string { export function capitalizeString(string:string):string {
function capitalizeWord(word: string): string { function capitalizeWord(word: string): string {
return word.charAt(0).toUpperCase() + word.substring(1); return word.charAt(0).toUpperCase() + word.substring(1);