const moment = require("moment") const {channelApi} = require("../../../../../rpdata/api/Channel") module.exports = class { onCreate(input) { this.state = { error: null, loading: false, values: { locationName: "", eventName: "", logged: false, } } } change(key, ev) { this.state.values = Object.assign({}, this.state.values, {[key]: ev.target.value}) } onInput(input) { this.state.values = { eventName: input.channel.eventName, locationName: input.channel.locationName, logged: input.channel.logged, } } open() { } close() { this.emit("close") } save() { if (this.state.loading) { return } const input = Object.assign({name: this.input.channel.name}, this.state.values) this.state.loading = true channelApi.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 }) } }