Newer
Older
dmpopidor / app / views / templates / admin_index.html.erb
<%= stylesheet_link_tag "admin" %>

<h1>
	<%= t('org_admin.templates_label') %>
</h1>
<div class="div_clear"></div>
<h2>
	<%= t('org_admin.templates.own_temp') %>
</h2>

<div class="div_left">
	<%= raw t('org_admin.templates.create_own_template_text_html')%>
</div>
<div class="div_right">
	<!-- link button to add new guidance -->
	<div class="move_2_right">
		<%= link_to t("org_admin.templates.create_template"),
		            admin_new_template_path,
		            class: 'btn btn-primary' %>
	</div>
</div>
<div class="div_clear"></div>

<!-- List of own templates -->
<% if @templates_own.length > 0 then %>
	<table id="dmp_table" class="dmp_table tablesorter">
		  <thead>
		    <tr>
		      	<th class="dmp_th_small"><%= t('org_admin.templates.title_label') %></th>
		      	<th class="dmp_th_medium"><%= t('org_admin.templates.desc_label') %></th>
		      	<th class="dmp_th_small"><%= t('org_admin.templates.published_label') %></th>
		      	<th class="dmp_th_small"><%= t('org_admin.templates.last_updated') %></th>
		      	<td class="dmp_th_small"><%= t('org_admin.templates.actions') %></td>
		    </tr>
		  </thead>
		  <tbody>
			<% @templates_own.each do |org_template| %>

		  	<tr>
	  			<td class="dmp_td_small">
	  				<%= org_template.title%>
	  			</td>
		        <td class="dmp_td_medium">
		        	<%= raw org_template.description.truncate(90, omission: t('helpers.truncate_continued')) %>
		        </td>
		        <td class="dmp_td_small">
			       	<%= org_template.published %>
			    </td>
			    <td class="dmp_td_small">
	        	<% last_temp_updated = org_template.updated_at %>
            <% org_template.phases.each do |phase|%>
              <% if org_template.updated_at.to_date < phase.updated_at.to_date then %>
                <% last_temp_updated = phase.updated_at %>
              <% end %>
            <% end %>
            <%= l last_temp_updated.to_date, formats: :short %>
		      </td>
		        <td class="dmp_td_small">
		        	<%if current_user.can_org_admin? then%>
						<% b_label = t('helpers.submit.edit')%>
					<%else%>
						<% b_label = t('helpers.view')%>
					<%end%>
					<%= link_to b_label, admin_template_template_path(org_template), class: "dmp_table_link"%>
		       	</td>
		     </tr>
	    	<%end%>
		  </tbody>
		</table>

<%end%>

<br/>
<div class="div_clear"></div>

<!-- display this only if the organisation is not a funder-->
<% if !current_user.org.funder? then %>
    <h2 class="float-left">
        <%= t("org_admin.templates.funders_temp") %>
    </h2>

    <!-- List of funders templates -->
    <% if @templates_funders.length > 0 then %>

        <table id="dmp_table_2" class="dmp_table tablesorter">
            <thead>
                <tr>
                    <th class="dmp_th_small"><%= t('org_admin.templates.title_label') %></th>
                    <th class="dmp_th_medium"><%= t('org_admin.templates.desc_label') %></th>
                    <th class="dmp_th_small"><%= t('org_admin.templates.published_label') %></th>
                    <th class="dmp_th_small"><%= t('org_admin.templates.last_updated') %></th>
                    <td class="dmp_th_small"><%= t('org_admin.templates.actions') %></td>
                </tr>
            </thead>
            <tbody>

                <% @templates_funders.each do |org_template| %>
                    <% if org_template.published? ||org_template.has_customisations?(current_user.organisation_id, org_template) then %>
                       <tr>
                            <td class="dmp_td_small">
                                <%= org_template.title%>
                            </td>
                            <td class="dmp_td_medium">
                                <%= raw org_template.description.truncate(90, omission: t('helpers.truncate_continued')) %>
                            </td>
                            <td class="dmp_td_small">
                                <%if org_template.published? then %>
                                    <%= org_template.published%>
                                <%else%>
                                    <%= t("helpers.false_lowercase")%>
                                <%end%>
                            </td>
                            <td class="dmp_td_small">
                                <% last_updated = org_template.updated_at %>
                                <%= l last_updated.to_date, formats: :short %>

                            </td>
                            <td class="dmp_td_small">
                                <%if current_user.can_org_admin? then%>
                                    <% if org_template.org_type == constant("organisation_types.funder") then %>
                                        <%if org_template.has_customisations?(current_user.org_id, org_template) then%>
                                            <% b_label = t("org_admin.templates.edit_customisation")%>
                                        <%else%>
                                            <% b_label = t("org_admin.templates.customise")%>
                                        <%end%>
                                    <%else%>
                                        <% b_label = t("helpers.submit.edit")%>
                                    <%end%>
                                <%else%>
                                    <% b_label = t("helpers.view")%>
                                <%end%>
                                <%= link_to b_label, admin_template_template_path(org_template), class: "dmp_table_link"%>
                            </td>
                        </tr>
                    <%end%>
                <%end%>
            </tbody>
        </table>
	<%end%>
<%end%>