<div class="modal-header">
	<h3 class="modal-title">{{ 'spdTitle' | translate }}</h3>
</div>
<div class="modal-body">

	<div class="well" ng-show="!model">
		{{ 'loading' | translate }}
	</div>

	<form class="form-horizontal" role="form" ng-show="model">

		<!-- Id -->
		<div class="form-group">
			<label class="col-sm-4 control-label">Id</label>
			<div class="col-sm-8">
				<p class="form-control-static">{{ model.id }}</p>
			</div>
		</div>

		<!-- Name (editable) -->
		<lacuna-editable-item description="{{ 'spdTooltipName' | translate }}" on-save="save(key, value)" on-edit="edit('name')" show-description="isEditable" editable="isEditable">
			<item-label>{{ 'name' | translate }}</item-label>
			<item-value>{{ model.name }}</item-value>
			<item-editor>
				<input type="text" class="form-control" ng-model="$editor.data.value">
			</item-editor>
		</lacuna-editable-item>

		<!-- Type (editable) -->
		<lacuna-editable-item description="{{ 'spdTooltipType' | translate }}" on-save="save(key, value)" on-edit="edit('type')" show-description="isEditable" editable="isEditable">
			<item-label>{{ 'spdType' | translate }}</item-label>
			<item-value>{{ 'signaturePolicyType_' + model.type | translate }}</item-value>
			<item-editor>
				<select class="form-control" ng-options="type as ('signaturePolicyType_' + type | translate) for type in policyTypes" ng-model="$editor.data.value"></select>
			</item-editor>
		</lacuna-editable-item>

		<!-- Underlying Policy (editable) -->
		<div ng-hide="model.isReadOnly">
			<lacuna-editable-item description="{{ 'spdTooltipUnderlyingPolicy' | translate }}" on-save="save(key, value)" on-edit="editUnderlyingPolicy()" show-description="isEditable" editable="isEditable">
				<item-label>{{ 'spdUnderlyingPolicy' | translate }}</item-label>
				<item-value>{{ model.underlyingPolicy.name }}</item-value>
				<item-editor>
					<select class="form-control" ng-options="policy.id as policy.name for policy in underlyingPolicies | filter: { 'isReadOnly': true }" ng-model="$editor.data.value"></select>
				</item-editor>
			</lacuna-editable-item>
		</div>

		<!-- Security Context (editable) -->
		<div ng-hide="model.isReadOnly">
			<lacuna-editable-item description="{{ 'spdTooltipSecurityContext' | translate }}" on-save="save(key, value)" on-edit="editSecurityContext()" show-description="isEditable" editable="isEditable">
				<item-label>{{ 'spdSecurityContext' | translate }}</item-label>
				<item-value>
					<span ng-show="model.securityContext">{{ model.securityContext.name }}</span>
					<em ng-hide="model.securityContext">{{ 'default' | translate }}</em>
				</item-value>
				<item-editor>
					<select class="form-control" ng-options="context.id as context.name for context in securityContexts" ng-model="$editor.data.value"></select>
				</item-editor>
			</lacuna-editable-item>
		</div>

		<!-- Timestamp Plan (editable) -->
		<div ng-hide="model.isReadOnly">
			<lacuna-editable-item description="{{ 'spdTooltipTimestampPlan' | translate }}" on-save="save(key, value)" on-edit="editTimestampPlan()" show-description="isEditable" editable="isEditable">
				<item-label>{{ 'spdTimestampPlan' | translate }}</item-label>
				<item-value>
					<span ng-show="model.timestampPlan">{{ model.timestampPlan.name }}</span>
					<em ng-hide="model.timestampPlan">{{ 'default' | translate }}</em>
				</item-value>
				<item-editor>
					<select class="form-control" ng-options="plan.id as plan.name for plan in timestampPlans" ng-model="$editor.data.value"></select>
				</item-editor>
			</lacuna-editable-item>
		</div>

	</form>

</div>
<div class="modal-footer">
	<button class="btn btn-danger pull-left" ng-click="remove()" ng-show="editor.isEnabled">{{ 'remove' | translate }}</button>
	<button class="btn btn-info pull-left" ng-click="testValidation()" ng-show="editor.isEnabled">{{ 'test' | translate }}</button>
	<button class="btn btn-primary" ng-click="close()">{{ 'close' | translate }}</button>
</div>
