Class: FileList

OCA.Files.FileList

The FileList class manages a file list view. A file list view consists of a controls bar and a file list table.

Constructor

new FileList($el, optionsopt)

Parameters:
Name Type Attributes Description
$el container element with existing markup for the #controls and a table
options Object <optional>
map of options, see other parameters
Properties
Name Type Attributes Default Description
scrollContainer Object <optional>
scrollable container, defaults to $(window)
dragOptions Object <optional>
drag options, disabled by default
folderDropOptions Object <optional>
folder drop options, disabled by default
detailsViewEnabled boolean <optional>
true whether to enable details view
filesClient OC.Files.Client <optional>
files client to use
Source:

Members

$el

Top-level container with controls and file list
Source:

$fileList

List of rows (table tbody)
Source:

$table

Files table
Source:

_allowSelection

Whether selection is allowed, checkboxes and selection overlay will be rendered
Source:

_clientSideSort

Whether to do a client side sort. When false, clicking on a table header will call reload(). When true, clicking on a table header will simply resort the list.
Source:

_currentDirectory :String

Current directory
Type:
  • String
Source:

_detailsView :OCA.Files.DetailsView

Type:
Source:

_filter :String

If not empty, only files containing this string will be shown
Type:
  • String
Source:

_selectedFiles :Object.<int, Object>

Map of file id to file data
Type:
Source:

_selectionSummary :OCA.Files.FileSummary

Summary of selected files.
Type:
Source:

_sort :String

Sort attribute
Type:
  • String
Source:

_sortComparator :function

Sort comparator function for the current sort
Type:
  • function
Source:

_sortDirection :String

Sort direction: 'asc' or 'desc'
Type:
  • String
Source:
Type:
Source:

dirInfo :OC.Files.FileInfo

Current directory entry
Type:
Source:

fileActions :OCA.Files.FileActions

File actions handler, defaults to OCA.Files.FileActions
Type:
Source:

files :Array.<OC.Files.FileInfo>

Array of files in the current folder. The entries are of file data.
Type:
Source:

filesClient :OC.Files.Client

Files client instance
Type:
Source:

fileSummary :OCA.Files.FileSummary

Type:
Source:

initialized :boolean

Whether the file list was initialized already.
Type:
  • boolean
Source:

Methods

_createRow(fileData, options)

Creates a new table row element using the given file data.
Parameters:
Name Type Description
fileData OC.Files.FileInfo file info attributes
options map of attributes
Source:
Returns:
new tr element (not appended to the table)

_createSummary()

Creates the file summary section
Source:

_findInsertionIndex(fileData)

Finds the index of the row before which the given fileData should be inserted, considering the current sorting
Parameters:
Name Type Description
fileData OC.Files.FileInfo file info
Source:

_getIconUrl(fileInfo) → {string}

Returns the icon URL matching the given file info
Parameters:
Name Type Description
fileInfo OC.Files.FileInfo file info
Source:
Returns:
icon URL
Type
string

_getWebdavProperties()

Returns list of webdav properties to request
Source:

_initFileActions(fileActions)

Initializes the file actions, set up listeners.
Parameters:
Name Type Description
fileActions OCA.Files.FileActions file actions
Source:

_nextPage(animate)

Appends the next page of files into the table
Parameters:
Name Type Description
animate true to animate the new elements
Source:
Returns:
array of DOM elements of the newly added files

_onClickBreadCrumb()

Event handler when clicking on a bread crumb
Source:

_onClickDeleteSelected()

Event handler for when clicking on "Delete" for the selected files
Source:

_onClickDownloadSelected()

Event handler for when clicking on "Download" for the selected files
Source:

_onClickFile()

Event handler for when clicking on files to select them
Source:

_onClickFileCheckbox()

Event handler for when clicking on a file's checkbox
Source:

_onClickHeader()

Event handler when clicking on a table header
Source:

_onClickSelectAll()

Event handler for when selecting/deselecting all files
Source:

_onDropOnBreadCrumb()

Event handler when dropping on a breadcrumb
Source:

_onFileActionsUpdated()

Event handler for when file actions were updated. This will refresh the file actions on the list.
Source:

_onResize()

Event handler for when the window size changed
Source:

