Skip to content

Commit

Permalink
pkp/pkp-lib#10067 Dashboard add extensibility for columns, left contr…
Browse files Browse the repository at this point in the history
…ols, right controls
  • Loading branch information
jardakotesovec committed Feb 24, 2025
1 parent b121af6 commit 3903d2e
Show file tree
Hide file tree
Showing 8 changed files with 240 additions and 20 deletions.
42 changes: 24 additions & 18 deletions src/pages/dashboard/DashboardPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
<div class="mt-2">
<div class="flex justify-between">
<div class="flex flex-row items-center gap-x-3">
<PkpButton @click="store.openFiltersModal">
{{ t('common.filter') }}
</PkpButton>
<DashboardBulkActions />
<DashboardBulkDeleteButton />
<component
:is="Components[action.component] || action.component"
v-bind="action.props || {}"
v-for="(action, i) in store.leftControlItems"
:key="i"
></component>
</div>
<div>
<Search
:search-phrase="store.searchPhrase"
:search-label="t('editor.submission.search')"
@search-phrase-changed="
(...args) => store.setSearchPhrase(...args)
"
></Search>
<div class="flex flex-row items-center gap-x-3">
<component
:is="Components[action.component] || action.component"
v-bind="action.props || {}"
v-for="(action, i) in store.rightControlItems"
:key="i"
></component>
</div>
</div>
</div>
Expand All @@ -56,17 +56,23 @@
</div>
</template>
<script setup>
import PkpButton from '@/components/Button/Button.vue';
import DashboardActiveFilters from './components/DashboardActiveFilters.vue';
import DashboardTable from './components/DashboardTable/DashboardTable.vue';
import DashboardBulkActions from './components/DashboardBulkActions.vue';
import DashboardBulkDeleteButton from './components/DashboardBulkDeleteButton.vue';
import Search from '@/components/Search/Search.vue';
import DashboardControlBulkActions from './components/DashboardControlBulkActions.vue';
import DashboardControlBulkDeleteButton from './components/DashboardControlBulkDeleteButton.vue';
import DashboardActionButton from './components/DashboardActionButton.vue';
import DashboardControlSearch from './components/DashboardControlSearch.vue';
import {useDashboardPageStore} from './dashboardPageStore';
import Spinner from '@/components/Spinner/Spinner.vue';
const Components = {
DashboardControlBulkActions,
DashboardControlBulkDeleteButton,
DashboardActionButton,
DashboardControlSearch,
};
const props = defineProps({
dashboardPage: {
required: true,
Expand Down
28 changes: 28 additions & 0 deletions src/pages/dashboard/components/DashboardActionButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<template>
<PkpButton
:is-primary="isPrimary"
:is-secondary="isSecondary"
:is-warnable="isWarnable"
:is-link="isLink"
@click="() => dashboardStore[action](actionArgs)"
>
{{ label }}
</PkpButton>
</template>
<script setup>
import PkpButton from '@/components/Button/Button.vue';
import {useDashboardPageStore} from '../dashboardPageStore';
const dashboardStore = useDashboardPageStore();
defineProps({
isPrimary: {type: Boolean, required: false, default: false},
isSecondary: {type: Boolean, required: false, default: false},
isWarnable: {type: Boolean, required: false, default: false},
action: {type: String, required: true},
actionArgs: {type: Object, required: false, default: () => {}},
isLink: {type: Boolean, default: false},
label: {type: String, required: true},
});
</script>
16 changes: 16 additions & 0 deletions src/pages/dashboard/components/DashboardControlSearch.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<Search
:search-phrase="store.searchPhrase"
:search-label="t('editor.submission.search')"
@search-phrase-changed="(...args) => store.setSearchPhrase(...args)"
></Search>
</template>
<script setup>
import Search from '@/components/Search/Search.vue';
import {useLocalize} from '@/composables/useLocalize';
const {t} = useLocalize();
import {useDashboardPageStore} from '../dashboardPageStore';
const store = useDashboardPageStore();
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
:item="item"
/>
<component
:is="cellComponents[column.componentName] || column.componentName"
:is="cellComponents[column.component] || column.component"
v-for="column in columns"
:key="column.id"
:item="item"
Expand Down
148 changes: 148 additions & 0 deletions src/pages/dashboard/composables/useDashboardConfiguration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import {useLocalize} from '@/composables/useLocalize';
import {DashboardPageTypes} from '../dashboardPageStore';

export function useDashboardConfiguration() {
const {t} = useLocalize();

function getLeftControls() {
const items = [];

items.push({
component: 'DashboardActionButton',
props: {label: t('common.filter'), action: 'openFiltersModal'},
});

items.push({
component: 'DashboardControlBulkActions',
props: {},
});

items.push({
component: 'DashboardControlBulkDeleteButton',
props: {},
});

return items;
}
function getRightControls() {
const items = [];

items.push({component: 'DashboardControlSearch', props: {}});

return items;
}

function getColumns({dashboardPage}) {
const columns = [];
if (dashboardPage === DashboardPageTypes.MY_REVIEW_ASSIGNMENTS) {
columns.push({
id: 'id',
header: t('common.id'),
component: 'CellReviewAssignmentId',
sortable: true,
});

columns.push({
id: 'title',
header: t('navigation.submissions'),
component: 'CellReviewAssignmentTitle',
sortable: false,
});

columns.push({
id: 'activity',
header: t('stats.editorialActivity'),
component: 'CellReviewAssignmentActivity',
sortable: false,
});

columns.push({
id: 'actions',
header: t('admin.jobs.list.actions'),
component: 'CellReviewAssignmentActions',
sortable: false,
});
} else if (dashboardPage === DashboardPageTypes.MY_SUBMISSIONS) {
columns.push({
id: 'id',
header: t('common.id'),
component: 'CellSubmissionId',
sortable: true,
});

columns.push({
id: 'title',
header: t('navigation.submissions'),
component: 'CellSubmissionTitle',
sortable: false,
});

columns.push({
id: 'stage',
header: t('workflow.stage'),
component: 'CellSubmissionStage',
sortable: false,
});

columns.push({
id: 'activity',
header: t('stats.editorialActivity'),
component: 'CellSubmissionActivity',
sortable: false,
});

columns.push({
id: 'actions',
header: t('admin.jobs.list.actions'),
component: 'CellSubmissionActions',
sortable: false,
});
} else {
columns.push({
id: 'id',
header: t('common.id'),
component: 'CellSubmissionId',
sortable: true,
});

columns.push({
id: 'title',
header: t('navigation.submissions'),
component: 'CellSubmissionTitle',
sortable: false,
});

columns.push({
id: 'stage',
header: t('workflow.stage'),
component: 'CellSubmissionStage',
sortable: false,
});

columns.push({
id: 'lastActivity',
header: t('editor.submission.days'),
component: 'CellSubmissionDays',
sortable: true,
});

columns.push({
id: 'activity',
header: t('stats.editorialActivity'),
component: 'CellSubmissionActivity',
sortable: false,
});

columns.push({
id: 'actions',
header: t('admin.jobs.list.actions'),
component: 'CellSubmissionActions',
sortable: false,
});
}

return columns;
}

return {getLeftControls, getRightControls, getColumns};
}
24 changes: 23 additions & 1 deletion src/pages/dashboard/dashboardPageStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {useAnnouncer} from '@/composables/useAnnouncer';
import {useUrl} from '@/composables/useUrl';
import {useQueryParams} from '@/composables/useQueryParams';
import {defineComponentStore} from '@/utils/defineComponentStore';
import {useExtender} from '@/composables/useExtender';

import {useWorkflowActions} from '../workflow/composables/useWorkflowActions';
import {useReviewerManagerActions} from '@/managers/ReviewerManager/useReviewerManagerActions';
Expand All @@ -17,6 +18,7 @@ import {useParticipantManagerActions} from '@/managers/ParticipantManager/usePar
import {useFileManagerActions} from '@/managers/FileManager/useFileManagerActions';

import {useEditorialLogic} from './composables/useEditorialLogic';
import {useDashboardConfiguration} from './composables/useDashboardConfiguration';
import {useReviewActivityLogic} from './composables/useReviewActivityLogic';
import {useSubmission} from '@/composables/useSubmission';

Expand Down Expand Up @@ -45,6 +47,8 @@ export const DashboardPageTypes = {
export const useDashboardPageStore = defineComponentStore(
'dashboardPage',
(pageInitConfig) => {
const extender = useExtender();

/**
* ModalStore
*/
Expand All @@ -69,6 +73,15 @@ export const useDashboardPageStore = defineComponentStore(
// Reactive query params parsed from the url
const queryParamsUrl = useQueryParams();

/**
* Config
*/
const dashboardConfig = extender.addFns(useDashboardConfiguration());
const leftControlItems = computed(() => dashboardConfig.getLeftControls());
const rightControlItems = computed(() =>
dashboardConfig.getRightControls(),
);

/**
* Views
*/
Expand Down Expand Up @@ -106,7 +119,11 @@ export const useDashboardPageStore = defineComponentStore(
/**
* Columns
*/
const columns = ref(pageInitConfig.columns);
const columns = computed(() =>
dashboardConfig.getColumns({
dashboardPage: pageInitConfig.dashboardPage,
}),
);

/**
* Search Phrase
Expand Down Expand Up @@ -414,6 +431,11 @@ export const useDashboardPageStore = defineComponentStore(
dashboardPage: pageInitConfig.dashboardPage,
dashboardPageTitle,
dashboardPageIcon,

// Config
leftControlItems,
rightControlItems,

// Views
views,
currentViewId,
Expand Down

0 comments on commit 3903d2e

Please sign in to comment.