{% extends "masterRead.html" %}

{% block content %}

  <h2>Story #{{ 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>

  <p>
  {% if domainObject.narrative%}
    {{ domainObject.asDictLabels.narrative }}
  {% else %}
    No narrative has been recorded for this story.
  {% endif %}
  </p>

  <h3>Events</h3>
  <div id="raises-table">
  {% if domainObject.raises %}
  <p>These interruptions may happen during (or after) this story.</p>
  <table>
      <th>Interruption</th>
      <th>Next Stories</th>
  {% for assn in domainObject.raises %}
      <tr>
        <td>
    {% if view.canUpdateDomainObject %}
          <a class="dissociate" href="#{{registryPath}}/raises/{{ assn.event.id }}">x</a>
    {% endif %}
          <a href="{{ uriPrefix }}/events/{{ assn.event.id }}/">{{ assn.event.description|escape }}</a>
        </td>
        <td>
    <big>
    {% for storyAssn in assn.event.responses %}
    <a href="{{ uriPrefix }}/stories/{{ storyAssn.story.id }}/">{{ storyAssn.story.description|escape }}.</a>&nbsp;
    {% endfor %}
    </big>
        </td>
      </tr>
  {% endfor %}
    </table>
  {% else %}
  <p>No registered events happen within this story.</p>
  {% endif %}
  </div>
  {% if view.canUpdateDomainObject %}
  <div><form><input type="text" id="raises-completer" class="completer" registryPath="{{registryPath}}/raises"/></form>  </div><br/>
  {% endif %}

  <div id="handles-table">
  {% if domainObject.handles %}
  <p>These interruptions may cause this story.</p>
  <table>
      <th>Cause
      </th>
      <th>Interrupted stories</th>
  {% for assn in domainObject.handles %}
      <tr>
        <td>
    {% if view.canUpdateDomainObject %}
          <a class="dissociate" href="#{{registryPath}}/handles/{{ assn.event.id }}">x</a>
    {% endif %}
          <a href="{{ uriPrefix }}/events/{{ assn.event.id }}/">{{ assn.event.description|escape }}</a>
        </td>
        <td>
        <big>
    {% for storyAssn in assn.event.causes %}
    <a href="{{ uriPrefix }}/stories/{{ storyAssn.story.id }}/">{{ storyAssn.story.description|escape }}.</a>&nbsp;
    {% endfor %}
        </big>
        </td>
      </tr>
  {% endfor %}
    </table>
  {% else %}
  <p>This story doesn't respond to any registered event.</p>
  {% endif %}
  </div>
  {% if view.canUpdateDomainObject %}
  <div><form><input type="text" id="handles-completer" class="completer" registryPath="{{registryPath}}/handles"/></form>  </div><br/>
  {% endif %}

  <h3>Requirements</h3>
  <div id="requirements-table">
  {% if domainObject.requirements %}
  <p>Products supporting this story satisfy the following requirements.
  </p>
  <table>
    <tr>
      <th>Requirement</th>
      <th>Ticket</th>
    </tr>
  {% for assn in domainObject.requirements %}
    <tr>
      <td>
    {% if view.canUpdateDomainObject %}
        <a class="dissociate" href="#{{registryPath}}/requirements/{{ assn.requirement.id }}">x</a>
    {% endif %}
        <a href="{{uriPrefix}}/requirements/{{assn.requirement.id}}/">{{assn.requirement.description|escape}}</a></td>
      <td class="ticket">
    {% if assn.requirement.ticketUrl %}
        <a href="{{assn.requirement.ticketUrl}}" title="{{assn.requirement.ticketUrl}}" target="_blank">&#10004;</a>
    {% else %}
        &nbsp;
    {% endif %}
      </td>
    </tr>
  {% endfor %}
  </table>
  {% else %}
  <p>This story has no requirement for system support.</p>
  {% endif %}
  </div>
  {% if view.canUpdateDomainObject %}
  <div><form><input type="text" id="requirements-completer" class="completer" registryPath="{{registryPath}}/requirements"/></form>  </div><br/>
  {% endif %}

  <h3>Products</h3>
  <div id="products-table">
  {% if domainObject.products %}
  <p>This story has been included within the following product specifications:
  </p>
  <table><th>Product</th>
  {% for assn in domainObject.products %}
    <tr>
      <td>
    {% if view.canUpdateDomainObject %}
        <a class="dissociate" href="#{{registryPath}}/products/{{ assn.product.id }}">x</a>
    {% endif %}
        <a href="{{uriPrefix}}/products/{{assn.product.id}}/">{{assn.product.description|escape}}</a>
      </td>
    </tr>
  {% endfor %}
  </table>
  {% else %}
  <p>This story has not been included within any products specifications at this time.</p>
  {% endif %}
  </div>
  {% if view.canUpdateDomainObject %}
  <div><form><input type="text" id="products-completer" class="completer" registryPath="{{registryPath}}/products"/></form>  </div><br/>
  {% endif %}

  {% if domainObject.ticketUrl %}
  <p>
    <b>Ticket:</b>
    <a href="{{domainObject.ticketUrl|escape}}">{{domainObject.ticketUrl|escape}}</a>
  </p>
  {% 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 %}

