-
Notifications
You must be signed in to change notification settings - Fork 1
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
Ben/lmb 1288 end date mandatarissen #465
Changes from 13 commits
7ddc58b
3971f40
413af4d
2916bfc
af57818
b120ee3
f33debe
4c4bd8f
6e964a1
29868f8
201bb4e
c52911a
c8360da
fe44e5b
a6ba1b6
31a0016
670c0ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
{{moment-format @mandataris.start "DD-MM-YYYY"}} | ||
</td> | ||
<td> | ||
{{moment-format @mandataris.einde "DD-MM-YYYY"}} | ||
{{moment-format @mandataris.displayEinde "DD-MM-YYYY"}} | ||
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. Maybe we can add a getter in the mandataris model for a formattedStartDate and end date? 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. context is always a bit different, so quite difficult to implement 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. no lets keep this in the templates as is, it's nice to know what format you'll get there |
||
</td> | ||
<td> | ||
{{@mandataris.status.label}} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import { | |
notBurgemeesterStates, | ||
} from 'frontend-lmb/utils/well-known-uris'; | ||
import { isRequiredForBestuursorgaan } from 'frontend-lmb/utils/is-fractie-selector-required'; | ||
import { endOfDay } from 'frontend-lmb/utils/date-manipulation'; | ||
|
||
export default class MandatarissenUpdateState extends Component { | ||
@tracked newStatus = null; | ||
|
@@ -104,7 +105,7 @@ export default class MandatarissenUpdateState extends Component { | |
if (!this.args.mandataris.einde) { | ||
return this.args.mandataris.status; | ||
} | ||
if (this.args.mandataris.einde.getTime() < new Date().getTime()) { | ||
if (this.args.mandataris.einde.getTime() <= new Date().getTime()) { | ||
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 don't think you can just change the sign here. getTime returns the time since epoch in milliseconds. i don't think the equals matters right? And the logic is still good because the mandataris is still in function until the end of the day? |
||
return this.mandatarisStatus.endedState; | ||
} | ||
return this.args.mandataris.status; | ||
|
@@ -197,7 +198,7 @@ export default class MandatarissenUpdateState extends Component { | |
(await this.args.mandataris.vervangerVan) || []; | ||
} | ||
|
||
this.args.mandataris.einde = this.date; | ||
this.args.mandataris.einde = endOfDay(this.date); | ||
await Promise.all([newMandataris.save(), this.args.mandataris.save()]); | ||
|
||
await this.mandatarisService.createNewLidmaatschap( | ||
|
@@ -218,8 +219,7 @@ export default class MandatarissenUpdateState extends Component { | |
} | ||
|
||
async endMandataris() { | ||
this.args.mandataris.einde = this.date; | ||
|
||
this.args.mandataris.einde = endOfDay(this.date); | ||
return await this.args.mandataris.save(); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import moment from 'moment'; | ||
|
||
export async function endOfDay(date) { | ||
if (date) { | ||
return moment(date).utc().add(1, 'days').startOf('day').toDate(); | ||
} else { | ||
return moment().utc().add(1, 'days').startOf('day').toDate(); | ||
} | ||
} | ||
|
||
export async function displayEndOfDay(date) { | ||
return moment(date).subtract(1, 'days').toDate(); | ||
} |
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.
Would name the argument
isMandatarisEndDate
or something, endOfDay could be anything so to speakThere 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.
The problem is this is not exclusive to mandatarissen, so I do keep it a bit abstract so it is useful in other cases as well. e.g. for bestuursorganen in de tijd.