<div class="contact-details-wrapper wrapper-show"
	 ng-class="{'mobile-show': ctrl.show, 'icon-loading': ctrl.loading}">
	<div id="app-navigation-toggle-back" class="details-back icon-download" ng-click="ctrl.clearContact()"></div>
	<div ng-if="ctrl.contact===undefined && !ctrl.loading && !ctrl.init">
		<div id="emptycontent">
			<div class="icon-contacts-dark"></div>
			<h2>{{ctrl.t.noContacts}}</h2>
		</div>
	</div>
	<div ng-if="ctrl.init">
		<div id="emptycontent">
			<div class="icon-contacts-dark"></div>
			<h2>{{ctrl.t.loading}}</h2>
		</div>
	</div>
	<div ng-if="ctrl.contact!==undefined">
		<header class="contactdetails__header" ng-style="{'background-color': (ctrl.contact.uid() | contactColor)}">
			<avatar data="ctrl.contact" ng-class="{'avatar--missing': ctrl.contact.photo()===undefined}"></avatar>
			<div id="details-contact-infos">
				<h2>
					<input type="text" id="details-fullName" class="contactdetails__name" placeholder="{{ctrl.t.placeholderName}}" autocomplete="off" autocorrect="off" spellcheck="false"
						   name="fullname" ng-model="ctrl.contact.fullName" ng-model-options="{ getterSetter: true, debounce: 500 }" ng-change="ctrl.updateContact()" value=""
						   ng-disabled="ctrl.addressBook.readOnly" />
				</h2>
				<div id="details-org-container">
					<input type="text" id="details-org" class="contactdetails__org" placeholder="{{ctrl.t.placeholderOrg}}" autocomplete="off" autocorrect="off" spellcheck="false"
						   name="org" ng-model="ctrl.contact.org" ng-model-options="{ getterSetter: true, debounce: 500 }" ng-change="ctrl.updateContact()" value=""
						   inputresize size="{{ctrl.contact.org().length > 1 ? ctrl.contact.org().length : '1'}}"
						   ng-disabled="ctrl.addressBook.readOnly" />
					<input type="text" id="details-title" class="contactdetails__title" placeholder="{{ctrl.t.placeholderTitle}}" autocomplete="off" autocorrect="off" spellcheck="false"
						   name="title" ng-model="ctrl.contact.title" ng-model-options="{ getterSetter: true, debounce: 500 }" ng-change="ctrl.updateContact()" value=""
						   inputresize size="{{ctrl.contact.title().length > 1 ? ctrl.contact.title().length : '1'}}"
						   ng-disabled="ctrl.addressBook.readOnly" />
				</div>
			</div>
			<div id="details-actions">
				<div class="icon-more-white openMenuButton" ng-click="ctrl.toggleMenu('options')">
				</div>
				<div class="popovermenu bubble menu"
					ng-class="{open: ctrl.openedMenu === 'options'}"
					click-outside="ctrl.closeMenus()"
					outside-if-not="openMenuButton,popovermenu">
					<ul>
						<li ng-if="ctrl.contact.failedProps.length>0">
							<a id="contact-failed-save" ng-click="ctrl.updateContact()" uib-tooltip="Contact failed to save please update" class="icon-checkmark">
								<span>Update</span>
							</a>
						</li>
						<li>
							<a href="{{ctrl.contact.data.url}}" id="contact-export-link" download="{{ ctrl.contact.readableFilename() }}" class="icon-download">
								<span>Download</span>
							</a>
						</li>
						<li ng-if="!ctrl.addressBook.readOnly">
							<a ng-click="ctrl.deleteContact()" class="icon-delete">
								<span>Delete</span>
							</a>
						</li>
					</ul>
				</div>
			</div>
		</header>
		<section>
			<propertyGroup ng-repeat="prop in ctrl.contact.props | toArray | orderDetailItems:'$key'" model="ctrl.contact" data="prop" name="prop.$key" class="property-{{prop.$key}} grid-span-{{prop.length}}"></propertyGroup>

			<div class="select-addressbook" ng-if="ctrl.addressBooks.length > 1 && !ctrl.addressBook.readOnly">
				<label for="details-addressbook">{{ctrl.t.addressBook}}</label>
				<select ng-model="ctrl.addressBook" ng-change="ctrl.changeAddressBook(ctrl.addressBook, oldAddressBook)" id="details-addressbook"
						ng-options="book.displayName for book in ctrl.addressBooks | filter: {readOnly: false}"
						ng-click="oldAddressBook = ctrl.addressBook" ng-init="oldAddressBook = ctrl.addressBook">
				</select>
			</div>
			<select class="add-field" ng-model="ctrl.field" ng-change="ctrl.addField(ctrl.field)" ng-if="!ctrl.addressBook.readOnly">
				<option value=''>{{ctrl.t.selectField}}</option>
				<option ng-repeat="field in ctrl.fieldDefinitions | fieldFilter: ctrl.contact | orderBy : 'name'" value="{{field.id}}">{{field.name}}</option>
			</select>
		</section>
	</div>
</div>
