diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb
index 313f84d..c19acc6 100644
--- a/app/controllers/templates_controller.rb
+++ b/app/controllers/templates_controller.rb
@@ -19,8 +19,25 @@
end
end
@templates_own = current_templates.values
- #funders templates
- @templates_funders = []#Org.funders.collect{|o| o.templates } #Template.funders_templates
+
+ # funders templates
+ funders_templates = {}
+ Org.includes(:templates).funder.each do |org|
+ org.templates.where(customization_of: nil, published: true).order(version: :desc).each do |temp|
+ if funders_templates[temp.dmptemplate_id].nil?
+ funders_templates[temp.dmptemplate_id] = temp
+ end
+ end
+ end
+
+ @templates_funders = funders_templates.values
+ # are any funder templates customized
+ @templates_customizations = {}
+ Template.where(org_id: current_user.org_id, customization_of: funders_templates.keys).order(version: :desc).each do |temp|
+ if @templates_customizations[temp.dmptemplate_id].nil?
+ @templates_customizations[temp.dmptemplate_id] = temp
+ end
+ end
end
diff --git a/app/views/templates/admin_index.html.erb b/app/views/templates/admin_index.html.erb
index 027aa65..81d0a82 100644
--- a/app/views/templates/admin_index.html.erb
+++ b/app/views/templates/admin_index.html.erb
@@ -46,16 +46,16 @@
<% #Yes if published version exists, Yes[Unpublished changes] if newer version modified, No otherwise%>
<% if org_template.published %>
- <%= "Yes" %>
+ <%= t("helpers.yes_label") %>
<% elsif org_template.version > 0 && Template.where(dmptemplate_id: org_template.dmptemplate_id, published: true).present? %>
<% #there is a published version, but this version is not %>
<% if org_template.created_at < org_template.updated_at %>
- <%= "Yes [Unpublished Changes]" %>
+ <%= t("org_admin.templates.unpublished_changes") %>
<% else %>
- <%= "Yes" %>
+ <%= t("helpers.yes_label") %>
<% end %>
<% else %>
- <%= "No" %>
+ <%= t("helpers.no_label") %>
<% end %>
|
@@ -84,66 +84,69 @@
<% if !current_user.org.funder? then %>
-
- <%= t("org_admin.templates.funders_temp") %>
-
+
+ <%= t("org_admin.templates.funders_temp") %>
+
-
- <% if @templates_funders.length > 0 then %>
-
-
-
-
- | <%= t('org_admin.templates.title_label') %> |
- <%= t('org_admin.templates.desc_label') %> |
- <%= t('org_admin.templates.published_label') %> |
- <%= t('org_admin.templates.last_updated') %> |
- <%= t('org_admin.templates.actions') %> |
-
-
-
-
- <% @templates_funders.each do |org_template| %>
- <% if org_template.published ||org_template.has_customisations?(current_user.organisation_id, org_template) then %>
-
- |
- <%= org_template.title%>
- |
-
- <%= raw org_template.description.truncate(90, omission: t('helpers.truncate_continued')) %>
- |
-
- <%if org_template.published? then %>
- <%= org_template.published%>
- <%else%>
- <%= t("helpers.false_lowercase")%>
- <%end%>
- |
-
- <% last_updated = org_template.updated_at %>
- <%= l last_updated.to_date, formats: :short %>
-
- |
-
- <%if current_user.can_org_admin? then%>
- <% if org_template.org.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"%>
- |
-
- <%end%>
- <%end%>
-
-
- <%end%>
-<%end%>
+
+ <% if @templates_funders.length > 0 then %>
+
+
+
+ | <%= t('org_admin.templates.title_label') %> |
+ <%= t('org_admin.templates.desc_label') %> |
+ <%= t('org_admin.templates.customise_label') %> |
+ <%= t('org_admin.templates.last_updated') %> |
+ <%= t('org_admin.templates.actions') %> |
+
+
+
+ <% @templates_funders.each do |org_template| %>
+
+ |
+ <%= org_template.title%>
+ |
+
+ <%= raw org_template.description.truncate(90, omission: t('helpers.truncate_continued')) %>
+ |
+
+ <% customized = 0 %>
+ <% template = org_template %>
+ <% if @templates_customizations[org_template.dmptemplate_id].present? %>
+ <% if @templates_customizations[org_template.dmptemplate_id].updated_at < org_template.updated_at %>
+ <%= t("org_admin.templates.original_changed") %>
+ <% customized = 3 %>
+ <% else %>
+ <% template = @templates_customizations[org_template.dmptemplate_id] %>
+ <% if !@templates_customizations[org_template.dmptemplate_id].published %>
+ <%= t("org_admin.templates.unpublished_changes") %>
+ <% customized = 2 %>
+ <% else %>
+ <%= t("helpers.yes_label") %>
+ <% customized = 1 %>
+ <% end %>
+ <% end %>
+ <% else %>
+ <%= t("helpers.no_label") %>
+ <% end %>
+ |
+
+ <% last_updated = org_template.updated_at %>
+ <%= l last_updated.to_date, formats: :short %>
+ |
+
+ <% if customized == 0 %>
+ <% b_label = t("org_admin.templates.customise") %>
+ <% elsif customized == 1 || customized == 2 %>
+ <% b_label = t("org_admin.templates.edit_customisation") %>
+ <% elsif customized == 3 %>
+ <% b_label = t("org_admin.templates.update_customisation") %>
+ <% end %>
+ <%= link_to b_label, admin_template_template_path(org_template), class: "dmp_table_link" %>
+ |
+
+ <% end %>
+
+
+ <% end %>
+<% end %>
diff --git a/config/locales/en-UK.yml b/config/locales/en-UK.yml
index 7251141..99325c2 100644
--- a/config/locales/en-UK.yml
+++ b/config/locales/en-UK.yml
@@ -277,12 +277,17 @@
desc_label: "Description"
actions: "Actions"
customise: "Customise"
+ customise_label: "Customised"
edit_customisation: "Edit customisation"
+ update_customisation: "Update Customisation"
created_message: "Information was successfully created."
updated_message: "Information was successfully updated."
destroyed_message: "Information was successfully deleted."
read_only: "Published templates cannot be edited."
section_delete_message: "You are about to delete '%{section_title}'. This will affect questions linked to this section. Are you sure?"
+ unpublished_changes: "Yes [Unpublished Changes]"
+ original_changed: "Yes [Original Template Has Changed]"
+
versions:
clone_versions_label: "Make big changes"
edit_versions_label: "Make small changes"
|