Skip to content

Commit

Permalink
[#1966] Remove actions from project page results
Browse files Browse the repository at this point in the history
  • Loading branch information
KasperBrandt committed Mar 15, 2016
1 parent 9603280 commit eb733b3
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 4 deletions.
34 changes: 32 additions & 2 deletions akvo/rsr/static/scripts-src/my-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var csrftoken,
endpoints,
i18n,
isAdmin,
isPublic,
months,
permissions,
projectIds,
Expand Down Expand Up @@ -587,6 +588,12 @@ function initReact() {
renderComments: function() {
var comments;

if (isPublic) {
return (
React.DOM.span(null )
);
}

if (this.props.update.comments !== undefined) {
comments = this.props.update.comments.map(function(comment) {
return (
Expand Down Expand Up @@ -629,7 +636,7 @@ function initReact() {
},

renderFooter: function() {
if (this.props.selectedPeriod.locked) {
if (this.props.selectedPeriod.locked || isPublic) {
return (
React.DOM.span(null )
);
Expand Down Expand Up @@ -839,6 +846,12 @@ function initReact() {
},

renderNewUpdate: function() {
if (isPublic) {
return (
React.DOM.div( {className:"new-update"})
);
}

if (this.props.addingNewUpdate) {
return (
React.DOM.div( {className:"new-update"},
Expand Down Expand Up @@ -1061,7 +1074,22 @@ function initReact() {
renderActions: function() {
var projectId;

if (isAdmin) {
if (isPublic) {
switch(this.props.period.locked) {
case false:
return (
React.DOM.td( {className:"actions-td"},
React.DOM.i( {className:"fa fa-unlock"} ), " ", i18n.period_unlocked
)
);
default:
return (
React.DOM.td( {className:"actions-td"},
React.DOM.i( {className:"fa fa-lock"} ), " ", i18n.period_locked
)
);
}
} else if (isAdmin) {
switch(this.props.period.locked) {
case false:
if (this.props.parent || this.props.child) {
Expand Down Expand Up @@ -2169,6 +2197,8 @@ function loadAndRenderReact() {
/* Initialise page */
document.addEventListener('DOMContentLoaded', function() {
// Retrieve data endpoints, translations and project IDs
isPublic = JSON.parse(document.getElementById('settings').innerHTML).public;
console.log('isPublic: ' + isPublic);
endpoints = JSON.parse(document.getElementById('data-endpoints').innerHTML);
i18n = JSON.parse(document.getElementById('translation-texts').innerHTML);
months = JSON.parse(document.getElementById('months').innerHTML);
Expand Down
34 changes: 32 additions & 2 deletions akvo/rsr/static/scripts-src/my-results.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var csrftoken,
endpoints,
i18n,
isAdmin,
isPublic,
months,
permissions,
projectIds,
Expand Down Expand Up @@ -587,6 +588,12 @@ function initReact() {
renderComments: function() {
var comments;

if (isPublic) {
return (
<span />
);
}

if (this.props.update.comments !== undefined) {
comments = this.props.update.comments.map(function(comment) {
return (
Expand Down Expand Up @@ -629,7 +636,7 @@ function initReact() {
},

renderFooter: function() {
if (this.props.selectedPeriod.locked) {
if (this.props.selectedPeriod.locked || isPublic) {
return (
<span />
);
Expand Down Expand Up @@ -839,6 +846,12 @@ function initReact() {
},

renderNewUpdate: function() {
if (isPublic) {
return (
<div className="new-update"></div>
);
}

if (this.props.addingNewUpdate) {
return (
<div className="new-update">
Expand Down Expand Up @@ -1061,7 +1074,22 @@ function initReact() {
renderActions: function() {
var projectId;

if (isAdmin) {
if (isPublic) {
switch(this.props.period.locked) {
case false:
return (
<td className="actions-td">
<i className="fa fa-unlock" /> {i18n.period_unlocked}
</td>
);
default:
return (
<td className="actions-td">
<i className="fa fa-lock" /> {i18n.period_locked}
</td>
);
}
} else if (isAdmin) {
switch(this.props.period.locked) {
case false:
if (this.props.parent || this.props.child) {
Expand Down Expand Up @@ -2169,6 +2197,8 @@ function loadAndRenderReact() {
/* Initialise page */
document.addEventListener('DOMContentLoaded', function() {
// Retrieve data endpoints, translations and project IDs
isPublic = JSON.parse(document.getElementById('settings').innerHTML).public;
console.log('isPublic: ' + isPublic);
endpoints = JSON.parse(document.getElementById('data-endpoints').innerHTML);
i18n = JSON.parse(document.getElementById('translation-texts').innerHTML);
months = JSON.parse(document.getElementById('months').innerHTML);
Expand Down
8 changes: 8 additions & 0 deletions akvo/templates/myrsr/my_results.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ <h4 class="resultProjectTitle">
<script id="react" src="{{ STATIC_URL }}lib/scripts/react-0.14.7.min.js"></script>
<script id="react-dom" src="{{ STATIC_URL }}lib/scripts/react-dom-0.14.7.min.js"></script>

{# Settings #}
<script type="application/json" id="settings">
{
"public": false
}
</script>

{# Initial data endpoints #}
<script type="application/json" id="data-endpoints">
{
Expand Down Expand Up @@ -92,6 +99,7 @@ <h4 class="resultProjectTitle">
"lock_period": "{% trans 'Lock period' %}",
"unlock_period": "{% trans 'Unlock period' %}",
"period_locked": "{% trans 'Period locked' %}",
"period_unlocked": "{% trans 'Period unlocked' %}",
"parent_project": "{% trans 'Parent project' %}",
"child_project": "{% trans 'Child project' %}",
"request_update": "{% trans 'Request update' %}",
Expand Down
8 changes: 8 additions & 0 deletions akvo/templates/project_main.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@
{###### RESULTS FRAMEWORK ######}
{% if project.is_impact_project and project.results.all %}

{# Settings #}
<script type="application/json" id="settings">
{
"public": true
}
</script>

{# Initial data endpoints #}
<script type="application/json" id="data-endpoints">
{
Expand Down Expand Up @@ -151,6 +158,7 @@
"lock_period": "{% trans 'Lock period' %}",
"unlock_period": "{% trans 'Unlock period' %}",
"period_locked": "{% trans 'Period locked' %}",
"period_unlocked": "{% trans 'Period unlocked' %}",
"parent_project": "{% trans 'Parent project' %}",
"child_project": "{% trans 'Child project' %}",
"request_update": "{% trans 'Request update' %}",
Expand Down

0 comments on commit eb733b3

Please sign in to comment.