<!DOCTYPE html>
<html ng-app="docxfeeder">
  <head>
    <meta charset="utf-8" />
    <title>
      KIS - Signets des documents types - Gestion champs
      commentaires/discriminant/obligatoire
    </title>

    <script src="../../../../../lib/angular/angular.js"></script>

    <link
      rel="stylesheet"
      href="../../../../../lib/bootstrap/dist/css/bootstrap.min.css"
    />
    <link
      rel="stylesheet"
      href="../../../../../lib/angular-bootstrap-nav-tree/dist/abn_tree.css"
    />
    <link
      rel="stylesheet"
      href="../../../../../lib/font-awesome/css/font-awesome.min.css"
    />
    <link
      rel="stylesheet"
      href="../../../../../lib/ngDialog/css/ngDialog.min.css"
    />
    <link
      rel="stylesheet"
      href="../../../../../lib/ngDialog/css/ngDialog-theme-default.min.css"
    />
    <link
      rel="stylesheet"
      href="../../../../../lib/ngDialog/css/ngDialog-theme-plain.min.css"
    />
    <link rel="stylesheet" href="feeder.css" />

    <script src="../../../../../lib/angular-bootstrap-nav-tree/dist/abn_tree_directive.js"></script>
    <script src="../../../../../lib/ngDialog/js/ngDialog.min.js"></script>
    <script src="../../../../../lib/angular-translate/angular-translate.js"></script>
    <script src="../../../../../lib/clipboardjs/clipboard.min.js"></script>

    <script src="feeder.js"></script>
  </head>
  <body ng-controller="feeder">
    <div class="container-fluid">
      <script type="text/ng-template" id="copybutton.html">
        <button class="btn btn-default btn-xs copyKey"
                data-clipboard-text="{{tocopy}}"
                ng-click="uglyNotif(tocopy)">
            <i class="fa fa-clipboard" ></i>
        </button>
      </script>
      <div ng-if="!showBody">
        <div class="alert alert-danger">
          Cet écran doit être utilisé depuis l'application KIS.
        </div>
      </div>

      <div ng-if="showBody">
        <div class="cssnotif" ng-class="{'xshow':shownotif.idx>=0}">
          <div class="title" ng-if="feederMode=='feeder'">
            Copié dans le presse papiers :
          </div>
          <div class="copied">{{copiedString}}</div>
        </div>

        <div class="ftop">
          <div class="mainTitle">Catégories</div>
          <div class="mainTree">
            <abn-tree
              tree-data="tree"
              tree-control="treectrl"
              on-select="treehandler(branch)"
            ></abn-tree>
          </div>
        </div>

        <div class="mainTitle fdata">
          <div
            class="btn btn-default"
            ng-if="feederMode=='discriminant' && currentBranch.type"
            ng-click="saveObligatoireDiscriminant()"
          >
            <i class="fa fa-save"></i> Enregistrer la configuration
          </div>
          <div
            class="btn btn-default resetDiscriminant"
            ng-if="feederMode=='discriminant' && currentBranch.type"
            ng-click="resetObligatoireDiscriminant()"
          >
            <i class="fa fa-times"></i> Réinitialiser la configuration
          </div>
          Données
        </div>
        <div class="fbottom">
          <div ng-if="loadingBranch" class="loadingBranch">
            <i class="fa fa-spin fa-spinner"></i>
          </div>
          <div class="alert alert-danger" ng-if="currentBranch.data == ''">
            Aucune donnée, penser à lancer l'extraction depuis l'administration.
          </div>

          <div
            ng-if="currentBranch.data && !loadingBranch && currentBranch.data.parts"
            class="branches {{feederMode}}"
          >
            <div
              ng-repeat="part in currentBranch.data.parts track by $index"
              ng-init="partIndex = $index"
              class="branchpart"
            >
              <label class="xcollapse" for="x-{{$index}}"
                >{{ part.label }}</label
              >
              <input id="x-{{$index}}" type="checkbox" name="wtv" />
              <div class="xcollapseicon">
                <i class="fa fa-chevron-up xclose"></i>
                <i class="fa fa-chevron-down open"></i>
              </div>
              <div class="feeditemwrapper">
                <div
                  ng-repeat="item in part.data track by $index"
                  ng-init="itemIndex=$index"
                  ng-class="{'active': copied.idx==itemIndex}"
                >
                  <div ng-if="item.type=='kis_separator'" class="separator feeditem">
                    {{ item.label}}
                    <span class="info fa fa-info-circle"
                          ng-if="item.info">
                      {{ item.info }}
                    </span>
                  </div>
                  <div
                    ng-if="item.type=='ignored' && item.reason !=='_doublon_'"
                    class="alert alert-warning ignored"
                  >
                    {{ item.reason}}
                  </div>

                  <div
                    ng-if="item.type!='kis_separator' && item.type!='ignored'"
                    class="feeditem"
                  >
                    <div class="discriminantonly obligatoire">
                      <label for="ob-{{partIndex+'_'+$index}}">
                        <input
                          type="checkbox"
                          name="ob[]"
                          id="ob-{{partIndex+'_'+$index}}"
                          class="obcb"
                          ng-model="obligatoireDiscriminant.obligatoire[item.key].value"
                        />
                        <span>obligatoire </span>
                      </label>

                      <div
                        class="btn btn-default btn-xs addcomment"
                        ng-show="obligatoireDiscriminant.obligatoire[item.key].value"
                        ng-click="addCommentDialog(item.key,'obligatoire')"
                        ng-class="{'hasComment':obligatoireDiscriminant.obligatoire[item.key].text}"
                      >
                        <i class="fa fa-comment-o"></i>
                      </div>
                    </div>
                    <div class="desc">
                      {{ item.description }}
                      <span class="type">
                        ({{ item.type }})
                      </span>
                      <button
                        ng-if="feederMode=='discriminant' &&  item.type=='textarea'"
                        class="btn btn-sm"
                        ng-class="hasValue(item) == true ? 'btn-info' : 'btn-default'"
                        ng-click="getCommentItem(item)"
                      >
                        <i class="fa fa-commenting-o"></i>
                      </button>
                      <span class="info fa fa-info-circle" ng-if="item.info">
                        {{ item.info }}
                      </span>
                    </div>
                    <div class="keypicker">
                      <div ng-if="!item.values" class="pickable solo feedonly">
                        <div
                          ng-include="'copybutton.html'"
                          ng-init="tocopy='#{'+stripCDATA(item.key)+'}';addToCopyList(item.description,tocopy);idx=itemIndex"
                        ></div>
                        <span class="key">
                          {{ '#{'+stripCDATA(item.key)+'}' }}</span
                        >
                      </div>
                      <div ng-if="item.values">
                        <div
                          ng-repeat="v in item.values track by $index"
                          class="pickable"
                        >
                          <div class="discriminantonly discriminanttoggle">
                            <label
                              for="disc-{{partIndex+'_'+itemIndex+'_'+$index}}"
                            >
                              <input
                                type="checkbox"
                                name="disc[]"
                                id="disc-{{partIndex+'_'+itemIndex+'_'+$index}}"
                                class="disccb"
                                ng-model="obligatoireDiscriminant.discriminant[item.key+'.'+v.value].value"
                              />
                              <span>discriminant</span>
                            </label>
                            <div
                              class="btn btn-default btn-xs addcomment"
                              ng-show="obligatoireDiscriminant.discriminant[item.key+'.'+v.value].value"
                              ng-click="addCommentDialog(item.key+'.'+v.value,'discriminant')"
                              ng-class="{'hasComment':obligatoireDiscriminant.discriminant[item.key+'.'+v.value].text}"
                            >
                              <i class="fa fa-comment-o"></i>
                            </div>
                          </div>
                          <div
                            class="feedonly"
                            ng-include="'copybutton.html'"
                            ng-init="tocopy='#{'+stripCDATA(item.key)+'-CB-'+v.value+'}';addToCopyList(item.description,tocopy);idx=itemIndex"
                          ></div>
                          <div class="sdesc">{{ v.description }}</div>
                          <div class="key feedonly">
                            {{ '#{'+stripCDATA(item.key)+'-CB-'+v.value+'}' }}
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>

            <div style="padding: 25px;">
              <button
                class="btn btn-default copyKey"
                data-clipboard-text="{{getAvailableBranchDataAsText()}}"
                ng-click="uglyNotif('Données copiées')"
              >
                <i class="fa fa-clipboard"></i> Obtenir la liste de toutes les
                données disponibles
              </button>
            </div>
            <div style="padding: 25px;">
              <div class="alert alert-info">
                <div>
                  <i class="fa fa-info-circle"></i> Il est possible de choisir
                  le format d'affichage des dates en ajoutant un suffixe au
                  signet.<br /><br />
                  Par exemple, pour une date au 20 septembre 2018 à 15h30 dont
                  le signet est #{a} :
                </div>

                <br />
                #{a-format_date_defaut} : <b>20/09/2018</b><br />
                #{a-format_date_jour} : <b>20</b><br />
                #{a-format_date_nom_jour} : <b>Jeudi</b><br />
                #{a-format_date_mois} : <b>09</b><br />
                #{a-format_date_nom_mois} : <b>Septembre</b><br />
                #{a-format_date_annee} : <b>2018</b><br />
                #{a-format_date_heure} : <b>15</b><br />
                #{a-format_date_horaire} : <b>15h30</b>
              </div>
            </div>
          </div>
          <div
            ng-if="currentBranch.type === 'elements_filiere_commentaire' && !loadingBranch"
            class="branches {{feederMode}} searcherEF"
          >
            <div class="searchBlock">
              <div class="col-xs-4">
                <div class="panel panel-default panelPadding">
                  <div class="row center-block">
                    <div class="col-xs-12">
                      <label class="small"> Type d'élément de filière </label>
                      <select
                        ng-options="type.alias for type in tabType | orderBy:'alias'"
                        ng-model="search.type"
                        ng-change="canSearch('type')"
                        class="form-control"
                      ></select>
                    </div>
                  </div>
                  <div class="row center-block">
                    <div
                      class="col-xs-12"
                      ng-if="search.common || search.type.type !=='all_elements'"
                    >
                      <label class="small"> Elément de filière </label>
                      <select
                        ng-options="element.alias for element in elementsFiliere | filter: {type : search.type.type} | orderBy:'alias'  "
                        ng-model="search.element"
                        ng-change="canSearch('element')"
                        ng-disabled="!search.enabled.element"
                        class="form-control"
                      ></select>
                    </div>
                  </div>
                  <div class="row center-block">
                    <div class="col-xs-12">
                      <label class="small"> Type de contrôle </label>
                      <select
                        ng-options="controle.label_court for controle in typeFormulaire"
                        ng-model="search.controle"
                        ng-change="canSearch('controle', 'element_filiere_commentaire')"
                        ng-disabled="!search.enabled.controle"
                        class="form-control"
                      ></select>
                    </div>
                  </div>
                </div>
              </div>

              <div class="col-xs-8">
                <div class="panel panel-default">
                  <div class="panel-heading">
                    <div
                      class="row feeditemwrapper"
                      ng-repeat="attribute in listeAttributes"
                    >
                      <div class="feeditem">
                        <div class="desc">
                          {{ attribute.alias }}
                          <span class="type">
                            (texte supérieur à 250 caractères)
                          </span>
                          <div class="discriminantonly obligatoire">
                            <button
                              ng-if="feederMode=='discriminant'"
                              class="btn btn-sm text-right"
                              ng-class="hasValue(attribute) == true ? 'btn-info' : 'btn-default'"
                              ng-click="getCommentItem(attribute, search.element)"
                            >
                              <i class="fa fa-commenting-o"></i>
                            </button>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div
            ng-if="currentBranch.type === 'elements_filiere_templater' && !loadingBranch"
            class="branches {{feederMode}} searcherEF"
          >
            <div class="searchBlock">
              <div class="col-xs-4">
                <div class="panel panel-default panelPadding">
                  <div class="row center-block">
                    <div class="col-xs-12">
                      <label class="small"> Type d'élément de filière </label>
                      <select
                        ng-options="type.alias for type in tabType | orderBy:'alias'"
                        ng-model="search.type"
                        ng-change="canSearch('type')"
                        class="form-control"
                      ></select>
                    </div>
                  </div>
                  <div class="row center-block">
                    <div
                      class="col-xs-12"
                      ng-if="search.common || search.type.type !=='all_elements'"
                    >
                      <label class="small"> Elément de filière </label>
                      <select
                        ng-options="element.alias for element in elementsFiliere | filter: {type : search.type.type} | orderBy:'alias'  "
                        ng-model="search.element"
                        ng-change="canSearch('element')"
                        ng-disabled="!search.enabled.element"
                        class="form-control"
                      ></select>
                    </div>
                  </div>
                  <div class="row center-block">
                    <div class="col-xs-12">
                      <label class="small"> Type de contrôle </label>
                      <select
                        ng-options="controle.label_court for controle in typeFormulaire"
                        ng-model="search.controle"
                        ng-change="canSearch('controle')"
                        ng-disabled="!search.enabled.controle"
                        class="form-control"
                      ></select>
                    </div>
                  </div>
                  <br />
                  <div
                    class="row center-block"
                    ng-show="data.selectedAttribute !== {}"
                  >
                    <div class="col-xs-12">
                      <label class="form-check-label small">
                        <input
                          type="checkbox"
                          ng-disabled="!search.enabled.controle"
                          ng-model="search.generique"
                          name="generique"
                          ng-change="canSearch('controle')"
                          class="form-check-input"
                        />
                        Inclure les caractéristiques de l'élément de filière
                      </label>
                    </div>
                  </div>
                  <br />
                  <div class="row center-block">
                    <div class="col-xs-12">
                      <label class="small">
                        Configuration des signets à récupérer
                      </label>
                      <select
                        ng-options="config.alias for config in config_signet"
                        ng-model="search.config"
                        ng-change="canSearch('config')"
                        ng-disabled="!search.enabled.config"
                        class="form-control"
                      ></select>
                    </div>
                  </div>
                  <div class="row center-block">
                    <div
                      class="col-xs-12"
                      ng-if="search.type.type !=='all_elements'"
                    >
                      <label class="small"> Liste des attributs </label>
                      <select
                        ng-options="attribute.alias for attribute in listeAttributes"
                        ng-model="data.selectedAttribute"
                        ng-class="{{attribute.class}}"
                        ng-change="getValueFeeder()"
                        ng-disabled="!search.enabled.attribute"
                        class="form-control"
                      ></select>
                    </div>
                  </div>
                  <br />
                  <div
                    class="row center-block"
                    ng-show="data.selectedAttribute !== {}"
                  >
                    <div class="col-xs-12">
                      <label class="form-check-label small">
                        <input
                          type="checkbox"
                          ng-model="search.template"
                          name="template"
                          ng-change="canSearch('fromTemplate')"
                          class="form-check-input"
                        />
                        Template
                      </label>
                    </div>
                  </div>
                </div>
              </div>

              <div class="col-xs-8">
                <div class="panel panel-default">
                  <div class="panel-heading">
                    <div class="row center-block">
                      <div
                        class="col-xs-12 alert alert-danger"
                        ng-if="search.template"
                      >
                        Tous les signets de template doivent être placés entre
                        les signets : <br />
                        #{set_element_filiere-debut} <br />
                        #{set_element_filiere-fin}
                      </div>
                    </div>
                    <div class="row spbrow">
                      <div class="row">
                        <div
                          class="col-xs-12 text-center"
                          ng-show="data.selectedAttribute.name != null"
                        >
                          Copie de(s) signet(s)
                          <span
                            ng-include="'copybutton.html'"
                            ng-click="tocopy=getElementToCopy(true);idx=itemIndex"
                          ></span>
                        </div>
                      </div>
                      <div class="col-xs-12">
                        <div
                          class="small"
                          ng-show="data.selectedAttribute.name != null"
                          ng-repeat="a in keyToShow track by $index"
                        >
                          <span ng-class="a.br == true   ? 'setCarriage' : '' ">
                            {{a.label}}
                          </span>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>
