-
Notifications
You must be signed in to change notification settings - Fork 3
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
Ontmoetingsformulier changes #611
Open
roberttullycarr
wants to merge
7
commits into
pandapanda_development
Choose a base branch
from
PP_OF_Changes
base: pandapanda_development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cb7f304
initial translations for encounter form
roberttullycarr c4d0ca7
added: translations, a migration and a mutation on encounters
roberttullycarr 4f4eefd
Merge branch 'pandapanda_development' into PP_OF_Changes
roberttullycarr 620462a
added: more ontmoetingsformulier changes
roberttullycarr 2763963
removed console.log
roberttullycarr ef8ad9c
Merge branch 'develop' into PP_OF_Changes
roberttullycarr a3639db
Merge branch 'pandapanda_development' into PP_OF_Changes
roberttullycarr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
database/migrations/20250210100019-add_encounter_form_fields_to_encounter_competitions.js
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,41 @@ | ||
'use strict'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
|
||
const columnsToAdd = ["homeCaptainPresent", "awayCaptainPresent", "gameLeaderPresent", "homeCaptainAccepted", "awayCaptainAccepted", "gameLeaderAccepted"]; | ||
|
||
module.exports = { | ||
async up (queryInterface, Sequelize) { | ||
return queryInterface.sequelize.transaction(t => { | ||
return Promise.all( | ||
columnsToAdd.map(column => queryInterface.addColumn( | ||
{ tableName: 'EncounterCompetitions', schema: 'event' }, | ||
column, | ||
{ | ||
type: Sequelize.DataTypes.BOOLEAN, | ||
allowNull: false, | ||
defaultValue: false, | ||
}, | ||
{ transaction: t }, | ||
)) | ||
); | ||
}); | ||
}, | ||
|
||
async down (queryInterface, Sequelize) { | ||
return queryInterface.sequelize.transaction(t => { | ||
return Promise.all( | ||
columnsToAdd.map(column => queryInterface.removeColumn( | ||
{ tableName: 'EncounterCompetitions', schema: 'event' }, | ||
column, | ||
{ | ||
type: Sequelize.DataTypes.BOOLEAN, | ||
allowNull: false, | ||
defaultValue: false, | ||
}, | ||
{ transaction: t }, | ||
)) | ||
); | ||
}); | ||
} | ||
}; |
41 changes: 41 additions & 0 deletions
41
database/migrations/20250220103101-add_encounterId_to_comments.js
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,41 @@ | ||
'use strict'; | ||
|
||
const columnsToAdd = ["encounterId"]; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up (queryInterface, Sequelize) { | ||
return queryInterface.sequelize.transaction(t => { | ||
return Promise.all( | ||
columnsToAdd.map(column => queryInterface.addColumn( | ||
{ tableName: 'Comments', schema: 'public' }, | ||
column, | ||
{ | ||
type: Sequelize.DataTypes.UUID, | ||
allowNull: true, | ||
references: { | ||
model: { | ||
tableName: 'EncounterCompetitions', | ||
schema: 'event', | ||
}, | ||
key: 'id', | ||
}, | ||
}, | ||
{ transaction: t }, | ||
)) | ||
); | ||
}); | ||
}, | ||
|
||
async down (queryInterface, Sequelize) { | ||
return queryInterface.sequelize.transaction(t => { | ||
return Promise.all( | ||
columnsToAdd.map(column => queryInterface.removeColumn( | ||
{ tableName: 'Comments', schema: 'public' }, | ||
column, | ||
{ transaction: t }, | ||
)) | ||
); | ||
}); | ||
} | ||
}; |
48 changes: 48 additions & 0 deletions
48
database/migrations/20250220103145-add_encounterCommentId_to_encounter_competition.js
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,48 @@ | ||
'use strict'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up (queryInterface, Sequelize) { | ||
const t = await queryInterface.sequelize.transaction(); | ||
|
||
try { | ||
await queryInterface.addConstraint( | ||
{ tableName: 'Comments', schema: 'public' }, | ||
{ | ||
fields: ['encounterId'], | ||
type: 'foreign key', | ||
references: { | ||
table: {tableName: 'EncounterCompetitions', schema: 'event'}, | ||
field: 'id', | ||
}, | ||
onDelete: 'cascade', | ||
onUpdate: 'cascade', | ||
name: 'Comments_encounterId_fkey', | ||
|
||
}, | ||
{transaction: t} | ||
); | ||
return t.commit(); | ||
} catch (error) { | ||
console.log('error', error) | ||
await t.rollback(); | ||
throw error; | ||
} | ||
}, | ||
|
||
async down (queryInterface, Sequelize) { | ||
const t = await queryInterface.sequelize.transaction(); | ||
|
||
try { | ||
await queryInterface.removeConstraint( | ||
{ tableName: 'Comments', schema: 'public' }, | ||
'Comments_encounterId_fkey', | ||
{ transaction: t }, | ||
); | ||
return t.commit(); | ||
} catch (error) { | ||
await t.rollback(); | ||
throw error; | ||
} | ||
}, | ||
}; |
Binary file not shown.
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// import { SocketEmitter, EVENTS } from '../../../sockets'; | ||
import { Field, ID, Int, ObjectType } from '@nestjs/graphql'; | ||
import { Field, ID, InputType, Int, ObjectType, OmitType, PartialType } from '@nestjs/graphql'; | ||
import { | ||
BelongsToGetAssociationMixin, | ||
BelongsToManyAddAssociationMixin, | ||
|
@@ -265,3 +265,46 @@ export class Game extends Model<InferAttributes<Game>, InferCreationAttributes<G | |
hasPlayers!: BelongsToManyHasAssociationsMixin<Player, string>; | ||
countPlayer!: BelongsToManyCountAssociationsMixin; | ||
} | ||
|
||
@InputType() | ||
export class GameNewInputPlayers { | ||
@Field(() => ID) | ||
id!: string; | ||
|
||
@Field(() => ID) | ||
systemId!: string; | ||
|
||
@Field(() => Int) | ||
team!: number; | ||
|
||
@Field(() => Int) | ||
player!: number; | ||
} | ||
|
||
@InputType() | ||
export class GameNewInput extends PartialType( | ||
OmitType(Game, ['id', 'visualCode', "rankingPoints", "players", 'competition','linkId', 'linkType', "tournament", "createdAt", "updatedAt"] as const), | ||
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 usually take the updatemodel as base so:
|
||
InputType | ||
) { | ||
@Field(() => ID, { nullable: true }) | ||
linkId!: string; | ||
|
||
@Field(() => String, { nullable: true }) | ||
linkType!: string; | ||
|
||
@Field(() => [GameNewInputPlayers], { nullable: true }) | ||
players!: GameNewInputPlayers[]; | ||
} | ||
|
||
@InputType() | ||
export class GameUpdateInput extends PartialType( | ||
OmitType(Game, ['id', 'visualCode', "rankingPoints", "players", 'competition','linkId', 'linkType', "tournament", "createdAt", "updatedAt"] as const), | ||
InputType | ||
) { | ||
@Field(() => ID, { nullable: true }) | ||
linkId!: string; | ||
|
||
@Field(() => ID, { nullable: true }) | ||
gameId!: string; | ||
} | ||
|
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 |
---|---|---|
|
@@ -75,7 +75,8 @@ export class CommentResolver { | |
playerId: user.id, | ||
linkId: newCommentData.linkId, | ||
linkType: newCommentData.linkType, | ||
clubId: newCommentData.clubId, | ||
...(newCommentData.clubId ? {clubId: newCommentData.clubId} : {}), | ||
...(newCommentData.encounterId ? {encounterId: newCommentData.encounterId} : {}), | ||
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. same here, this value should be filled in on linkId |
||
}, | ||
defaults: { | ||
...newCommentData, | ||
|
@@ -105,7 +106,7 @@ export class CommentResolver { | |
if (!(link instanceof EncounterCompetition)) { | ||
throw new BadRequestException(`linkType is not home_comment_chamge`); | ||
} | ||
await this.encounterComment(link, comment, user, transaction); | ||
await this.encounterComment(link, comment, user, transaction); | ||
break; | ||
} | ||
|
||
|
@@ -177,6 +178,8 @@ export class CommentResolver { | |
return EventCompetition.findByPk(linkId); | ||
case 'encounterChange': | ||
return EncounterCompetition.findByPk(linkId); | ||
case 'encounter': | ||
return EncounterCompetition.findByPk(linkId); | ||
default: | ||
throw new NotFoundException(`${linkType}: ${linkId}`); | ||
} | ||
|
@@ -230,13 +233,14 @@ export class CommentResolver { | |
) { | ||
throw new UnauthorizedException(`You do not have permission to edit this comment`); | ||
} | ||
|
||
if (home.clubId === comment.clubId) { | ||
await link.addHomeComment(comment, { transaction }); | ||
} else if (away.clubId === comment.clubId) { | ||
await link.addAwayComment(comment, { transaction }); | ||
} else { | ||
throw new BadRequestException(`clubId: ${comment.clubId} is not home or away`); | ||
if (comment.clubId !== null && comment.encounterId === null) { | ||
if (home.clubId === comment.clubId) { | ||
await link.addHomeComment(comment, { transaction }); | ||
} else if (away.clubId === comment.clubId) { | ||
await link.addAwayComment(comment, { transaction }); | ||
} else { | ||
throw new BadRequestException(`clubId: ${comment.clubId} is not home or away`); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This field isn't needed, this is handeled by the
linkId
andlinkType