data: Added channel list/add/edit

This commit is contained in:
2018-10-11 21:55:15 +02:00
parent d380a47d8d
commit a5ac48e3d6
20 changed files with 329 additions and 11 deletions
@@ -0,0 +1,34 @@
module.exports = class {
onCreate(input) {
this.state = {
channels: input.channels,
modal: null,
}
}
open(modal) {
this.state.modal = modal
}
close() {
this.state.modal = null
}
channelEdited(channel, patch) {
const channels = this.state.channels.slice()
const index = channels.findIndex(c => c.name === channel.name)
if (index === -1) {
return
}
channels[index] = Object.assign({}, channels[index], patch)
this.state.channels = channels
console.log(channels[index])
}
channelAdded(channel) {
this.state.channels = this.state.channels.concat(channel).sort((a,b) => a.name.localeCompare(b.name))
}
}
@@ -0,0 +1,5 @@
<data-menu categories=input.categories selected=(input.selected || {}) user=input.user on-open("open") />
<main>
<channel-list channels=state.channels on-edited("channelEdited") />
</main>
<add-channel-modal enabled=(state.modal === "channel.add") user=input.user on-added("channelAdded") on-close("close") />