<form id="delete-dashboard-form" method="post" action="<%= ApplicationController.root_context -%>/dashboards/delete">
  <input type="hidden" name="id" value="<%= @dashboard.id -%>">
  <% if @dashboard.global %>
    <input type="hidden" name="global" value="true" />
  <% else %>
    <input type="hidden" name="resource" value="<%= h(params[:resource]) %>"/>
  <% end %>
  <fieldset>
    <div class="modal-head">
      <h2><%= message 'dashboard.delete_confirm_title' -%></h2>
    </div>
    <div class="modal-body">
      <% @dashboard.errors.full_messages.each do |msg| %>
        <p class="error"><%= h msg -%></p>
      <% end %>
      <div class="info">
        <img src="<%= ApplicationController.root_context -%>/images/information.png" style="vertical-align: text-bottom"/>
        <%= message 'dashboard.do_you_want_to_delete_dashboard' -%>
      </div>
    </div>
    <div class="modal-foot">
      <input type="submit" value="<%= message 'dashboard.delete_dashboard' -%>" id="confirm-submit"/>
      <a href="#" onclick="return closeModalWindow()" id="confirm-cancel"><%= h message('cancel') -%></a>
    </div>
  </fieldset>
</form>

<script>
  $j("#delete-dashboard-form").modalForm({success: function (data) {
    var contextParams = data.trim().length > 0 ? '?resource=' + data.trim() : '';
    window.location = baseUrl + '/dashboards' + contextParams;
  }});
</script>
