<#macro templateTree filepath>
    <@tools.fileList type='task' path=filepath>
        <#list list as a>
            <#if !a.directory><@t.merge 'paths' filepath+'/'+a.fileName/></#if>
        </#list>
        <@sys.lock userId=admin.id itemType='taskTemplate' itemIds=t.paths><#assign lockMap=map!/></@sys.lock>
        <#if lockMap?has_content>
            <#list lockMap as k,lock>
                <#if lock.userId?has_content><@t.merge 'userIds' lock.userId/></#if>
            </#list>
        </#if>
        <@sys.user ids=t.userIds><#assign userMap=map!/></@sys.user>
        <#list list as a>
            <li>
                <#local path=filepath+'/'+a.fileName>
                <a href="taskTemplate/${a.directory?then('directory','content')}.html?path=${(path?url)!}" target="ajax" rel="taskTemplateBox">
                    <#if !a.directory && lockMap?has_content && lockMap[path]?has_content>
                        <#assign lockUser=(userMap[lockMap[path].userId?string].nickname)!''/>
                        <i class="icon-lock icon-large" title="<@t.page 'lock.message' lockUser/> ${lockMap[path].createDate}"></i>
                    </#if>
                    ${a.fileName}
                </a>
            <#if a.directory>
                <ul>
                    <@templateTree path/>
                </ul>
            </#if>
            </li>
        <#else>
            <li><a><@t.page 'empty_directory'/></a></li>
        </#list>
    </@tools.fileList>
</#macro>
<div class="pageContent">
    <div class="leftPageContent">
        <div class="card">
            <h2 class="contentTitle">
                <a class="button" href="taskTemplate/content.html" target="ajax" rel="taskTemplateBox"><@t.page 'task_template.create'/></a>
            </h2>
            <ul class="tree treeFolder" layoutH>
                <@templateTree ''/>
            </ul>
        </div>
    </div>
    <div id="taskTemplateBox" class="unitBox rightPageContent">
        <div class="card">
        <h2 class="contentTitle">
            <a class="button" href="taskTemplate/upload.html?path=${(path?url)!}" target="dialog" mask="true" width="500" height="250"><@t.page 'upload'/></a>
            <a class="button" href="taskTemplate/export?_csrf=<@tools.csrfToken admin=true/>" target="dwzExport" targetType="navTab"><@t.page "button.export"/></a>
        <#if path?has_content>
            <a class="button" href="taskTemplate/content.html?path=${path?url}/" target="ajax" rel="taskTemplateBox"><@t.page 'task_template.create_here'/></a>
            <a class="button" href="taskTemplate/delete?path=${path?url}&navTabId=taskTemplate/list&_csrf=<@tools.csrfToken admin=true/>" title="<@t.page 'confirm.delete_directory'/>" target="ajaxTodo"><@t.page 'button.delete_directory'/></a>
        </#if>
            <a class="button" href="cmsFileBackup/list.html?type=task&path=${(path?url)!}" target="navTab" rel="cmsFileBackup/list"><@t.page 'recycle_bin'/></a>
        </h2>
</div>
    </div>
</div>