Browse Source

Fixed story chapter fictionalDate field weirdness, especially when it's not provided.

master 1.3.1
Gisle Aune 6 years ago
parent
commit
3a057f6f24
  1. 2
      marko/page/story-content/components/comment/index.marko
  2. 10
      marko/page/story-content/components/edit-comment-modal/component.js

2
marko/page/story-content/components/comment/index.marko

@ -67,9 +67,11 @@ import moment from "moment"
<for (paragraph in state.paragraphs)> <for (paragraph in state.paragraphs)>
<div class="message-text color-text"> <div class="message-text color-text">
<markdown class="body" source=paragraph> <markdown class="body" source=paragraph>
<if (input.comment.fictionalDate)>
<span class="decoration color-menu">[</span> <span class="decoration color-menu">[</span>
<date class="color-menu" value=input.comment.fictionalDate></date> <date class="color-menu" value=input.comment.fictionalDate></date>
<span class="decoration color-menu">]&nbsp;</span> <span class="decoration color-menu">]&nbsp;</span>
</if>
<span class="decoration color-menu">&lt;</span> <span class="decoration color-menu">&lt;</span>
<span if(input.comment.character != null) class="tooltip color-primary"> <span if(input.comment.character != null) class="tooltip color-primary">
<span>${input.comment.characterName}</span> <span>${input.comment.characterName}</span>

10
marko/page/story-content/components/edit-comment-modal/component.js

@ -28,11 +28,19 @@ module.exports = class {
}) })
const comment = input.comment const comment = input.comment
let fictionalDate = new Date(comment.fictionalDate)
if (comment.fictionalDate && !Number.isNaN(fictionalDate.getTime()) && fictionalDate.getTime() !== 0) {
fictionalDate = moment(fictionalDate).format("MMM D, YYYY")
} else {
fictionalDate = ""
}
this.state.values = { this.state.values = {
subject: comment.subject, subject: comment.subject,
characterId: comment.characterId, characterId: comment.characterId,
characterName: comment.characterName, characterName: comment.characterName,
fictionalDate: moment(comment.fictionalDate).format("MMM D, YYYY"),
fictionalDate: fictionalDate,
source: comment.source, source: comment.source,
} }
} }

Loading…
Cancel
Save