{% load i18n %}

    <div class="modal" id="conditions-form-modal" tabindex="-1">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" tabindex="-1">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h2 class="modal-title">
                        <span ng-hide="service.values.id">{% trans 'Create condition' %}</span>
                        <span ng-show="service.values.copy">{% trans 'Copy condition' %}</span>
                        <span ng-show="service.values.id && !service.values.copy">{% trans 'Update condition' %}</span>
                    </h2>
                </div>

                <div class="modal-body">
                    <div class="copy-block" ng-show="service.values.copy">
                        <p>
                            {% trans 'Please enter the values for the copy of the condition below and change at least the <strong>key</strong>.' %}
                        </p>
                        <p>
                            {% trans 'Other properties can be changed once the new condition is created.' %}
                        </p>
                    </div>
                    <div class="row">
                        <div class="col-sm-6">
                            <div class="form-group" ng-class="{'has-error': service.errors.uri_prefix }">
                                <label class="control-label" for="uri_prefix">
                                    {{ meta.Condition.uri_prefix.verbose_name }}
                                </label>

                                <div class="input-group">
                                    <input class="form-control"
                                           id="condition_uri_prefix"
                                           type="text"
                                           ng-model="service.values.uri_prefix" />

                                    <span class="input-group-btn">
                                        <button type="button" class="btn btn-default"
                                            title="{% trans 'Insert default URI Prefix' %}"
                                            ng-click="service.values.uri_prefix = service.settings.default_uri_prefix">

                                            <span class="fa fa-magic"></span>
                                        </button>
                                    </span>
                                </div>

                                <p class="help-block">
                                    {{ meta.Condition.uri_prefix.help_text }}
                                </p>

                                <ul class="help-block list-unstyled" ng-show="service.errors.uri_prefix">
                                    <li ng-repeat="error in service.errors.uri_prefix">
                                        {$ error $}
                                    </li>
                                </ul>
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <formgroup
                                data-id="condition_key"
                                data-type="text"
                                data-label="{{ meta.Condition.key.verbose_name }}"
                                data-help="{{ meta.Condition.key.help_text }}"
                                data-model="service.values.key"
                                data-errors="service.errors.key">
                            </formgroup>
                        </div>
                    </div>

                    <div ng-hide="service.values.copy">
                        <formgroup
                            data-id="condition_comment"
                            data-type="textarea"
                            data-label="{{ meta.Condition.comment.verbose_name }}"
                            data-help="{{ meta.Condition.comment.help_text }}"
                            data-model="service.values.comment"
                            data-errors="service.errors.comment">
                        </formgroup>
                        <formgroup
                            data-id="condition_locked"
                            data-type="checkbox"
                            data-label="{{ meta.Condition.locked.verbose_name }}"
                            data-help="{{ meta.Condition.locked.help_text }}"
                            data-model="service.values.locked"
                            data-errors="service.errors.locked">
                        </formgroup>
                        <formgroup
                            data-id="condition_source"
                            data-type="selectnumber"
                            data-label="{{ meta.Condition.source.verbose_name }}"
                            data-help="{{ meta.Condition.source.help_text }}"
                            data-model="service.values.source"
                            data-errors="service.errors.source"
                            data-options="service.attributes"
                            data-options-label="uri"
                            data-options-null="1"
                            data-quicksearch="true">
                        </formgroup>
                        <formgroup
                            data-id="condition_relation"
                            data-type="select"
                            data-label="{{ meta.Condition.relation.verbose_name }}"
                            data-help="{{ meta.Condition.relation.help_text }}"
                            data-model="service.values.relation"
                            data-errors="service.errors.relation"
                            data-options="service.relations"
                            data-options-label="text">
                        </formgroup>
                        <formgroup
                            data-id="condition_target_text"
                            data-type="text"
                            data-label="{{ meta.Condition.target_text.verbose_name }}"
                            data-help="{{ meta.Condition.target_text.help_text }}"
                            data-model="service.values.target_text"
                            data-errors="service.errors.target_text">
                        </formgroup>
                        <formgroup
                            data-id="condition_target_option"
                            data-type="selectnumber"
                            data-label="{{ meta.Condition.target_option.verbose_name }}"
                            data-help="{{ meta.Condition.target_option.help_text }}"
                            data-model="service.values.target_option"
                            data-errors="service.errors.target_option"
                            data-options="service.options"
                            data-options-label="label"
                            data-options-null="1"
                            data-quicksearch="true">
                        </formgroup>
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        {% trans 'Close' %}
                    </button>
                    <button type="button" class="btn btn-primary"
                            ng-click="service.submitFormModal('conditions')">
                        {% trans 'Save' %}
                    </button>
                </div>
            </div>
        </div>
    </div>
