<commit_before>{% extends "pages/template/authenticated.html" %}

{% block content %}
<form action="/user/edit/{{user.uid}}" method="post">
    <input type="hidden" name="{{request.getAttribute('_csrf').parameterName}}"
           value="{{request.getAttribute('_csrf').token}}"/>

    <div class="mdl-grid">
        <div class="mdl-cell mdl-cell--12-col mdl-cell--8-col-tablet mdl-cell--4-col-phone">
            <h2 class="s2act-sectionHeadline">Edit user {{editUserForm.uid}}</h2>
        </div>
        {% set formName = 'editUserForm' %}
        {% set noSpacing = true %}

        {% if hasErrors(formName) %}
        <div class="mdl-cell mdl-cell--12-col mdl-cell--8-col-tablet mdl-cell--4-col-phone">
            <ul class="s2act-messages {{noSpacing ? 's2act-messages--nospacing' : ''}}">
                {% for err in getAllErrors(formName) %}
                <li class="s2act-message s2act-message--error">{{ err }}</li>
                {% endfor %}
            </ul>
        </div>
        {% endif %}
        <div class="mdl-cell mdl-cell--6-col mdl-cell--4-col-tablet mdl-cell--4-col-phone mdl-cell--order-0-phone">
            <div class="s2act-selectfield mdl-selectfield mdl-js-selectfield mdl-selectfield--floating-label">
                <select id="company" name="company" class="mdl-selectfield__select">
                    <option value=""></option>
                    {% for company in companies %}
                    <option value="{{company.key}}" {{isSelected(editUserForm.company,company.key)}}>{{company.value}}
                    </option>
                    {% endfor %}
                </select>
                <div class="mdl-selectfield__icon"><i class="material-icons">arrow_drop_down</i></div>
                <label class="mdl-selectfield__label" for="company">Company</label>
            </div>
            <div
                class="s2act-textfield s2act-textfield__halfWidth mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="text" name="firstName" id="firstName"
                       value="{{ editUserForm.firstName }}" readonly>
                <label class="mdl-textfield__label" for="firstName">Firstname *</label>
            </div>
            <div
                class="s2act-textfield s2act-textfield__halfWidth mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="text" name="lastName" id="lastName"
                       value="{{ editUserForm.lastName }}" readonly>
                <label class="mdl-textfield__label" for="lastName">Lastname *</label>
            </div>
            <div
                class="s2act-textfield s2act-textfield__halfWidth mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="text" name="uid" id="uid"
                       value="{{ editUserForm.uid }}" pattern="\D\D\D\D\D\D\D?\D?"
                       readonly>
                <label class="mdl-textfield__label" for="uid">Username</label>
                <span class="mdl-textfield__error">Please enter the uid with six, seven or eight characters</span>
            </div>
            <div
                class="s2act-textfield s2act-textfield__halfWidth mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="text" name="birthDate" id="birthDate"
                       value="{{ editUserForm.birthDate }}" pattern="\d\d\.\d\d">
                <label class="mdl-textfield__label" for="birthDate">Birthdate</label>
                <span class="mdl-textfield__error">Please enter the Birthdate in pattern dd.MM</span>
            </div>
            <div class="s2act-textfield mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="email" name="email" id="email"
                       value="{{ editUserForm.email }}" readonly>
                <label class="mdl-textfield__label" for="email">E-Mail</label>
            </div>
            <div
                class="s2act-textfield s2act-textfield__halfWidth mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="tel" name="telephoneNumber" id="telephoneNumber"
                       value="{{ editUserForm.telephoneNumber }}" pattern="\+?[0-9 ()]+">
                <label class="mdl-textfield__label" for="telephoneNumber">Telephone</label>
            </div>
            <div
                class="s2act-textfield s2act-textfield__halfWidth mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="tel" name="mobileNumber" id="mobileNumber"
                       value="{{ editUserForm.mobileNumber }}" pattern="\+?[0-9 ()]+">
                <label class="mdl-textfield__label" for="mobileNumber">Mobile</label>
                <span class="mdl-textfield__error">Please define a valid mobile number</span>
            </div>
            <div
                class="s2act-textfield s2act-textfield__halfWidth mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="text" name="passwordChange" id="passwordChange"
                       value="{{ user.prettyLastPasswordChange }}" disabled="disabled">
                <label class="mdl-textfield__label" for="passwordChange">Last password change</label>
            </div>
            <div
                class="s2act-textfield s2act-textfield__halfWidth mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="text" name="modified" id="modified"
                       value="{{ user.prettyModifytimestamp }} by {{ user.prettyModifiersName }}" disabled="disabled">
                <label class="mdl-textfield__label" for="modified">Last modified</label>
            </div>
        </div>
        <div class="mdl-cell mdl-cell--6-col mdl-cell--4-col-tablet mdl-cell--4-col-phone">
            <div class="s2act-textfield mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="tel" name="employeeNumber" id="employeeNumber"
                       value="{{ editUserForm.employeeNumber }}">
                <label class="mdl-textfield__label" for="employeeNumber">Employee number</label>
                <span class="mdl-textfield__error">Please define a valid mobile number</span>
            </div>
            <div class="s2act-selectfield mdl-selectfield mdl-js-selectfield mdl-selectfield--floating-label">
                <select id="team" name="team" class="mdl-selectfield__select">
                    <option value=""></option>
                    {% for department in departments %}
                    <option value="{{department}}" {{isSelected(editUserForm.team,department)}}>{{department}}</option>
                    {% endfor %}
                </select>
                <div class="mdl-selectfield__icon"><i class="material-icons">arrow_drop_down</i></div>
                <label class="mdl-selectfield__label" for="team">Team *</label>
            </div>
            <div class="s2act-textfield mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="text" name="title" id="title"
                       value="{{ editUserForm.title }}">
                <label class="mdl-textfield__label" for="title">Title *</label>
            </div>
            <div class="s2act-selectfield mdl-selectfield mdl-js-selectfield mdl-selectfield--floating-label">
                <select id="location" name="location" class="mdl-selectfield__select">
                    <option value=""></option>
                    {% for location in locations %}
                    <option value="{{location}}" {{isSelected(editUserForm.location,location)}}>{{location}}</option>
                    {% endfor %}
                </select>
                <div class="mdl-selectfield__icon"><i class="material-icons">arrow_drop_down</i></div>
                <label class="mdl-selectfield__label" for="location">Location *</label>
            </div>
            <div class="s2act-selectfield mdl-selectfield mdl-js-selectfield mdl-selectfield--floating-label">
                <select id="type" name="type" class="mdl-selectfield__select">
                    <option value=""></option>
                    {% for type in types %}
                    <option value="{{type}}" {{isSelected(editUserForm.type,type)}}>{{type}}</option>
                    {% endfor %}
                </select>
                <div class="mdl-selectfield__icon"><i class="material-icons">arrow_drop_down</i></div>
                <label class="mdl-selectfield__label" for="type">Type *</label>
            </div>
            <div
                class="s2act-textfield s2act-textfield__halfWidth mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="text" name="entryDate" id="entryDate"
                       value="{{ editUserForm.entryDate }}"
                       pattern="[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9][0-9][0-9]">
                <label class="mdl-textfield__label" for="entryDate">Entry date *</label>
                <span class="mdl-textfield__error">Please enter the entry date in pattern dd.MM.yyyy</span>
            </div>
            <div
                class="s2act-textfield s2act-textfield__halfWidth mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="text" name="exitDate" id="exitDate"
                       value="{{ editUserForm.exitDate }}"
                       pattern="[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9][0-9][0-9]">
                <label class="mdl-textfield__label" for="exitDate">Exit date *</label>
                <span class="mdl-textfield__error">Please enter the exitdate in pattern dd.MM.yyyy</span>
            </div>
        </div>
        <div class="mdl-cell mdl-cell--4-col mdl-cell--4-col-tablet mdl-cell--4-col-phone">
            <div
                class="s2act-textfield s2act-textfield__switch mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                {{switch('Status', 'status', editUserForm.status equals 'active', 'active', 'inactive')}}
            </div>
        </div>
        <div class="mdl-cell mdl-cell--4-col mdl-cell--4-col-tablet mdl-cell--4-col-phone">
            <div
                class="s2act-textfield s2act-textfield__switch mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                {{switch('E-Mail Status', 'mailStatus', editUserForm.mailStatus equals 'active', 'active', 'inactive')}}
            </div>
        </div>
        <div class="mdl-cell mdl-cell--12-col mdl-cell--8-col-tablet mdl-cell--4-col-phone">
            <div class="s2act-buttonRow">
                <input
                    class="s2act-button--right mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary"
                    type="submit" name="save" value="Save"/>
                {% if editUserForm.status equals 'active' %}
                <input
                    class="s2act-button--right mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-color--red"
                    type="submit" name="deactivateUser" value="Deactivate"/>
                {% else %}
                <input
                    class="s2act-button--right mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent"
                    type="submit" name="activateUser" value="Activate"/>
                {% endif %}
                <input
                    class="s2act-button--right mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent"
                    type="submit" name="resetPassword" value="Reset Password"/><commit_msg>added macro<commit_after>{% extends "pages/template/authenticated.html" %}


