-
Notifications
You must be signed in to change notification settings - Fork 1
BOS-63: Changed/added/refactored frontend data classes #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import { Author } from './author'; | ||
| import { Genre } from './genre'; | ||
| import { InventoryLocation } from './inventory-location'; | ||
| import { Theme } from './theme'; | ||
| import { Story } from './story'; | ||
|
|
||
| export enum AnthologyStatus { | ||
| ARCHIVED = 'Archived', | ||
| NOT_STARTED = 'NotStarted', | ||
| DRAFTING = 'Drafting', | ||
| CAN_BE_SHARED = 'CanBeShared', | ||
| } | ||
|
|
||
| export enum AnthologyPubLevel { | ||
| ZINE = 'Zine', | ||
| CHAPBOOK = 'Chapbook', | ||
| PERFECT_BOUND = 'PerfectBound', | ||
| SIGNATURE = 'Signature', | ||
| } | ||
|
|
||
| export class Anthology { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would change Anthology to an interface and make the methods free-standing getters since a publication will need be edited in the tracker view! |
||
| constructor( | ||
| public id: number, | ||
| public title: string, | ||
| public published_year: number, | ||
| public status: AnthologyStatus, | ||
| public stories?: Story[], | ||
| public subtitle?: string, | ||
| public byline?: string, | ||
| public description?: string, | ||
| public updated_at?: string, | ||
| public photo_url?: string, | ||
|
|
||
| // Additional fields from metadata | ||
| public foreword_author?: string, | ||
| public praise_quotes?: string, | ||
| public age_category?: string, | ||
| public isbn?: string, | ||
| public shopify_url?: string, | ||
| public binding_type?: string, | ||
| public dimensions?: string, | ||
| public printing_cost?: string, | ||
| public print_run?: number, | ||
| public weight?: string, | ||
| public page_count?: number, | ||
| public printed_by?: string, | ||
| public pub_level?: AnthologyPubLevel, | ||
| public publishing_permission?: string, | ||
| public programs?: string[], | ||
| public sponsors?: string[], | ||
| public number_of_students?: number, | ||
| public total_inventory?: number, | ||
| public inventory_locations?: InventoryLocation[], | ||
|
|
||
| // cached aggregated data from stories | ||
| private _authors?: Author[], | ||
| private _genres?: Genre[], | ||
| private _themes?: Theme[], | ||
| ) {} | ||
|
|
||
| getAuthors(): Author[] { | ||
| if (this._authors !== undefined) { | ||
| return this._authors; | ||
| } | ||
|
|
||
| const authors = this.stories?.flatMap((story) => story.authors) ?? []; | ||
| this._authors = authors; | ||
| return authors; | ||
| } | ||
|
|
||
| getGenres(): Genre[] { | ||
| if (this._genres !== undefined) { | ||
| return this._genres; | ||
| } | ||
|
|
||
| const genres = this.stories?.flatMap((story) => story.genres ?? []) ?? []; | ||
| this._genres = genres; | ||
| return genres; | ||
| } | ||
|
|
||
| getThemes(): Theme[] { | ||
| if (this._themes !== undefined) { | ||
| return this._themes; | ||
| } | ||
|
|
||
| const themes = this.stories?.flatMap((story) => story.themes ?? []) ?? []; | ||
| this._themes = themes; | ||
| return themes; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| export interface Author { | ||
| id: number; | ||
| name: string; | ||
| bio?: string; | ||
| grade?: number; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export interface Genre { | ||
| id: number; | ||
| name: string; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export interface InventoryLocation { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We now have an inventory-holding join table in the backend that has an id, inventory_id, anthology_id, and num_copies. However since we only have to display this info on the frontend it might be convenient to just store id, inventory_name, anthology_name, and num_copies in InventoryLocation. |
||
| id: number; | ||
| name: string; | ||
| num_copies: number; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the client meeting we made some changes to the anthology backend entity so that general book info and additional metadata such as production info are stored separately. For Anthology, the only fields needed are id, title, description, published_year, programs, status, pub_level, photo_url, isbn, and shopify_url. For the other production related information, I would create an additional interface called ProductionInfo that stores id, anthology_id, design_files_link, cover_image_file_link, binding_type, dimensions, printing_cost, print_run, weight_in_grams, page_count, and printed_by. You can see more details on the updated backend entities in our ticket notes for this week!