Skip to content

Commit

Permalink
show loading animation while immediate actions load. So for example w…
Browse files Browse the repository at this point in the history
…hen you click "Fetch", you'll now see that something is happening when your network is slow and it's not possible to click it again while doing so.
  • Loading branch information
phil294 committed May 10, 2023
1 parent 7fed1a5 commit 12d73e0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
6 changes: 5 additions & 1 deletion web/src/components/PromiseForm.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="slm">
form @submit.prevent="submit" enctype="multipart/form-data"
form @submit.prevent="submit" enctype="multipart/form-data" ref="form_ref"
/ using an invisible fieldset wrapper to group disable attribute for all children (does not work on <form> directly)
fieldset.low-key :disabled="disabled || loading" :class="$attrs.class"
legend
Expand Down Expand Up @@ -37,7 +37,11 @@ export default
data: =>
loading: false
methods:
request_submit: ->
@$refs.form_ref.requestSubmit()
submit: (event) ->
if not event
throw new Error("Cannot call `submit` on PromiseForm directly. Use `request_submit` instead.")
@loading = true
@$emit 'submit', event
Expand Down
14 changes: 10 additions & 4 deletions web/src/views/GitInput.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,24 @@ export default defineComponent
throw e
else
console.warn e
if props.git_action.ignore_errors
emit 'success'
return
finally
emit 'executed'
if not props.hide_result
data.value = result
emit 'success', result

do =>
# typing doesn't work https://github.com/vuejs/composition-api/issues/402
### @type {Ref<InstanceType<import('../components/PromiseForm.vue')>|null>} ###
# so we need the ts-ignore below. TODO
ref_form = ref null
onMounted =>
await get_saved()
if props.git_action.immediate
await execute()
if props.git_action.ignore_errors
emit 'success'
# @ts-ignore
await ref_form.value?.request_submit()

{
command
Expand All @@ -153,4 +158,5 @@ export default defineComponent
has_unsaved_changes
save
params_input_refs
ref_form
}
2 changes: 1 addition & 1 deletion web/src/views/GitInput.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template lang="slm">
div.col.gap-10
promise-form.col.gap-5 :action="execute"
promise-form.col.gap-5 :action="execute" ref="ref_form"
.row.align-center.gap-10
code git
input.command.flex-1 v-model="command"
Expand Down
10 changes: 5 additions & 5 deletions web/src/vue-shims.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module '*.vue' {
import { DefineComponent } from 'vue';
const component: DefineComponent<{}, {}, any>;
export default component;
}
// https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-plugin-typescript/generator/template/src/shims-vue.d.ts
declare module "*.vue" {
import Vue from "vue";
export default Vue;
}

0 comments on commit 12d73e0

Please sign in to comment.