Class: FileList

OCA.Files.FileList($el, optionsopt)

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
enableUpload boolean <optional>
false whether to enable uploader
filesClient OC.Files.Client <optional>
files client to use
Source:

Namespaces

Comparators

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:

_allowSorting

Whether or not users can change the sort attribute or direction
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:

_filesConfig :Backbone.Model

Type:
  • Backbone.Model
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:
  • Object.<int, Object>
Source:

_selectionSummary :OCA.Files.FileSummary

Summary of selected files.
Type:
  • OCA.Files.FileSummary
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:

_uploader :OC.Uploader

Type:
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:

fileMultiSelectMenu :OCA.Files.FileSelectionMenu

File selection menu, defaults to OCA.Files.FileSelectionMenu
Type:
  • OCA.Files.FileSelectionMenu
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:
  • OCA.Files.FileSummary
Source:

initialized :boolean

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

shown :boolean

Wheater the file list was already shown once
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:

_isHiddenFile(fileInfo) → {boolean}

Returns whether the given file info must be hidden
Parameters:
Name Type Description
fileInfo OC.Files.FileInfo file info
Source:
Returns:
true if the file is a hidden file, false otherwise
Type
boolean

_isValidPath(path) → {boolean}

Parameters:
Name Type Description
path string
Source:
Returns:
Type
boolean

_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:

_onClickCopyMoveSelected()

Event handler for when clicking on "Move" for the selected files
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:

_onGridviewChange() → {undefined}

Toggle showing gridview by default or not
Source:
Returns:
Type
undefined

_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:

_onShow()

Event handler when leaving previously hidden state
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, fileIdopt)

Sets the current directory name and updates the breadcrumb.
Parameters:
Name Type Attributes Description
targetDir directory to display
changeUrl true to also update the URL, false otherwise (default)
fileId string <optional>
file id
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 | OCA.Files.FileInfoModel file name from the current list or a FileInfoModel object
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)

addAndFetchFileInfo(fileName, diropt, options) → {Promise}

Add file into the list by fetching its information from the server first. If the given directory does not match the current directory, nothing will be fetched.
Parameters:
Name Type Attributes Description
fileName String file name
dir String <optional>
optional directory, defaults to the current one
options Object same options as #add
Since:
  • 9.0
Source:
Returns:
promise that resolves with the file info, or an already resolved Promise if no info was fetched. The promise rejects if the file was not found or an error occurred.
Type
Promise

changeDirectory(targetDir, changeUrlopt, forceopt, fileIdopt)

Changes the current directory and reload the file list.
Parameters:
Name Type Attributes Default Description
targetDir string target directory (non URL encoded)
changeUrl boolean <optional>
true if the URL must not be changed (defaults to true)
force boolean <optional>
false set to true to force changing directory
fileId string <optional>
optional file id, if known, to be appended in the URL
Source:

copy(fileNames, targetPath, callback, dir)

Copies a file to a given target folder.
Parameters:
Name Type Description
fileNames array of file names to copy
targetPath absolute target path
callback to call when copy is finished with success
dir the dir path where fileNames are located (optionnal, will take current folder if undefined)
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

getRegisteredDetailViews()

Returns the registered detail views.
Source:
Returns:
null|Array an array with the registered DetailFileInfoViews, or null if the details view is not enabled.

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:

(private) initialize($el, options)

Initialize the file list and its components
Parameters:
Name Type Description
$el container element with existing markup for the #controls and a table
options map of options, see other parameters
Properties
Name Type Attributes Description
scrollContainer scrollable container, defaults to $(window)
dragOptions drag options, disabled by default
folderDropOptions folder drop options, disabled by default
scrollTo name of file to scroll to after the first load
filesClient OC.Files.Client <optional>
files API client
filesConfig OC.Backbone.Model <optional>
files app configuration
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

isSelectedCopiable()

Check whether all selected files are copiable
Source:

isSelectedDeletable()

Check whether all selected files are deletable
Source:

isSelectedDownloadable()

Check whether all selected files are downloadable
Source:

isSelectedMovable()

Check whether all selected files are movable
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, callback, dir)

Moves a file to a given target folder.
Parameters:
Name Type Description
fileNames array of file names to move
targetPath absolute target path
callback function to call when movement is finished
dir the dir path where fileNames are located (optionnal, will take current folder if undefined)
Source:

pageSize() → {int}

Number of files per page Always show a minimum of 1
Source:
Returns:
page size
Type
int

registerBreadCrumbDetailView()

Register a view to be added to the breadcrumb view
Source:

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, persist)

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)
persist true to save changes in the database (default)
Source:

setupUploadEvents(uploader)

Setup file upload events related to the file-upload plugin
Parameters:
Name Type Description
uploader OC.Uploader
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 | OCA.Files.FileInfoModel file name or FileInfoModel 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: