You can now indicate that you have completed something and add evidence but the update doesn't yet work and it will need refatoring because we need to get back to the CAF or company.

This commit is contained in:
2024-04-25 14:48:50 +01:00
parent 8200b974c3
commit 6b0da161be
16 changed files with 177 additions and 87 deletions

View File

@@ -27,7 +27,9 @@
<% subprinciple.subprincipleitemgroups.each do |subprincipleitemgroup| %>
<td>
<% subprincipleitemgroup.subprincipleitems.each do |subprincipleitem| %>
<div id="<%= "subprincipleitemid_#{subprincipleitem.id}" %>" class="subprincipleitem"><%= subprincipleitem.description %></div>
<div style="background-color:<%= subprincipleitem.affirmative ? '#05aa05' : '#aa3030' %>;" id="<%= "subprincipleitemid_#{subprincipleitem.id}" %>" class="subprincipleitem"><%= subprincipleitem.description %><%= link_to "Change", edit_subprincipleitem_path(subprincipleitem) %>
</div>
<% end %>
</td>
<% end %>
@@ -40,31 +42,4 @@
<% end %>
<% end %>
<script type="text/javascript">
// Guard against double DOM loads
// https://stackoverflow.com/questions/71876873/rails-7-7-0-2-3-importmap-jquery-is-not-defined-in-view
var codeExecuted = false;
document.addEventListener('DOMContentLoaded', function(e) {
// Check if importmap stuff exisits without throwing an error.
// Then run main code w/ guard against multiple executions.
if ("importmapScriptsLoaded" in window) {
if (!codeExecuted) {
// Main code here
console.log($('#hello'));
$(".subprincipleitem").click(function(event) {
alert(event.target.id);
});
// Don't forget to bump guard for one-time only JS execution !!
codeExecuted = true;
};
};
});
</script>

View File

@@ -0,0 +1,17 @@
<h1><%= @subprincipleitem.subprincipleitemgroup.subprinciple.name%></h1>
<p><%= @subprincipleitem.subprincipleitemgroup.subprinciple.description%></p>
<p><%= @subprincipleitem.description %><p>
<%= form_with(model: @subprincipleitem) do |form| %>
<div>
<%= form.label :affirmative %> <%= form.check_box :affirmative, {}, true, false %>
</div>
<div>
<%= form.label :evidence %>
<%= form.rich_text_area :evidence %>
</div>
<div>
<%= form.submit %>
</div>
<% end %>