_onScroll()

Event handler for when scrolling the list container. This appends/renders the next page of entries when reaching the bottom.
Source:

_onUrlChanged()

Event handler for when the URL changed
Source:

_renderRow(fileData, optionsopt)

Creates a new row element based on the given attributes and returns it.
Parameters:
Name Type Attributes Description
fileData OC.Files.FileInfo map of file attributes
options Object <optional>
map of attributes
Properties
Name Type Attributes Description
index int <optional>
index at which to insert the element
updateSummary boolean <optional>
true to update the summary after adding (default), false otherwise. Defaults to true.
animate boolean <optional>
true to animate the thumbnail image after load defaults to true.
Source:
Returns:
new tr element (not appended to the table)

_selectFileEl($tr, state)

Selected/deselects the given file element and updated the internal selection cache.
Parameters:
Name Type Description
$tr Object single file row element
state bool true to select, false to deselect
Source:

_setCurrentDir(targetDir, changeUrl)

Sets the current directory name and updates the breadcrumb.
Parameters:
Name Type Description
targetDir directory to display
changeUrl true to also update the URL, false otherwise (default)
Source:

_showPermissionDeniedNotification()

Shows a "permission denied" notification
Source:

_updateDetailsView(fileName, showopt)

Update the details view to display the given file
Parameters:
Name Type Attributes Default Description
fileName string file name from the current list
show boolean <optional>
true whether to open the sidebar if it was closed
Source:

add(fileData, optionsopt)

Adds an entry to the files array and also into the DOM in a sorted manner.
Parameters:
Name Type Attributes Description
fileData OC.Files.FileInfo map of file attributes
options Object <optional>
map of attributes
Properties
Name Type Attributes Description
updateSummary boolean <optional>
true to update the summary after adding (default), false otherwise. Defaults to true.
silent boolean <optional>
true to prevent firing events like "fileActionsReady", defaults to false.
animate boolean <optional>
true to animate the thumbnail image after load defaults to true.
Source:
Returns:
new tr element (not appended to the table)

changeDirectory(targetDir, changeUrl, force)

Parameters:
Name Type Description
targetDir target directory (non URL encoded)
changeUrl false if the URL must not be changed (defaults to true)
force boolean set to true to force changing directory
Source:

createDirectory(name) → {Promise}

Create a directory inside the current directory.
Parameters:
Name Type Description
name string name of the directory
Since:
  • 8.2
Source:
Returns:
promise that will be resolved after the directory was created
Type
Promise

createFile(name) → {Promise}

Create an empty file inside the current directory.
Parameters:
Name Type Description
name string name of the file
Since:
  • 8.2
Source:
Returns:
promise that will be resolved after the file was created
Type
Promise

destroy()

Destroy / uninitialize this instance.
Source:

do_delete(files, dir)

Delete the given files from the given dir
Parameters:
Name Type Description
files file names list (without path)
dir directory in which to delete the files, defaults to the current directory
Source:

elementToFile($el)

Returns the file data from a given file element.
Parameters:
Name Type Description
$el file tr element
Source:
Returns:
file data

filter()

Deprecated:
  • use setFilter(filter)
Source:

findFile(fileName) → {OCA.Files.FileInfo}

Returns the file info for the given file name from the internal collection.
Parameters:
Name Type Description
fileName string file name
Since:
  • 8.2
Source:
Returns:
file info or null if it was not found
Type
OCA.Files.FileInfo

findFileEl(fileName) → {Object}

Returns the tr element for a given file name, but only if it was already rendered.
Parameters:
Name Type Description
fileName string file name
Source:
Returns:
jQuery object of the matching row
Type
Object

generatePreviewUrl(urlSpec)

Generates a preview URL based on the URL space.
Parameters:
Name Type Description
urlSpec attributes for the URL
Properties
Name Type Description
x int width
y int height
file String path to the file
Source:
Returns:
preview URL

getAjaxUrl()

Deprecated:
  • do not use nor override
Source:

getDirectoryPermissions()

Returns the directory permissions
Source:
Returns:
permission value as integer

getFilter(filter)

get the current filter
Parameters:
Name Type Description
filter
Source:

getModelForFile(fileName) → {OCA.Files.FileInfoModel}

