{% extends "base.html" %}

{% block title %}{{ _('Project Group') }} #{{ project.id }}: {{ project.name | get_translated_text }} — {{ service_name }}{% endblock %}

{% block stylesheets %}
  {{ super() }}
    <link rel="stylesheet" href="{{ fingerprinted_static('bootstrap-select/css/bootstrap-select.min.css') }}" />
{% endblock %}

{% block template_values %}
  {% do set_template_value("min_grant_user_warning", _('At least one user needs to have grant permissions for this project group.')) %}

  {{ super() }}
{% endblock %}

{% block scripts %}
  {{ super() }}
  <script src="{{ fingerprinted_static('bootstrap-select/js/bootstrap-select.min.js') }}"></script>
  <script type="module" src="{{ fingerprinted_static('sampledb/js/page/project_permissions.js') }}"></script>
{% endblock %}

{% block content %}
  <h3>{{ _('Project Group') }} #{{ project.id }}: {{ project.name | get_translated_text }}</h3>
  <h4>{{ _('Permissions') }}</h4>

  {% set user_may_edit = (permissions_form is not none) %}
  {% if user_may_edit %}
  <div id="alert-no-grant-user">
  </div>
  {% endif %}
  {% set form_url = url_for('.update_project_permissions', project_id=project.id) %}
  {% set fixed_user_permissions = {}  %}
  {% set show_administrators = False %}
  {% set show_instrument_scientists = False %}
  {% set show_all_users = False %}
  {% set read_permissions_description = _('Permission to view this project group\'s objects and their properties, files and comments.') %}
  {% set write_permissions_description = _('Permission to edit this project group and its objects and their properties and add files and comments. Includes Read permissions.') %}
  {% set grant_permissions_description = _('Permission to grant permissions to other users. Includes Write permissions.') %}
  {% include "permissions/permissions.html" %}
  {% if user_may_edit %}
    <div class="modal fade" id="deleteProjectModal" tabindex="-1" role="dialog" aria-labelledby="deleteProjectModalLabel">
      <div class="modal-dialog" role="document">
          <form action="{{ url_for('.project', project_id=project.id) }}" method="post">
            {{ delete_project_form.csrf_token }}
            <input type="hidden" name="remove_all_permissions" value="on" />
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="deleteProjectModalLabel">{{ _('Delete Project Group') }}</h4>
              </div>
              <div class="modal-body">
                {{ _('If you remove all users and groups from a project group, it will be deleted.') }}
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">{{ _('Cancel') }}</button>
                <button type="submit" class="btn btn-danger" id="button-delete-project" name="delete" value="delete">{{ _('Delete Project Group') }}</button>
              </div>
            </div>
          </form>
      </div>
    </div>
    <div class="container">
      <a href="{{ url_for('.project', project_id=project.id) }}" class="btn btn-default col-md-offset-9 col-md-3" style="margin-top: 1em;">{{ _('Cancel') }}</a>
    </div>
  {% endif %}
{% endblock %}
