<h3>
  <translate>adminparam.publishinfo_title</translate> {{ngDialogData.name}}
</h3>

<div>
  <label>{{"adminparam.publishinfo_state" | translate}}</label>
  <select ng-model="paramState" ng-change="">
    <option value=""> ----- </option>
    <option value="public">
      {{ 'common.public' | translate}}
    </option>
    <option value="private">
      {{ 'common.private' | translate}}
    </option>
  </select>
  <button title="{{'common.save' | translate}}" ng-click="savePublishInfos()">
    <span class="glyphicon glyphicon-floppy-disk"></span>
  </button>
</div>

<div ng-show="paramState=='public'">
  <div bs-active-pane="tabs.activeTab" ng-model="tabs.activeTab" bs-tabs>
    <div ng-repeat="tab in tabs" title="{{tab.title}}" bs-pane></div>
  </div>

  <div ng-show="tabs.activeTab == 0">
    <label>{{"adminparam.publishinfo_userslist" | translate}}</label>
    <div class="row publish-user-flex">
      <div class="col-xs-2 publish-user-pre">{{"common.choose" | translate}} :</div>
      <div class="col-xs-9">
        <div gcautocompletedeprecated list="users" res="listSelectedUser" elementtype="'utilisateur'"></div>
      </div>
      <div class="col-xs-1">
        <button title="{{'common.delete' | translate}}" ng-click="deleteUsers()">
          <i class="fa fa-times"></i>
        </button>
      </div>
    </div>
    <div ng-show="publishedUsers.length">
      <input
        type="checkbox"
        ng-model="userCheckboxes.checked"
        name="filter-checkbox"
        value=""
      />
      <span ng-if="!userCheckboxes.checked"
        >{{"common.selectall" | translate}}</span
      >
      <span ng-if="userCheckboxes.checked"
        >{{"common.deselectall" | translate}}</span
      >
    </div>

    <table class="table">
      <tr ng-repeat="login in publishedUsers">
        <td width="30" style="text-align: center">
          <input type="checkbox" ng-model="userCheckboxes.items[login]" />
        </td>
        <td>
          {{login}}
        </td>
      </tr>
    </table>
  </div>
  <div ng-show="tabs.activeTab == 1">
    <label>{{"adminparam.publishinfo_roleslist" | translate}}</label>

    <div class="row publish-user-flex">
      <div class="col-xs-2 publish-user-pre">{{"common.choose" | translate}} :</div>
      <div class="col-xs-9">
        <div gcautocompletedeprecated list="roles" res="listSelectedRole" elementtype="'rôle'"></div>
      </div>
      <div class="col-xs-1">
        <button title="{{'common.delete' | translate}}" ng-click="deleteRole()">
          <i class="fa fa-times"></i>
        </button>
      </div>
    </div>
    <div ng-show="publishedRoles.length">
      <input
        type="checkbox"
        ng-model="roleCheckboxes.checked"
        name="filter-checkbox"
        value=""
      />
      <span ng-if="!roleCheckboxes.checked"
        >{{"common.selectall" | translate}}</span
      >
      <span ng-if="roleCheckboxes.checked"
        >{{"common.deselectall" | translate}}</span
      >
    </div>

    <table class="table">
      <tr ng-repeat="role in publishedRoles">
        <td width="30" style="text-align: center">
          <input type="checkbox" ng-model="roleCheckboxes.items[role]" />
        </td>
        <td>
          {{role}}
        </td>
      </tr>
    </table>
  </div>
  <div ng-show="tabs.activeTab == 2">
    <label>{{"adminparam.publishinfo_groupslist" | translate}}</label>
    <div class="row publish-user-flex">
      <div class="col-xs-2 publish-user-pre">{{"common.choose" | translate}} :</div>
      <div class="col-xs-9">
        <div gcautocompletedeprecated list="groups" res="listSelectedGroup" elementtype="'groupe'"></div>
      </div>
      <div class="col-xs-1">
        <button title="{{'common.delete' | translate}}" ng-click="deleteGroup()">
          <i class="fa fa-times"></i>
        </button>
      </div>
    </div>
    <div ng-show="publishedGroups.length">
      <input
        type="checkbox"
        ng-model="groupCheckboxes.checked"
        id="select_all"
        name="filter-checkbox"
        value=""
      />
      <span ng-if="!groupCheckboxes.checked"
        >{{"common.selectall" | translate}}</span
      >
      <span ng-if="groupCheckboxes.checked"
        >{{"common.deselectall" | translate}}</span
      >
    </div>
    <table class="table">
      <tr ng-repeat="group in publishedGroups">
        <td width="30" style="text-align: center">
          <input type="checkbox" ng-model="groupCheckboxes.items[group]" />
        </td>
        <td>
          {{group}}
        </td>
      </tr>
    </table>
  </div>

  <br />
  <div
    class="row"
    ng-if="(publishedGroups.length||publishedRoles.length||publishedUsers.length)&&displayPublishedEmail()"
  >
    <div class="col-xs-12" ng-if="renderNumEmail()>0">
      <input
        type="checkbox"
        ng-model="publishedEmail.value"
        ng-true-value="true"
      />
      Envoyer {{renderNumEmail()}}
      <span ng-show="renderNumEmail()>1">Emails</span>
      <span ng-show="renderNumEmail()<=1">Email</span>
    </div>
    <div class="col-xs-2" ng-if="publishedEmail.value">
      Sujet
    </div>
    <div class="col-xs-10" ng-if="publishedEmail.value">
      <input
        type="text"
        ng-model="publishedEmail.subject"
        class="form-control"
      />
    </div>
    <div class="col-xs-12" ng-if="publishedEmail.value">
      Contenu
    </div>
    <div class="col-xs-12" ng-if="publishedEmail.value">
      <div text-angular ng-model="publishedEmail.content"></div>
    </div>
    <div class="col-xs-12" ng-if="publishedEmail.value" style="margin-top: 5px">
      <button
        type="button"
        class="btn btn-default pull-right"
        ng-disabled="!renderNumEmail()"
        ng-click="sendPublishedEmail(publishedEmail.subject,publishedEmail.content)"
      >
        Envoyer
      </button>
    </div>
  </div>
</div>