Returns a unique model for the given file name.
Parameters:
Name Type Description
fileName string | object file name or jquery row
Source:
Returns:
file info model
Type
OCA.Files.FileInfoModel

getSelectedFiles()

Returns the file info of the selected files
Source:
Returns:
array of file names

hideMask()

Hide the loading mask.
Source:
See:

highlightFiles(files, highlightFunctionopt)

Scroll to the last file of the given list Highlight the list of files
Parameters:
Name Type Attributes Description
files array of filenames,
highlightFunction function <optional>
optional function to be called after the scrolling is finished
Source:

inList(file) → {bool}

Returns whether the given file name exists in the list
Parameters:
Name Type Description
file string file name
Source:
Returns:
true if the file exists in the list, false otherwise
Type
bool

isAllSelected()

Returns whether all files are selected
Source:
Returns:
true if all files are selected, false otherwise

isSelectedDeletable()

Check whether all selected files are deletable
Source:

lazyLoadPreview(path, mime, callback, etag)

Lazy load a file's preview.
Parameters:
Name Type Description
path path of the file
mime mime type
callback callback function to call when the image was loaded
etag file etag (for caching)
Source:

move(fileNames, targetPath)

Moves a file to a given target folder.
Parameters:
Name Type Description
fileNames array of file names to move
targetPath absolute target path
Source:

pageSize() → {int}

Number of files per page
Source:
Returns:
page size
Type
int

registerDetailView()

Register a detail view to be added to all views
Source:

registerTabView()

Register a tab view to be added to all views
Source:

reload()

Reloads the file list using ajax call
Source:
Returns:
ajax call object

remove(name, optionsopt)

Removes a file entry from the list
Parameters:
Name Type Attributes Description
name name of the file to remove
options Object <optional>
map of attributes
Properties
Name Type Attributes Description
updateSummary boolean <optional>
true to update the summary after removing, false otherwise. Defaults to true.
Source:
Returns:
deleted element

rename(oldName)

Triggers file rename input field for the given file name. If the user enters a new name, the file will be renamed.
Parameters:
Name Type Description
oldName file name of the file to rename
Source:

setDirectoryPermissions()

Deprecated:
  • Yes
Source:

setFiles(filesArray)

Sets the files to be displayed in the list. This operation will re-render the list and update the summary.
Parameters:
Name Type Description
filesArray array of file data (map)
Source:

setFilter(filter)

hide files matching the given filter
Parameters:
Name Type Description
filter
Source:

setPageTitle()

Sets a new page title
Source:

setSort(sort, direction, update)

Sets the current sorting and refreshes the list
Parameters:
Name Type Description
sort sort attribute name
direction sort direction, one of "asc" or "desc"
update true to update the list, false otherwise (default)
Source:

setupUploadEvents()

Setup file upload events related to the file-upload plugin
Source:

setViewerMode(show)

Enables/disables viewer mode. In viewer mode, apps can embed themselves under the controls bar. In viewer mode, the actions of the file list will be hidden.
Parameters:
Name Type Description
show true for enabling, false for disabling
Source:

showActions(show)

Shows/hides action buttons
Parameters:
Name Type Description
show true for enabling, false for disabling
Source:

showDetailsView(fileName, tabIdopt)

Displays the details view for the given file and selects the given tab
Parameters:
Name Type Attributes Description
fileName string file name for which to show details
tabId string <optional>
optional tab id to select
Source:

showFileBusyState(files, busyopt)

Shows busy state on a given file row or multiple
Parameters:
Name Type Attributes Default Description
files string | Array.<string> file name or array of file names
busy bool <optional>
true busy state, true for busy, false to remove busy state
Since:
  • 8.2
Source:

showMask()

Shows the loading mask.
Source:
See:

unfilter()

Deprecated:
  • use setFilter('')
Source:

updateRow($tr, fileInfo, options) → {Object}

Updates the given row with the given file info
Parameters:
Name Type Description
$tr Object row element
fileInfo OCA.Files.FileInfo file info
options Object options
Source:
Returns:
new row element
Type
Object

updateSearch()

update the search object to use this filelist when filtering
Source:

updateSelectionSummary()

Update UI based on the current selection
Source: