Skip to content

Commit

Permalink
[#1966] Merge branch '#2011-results-improve' into #1966-results-frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
KasperBrandt committed Mar 31, 2016
2 parents a317324 + 9143766 commit 3171d17
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 18 deletions.
35 changes: 26 additions & 9 deletions akvo/rsr/static/scripts-src/my-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,10 @@ function initReact() {
};
},

goBack: function() {
this.props.selectPeriod(null);
},

handleMouseOver: function() {
// Update the state when the actual value info icon is hovered.
this.setState({actualValueHover: true});
Expand Down Expand Up @@ -1190,6 +1194,9 @@ function initReact() {

return (
React.DOM.div( {className:"indicator-period opacity-transition"},
React.DOM.div( {className:"backButton"},
React.DOM.a( {onClick:this.goBack}, "< ", i18nResults.back)
),
React.DOM.div( {className:"indicTitle"},
React.DOM.h4( {className:"indicator-title"},
i18nResults.indicator_period,": ", displayDate(this.props.selectedPeriod.period_start), " - ", displayDate(this.props.selectedPeriod.period_end)
Expand Down Expand Up @@ -1586,6 +1593,10 @@ function initReact() {
};
},

goBack: function() {
this.props.selectIndicator(null);
},

addNewUpdate: function(periodId) {
// Add a new indicator update.

Expand Down Expand Up @@ -1672,6 +1683,7 @@ function initReact() {
removeUpdate: this.props.removeUpdate,
selectedIndicator: this.props.selectedIndicator,
selectedPeriod: this.props.selectedPeriod,
selectPeriod: this.props.selectPeriod,
reloadPeriod: this.props.reloadPeriod,
lockPeriod: this.lockPeriod,
unlockPeriod: this.unlockPeriod
Expand All @@ -1682,6 +1694,9 @@ function initReact() {
// Show a list of periods.
return (
React.DOM.div( {className:"indicator opacity-transition"},
React.DOM.div( {className:"backButton"},
React.DOM.a( {onClick:this.goBack}, "< ", i18nResults.back)
),
React.DOM.h4( {className:"indicator-title"},
this.props.selectedIndicator.title,this.showMeasure()
),
Expand Down Expand Up @@ -2303,7 +2318,6 @@ function initReact() {

selectResult: function(resultId) {
// Keep track in the state which result has been selected
var oldSelectedResultId = this.state.selectedResultId;
this.setState({selectedResultId: resultId});
},

Expand All @@ -2313,14 +2327,11 @@ function initReact() {

// Update the window's hash
if (indicatorId !== null) {
var resultId;
if (this.state.selectedResultId === null) {
var indicator = this.findIndicator(indicatorId);
resultId = indicator.result;
} else {
resultId = this.state.selectedResultId;
}
var indicator = this.findIndicator(indicatorId);
var resultId = indicator.result;
window.location.hash = 'results,' + resultId + ',' + indicatorId;
} else {
window.location.hash = '';
}
},

Expand All @@ -2329,7 +2340,12 @@ function initReact() {
this.setState({selectedPeriodId: periodId});

// Update the window's hash
if (periodId !== null) {
var windowHashArray = window.location.hash.split(',');
if (periodId === null && windowHashArray.length === 4) {
windowHashArray.pop();
windowHashArray[0] = windowHashArray[0].substr(1);
window.location.hash = windowHashArray.join(',');
} else if (periodId !== null) {
var resultId = this.state.selectedResultId;
var indicatorId = this.state.selectedIndicatorId;
window.location.hash = 'results,' + resultId + ',' + indicatorId + ',' + periodId;
Expand Down Expand Up @@ -2401,6 +2417,7 @@ function initReact() {
removeUpdate: this.removeUpdate,
reloadPeriod: this.reloadPeriod,
selectedIndicator: this.selectedIndicator(),
selectIndicator: this.selectIndicator,
selectedPeriod: this.selectedPeriod(),
selectPeriod: this.selectPeriod,
findProjectOfResult: this.findProjectOfResult,
Expand Down
35 changes: 26 additions & 9 deletions akvo/rsr/static/scripts-src/my-results.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,10 @@ function initReact() {
};
},

goBack: function() {
this.props.selectPeriod(null);
},

handleMouseOver: function() {
// Update the state when the actual value info icon is hovered.
this.setState({actualValueHover: true});
Expand Down Expand Up @@ -1190,6 +1194,9 @@ function initReact() {

return (
<div className="indicator-period opacity-transition">
<div className="backButton">
<a onClick={this.goBack}>&lt; {i18nResults.back}</a>
</div>
<div className="indicTitle">
<h4 className="indicator-title">
{i18nResults.indicator_period}: {displayDate(this.props.selectedPeriod.period_start)} - {displayDate(this.props.selectedPeriod.period_end)}
Expand Down Expand Up @@ -1586,6 +1593,10 @@ function initReact() {
};
},

goBack: function() {
this.props.selectIndicator(null);
},

addNewUpdate: function(periodId) {
// Add a new indicator update.

Expand Down Expand Up @@ -1672,6 +1683,7 @@ function initReact() {
removeUpdate: this.props.removeUpdate,
selectedIndicator: this.props.selectedIndicator,
selectedPeriod: this.props.selectedPeriod,
selectPeriod: this.props.selectPeriod,
reloadPeriod: this.props.reloadPeriod,
lockPeriod: this.lockPeriod,
unlockPeriod: this.unlockPeriod
Expand All @@ -1682,6 +1694,9 @@ function initReact() {
// Show a list of periods.
return (
<div className="indicator opacity-transition">
<div className="backButton">
<a onClick={this.goBack}>&lt; {i18nResults.back}</a>
</div>
<h4 className="indicator-title">
{this.props.selectedIndicator.title}{this.showMeasure()}
</h4>
Expand Down Expand Up @@ -2303,7 +2318,6 @@ function initReact() {

selectResult: function(resultId) {
// Keep track in the state which result has been selected
var oldSelectedResultId = this.state.selectedResultId;
this.setState({selectedResultId: resultId});
},

Expand All @@ -2313,14 +2327,11 @@ function initReact() {

// Update the window's hash
if (indicatorId !== null) {
var resultId;
if (this.state.selectedResultId === null) {
var indicator = this.findIndicator(indicatorId);
resultId = indicator.result;
} else {
resultId = this.state.selectedResultId;
}
var indicator = this.findIndicator(indicatorId);
var resultId = indicator.result;
window.location.hash = 'results,' + resultId + ',' + indicatorId;
} else {
window.location.hash = '';
}
},

Expand All @@ -2329,7 +2340,12 @@ function initReact() {
this.setState({selectedPeriodId: periodId});

// Update the window's hash
if (periodId !== null) {
var windowHashArray = window.location.hash.split(',');
if (periodId === null && windowHashArray.length === 4) {
windowHashArray.pop();
windowHashArray[0] = windowHashArray[0].substr(1);
window.location.hash = windowHashArray.join(',');
} else if (periodId !== null) {
var resultId = this.state.selectedResultId;
var indicatorId = this.state.selectedIndicatorId;
window.location.hash = 'results,' + resultId + ',' + indicatorId + ',' + periodId;
Expand Down Expand Up @@ -2401,6 +2417,7 @@ function initReact() {
removeUpdate: this.removeUpdate,
reloadPeriod: this.reloadPeriod,
selectedIndicator: this.selectedIndicator(),
selectIndicator: this.selectIndicator,
selectedPeriod: this.selectedPeriod(),
selectPeriod: this.selectPeriod,
findProjectOfResult: this.findProjectOfResult,
Expand Down
1 change: 1 addition & 0 deletions akvo/templates/myrsr/my_results.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ <h4 class="resultProjectTitle">
"baseline_year": "{% trans 'Baseline year' %}",
"baseline_value": "{% trans 'Baseline value' %}",
"period": "{% trans 'Period' %}",
"back": "{% trans 'Back' %}",
"loading": "{% trans 'Loading' %}",
"number_of_pending_updates": "{% trans 'Number of pending updates' %}",
"lock_period": "{% trans 'Lock period' %}",
Expand Down
1 change: 1 addition & 0 deletions akvo/templates/project_main.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
"baseline_year": "{% trans 'Baseline year' %}",
"baseline_value": "{% trans 'Baseline value' %}",
"period": "{% trans 'Period' %}",
"back": "{% trans 'Back' %}",
"loading": "{% trans 'Loading' %}",
"number_of_pending_updates": "{% trans 'Number of pending updates' %}",
"lock_period": "{% trans 'Lock period' %}",
Expand Down

0 comments on commit 3171d17

Please sign in to comment.