{% extends "masterRead.html" %}

{% block content %}

  <h3>Process #{{ domainObject.id }}</h3>

  <h2>&quot;{{ domainObject.description|escape }}&quot;</h2>

  <h3>Goals</h3>
  <div id="goals-table">
  {% if domainObject.goals %}
  <p>The following have been identified as goals of this process:
  </p>
  <table>
    <th>Goal</th>
  {% for assn in domainObject.goals %}
    <tr>
      <td>
     {% if view.canUpdateDomainObject %}
        <a class="dissociate" href="#{{registryPath}}/goals/{{ assn.goal.id }}">x</a>
     {% endif %}
        <a href="{{ uriPrefix }}/goals/{{ assn.goal.id }}/">{{ assn.goal.description|escape }}</a>
      </td>
    </tr>
  {% endfor %}
  </table>
  {% else %}
  <p>No goals have been identified for this process.</p>
  {% endif %}
  </div>
  {% if view.canUpdateDomainObject %}
  <div><form><input type="text" id="goals-completer" class="completer" registryPath="{{registryPath}}/goals"/></form>  </div><br/>
  {% endif %}

  <h3>Events</h3>
  <div id="events-table">
  {% if domainObject.events %}
  <p>The following have been identified as events of this process:
  </p>
  <table>
    <th>Event</th><th>Stories</th>
  {% for assn in domainObject.events %}
    <tr>
      <td>
     {% if view.canUpdateDomainObject %}
        <a class="dissociate" href="#{{registryPath}}/events/{{ assn.event.id }}">x</a>
     {% endif %}
        <a href="{{ uriPrefix }}/events/{{ assn.event.id }}/">{{ assn.event.description|escape }}</a>
      </td>
      <td>
    {% for respAssn in assn.event.responses %}
      <a href="{{ uriPrefix }}/stories/{{ respAssn.story.id }}/">{{ respAssn.story.description|escape }}.</a>&nbsp;
    {% endfor %}
      </td>
      </tr>
  {% endfor %}
  </table>
  {% else %}
  <p>This process hasn't registered any events.</p>
  {% endif %}
  </div>
  {% if view.canUpdateDomainObject %}
  <div><form><input type="text" id="events-completer" class="completer" registryPath="{{registryPath}}/events"/></form>  </div><br/>
  {% endif %}

  <h3>Collections</h3>
  <div id="collections-table">
  {% if domainObject.collections %}
  <p>This process has been included in the following collections:
  </p>
  <table>
    <th>Collection</th>
  {% for assn in domainObject.collections %}
    <tr>
      <td>
     {% if view.canUpdateDomainObject %}
        <a class="dissociate" href="#{{registryPath}}/collections/{{ assn.collection.id }}">x</a>
     {% endif %}
        <a href="{{ uriPrefix }}/collections/{{ assn.collection.id }}/">{{ assn.collection.description|escape }}</a>
      </td>
      </tr>
  {% endfor %}
  </table>
  {% else %}
  <p>This process hasn't been registered in any collections.</p>
  {% endif %}
  </div>
  {% if view.canUpdateDomainObject %}
  <div><form><input type="text" id="collections-completer" class="completer" registryPath="{{registryPath}}/collections"/></form>  </div><br/>
  {% endif %}

  {% if domainObject.listProducts %}
  <h3>Products</h3>
  <p>The following products support the stories of this process:
  </p>
  <table>
    <th>Product</th><th>Stories</th>
  {% for product in domainObject.listProducts %}
    <tr>
      <td><a href="{{ uriPrefix }}/products/{{ product.id }}/">{{ product.description|escape }}</a></td>
      <td>
    {% for assn in product.stories %}
      <a href="{{ uriPrefix }}/stories/{{ assn.story.id }}/">{{ assn.story.description|escape }}.</a>&nbsp;
    {% endfor %}
      </td>
      </tr>
  {% endfor %}
  </table>
  {% 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 %}

