Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I9992 #366

Merged
merged 24 commits into from
Jul 2, 2024
Merged

I9992 #366

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7168d74
pkp/pkp-lib#9992 Migrate Announcements to SideModal
jardakotesovec Jun 19, 2024
67fa9cf
pkp/pkp-lib#9992 clean up announcements moved to SideModal
jardakotesovec Jun 19, 2024
cf1dff0
pkp/pkp-lib#9992 Composer modals migrated to SideModal
jardakotesovec Jun 19, 2024
013f428
pkp/pkp-lib#9992 FileAttacher modal clean up
jardakotesovec Jun 19, 2024
b9b81e0
pkp/pkp-lib#9992 Migrate issue stats modal to SideModal
jardakotesovec Jun 19, 2024
3822e3b
pkp/pkp-lib#9992 publication stats migrated to side modal
jardakotesovec Jun 20, 2024
0e49e78
pkp/pkp-lib#9992 users stats export modal migrated to side modal
jardakotesovec Jun 20, 2024
63963d7
pkp/pkp-lib#9992 wizard modal migrated to side modal
jardakotesovec Jun 20, 2024
b31dfb9
pkp/pkp-lib#9992 FieldPreparedContent migrated to side modal
jardakotesovec Jun 20, 2024
ef5ba31
pkp/pkp-lib#9992 InstitutionsListPanel migrated to side modal, make s…
jardakotesovec Jun 20, 2024
a630219
pkp/pkp-lib#9992 Migrate SubmissionFilesEditModal to openSideModal
jardakotesovec Jun 20, 2024
6283392
pkp/pkp-lib#9992 HighlightsListPanel migrated to side modal
jardakotesovec Jun 20, 2024
2bd6344
pkp/pkp-lib#9992 Migrate ContributorsListPanel to side panel, rename …
jardakotesovec Jun 20, 2024
9fef7c5
pkp/pkp-lib#9992 Migrate CatalogListPanel to side modal
jardakotesovec Jun 24, 2024
ed6f417
pkp/pkp-lib#9992 Migrate doi list panel to side modal
jardakotesovec Jun 24, 2024
f2bac87
pkp/pkp-lib#9992 migrate workflow page to side modal
jardakotesovec Jun 24, 2024
abd7b89
pkp/pkp-lib#9992 migrate manageEmails to side modal
jardakotesovec Jun 24, 2024
019458e
pkp/pkp-lib#9992 Migrate error doi message modals to useDialog
jardakotesovec Jun 25, 2024
d5ed9ff
pkp/pkp-lib#9992 clean up modals in stories, copied over the tpl files
jardakotesovec Jun 25, 2024
3632001
pkp/pkp-lib#9992 move title directly to modal component when its not …
jardakotesovec Jun 25, 2024
83320bc
pkp/pkp-lib#9992 Update documentation for SideModal and Dialog, refac…
jardakotesovec Jun 25, 2024
939ecf4
pkp/pkp-lib#9992 Clean up
jardakotesovec Jun 25, 2024
5a77c55
pkp/pkp-lib#9992 Fix SideModal stories template
jardakotesovec Jun 25, 2024
ca0ac83
pkp/pkp-lib#9992 Address code review feedback
jardakotesovec Jul 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 11 additions & 34 deletions src/components/Composer/Composer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -253,18 +253,6 @@
</div>
</template>
</field-prepared-content>
<modal
:close-label="t('common.close')"
:name="fileAttacherModalId"
:title="attachFilesLabel"
:open="isModalOpenedFileAttacher"
@close="resetFocusAfterAttachment"
>
<file-attacher
:attachers="attachers"
@attached:files="addAttachments"
/>
</modal>
<field-error
v-if="errors.attachments"
:id="id + '-attachments-error'"
Expand All @@ -287,21 +275,18 @@
import FieldAutosuggestPreset from '@/components/Form/fields/FieldAutosuggestPreset.vue';
import FieldError from '@/components/Form/FieldError.vue';
import FieldPreparedContent from '@/components/Form/fields/FieldPreparedContent.vue';
import FileAttacher from '@/components/FileAttacher/FileAttacher.vue';
import Modal from '@/components/Modal/Modal.vue';
import Search from '@/components/Search/Search.vue';
import FileAttacherModal from './FileAttacherModal.vue';
import ajaxErrorCallback from '@/mixins/ajaxError';
import dialog from '@/mixins/dialog';
import preparedContent from '@/mixins/preparedContent';

