<dialog-ok-cancel title="{{ user.Id == null ? 'Add' : 'Edit'}} user {{ user.Username }}">
    <div class="form-group">
        <label for="username" class="col-sm-2 control-label">Username</label>
        <div class="col-sm-9">
            <input autofocus id="username" class="form-control" ng-model="user.Username" ng-readonly="user.Id != null" required/>
        </div>
    </div>

    <div class="form-group">
        <label for="email" class="col-sm-2 control-label">Email</label>
        <div class="col-sm-9">
            <input id="email" class="form-control" ng-model="user.Email" lu-enable-permission="{{ permission }}"/>
        </div>
    </div>

    <div class="form-group">
        <label for="firstname" class="col-sm-2 control-label">Firstname</label>
        <div class="col-sm-9">
            <input id="firstname" class="form-control" ng-model="user.Firstname" lu-enable-permission="{{ permission }}"/>
        </div>
    </div>

    <div class="form-group">
        <label for="lastname" class="col-sm-2 control-label">Lastname</label>
        <div class="col-sm-9">
            <input id="lastname" class="form-control" ng-model="user.Lastname" lu-enable-permission="{{ permission }}"/>
        </div>
    </div>

    <div lu-show-permission="{{ permissionPassword }}">

        <div class="form-group">
            <label for="password" class="col-sm-2 control-label">Password</label>
            <div class="col-sm-9">
                <input id="password" class="form-control" type="password" ng-model="userPassword.value"
                       name="password" ui-validate="passwordValidation"/>
            </div>
        </div>

        <div class="form-group">
            <label for="password2" class="col-sm-2 control-label">Confirmation</label>
            <div class="col-sm-9">
                <input id="password2" class="form-control" type="password" ng-model="userPassword.confirm"
                       name="password2" ui-validate="password2Validation" ui-validate-watch="'userPassword.value'"/>
            </div>
        </div>

        <div class="col-sm-offset-2 col-sm-9">
            <p class="error" ng-show="form.password.$error.length">Passwords is too short</p>
            <p class="error" ng-show="form.password2.$error.same_passwords">Passwords do not match</p>
        </div>
    </div>

    <div class="form-group" ng-show="user.Id != null">
        <div class="col-sm-offset-2 col-sm-9">
            <div class="col-sm-6">
                <button type="button" class="btn btn-primary btn-block" ng-click="editPermissions(user)"
                        lu-show-permission="LU_PERM_USER_GET">
                    Edit permissions
                </button>
            </div>
            <div class="col-sm-6">
                <button type="button" class="btn btn-info btn-block" ng-click="showEffectivePermissions(user)"
                        lu-show-permission="LU_PERM_EFFECTIVE_GET,LU_PERM_GET">
                    Show effective permissions
                </button>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>

    <div class="form-group" ng-show="user.Id != null">
        <div class="col-sm-offset-2 col-sm-9">
            <div class="col-sm-6">
                <button type="button" class="btn btn-primary btn-block" ng-click="editSettings(user)"
                        lu-show-permission="LU_SETTING_USER_GET">
                    Edit settings
                </button>
            </div>
            <div class="col-sm-6">
                <button type="button" class="btn btn-info btn-block" ng-click="showEffectiveSettings(user)"
                        lu-show-permission="LU_SETTING_EFFECTIVE_GET,LU_SETTING_GET">
                    Show effective settings
                </button>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
</dialog-ok-cancel>