Skip to content

Commit 46632b4

Browse files
pkp/pkp-lib#10663 Hide submissions on dashboard when loading different view/page/...
1 parent 4a0d293 commit 46632b4

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

src/components/Modal/Dialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
class="flex items-center gap-x-4"
6767
:class="icon ? 'p-10 ps-24' : 'p-12'"
6868
>
69-
<Spinner v-if="isLoading" />
7069
<PkpButton
7170
v-for="action in actions"
7271
:key="action.label"
@@ -81,6 +80,7 @@
8180
>
8281
{{ action.label }}
8382
</PkpButton>
83+
<Spinner v-if="isLoading" />
8484
</div>
8585
</DialogPanel>
8686
</TransitionChild>

src/composables/useFetch.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ export function getCSRFToken() {
3939
* @returns {Ref<boolean>} return.isLoading - A ref object indicating whether the fetch operation is currently in progress.
4040
* @returns {Function} return.fetch - The function to call to initiate the fetch operation. This function is async and handles the actual fetching logic.
4141
*
42+
* * The `fetch` function accepts the following optional parameter:
43+
* @param {Object} [fetchOptions={}] - Options to customize the fetch operation.
44+
* @param {boolean} [fetchOptions.clearData=false] - If set to `true`, processes and cleans the fetched data before storing it in `data`. Defaults to `false`.
45+
4246
*/
4347
export function useFetch(url, options = {}) {
4448
/**
@@ -72,7 +76,7 @@ export function useFetch(url, options = {}) {
7276
const screenName = modalLevel?.value ? `modal_${modalLevel.value}` : 'base';
7377
const progressStore = useProgressStore();
7478

75-
async function _fetch() {
79+
async function _fetch({clearData} = {clearData: false}) {
7680
if (lastRequestController) {
7781
// abort in-flight request
7882
lastRequestController.abort();
@@ -109,6 +113,9 @@ export function useFetch(url, options = {}) {
109113
}
110114

111115
isSuccess.value = null;
116+
if (clearData) {
117+
data.value = null;
118+
}
112119
try {
113120
const result = await ofetchInstance(unref(url), opts);
114121
data.value = result;
@@ -144,7 +151,7 @@ export function useFetch(url, options = {}) {
144151

145152
let fetch = _fetch;
146153
if (options.debouncedMs) {
147-
fetch = useDebounceFn(_fetch);
154+
fetch = useDebounceFn(_fetch, options.debouncedMs);
148155
}
149156
return {
150157
data,

src/pages/dashboard/components/DashboardTable/DashboardTable.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020
{{ column.header }}
2121
</TableColumn>
2222
</TableHeader>
23-
<TableBody>
23+
<TableBody
24+
:empty-text="
25+
dashboardStore.isSubmissionsLoading
26+
? t('common.loading')
27+
: t('grid.noItems')
28+
"
29+
>
2430
<TableRow v-for="item in items" :key="item.id">
2531
<CellBulkDelete
2632
v-if="dashboardStore.bulkDeleteSelectionEnabled"

src/pages/dashboard/dashboardPageStore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export const useDashboardPageStore = defineComponentStore(
221221

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

224-
await fetchSubmissions();
224+
await fetchSubmissions({clearData: true});
225225
announce(t('common.loaded'));
226226
},
227227
{immediate: true},

0 commit comments

Comments
 (0)