diff --git a/marko/components/compact-list-property/index.marko b/marko/components/compact-list-property/index.marko index 31505f5..c02a2ea 100644 --- a/marko/components/compact-list-property/index.marko +++ b/marko/components/compact-list-property/index.marko @@ -1,4 +1,4 @@
${input.label}
-
${input.value}
+
${input.value}
\ No newline at end of file diff --git a/marko/components/compact-list-property/style.less b/marko/components/compact-list-property/style.less index 3e42a79..5c9bc2b 100644 --- a/marko/components/compact-list-property/style.less +++ b/marko/components/compact-list-property/style.less @@ -13,6 +13,10 @@ td.compact-list-property { padding-bottom: 0.25em; user-select: text; } + + div.value.weak { + opacity: 0.3333; + } } td.compact-list-property.short { diff --git a/marko/components/toggle/style.less b/marko/components/toggle/style.less index c9a12d7..dc4bcb8 100644 --- a/marko/components/toggle/style.less +++ b/marko/components/toggle/style.less @@ -1,8 +1,7 @@ div.toggle { div.toggle-pill { display: inline-block; - margin: 0.5em; - margin-bottom: 0; + margin: 0 0.5em; a.toggle-option { padding: 0.125em 0.5ch; diff --git a/marko/page/data/channels.marko b/marko/page/data/channels.marko new file mode 100644 index 0000000..2abd413 --- /dev/null +++ b/marko/page/data/channels.marko @@ -0,0 +1,6 @@ + + <@body> + + + + diff --git a/marko/page/data/components/add-channel-modal/component.js b/marko/page/data/components/add-channel-modal/component.js new file mode 100644 index 0000000..1f7b444 --- /dev/null +++ b/marko/page/data/components/add-channel-modal/component.js @@ -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 + }) + } +} \ No newline at end of file diff --git a/marko/page/data/components/add-channel-modal/index.marko b/marko/page/data/components/add-channel-modal/index.marko new file mode 100644 index 0000000..43a2bb0 --- /dev/null +++ b/marko/page/data/components/add-channel-modal/index.marko @@ -0,0 +1,24 @@ + +

Add Channel

+ +

${state.error}

+ + + + + + + + + + + + + +

The logbot is not yet available, so this does nothing right now.

+ + +
\ No newline at end of file diff --git a/marko/page/data/components/channel-list/index.marko b/marko/page/data/components/channel-list/index.marko new file mode 100644 index 0000000..ffc0243 --- /dev/null +++ b/marko/page/data/components/channel-list/index.marko @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/marko/page/data/components/channel/component.js b/marko/page/data/components/channel/component.js new file mode 100644 index 0000000..fee3c0b --- /dev/null +++ b/marko/page/data/components/channel/component.js @@ -0,0 +1,20 @@ +module.exports = class { + onCreate() { + this.state = { + modal: null, + deleted: false, + } + } + + open(modal) { + this.state.modal = modal + } + + close() { + this.state.modal = null + } + + removed() { + this.state.deleted = true + } +} \ No newline at end of file diff --git a/marko/page/data/components/channel/index.marko b/marko/page/data/components/channel/index.marko new file mode 100644 index 0000000..3c7d953 --- /dev/null +++ b/marko/page/data/components/channel/index.marko @@ -0,0 +1,10 @@ + + + + + + + Edit + + + \ No newline at end of file diff --git a/marko/page/data/components/channels-page/component.js b/marko/page/data/components/channels-page/component.js new file mode 100644 index 0000000..a1e9f6f --- /dev/null +++ b/marko/page/data/components/channels-page/component.js @@ -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)) + } +} \ No newline at end of file diff --git a/marko/page/data/components/channels-page/index.marko b/marko/page/data/components/channels-page/index.marko new file mode 100644 index 0000000..0f6495e --- /dev/null +++ b/marko/page/data/components/channels-page/index.marko @@ -0,0 +1,5 @@ + +
+ +
+ diff --git a/marko/page/data/components/character/index.marko b/marko/page/data/components/character/index.marko index a2621e5..140adff 100644 --- a/marko/page/data/components/character/index.marko +++ b/marko/page/data/components/character/index.marko @@ -1,6 +1,6 @@ - 0) /> + diff --git a/marko/page/data/components/characters-page/component.js b/marko/page/data/components/characters-page/component.js index 4417c16..725b330 100644 --- a/marko/page/data/components/characters-page/component.js +++ b/marko/page/data/components/characters-page/component.js @@ -25,7 +25,7 @@ module.exports = class { return } - characters[index] = Object.assign(characters[index], patch) + characters[index] = Object.assign({}, characters[index], patch) this.state.characters = characters } diff --git a/marko/page/data/components/data-menu/index.marko b/marko/page/data/components/data-menu/index.marko index 05c07da..cdecf4c 100644 --- a/marko/page/data/components/data-menu/index.marko +++ b/marko/page/data/components/data-menu/index.marko @@ -1,9 +1,9 @@ List Characters - Channels + Channels - Options - Add Character - Add Channel + Add + Character + Channel \ No newline at end of file diff --git a/marko/page/data/components/edit-channel-modal/component.js b/marko/page/data/components/edit-channel-modal/component.js new file mode 100644 index 0000000..b259fe9 --- /dev/null +++ b/marko/page/data/components/edit-channel-modal/component.js @@ -0,0 +1,57 @@ +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 + }) + } +} \ No newline at end of file diff --git a/marko/page/data/components/edit-channel-modal/index.marko b/marko/page/data/components/edit-channel-modal/index.marko new file mode 100644 index 0000000..0eb6066 --- /dev/null +++ b/marko/page/data/components/edit-channel-modal/index.marko @@ -0,0 +1,21 @@ + +

Edit ${input.channel.name}

+ +

${state.error}

+ + + + + + + + + + +

The logbot is not yet available, so this does nothing right now.

+ + +
\ No newline at end of file diff --git a/marko/page/data/components/edit-character-modal/index.marko b/marko/page/data/components/edit-character-modal/index.marko index ca4df44..4911b8a 100644 --- a/marko/page/data/components/edit-character-modal/index.marko +++ b/marko/page/data/components/edit-character-modal/index.marko @@ -12,5 +12,5 @@