Skip to content

Commit

Permalink
metadata view changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nczirjak-acdh committed Jun 4, 2024
1 parent ecfaa90 commit 81b9a7b
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 128 deletions.
87 changes: 46 additions & 41 deletions js/arche_detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ jQuery(function ($) {
//$('#meta-content-container').hide();
resId = $("#resId").val();
checkDetailCardEvents();

//call basic data
//fetchMetadata();
loadAdditionalData();

// hide the summary div if there is no data inside it
if ($('#av-summary').text().trim().length == 0) {
$('#ad-summary').hide();
}
}


});

Expand All @@ -54,7 +55,7 @@ jQuery(function ($) {
fetchBreadcrumb();
fetchRPR();
fetchPublications();

}

/**
Expand All @@ -63,42 +64,46 @@ jQuery(function ($) {
* @param {type} maxLines
* @returns {String}
*/
function truncateText(text, maxLines) {
var truncated = "";
var lines = text.split("\n");
var currentLine = 0;

for (var i = 0; i < lines.length; i++) {
var words = lines[i].split(" ");
for (var j = 0; j < words.length; j++) {
if (currentLine >= maxLines) {
break;
}
truncated += words[j] + " ";
if (truncated.length > 300) { // Approximately 5 lines assuming average line length
truncated = truncated.trim();
break;
}
}
if (currentLine >= maxLines) {
break;
}
truncated += "\n";
currentLine++;
}

return truncated.trim();
function truncateText(text, wordCount) {
return text.split(" ").splice(0, wordCount).join(" ");
}
function stripHtml(html) {
var temporaryDiv = document.createElement("div");
temporaryDiv.innerHTML = html;
return temporaryDiv.textContent || temporaryDiv.innerText || "";
}

function addButtonToDescriptionText() {
var longText = $('.descriptionTextShort').html();
// Select the first 5 lines
if(longText === undefined) {
if (longText === undefined) {
return;
}
var truncatedText = truncateText(longText, 5);
$('.descriptionTextShort').html(truncatedText + '...' + '<a class="hasdescription-toggle-button" id="descriptionTextShortBtn">' + Drupal.t("Continue reading") + '</a>');

var truncatedText = truncateText(longText, 150);
var strippedLongText = stripHtml(longText).trim();
var strippedTruncatedText = stripHtml(truncatedText).trim();

if (strippedLongText !== strippedTruncatedText) {
$('.descriptionTextShort').html(truncatedText + '...' + '<a class="hasdescription-toggle-button" id="descriptionTextShortBtn">' + Drupal.t("Continue reading") + '</a>');
}
}

function redrawTabs() {
console.log("redraw tab");
// Check if there is an active tab
if ($('#arche-detail-tabs .nav-item .nav-link.active').length === 0) {
console.log("there is no active tab");
// Activate the first visible tab
var firstVisibleTab = $('#arche-detail-tabs .nav-item .nav-link:visible').first();
firstVisibleTab.addClass('active');
var firstVisibleTabId = firstVisibleTab.attr('href');
$(firstVisibleTabId).addClass('show active');
}
}

function hideEmptyTabs(tab) {
$(tab).hide();
$(tab+'-content').hide();
redrawTabs();
}

/// hasDescription button ///
Expand Down Expand Up @@ -278,11 +283,7 @@ jQuery(function ($) {
}
}
});

}



}


