<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at
        
  http://www.apache.org/licenses/LICENSE-2.0
    
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->
<div ng-repeat="groupSchema in dynamicForm.groupSchemas">
  <uib-accordion ng-if="getByGroup(groupSchema).length">
    <div uib-accordion-group heading="{{groupSchema| translate}}"
         ng-init="status = {isOpen: (groupSchema == 'own')}" is-open="status.isOpen"
         class="breadcrumb-header panel panel-default">

      <div id="attribute" class="form-group" ng-repeat="derSchema in getByGroup(groupSchema) track by $index">
        <label for="derSchema.key">{{derSchema.labels[language] || derSchema.simpleKey}}
          <span ng-if="derSchema.mandatoryCondition === 'true'">*</span>
        </label>
        <div ng-if="!derSchema.multivalue">
          <dynamic-derived-attribute schema="derSchema" user="user" index="0"></dynamic-derived-attribute>
          <validation-message name="{{derSchema.simpleKey}}"/>
        </div>

        <div ng-if="derSchema.multivalue">
          <div ng-repeat="field in dynamicForm.attributeTable[derSchema.key].fields track by $index" 
               ng-model='dynamicForm.attributeTable[derSchema.key].fields[$index]'>
            <dynamic-derived-attribute schema="derSchema" user="user" index="$index"></dynamic-derived-attribute>
            <span>
              <button class="btn btn-secondary btn-default btn-sm minus" ng-if="$index > 0" type="button" 
                      ng-click="removeAttributeField(derSchema.key, $index)">
                <i class="fa fa-minus" title="Remove value"></i>
              </button>
            </span>
          </div>
          <span>
            <button class="btn btn-secondary btn-default btn-sm" type="button" 
                    ng-click="addAttributeField(derSchema.key)">
              <i class="fa fa-plus" title="Add value"></i>
            </button>
          </span>
        </div>
      </div>
    </div>
  </uib-accordion>
</div>