<span class="addressBookName">{{ctrl.addressBook.displayName}}</span>
<span class="utils">
	<span class="action" ng-show="ctrl.canExport">
		<a href="{{ctrl.addressBook.url}}?export"
			  id="addressBooklist-icon download"
			  title="Download"
			  class="icon-download">
		</a>
	</span>
    <span class="action">
        <span
            class="addressbooklist-icon icon-public"
            title="Show URL"
            ng-click="ctrl.toggleShowUrl()">
        </span>
    </span>
    <span class="action">
        <span
            class="addressbooklist-icon icon-share"
            title="Share Addressbook"
            ng-click="ctrl.toggleSharesEditor(ctrl.addressBook)">
        </span>
    </span>
    <span class="action">
        <span
            class="addressbooklist-icon icon-delete"
			ng-class="{hidden: ctrl.list.length === 1}"
            title="Delete Addressbook"
            ng-click="ctrl.deleteAddressBook()">
        </span>
    </span>
</span>
    <input class="addressBookUrl" ng-show="ctrl.showUrl" type="url" value="{{ctrl.addressBook.url}}" readonly />
<div class="addressBookShares" ng-show="ctrl.editingShares">
	<i ng-show="ctrl.loadingSharees" class="glyphicon glyphicon-refresh"></i>
	<input
		type="text"
		class="shareeInput"
		uib-typeahead="sharee.display for sharee in ctrl.findSharee($viewValue)"
		typeahead-on-select="ctrl.onSelectSharee($item)"
		typeahead-loading="ctrl.loadingSharees"
		ng-model="ctrl.selectedSharee"
		placeholder="Share with users or groups">
	<ul class="addressBook-share-list">
		<li ng-repeat="userShare in ctrl.addressBook.sharedWith.users" class="addressBook-share-item">
			<span class="shareeIdentifier">{{ userShare.displayname }}</span> -
			<input type="checkbox" name="editable"
				   id="checkbox_sharedWithUser_{{ctrl.addressBook.tmpId}}_{{$id}}"
				   ng-model="userShare.writable" value="edit"
				   ng-change="ctrl.updateExistingUserShare(userShare.id, userShare.writable)">
			<label for="checkbox_sharedWithUser_{{ctrl.addressBook.tmpId}}_{{$id}}"> can edit</label>
			<span class="utils">
				<span class="action">
					<span href="#"
						  id="addressBooklist-icon delete"
						  data-id="{{ ctrl.addressBook.uri }}"
						  title="Delete"
						  class="icon-delete"
						  ng-click="ctrl.unshareFromUser(userShare.id)">
					</span>
				</span>
			</span>
		</li>
		<li ng-repeat="groupShare in ctrl.addressBook.sharedWith.groups" class="calendar-share-item">
			{{ groupShare.displayname }} (group) -
			<input type="checkbox" name="editable"
				   id="checkbox_sharedWithGroup_{{ctrl.addressBook.tmpId}}_{{$id}}"
				   ng-model="groupShare.writable" value="edit"
				   ng-change="ctrl.updateExistingGroupShare(groupShare.id, groupShare.writable)">
			<label for="checkbox_sharedWithGroup_{{ctrl.addressBook.tmpId}}_{{$id}}"> can edit</label>
			<span class="utils hide">
				<span class="action">
					<span href="#"
						  id="addressBooklist-icon delete"
						  data-id="{{ ctrl.addressBook.uri }}"
						  title="Delete"
						  class="icon-delete"
						  ng-click="ctrl.unshareFromGroup(groupShare.id)">
					</span>
				</span>
			</span>
		</li>
	</ul>
</div>
