<!--
    Copyright (C) 2019 CERN.
    Copyright (C) 2019 Northwestern University.

    Invenio-RDM-Records is free software; you can redistribute it and/or modify it
    under the terms of the MIT License; see LICENSE file for more details.
-->

<div class="row record-elem" ng-repeat="record in vm.invenioSearchResults.hits.hits track by $index">
    <div class="col-xs-12">
        <div class="pull-right view-record hidden-xs">
        <a target="_self" ng-href="/records/{{record.id}}" class="btn btn-default">View</a>
        </div>
        <span class="label label-info" bs-tooltip data-container="div" data-title="Publication date">{{ record.metadata.publication_date|date:'longDate' }}</span>
        <span class="label label-default">{{ record.metadata.resource_type.type }}</span>
        <span ng-switch on="record.metadata.access_right">
        <span ng-switch-when="embargoed">
            <span class="label label-warning titlecase" bs-tooltip data-container="div" data-placement="top">{{ record.metadata.access_right }} Access</span>
        </span>
        <span ng-switch-when="closed">
                <span class="label label-danger titlecase" bs-tooltip data-container="div" data-placement="top">{{ record.metadata.access_right }} Access</span>
        </span>
        <span ng-switch-when="restricted">
            <span class="label label-danger titlecase" bs-tooltip data-container="div" data-placement="top">{{ record.metadata.access_right }} Access</span>
        </span>
        <span ng-switch-default>
            <span class="label label-success titlecase">{{ record.metadata.access_right }} Access</span>
        </span>
        </span>
        <h4><a class="record-title" target="_self" ng-href="/records/{{record.id}}">{{record.metadata.title}}</a></h4>
        <p>
        <span ng-repeat='contributor in record.metadata.contributors'>
            <a target="_self" ng-href="/records/{{record.id}}" class="text-muted">{{ contributor.name }}</a>;
        </span>
        </p>
        <p class="hidden-xs">
            <a class="record-description" target="_self" ng-href="/records/{{record.id}}">
                <span ng-bind-html="record.metadata.description|striptags|limitTo:300">{{ record.metadata.description }}</span>
            </a>
        </p>
        <p>
        <small class="text-muted hidden-xs">
            Uploaded on {{ record.created|date:'longDate' }}
        </small>
        </p>
        <p ng-if="!vm.invenioSearchArgs.all_versions && record.metadata.relations.version[0].count > 1">
        <span class="text-muted hidden-xs"><a href ng-click="vm.invenioSearchArgs.q = 'conceptrecid:' + record.conceptrecid; vm.invenioSearchArgs.all_versions = true; vm.invenioSearchArgs.sort='-version'"><small><i>{{ record.metadata.relations.version[0].count - 1 }} more version(s) exist for this record</i></small></a></span>
        </p>
        <hr />
    </div>
</div>
