const moment = require("moment") const {storyApi} = require("../../../../../rpdata/api/Story") module.exports = class { onCreate(input) { this.state = { error: null, loading: false, } } change(key, ev) { this.state.values[key] = ev.target.value } close() { this.emit("close") } addTag(tag) { if (tag.kind == "" || tag.name.length < 1) { this.state.error = "You cannot add an empty tag" return } this.state.error = null storyApi.addTag({id: this.input.story.id, tag}).then(({tags}) => { this.emit("tags", tags) }).catch(errs => { this.state.error = errs.message || errs[0].message || "Add tag failed" }) } removeTag(tag) { this.state.error = null storyApi.removeTag({id: this.input.story.id, tag}).then(({tags}) => { this.emit("tags", tags) }).catch(errs => { this.state.error = errs.message || errs[0].message || "Remove tag failed" }) } }