puphpet/puphpet

View on GitHub
src/PuphpetBundle/Resources/views/postgresql/grant.html.twig

Summary

Maintainability
Test Coverage
{% set uniqid = uniqid ?? uniqid('grant_') %}
{% set idBase = "postgresql-grants-#{uniqid}" %}
{% set nameBase = "postgresql[grants][#{uniqid}]" %}

<div id="{{ idBase }}" data-uniqid="{{ uniqid }}" data-name="{{ nameBase }}"
     class="tab-pane {{ active is defined and active ? 'active' }}">
    <div class="form-group col-xs-12 col-sm-6">
        <label for="{{ idBase }}-role">
            User
        </label>
        <input type="text" id="{{ idBase }}-role"
               name="{{ nameBase }}[role]"
               placeholder="username" class="form-control"
               value="{{ grant.role }}" />
        <div class="help-block">
            User must be defined in section above!
        </div>
    </div>

    <div class="form-group col-xs-12 col-sm-6">
        <label for="{{ idBase }}-db">
            Database
        </label>
        <input type="text" id="{{ idBase }}-db"
               name="{{ nameBase }}[db]"
               placeholder="database_name" class="form-control"
               value="{{ grant.db }}" />
        <div class="help-block">
            Database must be defined in section above!
        </div>
    </div>

    <div class="clearfix"></div>

    <div class="form-group col-xs-12 col-sm-6">
        <label for="{{ idBase }}-privilege">
            Privileges
        </label>
        <select id="{{ idBase }}-privilege"
                name="{{ nameBase }}[privilege][]"
                multiple class="form-control select-tags-editable">
            {% if grant.privilege is defined %}
                {% for privilege in grant.privilege %}
                    <option selected value="{{ privilege }}">{{ privilege }}</option>
                {% endfor %}
            {% endif %}

            {% for privilege in available_privileges %}
                {% if privilege not in grant.privilege %}
                    <option value="{{ privilege }}">{{ privilege }}</option>
                {% endif %}
            {% endfor %}
        </select>
        <div class="help-block">
            Choose "All" or a mix of the others.
        </div>
    </div>

    <div class="clearfix"></div>
</div>