Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1262 #1264] Updated accordion on project main page #1279

Merged
merged 3 commits into from
Mar 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions akvo/rsr/static/rsr/v3/js/src/react-project-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,56 @@ var CarouselItem = ReactBootstrap.CarouselItem;
var Panel = ReactBootstrap.Panel;

var AccordionInstance = React.createClass({displayName: 'AccordionInstance',
splitLines: function(text) {
var lines = text.match(/[^\r\n]+/g).map(function(line) {
return (
React.DOM.p(null, line)
);
});
return lines
},

render: function() {
var background, current_status, project_plan, target_group, sustainability;
if (this.props.source.background != "") {
background = Panel( {className:"background", header:"Background", key:'background'}, this.props.source.background);
background = Panel( {className:"background", header:"Background", key:'background'}, this.splitLines(this.props.source.background));
} else {
background = null;
}
if (this.props.source.current_status != "") {
current_status = Panel( {className:"current_status", header:"Current situation", key:'current_status'}, this.props.source.current_status);
current_status = Panel( {className:"current_status", header:"Current situation", key:'current_status'}, this.splitLines(this.props.source.current_status));
} else {
current_status = null;
}
if (this.props.source.project_plan != "") {
project_plan = Panel( {className:"project_plan", header:"Project plan", key:'project_plan'}, this.props.source.project_plan);
project_plan = Panel( {className:"project_plan", header:"Project plan", key:'project_plan'}, this.splitLines(this.props.source.project_plan));
} else {
project_plan = null;
}
if (this.props.source.target_group != "") {
target_group = Panel( {className:"target_group", header:"Target group", key:'target_group'}, this.props.source.target_group);
target_group = Panel( {className:"target_group", header:"Target group", key:'target_group'}, this.splitLines(this.props.source.target_group));
} else {
target_group = null;
}
if (this.props.source.sustainability != "") {
sustainability = Panel( {className:"sustainability", header:"Sustainability", key:'sustainability'}, this.props.source.sustainability);
sustainability = Panel( {className:"sustainability", header:"Sustainability", key:'sustainability'}, this.splitLines(this.props.source.sustainability));
} else {
sustainability = null;
}
if (this.props.source.goals_overview != "") {
goals_overview = Panel( {className:"goals_overview", header:"Goals overview", key:'goals_overview'}, this.splitLines(this.props.source.goals_overview));
} else {
goals_overview = null;
}

return (
Accordion(null,
background,
current_status,
project_plan,
target_group,
sustainability
sustainability,
goals_overview
)
);
}
Expand Down
25 changes: 20 additions & 5 deletions akvo/rsr/static/rsr/v3/js/src/react-project-main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,47 @@ var CarouselItem = ReactBootstrap.CarouselItem;
var Panel = ReactBootstrap.Panel;

var AccordionInstance = React.createClass({
splitLines: function(text) {
var lines = text.match(/[^\r\n]+/g).map(function(line) {
return (
<p>{line}</p>
);
});
return lines
},

render: function() {
var background, current_status, project_plan, target_group, sustainability;
if (this.props.source.background != "") {
background = <Panel className="background" header="Background" key={'background'}>{this.props.source.background}</Panel>;
background = <Panel className="background" header="Background" key={'background'}>{this.splitLines(this.props.source.background)}</Panel>;
} else {
background = null;
}
if (this.props.source.current_status != "") {
current_status = <Panel className="current_status" header="Current situation" key={'current_status'}>{this.props.source.current_status}</Panel>;
current_status = <Panel className="current_status" header="Current situation" key={'current_status'}>{this.splitLines(this.props.source.current_status)}</Panel>;
} else {
current_status = null;
}
if (this.props.source.project_plan != "") {
project_plan = <Panel className="project_plan" header="Project plan" key={'project_plan'}>{this.props.source.project_plan}</Panel>;
project_plan = <Panel className="project_plan" header="Project plan" key={'project_plan'}>{this.splitLines(this.props.source.project_plan)}</Panel>;
} else {
project_plan = null;
}
if (this.props.source.target_group != "") {
target_group = <Panel className="target_group" header="Target group" key={'target_group'}>{this.props.source.target_group}</Panel>;
target_group = <Panel className="target_group" header="Target group" key={'target_group'}>{this.splitLines(this.props.source.target_group)}</Panel>;
} else {
target_group = null;
}
if (this.props.source.sustainability != "") {
sustainability = <Panel className="sustainability" header="Sustainability" key={'sustainability'}>{this.props.source.sustainability}</Panel>;
sustainability = <Panel className="sustainability" header="Sustainability" key={'sustainability'}>{this.splitLines(this.props.source.sustainability)}</Panel>;
} else {
sustainability = null;
}
if (this.props.source.goals_overview != "") {
goals_overview = <Panel className="goals_overview" header="Goals overview" key={'goals_overview'}>{this.splitLines(this.props.source.goals_overview)}</Panel>;
} else {
goals_overview = null;
}

return (
<Accordion>
Expand All @@ -41,6 +55,7 @@ var AccordionInstance = React.createClass({
{project_plan}
{target_group}
{sustainability}
{goals_overview}
</Accordion>
);
}
Expand Down
1 change: 1 addition & 0 deletions akvo/rsr/views/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def _get_accordion_data(project):
accordion_data['project_plan'] = project.project_plan
accordion_data['target_group'] = project.target_group
accordion_data['sustainability'] = project.sustainability
accordion_data['goals_overview'] = project.goals_overview
return accordion_data


Expand Down