From eb733b367b298ba1bfe439d200f768f1227aa76f Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Tue, 15 Mar 2016 14:26:16 +0100 Subject: [PATCH] [#1966] Remove actions from project page results --- akvo/rsr/static/scripts-src/my-results.js | 34 ++++++++++++++++++++-- akvo/rsr/static/scripts-src/my-results.jsx | 34 ++++++++++++++++++++-- akvo/templates/myrsr/my_results.html | 8 +++++ akvo/templates/project_main.html | 8 +++++ 4 files changed, 80 insertions(+), 4 deletions(-) diff --git a/akvo/rsr/static/scripts-src/my-results.js b/akvo/rsr/static/scripts-src/my-results.js index 721be55f9f..caa9d5276e 100644 --- a/akvo/rsr/static/scripts-src/my-results.js +++ b/akvo/rsr/static/scripts-src/my-results.js @@ -9,6 +9,7 @@ var csrftoken, endpoints, i18n, isAdmin, + isPublic, months, permissions, projectIds, @@ -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 ( @@ -629,7 +636,7 @@ function initReact() { }, renderFooter: function() { - if (this.props.selectedPeriod.locked) { + if (this.props.selectedPeriod.locked || isPublic) { return ( React.DOM.span(null ) ); @@ -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"}, @@ -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) { @@ -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); diff --git a/akvo/rsr/static/scripts-src/my-results.jsx b/akvo/rsr/static/scripts-src/my-results.jsx index b730c2ecb1..07f69a1ae5 100644 --- a/akvo/rsr/static/scripts-src/my-results.jsx +++ b/akvo/rsr/static/scripts-src/my-results.jsx @@ -9,6 +9,7 @@ var csrftoken, endpoints, i18n, isAdmin, + isPublic, months, permissions, projectIds, @@ -587,6 +588,12 @@ function initReact() { renderComments: function() { var comments; + if (isPublic) { + return ( + + ); + } + if (this.props.update.comments !== undefined) { comments = this.props.update.comments.map(function(comment) { return ( @@ -629,7 +636,7 @@ function initReact() { }, renderFooter: function() { - if (this.props.selectedPeriod.locked) { + if (this.props.selectedPeriod.locked || isPublic) { return ( ); @@ -839,6 +846,12 @@ function initReact() { }, renderNewUpdate: function() { + if (isPublic) { + return ( +
+ ); + } + if (this.props.addingNewUpdate) { return (
@@ -1061,7 +1074,22 @@ function initReact() { renderActions: function() { var projectId; - if (isAdmin) { + if (isPublic) { + switch(this.props.period.locked) { + case false: + return ( + + {i18n.period_unlocked} + + ); + default: + return ( + + {i18n.period_locked} + + ); + } + } else if (isAdmin) { switch(this.props.period.locked) { case false: if (this.props.parent || this.props.child) { @@ -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); diff --git a/akvo/templates/myrsr/my_results.html b/akvo/templates/myrsr/my_results.html index a8bd6a6844..ad9b744c50 100644 --- a/akvo/templates/myrsr/my_results.html +++ b/akvo/templates/myrsr/my_results.html @@ -28,6 +28,13 @@

+ {# Settings #} + + {# Initial data endpoints #} + {# Initial data endpoints #}