{% macro inputText(label, fieldName, value, pattern=".*", errorMsg="", halfWidth=true, readonly=false) %}
<div class="s2act-textfield {{ halfWidth ? 's2act-textfield__halfWidth' : '' }} mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
    <input class="mdl-textfield__input" type="text" name="{{ fieldName }}" id="{{ fieldName }}"
           value="{{ value }}" pattern="{{ pattern }}" {{ readonly ? 'readonly' : '' }}>
    <label class="mdl-textfield__label" for="{{ fieldName }}">{{ label }}</label>
    <span class="mdl-textfield__error">{{ errorMsg }}</span>
</div>
{% endmacro %}


{% block content %}

<form action="/user/edit/{{user.uid}}" method="post">
    <input type="hidden" name="{{request.getAttribute('_csrf').parameterName}}"
           value="{{request.getAttribute('_csrf').token}}"/>

    <div class="mdl-grid">
        <div class="mdl-cell mdl-cell--12-col mdl-cell--8-col-tablet mdl-cell--4-col-phone">
            <h2 class="s2act-sectionHeadline">Edit user {{editUserForm.uid}}</h2>
        </div>
        {% set formName = 'editUserForm' %}
        {% set noSpacing = true %}

        {% if hasErrors(formName) %}
        <div class="mdl-cell mdl-cell--12-col mdl-cell--8-col-tablet mdl-cell--4-col-phone">
            <ul class="s2act-messages {{noSpacing ? 's2act-messages--nospacing' : ''}}">
                {% for err in getAllErrors(formName) %}
                <li class="s2act-message s2act-message--error">{{ err }}</li>
                {% endfor %}
            </ul>
        </div>
        {% endif %}
        <div class="mdl-cell mdl-cell--6-col mdl-cell--4-col-tablet mdl-cell--4-col-phone mdl-cell--order-0-phone">
            <div class="s2act-selectfield mdl-selectfield mdl-js-selectfield mdl-selectfield--floating-label">
                <select id="company" name="company" class="mdl-selectfield__select">
                    <option value=""></option>
                    {% for company in companies %}
                    <option value="{{company.key}}" {{isSelected(editUserForm.company,company.key)}}>{{company.value}}
                    </option>
                    {% endfor %}
                </select>
                <div class="mdl-selectfield__icon"><i class="material-icons">arrow_drop_down</i></div>
                <label class="mdl-selectfield__label" for="company">Company</label>
            </div>

            {{ inputText("FirstName *", "firstName", editUserForm.firstName) }}
            {{ inputText("Lastname *", "lastName", editUserForm.lastName) }}
            {{ inputText("Username", "uid", editUserForm.uid, pattern="\D\D\D\D\D\D\D?\D?", errorMsg="Please enter the uid with six, seven or eight characters") }}
            {{ inputText("Birthdate", "birthDate", editUserForm.birthDate, pattern="\d\d\.\d\d", errorMsg="Please enter the Birthdate in pattern dd.MM") }}
            {{ inputText("E-Mail *", "email", editUserForm.email, readonly=true, halfWidth=false) }}
            {{ inputText("Telephone", "telephoneNumber", editUserForm.telephoneNumber, pattern="\+?[0-9 ()]+") }}
            {{ inputText("Mobile", "mobileNumber", editUserForm.mobileNumber, pattern="\+?[0-9 ()]+", errorMsg="Please define a valid mobile number") }}
            {{ inputText("Last password change", "passwordChange", user.prettyLastPasswordChange, readonly=true) }}
            {{ inputText("Last modified", "modified", user.prettyModifytimestamp + " by " + user.prettyModifiersName, readonly=true) }}

        </div>
        <div class="mdl-cell mdl-cell--6-col mdl-cell--4-col-tablet mdl-cell--4-col-phone">

            {{ inputText("Employee number", "employeeeNumber", editUserForm.employeeNumber, errorMsg="Please define a valid mobile number", halfWidth=false) }}

            <div class="s2act-selectfield mdl-selectfield mdl-js-selectfield mdl-selectfield--floating-label">
                <select id="team" name="team" class="mdl-selectfield__select">
                    <option value=""></option>
                    {% for department in departments %}
                    <option value="{{department}}" {{isSelected(editUserForm.team,department)}}>{{department}}</option>
                    {% endfor %}
                </select>
                <div class="mdl-selectfield__icon"><i class="material-icons">arrow_drop_down</i></div>
                <label class="mdl-selectfield__label" for="team">Team *</label>
            </div>

            {{ inputText("Title *", "title", editUserForm.title, halfWidth=false) }}

            <div class="s2act-selectfield mdl-selectfield mdl-js-selectfield mdl-selectfield--floating-label">
                <select id="location" name="location" class="mdl-selectfield__select">
                    <option value=""></option>
                    {% for location in locations %}
                    <option value="{{location}}" {{isSelected(editUserForm.location,location)}}>{{location}}</option>
                    {% endfor %}
                </select>
                <div class="mdl-selectfield__icon"><i class="material-icons">arrow_drop_down</i></div>
                <label class="mdl-selectfield__label" for="location">Location *</label>
            </div>
            <div class="s2act-selectfield mdl-selectfield mdl-js-selectfield mdl-selectfield--floating-label">
                <select id="type" name="type" class="mdl-selectfield__select">
                    <option value=""></option>
                    {% for type in types %}
                    <option value="{{type}}" {{isSelected(editUserForm.type,type)}}>{{type}}</option>
                    {% endfor %}
                </select>
                <div class="mdl-selectfield__icon"><i class="material-icons">arrow_drop_down</i></div>
                <label class="mdl-selectfield__label" for="type">Type *</label>
            </div>

            {{ inputText("Entry date *", "entryDate", editUserForm.entryDate, "[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9][0-9][0-9]", errorMsg="Please enter the entry date in pattern dd.MM.yyyy") }}
            {{ inputText("Exit date *", "exitDate", editUserForm.exitDate, "[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9][0-9][0-9]", errorMsg="Please enter the exit date in pattern dd.MM.yyyy") }}
        </div>
        <div class="mdl-cell mdl-cell--4-col mdl-cell--4-col-tablet mdl-cell--4-col-phone">
            <div
                class="s2act-textfield s2act-textfield__switch mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                {{switch('Status', 'status', editUserForm.status equals 'active', 'active', 'inactive')}}
            </div>
        </div>
        <div class="mdl-cell mdl-cell--4-col mdl-cell--4-col-tablet mdl-cell--4-col-phone">
            <div
                class="s2act-textfield s2act-textfield__switch mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                {{switch('E-Mail Status', 'mailStatus', editUserForm.mailStatus equals 'active', 'active', 'inactive')}}
            </div>
        </div>
        <div class="mdl-cell mdl-cell--12-col mdl-cell--8-col-tablet mdl-cell--4-col-phone">
            <div class="s2act-buttonRow">
                <input
                    class="s2act-button--right mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary"
                    type="submit" name="save" value="Save"/>
                {% if editUserForm.status equals 'active' %}
                <input
                    class="s2act-button--right mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-color--red"
                    type="submit" name="deactivateUser" value="Deactivate"/>
                {% else %}
                <input
                    class="s2act-button--right mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent"
                    type="submit" name="activateUser" value="Activate"/>
                {% endif %}
                <input
                    class="s2act-button--right mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent"
                    type="submit" name="resetPassword" value="Reset Password"/>
{'fraction_non_alphanumeric': 0.1581587488934789, 'fraction_numerical': 0.009196419789515098, 'mean_word_length': 2.23239548561437, 'pattern_counts': {'":': 0, '<': 261, '<?xml version=': 0, '>': 261, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3217741', 'n_tokens_mistral': 6264, 'n_tokens_neox': 5890, 'n_words': 985}