<div class="card mb-3">
	<div class="card-header bg-primary text-white py-1">Duplicates</div>
		
	<div class="text-muted card-body" ng-if="duplicates.length == 0">No duplicates</div>
		
	<table class="table table-sm mt-2" ng-if="duplicates.length > 0">
		<thead>
			<tr class="d-flex">
				<th class="col-4 pl-3" style="border-top: none;">Related organization</th>
				<th class="col-1 text-center" style="border-top: none;">Acronym</th>
				<th class="col-2 text-center" style="border-top: none;">Country</th>
				<th class="col-3" style="border-top: none;">Source</th>
				<th class="col-2" style="border-top: none;"></th>
			</tr>
		</thead>
		<tbody>
			<tr class="d-flex" ng-repeat="sr in duplicates">
				<td class="col-4 pl-3">{{sr.oaName}}
					<span class="small" ng-repeat="oid in sr.otherIdentifiers">
						<br /><b>PID ({{oid.type}}): </b>{{oid.id}}
					</span>
					<span class="small"><br /><b>URL: </b><a href="{{sr.oaUrl}}" target="_blank" ng-if="sr.oaUrl">{{sr.oaUrl}}</a></span>
					<br />
					<span title="EC flags" class="badge badge-success" ng-show="sr.ecLegalBody">legal body</span>
					<span title="EC flags" class="badge badge-success" ng-show="sr.ecLegalPerson">legal person</span>
					<span title="EC flags" class="badge badge-success" ng-show="sr.ecNonProfit">non profit</span>
					<span title="EC flags" class="badge badge-success" ng-show="sr.ecResearchOrganization">research organization</span>
					<span title="EC flags" class="badge badge-success" ng-show="sr.ecHigherEducation">higher education</span>
					<span title="EC flags" class="badge badge-success" ng-show="sr.ecInternationalOrganizationEurInterests">international organization Eur interests</span>
					<span title="EC flags" class="badge badge-success" ng-show="sr.ecInternationalOrganization">international organization</span>
					<span title="EC flags" class="badge badge-success" ng-show="sr.ecEnterprise">enterprise</span>
					<span title="EC flags" class="badge badge-success" ng-show="sr.ecSmeValidated">sme validated</span>
					<span title="EC flags" class="badge badge-success" ng-show="sr.ecNutscode">nuts code</span>
				</td>
				<td class="col-1 text-center small">{{sr.oaAcronym}}</td>
				<td class="col-2 text-center small"><img ng-src="resources/images/flags/{{sr.oaCountry}}.gif" /> {{sr.oaCountry}}</td>
				<td class="col-3 small">
					<b>Original Id:</b> <span class="text-monospace">{{sr.oaOriginalId}}</span><br />
					<b>OA Graph Node ID: </b> <span class="text-monospace">{{sr.openaireId}}</span> <a href="/redirect/oa/{{sr.openaireId}}" target="_blank">[try]</a>
					<span ng-if="sr.oaCollectedFrom"><br /><b>Provenance:</b> {{sr.oaCollectedFrom}}</span>
					<span ng-if="sr.createdBy && sr.createdBy != 'dedupWf'"><br /><b>Added by:</b> {{sr.createdBy}}</span>
				</td>
				<td class="col-2 text-right">
					<div class="btn-group btn-group-toggle btn-group-sm" data-toggle="buttons" ng-hide="readonly">
						<label class="btn" ng-class="{'btn-danger' : sr.relType == 'is_different', 'btn-outline-danger' : sr.relType != 'is_different'}"> <input type="radio" autocomplete="off" ng-model="sr.relType"
							value="is_different" ng-class="{'active' : sr.relType == 'is_different'}"><i class="fas fa-times fa-fw"></i>
						</label>
						<label class="btn" ng-class="{'btn-info' : sr.relType == 'suggested', 'btn-outline-info' : sr.relType != 'suggested'}"> <input type="radio" autocomplete="off" ng-model="sr.relType"
							value="suggested" ng-class="{'active' : sr.relType == 'suggested'}"><i class="fas fa-question fa-fw"></i>
						</label>
						<label class="btn" ng-class="{'btn-success' : sr.relType == 'is_similar', 'btn-outline-success' : sr.relType != 'is_similar'}"> <input type="radio" autocomplete="off" ng-model="sr.relType"
							value="is_similar" ng-class="{'active' : sr.relType == 'is_similar'}" /><i class="fas fa-check fa-fw"></i>
						</label>
					</div>
					<div class="btn-group btn-group-sm" ng-show="readonly">
						<label class="btn btn-outline-dark"><i class="fas fa-times fa-fw"></i></label>
						<label class="btn btn-dark"><i class="fas fa-question fa-fw"></i></label>
						<label class="btn btn-outline-dark"><i class="fas fa-check fa-fw"></i></label>
					</div>
				</td>
			</tr>
		</tbody>
	</table>
	
	<div class="card-footer text-right" ng-if="showButtons">
		<button class="btn btn-sm btn-outline-primary" data-toggle="modal" data-target="#addDuplicateModal">add</button>
		<button class="btn btn-sm btn-primary" ng-click="saveFunction()" ng-if="duplicates.length > 0">save</button>
	</div>
	
</div>

<select-org-modal modal-id="addDuplicateModal" selected-org="newDuplicate" filter-status="candidate_dup" on-select="addDuplicate()"></select-org-modal>
