<h3 class="modalTitle">
    {{ 'hpo.common.mapping' | translate }} > {{ expressions.label | translate }}
</h3>
<form id="formulaire-feature" ng-submit="confirm(expressions)">
    <div class="modalBody marginTop">
        <div class="col-md-12"
                ng-show="(expressions.type === 'matrix' && expressions.header &&
                                                expressions.column && expressions.column_source==expressions.header_source&&((expressions.column_source=='attribute'&&
                                                expressions.header.name === expressions.column.name)||(expressions.column_source=='criteria'&&
                                                expressions.header === expressions.column))) ||
                        (expressions.type === 'auxiliaire' && expressions.column_param &&
                                                    expressions.header_param &&
                                                    (expressions.column_param.name === expressions.header_param.name))">
          <div class="alert alert-warning">
            <translate>hpo.multicritere.construct.samevalues</translate>
          </div>
        </div>

        <div class="form-group clearfix">
          <div class="col-xs-12">
              <label class="required">
                <translate>hpo.multicritere.parameters.type.title</translate> :
              </label>
               &nbsp;&nbsp;<translate>{{ 'hpo.multicritere.parameters.type.' + expressions.type }}</translate>
          </div>
        </div>


        <div class="form-group clearfix marginTop">
          <div class="col-xs-12">
              <label class="required"><translate>hpo.multicritere.parameters.column</translate></label>
          </div>

          <div class="col-xs-12">
            <div class="col-xs-6">
              <span><translate>hpo.multicritere.parameters.parameter</translate></span>
            </div>

            <div class="col-xs-6">
               <select
                class="form-control"
                ng-model="expressions.column_source"
                ng-change="onChangeSourceMatrix('column')"
                required>
                  <option value='attribute'>{{'hpo.data.prepare.attributes' | translate}}</option>
                  <option value='criteria' ng-if="expressions.type === 'matrix'">{{'hpo.data.prepare.critèreResult' | translate}}</option>
                </select>
              
            </div>
          </div>

          <div class="col-xs-12">
            <div class="col-xs-6">
              <select
                class="form-control"
                ng-model="expressions.column_param"
                ng-options="attr as attr.displayName for attr in expressions.colonnes | orderBy:'toString()'"
                required/>

            </div>
            <div class="col-xs-6">
              <select
                class="form-control"
                ng-model="expressions.column"
                ng-if="expressions.column_source=='attribute'"
                ng-options="attr as attr.alias for attr in expressions.attributes | orderBy:'alias'"
                required/>

                <div ng-if="expressions.column_source=='criteria'">
                  <div class="panel panel-primary panel-hpo">
                      <h5 class="adjust-positions text-left">
                        <div  style="margin-top:-5px;text-align: center;">
                          <select class="btn btn-mini btn-default"
                                  ng-model="selected_critereas_categorie"
                                  ng-init="selected_critereas_categorie = selected_critereas_categorie || informations.critereas_categories[0]"
                                  ng-options="categorie for categorie in informations.critereas_categories | orderBy:'toString()'"/>
                        </div>
                      </h5>
                      <div class="row marginTop">
                          <div class="col-md-12 marginTop">
                            <div class="alert alert-info" ng-show="!critereas || critereas.length === 0">
                              <translate>hpo.common.nodata</translate>
                            </div>
                            <div class="col-md-12"
                                ng-hide="!informations.critereas_categories || informations.critereas_categories.length === 0">
                              <div class="search">
                                <span class="fa fa-filter"></span>
                                <input type="text" ng-model="filtercritereas" class="form-control"
                                    placeholder="{{ 'hpo.data.prepare.filter' | translate }}"
                                ng-keydown="filtercritereas = $event.keyCode === 27 ? '' : filtercritereas "/>
                                <a ng-show="filtercritereas.length > 0" ng-click="filtercritereas = ''">
                                  <span class="fa fa-times-circle"></span>
                                </a>
                              </div>
                            </div>
                          </div>
                      </div>
                      <div class="row adjust-positions marginBottom" css-manipulate='{"mh":"275px","ovy":"auto"}'>
                        <div class="col-md-12 nopaddingLeft" ng-repeat="criterea in critereas | orderBy:'name'">
                          <div class="input-group" ng-show="filterFunc(filtercritereas,criterea.name) && criterea.uid !== currentParameter.uid  &&
                                         criterea.categorie === selected_critereas_categorie">
                             <button type="button"
                                         ng-class="expressions.selectedItemColumn==criterea.name ? 'btn btn btn-primary btn-scientific btn-mini form-control' : 'btn btn-scientific btn-default btn-mini form-control'" 
                                         ng-click="addSupplementCriterea(criterea , 'criterea' , undefined, currentParameter,undefined,undefined,'column')"
                                         ng-show="filterFunc(filtercritereas,criterea.name) && criterea.uid !== currentParameter.uid  &&
                                          criterea.categorie === selected_critereas_categorie">{{ criterea.name }}</button>
                            <span class="input-group-addon btn btn-info" ng-hide="criterea.noinfo"
                                ng-click="getCritereaInfo(criterea)">
                                <i class="fa fa-info"></i>
                            </span>
                          </div>
                        </div>
                      </div>
                  </div>
              </div>

            </div>
          </div>
        </div>

        <div class="form-group clearfix marginTop">
          <div class="col-xs-12">
              <label class="required">
                <translate ng-show="expressions.type === 'matrix'">hpo.multicritere.parameters.header</translate>
                <translate ng-show="expressions.type === 'auxiliaire'">hpo.multicritere.parameters.value</translate>
              </label>
          </div>
          <div class="col-xs-12">
            <div class="col-xs-6  col-md-offset-3"  ng-show="expressions.type === 'auxiliaire'">
              <span><translate>hpo.multicritere.parameters.parameter</translate></span>
            </div>

            <div class="col-xs-6  col-md-offset-3" ng-show="expressions.type === 'matrix'">
              <select
                class="form-control"
                ng-model="expressions.header_source"
                ng-change="onChangeSourceMatrix('header')"
                required>
                  <option value='attribute'>{{'hpo.data.prepare.attributes' | translate}}</option>
                  <option value='criteria' ng-if="expressions.type === 'matrix'">{{'hpo.data.prepare.critèreResult' | translate}}</option>
                </select>
            </div>
          </div>

          <div class="col-xs-12">
            <div class="col-xs-6 col-md-offset-3" ng-show="expressions.type === 'auxiliaire'">
              <select
                class="form-control"
                ng-model="expressions.header_param"
                ng-options="attr as attr.displayName for attr in expressions.colonnes | orderBy:'toString()'"
                required/>

            </div>
            <div class="col-xs-6 col-md-offset-3" ng-show="expressions.type === 'matrix'">
              <select
                class="form-control"
                ng-model="expressions.header"
                 ng-if="expressions.header_source=='attribute'"
                ng-options="attr as attr.alias for attr in expressions.attributes | orderBy:'alias'"
                required/>
              <div ng-if="expressions.header_source=='criteria'">
                  <div class="panel panel-primary panel-hpo">
                      <h5 class="adjust-positions text-left">
                        <div  style="margin-top:-5px;text-align: center;">
                          <select class="btn btn-mini btn-default"
                                  ng-model="selected_critereas_categorie"
                                  ng-init="selected_critereas_categorie = selected_critereas_categorie || informations.critereas_categories[0]"
                                  ng-options="categorie for categorie in informations.critereas_categories | orderBy:'toString()'"/>
                        </div>
                      </h5>
                      <div class="row marginTop">
                          <div class="col-md-12 marginTop">
                            <div class="alert alert-info" ng-show="!critereas || critereas.length === 0">
                              <translate>hpo.common.nodata</translate>
                            </div>
                            <div class="col-md-12"
                                ng-hide="!informations.critereas_categories || informations.critereas_categories.length === 0">
                              <div class="search">
                                <span class="fa fa-filter"></span>
                                <input type="text" ng-model="filtercritereas" class="form-control"
                                    placeholder="{{ 'hpo.data.prepare.filter' | translate }}"
                                ng-keydown="filtercritereas = $event.keyCode === 27 ? '' : filtercritereas "/>
                                <a ng-show="filtercritereas.length > 0" ng-click="filtercritereas = ''">
                                  <span class="fa fa-times-circle"></span>
                                </a>
                              </div>
                            </div>
                          </div>
                      </div>
                      <div class="row adjust-positions marginBottom" css-manipulate='{"mh":"275px","ovy":"auto"}'>
                        <div class="col-md-12 nopaddingLeft" ng-repeat="criterea in critereas | orderBy:'name'">
                          <div class="input-group" ng-show="filterFunc(filtercritereas,criterea.name) && criterea.uid !== currentParameter.uid  &&
                                         criterea.categorie === selected_critereas_categorie">
                             <button type="button"
                                         ng-class="expressions.selectedItemHeader==criterea.name ? 'btn btn btn-primary btn-scientific btn-mini form-control' : 'btn btn-scientific btn-default btn-mini form-control'" 
                                         ng-click="addSupplementCriterea(criterea , 'criterea' , undefined, currentParameter,undefined,undefined,'header')"
                                         ng-show="filterFunc(filtercritereas,criterea.name) && criterea.uid !== currentParameter.uid  &&
                                          criterea.categorie === selected_critereas_categorie">{{ criterea.name }}</button>
                            <span class="input-group-addon btn btn-info" ng-hide="criterea.noinfo"
                                ng-click="getCritereaInfo(criterea)">
                                <i class="fa fa-info"></i>
                            </span>
                          </div>
                        </div>
                      </div>
                  </div>
              </div>

            </div>
          </div>
        </div>

          <hr>

          <!-- Single button -->
          <div class="row nomargin">
              <div class="col-xs-12 text-right nopadding-col marginBottom">
                  <button class="btn btn-primary" type="submit"
                          ng-disabled="!expressions.column_param ||
                                      !expressions.column ||
                                      !expressions.column_param.name ||
                                      (expressions.type === 'matrix' && !expressions.header) || (expressions.type === 'matrix' && expressions.header &&
                                                expressions.column && expressions.column_source==expressions.header_source&&((expressions.column_source=='attribute'&&
                                                expressions.header.name === expressions.column.name)||(expressions.column_source=='criteria'&&
                                                expressions.header === expressions.column))) ||
                        (expressions.type === 'auxiliaire' &&  !expressions.header_param) || (expressions.type === 'auxiliaire' &&  expressions.header_param &&  expressions.column_param &&
                                                    expressions.header_param &&
                                                    (expressions.column_param.name === expressions.header_param.name))">
                      <translate>common.apply</translate>
                  </button>
              </div>
          </div>


  </div>
</form>
