<h2>Conflicts</h2>

<div class="input-group input-group-sm mt-3 mb-3">
    <div class="input-group-append">
		<span class="input-group-text text-outline-primary">Current country:</span>
		<button class="btn btn-outline-primary dropdown-toggle" data-toggle="dropdown">{{country}}</button>
		<div class="dropdown-menu">
			<small>
				<a class="dropdown-item" href="#!/conflicts/{{c.code}}" 
					ng-repeat="c in info.data.byCountry"
					ng-if="c.nConflicts > 0">
					{{c.desc}} ({{c.code}}) <span class="badge badge-danger float-right">{{c.nConflicts}}</span>
				</a>
			</small>
		</div>
    </div>
</div>

<h5 class="text-muted" ng-if="!loading && conflicts.length == 0">No conflicts</h5>

<p ng-show="conflicts.length > 0">
	<input type="text" class="form-control form-control-sm" ng-model="conflictFilter" placeholder="Filter..." />
</p>

<div class="card text-white mb-3" ng-repeat="w in conflicts | filter:conflictFilter" class="mb-2">
	<div class="card-header bg-primary text-white py-1">Group {{$index+1}}</div>
	<table class="table table-sm">
		<tr ng-repeat="o in w">
			<th style="width:40px" class="text-center">#{{$index+1}}</th>
			<td><a href="#!/edit/0/{{o.id}}" title="{{o.id}}">{{o.name}}</a></td>
			<td style="width:250px"><img ng-src="resources/images/flags/{{o.country}}.gif" /> {{o.city || '-'}}, {{o.country}}</td>
			<td style="width:80px" class="text-right">{{o.type}}</td>
		</tr>
	</table>
	<div class="card-footer bg-secondary py-1">
		<button class="btn btn-sm btn-outline-primary" data-toggle="modal" data-target="#addNewConflictModal" ng-click="prepareAddConflictModal(w)">add</button>
		<div class="btn-group">
			<button class="btn btn-sm btn-primary" ng-click="prepareConflictsModal(w)" data-toggle="modal" data-target="#resolveConflictsModal">resolve manually</button>
			<button class="btn btn-sm btn-warning" ng-click="resolveConflictGroup(w, true)">merge all</button>
			<button class="btn btn-sm btn-danger"  ng-click="resolveConflictGroup(w, false)">all different</button>
		</div>
	</div>
</div>

<resolve-conflicts-modal modal-id="resolveConflictsModal" orgs="orgs" selected-orgs="selectedOrgs"></resolve-conflicts-modal>

<select-org-modal modal-id="addNewConflictModal" selected-org="newConflict" filter-status="approved" on-select="addConflict()"></select-org-modal>

