-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
file_input.pt
115 lines (112 loc) · 3.61 KB
/
file_input.pt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<div tal:define="
download_url view/download_url;
exists python: view.value is not None;
action view/action;
allow_nochange view/allow_nochange;
doc_type view/file_content_type;
icon view/file_icon;
filename view/filename;
"
tal:attributes="
view/attributes;
"
i18n:domain="plone"
>
<tal:if tal:define="
up_id view/file_upload_id;
"
tal:condition="up_id"
>
<input name="${view/name}.file_upload_id"
type="hidden"
value="${up_id}"
/>
<span>
<tal:i18n i18n:translate="file_already_uploaded">File already uploaded:</tal:i18n>
${filename}
</span>
</tal:if>
<span tal:condition="python:exists and download_url and action=='nochange'">
<img alt="${doc_type}"
src="${icon}"
title="${filename}"
tal:condition="icon"
/>
<a href="${download_url}">${filename}</a>
<span class="text-muted">
—<tal:doc_type condition="doc_type">
<span tal:replace="doc_type"
i18n:translate=""
>ContentType</span>,</tal:doc_type>
${view/file_size}
</span>
</span>
<tal:block condition="allow_nochange">
<div class="form-check">
<input class="form-check-input"
id="${view/id}-nochange"
checked="${python:'checked' if action == 'nochange' else None}"
name="${view/name}.action"
onclick="document.getElementById('${view/id}-input').disabled=true;"
type="radio"
value="nochange"
/>
<label class="form-check-label"
for="${view/id}-nochange"
i18n:translate="file_keep"
>Keep existing file</label>
</div>
<div class="form-check"
tal:condition="not:view/field/required"
>
<input class="form-check-input"
id="${view/id}-remove"
checked="${python:'checked' if action == 'remove' else None}"
name="${view/name}.action"
onclick="document.getElementById('${view/id}-input').disabled=true;"
type="radio"
value="remove"
/>
<label class="form-check-label"
for="${view/id}-remove"
i18n:translate="file_remove"
>Remove existing file</label>
</div>
<div class="form-check">
<input class="form-check-input"
id="${view/id}-replace"
checked="${python:'checked' if action == 'replace' else None}"
name="${view/name}.action"
onclick="document.getElementById('${view/id}-input').disabled=false"
type="radio"
value="replace"
/>
<label class="form-check-label"
for="${view/id}-replace"
i18n:translate="file_replace"
>Replace with new file</label>
</div>
</tal:block>
<input class="form-control ${python:view.error and 'is-invalid' or ''}"
id="${view/id}-input"
accept="${view/accept}"
disabled="${view/disabled}"
maxlength="${view/maxlength}"
name="${view/name}"
required="${python:view.required and 'required' or None}"
size="${view/size}"
type="file"
/>
<div class="form-text"
tal:condition="view/accept"
i18n:translate="namedfile_accepted_types"
>
Allowed types:
<tal:i18n i18n:name="accepted_types">${view/accept}</tal:i18n>.
</div>
<script type="text/javascript"
tal:condition="python:allow_nochange and action != 'replace'"
tal:content="string:document.getElementById('${view/id}-input').disabled=true;"
>
</script>
</div>