-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add boards and board members collections
- Loading branch information
1 parent
a2ccaa9
commit 4e58094
Showing
10 changed files
with
3,093 additions
and
1,012 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import type { CollectionConfig } from "payload/types"; | ||
import { signedIn } from "../../access/signed-in"; | ||
import { guildYearField } from "../../fields/guild-year"; | ||
|
||
export const BoardMembers: CollectionConfig = { | ||
slug: "board-members", | ||
defaultSort: "-guildYear", | ||
admin: { | ||
useAsTitle: "name", | ||
defaultColumns: ["guildYear", "photo", "name", "title"], | ||
}, | ||
access: { | ||
read: () => true, | ||
create: signedIn, | ||
update: signedIn, | ||
delete: signedIn, | ||
}, | ||
fields: [ | ||
guildYearField({ | ||
name: "guildYear", | ||
required: true, | ||
}), | ||
{ | ||
name: "photo", | ||
type: "relationship", | ||
relationTo: "media", | ||
}, | ||
{ | ||
name: "name", | ||
type: "text", | ||
required: true, | ||
}, | ||
{ | ||
name: "title", | ||
type: "text", | ||
required: true, | ||
localized: true, | ||
}, | ||
{ | ||
name: "email", | ||
type: "email", | ||
required: true, | ||
}, | ||
{ | ||
name: "telegram", | ||
type: "text", | ||
required: true, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import type { Board } from "@tietokilta/cms-types/payload"; | ||
import type { CollectionConfig, FilterOptions } from "payload/types"; | ||
import { signedIn } from "../../access/signed-in"; | ||
import { guildYearField } from "../../fields/guild-year"; | ||
|
||
const filterCurrentYear: FilterOptions<Board> = ({ data }) => ({ | ||
guildYear: { | ||
equals: data.year, | ||
}, | ||
}); | ||
|
||
export const Boards: CollectionConfig = { | ||
slug: "boards", | ||
defaultSort: "-year", | ||
admin: { | ||
useAsTitle: "year", | ||
defaultColumns: ["year", "groupPhoto"], | ||
}, | ||
access: { | ||
read: () => true, | ||
create: signedIn, | ||
update: signedIn, | ||
delete: signedIn, | ||
}, | ||
fields: [ | ||
guildYearField({ | ||
name: "year", | ||
required: true, | ||
}), | ||
{ | ||
name: "description", | ||
maxLength: 360, | ||
type: "textarea", | ||
localized: true, | ||
required: true, | ||
}, | ||
{ | ||
name: "groupPhoto", | ||
type: "relationship", | ||
relationTo: "media", | ||
}, | ||
{ | ||
name: "boardMembers", | ||
type: "array", | ||
required: true, | ||
minRows: 3, | ||
fields: [ | ||
{ | ||
name: "boardMember", | ||
type: "relationship", | ||
relationTo: "board-members", | ||
filterOptions: filterCurrentYear, | ||
}, | ||
], | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Field, FieldBase } from "payload/dist/fields/config/types"; | ||
|
||
const currentYear = new Date().getFullYear(); | ||
const foundedYear = 1986; | ||
|
||
export const guildYearField = ( | ||
base: Omit<FieldBase, "name"> & { name?: string } = {}, | ||
): Field => ({ | ||
name: "guildYear", | ||
hasMany: false, | ||
...base, | ||
type: "select", | ||
options: Array.from( | ||
{ length: currentYear - foundedYear + 1 }, | ||
(_, i) => `${currentYear - i}`, | ||
), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
[{ | ||
"_id": { | ||
"$oid": "65a6abbbc653ae138bb3c085" | ||
}, | ||
"guildYear": "2024", | ||
"name": "Mikael Siidorow", | ||
"title": { | ||
"fi": "Puheenjohtaja", | ||
"en": "Chair" | ||
}, | ||
"email": "[email protected]", | ||
"telegram": "Tietokila", | ||
"createdAt": { | ||
"$date": "2024-01-16T16:15:55.83Z" | ||
}, | ||
"updatedAt": { | ||
"$date": "2024-01-16T16:16:35.564Z" | ||
}, | ||
"__v": 0 | ||
}, | ||
{ | ||
"_id": { | ||
"$oid": "65a6ace2990f05954dcac743" | ||
}, | ||
"guildYear": "2024", | ||
"name": "Lauri Lappalainen", | ||
"title": { | ||
"fi": "Varapuheenjohtaja", | ||
"en": "Vice Chair" | ||
}, | ||
"email": "[email protected]", | ||
"telegram": "labbbis", | ||
"createdAt": { | ||
"$date": "2024-01-16T16:20:50.659Z" | ||
}, | ||
"updatedAt": { | ||
"$date": "2024-01-16T16:21:34.767Z" | ||
}, | ||
"__v": 0 | ||
}, | ||
{ | ||
"_id": { | ||
"$oid": "65a6ad15990f05954dcac75f" | ||
}, | ||
"guildYear": "2024", | ||
"name": "Samu \"Chef\" Paakkari", | ||
"title": { | ||
"fi": "Rahastonhoitaja", | ||
"en": "Treasurer" | ||
}, | ||
"email": "[email protected]", | ||
"telegram": "chefz", | ||
"createdAt": { | ||
"$date": "2024-01-16T16:21:41.475Z" | ||
}, | ||
"updatedAt": { | ||
"$date": "2024-01-16T16:22:08.083Z" | ||
}, | ||
"__v": 0 | ||
}, | ||
{ | ||
"_id": { | ||
"$oid": "65a6b338848d0618d686b114" | ||
}, | ||
"guildYear": "2023", | ||
"name": "Joonas Sorvari", | ||
"title": { | ||
"fi": "Puheenjohtaja", | ||
"en": "Chair" | ||
}, | ||
"email": "[email protected]", | ||
"telegram": "Tietokila", | ||
"createdAt": { | ||
"$date": "2024-01-16T16:47:52.452Z" | ||
}, | ||
"updatedAt": { | ||
"$date": "2024-01-16T16:47:57.851Z" | ||
}, | ||
"__v": 0 | ||
}] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[{ | ||
"_id": { | ||
"$oid": "65a6b375848d0618d686b139" | ||
}, | ||
"year": "2024", | ||
"description": { | ||
"en": "Tällä sivulla on esitelty killan hallituksen jäsenet vuodelle 2024 yhteystietoineen.\nMikäli haluat ottaa yhteyttä koko hallitukseen, voit lähettää sähköpostia osoitteeseen hallitus (at) tietokilta.fi." | ||
}, | ||
"boardMembers": [ | ||
{ | ||
"boardMember": "65a6abbbc653ae138bb3c085", | ||
"id": "65a6b3753aabf6ee79336ffe" | ||
}, | ||
{ | ||
"boardMember": "65a6ad15990f05954dcac75f", | ||
"id": "65a6b3753aabf6ee79336fff" | ||
}, | ||
{ | ||
"boardMember": "65a6ace2990f05954dcac743", | ||
"id": "65a6b3753aabf6ee79337000" | ||
} | ||
], | ||
"createdAt": { | ||
"$date": "2024-01-16T16:48:53.956Z" | ||
}, | ||
"updatedAt": { | ||
"$date": "2024-01-16T16:48:53.956Z" | ||
}, | ||
"__v": 0 | ||
}] | ||
|
Oops, something went wrong.