Skip to content

Commit

Permalink
Merge pull request #63 from dikastes/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dikastes authored Jul 25, 2024
2 parents 576173b + d8fd253 commit 1dab731
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 70 deletions.
6 changes: 5 additions & 1 deletion Resources/Private/Language/de.locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
<source>edited work</source>
<target>bearbeitetes Werk</target>
</trans-unit>
<trans-unit id="mpdbresearch.editedWork">
<trans-unit id="mpdbresearch.noWorkData">
<source>No workdata could be found for this item.</source>
<target>Für diesen Verlagsartikel konnten keine Werkdaten erschlossen werden.</target>
</trans-unit>
Expand All @@ -148,6 +148,10 @@
<source>No economic data could be retrieved for several published items.</source>
<target>Für einige Verlagsartikel konnten keine Wirtschaftsdaten gefunden werden.</target>
</trans-unit>
<trans-unit id="mpdbresearch.typeTooltip">
<source>The type of the published item indicates, whether it is a simple work print, a collection print, a version or something else.</source>
<target>Der Typ des Verlagsartikels gibt an, ob es sich um einen einfachen Werkdruck, einen Sammeldruck, eine Bearbeitung oder etwas anderes handelt.</target>
</trans-unit>
</body>
</file>
</xliff>
12 changes: 12 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@
<trans-unit id="mpdbresearch.noEconomicDataParagraph">
<source>No economic data could be retrieved for several published items.</source>
</trans-unit>
<trans-unit id="mpdbresearch.containedWork">
<source>contained work</source>
</trans-unit>
<trans-unit id="mpdbresearch.containedWorks">
<source>contained works</source>
</trans-unit>
<trans-unit id="mpdbresearch.editedWork">
<source>edited work</source>
</trans-unit>
<trans-unit id="mpdbresearch.typeTooltip">
<source>The type of the published item indicates, whether it is a simple work print, a collection print, a version or something else.</source>
</trans-unit>
</body>
</file>
</xliff>
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Index/IndexPicker.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<li>
<f:variable name="searchconfig">{mpdbpres:setConfig(config:searchconfig,key:'index',value:'')}</f:variable>
<f:link.action action="search" arguments="{config:searchconfig}">
🗙
X
</f:link.action>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Index/PublisherPicker.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<li>
<f:variable name="searchconfig">{mpdbpres:setConfig(config:searchconfig,key:'publisher',value:'')}</f:variable>
<f:link.action action="search" arguments="{config:searchconfig}">
🗙
X
</f:link.action>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Index/SearchSlot.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</f:form.button>
<f:variable name="searchconfig">{mpdbpres:setConfig(config:searchConfig,key:'searchTerm',value:'')}</f:variable>
<f:link.action action="search" arguments="{config:searchconfig}" class="button" id="reset-button">
🗙
X
</f:link.action>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions Resources/Private/Templates/PublishedItem/Show.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ <h1 class="current-item">{publishedItem.title}</h1>
<div class="content">
<h4> {publishedItem.mvdbId} </h4>
<span data-tooltip title="{f:translate(key:'mpdbresearch.typeTooltip')}">
<f:translate key="LLL:EXT:mpdb-core/Resources/Private/Language/locallang_csh_publisheditem:{publishedItem.type}" />
<f:translate key="LLL:EXT:mpdb_core/Resources/Private/Language/locallang_csh_publisheditem.xlf:type.{publishedItem.type}" />
</span>
<table>
<f:if condition="{publishedItem.editor}">
<f:if condition="{publishedItem.editors.0}">
<tr>
<td>
<f:translate key="LLL:EXT:mpdb-core/Resources/Private/Language/locallang_csh_publisheditem:editor" />
<f:translate key="LLL:EXT:mpdb_core/Resources/Private/Language/locallang_csh_publisheditem.xlf:editor" />
</td>
<td>
{publishedItem.editor.name}
{publishedItem.editors.0.name}
<f:if condition="{publishedItem.editor.dateOfBirth}">
<span data-tooltip title="*{publishedItem.editor.dateOfBirth->f:format.date(format:'d.m.Y')}, {publishedItem.editor.placeOfBirth}, &#x271D;{publishedItem.editor.dateOfDeath->f:format.date(format:'d.m.Y')}, {publishedItem.editor.placeOfDeath}">
({publishedItem.editor.dateOfBirth->f:format.date(format:'Y')}&ndash;
Expand Down
10 changes: 8 additions & 2 deletions Resources/Public/JavaScript/GraphController.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ const tx_publisherdb_graphController = {
.domain(d3.extent(tx_publisherdb_visualizationStatus.years))
.range([0, this.timeseriesWidth])
.nice();
this._yearBandScale = d3.scaleBand()
.range([0, this.timeseriesWidth])
.domain(tx_publisherdb_visualizationStatus.years);

this._yearAxis = d3.axisBottom()
.tickFormat(d3.format(' '))
.scale(this._yearScale);
this._yearBandAxis = d3.axisBottom()
.tickFormat(d3.format(' '))
.scale(this._yearBandScale);

},

Expand Down Expand Up @@ -55,7 +61,7 @@ const tx_publisherdb_graphController = {
data: tx_publisherdb_visualizationStatus.summedYearData.map(d => ({year: d.year, quantity: d.total})),
qAxis: qAxis,
qScale: qScale,
tAxis: this._yearAxis,
tAxis: graphType == 'area' ? this._yearAxis : this._yearBandAxis,
tScale: this._yearScale,
margin: margin,
title: '',
Expand All @@ -77,7 +83,7 @@ const tx_publisherdb_graphController = {
target: subitemsTarget,
startY: timeseriesHeight + margin * 2,
width: this.timeseriesWidth,
tAxis: this._yearAxis,
tAxis: graphType == 'area' ? this._yearAxis : this._yearBandAxis,
data: tx_publisherdb_visualizationStatus.summedYearData,
tScale: this._yearScale,
titles: tx_publisherdb_visualizationStatus.subitemIds,
Expand Down
8 changes: 4 additions & 4 deletions Resources/Public/JavaScript/TimeseriesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ class TimeseriesView {

const bandScale = d3.scaleBand()
.range([0, this.width])
.domain(d3.extent(this.data, d => +d.year))
.align(0)
.paddingOuter(.25)
.paddingInner(.5);
.domain(this.data.map(d => d.year))
.align(.5)
.paddingOuter(.1)
.paddingInner(.2);

this.target.append('g')
.attr('transform', `translate(${this.width},0)`)
Expand Down
113 changes: 57 additions & 56 deletions Resources/Public/JavaScript/VisualizationStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ let tx_publisherdb_visualizationStatus = {
this._isPublishedItem = data.published_subitems ? true : false;
this._data = data;

const publishedSubitems = this._data.published_subitems ??
this._data.published_items.flatMap(({id, published_subitems}) => published_subitems);
if (
this._data.published_subitems &&
this._data.published_subitems.length == 1 &&
this._data.published_subitems[0].prints_per_year.length == 1
publishedSubitems.length == 1 &&
publishedSubitems[0].prints_per_year.length == 1
) {
this.singlePrint = true;
this._config.granularity = tx_publisherdb_granularity.BY_DATE;
Expand Down Expand Up @@ -226,6 +227,8 @@ let tx_publisherdb_visualizationStatus = {
},

updateData() {
// unification function
const unify = date => d3.isoParse(`${date}`).getYear() + 1900;
// retrieve published subitems
const publishedSubitems = this.isPublishedItem ? this.data.published_subitems :
this.data.published_items.map(d => d.published_subitems).flat();
Expand All @@ -237,64 +240,62 @@ let tx_publisherdb_visualizationStatus = {
.filter(d => !this.excludedElements.includes(d))
.filter(d => currentPublisherRegex ? currentPublisherRegex.test(d) : true);

if (this._targetData != 'prints_by_date') {
// retrieve per year data including totals for table body
const years = publishedSubitems.map(subitem => {
const targetData = subitem[this.targetData] ?? [];
return targetData.map(print => print.date);
})
.flat();
this.years = d3.range(+d3.min(years), +d3.max(years) + 1)
.filter(year => !this.excludedYears.includes(year));

const yearData = this.years.map(year => ({
year: year,
items: publishedSubitems
.filter(item => !this.excludedElements.includes(item.id))
.filter(item => currentPublisherRegex ? currentPublisherRegex.test(item.id) : true)
.map(prints => {
const targetData = prints[this.targetData] ?? [];
const targetPrint = targetData.filter(print => print.date == year);
return {
id: prints.id,
quantity: targetPrint.length > 0 ? targetPrint[0].quantity : 0
};
}),
}))
.sort(this.sort)
.map(item => ({ year: item.year, items: item.items.map(i => i.quantity) }));

if (this.targetData == 'prints_per_year_cumulative') {
for(let i = 0; i < yearData.length; i++) {
for (let j = 0; j < yearData[i].items.length; j++) {
if (yearData[i].items[j] == 0 && i > 0) {
let runner = i - 1;
while (runner > 0 && yearData[runner].items[j] == 0) {
runner--;
}
yearData[i].items[j] = yearData[runner].items[j];
// retrieve per year data including totals for table body
const years = publishedSubitems.map(subitem => {
const targetData = subitem[this.targetData] ?? [];
return targetData.map(print => unify(print.date));
})
.flat();
this.years = d3.range(+d3.min(years), +d3.max(years) + 1)
.filter(year => !this.excludedYears.includes(year));

const yearData = this.years.map(year => ({
year: year,
items: publishedSubitems
.filter(item => !this.excludedElements.includes(item.id))
.filter(item => currentPublisherRegex ? currentPublisherRegex.test(item.id) : true)
.map(prints => {
const targetData = prints[this.targetData] ?? [];
const targetPrint = targetData.filter(print => unify(print.date) == year);
return {
id: prints.id,
quantity: targetPrint.length > 0 ? targetPrint[0].quantity : 0
};
}),
}))
.sort(this.sort)
.map(item => ({ year: item.year, items: item.items.map(i => i.quantity) }));

if (this.targetData == 'prints_per_year_cumulative') {
for(let i = 0; i < yearData.length; i++) {
for (let j = 0; j < yearData[i].items.length; j++) {
if (yearData[i].items[j] == 0 && i > 0) {
let runner = i - 1;
while (runner > 0 && yearData[runner].items[j] == 0) {
runner--;
}
yearData[i].items[j] = yearData[runner].items[j];
}
}
}

this.summedYearData = yearData.map(({year, items}) => ({
year, items,
total: items.reduce((a, b) => +a + b)
}));

// retrieve per item sums for table footer
this.sums = publishedSubitems.filter(item => !this.excludedElements.includes(item.id))
.filter(item => currentPublisherRegex ? currentPublisherRegex.test(item.id) : true)
.map(
subitem => {
const targetData = subitem[this.targetData] ?? [];
const filteredTargetData = targetData.filter(print => !this.excludedYears.includes(print.date));
const sum = filteredTargetData.length ? filteredTargetData.map(print => print.quantity)
?.reduce( (a, b) => +a + b ) : null
return { id: subitem.id, sum: sum };
});
}

this.summedYearData = yearData.map(({year, items}) => ({
year, items,
total: items.reduce((a, b) => +a + b)
}));

// retrieve per item sums for table footer
this.sums = publishedSubitems.filter(item => !this.excludedElements.includes(item.id))
.filter(item => currentPublisherRegex ? currentPublisherRegex.test(item.id) : true)
.map(
subitem => {
const targetData = subitem[this.targetData] ?? [];
const filteredTargetData = targetData.filter(print => !this.excludedYears.includes(print.date));
const sum = filteredTargetData.length ? filteredTargetData.map(print => print.quantity)
?.reduce( (a, b) => +a + b ) : null
return { id: subitem.id, sum: sum };
});
},

registerView: function (view) {
Expand Down

0 comments on commit 1dab731

Please sign in to comment.