Skip to content

Commit fa26e41

Browse files
committed
Merge branch 'forgetful-file-input' of Arnei/opencast-admin-interface into r/19.x
Pull request #1529 Fixes #946 Fix input element not displaying file in Create Event
2 parents a6d7066 + 2648ac6 commit fa26e41

4 files changed

Lines changed: 64 additions & 13 deletions

File tree

src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,18 +277,39 @@ const Upload = <T extends RequiredFormPropsUpload>({
277277
</p>
278278
</td>
279279
<td>
280-
<div className="file-upload">
280+
<div
281+
className="fake-file-input blue-btn"
282+
role="button"
283+
tabIndex={0}
284+
onClick={() => document.getElementById(asset.id)?.click()}
285+
onKeyDown={e => {
286+
if (e.key === "Enter" || e.key === " ") {
287+
e.preventDefault();
288+
document.getElementById(asset.id)?.click();
289+
}
290+
}}
291+
aria-label={t("EVENTS.EVENTS.NEW.SOURCE.UPLOAD.ARIA_FILE_PICKER")}
292+
>
293+
<span className="file-button">
294+
{t("EVENTS.EVENTS.NEW.SOURCE.UPLOAD.FILE_PICKER")}
295+
</span>
296+
297+
<span className="file-text">
298+
{asset.file && asset.file.length > 0
299+
? asset.file[0].name
300+
: t("EVENTS.EVENTS.NEW.SOURCE.UPLOAD.NO_FILE_PICKED")}
301+
</span>
302+
281303
<input
282304
id={asset.id}
283-
className="blue-btn file-select-btn"
305+
type="file"
306+
name={`uploadAssetsTrack.${key}.file`}
307+
hidden
284308
accept={asset.accept}
309+
multiple={asset.multiple}
285310
onChange={e =>
286311
handleChange(e, `uploadAssetsTrack.${key}.file`)
287312
}
288-
type="file"
289-
multiple={asset.multiple}
290-
name={`uploadAssetsTrack.${key}.file`}
291-
tabIndex={0}
292313
/>
293314
</div>
294315
</td>

src/i18n/org/opencastproject/adminui/languages/lang-en_US.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,9 @@
526526
"CAPTION": "Upload",
527527
"RECORDING_ELEMENTS": "Recording elements",
528528
"RECORDING_METADATA": "Recording metadata",
529+
"FILE_PICKER": "Upload file...",
530+
"NO_FILE_PICKED": "No file chosen",
531+
"ARIA_FILE_PICKER": "Upload file",
529532
"SEGMENTABLE": {
530533
"SHORT": "Presentation",
531534
"DETAIL": "The file contains a recording of a what is shown to an audience (Keynote, Powerpoint, etc)."

src/styles/components/_inputs.scss

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,37 @@ input[type="radio"].ios {
226226

227227
}
228228

229+
/**
230+
* Fake upload for create event dialog
231+
*/
232+
.fake-file-input {
233+
display: flex;
234+
align-items: center;
235+
width: 100%;
236+
min-width: 256px;
237+
max-width: 320px;
238+
max-height: 34px;
239+
}
240+
241+
/* Left button */
242+
.file-button {
243+
display: flex;
244+
justify-content: center;
245+
align-items: center;
246+
max-height: 22px;
247+
background: variables.$modal-nav-bg-color;
248+
border: 1px solid variables.$main-border-color;
249+
border-radius: 4px;
250+
padding: 0px 8px;
251+
color: variables.$color-black;
252+
margin-right: 8px;
253+
white-space: nowrap;
254+
}
255+
256+
/* Right text */
257+
.file-text {
258+
color: variables.$color-white;
259+
overflow: hidden;
260+
text-overflow: ellipsis;
261+
white-space: nowrap;
262+
}

src/styles/main.scss

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,3 @@ select {
155155
input.disabled, select.disabled {
156156
background: variables.$modal-nav-bg-color;
157157
}
158-
159-
// Use HTML5 input field for file upload
160-
.file-upload > input[type="file"] {
161-
width: 100%;
162-
visibility: visible !important;
163-
text-align: left;
164-
}

0 commit comments

Comments
 (0)