Expand Down Expand Up @@ -310,6 +311,7 @@ jQuery(function ($) {
console.log('response error');
console.log(error);
//$('.child-elements-div').hide();
hideEmptyTabs('#associated-publications-tab');
return;
}
console.log('response: ');
Expand All @@ -320,6 +322,7 @@ jQuery(function ($) {
console.log('error');
console.log(error);
$('.publications-elements-div').hide();
hideEmptyTabs('#associated-publications-tab');
}
},
'columns': [
Expand Down Expand Up @@ -364,6 +367,7 @@ jQuery(function ($) {
if (response === undefined) {
console.log('response error');
console.log(error);
hideEmptyTabs('#associated-coll-res-tab');
//$('.child-elements-div').hide();
return;
}
Expand All @@ -374,6 +378,7 @@ jQuery(function ($) {
//$(".loader-versions-div").hide();
console.log('error');
console.log(error);
hideEmptyTabs('#associated-coll-res-tab');
$('.rcr-elements-div').hide();
}
},
Expand Down Expand Up @@ -607,7 +612,7 @@ jQuery(function ($) {

}



function showType() {
if (resObj.getType()) {
Expand Down Expand Up @@ -747,10 +752,10 @@ jQuery(function ($) {
*/
function showCiteBlock() {
var url = $('#biblaTexUrl').val();
console.log("BIBLATEX: "+ url);
console.log("BIBLATEX: " + url);
if (url) {
//url = "https://arche-biblatex.acdh.oeaw.ac.at/?id=https://arche-dev.acdh-dev.oeaw.ac.at/api/214536&lang=en";
$.get(url+'&lang='+drupalSettings.arche_core_gui.gui_lang).done(function (data) {
$.get(url + '&lang=' + drupalSettings.arche_core_gui.gui_lang).done(function (data) {
$('#cite-div').removeClass('hidden');
//$('#cite-content-div').addClass('show');
//$('#cite-content-div').removeClass('hidden');
Expand Down
2 changes: 1 addition & 1 deletion src/Object/ResourceCoreObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ public function getLicenseData(): array {
foreach ($this->properties[$k] as $val) {
if (isset($val['value'])) {
$obj = [];
if (isset($val['id'])) {
if (isset($val['id']) && (int)$this->repoid !== (int)$val['id']) {
$obj['id'] = $val['id'];
}
$obj['value'] = $val['value'];
Expand Down
146 changes: 83 additions & 63 deletions templates/arche-detail.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -133,69 +133,89 @@
</div>
{% endif %}

<!-- Child elements -->
<div class="row basic-inside-content-div child-elements-div">
<div class="col-lg-12 ">
<h5>{{ "Collection Content"|trans }}</h5>
</div>
<div class="col-lg-12 child-tree-div">
<div id="child-tree" class="tree-view-container"></div>
</div>

<!--
<div class="col-lg-12 ">
<div class="basic-inside-content-div" id="childDtDiv">
<table class="child-table table row-border" cellspacing="0" width="100%" id='childDT'>
<div style="font-size: 14px; font-weight: bold;">
<label>{{ "Order the result by"|trans }}:</label>
<select name="sortBy" id="sortBy" class="form-control form-control-sm">
<option value="1-0">{{ "Title (ASC)"|trans }}</option>
<option value="1-1">{{ "Title (DESC)"|trans }}</option>
</select>
</div>
<br>

<tbody>
</tbody>
</table>
<ul class="nav nav-tabs" id="arche-detail-tabs">
<li class="nav-item" id="associated-publications-tab">
<a class="nav-link active" data-bs-toggle="tab" href="#associated-publications-tab-content">{{ "Associated Publications"|trans }}</a>
</li>
<li class="nav-item" id="associated-coll-res-tab">
<a class="nav-link" data-bs-toggle="tab" href="#associated-coll-res-tab-content">{{ "Associated Collections and Resources"|trans }}</a>
</li>
<li class="nav-item" id="collection-content-tab">
<a class="nav-link" data-bs-toggle="tab" href="#collection-content-tab-content">{{ "Collection Content"|trans }}</a>
</li>
</ul>

<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane container active" id="associated-publications-tab-content">
<div class="row basic-inside-content-div publications-elements-div">

<div class="col-lg-12 publications-table-div">
<table class="publications-table table row-border" cellspacing="0" width="100%" id='publicationsDT'>
<thead>
<tr>
<th>{{ "Citation"|trans }}</th>
<th>{{ "Relation Type"|trans }}</th>
</tr>
</thead>
</table>
</div>
</div>
</div>-->
</div>

<div class="row basic-inside-content-div rcr-elements-div">
<div class="col-lg-12 ">
<h5>{{ "Associated Collections and Resources"|trans }}</h5>
</div>
<div class="col-lg-12 rcr-table-div">
<table class="rcr-table table row-border" cellspacing="0" width="100%" id='rcrDT'>
<thead>
<tr>
<th>{{ "Title"|trans }}</th>
<th>{{ "Relation type"|trans }}</th>
<th>{{ "Type"|trans }}</th>
</tr>
</thead>
</table>
</div>
</div>

<div class="row basic-inside-content-div publications-elements-div">
<div class="col-lg-12 ">
<h5>{{ "Associated Publications"|trans }}</h5>
<div class="tab-pane container fade" id="associated-coll-res-tab-content">
<div class="row basic-inside-content-div rcr-elements-div">
<div class="col-lg-12 ">

</div>
<div class="col-lg-12 rcr-table-div">
<table class="rcr-table table row-border" cellspacing="0" width="100%" id='rcrDT'>
<thead>
<tr>
<th>{{ "Title"|trans }}</th>
<th>{{ "Relation type"|trans }}</th>
<th>{{ "Type"|trans }}</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
<div class="col-lg-12 publications-table-div">
<table class="publications-table table row-border" cellspacing="0" width="100%" id='publicationsDT'>
<thead>
<tr>
<th>{{ "Citation"|trans }}</th>
<th>{{ "Relation Type"|trans }}</th>
</tr>
</thead>
</table>

<div class="tab-pane container fade" id="collection-content-tab-content">
<!-- Collection Contents -->
<div class="row basic-inside-content-div child-elements-div">
<div class="col-lg-12 child-tree-div">
<div id="child-tree" class="tree-view-container"></div>
</div>

<!--
<div class="col-lg-12 ">
<div class="basic-inside-content-div" id="childDtDiv">
<table class="child-table table row-border" cellspacing="0" width="100%" id='childDT'>
<div style="font-size: 14px; font-weight: bold;">
<label>{{ "Order the result by"|trans }}:</label>
<select name="sortBy" id="sortBy" class="form-control form-control-sm">
<option value="1-0">{{ "Title (ASC)"|trans }}</option>
<option value="1-1">{{ "Title (DESC)"|trans }}</option>
</select>
</div>
<br>
<tbody>
</tbody>
</table>
</div>
</div>-->
</div>

</div>

</div>

</div>
</div>

Expand All @@ -209,7 +229,7 @@
{% if data.isTitleImage() %}
{{ include(arche_core_gui_path ~ '/templates/blocks/titleimage-block.html.twig', {'data': data.getTitleImageUrl() } ) }}
{% endif %}

{% if data.getMapType()|lower == 'polygon' %}
{{ include(arche_core_gui_path ~ '/templates/blocks/map-card-block.html.twig', {'data': data.getPolygon(), 'type': 'polygon' } ) }}
{% elseif data.getMapType()|lower == 'multipolygon' %}
Expand All @@ -218,7 +238,7 @@
{{ include(arche_core_gui_path ~ '/templates/blocks/map-card-block.html.twig', {'data': data.getCoordinates(), 'type': 'coordinates' } ) }}
{% endif %}


{% if data.getPidOrAcdhIdentifier() %}
{{ include(arche_core_gui_path ~ '/templates/blocks/pid-card-block.html.twig', {'data': data.getPidOrAcdhIdentifier() } ) }}
{% endif %}
Expand All @@ -230,30 +250,30 @@
{% if data.getCreditsData()|length > 0 %}
{{ include(arche_core_gui_path ~ '/templates/blocks/credits-card-block.html.twig', {'data': data.getCreditsData() } ) }}
{% endif %}

{% if data %}
{{ include(arche_core_gui_path ~ '/templates/blocks/download-card-block.html.twig', {'data': data } ) }}
{% endif %}

{% if data %}
{{ include(arche_core_gui_path ~ '/templates/blocks/view-share-card-block.html.twig', {'data': data } ) }}

{{ include(arche_core_gui_path ~ '/templates/blocks/view-share-card-block.html.twig', {'data': data } ) }}

{% endif %}

{% if data.hasVersion %}
{{ include(arche_core_gui_path ~ '/templates/blocks/versions-card-block.html.twig', {'data': data } ) }}
{% endif %}
<!-- TOP COLLECTION / COLLECTION -->

<!-- TOP COLLECTION / COLLECTION -->
{% if data.getAcdhType()|lower == 'topcollection' or data.getAcdhType()|lower == 'collection' %}
{% if data.getCollectionTechnicalData()|length > 0 %}
{{ include(arche_core_gui_path ~ '/templates/blocks/collection-technical-card-block.html.twig', {'data': data.getCollectionTechnicalData() } ) }}
{% endif %}
{% endif %}

<!-- RESOURCE / METADATA -->
{% if data.getAcdhType()|lower == 'resource' or data.getAcdhType()|lower == 'metadata' %}
{% if data.getAcdhType()|lower == 'resource' or data.getAcdhType()|lower == 'metadata' %}
{% if data.getResMetaTechnicalData()|length > 0 %}
{{ include(arche_core_gui_path ~ '/templates/blocks/res-meta-technical-card-block.html.twig', {'data': data.getResMetaTechnicalData() } ) }}
{% endif %}
Expand Down
1 change: 1 addition & 0 deletions templates/blocks/licenses-card-block.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</div>
<div id="licensesBody" class="collapse show">
<div class="card-body meta-sidebar flex-column">
{{ resId }}
{% for key, value in obj %}
<div>
<b>{{ key|trans }}:</b></br>
Expand Down
Loading

0 comments on commit 81b9a7b

Please sign in to comment.