story-content: Added remove story modal, added annotations
This commit is contained in:
@@ -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>
|
||||
Reference in New Issue
Block a user