{% extends "masterRead.html" %}

{% block content %}

  <h2>Event #{{ domainObject.id }}</h2>

  {% if view.canUpdateDomainObject %}
  <form action="{{uriPrefix}}/{{registryPath}}/update/" method="post">
      <input type="submit" value="Update &raquo;" />
      <br />
  </form>
  {% endif %}

  <h2>&quot;{{ domainObject.description|escape }}&quot;</h2>
  <h3>Stories</h3>
  <div id="responses-table">
  {% if domainObject.responses %}
  <p>These stories may respond to this event.</p>
  <table>
    <th>Next Story</th>
    <th>Interruptions</th>
  {% for assn in domainObject.responses %}
    <tr>
      <td>
         {% if view.canUpdateDomainObject %}
        <a class="dissociate" href="#{{registryPath}}/responses/{{ assn.story.id }}">x</a>
         {% endif %}
        <big>
        <a href="{{ uriPrefix }}/stories/{{ assn.story.id }}/">{{ assn.story.description|escape }}</a>
        </big>
      </td>
      <td>
    {% for eventAssn in assn.story.raises %}
      <a href="{{ uriPrefix }}/events/{{ eventAssn.event.id }}/">{{ eventAssn.event.description|escape }}.</a>&nbsp;
    {% endfor %}
      </td>
    </tr>
  {% endfor %}
  </table>
  {% else %}
  <p>No registered stories respond to this event.</p>
  {% endif %}
  </div>
  {% if view.canUpdateDomainObject %}
  <div><form><input type="text" id="responses-completer" class="completer" registryPath="{{registryPath}}/responses"/></form></div><br/>
  {% endif %}

  <div id="causes-table">
  {% if domainObject.causes %}
  <p>These stories may be interrupted by this event.</p>
  <table>
    <th>Story</th>
    <th>Causes</th>
  {% for assn in domainObject.causes %}
    <tr>
      <td>
         {% if view.canUpdateDomainObject %}
        <a class="dissociate" href="#{{registryPath}}/causes/{{ assn.story.id }}">x</a>
         {% endif %}
        <big>
        <a href="{{ uriPrefix }}/stories/{{ assn.story.id }}/">{{ assn.story.description|escape }}</a>
        </big>
      </td>
      <td>
    {% for eventAssn in assn.story.handles %}
        <a href="{{ uriPrefix }}/events/{{ eventAssn.event.id }}/">{{ eventAssn.event.description|escape }}.</a>&nbsp;
    {% endfor %}
      </td>
    </tr>
  {% endfor %}
  </table>
  {% else %}
  <p>No registered stories are interrupted by this event.</p>
  {% endif %}
  </div>
  {% if view.canUpdateDomainObject %}
  <div><form><input type="text" id="causes-completer" class="completer" registryPath="{{registryPath}}/causes"/></form>  </div><br/>
  {% endif %}

  <div id="processes-table">
  <h3>Processes</h3>
  {% if domainObject.processes %}
  <p>This event is recognised by the following processes.</p>
  <table>
    <th>Process</th>
    <th>Goals</th>
  {% for assn in domainObject.processes %}
    <tr>
      <td>
         {% if view.canUpdateDomainObject %}
        <a class="dissociate" href="#{{registryPath}}/processes/{{ assn.process.id }}">x</a>
         {% endif %}
        <a href="{{ uriPrefix }}/processes/{{ assn.process.id }}/">{{ assn.process.description|escape }}</a>
      </td>
      <td>
    {% for goalAssn in assn.process.goals %}
        <a href="{{ uriPrefix }}/goals/{{ goalAssn.goal.id }}/">{{ goalAssn.goal.description|escape }}.</a>&nbsp;
    {% endfor %}
      </td>
    </tr>
  {% endfor %}
  </table>
  {% else %}
  <p>This event is not recognised by any processes at this time.</p>
  {% endif %}
  </div>
  {% if view.canUpdateDomainObject %}
  <div><form><input type="text" id="processes-completer" class="completer" registryPath="{{registryPath}}/processes"/></form>  </div><br/>
  {% endif %}

  {% if view.canUpdateDomainObject %}
  <form action="{{uriPrefix}}/{{registryPath}}/update/" method="post">
    <strong>Do you wish to update this {{domainClassName}}?</strong><br />
    <p>
      <input type="submit" value="Update {{domainClassName}} &raquo;" />
    </p>
  </form>
    {% endif %}
    {% if view.canDeleteDomainObject %}
  <form action="{{uriPrefix}}/{{registryPath}}/delete/" method="post">
    <strong>Do you wish to delete this {{domainClassName}}?</strong><br />
    <p>
      <input type="submit" value="Delete {{domainClassName}} &raquo;" />
    </p>
  </form>
  {% endif %}

{% endblock %}

