Skip to content

Commit

Permalink
#8248 consider when latest date is not bigger than earliest date and …
Browse files Browse the repository at this point in the history
…COUNTER R5 stats are not available yet
  • Loading branch information
bozana committed Jan 24, 2024
1 parent e76135c commit c1267f7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
7 changes: 0 additions & 7 deletions classes/components/forms/counter/PKPCounterReportForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
namespace PKP\components\forms\counter;

use PKP\components\forms\FormComponent;
use PKP\sushi\CounterR5Report;

define('FORM_COUNTER', 'counter');

Expand Down Expand Up @@ -54,12 +53,6 @@ public function __construct(string $action, array $locales)
public function getConfig()
{
$config = parent::getConfig();

$earliestDate = CounterR5Report::getEarliestDate();
$lastDate = CounterR5Report::getLastDate();

$config['earliestDate'] = $earliestDate;
$config['lastDate'] = $lastDate;
$config['reportFields'] = array_map(function ($reportFields) {
return array_map(function ($reportField) {
$field = $this->getFieldConfig($reportField);
Expand Down
6 changes: 6 additions & 0 deletions classes/components/listPanels/PKPCounterReportsListPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
namespace PKP\components\listPanels;

use APP\components\forms\counter\CounterReportForm;
use PKP\sushi\CounterR5Report;

class PKPCounterReportsListPanel extends ListPanel
{
Expand All @@ -34,12 +35,17 @@ class PKPCounterReportsListPanel extends ListPanel
public function getConfig(): array
{
$config = parent::getConfig();

$earliestDate = CounterR5Report::getEarliestDate();
$lastDate = CounterR5Report::getLastDate();

$config = array_merge(
$config,
[
'apiUrl' => $this->apiUrl,
'editCounterReportLabel' => __('manager.statistics.counterR5Report.settings'),
'form' => $this->form->getConfig(),
'usagePossible' => $lastDate > $earliestDate,
]
);
return $config;
Expand Down
3 changes: 3 additions & 0 deletions locale/en/manager.po
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,9 @@ msgstr "Counter R5 Reports"
msgid "manager.statistics.counterR5Reports.description"
msgstr "See <a href=\"https://cop5.projectcounter.org/en/5.0.3/04-reports/index.html\" target=\"_new\">COUNTER 5.0.3 documentation</a> for more information about each report."

msgid "manager.statistics.counterR5Reports.usageNotPossible"
msgstr "There are no COUNTER R5 usage statistics available yet."

msgid "manager.statistics.counterR5Report.settings"
msgstr "Report Settings"

Expand Down
5 changes: 5 additions & 0 deletions pages/stats/PKPStatsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use PKP\security\authorization\ContextAccessPolicy;
use PKP\security\Role;
use PKP\statistics\PKPStatisticsHelper;
use PKP\sushi\CounterR5Report;

class PKPStatsHandler extends Handler
{
Expand Down Expand Up @@ -458,13 +459,17 @@ public function counterR5(array $args, Request $request): void
]
);

$earliestDate = CounterR5Report::getEarliestDate();
$lastDate = CounterR5Report::getLastDate();

$templateMgr->setState([
'components' => [
$counterReportsListPanel->id => $counterReportsListPanel->getConfig(),
],
]);
$templateMgr->assign([
'pageComponent' => 'CounterReportsPage',
'usagePossible' => $lastDate > $earliestDate,
]);
$templateMgr->display('stats/counterReports.tpl');
}
Expand Down
3 changes: 3 additions & 0 deletions templates/stats/counterReports.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
{translate key="manager.statistics.counterR5Reports"}
</h1>
<p>{translate key="manager.statistics.counterR5Reports.description"}</p>
{if !$usagePossible}
<notification class="pkpNotification--backendPage__header" type="warning">{translate key="manager.statistics.counterR5Reports.usageNotPossible"}</notification>
{/if}
<panel>
<panel-section>
<counter-reports-list-panel
Expand Down

0 comments on commit c1267f7

Please sign in to comment.