Skip to content

Commit

Permalink
Merge pull request #81 from slub/64-repeat-dashboard
Browse files Browse the repository at this point in the history
64 repeat dashboard
  • Loading branch information
dikastes authored Oct 15, 2024
2 parents 4f2d67b + cc0e311 commit 94bcb2c
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 103 deletions.
1 change: 1 addition & 0 deletions Classes/Controller/PersonController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function showAction(GndPerson $person)
pluck('published_subitems')->
flatten(1)->
pluck('prints_by_date')->
flatten(1)->
filter()->
count();

Expand Down
1 change: 1 addition & 0 deletions Classes/Controller/PublishedItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function showAction(PublishedItem $publishedItem)
$hasPrints = $document->
get('published_subitems')->
pluck('prints_by_date')->
flatten(1)->
count();

$visualizationCall = $this->getJsCall($document, $this->publishers, $publishedItem->getMvdbId());
Expand Down
1 change: 1 addition & 0 deletions Classes/Controller/WorkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function showAction(GndWork $work)
pluck('published_subitems')->
flatten(1)->
pluck('prints_by_date')->
flatten(1)->
filter()->
count();
$publishedItems = $this->publishedItemRepository->findByContainedWorks($work->getUid());
Expand Down
10 changes: 9 additions & 1 deletion Resources/Private/Templates/Person/Show.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,17 @@ <h3>

<f:if condition="{hasPrints}">
<f:then>
<f:if condition="{hasPrints}>1">
<div class="{dashboardTarget}"></div>
</f:if>
<div id="{graphTarget}"></div>
<div id="{dashboardTarget}"></div>
<f:if condition="{hasPrints}>1">
<div class="{dashboardTarget}"></div>
</f:if>
<div id="{tableTarget}"> </div>
<f:if condition="{hasPrints}>1">
<div class="{dashboardTarget}"></div>
</f:if>
{visualizationCall->f:format.raw()}
</f:then>
<f:else>
Expand Down
14 changes: 11 additions & 3 deletions Resources/Private/Templates/PublishedItem/Show.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,17 @@ <h2>
<p> {publishedItem.publicComment} </p>
<f:if condition="{hasPrints}">
<f:then>
<div id="{graphTarget}"></div>
<div id="{dashboardTarget}"></div>
<div id="{tableTarget}"> </div>
<f:if condition="{hasPrints}>1">
<div class="{dashboardTarget}"></div>
</f:if>
<div id="{graphTarget}"></div>
<f:if condition="{hasPrints}>1">
<div class="{dashboardTarget}"></div>
</f:if>
<div id="{tableTarget}"> </div>
<f:if condition="{hasPrints}>1">
<div class="{dashboardTarget}"></div>
</f:if>
{visualizationCall->f:format.raw()}
</f:then>
<f:else>
Expand Down
10 changes: 9 additions & 1 deletion Resources/Private/Templates/Work/Show.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,17 @@ <h3>

<f:if condition="{hasPrints}">
<f:then>
<f:if condition="{hasPrints}>1">
<div class="{dashboardTarget}"></div>
</f:if>
<div id="{graphTarget}"> </div>
<div id="{dashboardTarget}"></div>
<f:if condition="{hasPrints}>1">
<div class="{dashboardTarget}"></div>
</f:if>
<div id="{tableTarget}"> </div>
<f:if condition="{hasPrints}>1">
<div class="{dashboardTarget}"></div>
</f:if>
{visualizationCall->f:format.raw()}
</f:then>
<f:else>
Expand Down
193 changes: 95 additions & 98 deletions Resources/Public/JavaScript/DashboardController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,70 @@ const tx_publisherdb_dashboardExcludedItem = 'excluded-item';
const tx_publisherdb_dashboardExcludedYear = 'excluded-year';
const tx_publisherdb_dashboardPublisher = 'publisher';

const prefix = 'dashboard';
const movingAverages = `${prefix}-moving-averages`;
const setMovingAverage = `${prefix}-set-moving-average`;
const setCumulative = `${prefix}-set-cumulative`;
const setPerYear = `${prefix}-set-per-year`;
const setByDate = `${prefix}-set-by-date`;
const btnClassList = 'primary button hollow';

