<@sys.user id=id absoluteURL=false replaceSensitive=false>
    <#assign
        a=object
        deptId=(a.deptId)!''
    />
</@sys.user>
<@sys.dept id=deptId!><#assign dept=object/></@sys.dept>
<form method="post" autocomplete="off" action="sysUser/save?callbackType=closeCurrent&navTabId=sysUser/list" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">
    <input name="id" type="hidden" value="${id!}"/>
    <input type="hidden" name="_csrf" value="<@tools.csrfToken admin=true/>"/>
    <input type="hidden" name="encoding" value="sha512"/>
    <div class="formBar card">
        <ul>
            <li><button type="submit" class="buttonActive" title="ctrl+s"><@t.page 'button.save'/></button></li>
            <li><button type="button" class="button close"><@t.page 'button.close'/></button></li>
        </ul>
    </div>
    <div class="card">
        <div class="pageFormContent" layoutH>
            <dl class="nowrap">
                <dt><@t.page 'user.username'/>:</dt>
                <dd>
                    <input class="required" name="name" type="text" maxlength="50" size="30" value="${(a.name)!}"/>
                    <label><input name="superuser" type="checkbox" class="form-check-input"/><@t.page 'admin'/></label>
                </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="30" value="${(dept.name)!}"/>
                    <a class="btnLook" href="sysDept/lookup.html" width="920" lookupGroup=""><@t.page 'dept.select'/></a>
                    <span class="info"><@t.page 'user.dept.description'/></span>
                </dd>
            </dl>
            <dl class="nowrap superuser hide">
                <dt><@t.page 'user.content_permissions'/>:</dt>
                <dd>
                    <select class="combox required" name="contentPermissions">
                        <option value="0"${(!a?has_content||0=a.contentPermissions)?then(' selected="true"','')?no_esc}><@t.page 'user.content_permissions.0'/></option>
                        <option value="1"${(a?has_content&&1=a.contentPermissions)?then(' selected="true"','')?no_esc}><@t.page 'user.content_permissions.1'/></option>
                        <option value="2"${(a?has_content&&2=a.contentPermissions)?then(' selected="true"','')?no_esc}><@t.page 'user.content_permissions.2'/></option>
                    </select>
                </dd>
            </dl>
            <dl class="nowrap">
                <dt><@t.page 'password'/>:</dt>
                <dd>
                    <input<#if !a?has_content> class="required"</#if> name="password" type="password" escape="true" maxlength="30" size="20"/>
                    <#if a?has_content><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?has_content> class="required"</#if> name="repassword" type="password" escape="true" maxlength="30" size="20"/></dd>
            </dl>
            <dl class="nowrap">
                <dt><@t.page 'user.nickname'/>:</dt>
                <dd><input class="required" name="nickname" type="text" size="30" maxlength="30" value="${(a.nickname)!}"/></dd>
            </dl>
            <dl class="nowrap">
                <dt><@t.page 'cover'/>:</dt>
                <dd>
                    <input name="cover" class="preview" value="${(a.cover)!}" maxlength="300" size="50" type="text"/>
                    <a class="btnAttach" href="common/upload.html?field=cover&fileTypes=image" lookupGroup="" width="1000" height="600"><@t.page 'cover'/></a>
                    <a class="view icon-eye-open" ref="cover" data-prefix="${getFileUploadPrefix()}" href="javascript:void(0);" target="_blank"><@t.page 'button.view'/></a>
                </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 class="superuser hide">
                <legend><i class="icon-user-md icon-large"></i><@t.page 'role'/></legend>
                <ul class="tree treeFolder treeCheck">
            <@sys.roleList>
                <#list page.list as a>
                    <li><a tname="roleIds" tvalue="${a.id}">${a.name}</a></li>
                </#list>
            </@sys.roleList>
                </ul>
            </fieldset>
    <script>
    $('input[name=superuser]',navTab.getCurrentPanel()).on("click", function(){
        if($(this).is(':checked')) {
            $('.superuser',navTab.getCurrentPanel()).show();
        } else {
            $('.superuser',navTab.getCurrentPanel()).hide();
        }
    });
<#if a?has_content&&a.superuser>
    $('input[name=superuser]',navTab.getCurrentPanel()).trigger("click");
    <#if a.roles?has_content>
        <#list a.roles?split(',') as role>
            $('.tree li a[tname=roleIds][tvalue=${role?js_string}]',navTab.getCurrentPanel()).attr('checked','true');
        </#list>
    </#if>
</#if>
    </script>
        </div>
    </div>
</form>