application/views/schema_modification_error.html.erb
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="robots" content="noindex" />
<title>Spontaneous: Loading...</title>
<link REL="SHORTCUT ICON" HREF="/@spontaneous/static/favicon.ico" />
<link rel="stylesheet" href="<%= style_url("spontaneous") %>" type="text/css" media="screen" charset="utf-8" />
<script type="text/javascript" charset="utf-8" src="<%= script_url("vendor/jquery") %>"></script>
<script type="text/javascript">
var Spontaneous = {};
</script>
<script type="text/javascript">
function _confirm(id) {
var t = 200;
$('.actions li p:visible').slideUp(t);
$(id).slideDown(t)
}
function _cancel(id) {
$(id).slideUp(200)
}
function solution(action, source, dest) {
console.log(action, source, dest);
}
</script>
</head>
<body id="schema-error">
<div id="container">
<%
types = modification.actions.map { |a| a.source.owner}.uniq.compact
%>
<h1>There are unresolved changes to <%= types.length == 0 ? "the schema" : types.map { |o| "<strong>‘#{o}’</strong>"}.join(', ')%></h1>
<% source_file = modification.actions[0].source.source_file %>
<p class="src"><a href="mvim://open?url=file://<%= source_file %>"><%= source_file %></a></p>
<p>Please choose one of the following solutions:</p>
<ul class="actions">
<% modification.actions.each do |action|
id = "#{action.action}-#{action.source.name.to_s.gsub('::', '__')}#{action.dest ? "-#{action.dest.name.to_s.gsub('::', '__')}" : ""}"
%>
<li>
<form action="/@spontaneous/schema/<%= action.action %>" method="post">
<input type="hidden" name="origin" value="<%= env['SCRIPT_NAME'] %>" />
<input type="hidden" name="__token" value="<%= env[S::Rack::CSRF_TOKEN] %>" />
<input type="hidden" name="uid" value="<%= action.source.to_s %>" />
<% if action.dest %>
<input type="hidden" name="ref" value="<%= action.dest.schema_name %>" />
<% end %>
<a onclick="_confirm('#<%= id %>')"><strong><%= action.action.capitalize %></strong> <%= action.category %> ‘<em><%= action.source.name %></em>’ <% if action.dest %>
to ‘<em><%= action.dest.name %></em>’
<% end %>
</a>
<div id="<%= id %>" style="display: none">
<% if action.action == :delete %>
<% case action.category %>
<% when :type %>
<p class="warning">Deleting a type will delete all instances of it from the db and any of their descendents. This cannot be undone so snapshot your database with <code>spot site dump</code> before proceeding.</p>
<% when :box %>
<p class="warning">Deleting a box will delete the contents of all boxes of that type. This cannot be undone so snapshot your database with <code>spot site dump</code> before proceeding.</p>
<% end %>
<% end %>
<p>Are you sure? <a class="button cancel" onclick="_cancel('#<%= id %>')">No</a> <button class="button" onclick="solution('<%= action.action %>', '<%= action.source.name %>', '<%= action.dest ? action.dest.name : '' %>')">Yes</button></p>
</div>
</form>
</li>
<% end %>
</ul>
</div>
</body>
</html>