The frontend/UI server, written in JS using the MarkoJS library
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.
 
 
 
 

57 lines
1.1 KiB

const moment = require("moment")
const {charactersApi} = require("../../../../../rpdata/api/Character")
module.exports = class {
onCreate(input) {
this.state = {
error: null,
loading: false,
values: {
name: "",
shortName: "",
description: "",
}
}
}
change(key, ev) {
this.state.values[key] = ev.target.value
}
onInput(input) {
this.state.values = {
name: input.character.name,
shortName: input.character.shortName,
description: input.character.description,
}
}
open() {
}
close() {
this.emit("close")
}
save() {
if (this.state.loading) {
return
}
const input = Object.assign({id: this.input.character.id}, this.state.values)
this.state.loading = true
charactersApi.edit(input).then((res) => {
this.emit("edited", res)
this.emit("close")
}).catch(errs => {
console.warn("Failed to edit:", errs)
this.state.error = "Failed to edit: " + errs[0].message
}).then(() => {
this.state.loading = false
})
}
}