import {useModal} from '@/composables/useModal';
export default {
name: 'Composer',
components: {
FieldAutosuggestPreset,
FieldError,
FieldPreparedContent,
FileAttacher,
Modal,
Search,
},
mixins: [ajaxErrorCallback, dialog, preparedContent],
Expand Down Expand Up @@ -555,7 +540,6 @@ export default {
searchPhrase: '',
searchResults: [],
showSearchResultCount: 10,
isModalOpenedFileAttacher: false,
};
},
computed: {
Expand Down Expand Up @@ -586,7 +570,13 @@ export default {
icon: 'upload',
text: self.t('common.attachFiles'),
onAction() {
self.isModalOpenedFileAttacher = true;
const {openSideModal} = useModal();

openSideModal(FileAttacherModal, {
title: self.attachFilesLabel,
attachers: self.attachers,
onAddAttachments: self.addAttachments,
});
},
});
editor.settings.toolbar += ' | pkpAttachFiles';
Expand Down Expand Up @@ -753,7 +743,8 @@ export default {
}),
];
this.emitChange({attachments});
this.isModalOpenedFileAttacher = false;
const {closeSideModal} = useModal();
closeSideModal(FileAttacherModal);
},

/**
Expand Down Expand Up @@ -916,20 +907,6 @@ export default {
});
},

/**
* Reset the focus when the attachment modal is closed
*/
resetFocusAfterAttachment() {
this.isModalOpenedFileAttacher = false;
this.$nextTick(() => {
if (this.$refs.attachedFiles) {
this.$refs.attachedFiles.focus();
} else {
this.setFocusIn(this.$el.querySelector('.composer__body'));
}
});
},

/**
* Search for email templates
*/
Expand Down
26 changes: 26 additions & 0 deletions src/components/Composer/FileAttacherModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<SideModalBody>
<template #title>
{{ title }}
</template>
<SideModalLayoutBasic>
<FileAttacher
:attachers="attachers"
@attached:files="(...args) => emit('addAttachments', ...args)"
/>
</SideModalLayoutBasic>
</SideModalBody>
</template>

<script setup>
import SideModalBody from '@/components/Modal/SideModalBody.vue';
import SideModalLayoutBasic from '@/components/Modal/SideModalLayoutBasic.vue';
import FileAttacher from '@/components/FileAttacher/FileAttacher.vue';

defineProps({
title: {type: String, required: true},
attachers: {type: Object, required: true},
});

