Skip to content
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

Merged
merged 3 commits into from
Apr 3, 2024

Conversation

wilwong89
Copy link
Contributor

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

  • I have read the CONTRIBUTING doc
  • I have checked that unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Note that a db migration is necessary and the migration file is included.

Copy link

github-actions bot commented Mar 28, 2024

Coverage Report (Frontend)

Totals Coverage
Statements: 24.38% ( 425 / 1743 )
Methods: 24.68% ( 78 / 316 )
Lines: 28.03% ( 275 / 981 )
Branches: 16.14% ( 72 / 446 )

@wilwong89 wilwong89 force-pushed the feature/bring-forward branch from a0ae71e to a82d0a3 Compare March 28, 2024 21:28
Copy link

github-actions bot commented Mar 28, 2024

Coverage Report (Application)

Totals Coverage
Statements: 45.3% ( 405 / 894 )
Methods: 35.91% ( 65 / 181 )
Lines: 61.1% ( 289 / 473 )
Branches: 21.25% ( 51 / 240 )

Copy link

codeclimate bot commented Mar 28, 2024

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';
Copy link
Collaborator

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('');
Copy link
Collaborator

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.

@@ -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 || '',
Copy link
Collaborator

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.

@@ -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),
Copy link
Collaborator

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.

Comment on lines 6 to 7
bringForwardDate?: string | null;
bringForwardState?: string | null;
Copy link
Collaborator

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),
Copy link
Collaborator

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

@wilwong89 wilwong89 force-pushed the feature/bring-forward branch from a82d0a3 to b37de12 Compare March 28, 2024 23:33
@wilwong89 wilwong89 force-pushed the feature/bring-forward branch from b37de12 to 1036aa8 Compare March 28, 2024 23:43
@wilwong89 wilwong89 closed this Mar 29, 2024
@wilwong89 wilwong89 reopened this Mar 29, 2024
Copy link
Contributor

@TimCsaky TimCsaky left a 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());
Copy link
Contributor

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">
Copy link
Contributor

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();
Copy link
Contributor

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

@kyle1morel kyle1morel changed the base branch from master to feature/bring-forward-date April 3, 2024 20:43
@kyle1morel kyle1morel merged commit 8230085 into feature/bring-forward-date Apr 3, 2024
32 of 33 checks passed
@kyle1morel kyle1morel deleted the feature/bring-forward branch April 3, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants