Newer
Older
dmpopidor / app / views / projects / _project_details.html.erb
@Marta Ribeiro Marta Ribeiro on 3 Jun 2016 9 KB DMPonline4 - RAILS 4.0 (#4)
<!-- Project title = default title is the template title plus date of creation -->
<div class="dmp_details_body">
	<div class="view-project <%= if @show_form && @project.administerable_by(current_user.id) then "project-hide" end %>">
		<div class="div_left">
			<p>
				<%= t('helpers.project.project_details_text_html')%>
			</p>	
		</div>
		
		<!-- edit project button -->
		<div class="div_right">
			<% if @project.administerable_by(current_user.id) then %>
				<a href='#' class='btn btn-primary show-edit-toggle'><%= t("helpers.project.edit") %></a>
			<% end %>
		</div>
		<!-- display project details -->
		<div class="dmp_details">
			<table class="dmp_details_table">
				<tr>
					<td class="first"><%= t('helpers.project.project_name') %></td>
					<td><%= @project.title %></td>
				</tr>
				<tr>
					<td class="first"><%= t('helpers.project.project_identifier') %></td>
					<td>
						<% if !@project.identifier.nil? && @project.identifier != "" then %>
							<%= @project.identifier %>
						<%else%>
							 -
						<%end%>	
					</td>
				</tr>
				<tr>
					<td class="first"><%= t('helpers.project.grant_title') %></td>
					<td>
						<% if !@project.grant_number.nil? && @project.grant_number!= "" then %>
							<%= @project.grant_number %>
						<%else%>
							-	
						<%end%>	
					</td>
				</tr>
				<tr>
					<td class="first"><%= t('helpers.project.principal_investigator') %></td>
					<td><% if !@project.principal_investigator.nil? && @project.principal_investigator != "" then%>
							<%= @project.principal_investigator %>
						<%else%>
							 -
						<%end%>	
					</td>
				</tr>
				<% if !@project.principal_investigator_identifier.nil? && @project.principal_investigator_identifier != "" then %>
					<tr>
						<td class="first"><%= t('helpers.project.principal_investigator_id') %></td>
						<td>
							<%= @project.principal_investigator_identifier %>
						</td>
					</tr>
				<%end%>		
				<tr>
					<td class="first"><%= t('helpers.project.project_data_contact') %></td>
					<td><% if !@project.data_contact.nil? && @project.data_contact != "" then%>
							<%= @project.data_contact %>
						<%else%>
							 -
						<%end%>	
					</td>
				</tr>
				<tr>
					<td class="first"><%= t('helpers.desc') %></td>
					<td><% if !@project.description.nil? && @project.description != "" then%>
							<%= @project.description %>
						<%else%>
							 -
						<%end%>	
					</td>
				</tr>
			</table>
		</div>
	</div>
	<% if @project.administerable_by(current_user.id) then %>
		<div class="edit-project <%= unless @show_form then "project-hide" end %>">
			<!-- edit project button -->
			<div class="div_left">
				<p>
					<%= raw t('helpers.project.project_details_editing_text_html')%>
				</p>
			</div>
			<div class="div_right">
				<a href='#' class='btn btn-primary show-edit-toggle'><%= t("helpers.links.cancel") %></a>
			</div>
			<div class="div_clear"> </div>
			<%= semantic_form_for @project, :url => {:controller => :projects, :action => :update }, :html=>{:method=>:put} do |f| %>
			<%= f.inputs do %>
				<div class="dmp_details">
					
					<!-- If not first time login in or editing project details -->
					<table class="dmp_details_table">
						<tr>
							<td class="first"><%= t('helpers.project.project_name') %></td>
							<td>
								<%= f.text_field :title, :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('helpers.project.project_name_help_text') %>
							</td>
						</tr>
						<tr>
							<td class="first"><%= t('helpers.project.project_identifier') %></td>
							<td>
								<%= f.text_field :identifier, :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('helpers.project.project_identifier_help_text') %>
							</td>
						</tr>
						<tr>
							<td class="first"><%= t('helpers.project.grant_title') %></td>
							<td>
								<%= f.text_field :grant_number, :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('helpers.project.grant_help_text') %>
							</td>
						</tr>
						<tr>
							<td class="first"><%= t('helpers.project.principal_investigator') %></td>
							<td>
								<%= f.text_field :principal_investigator, :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('helpers.project.principal_investigator_help_text') %>
							</td>
						</tr>
						<tr>
							<td class="first"><%= t('helpers.project.principal_investigator_id') %></td>
							<td>
								<%= f.text_field :principal_investigator_identifier, :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('helpers.project.principal_investigator_id_help_text') %>
							</td>
						</tr>
						<tr>
							<td class="first"><%= t('helpers.project.project_data_contact') %></td>
							<td>
								<%= f.text_field :data_contact, :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('helpers.project.project_data_contact_help_text') %>	
							</td>
						</tr>
						<tr>
							<td class="first"><%= t('helpers.desc') %></td>
							<td>
								<%= f.text_area :description, { :rows => 7, :class => 'text_area has-tooltip', 'data-toggle' => "tooltip", 'data-html' => "true", 'title'=> t('helpers.project.project_desc_help_text_html')} %>
							</td>
						</tr>
					</table>				
				</div>
				<% end %>
				<!-- submit buttons -->
				<%= f.actions do %>	
					<div class="move_2_right">
						<%= f.submit t("helpers.submit.save"), :class => 'btn btn-primary' %>
						<a href='#' class='btn btn-primary show-edit-toggle'><%= t("helpers.links.cancel") %></a>
					</div>
				<%end%>
			<%end%>	
	</div>
	<% end %>
	<h3><%= t('helpers.project.project_static_info')%></h3>
	<table class="dmp_details_table">
		<!-- get the funder name if there is one -->
		<%if @project.dmptemplate.organisation.organisation_type.name == t('helpers.org_type.funder') %>
			<tr>
				<td class="first"><%= t('helpers.org_type.funder') %></td>
				<td><%= @project.dmptemplate.organisation.name %></td>
			</tr>
		<%end%>
		<%if !@project.organisation_id.nil?	%>
			<tr>
				<td class="first"><%= t('helpers.org_type.institution') %></td>
				<td><%= @project.organisation.name %></td>
			</tr>
		<%end%>
	</table>
			
	<!-- If project has plans-->
	<% if @project.plans.any? %>
		<% if @project.plans.count == 1 then %>
			<% @project.plans.each do |plan| %>
				
				<div class="move_2_right">
					<%= link_to t('helpers.answer_questions'), [:edit, @project, plan], :class => 'btn btn-primary'  %>
					<a href="#<%= plan.id %>-export-dialog" data-toggle="modal" class='btn btn-primary'><%= t('helpers.export') %></a>
				</div>
				<%= render :partial => "plans/export", locals: {plan: plan} %>
				<div class="div_clear"></div>
				<p><%= raw plan.version.phase.description %></p>
				<% if !plan.sections.nil? %>
					<table class="dmp_table">
						<thead>
						    <tr>
						      	<th class="dmp_th_medium"><%= t('helpers.sections_label')%></th>
						      	<th class="dmp_th_big"><%= t('helpers.questions_label')%></th>
		   					</tr>
	   					</thead>
	   					<tbody>
	   						<% plan.sections.each do |section| %>
								<tr >
									<th class="dmp_th_border" >
										<p><%= section.title %></p>
									</th>
	        						<td class="dmp_td_border" >	
										<% if section.questions.any? %>
											<% questions = section.questions.sort_by(&:number) %>
											<ul class="question_ul">
												<% questions.each do |ques|%>
													<li>
														- <%= ques.text %>
													</li>	
												<%end%>
											</ul>
										<%end%>		
									</td>
								</tr>		
							<%end%>
						</tbody>	
					</table>
				<%end%>	
			<%end%>
		<%else%>	
			<div class="project_description">
				<%= raw @project.dmptemplate.description %>
			</div>	
			<% @project.plans.each do |plan| %>
				<div class="accordion" id="project-accordion">
					<div class="accordion-group">
						<div class="accordion-heading">
							<a class="accordion-toggle" data-toggle="collapse" data-parent="#project-accordion" href="#<%= plan.version.phase.id %>">
								<h3><%= plan.version.phase.title %><span class="plus-laranja"> </span>
								</h3>
							</a>
						</div>
						<div id="<%= plan.version.phase.id %>" class="accordion-project collapse">
							<div class="accordion-inner">
								<div class="div_right">
									<%= link_to t('helpers.answer_questions'), [:edit, @project, plan], :class => 'btn btn-primary'  %>
									<a href="#<%= plan.id %>-export-dialog" data-toggle="modal" class='btn btn-primary'><%= t('helpers.export') %></a>
								</div>
								<%= render :partial => "plans/export", locals: {plan: plan} %>
								<div class="div_clear"></div>
									<p><%= raw plan.version.phase.description %>
								</p>
												
								<% if !plan.sections.nil? %>
									<table class="dmp_table">
										<thead>
										    <tr>
										      	<th class="dmp_th_medium"><%= t('helpers.sections_label')%></th>
										      	<th class="dmp_th_big"><%= t('helpers.questions_label')%></th>
						   					</tr>
					   					</thead>
					   					<tbody>
					   						<% plan.sections.each do |section| %>
												<tr >
													<th class="dmp_th_border" >
														<p><%= section.title %></p>
													</th>
					        						<td class="dmp_td_border" >	
														<% if section.questions.any? %>
															<% questions = section.questions.sort_by(&:number) %>
															<ul class="question_ul">
																<% questions.each do |ques|%>
																	<li>
																		- <%= ques.text %>
																	</li>	
																<%end%>
															</ul>
														<%end%>		
													</td>
												</tr>		
											<%end%>
										</tbody>	
									</table>
								<%end%>
							</div>
						</div>
					</div>
				</div>				
			<%end%>	
		<%end%>	
	<%end%>				
</div>