<@_sysUser id=id>
    <#assign a=object/>
</@_sysUser>
<@_sysDept id=(a.deptId)!deptId><#assign dept=object/></@_sysDept>
<form method="post" autocomplete="off" action="sysDept/saveUser?callbackType=closeCurrent&navTabId=sysDept/userList" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">
    <input name="id" type="hidden" value="${id!}" />
    <input type="hidden" name="_csrf" value="<@_csrfToken admin=true/>"/>
    <div class="formBar">
        <ul>
            <li><button type="submit" class="buttonActive"><@t.page 'button.save'/></button></li>
            <li><button type="button" class="button close"><@t.page 'button.close'/></button></li>
        </ul>
    </div>
    <div class="pageFormContent" layoutH>
        <dl class="nowrap">
            <dt><@t.page 'user.username'/>:</dt>
            <dd>
                <input class="required" name="name" type="text" maxlength="20" size="20" value="${(a.name)!}"/>
            <#if admin.ownsAllContent>
                <label><input name="ownsAllContent" type="checkbox"<#if !a?has_content||a.ownsAllContent> checked="true"</#if>/><@t.page 'user.own_all_content'/></label>
            </#if>
            </dd>
        </dl>
        <dl class="nowrap">
            <dt><@t.page 'dept'/>:</dt>
            <dd>
                <input name="deptId" type="hidden" value="${(dept.id)!}"/>
                <input readonly="readonly" name="deptName" type="text" size="10" value="${(dept.name)!}"/>
            </dd>
        </dl>
        <dl class="nowrap">
            <dt><@t.page 'password'/>:</dt>
            <dd>
                <input<#if !a??> class="required"</#if> name="password" type="password" maxlength="30" size="20" value=""/>
                <#if a??><span class="info"><@t.page 'user.password.description'/></span></#if>
            </dd>
        </dl>
        <dl class="nowrap">
            <dt><@t.page 'repeat_password'/>:</dt>
            <dd><input<#if !a??> class="required"</#if> name="repassword" type="password" maxlength="30" size="20" value=""/></dd>
        </dl>
        <dl class="nowrap">
            <dt><@t.page 'user.nickname'/>:</dt>
            <dd><input class="required" name="nickName" type="text" size="20" maxlength="30" value="${(a.nickName)!}"/></dd>
        </dl>
        <dl class="nowrap">
            <dt><@t.page 'email'/>:</dt>
            <dd><input name="email" type="text" size="30" maxlength="50" value="${(a.email)!}"/></dd>
        </dl>
        <fieldset>
            <legend><i class="icon-user-md icon-large"></i> <@t.page 'role'/>(<@t.page 'dept.role.description'/>)</legend>
            <ul class="tree treeFolder treeCheck expand">
        <@_sysRole ids=admin.roles>
            <#list map as k,role>
                <li><a tname="roleIds" tvalue="${k}">${role.name}</a></li>
            </#list>
        </@_sysRole>
            </ul>
        </fieldset>
<#if a?has_content&&a.superuserAccess>
<script>
    $('input[name=superuserAccess]',navTab.getCurrentPanel()).click();
<#if a.roles?has_content>
    <#list a.roles?split(',') as role>
        if($('.tree li a[tname=roleIds][tvalue=${role?js_string}]',navTab.getCurrentPanel()).length) {
            $('.tree li a[tname=roleIds][tvalue=${role?js_string}]',navTab.getCurrentPanel()).prop('checked',true);
        } else {
            $('form',navTab.getCurrentPanel()).prepend('<input name="roleIds" value="${role}" type="hidden"/>');
        }
    </#list>
</#if>
</script>
</#if>
    </div>
</form>