Uploaded (2)Add new files and press to start uploading pending files:Start
Uploaded By: David Keane · Uploaded On: 2014-07-26 · File Size: 35 KB
Uploaded By: John Smith · Uploaded On: 2014-09-02 · File Size: 226.6 KB ·
<ui5-upload-collectionid="uploadCollection"mode="Delete"accessible-name="Uploaded (2)"><divslot="header"class="header"><ui5-title>Uploaded (2)</ui5-title><ui5-label>Add new files and press to start uploading pending files:</ui5-label><ui5-buttonid="startUploading">Start</ui5-button><divclass="spacer"></div><ui5-file-uploaderid="fileUploader"hide-inputmultiple><ui5-buttonicon="add"design="Transparent"></ui5-button></ui5-file-uploader></div><ui5-upload-collection-itemfile-name="LaptopHT-1000.jpg"file-name-clickableupload-state="Complete"><imgsrc="../../../assets/images/HT-1000.jpg"slot="thumbnail">
Uploaded By: David Keane · Uploaded On: 2014-07-26 · File Size: 35 KB
</ui5-upload-collection-item><ui5-upload-collection-itemfile-name="Notes.txt"upload-state="Complete"><ui5-iconname="document-text"slot="thumbnail"></ui5-icon>
Uploaded By: John Smith · Uploaded On: 2014-09-02 · File Size: 226.6 KB ·
</ui5-upload-collection-item></ui5-upload-collection><script>constcreateThumbnail=fileName=>{consticon=document.createElement("ui5-icon");icon.name="document";icon.slot="thumbnail";returnicon;};constcreateUCI=file=>{constuci=document.createElement("ui5-upload-collection-item");description=document.createTextNode("Last modified: "+file.lastModifiedDate+", size: "+file.size);uci.appendChild(createThumbnail(file.name));uci.appendChild(description);uci.file=file;uci.fileName=file.name;returnuci;}fileUploader.addEventListener("change",event=>{constfiles=event.detail.files;for(leti=0;i<files.length;i++){uploadCollection.appendChild(createUCI(files[i]));}});startUploading.addEventListener("click",event=>{uploadCollection.items.forEach(item=>{// if there is a file ready to be uploaded send requestif(item.uploadState==="Ready"&&item.file){constoXHR=newXMLHttpRequest();oXHR.open("POST","/upload",true);oXHR.onreadystatechange=function(){if(this.status!==200){item.uploadState="Error";}};oXHR.send(item.file);item.uploadState="Uploading";}});});uploadCollection.addEventListener("ui5-item-delete",event=>{uploadCollection.removeChild(event.detail.item)});</script>
UploadCollection With File Renaming Enabled
Attachments(2)
Uploaded By: David Keane · Uploaded On: 2014-07-26 · File Size: 35 KB
Uploaded By: John Smith · Uploaded On: 2014-09-02 · File Size: 226.6 KB ·
<ui5-upload-collectionid="uploadCollectionWithRenaming"><divslot="header"class="header"><ui5-title>Attachments(2)</ui5-title></div><ui5-upload-collection-itemfile-name="LaptopHT-1000.jpg"file-name-clickabletype="Detail"upload-state="Complete"><imgsrc="../../../assets/images/HT-1000.jpg"slot="thumbnail">
Uploaded By: David Keane · Uploaded On: 2014-07-26 · File Size: 35 KB
</ui5-upload-collection-item><ui5-upload-collection-itemfile-name="Notes.txt"type="Detail"upload-state="Complete"><ui5-iconname="document-text"slot="thumbnail"></ui5-icon>
Uploaded By: John Smith · Uploaded On: 2014-09-02 · File Size: 226.6 KB ·
</ui5-upload-collection-item></ui5-upload-collection><script>uploadCollectionWithRenaming.addEventListener("rename",event=>{alert("Rename event:"+event.target.fileName);});</script>
UploadCollection With Different Uploading States of Items
UploadCollection With Drag and Drop and No Initial Data
Attachments
<ui5-upload-collectionid="uploadCollectionDnD"style="height: 30rem;"><divclass="header"slot="header"><ui5-title>Attachments</ui5-title></div></ui5-upload-collection><script>uploadCollectionDnD.addEventListener("drop",event=>{event.preventDefault();constfiles=event.dataTransfer.files;// Take the files from the drop event and create <ui5-upload-collection-item>fromthemfor(leti=0;i<files.length;i++){uci=createUCI(files[i]);uploadCollectionDnD.appendChild(uci)}});</script>
Overview
This component allows you to represent files before uploading them to a server, with the help of ui5-upload-collection-item. It also allows you to show already uploaded files.
You can use both properties and attributes with the same effect. The name of each attribute is listed below the name of the property, if different.
Name
Type
Default Value
Description
accessibleName
accessible-name
string
""
Defines the accessible ARIA name of the component.
since v1.0.0-rc.16
hideDragOverlay
hide-drag-overlay
boolean
false
By default there will be drag and drop overlay shown over the ui5-upload-collection when files are dragged. If you don't intend to use drag and drop, set this property.
Note: It is up to the application developer to add handler for drop event and handle it. ui5-upload-collection only displays an overlay.
mode
ListMode
"None"
Defines the mode of the ui5-upload-collection.
Note:
None
SingleSelect
MultiSelect
Delete
noDataDescription
no-data-description
string
""
Allows you to set your own text for the 'No data' description.
noDataText
no-data-text
string
""
Allows you to set your own text for the 'No data' text.
Slots
This Element provides slot(s). This means it can display its child nodes.
Unless targeting the default slot, use the slot attribute to define the destination slot for each child.
Text, along with HTML Elements with no slot attribute, goes the the default slot.
Slot
Type
Description
default
HTMLElement [0..n]
Defines the items of the ui5-upload-collection. Note: Use ui5-upload-collection-item for the intended design.
header
HTMLElement [0..n]
Defines the ui5-upload-collection header.
Note: If header slot is provided, the labelling of the UploadCollection is a responsibility of the application developer. accessibleName should be used.
Events
This Web Component fires semantic events upon user interaction. You can bind to these events with the standard DOM APIs, such as addEventListener.
Name
Description
drop
Fired when an element is dropped inside the drag and drop overlay.
Note: The drop event is fired only when elements are dropped within the drag and drop overlay and ignored for the other parts of the ui5-upload-collection.
dataTransfer
type: DataTransfer description: The drop event operation data.
item-delete
Fired when the Delete button of any item is pressed.
Note: A Delete button is displayed on each item, when the ui5-upload-collectionmode property is set to Delete.
item
type: HTMLElement description: The ui5-upload-collection-item which was renamed.
selection-change
Fired when selection is changed by user interaction in SingleSelect and MultiSelect modes.
selectedItems
type: Array description: An array of the selected items.
UploadCollectionItem
Overview
A component to be used within the ui5-upload-collection.
You can use both properties and attributes with the same effect. The name of each attribute is listed below the name of the property, if different.
Name
Type
Default Value
Description
disableDeleteButton
disable-delete-button
boolean
false
Disables the delete button.
file
File
null
Holds an instance of File associated with this item.
fileName
file-name
string
""
The name of the file.
fileNameClickable
file-name-clickable
boolean
false
If set to true the file name will be clickable and it will fire file-name-click event upon click.
hideRetryButton
hide-retry-button
boolean
false
Hides the retry button when uploadState property is Error.
hideTerminateButton
hide-terminate-button
boolean
false
Hides the terminate button when uploadState property is Uploading.
progress
sap.ui.webc.base.types.Integer
0
The upload progress in percentage.
Note: Expected values are in the interval [0, 100].
uploadState
upload-state
sap.ui.webc.fiori.types.UploadState
"Ready"
If set to Uploading or Error, a progress indicator showing the progress is displayed. Also if set to Error, a refresh button is shown. When this icon is pressed retry event is fired. If set to Uploading, a terminate button is shown. When this icon is pressed terminate event is fired.
Slots
This Element provides slot(s). This means it can display its child nodes.
Unless targeting the default slot, use the slot attribute to define the destination slot for each child.
Text, along with HTML Elements with no slot attribute, goes the the default slot.
Slot
Type
Description
default
Node [0..n]
Hold the description of the ui5-upload-collection-item. Will be shown below the file name.
thumbnail
HTMLElement
A thumbnail, which will be shown in the beginning of the ui5-upload-collection-item.
Note: Use ui5-icon or img for the intended design.
Events
This Web Component fires semantic events upon user interaction. You can bind to these events with the standard DOM APIs, such as addEventListener.
Name
Description
file-name-click
Fired when the file name is clicked.
Note: This event is only available when fileNameClickable property is true.
rename
Fired when the fileName property gets changed.
Note: An edit button is displayed on each item, when the ui5-upload-collection-itemtype property is set to Detail.
retry
Fired when the retry button is pressed.
Note: Retry button is displayed when uploadState property is set to Error.
terminate
Fired when the terminate button is pressed.
Note: Terminate button is displayed when uploadState property is set to Uploading.
Theme:Morning Horizon (Light)Evening Horizon (Dark)Horizon High Contrast BlackHorizon High Contrast WhiteQuartz LightQuartz DarkQuartz High Contrast BlackQuartz High Contrast White