Implemented +/- buttons for episode count (closes #72)

This commit is contained in:
Eduard Urbach 2017-11-16 22:54:42 +01:00
parent abfad585e8
commit e8aed98b3c
2 changed files with 16 additions and 3 deletions

View File

@ -18,9 +18,9 @@ component InputNumberWithButtons(id string, value float64, label string, placeho
label(for=id)= label + ":"
.number-input-container
input.widget-ui-element.action(id=id, data-field=id, type="number", value=value, min=min, max=max, step=step, placeholder=placeholder, title=placeholder, data-action="save", data-trigger="change")
button
button.action(data-action="addNumber", data-trigger="click", data-id=id, data-add="1")
RawIcon("plus")
button
button.action(data-action="addNumber", data-trigger="click", data-id=id, data-add="-1")
RawIcon("minus")
component InputSelection(id string, value string, label string, placeholder string, options []*arn.Option)

View File

@ -78,3 +78,16 @@ export function increaseEpisode(arn: AnimeNotifier, element: HTMLElement) {
prev.innerText = String(episodes + 1)
save(arn, prev)
}
// Add number
export function addNumber(arn: AnimeNotifier, element: HTMLElement) {
if(arn.isLoading) {
return
}
let input = arn.app.find(element.dataset.id) as HTMLInputElement
let add = parseInt(element.dataset.add)
let num = parseInt(input.value)
input.value = (num + add).toString()
save(arn, input)
}