Constructor
new JobFilesController(params)
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
params |
URLSearchParams |
The URL search params parsed from the URL used to reach this page. This should contain at least the Job Id. Properties
|
Methods
addFileToPackageSources(filepath)
This adds a file or folder to the list of items that will be packaged in this job. The item is added to the sourceFiles list of the Job's PackageOperation attribute.
Parameters:
Name | Type | Description |
---|---|---|
filepath |
string |
The absolute path to a file or folder that is to be packaged as part of this job. |
addItemsToUI()
This adds files and folders to the display.
addItemToUI()
This adds a single file or folder to the UI.
addRow(filepath, type, fileCount, dirCount, byteCount)
This adds one row to the table that lists which files and folders this job will package.
Parameters:
Name | Type | Description |
---|---|---|
filepath |
string |
The absolute path to a file or folder that is to be packaged as part of this job. |
type |
string |
The type of item that filepath represents. This should be either "file" or "directory". |
fileCount |
number |
The number of files contained by the item in param filepath. For files, this will be 1. For directories, it will be the total number of files in the directory and all of its subdirectories. (This info is readily available from the FileSystemReader plugin.) |
dirCount |
number |
The number of directories contained by the item in param filepath. For files, this will be 0. For directories, this will be 1 (for the directory itself) plus the total count of all directories within that directory and all of its subdirectories. (This info is readily available from the FileSystemReader plugin.) |
byteCount |
number |
The total number of bytes contained by the item at filepath. For files, this will be the filesize. For directories, this will be the sum of bytes contained by all the files within the directory and all its subdirectories. (This info is readily available from the FileSystemReader plugin.) |
attachDeleteEvents()
This attaches the deletion handler to the red X beside each file and folder. Clicking the red delete icon causes the filepath to be removed from the UI and from this Job's list of sourceFiles in PackageOperation.
attachDragAndDropEvents()
This attaches drag and drop events, so users can add files and folders to the job by dragging them into the application window.
findContainingItem(filepath) → {string}
This checks the list of source files and folders to see if any of the items already set to be packaged contains the item that the user just dragged into the window. We make this check to avoid adding duplicate files or folders to the list of sources.
Parameters:
Name | Type | Description |
---|---|---|
filepath |
string |
The absolute path to a file or folder that is to be packaged as part of this job. |
getTableRow(filepath, type, fileCount, dirCount, byteCount) → {string}
Returns the HTML for a single table row in the files/folders display.
Parameters:
Name | Type | Description |
---|---|---|
filepath |
string |
The absolute path to a file or folder that is to be packaged as part of this job. |
type |
string |
The type of item that filepath represents. This should be either "file" or "directory". |
fileCount |
number |
The number of files contained by the item in param filepath. For files, this will be 1. For directories, it will be the total number of files in the directory and all of its subdirectories. (This info is readily available from the FileSystemReader plugin.) |
dirCount |
number |
The number of directories contained by the item in param filepath. For files, this will be 0. For directories, this will be 1 (for the directory itself) plus the total count of all directories within that directory and all of its subdirectories. (This info is readily available from the FileSystemReader plugin.) |
byteCount |
number |
The total number of bytes contained by the item at filepath. For files, this will be the filesize. For directories, this will be the sum of bytes contained by all the files within the directory and all its subdirectories. (This info is readily available from the FileSystemReader plugin.) |
postRenderCallback()
This attaches required events to the Job files UI and adds the list of files and folders to be packaged to the UI.
removeItemFromUI(filepath)
This deletes a file or folder from the list of files and folders in the UI (but does not delete the item from the underlying PackageOperation).
Parameters:
Name | Type | Description |
---|---|---|
filepath |
string |
The absolute path to a file or folder to be removed from the UI. |
show()
This displays the Job files UI, where the user can drag and drop files.
updateTotal(elementId, amountToAdd) → {number}
Updates one of the total fields at the bottom of the list of files and folders, and returns the calculated total.
Parameters:
Name | Type | Description |
---|---|---|
elementId |
string |
The id (css selector) of the element whose text should be updated. |
amountToAdd |
number |
The number to add to the existing total already displayed in the cell. This will be negative in cases where you're removing files or folders. |
updateTotals(fileCount, dirCount, byteCount)
Updates the total number of files, folders, and bytes to be packaged.
Parameters:
Name | Type | Description |
---|---|---|
fileCount |
number |
The number of files contained by the item in param filepath. For files, this will be 1. For directories, it will be the total number of files in the directory and all of its subdirectories. (This info is readily available from the FileSystemReader plugin.) This number will be added to the total file count. |
dirCount |
number |
The number of directories contained by the item in param filepath. For files, this will be 0. For directories, this will be 1 (for the directory itself) plus the total count of all directories within that directory and all of its subdirectories. (This info is readily available from the FileSystemReader plugin.) This number will be added to the total directory count. |
byteCount |
number |
The total number of bytes contained by the item at filepath. For files, this will be the filesize. For directories, this will be the sum of bytes contained by all the files within the directory and all its subdirectories. (This info is readily available from the FileSystemReader plugin.) This number will be added to the total byte count. |