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

[FINNA-1454] AIPA: Record page style, display and text changes #2806

Merged
merged 13 commits into from
Dec 13, 2023
1 change: 1 addition & 0 deletions local/languages/finna/Aipa/fi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ learningAreas = "Oppimisen alueet"
lowerSecondarySchool = "Yläkoulu"
lrmi_assignment_ideas = "Tehtäväideat"
lrmi_objectives = "Tavoite ja sisältöalue"
More Information = "Lisätietoa"
primarySchool = "Alakoulu"
questions_feedback = "Kysymyksiä tai palautetta aineistopaketista?"
rights_coverage_text_and_materials = "Käyttöoikeus koskee paketin tekstisisältöjä ja sen aineistoja."
Expand Down
1 change: 1 addition & 0 deletions local/languages/finna/Aipa/sv.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ learningAreas = "Lärområden"
lowerSecondarySchool = "Högstadiet"
lrmi_assignment_ideas = "Uppgiftsidéer"
lrmi_objectives = "Mål och innehållsområden"
More Information = "Mer information"
primarySchool = "Lågstadiet"
questions_feedback = "Frågor eller respons angående materialetpaketet?"
studyContents = "Innehållsområden"
Expand Down
43 changes: 25 additions & 18 deletions module/Finna/src/Finna/View/Helper/Root/Aipa.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,8 @@ public function renderEducationalLevelsAndSubjects(array $educationalData): stri
$component = $this->getView()->plugin('component');
$langcode = $this->view->layout()->userLang;

// Basic education levels are mapped to primary school and lower secondary
// school levels.
$levelCodeValues = EducationalData::getMappedLevelCodeValues(
$educationalData[EducationalData::EDUCATIONAL_LEVELS] ?? []
);

usort($levelCodeValues, [$this, 'sortEducationalLevels']);

