Skip to content

Commit

Permalink
I9992 (pkp#10124)
Browse files Browse the repository at this point in the history
* pkp#9992 Migration to side modal for context stats

* pkp#9992 Migration to side modal for publication stats

* pkp#9992 users stats export modal migrated to side modal

* pkp#9992 wizard modal migrated to side modal

* pkp#9992 Migrate ContributorsListPanel to side panel, migrated translations

* pkp#9992 migrate manageEmails to side modal

* pkp#9992 adjust cypress tests for side modal

* pkp#9992 Adjust cypress tests for side modal migration
  • Loading branch information
jardakotesovec authored Jul 2, 2024
1 parent 203067f commit cfb1849
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 253 deletions.
6 changes: 6 additions & 0 deletions classes/components/PKPStatsPublicationPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class PKPStatsPublicationPage extends PKPStatsComponent
/** @var string A search phrase to filter the list of items */
public $searchPhrase = null;

/** @var string When Geographical statistic are enabled, options: countries/regions/cities */
public $geoReportType = null;



/**
* Retrieve the configuration data to be used when initializing this
* handler on the frontend
Expand Down Expand Up @@ -85,6 +90,7 @@ public function getConfig()
'orderBy' => $this->orderBy,
'orderDirection' => $this->orderDirection,
'isLoadingTimeline' => false,
'geoReportType' => $this->geoReportType
]
);

Expand Down
15 changes: 0 additions & 15 deletions classes/components/listPanels/ContributorsListPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,6 @@ public function getConfig()
'publicationApiUrlFormat' => $this->getPublicationUrlFormat(),
'form' => $this->getLocalizedForm(),
'items' => $this->items,
'i18nAddContributor' => __('grid.action.addContributor'),
'i18nConfirmDelete' => __('grid.action.deleteContributor.confirmationMessage'),
'i18nDeleteContributor' => __('grid.action.deleteContributor'),
'i18nEditContributor' => __('grid.action.edit'),
'i18nSetPrimaryContact' => __('author.users.contributor.setPrincipalContact'),
'i18nPrimaryContact' => __('author.users.contributor.principalContact'),
'i18nContributors' => __('submission.contributors'),
'i18nSaveOrder' => __('grid.action.saveOrdering'),
'i18nPreview' => __('contributor.listPanel.preview'),
'i18nPreviewDescription' => __('contributor.listPanel.preview.description'),
'i18nDisplay' => __('contributor.listPanel.preview.display'),
'i18nFormat' => __('contributor.listPanel.preview.format'),
'i18nAbbreviated' => __('contributor.listPanel.preview.abbreviated'),
'i18nPublicationLists' => __('contributor.listPanel.preview.publicationLists'),
'i18nFull' => __('contributor.listPanel.preview.full'),
]
);

Expand Down
6 changes: 3 additions & 3 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -785,12 +785,12 @@ Cypress.Commands.add('checkDoiMarkedStatus', (status, itemId, isValid, expectedS
if (isValid) {
cy.get('.app__notifications').contains(`Items successfully marked ${status}`, {matchCase: false, timeout:20000});
} else {
cy.get('div[name="failedDoiActionModal"]').contains('Failed to mark the DOI', {timeout:20000});
cy.get('div[role=dialog]').contains('Failed to mark the DOI', {timeout:20000});
}

cy.get(`#list-item-${itemType}-${itemId} .pkpBadge`).contains(expectedStatus);
if (!isValid) {
cy.get(`div[name="failedDoiActionModal"] button:contains('Close')`).click();
cy.get(`div[role=dialog] button:contains('Close')`).click();
}
});

Expand Down Expand Up @@ -838,7 +838,7 @@ Cypress.Commands.add('uploadSubmissionFiles', (files, options) => {
} else {
$row.get('button:contains("Other")').last().click({force: true});
cy.get('.pkpFormField--options__optionLabel').contains(file.genre).click();
cy.get('.modal button').contains('Save').click();
cy.get('div[role="dialog"] button').contains('Save').click();
}
cy.wait('@genreDefined').its('response.statusCode').should('eq', 200);

Expand Down
6 changes: 3 additions & 3 deletions cypress/tests/integration/Announcements.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('Announcements', function() {
cy.get('#announcement-title-control-en').type(title, {delay: 0});
cy.setTinyMceContent('announcement-descriptionShort-control-en', desc);
cy.setTinyMceContent('announcement-description-control-en', desc.repeat(5));
cy.get('.modal .pkpForm button').contains('Save').click();
cy.get('[role=dialog] .pkpForm button').contains('Save').click();
cy.get('#announcements .listPanel__itemTitle:contains("' + title + '")')
.parents('.listPanel__itemSummary').find('a').contains('View').click();
cy.get('h1').contains(title);
Expand All @@ -55,13 +55,13 @@ describe('Announcements', function() {
var title = 'Example announcement';
cy.wait(500);
cy.get('#announcement-title-control-en').type(title, {delay: 0});
cy.get('.modal .pkpForm button').contains('Save').click();
cy.get('[role=dialog] .pkpForm button').contains('Save').click();

// Edit announcement
cy.get('#announcements .listPanel__itemTitle:contains("' + title + '")')
.parents('.listPanel__itemSummary').find('button').contains('Edit').click();
cy.get('#announcement-title-control-en').type('2');
cy.get('.modal .pkpForm button').contains('Save').click();
cy.get('[role=dialog] .pkpForm button').contains('Save').click();
cy.get('#announcements .listPanel__itemTitle:contains("' + title + '2")');

// Delete announcement
Expand Down
30 changes: 16 additions & 14 deletions pages/stats/PKPStatsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,20 @@ public function publications($args, $request)
'dateEnd' => $dateEnd,
]);

$geoAPIEndPoint = null;
$geoStatsSetting = $context->getEnableGeoUsageStats($request->getSite());
switch ($geoStatsSetting) {
case PKPStatisticsHelper::STATISTICS_SETTING_COUNTRY:
$geoAPIEndPoint = 'countries';
break;
case PKPStatisticsHelper::STATISTICS_SETTING_REGION:
$geoAPIEndPoint = 'regions';
break;
case PKPStatisticsHelper::STATISTICS_SETTING_CITY:
$geoAPIEndPoint = 'cities';
break;
}

$statsComponent = new \PKP\components\PKPStatsPublicationPage(
$dispatcher->url($request, PKPApplication::ROUTE_API, $context->getPath(), 'stats/publications'),
[
Expand Down Expand Up @@ -322,28 +336,16 @@ public function publications($args, $request)
],
'orderBy' => 'total',
'orderDirection' => true,
'geoReportType' => $geoAPIEndPoint

]
);

$geoAPIEndPoint = null;
$geoStatsSetting = $context->getEnableGeoUsageStats($request->getSite());
switch ($geoStatsSetting) {
case PKPStatisticsHelper::STATISTICS_SETTING_COUNTRY:
$geoAPIEndPoint = 'countries';
break;
case PKPStatisticsHelper::STATISTICS_SETTING_REGION:
$geoAPIEndPoint = 'regions';
break;
case PKPStatisticsHelper::STATISTICS_SETTING_CITY:
$geoAPIEndPoint = 'cities';
break;
}
$templateMgr->setState($statsComponent->getConfig());
$templateMgr->assign([
'pageComponent' => 'StatsPublicationsPage',
'pageTitle' => __('stats.publicationStats'),
'pageWidth' => TemplateManager::PAGE_WIDTH_WIDE,
'geoReportType' => $geoAPIEndPoint
]);

$templateMgr->display('stats/publications.tpl');
Expand Down
64 changes: 0 additions & 64 deletions templates/management/manageEmails.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -99,68 +99,4 @@
</div>
</template>
</list-panel>
<modal
:close-label="t('common.close')"
name="mailable"
:title="currentMailable ? currentMailable.name : ''"
:open="isModalOpenedMailable"
@close="closeMailableModal"
>
<template v-if="currentMailable">
<p>{{ currentMailable.description }}</p>
<p>{translate key="manager.mailables.addTemplates"}</p>
<list-panel
:items="currentMailable.emailTemplates"
>
<template #header>
<pkp-header>
<h3>{translate key="manager.mailables.templates"}</h3>
<template #actions>
<pkp-button @click="openTemplate()">{translate key="manager.emails.addEmail"}</pkp-button>
</template>
</pkp-header>
</template>
<template #item-subtitle="{ldelim}item{rdelim}">
{{ localize(item.name) }}
</template>
<template #item-actions="{ldelim}item{rdelim}">
<badge v-if="item.key === currentMailable.emailTemplateKey">
{translate key="common.default"}
</badge>
<pkp-button @click="openTemplate(item)">
{translate key="common.edit"}
</pkp-button>
<pkp-button
v-if="item.key === currentMailable.emailTemplateKey && item.id"
:is-warnable="true"
@click="confirmResetTemplate(item)"
>
{translate key="common.reset"}
</pkp-button>
<pkp-button
v-else-if="item.id"
:is-warnable="true"
@click="confirmRemoveTemplate(item)"
>
{translate key="common.remove"}
</pkp-button>
</template>
</list-panel>
</template>
</modal>
<modal
:close-label="t('common.close')"
name="template"
:title="currentTemplate ? '{translate key="manager.mailables.editTemplate"}' : '{translate key="manager.emails.addEmail"}'"
:open="isModalOpenedTemplate"
@close="closeTemplateModal"
>
<pkp-form
ref="templateForm"
class="manageEmails__templateForm"
v-bind="currentTemplateForm"
@set="updateCurrentTemplateForm"
@success="templateSaved"
></pkp-form>
</modal>
{/block}
43 changes: 1 addition & 42 deletions templates/stats/context.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -104,51 +104,10 @@
<template #actions>
<pkp-button
ref="downloadReportModalButton"
@click="isModalOpenedDownloadReport = true"
@click="openDownloadReportModal"
>
{translate key="common.downloadReport"}
</pkp-button>
<modal
close-label="{translate key="common.close"}"
name="downloadReport"
title={translate key="common.download"}
:open="isModalOpenedDownloadReport"
@close="isModalOpenedDownloadReport = false"
>
<p>{translate key="stats.context.downloadReport.description"}</p>
<table class="pkpTable pkpStats__reportParams">
<tr class="pkpTable__row">
<th>{translate key="stats.dateRange"}</th>
<td>{{ getDateRangeDescription() }}</th>
</tr>
</table>
<action-panel class="pkpStats__reportAction">
<h2>{translate key="context.context"}</h2>
<p>
{translate key="stats.context.downloadReport.downloadContext.description"}
</p>
<template #actions>
<pkp-button
@click="downloadReport"
>
{translate key="stats.context.downloadReport.downloadContext"}
</pkp-button>
</template>
</action-panel>
<action-panel class="pkpStats__reportAction">
<h2>{translate key="stats.timeline"}</h2>
<p>
{{ getTimelineDescription() }}
</p>
<template #actions>
<pkp-button
@click="downloadReport('timeline')"
>
{translate key="stats.timeline.downloadReport.downloadTimeline"}
</pkp-button>
</template>
</action-panel>
</modal>
</template>
</pkp-header>
<pkp-table
Expand Down
89 changes: 1 addition & 88 deletions templates/stats/publications.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -175,97 +175,10 @@
</div>
<pkp-button
ref="downloadReportModalButton"
@click="isModalOpenedDownloadReport = true"
@click="openDownloadReportModal"
>
{translate key="common.downloadReport"}
</pkp-button>
<modal
close-label="{translate key="common.close"}"
name="downloadReport"
title={translate key="common.download"}
:open="isModalOpenedDownloadReport"
@close="isModalOpenedDownloadReport = false"
>
<p>{translate key="stats.publications.downloadReport.description"}</p>
<table class="pkpTable pkpStats__reportParams">
<tr class="pkpTable__row">
<th>{translate key="stats.dateRange"}</th>
<td>{{ getDateRangeDescription() }}</td>
</tr>
<tr
v-for="(filterSet, index) in filters"
class="pkpTable__row">
<th>{{ filterSet.heading }}</th>
<td>{{ getFilterDescription(filterSet) }}</td>
</tr>
<tr
v-if="searchPhrase"
class="pkpTable__row">
<th>{translate key="common.searchPhrase"}</th>
<td>{{ searchPhrase }}</td>
</tr>
</table>
<action-panel class="pkpStats__reportAction">
<h2>{translate key="common.publications"}</h2>
<p>
{translate key="stats.publications.downloadReport.downloadSubmissions.description"}
</p>
<template #actions>
<pkp-button
@click="downloadReport"
>
{translate key="stats.publications.downloadReport.downloadSubmissions"}
</pkp-button>
</template>
</action-panel>
<action-panel class="pkpStats__reportAction">
<h2>{translate key="submission.files"}</h2>
<p>
{translate key="stats.publications.downloadReport.downloadFiles.description"}
</p>
<template #actions>
<pkp-button
@click="downloadReport('files')"
>
{translate key="stats.publications.downloadReport.downloadFiles"}
</pkp-button>
</template>
</action-panel>
<action-panel class="pkpStats__reportAction">
<h2>{translate key="stats.timeline"}</h2>
<p>
{{ getTimelineDescription() }}
</p>
<template #actions>
<pkp-button
@click="downloadReport('timeline')"
>
{translate key="stats.timeline.downloadReport.downloadTimeline"}
</pkp-button>
</template>
</action-panel>
{if $geoReportType}
<action-panel class="pkpStats__reportAction">
<h2>
{translate key="common.geographic"}
<tooltip
tooltip="{translate key="stats.geographic.ccAttribution"}"
label="{translate key="stats.geographic.tooltip.label"}"
></tooltip>
</h2>
<p>
{translate key="stats.publications.downloadReport.downloadGeographic.description"}
</p>
<template #actions>
<pkp-button
@click="downloadReport('{$geoReportType}')"
>
{translate key="stats.publications.downloadReport.downloadGeographic"}
</pkp-button>
</template>
</action-panel>
{/if}
</modal>
</template>
</pkp-header>
<pkp-table
Expand Down
11 changes: 1 addition & 10 deletions templates/stats/users.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<pkp-header>
<h1 id="usersTableLabel" class="pkpHeader__title">{translate key="manager.statistics.statistics.registeredUsers"}</h1>
<template #actions>
<pkp-button ref="exportButton" @click="isModalOpenedExport = true">
<pkp-button ref="exportButton" @click="openExportModal">
{translate key="common.export"}
</pkp-button>
</template>
Expand All @@ -39,13 +39,4 @@
</table>
</div>
</div>
<modal
close-label="common.close"
name="export"
title="{translate key="manager.export.usersToCsv.label"}"
:open="isModalOpenedExport"
@close="isModalOpenedExport = false"
>
<pkp-form v-bind="components.usersReportForm" @set="set" @success="loadExport" />
</modal>
{/block}
Loading

0 comments on commit cfb1849

Please sign in to comment.