diff --git a/resources/js/components/actions/BulkActions.vue b/resources/js/components/actions/BulkActions.vue index 5382b1eb4a..9a9252afb5 100644 --- a/resources/js/components/actions/BulkActions.vue +++ b/resources/js/components/actions/BulkActions.vue @@ -16,6 +16,7 @@ const emit = defineEmits(['started', 'completed']); const { prepareActions, runServerAction } = useActions(); let actions = ref([]); +let loading = ref(false); const confirmableActions = useTemplateRef('confirmableActions'); @@ -49,6 +50,8 @@ function getActions() { return; } + loading.value = true; + let params = { selections: toRaw(props.selections), }; @@ -59,7 +62,10 @@ function getActions() { axios .post(props.url + '/list', params) - .then(response => actions.value = response.data); + .then(response => { + actions.value = response.data; + loading.value = false; + }); } let errors = ref({}); @@ -91,5 +97,6 @@ function runAction(action, values, onSuccess, onError) { diff --git a/resources/js/components/ui/Listing/BulkActions.vue b/resources/js/components/ui/Listing/BulkActions.vue index 525a1b9f4e..3b9305c985 100644 --- a/resources/js/components/ui/Listing/BulkActions.vue +++ b/resources/js/components/ui/Listing/BulkActions.vue @@ -2,12 +2,23 @@ import { Motion } from 'motion-v'; import { injectListingContext } from '../Listing/Listing.vue'; import { computed, ref, watch } from 'vue'; -import { Button, ButtonGroup } from '@ui'; +import { Button, ButtonGroup, Icon } from '@ui'; import BulkActions from '@/components/actions/BulkActions.vue'; const { actionUrl, actionContext, selections, refresh, clearSelections } = injectListingContext(); const busy = ref(false); const hasSelections = computed(() => selections.value.length > 0); +const visible = ref(false); +let visibleTimeout = null; + +watch(hasSelections, (value) => { + clearTimeout(visibleTimeout); + if (value) { + visibleTimeout = setTimeout(() => visible.value = true, 300); + } else { + visible.value = false; + } +}); watch(busy, (busy) => Statamic.$progress.loading('action', busy)); @@ -40,21 +51,22 @@ function actionFailed(response) { :context="actionContext" @started="actionStarted" @completed="actionCompleted" - v-slot="{ actions }" + v-slot="{ actions, loading }" >