Gisle Aune
6 years ago
10 changed files with 171 additions and 6 deletions
-
3marko/components/annotation/index.marko
-
36marko/components/annotation/style.less
-
5marko/page/story-content/components/page/component.js
-
13marko/page/story-content/components/page/index.marko
-
23marko/page/story-content/components/page/style.less
-
56marko/page/story-content/components/remove-story-modal/component.js
-
9marko/page/story-content/components/remove-story-modal/index.marko
-
12middleware/locals.js
-
2routes/story/by-tag.js
-
18rpdata/api/Story.js
@ -0,0 +1,3 @@ |
|||
<div class=("annotation annotation-level-"+(input.level||"info"))> |
|||
<include(input.renderBody)/> |
|||
</div> |
@ -0,0 +1,36 @@ |
|||
div.annotation { |
|||
outline: 1px solid; |
|||
padding: 0.25em 1ch; |
|||
margin-bottom: 1em; |
|||
|
|||
h2 { |
|||
font-size: 1em; |
|||
margin: 0; |
|||
text-align: center; |
|||
border-bottom: 0.25px dotted; |
|||
margin-bottom: 0.25em; |
|||
padding-bottom: 0.25em; |
|||
} |
|||
|
|||
p { |
|||
margin-top: 0.5em; |
|||
} |
|||
p:first-of-type { |
|||
margin: 0; |
|||
} |
|||
} |
|||
|
|||
div.annotation-level-info { |
|||
background-color: rgba(0, 31, 63, 0.5); |
|||
color: #08F; |
|||
} |
|||
|
|||
div.annotation-level-warning { |
|||
background-color: rgba(63, 31, 0, 0.5); |
|||
color: #F80; |
|||
} |
|||
|
|||
div.annotation-level-error { |
|||
background-color: rgba(63, 7, 0, 0.5); |
|||
color: #F10; |
|||
} |
@ -1,11 +1,22 @@ |
|||
<story-content-menu key="menu" on-select("menuSelect") story=state.story selected=(input.selected || {}) user=input.user /> |
|||
<main> |
|||
<div class="story-content"> |
|||
<h1 class="color-primary">${state.story.name}</h1> |
|||
<div class="header"> |
|||
<h1 class="color-primary">${state.story.name}</h1> |
|||
<a on-click("open", "story.edit") class="color-menu">Edit</a> |
|||
<a on-click("open", "story.remove") class="color-menu">Remove</a> |
|||
</div> |
|||
<story-tags tags=state.story.tags on-select("open", "story.tags")/> |
|||
<annotation if(state.removed) level="error"> |
|||
<p> |
|||
This story has been removed. Your browser has not refreshed the page yet, |
|||
so you can still read it (or back it up) before leaving the page. |
|||
</p> |
|||
</annotation> |
|||
<chapter for(chapter in state.story.chapters) key=chapter.id chapter=chapter on-edit("updateChapter", chapter.id) on-remove("removeChapter", chapter.id)/> |
|||
</div> |
|||
|
|||
<create-chapter-modal storyId=state.story.id enabled=(state.modal === "chapter.add") chapter=input.chapter on-close("close") on-add("addChapter") /> |
|||
<edit-story-tags-modal enabled=(state.modal === "story.tags") story=state.story on-tags("updateStoryTags") on-close("close") /> |
|||
<remove-story-modal enabled=(state.modal === "story.remove") story=state.story on-remove("timeToDie") on-close("close") /> |
|||
</main> |
@ -0,0 +1,56 @@ |
|||
const moment = require("moment") |
|||
|
|||
const {storyApi} = require("../../../../../rpdata/api/Story") |
|||
|
|||
module.exports = class { |
|||
onCreate(input) { |
|||
this.state = { |
|||
error: null, |
|||
loading: false, |
|||
values: { |
|||
title: "", |
|||
source: "", |
|||
fictionalDate: "", |
|||
}, |
|||
} |
|||
} |
|||
|
|||
onInput(input) { |
|||
if (input.chapter && !this.first) { |
|||
let {fictionalDate, title, source} = input.chapter |
|||
|
|||
if (fictionalDate != null) { |
|||
fictionalDate = moment.utc(fictionalDate).format("MMM D, YYYY") |
|||
} |
|||
|
|||
this.state.values = {fictionalDate, title, source} |
|||
} |
|||
} |
|||
|
|||
change(key, ev) { |
|||
this.state.values[key] = ev.target.value |
|||
} |
|||
|
|||
open() { |
|||
|
|||
} |
|||
|
|||
close() { |
|||
this.emit("close") |
|||
} |
|||
|
|||
doIt() { |
|||
this.state.loading = true |
|||
|
|||
storyApi.remove({id: this.input.story.id}).then(() => { |
|||
this.emit("remove") |
|||
this.emit("close") |
|||
}).catch(errs => { |
|||
console.warn("Failed to delete:", errs) |
|||
|
|||
this.state.error = "Failed to delete: " + errs.message || errs[0].message |
|||
}).then(() => { |
|||
this.state.loading = false |
|||
}) |
|||
} |
|||
} |
@ -0,0 +1,9 @@ |
|||
<modal class="modal color-text nolabel" key="modal" enabled=(input.enabled) notification closable on-close("close") on-open("open") > |
|||
<h1>Delete Story</h1> |
|||
|
|||
<p class="color-error">${state.error}</p> |
|||
|
|||
<p class="color-danger">Deletion is final!</p> |
|||
|
|||
<button disabled=state.loading on-click("doIt")>Yes, do as I say!</button> |
|||
</modal> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue