Skip to content

Commit

Permalink
pkp/pkp-lib#10663 Hide submissions on dashboard when loading differen…
Browse files Browse the repository at this point in the history
…t view/page/...
  • Loading branch information
jardakotesovec committed Jan 9, 2025
1 parent 4a0d293 commit 55bdd6e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/Modal/Dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
class="flex items-center gap-x-4"
:class="icon ? 'p-10 ps-24' : 'p-12'"
>
<Spinner v-if="isLoading" />
<PkpButton
v-for="action in actions"
:key="action.label"
Expand All @@ -81,6 +80,7 @@
>
{{ action.label }}
</PkpButton>
<Spinner v-if="isLoading" />
</div>
</DialogPanel>
</TransitionChild>
Expand Down
11 changes: 9 additions & 2 deletions src/composables/useFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export function getCSRFToken() {
* @returns {Ref<boolean>} return.isLoading - A ref object indicating whether the fetch operation is currently in progress.
* @returns {Function} return.fetch - The function to call to initiate the fetch operation. This function is async and handles the actual fetching logic.
*
* * The `fetch` function accepts the following optional parameter:
* @param {Object} [fetchOptions={}] - Options to customize the fetch operation.
* @param {boolean} [fetchOptions.clearData=false] - If set to `true`, processes and cleans the fetched data before storing it in `data`. Defaults to `false`.
*/
export function useFetch(url, options = {}) {
/**
Expand Down Expand Up @@ -72,7 +76,7 @@ export function useFetch(url, options = {}) {
const screenName = modalLevel?.value ? `modal_${modalLevel.value}` : 'base';
const progressStore = useProgressStore();

async function _fetch() {
async function _fetch({clearData} = {clearData: false}) {
if (lastRequestController) {
// abort in-flight request
lastRequestController.abort();
Expand Down Expand Up @@ -109,6 +113,9 @@ export function useFetch(url, options = {}) {
}

isSuccess.value = null;
if (clearData) {
data.value = null;
}
try {
const result = await ofetchInstance(unref(url), opts);
data.value = result;
Expand Down Expand Up @@ -144,7 +151,7 @@ export function useFetch(url, options = {}) {

let fetch = _fetch;
if (options.debouncedMs) {
fetch = useDebounceFn(_fetch);
fetch = useDebounceFn(_fetch, options.debouncedMs);
}
return {
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
{{ column.header }}
</TableColumn>
</TableHeader>
<TableBody>
<TableBody
:empty-text="
dashboardStore.isSubmissionsLoading
? t('common.loading')
: t('grid.noItems')
"
>
<TableRow v-for="item in items" :key="item.id">
<CellBulkDelete
v-if="dashboardStore.bulkDeleteSelectionEnabled"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/dashboard/dashboardPageStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export const useDashboardPageStore = defineComponentStore(

announce(t('common.loading'));

await fetchSubmissions();
await fetchSubmissions({clearData: true});
announce(t('common.loaded'));
},
{immediate: true},
Expand Down

0 comments on commit 55bdd6e

Please sign in to comment.