const tx_publisherdb_dashboardController = {

set target(target) {
this._target = target;
this.render();
},

render() {
const createIncludeButton = type => id => `<a id="${id}" class="include-${type} m-1"> + </a>`;
const createYearIncludeButton = createIncludeButton('year');
const createElementIncludeButton = createIncludeButton('element');

const target = d3.select(`#${this._target}`);
draw(targetElement) {
const target = d3.select(targetElement);
target.html('');

const movingAverages = target.append('div')
.attr('class', 'display')
movingAverages.append('h3')
.html('Anzeige');
const movingAveragesList = movingAverages.append('div')
.attr('class', 'tiny button-group');
tx_publisherdb_visualizationStatus.movingAverages.forEach( ma => {
movingAveragesList
.append('a')
.attr('data', ma)
.attr('type', setMovingAverage)
.attr('class', btnClassList)
.html(`gleitender MW ${ma}`);
});
movingAveragesList.append('a')
.attr('type', setCumulative)
.attr('class', btnClassList)
.html('kumulativ');
movingAveragesList.append('a')
.attr('type', setPerYear)
.attr('class', btnClassList)
.html('pro Jahr');
movingAveragesList.append('a')
.attr('type', setByDate)
.attr('class', btnClassList)
.html('nach Datum');

if (!tx_publisherdb_visualizationStatus.isPublishedItem) {
const publishers = target.append('div')
.attr('class', 'dashboard-publishers');
publishers.append('h3')
.text('Verlage');
const publisherList = publishers.append('div')
.attr('class', 'tiny button-group');
publisherList.selectAll(`a.${tx_publisherdb_dashboardPublisher}`)
.data(tx_publisherdb_visualizationStatus.publishers)
.join('a')
.attr('class', `${tx_publisherdb_dashboardPublisher} primary button hollow include-year`)
.attr('class', d => d.id)
.html(d => d.id)
.attr('title', d => d.name);
}

const excludedItems = target.append('div')
.attr('id', 'dashboard-excluded-items');
.attr('class', 'dashboard-excluded-items');
excludedItems.append('h3')
.text('Ausgeschlossene Verlagsartikel');
if (tx_publisherdb_visualizationStatus.excludedElements.length) {
Expand All @@ -39,54 +86,16 @@ const tx_publisherdb_dashboardController = {
.text('Sie können in der tabellarischen Ansicht auf das "X" klicken, um einzelne Verlagsteilartikel aus den Ansichten auszuschließen.')
}

/*
const excludedYears = target.append('div')
.attr('id', 'dashboard-excluded-years');
excludedYears.append('h3')
.text('Ausgeschlossene Jahre');
if (tx_publisherdb_visualizationStatus.excludedYears.length) {
const excludedYearList = excludedYears.append('div')
.attr('class', 'tiny button-group');
excludedYearList.selectAll(`a.${tx_publisherdb_dashboardExcludedYear}`)
.data(tx_publisherdb_visualizationStatus.excludedYears.sort())
.join('a')
.attr('class', `${tx_publisherdb_dashboardExcludedYear} primary button hollow include-year`)
.attr('id', d => d)
.html(d => d);
}
*/
},

const movingAverages = target.append('div')
.attr('id', 'dashboard-moving-averages')
movingAverages.append('h3')
.html('Anzeige');
const movingAveragesList = movingAverages.append('div')
.attr('class', 'tiny button-group');
tx_publisherdb_visualizationStatus.movingAverages.forEach( ma => {
movingAveragesList
.append('a')
.attr('id', `dashboard-set-moving-average-${ma}`)
.attr('class', 'dashboard-set-moving-average primary button hollow')
.html(`gleitender MW ${ma}`);
});
movingAveragesList.append('a')
.attr('id', 'dashboard-set-cumulative')
.attr('class', 'primary button hollow dashboard-set-cumulativity')
.html('kumulativ');
/*
movingAveragesList.append('a')
.attr('id', 'dashboard-set-absolute')
.attr('class', 'primary button hollow dashboard-set-cumulativity')
.html('absolut');
*/
movingAveragesList.append('a')
.attr('id', 'dashboard-set-per-year')
.attr('class', 'primary button hollow dashboard-set-granularity')
.html('pro Jahr');
movingAveragesList.append('a')
.attr('id', 'dashboard-set-by-date')
.attr('class', 'primary button hollow dashboard-set-granularity')
.html('nach Datum');
render() {
const createIncludeButton = type => id => `<a class="${id}" class="include-${type} m-1"> + </a>`;
const createYearIncludeButton = createIncludeButton('year');
const createElementIncludeButton = createIncludeButton('element');
const displayBtnList = `a[type=${setMovingAverage}], a[type=${setCumulative}], a[type=${setPerYear}], a[type=${setByDate}]`;

const target = d3.selectAll(`.${this._target}`);
target.nodes().forEach(target => this.draw(target));

$('a.include-year').click( e => {
const year = e.currentTarget.id;
Expand All @@ -98,62 +107,50 @@ const tx_publisherdb_dashboardController = {
tx_publisherdb_visualizationStatus.includeElement(element);
});

$('a.dashboard-set-moving-average').click ( e => {
const ma = e.currentTarget.id.replace('dashboard-set-moving-average-', '');
$(`a[type=${setMovingAverage}]`).click ( e => {
const ma = e.currentTarget.attributes.data.nodeValue;
tx_publisherdb_visualizationStatus.config = {
granularity: tx_publisherdb_granularity.PER_YEAR,
cumulativity: tx_publisherdb_cumulativity.MOVING_AVERAGE,
movingAverage: ma
};

$(displayBtnList).addClass('hollow');
$(`a[type=${setMovingAverage}][data=${ma}]`).removeClass('hollow');
});

$('a.dashboard-set-cumulativity').click ( e => {
if (e.currentTarget.id == 'dashboard-set-cumulative') {
tx_publisherdb_visualizationStatus.config = {
granularity: tx_publisherdb_granularity.PER_YEAR,
cumulativity: tx_publisherdb_cumulativity.CUMULATIVE,
movingAverage: -1
}
} else {
tx_publisherdb_visualizationStatus.config = {
granularity: tx_publisherdb_visualizationStatus.config.granularity,
cumulativity: tx_publisherdb_cumulativity.ABSOLUTE,
movingAverage: -1
}
$(`a[type=${setCumulative}]`).click ( e => {
tx_publisherdb_visualizationStatus.config = {
granularity: tx_publisherdb_granularity.PER_YEAR,
cumulativity: tx_publisherdb_cumulativity.CUMULATIVE,
movingAverage: -1
}

$(displayBtnList).addClass('hollow');
$(`a[type=${setCumulative}]`).removeClass('hollow');
});

$('a.dashboard-set-granularity').click ( e => {
if (e.currentTarget.id == 'dashboard-set-per-year') {
tx_publisherdb_visualizationStatus.config = {
cumulativity: tx_publisherdb_cumulativity.ABSOLUTE,
granularity: tx_publisherdb_granularity.PER_YEAR,
movingAverage: -1
}
} else {
tx_publisherdb_visualizationStatus.config = {
cumulativity: tx_publisherdb_cumulativity.ABSOLUTE,
granularity: tx_publisherdb_granularity.BY_DATE,
movingAverage: -1
}
$(`a[type=${setPerYear}]`).click ( e => {
tx_publisherdb_visualizationStatus.config = {
cumulativity: tx_publisherdb_cumulativity.ABSOLUTE,
granularity: tx_publisherdb_granularity.PER_YEAR,
movingAverage: -1
}

$(displayBtnList).addClass('hollow');
$(`a[type=${setPerYear}]`).removeClass('hollow');
});

if (!tx_publisherdb_visualizationStatus.isPublishedItem) {
const publishers = target.append('div')
.attr('id', 'dashboard-publishers');
publishers.append('h3')
.text('Verlage');
const publisherList = publishers.append('div')
.attr('class', 'tiny button-group');
publisherList.selectAll(`a.${tx_publisherdb_dashboardPublisher}`)
.data(tx_publisherdb_visualizationStatus.publishers)
.join('a')
.attr('class', `${tx_publisherdb_dashboardPublisher} primary button hollow include-year`)
.attr('id', d => d.id)
.html(d => d.id)
.attr('title', d => d.name);
}
$(`a[type=${setByDate}]`).click ( e => {
tx_publisherdb_visualizationStatus.config = {
cumulativity: tx_publisherdb_cumulativity.ABSOLUTE,
granularity: tx_publisherdb_granularity.BY_DATE,
movingAverage: -1
}

$(displayBtnList).addClass('hollow');
$(`a[type=${setByDate}]`).removeClass('hollow');
});

$(`a.${tx_publisherdb_dashboardPublisher}`).click ( e => {
tx_publisherdb_visualizationStatus.currentPublisher = e.currentTarget.id;
Expand Down

0 comments on commit 94bcb2c

Please sign in to comment.