Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileManager - Update event / callback function signatures #11953

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/file_management/object_provider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import FileSystemProviderBase, {
export interface ObjectFileSystemProviderOptions extends FileSystemProviderBaseOptions<ObjectFileSystemProvider> {
/**
* @docid ObjectFileSystemProviderOptions.contentExpr
* @type string|function(fileItem)
* @type string|function(fileSystemItem)
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
Expand All @@ -19,7 +19,7 @@ export interface ObjectFileSystemProviderOptions extends FileSystemProviderBaseO
data?: Array<any>;
/**
* @docid ObjectFileSystemProviderOptions.itemsExpr
* @type string|function(fileItem)
* @type string|function(fileSystemItem)
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
Expand Down
12 changes: 6 additions & 6 deletions js/file_management/provider_base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,42 @@ import FileSystemItem from './file_system_item';
export interface FileSystemProviderBaseOptions<T = FileSystemProviderBase> {
/**
* @docid FileSystemProviderBaseOptions.dateModifiedExpr
* @type string|function(fileItem)
* @type string|function(fileSystemItem)
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
dateModifiedExpr?: string | Function;
/**
* @docid FileSystemProviderBaseOptions.isDirectoryExpr
* @type string|function(fileItem)
* @type string|function(fileSystemItem)
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
isDirectoryExpr?: string | Function;
/**
* @docid FileSystemProviderBaseOptions.keyExpr
* @type string|function(fileItem)
* @type string|function(fileSystemItem)
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
keyExpr?: string | Function;
/**
* @docid FileSystemProviderBaseOptions.nameExpr
* @type string|function(fileItem)
* @type string|function(fileSystemItem)
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
nameExpr?: string | Function;
/**
* @docid FileSystemProviderBaseOptions.sizeExpr
* @type string|function(fileItem)
* @type string|function(fileSystemItem)
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
sizeExpr?: string | Function;
/**
* @docid FileSystemProviderBaseOptions.thumbnailExpr
* @type string|function(fileItem)
* @type string|function(fileSystemItem)
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
Expand Down
2 changes: 1 addition & 1 deletion js/file_management/remote_provider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface RemoteFileSystemProviderOptions extends FileSystemProviderBaseO
endpointUrl?: string;
/**
* @docid RemoteFileSystemProviderOptions.hasSubDirectoriesExpr
* @type string|function(fileItem)
* @type string|function(fileSystemItem)
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
Expand Down
13 changes: 8 additions & 5 deletions js/ui/file_manager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
dxElement
} from '../core/element';

import FileSystemItem from '../file_management/file_system_item';

import {
dxContextMenuItem
} from './context_menu';
Expand Down Expand Up @@ -56,12 +58,12 @@ export interface dxFileManagerOptions extends WidgetOptions<dxFileManager> {
/**
* @docid dxFileManagerOptions.customizeThumbnail
* @type function
* @type_function_param1 fileItem:object
* @type_function_param1 fileSystemItem:FileSystemItem
* @type_function_return string
* @prevFileNamespace DevExpress.ui
* @public
*/
customizeThumbnail?: ((fileItem: any) => string);
customizeThumbnail?: ((fileSystemItem: FileSystemItem) => string);
/**
* @docid dxFileManagerOptions.fileSystemProvider
* @type object
Expand All @@ -83,24 +85,25 @@ export interface dxFileManagerOptions extends WidgetOptions<dxFileManager> {
* @extends Action
* @type function(e)
* @type_function_param1 e:object
* @type_function_param1_field4 directory:FileSystemItem
* @default null
* @action
* @prevFileNamespace DevExpress.ui
* @public
*/
onCurrentDirectoryChanged?: ((e: { component?: dxFileManager, element?: dxElement, model?: any }) => any);
onCurrentDirectoryChanged?: ((e: { component?: dxFileManager, element?: dxElement, model?: any, directory?: FileSystemItem }) => any);
/**
* @docid dxFileManagerOptions.onSelectedFileOpened
* @extends Action
* @type function(e)
* @type_function_param1 e:object
* @type_function_param1_field4 fileItem:object
* @type_function_param1_field4 file:FileSystemItem
* @default null
* @action
* @prevFileNamespace DevExpress.ui
* @public
*/
onSelectedFileOpened?: ((e: { component?: dxFileManager, element?: dxElement, model?: any, fileItem?: any }) => any);
onSelectedFileOpened?: ((e: { component?: dxFileManager, element?: dxElement, model?: any, file?: FileSystemItem }) => any);
/**
* @docid dxFileManagerOptions.permissions
* @type object
Expand Down
7 changes: 4 additions & 3 deletions js/ui/file_manager/ui.file_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,14 +543,15 @@ class FileManager extends Widget {
}

_onSelectedDirectoryChanged() {
const currentDirectory = this._getCurrentDirectory();
const currentPath = this._controller.getCurrentPath();

this._filesTreeView.updateCurrentDirectory();
this._itemView.refresh();
this._breadcrumbs.setCurrentDirectory(this._getCurrentDirectory());
this._breadcrumbs.setCurrentDirectory(currentDirectory);

this.option('currentPath', currentPath);
this._onCurrentDirectoryChangedAction();
this._onCurrentDirectoryChangedAction({ directory: currentDirectory.fileItem });
}

getDirectories(parentDirectoryInfo) {
Expand All @@ -577,7 +578,7 @@ class FileManager extends Widget {
_onSelectedItemOpened({ fileItemInfo }) {
const fileItem = fileItemInfo.fileItem;
if(!fileItem.isDirectory) {
this._onSelectedFileOpenedAction({ fileItem });
this._onSelectedFileOpenedAction({ file: fileItem });
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,18 @@ QUnit.module('Details View', moduleConfig, () => {
});

test('Raise the SelectedFileOpened event', function(assert) {
let eventCounter = 0;
const spy = sinon.spy();
const fileManagerInstance = $('#fileManager').dxFileManager('instance');
fileManagerInstance.option('onSelectedFileOpened', e => {
eventCounter++;
});
fileManagerInstance.option('onSelectedFileOpened', spy);

getCellInDetailsView(this.$element, 2, 2).trigger('dxdblclick');
this.clock.tick(800);
assert.equal(eventCounter, 1);
assert.equal(spy.callCount, 1);
assert.equal(spy.args[0][0].file.name, '1.txt', 'file passed as argument');

getCellInDetailsView(this.$element, 1, 2).trigger('dxdblclick');
this.clock.tick(800);
assert.equal(eventCounter, 1);
assert.equal(spy.callCount, 1);
});

test('Apply sorting by click on file type column header', function(assert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,29 +253,29 @@ QUnit.module('Navigation operations', moduleConfig, () => {

test('change current directory by public API', function(assert) {
const inst = this.wrapper.getInstance();
assert.equal(inst.option('currentPath'), '');
const spy = sinon.spy();

const that = this;
let onCurrentDirectoryChangedCounter = 0;
inst.option('onCurrentDirectoryChanged', function() {
onCurrentDirectoryChangedCounter++;
});
assert.equal(inst.option('currentPath'), '');

inst.option('onCurrentDirectoryChanged', spy);
inst.option('currentPath', 'Folder 1/Folder 1.1');
this.clock.tick(800);

assert.equal(onCurrentDirectoryChangedCounter, 1);
assert.equal(spy.callCount, 1);
assert.equal(spy.args[0][0].directory.path, 'Folder 1/Folder 1.1', 'directory passed as argument');
assert.equal(inst.option('currentPath'), 'Folder 1/Folder 1.1', 'The option \'currentPath\' was changed');

const $folder1Node = that.wrapper.getFolderNode(1);
const $folder1Node = this.wrapper.getFolderNode(1);
assert.equal($folder1Node.find('span').text(), 'Folder 1');

const $folder11Node = that.wrapper.getFolderNode(2);
const $folder11Node = this.wrapper.getFolderNode(2);
assert.equal($folder11Node.find('span').text(), 'Folder 1.1');

inst.option('currentPath', '');
this.clock.tick(800);

assert.equal(spy.callCount, 2);
assert.equal(spy.args[1][0].directory.path, '', 'directory argument updated');
assert.equal(this.wrapper.getFocusedItemText(), 'Files', 'root folder selected');
assert.equal(this.wrapper.getBreadcrumbsPath(), 'Files', 'breadcrumbs refrers to the root folder');
});
Expand Down
6 changes: 3 additions & 3 deletions ts/dx.all.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3578,15 +3578,15 @@ declare module DevExpress.ui {
/** @name dxFileManager.Options.customizeDetailColumns */
customizeDetailColumns?: ((columns: Array<dxDataGridColumn>) => Array<dxDataGridColumn>);
/** @name dxFileManager.Options.customizeThumbnail */
customizeThumbnail?: ((fileItem: any) => string);
customizeThumbnail?: ((fileSystemItem: DevExpress.fileManagement.FileSystemItem) => string);
/** @name dxFileManager.Options.fileSystemProvider */
fileSystemProvider?: any;
/** @name dxFileManager.Options.itemView */
itemView?: { mode?: 'details' | 'thumbnails', showFolders?: boolean, showParentFolder?: boolean };
/** @name dxFileManager.Options.onCurrentDirectoryChanged */
onCurrentDirectoryChanged?: ((e: { component?: dxFileManager, element?: DevExpress.core.dxElement, model?: any }) => any);
onCurrentDirectoryChanged?: ((e: { component?: dxFileManager, element?: DevExpress.core.dxElement, model?: any, directory?: DevExpress.fileManagement.FileSystemItem }) => any);
/** @name dxFileManager.Options.onSelectedFileOpened */
onSelectedFileOpened?: ((e: { component?: dxFileManager, element?: DevExpress.core.dxElement, model?: any, fileItem?: any }) => any);
onSelectedFileOpened?: ((e: { component?: dxFileManager, element?: DevExpress.core.dxElement, model?: any, file?: DevExpress.fileManagement.FileSystemItem }) => any);
/** @name dxFileManager.Options.permissions */
permissions?: { copy?: boolean, create?: boolean, delete?: boolean, download?: boolean, move?: boolean, rename?: boolean, upload?: boolean };
/** @name dxFileManager.Options.rootFolderName */
Expand Down