familyfriendlymikey
2 years ago
9 changed files with 143 additions and 98 deletions
@ -1,37 +1,106 @@ |
|||||
tag app-edit < app-prompt |
tag app-edit |
||||
|
|
||||
|
get render? do mounted? |
||||
|
active = no |
||||
|
|
||||
|
def open data |
||||
|
link = data |
||||
|
active = yes |
||||
|
|
||||
|
def close |
||||
|
active = no |
||||
|
|
||||
|
def mount |
||||
|
setTimeout(&, 40) do |
||||
|
$dn.focus! |
||||
|
imba.commit! |
||||
|
|
||||
def handle_click_set_default_bang |
def handle_click_set_default_bang |
||||
if editing_link.is_bang isnt true |
if link.is_bang isnt true |
||||
return err "setting default bang", "Link is not a bang." |
return err "setting default bang", "Link is not a bang." |
||||
config.default_bang = editing_link |
config.default_bang = link |
||||
save_config! |
save_config! |
||||
editing_link = no |
|
||||
state.query = prior_query |
state.query = prior_query |
||||
prior_query = '' |
prior_query = '' |
||||
sort_links! |
sort_links! |
||||
|
|
||||
|
def handle_delete |
||||
|
try |
||||
|
await api.delete_link link |
||||
|
close! |
||||
|
catch e |
||||
|
err "deleting link", e |
||||
|
|
||||
|
def save |
||||
|
try |
||||
|
if /\s/.test link.name.trim! |
||||
|
throw "Link name may not contain spaces." |
||||
|
api.update_link link, api.construct_link_text link |
||||
|
close! |
||||
|
catch e |
||||
|
err "saving link", e |
||||
|
|
||||
|
get new_link_text |
||||
|
"wip" |
||||
|
|
||||
|
def cycle_focus |
||||
|
if document.activeElement is $dn |
||||
|
$n.focus! |
||||
|
elif document.activeElement is $n |
||||
|
$u.focus! |
||||
|
else |
||||
|
$dn.focus! |
||||
|
|
||||
def render |
def render |
||||
|
|
||||
<self> |
<self> |
||||
|
css d:flex fld:column gap:20px w:100% |
||||
|
|
||||
<.tips> |
<.tips> |
||||
|
|
||||
<.tip |
<.tip |
||||
@click=(active = no) |
@click=close |
||||
|
@hotkey('esc').capture.if(!state.loading)=close |
||||
> |
> |
||||
<.tip-hotkey> "Esc" |
<.tip-hotkey> "Esc" |
||||
<.tip-content> "Cancel Edits" |
<.tip-content> "Cancel" |
||||
if editing_link.is_bang |
|
||||
<.tip |
<.tip |
||||
@click=handle_click_set_default_bang |
@click=handle_delete |
||||
> |
@hotkey('shift+backspace').capture.if(!state.loading)=handle_delete |
||||
|
> |
||||
|
css fl:2 |
||||
|
<.tip-hotkey> "Shift + Backspace" |
||||
|
<.tip-content> "Delete Link" |
||||
|
|
||||
|
if link.is_bang |
||||
|
<.tip @click=handle_click_set_default_bang> |
||||
|
css fl:2 |
||||
<.tip-hotkey> "Click" |
<.tip-hotkey> "Click" |
||||
<.tip-content> "Set Default Bang" |
<.tip-content> "Set Default Bang" |
||||
|
|
||||
<.tip |
<.tip |
||||
@click=handle_shift_return |
@click=save |
||||
|
@hotkey('shift+return').capture.if(!state.loading)=save |
||||
> |
> |
||||
<.tip-hotkey> "Shift + Return" |
css fl:2 |
||||
<.tip-content[of:hidden text-overflow:ellipsis white-space:nowrap]> |
<.tip-hotkey> "Return" |
||||
"Update Link" |
<.tip-content> "Update Link" |
||||
<.tip |
|
||||
@click=handle_shift_backspace |
<.tip.noclick |
||||
|
@hotkey('tab').capture.if(!state.loading)=cycle_focus |
||||
> |
> |
||||
<.tip-hotkey> "Shift + Backspace" |
<.tip-hotkey> "Tab" |
||||
<.tip-content> "Delete Link" |
<.tip-content> "Next" |
||||
|
|
||||
|
<.inputs> |
||||
|
css d:flex fld:column gap:20px |
||||
|
|
||||
|
<div> |
||||
|
<input$dn bind=link.display_name> |
||||
|
|
||||
|
<div> |
||||
|
<input$n bind=link.name> |
||||
|
|
||||
|
<div> |
||||
|
<input$u bind=link.url> |
||||
|
Loading…
Reference in new issue