inputDropFilesItem.ftl
1 <#-- Macro: cInputDropFilesItem
2
3 Description: Defines a macro that show a checkbox
4
5 Parameters:
6 @param - name - string - required - the name of of the element
7 @param - label - string - required - the label associated to the input
8 @param - idx - string - required - the index of the file
9 @param - handler - object - required - Handler used to manage files
10 @param - fileSize - number - optional - File size in octet, default 0
11 @param - ext - string - optional - the extension of the file, default ''
12 @param - unit - string - optional - the unit used to show the file size, default ''
13 @param - urlDl - string - optional - The url to download the file - default ''
14 @param - maxChars - string - optional - the max numbers of chars to show in the file name, default 24
15 @param - urlRm - string - optional - Url to remove the file default ''
16 @param - class - string - optional - the CSS class of the element, default ''
17 -->
18 <#macro inputDropFilesItem name label idx handler image=false fileSize=0 ext='' unit='' maxChars=60 urlDl='' urlRm='' class='' deprecated...>
19 <@deprecatedWarning args=deprecated />
20 <#local fileLabel><#if label?length gt maxChars>${label[0..maxChars]}...<#else>${label}</#if></#local>
21 <#if handler?has_content>
22 <#local handlerName>${handler.handlerName}</#local>
23 <#local cUrlDl>jsp/site/plugins/asynchronousupload/DoDownloadFile.jsp?fieldname=${name}&field_index=${idx}&fileName=${label}&asynchronousupload.handler=${handler.handlerName}</#local>
24 <#local cUrlRm></#local>
25 <#local cName>${handler.uploadCheckboxPrefix}${name}${idx}</#local>
26 <#local cId>${handler.uploadCheckboxPrefix}${name}${idx}</#local>
27 <#else>
28 <#local cUrlDl>${urlDl}</#local>
29 <#local cUrlRm>${urlRm!}</#local>
30 <#local cName>_form_upload_checkbox_${name}${idx}</#local>
31 <#local cId>_form_upload_checkbox_${name}${idx}</#local>
32 </#if>
33 <#if fileSize??>
34 <#switch unit>
35 <#case "Mo">
36 <#assign octetUnit="Mo">
37 <#assign octetNumber=fileSize/(1024*1024)>
38 <#break>
39 <#case "Ko">
40 <#assign octetUnit="Ko">
41 <#assign octetNumber=fileSize/1024>
42 <#break>
43 <#case "o">
44 <#assign octetUnit="o">
45 <#assign octetNumber=fileSize>
46 <#break>
47 <#default>
48 <#if fileSize < 1024 >
49 <#assign octetUnit="o">
50 <#assign octetNumber=fileSize>
51 <#elseif fileSize < 1024 * 1024 >
52 <#assign octetUnit="Ko">
53 <#assign octetNumber=fileSize/1024>
54 <#else>
55 <#assign octetUnit="Mo">
56 <#assign octetNumber=fileSize/(1024*1024)>
57 </#if>
58 </#switch>
59 </#if>
60 <#if ext = ''><#local ext=name?keep_after_last('.') /></#if>
61 <li class="files-item<#if class!=''> ${class}</#if>" id="_file_uploaded_${name}${idx}">
62 <label class="files-item-label<#if image=true> image</#if>" for="${cId}">
63 <#if image=true><img src="themes/shared/images/none.svg" alt="" width="80" class="img-fluid img-thumbnail"></#if>
64 <a href="${cUrlDl}" class="files-item-link" title="#i18n{portal.util.labelDownload} ${label}" data-type="${ext!}" data-img="">
65 <span class="file-item-label">${fileLabel}</span>
66 <span class="file-item-info"><#if fileSize?has_content>${octetNumber?string["0"]} ${octetUnit}</#if></span>
67 </a>
68 </label>
69 <button type="button" class="btn btn-link main-color deleteSingleFile p-0"<#if cUrlRm !=''> data-url="${cUrlRm!}"</#if> data-item="#_file_uploaded_${name}${idx}" fieldName="${name}" handlerName="${handlerName!}" index="${idx}" title="#i18n{portal.util.labelDelete} ${fileLabel}">
70 <svg class="paris-icon paris-icon-close" role="img" aria-hidden="true" focusable="false">
71 <use xlink:href="#paris-icon-close"></use>
72 </svg>
73 </button>
74 </li>
75 </#macro>