[%- PROCESS 'edit/details/macros.tt' -%]

<table class="details edit-relationship-type">
  [%- IF edit.display_data.link_type -%]
      <tr>
        <th>[% l('Entity types:') %]</th>
        <td>[% edit.display_data.link_type.entity0_type %]</td>
        <td>[% edit.display_data.link_type.entity1_type %]</td>
      </tr>
  [%- END -%]
  [%- display_word_diff(l('Name:'),
                        html_escape(edit.data.old.name),
                        html_escape(edit.data.new.name)) ||
      '<tr><th>' _ l('Name:') _ '</th><td colspan=2>' _ html_escape(edit.data.old.name) _ '</td></tr>' -%]

  [%- display_html_diff(l('Description:'),
                        edit.data.old.description,
                        edit.data.new.description) ||
      '<tr><th>' _ l('Description:') _ '</th><td colspan=2>' _ html_escape(edit.data.old.description) _ '</td></tr>' -%]

  [%- display_word_diff(l('Link phrase:'),
                        html_escape(edit.data.old.link_phrase),
                        html_escape(edit.data.new.link_phrase)) -%]

  [%- display_word_diff(l('Reverse link phrase:'),
                        html_escape(edit.data.old.reverse_link_phrase),
                        html_escape(edit.data.new.reverse_link_phrase)) -%]

  [%- display_word_diff(l('Long link phrase:'),
                        html_escape(edit.data.old.long_link_phrase),
                        html_escape(edit.data.new.long_link_phrase)) -%]

  [%- display_word_diff(l('Child order:'),
                        html_escape(edit.data.old.child_order),
                        html_escape(edit.data.new.child_order)) -%]

  [%- IF edit.data.old.is_deprecated != edit.data.new.is_deprecated %]
  [%- display_full_change(l('Deprecated:'),
                          yesno(edit.data.old.is_deprecated),
                          yesno(edit.data.new.is_deprecated)) -%]
  [% END %]

  [%- IF edit.data.old.has_dates != edit.data.new.has_dates %]
  [%- display_full_change(l('Allows dates:'),
                          yesno(edit.data.old.has_dates),
                          yesno(edit.data.new.has_dates)) -%]
  [% END %]

  [% IF edit.data.old.entity0_cardinality != edit.data.new.entity0_cardinality %]
  [%- display_word_diff(l('entity0 cardinality:'),
                        link_type_cardinality_name(edit.data.old.entity0_cardinality),
                        link_type_cardinality_name(edit.data.new.entity0_cardinality)) -%]
  [% END %]
  [% IF edit.data.old.entity1_cardinality != edit.data.new.entity1_cardinality %]
  [%- display_word_diff(l('entity1 cardinality:'),
                        link_type_cardinality_name(edit.data.old.entity1_cardinality),
                        link_type_cardinality_name(edit.data.new.entity1_cardinality)) -%]
  [% END %]

  [% IF edit.display_data.attributes %]
  <tr>
    <th>[% l('Attributes:') %]</th>
    <td class="old">
      <ul>
        [% FOR attribute=edit.display_data.attributes.old %]
        <li>
          [% attribute.type.name %]: [% attribute.min %]-[% attribute.max %]
        </li>
        [% END %]
      </ul>
    </td>
    <td class="new">
      <ul>
        [% FOR attribute=edit.display_data.attributes.new %]
        <li>
          [% attribute.type.name %]: [% attribute.min %]-[% attribute.max %]
        </li>
        [% END %]
      </ul>
    </td>
  </tr>
  [% END %]

  [% IF edit.data.old.parent_id != edit.data.new.parent_id %]
  <tr>
    <th>[% l('Parent') %]</th>
    <td class="old">[% edit.display_data.parent.old.name %]</td>
    <td class="new">[% edit.display_data.parent.new.name %]</td>
  </tr>
  [% END %]

  [% IF edit.data.old.documentation != edit.data.new.documentation;
       display_word_diff(l('Documentation:'),
                         html_escape(edit.data.old.documentation),
                         html_escape(edit.data.new.documentation));
     END %]

  <tr>
    <th>[% l('Examples:') %]</th>
    <td class="old">
      <ul>
        [% FOREACH example=edit.display_data.examples.old %]
        <li>
          [% descriptive_link(example.relationship.source); %]
          [% example.relationship.verbose_phrase; %]
          [% descriptive_link(example.relationship.target); %]
          [% relationship_date_text(example.relationship); %]
        </li>
        [% END %]
      </ul>
    </td>
    <td class="new">
      <ul>
        [% FOREACH example=edit.display_data.examples.new %]
        <li>
          [% descriptive_link(example.relationship.source); %]
          [% example.relationship.verbose_phrase; %]
          [% descriptive_link(example.relationship.target); %]
          [% relationship_date_text(example.relationship); %]
        </li>
        [% END %]
      </ul>
    </td>
  </tr>
</table>
