logs-content: Added add post form

This commit is contained in:
2018-09-30 15:59:28 +02:00
parent 3c35f75f62
commit 3466b1a707
7 changed files with 144 additions and 6 deletions
@@ -5,10 +5,19 @@ const {postApi} = require("../../../../../rpdata/api/Post")
module.exports = class {
onCreate(input) {
this.state = {
log: input.log
log: input.log,
modal: null,
}
}
open(modal) {
this.state.modal = modal
}
close() {
this.state.modal = null
}
/**
* Patch the posts
*
@@ -70,8 +79,13 @@ module.exports = class {
})
}
postEdited(post) {
this.patch([post])
postEdited(patch) {
this.patch([patch])
}
postAdded(post) {
this.state.log.posts = this.state.log.posts.concat([post])
this.state.log = Object.assign({}, this.state.log)
}
get title() {
@@ -1,4 +1,4 @@
<logs-content-menu user=input.user log=state.log />
<logs-content-menu user=input.user log=state.log on-select("open") />
<main>
<div class="logs-content">
<h1 class="color-primary">${component.title}</h1>
@@ -12,4 +12,6 @@
last=(post.position === state.log.posts.length)
/>
</div>
<add-post-modal enabled=(state.modal === "add") logId=state.log.id on-close("close") on-added("postAdded") />
</main>