data: Added channel list/add/edit
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
const moment = require("moment")
|
||||
|
||||
const {channelApi} = require("../../../../../rpdata/api/Channel")
|
||||
|
||||
module.exports = class {
|
||||
onCreate(input) {
|
||||
this.state = {
|
||||
error: null,
|
||||
loading: false,
|
||||
values: {
|
||||
name: "",
|
||||
locationName: "",
|
||||
eventName: "",
|
||||
logged: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
change(key, ev) {
|
||||
this.state.values = Object.assign({}, this.state.values, {[key]: ev.target.value})
|
||||
}
|
||||
|
||||
open() {
|
||||
|
||||
}
|
||||
|
||||
close() {
|
||||
this.emit("close")
|
||||
}
|
||||
|
||||
save() {
|
||||
if (this.state.loading) {
|
||||
return
|
||||
}
|
||||
|
||||
const input = Object.assign({}, this.state.values)
|
||||
|
||||
this.state.loading = true
|
||||
channelApi.add(input).then((res) => {
|
||||
this.emit("added", res)
|
||||
this.emit("close")
|
||||
}).catch(errs => {
|
||||
console.warn("Failed to add:", errs)
|
||||
|
||||
this.state.error = "Failed to add: " + JSON.stringify(errs)
|
||||
}).then(() => {
|
||||
this.state.loading = false
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<modal class="modal color-text nolabel" key="modal" enabled=(input.enabled) closable on-close("close") on-open("open") >
|
||||
<h1>Add Channel</h1>
|
||||
|
||||
<p class="color-error">${state.error}</p>
|
||||
|
||||
<label>Name</label>
|
||||
<input key="name" placeholder="(Required)" class="big" on-change("change", "name") value=state.values.name />
|
||||
|
||||
<label>Event Name</label>
|
||||
<input key="eventName" placeholder="(None)" on-change("change", "eventName") value=state.values.eventName />
|
||||
|
||||
<label>Location Name</label>
|
||||
<input key="locationName" placeholder="(None)" on-change("change", "locationName") value=state.values.locationName />
|
||||
|
||||
<label>Logged</label>
|
||||
<toggle value=state.values.logged on="On" off="Off"
|
||||
onDesc="Log new posts in this channel."
|
||||
offDesc="The logbot will not monitor this channel."
|
||||
on-change("change", "logged") />
|
||||
|
||||
<p class="color-danger" if(state.values.logged)>The logbot is not yet available, so this does nothing right now.</p>
|
||||
|
||||
<button disabled=state.loading on-click("save")>Save</button>
|
||||
</modal>
|
||||
Reference in New Issue
Block a user