{% extends "p4l/p4l_base.html" %}
{% load static %}
{% load i18n %}

{% block page_title %}{% trans 'Record' %} {{ params.identifier }} - {% trans 'View' %}{% endblock %}

{% block css_page %}
  <link rel="stylesheet" href="{% static 'p4l/lib/css/smoothness/jquery-ui-1.10.3.custom.css' %}">
  <link rel="stylesheet" href="{% static 'p4l/css/semantictree.css' %}">
{% endblock %}

{% block js_page %}
<script type="text/javascript" src="{% url 'django.views.i18n.javascript_catalog' %}"></script>
<script type="text/javascript" src="{% static 'p4l/lib/angular/angular.min.js' %}"></script>
<script type="text/javascript" src="{% static 'p4l/lib/angular/angular-route.min.js' %}"></script>
<script type="text/javascript" src="{% static 'p4l/lib/angular/angular-resource.min.js' %}"></script>
<script type="text/javascript" src="{% static 'p4l/lib/angular-mod/angular-translate.min.js' %}"></script>
<script type="text/javascript" src="{% static 'p4l/lib/jquery-1.9.1.js' %}"></script>
<script type="text/javascript" src="{% static 'p4l/lib/jquery-ui-1.10.3.custom.min.js' %}"></script>
<script type="text/javascript" src="{% static 'p4l/lib/jquery.jstree.js' %}"></script>
<script type="text/javascript" src="{% static 'p4l/js/p4l.js' %}"></script>
<script type="text/javascript" src="{% static 'p4l/js/semantictree.js' %}"></script>
<script type="text/javascript">
    angular.module("recordApp")
        .value('context', {
            record_id: "{{record.identifier}}",
            uri_labels: angular.fromJson('{{uri_labels | safe | addslashes}}'),
            csrf_token: "{{ csrf_token }}",
            urls: {
                base_static: "{% get_static_prefix %}",
                record_api: "{% url 'record-detail' identifier=':recordId' %}".replace("\%3A",":"),
                previous: "{{request.GET.previous}}",
                home: "{% url 'p4l_home' %}"
            },
            query_dicts: angular.fromJson('{{ query_dicts | safe | addslashes}}'),
            languages_list: angular.fromJson('{{ languages_list | safe | addslashes}}'),
        })
        .config(['$translateProvider', function($translateProvider) {
            $translateProvider.translations(catalog); //catalog is declared in django.views.i18n.javascript_catalog
        }]);
    
</script>
{% endblock %}

{% block content %}
<div class="row text-right">
    <a class="btn btn-default" href="{% url 'p4l_record_view' slug=record.identifier %}">{% trans 'View the record' %} <i class="glyphicon glyphicon-eye-open"></i></a>
