Skip to content

Commit

Permalink
conclusions additional popovers
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrFr committed Dec 3, 2019
1 parent d3a02cd commit 0da785c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 23 deletions.
35 changes: 22 additions & 13 deletions repair/js/views/conclusions/flow-targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function(_, BaseView, GDSECollection, Muuri){

var indicatorColumns = [];
this.indicators.forEach(function(indicator){
indicatorColumns.push(indicator.id)
indicatorColumns.push(indicator)
var th = document.createElement('th');
th.innerHTML = indicator.get('name');
header.appendChild(th);
Expand All @@ -109,18 +109,21 @@ function(_, BaseView, GDSECollection, Muuri){

this.aims.forEach(function(aim){
var row = table.insertRow(-1),
desc = aim.get('description') || '';
var panelItem = _this.panelItem(aim.get('text'), {
popoverText: desc.replace(/\n/g, "<br/>")
desc = aim.get('description') || '',
title = aim.get('text');
var panelItem = _this.panelItem(title, {
popoverText: '<b>' + title + '</b><br>' + desc.replace(/\n/g, "<br/>"),
})
panelItem.style.maxWidth = '500px';
row.insertCell(0).appendChild(panelItem);
var indicatorCount = _this.indicatorCountPerAim[aim.id];
indicatorColumns.forEach(function(indicatorId){
var count = indicatorCount[indicatorId],
indicatorColumns.forEach(function(indicator){
var count = indicatorCount[indicator.id],
cell = row.insertCell(-1);
if (count){
var item = _this.panelItem(count + ' x');
var item = _this.panelItem(count + ' x', {
popoverText: '<b>' + indicator.get('name') + '</b> ' + gettext('used') + ' ' + count + ' x ' + 'in' + ' <b>' + aim.get('text') + '</b>'
});
item.style.backgroundImage = 'none';
item.style.width = '50px';
cell.appendChild(item);
Expand All @@ -145,7 +148,7 @@ function(_, BaseView, GDSECollection, Muuri){

var userColumns = [];
this.users.forEach(function(user){
userColumns.push(user.id);
userColumns.push(user);
var name = user.get('alias') || user.get('name'),
th = document.createElement('th');
th.innerHTML = name;
Expand All @@ -154,18 +157,24 @@ function(_, BaseView, GDSECollection, Muuri){
this.indicators.forEach(function(indicator){
var row = table.insertRow(-1),
text = indicator.get('name') + ' (' + indicator.get('spatial_reference').toLowerCase() + ')';
var panelItem = _this.panelItem(text)
var panelItem = _this.panelItem(text, {
popoverText: text
})
panelItem.style.maxWidth = '500px';
row.insertCell(0).appendChild(panelItem);
var userTargets = _this.userTargetsPerIndicator[indicator.id];
if (!userTargets) return;
userColumns.forEach(function(userId){
var target = userTargets[userId],
cell = row.insertCell(-1);
userColumns.forEach(function(user){
var target = userTargets[user.id],
cell = row.insertCell(-1),
name = user.get('alias') || user.get('name');
if (target != null){
var targetValue = _this.targetValues.get(target.get('target_value')),
amount = targetValue.get('number'),
item = _this.panelItem(targetValue.get('text'));
targetText = targetValue.get('text'),
item = _this.panelItem(targetText, {
popoverText: '<b>' + name + '</b><br>' + text + '<br>' + targetText
});
cell.appendChild(item);
var hue = (amount >= 0) ? 90 : 0, // green or red
sat = 100 - 70 * Math.abs(Math.min(amount, 1)),
Expand Down
18 changes: 11 additions & 7 deletions repair/js/views/conclusions/objectives.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function(_, BaseView, GDSECollection, Muuri){
this.users.forEach(function(user){
var name = user.get('alias') || user.get('name'),
th = document.createElement('th');
userColumns.push(user.id);
userColumns.push(user);
th.innerHTML = name;
header.appendChild(th);
var userObjectives = objectives.filterBy({'user': user.get('user')});
Expand Down Expand Up @@ -122,11 +122,14 @@ function(_, BaseView, GDSECollection, Muuri){
item = _this.createAimItem(aim, i);
row.insertCell(0).appendChild(item);
var aimRank = rankingMap[aim.id];
userColumns.forEach(function(userId){
userColumns.forEach(function(user){
var cell = row.insertCell(-1),
rank = aimRank[userId];
rank = aimRank[user.id],
name = user.get('alias') || user.get('name');
if (rank) {
var item = _this.panelItem('#' + rank);
var item = _this.panelItem('#' + rank, {
popoverText: name + ' ' + gettext('ranked') + ' <b>' + aim.get('text') + '</b> #' + rank
});
item.style.width = '50px';
item.style.backgroundImage = 'none';
cell.appendChild(item);
Expand All @@ -141,10 +144,11 @@ function(_, BaseView, GDSECollection, Muuri){
},

createAimItem: function(aim, rank){
var desc = aim.get('description') || '';
var desc = aim.get('description') || '',
title = aim.get('text');

var panelItem = this.panelItem(aim.get('text'), {
popoverText: desc.replace(/\n/g, "<br/>"),
var panelItem = this.panelItem(title, {
popoverText: '<b>' + title + '</b><br>' + desc.replace(/\n/g, "<br/>"),
overlayText: '#' + rank
})
panelItem.style.maxWidth = '500px';
Expand Down
12 changes: 9 additions & 3 deletions repair/js/views/conclusions/strategies.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,10 @@ function(_, BaseView, GDSECollection, Map, ol, chroma){
var row = table.insertRow(-1),
text = solution.get('name'),
questions = _this.questions[solution.id];
var solItem = _this.panelItem(text, { overlayText: '0x' });
var solItem = _this.panelItem(text, {
overlayText: '0x',
popoverText: text
});
solItem.style.maxWidth = '600px';
row.insertCell(0).appendChild(solItem);
_this.users.forEach(function(user){
Expand Down Expand Up @@ -452,7 +455,10 @@ function(_, BaseView, GDSECollection, Map, ol, chroma){
function addRow(table, node, userSet, totalCount){
var row = table.insertRow(-1),
text = node.get('name');
var panelItem = _this.panelItem(text, { overlayText: totalCount + 'x' });
var panelItem = _this.panelItem(text, {
overlayText: totalCount + 'x',
popoverText: text
});
panelItem.style.width = '500px';
row.insertCell(0).appendChild(panelItem);
_this.users.forEach(function(user){
Expand Down Expand Up @@ -553,7 +559,7 @@ function(_, BaseView, GDSECollection, Map, ol, chroma){
stakeholders.forEach(function(stakeholder){
var row = table.insertRow(-1),
text = stakeholder.get('name');
var panelItem = _this.panelItem(text);
var panelItem = _this.panelItem(text, {popoverText: text});
panelItem.style.maxWidth = '500px';
row.insertCell(0).appendChild(panelItem);

Expand Down

0 comments on commit 0da785c

Please sign in to comment.