You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.1 KiB
56 lines
1.1 KiB
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
|
|
})
|
|
}
|
|
}
|