Checkbox item visualizes error

This commit is contained in:
Magnus Åhall 2024-01-10 23:28:00 +01:00
parent f98a6ab863
commit dc2b6dac8b
4 changed files with 21 additions and 2 deletions

View file

@ -46,7 +46,10 @@ class App extends Component {
responseError({ comm, app, upload }) {//{{{
if (comm !== undefined) {
comm.text().then(body => alert(body))
if (typeof comm.text === 'function')
comm.text().then(body => alert(body))
else
alert(comm)
return
}

View file

@ -80,6 +80,7 @@ class ChecklistItemElement extends Component {
}//}}}
update(checked) {//{{{
this.setState({ checked })
this.checkbox.current.classList.remove('error')
window._app.current.request('/node/checklist_item/state', {
ChecklistItemID: this.props.item.ID,
State: checked,
@ -89,6 +90,8 @@ class ChecklistItemElement extends Component {
setTimeout(()=>this.checkbox.current.classList.remove('ok'), 500)
})
.catch(window._app.current.responseError)
.catch(()=>{
this.checkbox.current.classList.add('error')
})
}//}}}
}