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

17319 - Date Requirement #527

Merged
merged 5 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "business-edit-ui",
"version": "4.6.0",
"version": "4.6.1",
"private": true,
"appName": "Edit UI",
"sbcName": "SBC Common Components",
Expand Down
7 changes: 7 additions & 0 deletions src/components/SpecialResolution/Resolution.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,12 @@
<ResolutionEditor
ref="resolutionEditor"
:isEditing="isEditing"
@emitDate="onResolutionDate($event)"
/>
<SigningParty
ref="signingParty"
:isEditing="isEditing"
:changedResolutionDate="changedResolutionDate"
/>
<div
v-if="isEditing"
Expand Down Expand Up @@ -209,6 +211,7 @@ export default class Resolution extends Vue {
isEditing = true
hasChanged = false
dropdown = false
changedResolutionDate = ''

/** Displays an invalid section to user if form is invalid. */
get invalidResolutionSection (): boolean {
Expand Down Expand Up @@ -257,6 +260,10 @@ export default class Resolution extends Vue {
async updateIsEditingSpecialResolution (val): Promise<void> {
await this.setEditingSpecialResolution(val)
}

onResolutionDate (date: string) {
this.changedResolutionDate = date
}
}
</script>

Expand Down
13 changes: 7 additions & 6 deletions src/components/SpecialResolution/ResolutionEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@

<script lang="ts">
import Vue from 'vue'
import { Component, Prop, Watch } from 'vue-property-decorator'
import { Component, Emit, Prop, Watch } from 'vue-property-decorator'
import { Action, Getter } from 'pinia-class'
import {
TiptapVuetify,
Expand Down Expand Up @@ -244,11 +244,7 @@ export default class ResolutionEditor extends Vue {

/** The maximum resolution date that can be entered (today). */
get resolutionDateMax (): string {
if (this.getSpecialResolution.signingDate) {
return DateUtilities.dateToYyyyMmDd(DateUtilities.yyyyMmDdToDate(this.getSpecialResolution.signingDate))
} else {
return this.getCurrentDate
}
return this.getCurrentDate
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Even though this computed function is trivial, it's alongside resolutionDateMin(), so there's a nice symmetry / consistency when I look for what the code does.

}

/* Determines if we should show validation for resolution text, substitute for rules. */
Expand All @@ -267,6 +263,7 @@ export default class ResolutionEditor extends Vue {
}
this.resolutionDateText = val
if (this.getComponentValidate) {
this.emitDate(this.resolutionDateText)
await this.onValidate()
}
}
Expand All @@ -284,6 +281,7 @@ export default class ResolutionEditor extends Vue {
async undoToStore (): Promise<void> {
this.resolution = this.resolutionOriginal
this.resolutionDateText = this.resolutionDateTextOriginal
this.emitDate(this.resolutionDateText)
await this.setSpecialResolution({
...this.getSpecialResolution,
resolutionDate: this.resolutionDateText,
Expand Down Expand Up @@ -325,6 +323,9 @@ export default class ResolutionEditor extends Vue {
const isValid = hasData && isResolutionDateValid && (!includeIsEditing || !this.isEditing)
this.setSpecialResolutionValid(isValid)
}

@Emit('emitDate')
emitDate (date: string) { return date }
}
</script>

Expand Down
13 changes: 7 additions & 6 deletions src/components/SpecialResolution/SigningParty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export default class SigningParty extends Vue {
@Action(useStore) setSpecialResolutionSignatureValid!: (x: boolean) => void

@Prop({ default: false }) readonly isEditing!: boolean
@Prop({ default: '' }) readonly changedResolutionDate!: string

$refs!: {
signatureDatePickerRef: DatePickerShared,
Expand Down Expand Up @@ -180,13 +181,13 @@ export default class SigningParty extends Vue {
return (pstDate >= minDate && pstDate <= maxDate)
}

/** The minimum signature date that can be entered (resolution date or today). */
/** The minimum signature date that can be entered (resolution date). */
get signatureDateMin (): string {
if (this.getSpecialResolution.resolutionDate) {
return DateUtilities.dateToYyyyMmDd(DateUtilities.yyyyMmDdToDate(this.getSpecialResolution.resolutionDate))
} else {
return this.getCurrentDate
}
const dateToUse = (this.changedResolutionDate && this.changedResolutionDate.trim() !== '')
? this.changedResolutionDate
: (this.getSpecialResolution.resolutionDate || this.getCurrentDate)

return DateUtilities.dateToYyyyMmDd(DateUtilities.yyyyMmDdToDate(dateToUse))
}

/** The maximum signature date that can be entered (today). */
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/Resolution.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,14 @@ describe('Special Resolution Form component', () => {
await Vue.nextTick()
expect(store.stateModel.validationFlags.flagsCompanyInfo.isValidSpecialResolutionSignature).toBe(true)
expect(store.stateModel.validationFlags.flagsCompanyInfo.isValidSpecialResolution).toBe(true)
// Set resolutionDate to a date AFTER the current date to make it invalid
const dayAfterCurrentDate = new Date(store.stateModel.tombstone.currentDate)
dayAfterCurrentDate.setDate(dayAfterCurrentDate.getDate() + 1)
const invalidResolutionDate = dayAfterCurrentDate.toISOString().split('T')[0]
store.stateModel.specialResolution = {
...store.stateModel.specialResolution,
resolutionDate: '2026-03-01',
signingDate: '2024-01-01'
resolutionDate: invalidResolutionDate,
signingDate: '2021-01-01'
}
await Vue.nextTick()
wrapper = mount(Resolution, { vuetify })
Expand Down