Improved tag editing

This commit is contained in:
Eduard Urbach 2018-03-24 21:20:03 +01:00
parent cd1895e3c4
commit 2cbf7c4e5c
4 changed files with 8 additions and 7 deletions

View File

@ -55,12 +55,11 @@ component InputTags(id string, value []string, label string, tooltip string)
label(for=id)= label + ":"
.tags(id=id)
for index, tag := range value
.tag.tag-edit
span.tag-title.action(contenteditable="true", data-trigger="focusout", data-action="save", data-field=id + "[" + strconv.Itoa(index) + "]")= tag
.tag.tag-edit.action(contenteditable="true", data-action="save", data-trigger="focusout", data-field=id + "[" + strconv.Itoa(index) + "]")= tag
button.tag-remove.action(data-action="arrayRemove", data-trigger="click", data-field=id, data-index=index)
RawIcon("trash")
button.tag-add.action(data-action="arrayAppend", data-trigger="click", data-field=id)
button.tag-add.action(data-action="arrayAppend", data-trigger="click", data-field=id, title="Add more")
RawIcon("plus")
p!= tooltip

View File

@ -414,8 +414,6 @@ export class AnimeNotifier {
}
reloadContent(cached?: boolean) {
// console.log("reload content", "/_" + this.app.currentPath)
let headers = new Headers()
if(!cached) {
@ -482,6 +480,7 @@ export class AnimeNotifier {
let actionTrigger = element.dataset.trigger
let actionName = element.dataset.action
// Filter out invalid definitions
if(!actionTrigger || !actionName) {
continue
}
@ -501,11 +500,13 @@ export class AnimeNotifier {
element.onclick = null
}
// Warn us about undefined actions
if(!(actionName in actions)) {
this.statusMessage.showError(`Action '${actionName}' has not been defined`)
continue
}
// Register the actual action handler
let actionHandler = e => {
actions[actionName](this, element, e)

View File

@ -31,13 +31,14 @@ mixin genre-tag
color text-color
.tag-edit
border-right none
border-top-right-radius 0
border-bottom-right-radius 0
width auto
.tag-remove
tag-dimensions
margin-left 0
border-left none
border-top-left-radius 0
border-bottom-left-radius 0

View File

@ -218,7 +218,7 @@ func RenderField(b *bytes.Buffer, v *reflect.Value, field reflect.StructField, i
b.WriteString(`<div class="spacer"></div>`)
// Remove button
b.WriteString(`<button class="action" data-action="arrayRemove" data-trigger="click" data-field="` + field.Name + `" data-index="`)
b.WriteString(`<button class="action" title="Delete this ` + field.Name + `" data-action="arrayRemove" data-trigger="click" data-field="` + field.Name + `" data-index="`)
b.WriteString(strconv.Itoa(sliceIndex))
b.WriteString(`">` + utils.RawIcon("trash") + `</button>`)