Skip to content

Commit

Permalink
[MIM-1762] Add checkbox to toggle time for modified date for statisti…
Browse files Browse the repository at this point in the history
…cs (#2808)

Add checkbox  to toggle time for modified date for statistics
  • Loading branch information
johnnadeluy authored and Carl-OW committed Jul 9, 2024
1 parent 6b63b74 commit fc83925
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
<label>Endringsmelding</label>
<default>true</default>
<items>
<input name="showModifiedTime" type="CheckBox">
<label>Vis klokkeslett for publisering</label>
<default>unchecked</default>
</input>
<input name="lastModified" type="DateTime">
<label>Dato og tid</label>
</input>
Expand Down Expand Up @@ -134,4 +138,4 @@
<label>Skjul statistikk fra statbank emnetre</label>
</input>
</form>
</content-type>
</content-type>
4 changes: 3 additions & 1 deletion src/main/resources/site/parts/statistics/statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function renderPart(req: XP.Request): XP.Response {
const modifiedText: string | undefined = page.data.showModifiedDate
? page.data.showModifiedDate.modifiedOption.modifiedText
: undefined
const showModifiedTime: boolean | undefined = page.data.showModifiedDate?.modifiedOption.showModifiedTime
const modifiedDate: string | undefined = page.data.showModifiedDate
? page.data.showModifiedDate.modifiedOption.lastModified
: undefined
Expand Down Expand Up @@ -118,7 +119,8 @@ function renderPart(req: XP.Request): XP.Response {

if (page.data.showModifiedDate && previousReleaseDate && modifiedDate) {
if (isAfter(new Date(modifiedDate), new Date(previousReleaseDate))) {
changeDate = formatDate(modifiedDate, 'PPp', language)
const dateFormat = showModifiedTime ? 'PPp' : 'PPP'
changeDate = formatDate(modifiedDate, dateFormat, language)
}
}

Expand Down

0 comments on commit fc83925

Please sign in to comment.