-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement initial bring forward features #49
Conversation
a0ae71e
to
a82d0a3
Compare
Code Climate has analyzed commit 1036aa8 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 50.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 38.7% (2.3% change). View more on Code Climate. |
@@ -0,0 +1,31 @@ | |||
import type { Knex } from 'knex'; |
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.
Let's rename this to file to 20240327000000_001-bring-forward.ts
. I should've followed our historical naming convention with the init migration, but it slipped by before going to prod. So let's start this now.
.then(() => | ||
knex.schema.alterTable('note', function (table) { | ||
table.timestamp('bring_forward_date', { useTz: true }); | ||
table.text('bring_forward_state').defaultTo(''); |
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.
Can we make this nullable instead of defaulting to an empty string. NULL is a better representation of no value.
app/src/db/models/note.ts
Outdated
@@ -30,6 +32,8 @@ export default { | |||
return { | |||
noteId: input.note_id, | |||
activityId: input.activity_id, | |||
bringForwardDate: input.bring_forward_date?.toISOString() ?? null, | |||
bringForwardState: input.bring_forward_state || '', |
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.
Can we make this nullable instead of defaulting to an empty string. NULL is a better representation of no value.
app/src/validators/note.ts
Outdated
@@ -8,6 +8,8 @@ const schema = { | |||
body: Joi.object({ | |||
createdAt: Joi.date().required(), | |||
activityId: activityId, | |||
bringForwardDate: Joi.date().iso().allow(null), | |||
bringForwardState: Joi.string().allow(null), |
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.
Consider: If we are allowing null and expecting a value otherwise, this can be min(1) to disallow empty set.
frontend/src/types/Note.ts
Outdated
bringForwardDate?: string | null; | ||
bringForwardState?: string | null; |
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.
Should not have | null
here as they are marked as optional.
.nullable() | ||
.when('noteType', { | ||
is: (noteType: string) => noteType === NOTE_TYPES.BRING_FORWARD, | ||
then: (schema) => schema.test('must select date', 'A date must be selected', (value) => value instanceof Date), |
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.
Let's make the error message match the required error: Bring forward date is a required field
a82d0a3
to
b37de12
Compare
b37de12
to
1036aa8
Compare
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.
looking good!
@@ -61,6 +95,8 @@ watch(visible, (newValue) => { | |||
nextTick().then(() => { | |||
if (newValue && formRef.value) { | |||
formRef.value.setFieldValue('createdAt', new Date()); |
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.
if the 'Date' field is read-only, and we always want it to be the current date/time i question whether it needs to be on the form at all. something i could ask Tyler about i guess
<Divider type="solid" /> | ||
</template> | ||
<template #content> | ||
<div class="grid nested-grid"> | ||
<!-- Left column --> | ||
<div class="col-12 md:col-6 lg:col-4"> |
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.
these columns are too wide on big screens. lg:col-2 is probably enough
.then(() => | ||
knex.schema.alterTable('note', function (table) { | ||
table.timestamp('bring_forward_date', { useTz: true }); | ||
table.text('bring_forward_state').nullable(); |
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.
fyi. you don't need to add nullable(). fields are nullable by default on column creation
Description
Implement the initial bring forwards feature with the following changes:
-frontend to set bring forward status and dates, and display that information
-db model changes to store bring forward status and dates
-update type definition and unit tests
Showcase-3432
Types of changes
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Checklist
Further comments
Note that a db migration is necessary and the migration file is included.