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 + ":" label(for=id)= label + ":"
.tags(id=id) .tags(id=id)
for index, tag := range value for index, tag := range value
.tag.tag-edit .tag.tag-edit.action(contenteditable="true", data-action="save", data-trigger="focusout", data-field=id + "[" + strconv.Itoa(index) + "]")= tag
span.tag-title.action(contenteditable="true", data-trigger="focusout", data-action="save", data-field=id + "[" + strconv.Itoa(index) + "]")= tag
button.tag-remove.action(data-action="arrayRemove", data-trigger="click", data-field=id, data-index=index) button.tag-remove.action(data-action="arrayRemove", data-trigger="click", data-field=id, data-index=index)
RawIcon("trash") 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") RawIcon("plus")
p!= tooltip p!= tooltip

View File

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

View File

@ -31,13 +31,14 @@ mixin genre-tag
color text-color color text-color
.tag-edit .tag-edit
border-right none
border-top-right-radius 0 border-top-right-radius 0
border-bottom-right-radius 0 border-bottom-right-radius 0
width auto
.tag-remove .tag-remove
tag-dimensions tag-dimensions
margin-left 0 margin-left 0
border-left none
border-top-left-radius 0 border-top-left-radius 0
border-bottom-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>`) b.WriteString(`<div class="spacer"></div>`)
// Remove button // 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(strconv.Itoa(sliceIndex))
b.WriteString(`">` + utils.RawIcon("trash") + `</button>`) b.WriteString(`">` + utils.RawIcon("trash") + `</button>`)