const emit = defineEmits(['addAttachments']);
</script>
65 changes: 0 additions & 65 deletions src/components/Container/ManageEmailsPage.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,71 +97,6 @@ const ManageEmailsPageWithDataAndTemplate = {
</div>
</template>
</list-panel>
<modal
:close-label="t('common.close')"
name="mailable"
:open="isModalOpenedMailable"
:title="currentMailable ? currentMailable.name : ''"
@close="closeMailableModal"
>
<template v-if="currentMailable">
<p>{{ currentMailable.description }}</p>
<p>
Add and edit templates that you would like to make available to the
user when they are sending this email. The default will be loaded
automatically, and the user will be able to quickly load any other
templates you add here.
</p>
<list-panel :items="currentMailable.emailTemplates">
<template #header>
<pkp-header>
<h3>Templates</h3>
<template #actions>
<pkp-button @click="openTemplate()">Add Template</pkp-button>
</template>
</pkp-header>
</template>
<template #item-subtitle="{item}">
{{ localize(item.name) }}
</template>
<template #item-actions="{item}">
<badge v-if="item.key === currentMailable.emailTemplateKey">
Default
</badge>
<pkp-button @click="openTemplate(item)">Edit</pkp-button>
<pkp-button
v-if="item.key === currentMailable.emailTemplateKey && item.id"
:is-warnable="true"
@click="confirmResetTemplate(item)"
>
Reset
</pkp-button>
<pkp-button
v-else-if="item.id"
:is-warnable="true"
@click="confirmRemoveTemplate(item)"
>
Remove
</pkp-button>
</template>
</list-panel>
</template>
</modal>
<modal
:close-label="t('common.close')"
name="template"
:open="isModalOpenedTemplate"
:title="currentTemplate ? 'Edit Template' : 'Add Template'"
@close="closeTemplateModal"
>
<pkp-form
ref="templateForm"
class="manageEmails__templateForm"
v-bind="currentTemplateForm"
@set="updateCurrentTemplateForm"
@success="templateSaved"
></pkp-form>
</modal>
</div>
`,
data() {
Expand Down
50 changes: 29 additions & 21 deletions src/components/Container/ManageEmailsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import Modal from '../Modal/Modal.vue';
import PkpFilter from '../Filter/Filter.vue';
import Search from '../Search/Search.vue';
import dialog from '../../mixins/dialog';
import EditMailableModal from '@/pages/manageEmails/EditMailableModal.vue';
import EditTemplateModal from '@/pages/manageEmails/EditTemplateModal.vue';
import {useLocalize} from '@/composables/useLocalize';
import {useModal} from '@/composables/useModal';

const {t} = useLocalize();

export default {
name: 'ManageEmailsPage',
Expand Down Expand Up @@ -36,8 +42,6 @@ export default {
mailables: [],
/** The URL to the `/mailables` endpoint in the REST API. */
mailablesApiUrl: '',
/** Used to reset focus when a modal is closed. */
resetFocusTo: {},
/** The value of the search input. */
searchPhrase: '',
/** A "clean" copy of the form to add or edit an `EmailTemplate`. The `currentTemplateForm` is a copy of this form that has been modified to add or edit a specific template. */
Expand Down Expand Up @@ -296,8 +300,8 @@ export default {
* Fired when the mailable modal is closed
*/
closeMailableModal() {
this.isModalOpenedMailable = false;
this.resetFocus();
const {closeSideModal} = useModal();
closeSideModal(EditMailableModal);
setTimeout(() => {
this.currentMailable = {};
this.currentTemplate = {};
Expand All @@ -315,9 +319,15 @@ export default {
openMailable(mailable) {
if (mailable.supportsTemplates) {
this.getMailable(mailable, (mailable) => {
this.resetFocusTo = document.activeElement;
this.currentMailable = mailable;
this.isModalOpenedMailable = true;
const {openSideModal} = useModal();
openSideModal(EditMailableModal, {
title: mailable ? mailable.name : '',
mailable: this.currentMailable,
onOpenTemplate: this.openTemplate,
onConfirmResetTemplate: this.confirmRemoveTemplate,
onConfirmRemoveTemplate: this.confirmRemoveTemplate,
});
});
} else {
this.getTemplate(mailable.emailTemplateKey, (template) => {
Expand All @@ -334,9 +344,18 @@ export default {
*/
openTemplate(template) {
template = template || {};
this.resetFocusTo = document.activeElement;
this.currentTemplate = template;
this.$nextTick(() => (this.isModalOpenedTemplate = true));
const {openSideModal} = useModal();
this.$nextTick(() =>
openSideModal(EditTemplateModal, {
title: this.currentTemplate
? t('manager.mailables.editTemplate')
: t('manager.emails.addEmail'),
currentTemplateForm: this.currentTemplateForm,
onUpdateCurrentTemplateForm: this.updateCurrentTemplateForm,
onTemplateSaved: this.templateSaved,
}),
);
},

/**
Expand All @@ -355,17 +374,6 @@ export default {
this.activeFilters = newFilters;
},

/**
* A helper function to move the focus back to the element
* it was last at. This is usually used with modals to restore
* the focus after a modal is closed.
*/
resetFocus() {
if (this.resetFocusTo) {
this.resetFocusTo.focus();
}
},

/**
* Setup the form to edit an email template
*
Expand Down Expand Up @@ -455,9 +463,9 @@ export default {
* Fired when the email template modal has been closed
*/
closeTemplateModal() {
this.isModalOpenedTemplate = false;
const {closeSideModal} = useModal();
closeSideModal(EditTemplateModal);
if (this.currentMailable.supportsTemplates) {
this.resetFocus();
setTimeout(() => {
this.currentTemplate = {};
}, 300);
Expand Down
22 changes: 22 additions & 0 deletions src/components/Container/StatsContextPage.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script>
import StatsPublicationsPage from '@/components/Container/StatsPublicationsPage.vue';
import ContextDownloadReportModal from '@/pages/statsContext/ContextDownloadReportModal.vue';
import {useModal} from '@/composables/useModal';

export default {
name: 'StatsContextPage',
Expand All @@ -8,6 +10,26 @@ export default {
return {isModalOpenedDownloadReport: false};
},
methods: {
/**
* Open download report modal, for context
*/
openDownloadReportModal() {
const {openSideModal} = useModal();
openSideModal(ContextDownloadReportModal, {
timelineDescription: this.getTimelineDescription(),
dateRangeDescription: this.getDateRangeDescription(),
onDownloadReport: this.downloadReport,
});
},

/**
* Close download report modal, for context
*/
closeDownloadReportModal() {
const {closeSideModal} = useModal();
closeSideModal(ContextDownloadReportModal);
},

/**
* The params to send with each GET request
*
Expand Down
24 changes: 23 additions & 1 deletion src/components/Container/StatsIssuesPage.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script>
import StatsPublicationsPage from '@/components/Container/StatsPublicationsPage.vue';

import IssueDownloadReportModal from '@/pages/statsIssues/IssueDownloadReportModal.vue';
import {useModal} from '@/composables/useModal';
export default {
name: 'StatsIssuesPage',
extends: StatsPublicationsPage,
Expand All @@ -10,6 +11,27 @@ export default {
};
},
methods: {
/**
* Open download report modal, for issues
*/
openDownloadReportModal() {
const {openSideModal} = useModal();
openSideModal(IssueDownloadReportModal, {
searchPhrase: this.searchPhrase,
timelineDescription: this.getTimelineDescription(),
dateRangeDescription: this.getDateRangeDescription(),
onDownloadReport: this.downloadReport,
});
},

/**
* Close download report modal, for issues
*/
closeDownloadReportModal() {
const {closeSideModal} = useModal();
closeSideModal(IssueDownloadReportModal);
},

/**
* Set items and itemsMax from the API call result
*/
Expand Down
Loading