</div>
{% verbatim %}
<div ng-app="recordApp" ng-controller="RecordCtrl" ng-cloak>
<form name="recordForm">
<table class="table record-table">
  <thead>
    <tr><td>{{'property' | translate}}</td><td>{{'value' | translate }}</td></tr>
  </thead>
  <tbody>
    <tr>
      <td>URI</td>
      <td>{{record.uri}}</td>
    </tr>
    <tr>
      <td>{{ 'identifier' | translate}}</td>
      <td>{{record.identifier}}</td>
    </tr>
    <tr>
      <td>{{ 'subjects' | translate}}</td>
      <td><add-sem-uri list="record.subjects" listname="subjects" placeholder="{{'Add a new subject' | translate}}"></add-sem-uri></td>
    </tr>
    <tr>
      <td>{{ 'themes' | translate}}</td>
      <td><add-sem-uri list="record.themes" listname="themes" placeholder="{{'Add a new theme' | translate}}"></add-sem-uri></td>
    </tr>
    <tr>
      <td>{{ 'countries' | translate}}</td>
      <td><add-sem-uri list="record.countries" listname="countries" placeholder="{{'Add a new country' | translate}}"></add-sem-uri></td>
    </tr>
    <tr>
        <td>{{ 'notes' | translate}}</td>
        <td><textarea id="record-notes-input" class="form-control" ng-model="record.notes"></textarea></td>
    </tr>
    <tr>
      <td>{{ 'issns' | translate }}</td>
      <td><object-list form-template="issnForm" disp-template="" object-list="record.issns" 
                       object-fields='["issn", "lang"]' table="true" size-fields='[7, 2]' label-fields='["Issns","Language"]'></object-list></td>
    </tr>
    <tr>
        <td>{{ 'isbns' | translate }}</td>
        <td><object-list form-template="isbnForm" disp-template="" object-list="record.isbns" 
                         object-fields='["isbn", "lang"]' table="true" size-fields='[7, 2]' label-fields='["Isbns","Language"]'></object-list></td>
    </tr>
    <tr>
      <td>{{ 'document code' | translate }}</td>
      <td><object-list form-template="documentCodeForm" disp-template="" object-list="record.documentCodes" 
                       object-fields='["documentCode"]' table="true" size-fields='[9]' label-fields='["Document code"]'></object-list></td>
    </tr>
    <tr>
      <td>{{ 'language' | translate }}</td>
      <td><simple-sem-uri val="record.language" listname="languages" placeholder="{{'Modify the language' | translate}}"></simple-sem-uri></td>
    </tr>
    <tr>
      <td>{{ 'other languages' | translate }}</td>
      <td><add-sem-uri list="record.otherLanguages" listname="languages" placeholder="{{'Add a new language' | translate}}"></add-sem-uri></td>
    </tr>
    <tr>
      <td>{{ 'titles' | translate }}</td>
      <td><object-list form-template="titleForm" disp-template="" object-list="record.titles"
                       object-fields='["title", "lang"]' table="true" size-fields='[7, 2]' label-fields='["Title","Language"]'></object-list></td>
    </tr>
    <tr>
      <td>{{ 'abstracts' | translate }}</td>
      <td><object-list form-template="abstractForm" disp-template="" object-list="record.abstracts"
                       object-fields='["abstract", "lang"]' table="true" size-fields='[7, 2]' label-fields='["Abstract","Language"]'></object-list></td>
    </tr>
    <tr>
      <td>{{ 'added titles' | translate }}</td>
      <td><object-list form-template="titleForm" disp-template="" object-list="record.addedTitles"
                       object-fields='["title", "lang"]' table="true" size-fields='[7, 2]' label-fields='["Title","Language"]'></object-list></td>
    </tr>
    <tr>
      <td>{{ 'titles main document' | translate }}</td>
      <td><object-list form-template="titleForm" disp-template="" object-list="record.titlesMainDocument"
                       object-fields='["title", "lang"]' table="true" size-fields='[7, 2]' label-fields='["Title","Language"]'></object-list></td>
    </tr>
    <tr>
      <td>{{ 'edition statement' | translate }}</td>
      <td><textarea id="record-editionStatement-input" class="form-control" ng-model="record.editionStatement"></textarea></td>
    </tr>
    <tr>
      <td>{{ 'imprints' | translate }}</td>
      <td><object-list form-template="imprintForm" disp-template="" object-list="record.imprints" 
                       object-fields='["imprintCity","publisher","imprintDate", "lang"]' table="true" 
                       size-fields='[3,2,2,2]' label-fields='["City","Publisher","Date","Language"]' ></object-list></td>
    </tr>
    <tr>
      <td>{{ 'collations' | translate }}</td>
      <td><object-list form-template="collationForm" disp-template="" object-list="record.collations"
                       object-fields='["collation", "lang"]' table="true" size-fields='[7, 2]' label-fields='["collation","Language"]'></object-list></td>
    </tr>
    <tr>
      <td>{{ 'volume issues' | translate }}</td>
      <td><object-list form-template="volumeIssueForm" disp-template="" object-list="record.volumeIssues"
                       object-fields='["volume", "number", "lang"]' table="true" 
                       size-fields='[4, 3, 2]' label-fields='["Volume","Number","Language"]'></object-list></td>
    </tr>
    <tr>
      <td>{{ 'project names' | translate }}</td>
      <td><add-sem-uri list="record.projectNames" listname="projects" placeholder="{{'Add a new project' | translate}}"></add-sem-uri></td>
    </tr>
    <tr>
      <td>{{ 'periodicals' | translate }}</td>
      <td><object-list form-template="periodicalForm" disp-template="" object-list="record.periodicals"
                       object-fields='["label", "lang"]' table="true" size-fields='[7, 2]' label-fields='["Label","Language"]'></object-list></td>
    </tr>
    <tr>
      <td>{{ 'meetings' | translate }}</td>
      <td><object-list form-template="meetingForm" disp-template="" object-list="record.meetings"
                       object-fields='["label", "meetingNumber", "meetingPlace", "meetingDate", "meetingYear", "lang"]' table="true"
                       size-fields='[3, 1, 2, 1, 1, 1]' label-fields='["Label","Number","Place","Date","Year","Language"]' ></object-list></td>
    </tr>
    <tr>
      <td>{{ 'series' | translate }}</td>
      <td><object-list form-template="serieForm" disp-template="" object-list="record.series" 
                       object-fields='["title", "volume", "lang"]' table="true" 
                       size-fields='[5, 2, 2]' label-fields='["Title","Volume","Language"]'></object-list></td>
    </tr>
    <tr>
      <td>{{ 'authors' | translate }}</td>
      <td><object-list form-template="personForm" disp-template="" object-list="record.authors"
                       object-fields='["name"]' table="true" size-fields='[9]'></object-list></td>
    </tr>
    <tr>
      <td>{{ 'subject persons' | translate }}</td>
      <td><object-list form-template="personForm" disp-template="" object-list="record.subjectPersons"
                       object-fields='["name"]' table="true" size-fields='[9]'></object-list></td>
    </tr>
    <tr>
      <td>{{ 'subject corporate bodies' | translate }}</td>
      <td><add-sem-uri list="record.subjectCorporateBodies" listname="organizations" placeholder="{{'Add a new organization' | translate}}"></add-sem-uri></td>
    </tr>
    <tr>
      <td>{{ 'subject meetings' | translate }}</td>
      <td><object-list form-template="meetingForm" disp-template="" object-list="record.subjectMeetings"
                       object-fields='["label", "meetingNumber", "meetingPlace", "meetingDate", "meetingYear", "lang"]' table="true"
                       size-fields='[3, 1, 2, 1, 1, 1]' label-fields='["Label","Number","Place","Date","Year","Language"]' ></object-list></td>
    </tr>
    <tr>
      <td>{{ 'corporate authors' | translate }}</td>
      <td><add-sem-uri list="record.corporateAuthors" listname="organizations" placeholder="{{'Add a new organization' | translate}}"></add-sem-uri></td>
    </tr>
    <tr>
      <td>{{ 'Urls' | translate }}</td>
      <td><object-list form-template="urlForm" disp-template="urlDisp" object-list="record.urls" 
                       object-fields='["address", "display", "accessLevel"]' table="true"
                       size-fields='[5, 2, 2]' label-fields='["Address", "Display", "Access level"]'></object-list></td>
    </tr>
    <tr>
      <td>{{ 'record type' | translate }}</td>
      <td><simple-sem-uri val="record.recordType" listname="types" placeholder="{{'Modify the record type' | translate}}"></simple-sem-uri></td>
    </tr>
    <tr>
      <td>{{ 'is document part' | translate }}</td>
      <td><input type="checkbox" ng-model="record.isDocumentPart" /></td>
    </tr>
    <tr>
      <td>{{ 'is multilingual' | translate }}</td>
      <td><input type="checkbox" ng-model="record.isMultilingual" /></td>
    </tr>
  </tbody>
</table>
<button type="submit" class="btn btn-primary" id="record-submit" ng-click="submitRecord()">
    <span ng-class="['glyphicon', saving?'spinner':'glyphicon-save']"></span>
    <span>{{ 'Save' | translate }}</span>
</button>
<a class="btn btn-primary" id="record-back" href="{{getPreviousUrl()}}">
    <span class="glyphicon glyphicon-arrow-left"></span>
    <span>{{ 'Cancel' | translate }}</span>
</a>
</form>
</div>
{% endverbatim %}
<div class="row text-right">
    <a class="btn btn-default" href="{% url 'p4l_record_view' slug=record.identifier %}">{% trans 'View the record' %} <i class="glyphicon glyphicon-eye-open"></i></a>
</div>
{% endblock %}