$html = '';
foreach ($levelCodeValues as $levelCodeValue) {
foreach ($this->getEducationalLevelCodeValues($educationalData) as $levelCodeValue) {
$levelData = EducationalData::getEducationalLevelData($levelCodeValue, $educationalData);
if (empty($levelData)) {
continue;
Expand Down Expand Up @@ -205,17 +197,9 @@ public function renderStudyContentsAndObjectives(array $educationalData): string
$transEsc = $this->getView()->plugin('transEsc');
$langcode = $this->view->layout()->userLang;

// Basic education levels are mapped to primary school and lower secondary
// school levels.
$levelCodeValues = EducationalData::getMappedLevelCodeValues(
$educationalData[EducationalData::EDUCATIONAL_LEVELS] ?? []
);

usort($levelCodeValues, [$this, 'sortEducationalLevels']);

$html = '';
$levelsHtml = [];
foreach ($levelCodeValues as $levelCodeValue) {
foreach ($this->getEducationalLevelCodeValues($educationalData) as $levelCodeValue) {
$levelData = EducationalData::getEducationalLevelData($levelCodeValue, $educationalData);
if (empty($levelData)) {
continue;
Expand Down Expand Up @@ -325,6 +309,29 @@ public function renderStudyContentsAndObjectives(array $educationalData): string
return $html;
}

/**
* Get processed educational level code values.
*
* @param array $educationalData Educational data from record driver
*
* @return array
*/
protected function getEducationalLevelCodeValues(array $educationalData): array
{
// Basic education levels are mapped to primary school and lower secondary
// school levels.
$levelCodeValues = EducationalData::getMappedLevelCodeValues(
$educationalData[EducationalData::EDUCATIONAL_LEVELS] ?? []
);

// Remove basic education root level, data should be entered at lower levels.
unset($levelCodeValues[EducationalLevelInterface::BASIC_EDUCATION]);

usort($levelCodeValues, [$this, 'sortEducationalLevels']);

return $levelCodeValues;
}

/**
* Sort educational levels.
*
Expand Down
16 changes: 16 additions & 0 deletions module/Finna/src/Finna/View/Helper/Root/RecordDataFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,21 @@ public function filterForwardFields($coreFields)
return $this->filterFields($coreFields, $include);
}

/**
* Filter unnecessary fields from AIPA records.
*
* @param array $coreFields data to filter.
*
* @return array
*/
public function filterAipaFields($coreFields)
{
$aipaFields = $this->filterQDCFields($coreFields);
unset($aipaFields['Language']);
unset($aipaFields['Subjects']);
return $aipaFields;
}

/**
* Get default configuration.
*
Expand All @@ -575,6 +590,7 @@ public function getDefaults($key = 'core'): array
}
switch ($type) {
case 'aipa':
return $this->filterAipaFields($defaults);
case 'dc':
case 'qdc':
return $this->filterQDCFields($defaults);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
flex-wrap: wrap;
gap: 5px;
& dt {
font-weight: normal;
font-weight: bold;
padding: 5px 10px 5px 0;
&:not(:only-child):after {
content: ':';
Expand All @@ -14,6 +14,5 @@
border-radius: .5em;
background-color: #f4f4f4;
padding: 5px 10px;
text-transform: lowercase;
}
}
47 changes: 27 additions & 20 deletions themes/finna2/less/finna/record.less
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,28 @@ finna-model-viewer .object-editor {
}

.record.full-width-layout {
.record-accordions.record-tabs {
width: 100%;
padding-right: 0;
float: none;
}
}

.record-format-aipa {
.media-body:not(.record-container .media-body) {
display: block;
width: auto;
}
.recordFormat {
display: block;
margin-bottom: 21px;
padding-bottom: .1em;
}
.access-rights {
margin-bottom: 21px;
}
.record-core-metadata,
.finna-tag-list,
.summary,
.record-toc,
.encapsulated-records {
Expand All @@ -1335,26 +1356,6 @@ finna-model-viewer .object-editor {
margin-bottom: 21px;
padding-bottom: .1em;
}
.record-accordions.record-tabs {
width: 100%;
padding-right: 0;
float: none;
}
}

.record-format-aipa {
& > .record-main > div > .media-body {
display: block;
width: auto;
}
.recordFormat {
display: block;
margin-bottom: 21px;
padding-bottom: .1em;
}
.access-rights {
margin-bottom: 21px;
}
h3.panel-title {
font-size: 16px;
margin: 0;
Expand Down Expand Up @@ -1397,3 +1398,9 @@ finna-model-viewer .object-editor {
margin-bottom: 15px;
}
}

.encapsulated-record.record-format-lrmi {
.record-core-metadata + .finna-panel {
margin-top: 21px;
}
}
2 changes: 1 addition & 1 deletion themes/finna2/templates/RecordDriver/AipaLrmi/core.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<div class="record-core-metadata">
<?php if ($showData && ($results = $this->driver->getNonPresenterAuthors())): ?>
<div class="truncate-field recordAuthors">
<strong><?= $this->transEsc('Curated By') ?>:</strong>
<strong><?= $this->transEsc('Aipa::Curated By') ?>:</strong>
<span>
<?php foreach ($results as $index => $author): ?>
<?=($index > 0 ? '; ' : '')?><a href="<?=$this->record($this->driver)->getLink('author', $author['name'])?>"><?=$this->escapeHtml($author['name'])?><?php if (!empty($author['affiliation'])): ?>, <?= $this->escapeHtml($author['affiliation']) ?><?php endif;?></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@
</div>
</div>
<?php else: ?>
<?php
// Add curated record variable and replace driver with encapsulated record.
// Then render the same template using the encapsulated record.
$this->curatedRecord = $this->driver;
$this->driver = $record;
<?=
// Render the same template using the encapsulated record.
// renderTemplate() is used to set temporary global variables.
$this->record($record)->renderTemplate(
'result-condensed.phtml',
[
'driver' => $record,
'curatedRecord' => $this->driver,
'listNoteTitle' => $this->translate('Aipa::More Information'),
]
)
?>
<?= $this->record($this->driver)->getSearchResult('condensed', $this->results) ?>
<?php endif; ?>
<?php endif; ?>
<!-- END of: finna - RecordDriver/CuratedRecord/result-condensed.phtml -->
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@
</div>
</div>
<?php else: ?>
<?php
// Add curated record variable and replace driver with encapsulated record.
// Then render the same template using the encapsulated record.
$this->curatedRecord = $this->driver;
$this->driver = $record;
<?=
// Render the same template using the encapsulated record.
// renderTemplate() is used to set temporary global variables.
$this->record($record)->renderTemplate(
'result-grid.phtml',
[
'driver' => $record,
'curatedRecord' => $this->driver,
'listNoteTitle' => $this->translate('Aipa::More Information'),
]
)
?>
<?= $this->record($this->driver)->getSearchResult('grid', $this->results) ?>
<?php endif; ?>
<?php endif; ?>
<!-- END of: finna - RecordDriver/CuratedRecord/result-grid.phtml -->
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@
</div>
</div>
<?php else: ?>
<?php
// Add curated record variable and replace driver with encapsulated record.
// Then render the same template using the encapsulated record.
$this->curatedRecord = $this->driver;
$this->driver = $record;
<?=
// Render the same template using the encapsulated record.
// renderTemplate() is used to set temporary global variables.
$this->record($record)->renderTemplate(
'result-list.phtml',
[
'driver' => $record,
'curatedRecord' => $this->driver,
'listNoteTitle' => $this->translate('Aipa::More Information'),
]
)
?>
<?= $this->record($this->driver)->getSearchResult('list', $this->results) ?>
<?php endif; ?>
<?php endif; ?>
<!-- END of: finna - RecordDriver/CuratedRecord/result-list.phtml -->
27 changes: 0 additions & 27 deletions themes/finna2/templates/RecordDriver/SolrAipa/core-fields.phtml

This file was deleted.

2 changes: 1 addition & 1 deletion themes/finna2/templates/RecordDriver/SolrAipa/core.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<?php ob_end_clean(); ?>

<?php $this->metadata()->generateMetatags($this->driver);?>
<div>
<div class="media">
<h1 class="record-title visible-xs"><?=$this->escapeHtml($this->driver->getTitle())?></h1>
<?php if ($thumbnail && $thumbnailAlignment == 'left'): ?>
<?=$thumbnail ?>
Expand Down
8 changes: 4 additions & 4 deletions themes/finna2/templates/list/list-notes.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
$note = $this->markdown()->toHtml($note);
$view = $this->params->getView();

$noteDesc = $this->transEsc('Note');
$noteTitle = $this->escapeHtml($this->listNoteTitle ?? $this->translate('Note'));
?>
<?php if ($view === 'condensed'): ?>
<button class="note-button condensed" aria-hidden="true" title="<?=$noteDesc?>"><?=$this->icon('list-note') ?><?=$noteDesc?><span class="caret"></span></button>
<button class="note-button condensed" aria-hidden="true" title="<?=$noteTitle?>"><?=$this->icon('list-note') ?><?=$noteTitle?><span class="caret"></span></button>
<?php endif; ?>
<div class="<?= in_array($view, ['grid', 'condensed']) ? "note-overlay-$view note-hide" : 'note-overlay-list' ?>">
<div class="notes">
Expand All @@ -29,13 +29,13 @@
<?php endif; ?>
<div class="note-rows">
<?php if ($view === 'list' || $view === 'compact'): ?>
<?=$this->icon('list-note') ?><span><?=$noteDesc?>:</span>
<?=$this->icon('list-note') ?><span><?=$noteTitle?>:</span>
<?php endif; ?>
<?=$note;?>
</div>
</div>
</div>
<?php if ($view === 'grid'): ?>
<button class="note-button" aria-hidden="true" title="<?=$noteDesc?>"><?=$this->icon('list-note') ?><?=$noteDesc?><span class="caret"></span></button>
<button class="note-button" aria-hidden="true" title="<?=$noteTitle?>"><?=$this->icon('list-note') ?><?=$noteTitle?><span class="caret"></span></button>
<?php endif; ?>
<!-- END of: finna - list/list-notes.phtml -->