@syncfusion/ej2-filemanager 20.1.52-10460 → 20.1.52-10461
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +412 -410
- package/README.md +69 -69
- package/dist/ej2-filemanager.min.js +1 -0
- package/dist/ej2-filemanager.umd.min.js +1 -10
- package/dist/ej2-filemanager.umd.min.js.map +1 -1
- package/dist/es6/ej2-filemanager.es2015.js +57 -54
- package/dist/es6/ej2-filemanager.es2015.js.map +1 -1
- package/dist/es6/ej2-filemanager.es5.js +174 -171
- package/dist/es6/ej2-filemanager.es5.js.map +1 -1
- package/dist/global/ej2-filemanager.min.js +1 -10
- package/dist/global/ej2-filemanager.min.js.map +1 -1
- package/dist/global/index.d.ts +0 -9
- package/dist/ts/file-manager/actions/breadcrumb-bar.ts +427 -0
- package/dist/ts/file-manager/actions/toolbar.ts +498 -0
- package/dist/ts/file-manager/base/classes.ts +225 -0
- package/dist/ts/file-manager/base/constant.ts +137 -0
- package/dist/ts/file-manager/base/file-manager.ts +1659 -0
- package/dist/ts/file-manager/base/interface.ts +652 -0
- package/dist/ts/file-manager/common/operations.ts +614 -0
- package/dist/ts/file-manager/common/utility.ts +1503 -0
- package/dist/ts/file-manager/layout/details-view.ts +1837 -0
- package/dist/ts/file-manager/layout/large-icons-view.ts +1587 -0
- package/dist/ts/file-manager/layout/navigation-pane.ts +879 -0
- package/dist/ts/file-manager/models/ajax-settings.ts +39 -0
- package/dist/ts/file-manager/models/column.ts +197 -0
- package/dist/ts/file-manager/models/contextMenu-settings.ts +44 -0
- package/dist/ts/file-manager/models/default-locale.ts +102 -0
- package/dist/ts/file-manager/models/details-view-settings.ts +48 -0
- package/dist/ts/file-manager/models/navigation-pane-settings.ts +42 -0
- package/dist/ts/file-manager/models/search-settings.ts +48 -0
- package/dist/ts/file-manager/models/toolbar-settings.ts +25 -0
- package/dist/ts/file-manager/models/upload-settings.ts +51 -0
- package/dist/ts/file-manager/pop-up/context-menu.ts +614 -0
- package/dist/ts/file-manager/pop-up/dialog.ts +996 -0
- package/helpers/e2e/filemanagerHelper.js +183 -166
- package/license +9 -9
- package/package.json +72 -72
- package/src/file-manager/base/file-manager-model.d.ts +329 -329
- package/src/file-manager/base/file-manager.js +19 -19
- package/src/file-manager/models/ajax-settings-model.d.ts +21 -21
- package/src/file-manager/models/ajax-settings.js +19 -19
- package/src/file-manager/models/column-model.d.ts +98 -98
- package/src/file-manager/models/column.js +19 -19
- package/src/file-manager/models/contextMenu-settings-model.d.ts +21 -21
- package/src/file-manager/models/contextMenu-settings.js +19 -19
- package/src/file-manager/models/details-view-settings-model.d.ts +19 -19
- package/src/file-manager/models/details-view-settings.js +19 -19
- package/src/file-manager/models/navigation-pane-settings-model.d.ts +25 -25
- package/src/file-manager/models/navigation-pane-settings.js +19 -19
- package/src/file-manager/models/search-settings-model.d.ts +26 -26
- package/src/file-manager/models/search-settings.js +19 -19
- package/src/file-manager/models/toolbar-settings-model.d.ts +11 -11
- package/src/file-manager/models/toolbar-settings.js +19 -19
- package/src/file-manager/models/upload-settings-model.d.ts +31 -31
- package/src/file-manager/models/upload-settings.js +19 -19
- package/src/file-manager/pop-up/context-menu.js +3 -0
- package/styles/compatibility/bootstrap.css +1 -0
- package/styles/compatibility/bootstrap.scss +12 -0
- package/styles/compatibility/bootstrap4.css +1 -0
- package/styles/compatibility/bootstrap4.scss +12 -0
- package/styles/compatibility/fabric.css +1 -0
- package/styles/compatibility/fabric.scss +12 -0
- package/styles/compatibility/highcontrast.css +1 -0
- package/styles/compatibility/highcontrast.scss +12 -0
- package/styles/compatibility/material.css +1 -0
- package/styles/compatibility/material.scss +12 -0
- package/styles/file-manager/_all.scss +2 -2
- package/styles/file-manager/_bds-definition.scss +236 -0
- package/styles/file-manager/_bigger.scss +759 -0
- package/styles/file-manager/_bootstrap-dark-definition.scss +244 -240
- package/styles/file-manager/_bootstrap-definition.scss +245 -241
- package/styles/file-manager/_bootstrap4-definition.scss +246 -242
- package/styles/file-manager/_bootstrap5-definition.scss +242 -237
- package/styles/file-manager/_bootstrap5.3-definition.scss +242 -0
- package/styles/file-manager/_fabric-dark-definition.scss +242 -238
- package/styles/file-manager/_fabric-definition.scss +244 -240
- package/styles/file-manager/_fluent-definition.scss +249 -246
- package/styles/file-manager/_fluent2-definition.scss +255 -0
- package/styles/file-manager/_fusionnew-definition.scss +241 -0
- package/styles/file-manager/_highcontrast-definition.scss +244 -240
- package/styles/file-manager/_highcontrast-light-definition.scss +244 -240
- package/styles/file-manager/_layout.scss +1252 -1815
- package/styles/file-manager/_material-dark-definition.scss +245 -240
- package/styles/file-manager/_material-definition.scss +245 -240
- package/styles/file-manager/_material3-definition.scss +235 -0
- package/styles/file-manager/_tailwind-definition.scss +236 -232
- package/styles/file-manager/_theme.scss +418 -397
- package/styles/file-manager/icons/_bds.scss +235 -0
- package/styles/file-manager/icons/_bootstrap-dark.scss +235 -235
- package/styles/file-manager/icons/_bootstrap.scss +235 -236
- package/styles/file-manager/icons/_bootstrap4.scss +235 -236
- package/styles/file-manager/icons/_bootstrap5.3.scss +235 -0
- package/styles/file-manager/icons/_bootstrap5.scss +235 -235
- package/styles/file-manager/icons/_fabric-dark.scss +229 -230
- package/styles/file-manager/icons/_fabric.scss +229 -230
- package/styles/file-manager/icons/_fluent.scss +235 -235
- package/styles/file-manager/icons/_fluent2.scss +235 -0
- package/styles/file-manager/icons/_fusionnew.scss +235 -0
- package/styles/file-manager/icons/_highcontrast-light.scss +235 -235
- package/styles/file-manager/icons/_highcontrast.scss +229 -229
- package/styles/file-manager/icons/_material-dark.scss +235 -235
- package/styles/file-manager/icons/_material.scss +235 -235
- package/styles/file-manager/icons/_material3.scss +235 -0
- package/styles/file-manager/icons/_tailwind.scss +235 -235
- package/.eslintrc.json +0 -244
- package/styles/bootstrap-dark.css +0 -1920
- package/styles/bootstrap-dark.scss +0 -1
- package/styles/bootstrap.css +0 -1899
- package/styles/bootstrap.scss +0 -1
- package/styles/bootstrap4.css +0 -1935
- package/styles/bootstrap4.scss +0 -1
- package/styles/bootstrap5-dark.css +0 -1982
- package/styles/bootstrap5-dark.scss +0 -1
- package/styles/bootstrap5.css +0 -1982
- package/styles/bootstrap5.scss +0 -1
- package/styles/fabric-dark.css +0 -1891
- package/styles/fabric-dark.scss +0 -1
- package/styles/fabric.css +0 -1891
- package/styles/fabric.scss +0 -1
- package/styles/file-manager/_bootstrap5-dark-definition.scss +0 -1
- package/styles/file-manager/_fluent-dark-definition.scss +0 -1
- package/styles/file-manager/_tailwind-dark-definition.scss +0 -1
- package/styles/file-manager/bootstrap-dark.css +0 -1920
- package/styles/file-manager/bootstrap-dark.scss +0 -16
- package/styles/file-manager/bootstrap.css +0 -1899
- package/styles/file-manager/bootstrap.scss +0 -16
- package/styles/file-manager/bootstrap4.css +0 -1935
- package/styles/file-manager/bootstrap4.scss +0 -16
- package/styles/file-manager/bootstrap5-dark.css +0 -1982
- package/styles/file-manager/bootstrap5-dark.scss +0 -16
- package/styles/file-manager/bootstrap5.css +0 -1982
- package/styles/file-manager/bootstrap5.scss +0 -16
- package/styles/file-manager/fabric-dark.css +0 -1891
- package/styles/file-manager/fabric-dark.scss +0 -16
- package/styles/file-manager/fabric.css +0 -1891
- package/styles/file-manager/fabric.scss +0 -16
- package/styles/file-manager/fluent-dark.css +0 -1901
- package/styles/file-manager/fluent-dark.scss +0 -16
- package/styles/file-manager/fluent.css +0 -1900
- package/styles/file-manager/fluent.scss +0 -16
- package/styles/file-manager/highcontrast-light.css +0 -1897
- package/styles/file-manager/highcontrast-light.scss +0 -16
- package/styles/file-manager/highcontrast.css +0 -1897
- package/styles/file-manager/highcontrast.scss +0 -16
- package/styles/file-manager/icons/_bootstrap5-dark.scss +0 -1
- package/styles/file-manager/icons/_fluent-dark.scss +0 -1
- package/styles/file-manager/icons/_tailwind-dark.scss +0 -1
- package/styles/file-manager/material-dark.css +0 -1945
- package/styles/file-manager/material-dark.scss +0 -16
- package/styles/file-manager/material.css +0 -1932
- package/styles/file-manager/material.scss +0 -16
- package/styles/file-manager/tailwind-dark.css +0 -1969
- package/styles/file-manager/tailwind-dark.scss +0 -16
- package/styles/file-manager/tailwind.css +0 -1969
- package/styles/file-manager/tailwind.scss +0 -16
- package/styles/fluent-dark.css +0 -1901
- package/styles/fluent-dark.scss +0 -1
- package/styles/fluent.css +0 -1900
- package/styles/fluent.scss +0 -1
- package/styles/highcontrast-light.css +0 -1897
- package/styles/highcontrast-light.scss +0 -1
- package/styles/highcontrast.css +0 -1897
- package/styles/highcontrast.scss +0 -1
- package/styles/material-dark.css +0 -1945
- package/styles/material-dark.scss +0 -1
- package/styles/material.css +0 -1932
- package/styles/material.scss +0 -1
- package/styles/tailwind-dark.css +0 -1969
- package/styles/tailwind-dark.scss +0 -1
- package/styles/tailwind.css +0 -1969
- package/styles/tailwind.scss +0 -1
- package/tslint.json +0 -111
@@ -0,0 +1,1659 @@
|
|
1
|
+
import { Component, EmitType, ModuleDeclaration, isNullOrUndefined, L10n, closest } from '@syncfusion/ej2-base';
|
2
|
+
import { Property, INotifyPropertyChanged, NotifyPropertyChanges, Complex, select } from '@syncfusion/ej2-base';
|
3
|
+
import { createElement, addClass, removeClass, setStyleAttribute as setAttr, getUniqueID } from '@syncfusion/ej2-base';
|
4
|
+
import { isNullOrUndefined as isNOU, formatUnit, Browser, KeyboardEvents, KeyboardEventArgs } from '@syncfusion/ej2-base';
|
5
|
+
import { Event, EventHandler, getValue, setValue } from '@syncfusion/ej2-base';
|
6
|
+
import { Splitter, PanePropertiesModel } from '@syncfusion/ej2-layouts';
|
7
|
+
import { Dialog, createSpinner, hideSpinner, showSpinner, BeforeOpenEventArgs, BeforeCloseEventArgs } from '@syncfusion/ej2-popups';
|
8
|
+
import { createDialog, createExtDialog } from '../pop-up/dialog';
|
9
|
+
import { ToolbarSettings, ToolbarSettingsModel, AjaxSettings, NavigationPaneSettings, DetailsViewSettings } from '../models/index';
|
10
|
+
import { NavigationPaneSettingsModel, DetailsViewSettingsModel } from '../models/index';
|
11
|
+
import { AjaxSettingsModel, SearchSettings, SearchSettingsModel } from '../models/index';
|
12
|
+
import { Toolbar } from '../actions/toolbar';
|
13
|
+
import { DetailsView } from '../layout/details-view';
|
14
|
+
import { LargeIconsView } from '../layout/large-icons-view';
|
15
|
+
import { Uploader, UploadingEventArgs, SelectedEventArgs, FileInfo, CancelEventArgs } from '@syncfusion/ej2-inputs';
|
16
|
+
import { UploadSettingsModel } from '../models/upload-settings-model';
|
17
|
+
import { UploadSettings } from '../models/upload-settings';
|
18
|
+
import * as events from './constant';
|
19
|
+
import * as CLS from './classes';
|
20
|
+
import { read, filter, createFolder } from '../common/operations';
|
21
|
+
import { FileManagerModel } from './file-manager-model';
|
22
|
+
import { ITreeView, IContextMenu, ViewType, SortOrder, FileDragEventArgs, RetryArgs, ReadArgs, FileSelectionEventArgs } from './interface';
|
23
|
+
import { BeforeSendEventArgs, SuccessEventArgs, FailureEventArgs, FileLoadEventArgs } from './interface';
|
24
|
+
import { FileOpenEventArgs, FileSelectEventArgs, MenuClickEventArgs, MenuOpenEventArgs } from './interface';
|
25
|
+
import { ToolbarClickEventArgs, ToolbarCreateEventArgs, UploadListCreateArgs } from './interface';
|
26
|
+
import { PopupOpenCloseEventArgs, BeforePopupOpenCloseEventArgs, BeforeDownloadEventArgs, BeforeImageLoadEventArgs } from './interface';
|
27
|
+
import { refresh, getPathObject, getLocaleText, setNextPath, createDeniedDialog, getCssClass } from '../common/utility';
|
28
|
+
import { hasContentAccess, hasUploadAccess, updateLayout, createNewFolder, uploadItem } from '../common/utility';
|
29
|
+
import { TreeView as BaseTreeView } from '@syncfusion/ej2-navigations';
|
30
|
+
import { ContextMenuSettingsModel } from '../models/contextMenu-settings-model';
|
31
|
+
import { ContextMenuSettings } from '../models/contextMenu-settings';
|
32
|
+
import { BreadCrumbBar } from '../actions/breadcrumb-bar';
|
33
|
+
import { ContextMenu } from '../pop-up/context-menu';
|
34
|
+
import { defaultLocale } from '../models/default-locale';
|
35
|
+
import { PositionModel } from '@syncfusion/ej2-base/src/draggable-model';
|
36
|
+
|
37
|
+
/**
|
38
|
+
* The FileManager component allows users to access and manage the file system through the web browser. It can performs the
|
39
|
+
* functionalities like add, rename, search, sort, upload and delete files or folders. And also it
|
40
|
+
* provides an easy way of dynamic injectable modules like toolbar, navigationpane, detailsview, largeiconsview.
|
41
|
+
* ```html
|
42
|
+
* <div id="file"></div>
|
43
|
+
* ```
|
44
|
+
* ```typescript,
|
45
|
+
* let feObj: FileManager = new FileManager();
|
46
|
+
* feObj.appendTo('#file');
|
47
|
+
* ```
|
48
|
+
*/
|
49
|
+
|
50
|
+
@NotifyPropertyChanges
|
51
|
+
export class FileManager extends Component<HTMLElement> implements INotifyPropertyChanged {
|
52
|
+
|
53
|
+
/* Internal modules */
|
54
|
+
/** @hidden */
|
55
|
+
public toolbarModule: Toolbar;
|
56
|
+
/** @hidden */
|
57
|
+
public detailsviewModule: DetailsView;
|
58
|
+
/** @hidden */
|
59
|
+
public navigationpaneModule: ITreeView;
|
60
|
+
/** @hidden */
|
61
|
+
public largeiconsviewModule: LargeIconsView;
|
62
|
+
/** @hidden */
|
63
|
+
public contextmenuModule: IContextMenu;
|
64
|
+
/** @hidden */
|
65
|
+
public breadcrumbbarModule: BreadCrumbBar;
|
66
|
+
|
67
|
+
|
68
|
+
/* Internal variables */
|
69
|
+
private keyboardModule: KeyboardEvents;
|
70
|
+
private keyConfigs: { [key: string]: string };
|
71
|
+
// eslint-disable-next-line
|
72
|
+
public filterData: Object = null;
|
73
|
+
public originalPath: string;
|
74
|
+
public filterPath: string;
|
75
|
+
public filterId: string;
|
76
|
+
public hasId: boolean;
|
77
|
+
public pathNames: string[];
|
78
|
+
public pathId: string[];
|
79
|
+
public expandedId: string;
|
80
|
+
// eslint-disable-next-line
|
81
|
+
public itemData: Object[];
|
82
|
+
// eslint-disable-next-line
|
83
|
+
public visitedData: Object;
|
84
|
+
public visitedItem: Element;
|
85
|
+
public toolbarSelection: boolean;
|
86
|
+
// Specifies the parent path of the CWD(this.path).
|
87
|
+
public targetPath: string;
|
88
|
+
// eslint-disable-next-line
|
89
|
+
public feParent: Object[];
|
90
|
+
// eslint-disable-next-line
|
91
|
+
public feFiles: Object[];
|
92
|
+
public activeElements: Element[];
|
93
|
+
public activeModule: string;
|
94
|
+
public targetModule: string;
|
95
|
+
public treeObj: BaseTreeView;
|
96
|
+
public dialogObj: Dialog;
|
97
|
+
public viewerObj: Dialog;
|
98
|
+
public extDialogObj: Dialog;
|
99
|
+
public selectedNodes: string[] = [];
|
100
|
+
public duplicateItems: string[] = [];
|
101
|
+
// eslint-disable-next-line
|
102
|
+
public duplicateRecords: Object[] = [];
|
103
|
+
public previousPath: string[] = [];
|
104
|
+
public nextPath: string[] = [];
|
105
|
+
public fileAction: string;
|
106
|
+
public pasteNodes: string[];
|
107
|
+
public isLayoutChange: boolean = false;
|
108
|
+
public replaceItems: string[];
|
109
|
+
// eslint-disable-next-line
|
110
|
+
public createdItem: { [key: string]: Object; };
|
111
|
+
public layoutSelectedItems: string[] = [];
|
112
|
+
// eslint-disable-next-line
|
113
|
+
public renamedItem: { [key: string]: Object; };
|
114
|
+
public renamedId: string = null;
|
115
|
+
public uploadItem: string[] = [];
|
116
|
+
public fileLength: number;
|
117
|
+
public deleteRecords: string[] = [];
|
118
|
+
public fileView: string;
|
119
|
+
public isDevice: boolean;
|
120
|
+
public isMobile: boolean;
|
121
|
+
public isBigger: boolean;
|
122
|
+
public isFile: boolean = false;
|
123
|
+
// eslint-disable-next-line
|
124
|
+
public actionRecords: Object[];
|
125
|
+
// eslint-disable-next-line
|
126
|
+
public activeRecords: Object[];
|
127
|
+
public isCut: boolean = false;
|
128
|
+
public isSearchCut: boolean = false;
|
129
|
+
public isSearchDrag: boolean = false;
|
130
|
+
public isPasteError: boolean = false;
|
131
|
+
public folderPath: string = '';
|
132
|
+
public isSameAction: boolean = false;
|
133
|
+
public currentItemText: string;
|
134
|
+
public renameText: string;
|
135
|
+
public isFiltered: boolean = false;
|
136
|
+
// Specifies whether the sort by option is clicked or not.
|
137
|
+
public isSortByClicked: boolean = false;
|
138
|
+
public enablePaste: boolean = false;
|
139
|
+
public splitterObj: Splitter;
|
140
|
+
public persistData: boolean = false;
|
141
|
+
public breadCrumbBarNavigation: HTMLElement;
|
142
|
+
public localeObj: L10n;
|
143
|
+
public uploadObj: Uploader;
|
144
|
+
public uploadDialogObj: Dialog;
|
145
|
+
public retryArgs: RetryArgs[] = [];
|
146
|
+
private isOpened: boolean = false;
|
147
|
+
public isRetryOpened: boolean = false;
|
148
|
+
public isPathDrag: boolean = false;
|
149
|
+
// eslint-disable-next-line
|
150
|
+
public searchedItems: { [key: string]: Object; }[] = [];
|
151
|
+
public searchWord: string;
|
152
|
+
public retryFiles: FileInfo[] = [];
|
153
|
+
public isApplySame: boolean = false;
|
154
|
+
public uploadEventArgs: BeforeSendEventArgs;
|
155
|
+
// eslint-disable-next-line
|
156
|
+
public dragData: { [key: string]: Object; }[] = [];
|
157
|
+
public dragNodes: string[] = [];
|
158
|
+
public dragPath: string = '';
|
159
|
+
public dropPath: string = '';
|
160
|
+
public isDragDrop: boolean = false;
|
161
|
+
public virtualDragElement: HTMLElement;
|
162
|
+
// eslint-disable-next-line
|
163
|
+
public dropData: Object;
|
164
|
+
public treeExpandTimer: number = null;
|
165
|
+
public dragCursorPosition: PositionModel = { left: 44, top: 18 };
|
166
|
+
public isDropEnd: boolean = false;
|
167
|
+
public dragCount: number = 0;
|
168
|
+
// eslint-disable-next-line
|
169
|
+
public droppedObjects: Object[] = [];
|
170
|
+
public destinationPath: string;
|
171
|
+
public uploadingCount: number = 0;
|
172
|
+
public uploadedCount: number = 0;
|
173
|
+
|
174
|
+
/**
|
175
|
+
* Specifies the AJAX settings of the file manager.
|
176
|
+
*
|
177
|
+
* @default {
|
178
|
+
* getImageUrl: null;
|
179
|
+
* url: null;
|
180
|
+
* uploadUrl: null;
|
181
|
+
* downloadUrl: null;
|
182
|
+
* }
|
183
|
+
*/
|
184
|
+
@Complex<AjaxSettingsModel>({}, AjaxSettings)
|
185
|
+
public ajaxSettings: AjaxSettingsModel;
|
186
|
+
|
187
|
+
/**
|
188
|
+
* Enables or disables drag-and-drop of files.
|
189
|
+
*
|
190
|
+
* @default false
|
191
|
+
*/
|
192
|
+
@Property(false)
|
193
|
+
public allowDragAndDrop: boolean;
|
194
|
+
|
195
|
+
/**
|
196
|
+
* Enables or disables the multiple files selection of the file manager.
|
197
|
+
*
|
198
|
+
* @default true
|
199
|
+
*/
|
200
|
+
@Property(true)
|
201
|
+
public allowMultiSelection: boolean;
|
202
|
+
|
203
|
+
/**
|
204
|
+
* Specifies the context menu settings of the file manager.
|
205
|
+
*
|
206
|
+
* @default {
|
207
|
+
* file: ['Open','|', 'Cut', 'Copy', '|', 'Delete', 'Rename', '|', 'Details'],
|
208
|
+
* folder: ['Open','|', 'Cut', 'Copy', 'Paste', '|', 'Delete', 'Rename', '|', 'Details'],
|
209
|
+
* layout: ['SortBy', 'View', 'Refresh', '|', 'Paste', '|', 'NewFolder', 'Upload', '|', 'Details', '|', 'SelectAll'],
|
210
|
+
* visible: true,
|
211
|
+
* }
|
212
|
+
*/
|
213
|
+
@Complex<ContextMenuSettingsModel>({}, ContextMenuSettings)
|
214
|
+
public contextMenuSettings: ContextMenuSettingsModel;
|
215
|
+
|
216
|
+
/**
|
217
|
+
* Specifies the root CSS class of the file manager that allows you to customize the appearance by overriding the styles.
|
218
|
+
*
|
219
|
+
* @default ''
|
220
|
+
*/
|
221
|
+
@Property('')
|
222
|
+
public cssClass: string;
|
223
|
+
|
224
|
+
/**
|
225
|
+
* Specifies the details view settings of the file manager.
|
226
|
+
*
|
227
|
+
* @default {
|
228
|
+
* columns: [{
|
229
|
+
* field: 'name', headerText: 'Name', minWidth: 120, template: '<span class="e-fe-text">${name}</span>',
|
230
|
+
* customAttributes: { class: 'e-fe-grid-name'}}, { field: '_fm_modified', headerText: 'DateModified', type: 'dateTime',
|
231
|
+
* format: 'MMMM dd, yyyy HH:mm', minWidth: 120, width: '190' }, { field: 'size', headerText: 'Size', minWidth: 90, width: '110',
|
232
|
+
* template: '<span class="e-fe-size">${size}</span>' }
|
233
|
+
* ]
|
234
|
+
* }
|
235
|
+
*/
|
236
|
+
@Complex<DetailsViewSettingsModel>({}, DetailsViewSettings)
|
237
|
+
public detailsViewSettings: DetailsViewSettingsModel;
|
238
|
+
|
239
|
+
/**
|
240
|
+
* Defines whether to allow the cross-scripting site or not.
|
241
|
+
*
|
242
|
+
* @default true
|
243
|
+
*/
|
244
|
+
@Property(true)
|
245
|
+
public enableHtmlSanitizer: boolean;
|
246
|
+
|
247
|
+
/**
|
248
|
+
* Enables or disables persisting component's state between page reloads. If enabled, the following APIs will persist:
|
249
|
+
* 1. `view`: Represents the previous view of the file manager.
|
250
|
+
* 2. `path`: Represents the previous path of the file manager.
|
251
|
+
* 3. `selectedItems`: Represents the previous selected items in the file manager.
|
252
|
+
*
|
253
|
+
* @default false
|
254
|
+
*/
|
255
|
+
@Property(false)
|
256
|
+
public enablePersistence: boolean;
|
257
|
+
|
258
|
+
/**
|
259
|
+
* Specifies the height of the file manager.
|
260
|
+
*
|
261
|
+
* @default '400px'
|
262
|
+
*/
|
263
|
+
@Property('400px')
|
264
|
+
public height: string | number;
|
265
|
+
|
266
|
+
/**
|
267
|
+
* Specifies the initial view of the file manager.
|
268
|
+
* With the help of this property, initial view can be changed to details or largeicons view. The available views are:
|
269
|
+
* * `LargeIcons`
|
270
|
+
* * `Details`
|
271
|
+
*
|
272
|
+
* @default 'LargeIcons'
|
273
|
+
*/
|
274
|
+
@Property('LargeIcons')
|
275
|
+
public view: ViewType;
|
276
|
+
|
277
|
+
/**
|
278
|
+
* Specifies the navigationpane settings of the file manager.
|
279
|
+
*
|
280
|
+
* @default {
|
281
|
+
* maxWidth: '650px',
|
282
|
+
* minWidth: '240px',
|
283
|
+
* visible: true,
|
284
|
+
* sortOrder: 'None'
|
285
|
+
* }
|
286
|
+
*/
|
287
|
+
@Complex<NavigationPaneSettingsModel>({}, NavigationPaneSettings)
|
288
|
+
public navigationPaneSettings: NavigationPaneSettingsModel;
|
289
|
+
|
290
|
+
/**
|
291
|
+
* Specifies the current path of the file manager.
|
292
|
+
*
|
293
|
+
* @default '/'
|
294
|
+
*/
|
295
|
+
@Property('/')
|
296
|
+
public path: string;
|
297
|
+
|
298
|
+
/**
|
299
|
+
* Specifies the target element in which the File Manager’s dialog will be displayed.
|
300
|
+
* The default value is null, which refers to the File Manager element.
|
301
|
+
*
|
302
|
+
* @default null
|
303
|
+
*/
|
304
|
+
@Property(null)
|
305
|
+
public popupTarget: HTMLElement | string;
|
306
|
+
|
307
|
+
/**
|
308
|
+
* Specifies the search settings of the file manager.
|
309
|
+
*
|
310
|
+
* @default {
|
311
|
+
* allowSearchOnTyping: true,
|
312
|
+
* filterType: 'contains',
|
313
|
+
* ignoreCase: true
|
314
|
+
* }
|
315
|
+
*/
|
316
|
+
@Complex<SearchSettingsModel>({}, SearchSettings)
|
317
|
+
public searchSettings: SearchSettingsModel;
|
318
|
+
|
319
|
+
/**
|
320
|
+
* Specifies the selected folders and files name of the file manager.
|
321
|
+
*
|
322
|
+
* @default []
|
323
|
+
*/
|
324
|
+
@Property()
|
325
|
+
public selectedItems: string[];
|
326
|
+
|
327
|
+
/**
|
328
|
+
* Shows or hides the file extension in file manager.
|
329
|
+
*
|
330
|
+
* @default true
|
331
|
+
*/
|
332
|
+
@Property(true)
|
333
|
+
public showFileExtension: boolean;
|
334
|
+
|
335
|
+
/**
|
336
|
+
* Specifies the root folder alias name in file manager
|
337
|
+
*
|
338
|
+
* @default null
|
339
|
+
*/
|
340
|
+
@Property(null)
|
341
|
+
public rootAliasName: string;
|
342
|
+
|
343
|
+
/**
|
344
|
+
* Shows or hides the files and folders that are marked as hidden.
|
345
|
+
*
|
346
|
+
* @default false
|
347
|
+
*/
|
348
|
+
@Property(false)
|
349
|
+
public showHiddenItems: boolean;
|
350
|
+
|
351
|
+
/**
|
352
|
+
* Shows or hides the thumbnail images in largeicons view.
|
353
|
+
*
|
354
|
+
* @default true
|
355
|
+
*/
|
356
|
+
@Property(true)
|
357
|
+
public showThumbnail: boolean;
|
358
|
+
|
359
|
+
/**
|
360
|
+
* Specifies a value that indicates whether the folders and files are sorted in the ascending or descending order,
|
361
|
+
* or they are not sorted at all. The available types of sort orders are,
|
362
|
+
* `None` - Indicates that the folders and files are not sorted.
|
363
|
+
* `Ascending` - Indicates that the folders and files are sorted in the ascending order.
|
364
|
+
* `Descending` - Indicates that the folders and files are sorted in the descending order.
|
365
|
+
*
|
366
|
+
* @default 'Ascending'
|
367
|
+
*/
|
368
|
+
@Property('Ascending')
|
369
|
+
public sortOrder: SortOrder;
|
370
|
+
|
371
|
+
/**
|
372
|
+
* Specifies the field name being used as the sorting criteria to sort the files of the file manager component.
|
373
|
+
*
|
374
|
+
* @default 'name'
|
375
|
+
*/
|
376
|
+
@Property('name')
|
377
|
+
public sortBy: string;
|
378
|
+
|
379
|
+
/**
|
380
|
+
* Specifies the group of items aligned horizontally in the toolbar.
|
381
|
+
*
|
382
|
+
* @default {
|
383
|
+
* items: ['NewFolder', 'Upload', 'Cut', 'Copy', 'Paste', 'Delete',
|
384
|
+
* 'Download', 'Rename', 'SortBy', 'Refresh', 'Selection', 'View', 'Details'],
|
385
|
+
* visible: true
|
386
|
+
* }
|
387
|
+
*/
|
388
|
+
@Complex<ToolbarSettingsModel>({}, ToolbarSettings)
|
389
|
+
public toolbarSettings: ToolbarSettingsModel;
|
390
|
+
|
391
|
+
/**
|
392
|
+
* Specifies the upload settings for the file manager.
|
393
|
+
*
|
394
|
+
* @default {
|
395
|
+
* autoUpload: true,
|
396
|
+
* minFileSize: 0,
|
397
|
+
* maxFileSize: 30000000,
|
398
|
+
* allowedExtensions: '',
|
399
|
+
* autoClose: false
|
400
|
+
* }
|
401
|
+
*/
|
402
|
+
@Complex<UploadSettingsModel>({}, UploadSettings)
|
403
|
+
public uploadSettings: UploadSettingsModel;
|
404
|
+
|
405
|
+
/**
|
406
|
+
* Specifies the width of the file manager.
|
407
|
+
*
|
408
|
+
* @default '100%'
|
409
|
+
*/
|
410
|
+
@Property('100%')
|
411
|
+
public width: string | number;
|
412
|
+
|
413
|
+
/**
|
414
|
+
* Triggers before the file/folder is rendered.
|
415
|
+
*
|
416
|
+
* @event
|
417
|
+
*/
|
418
|
+
@Event()
|
419
|
+
public fileLoad: EmitType<FileLoadEventArgs>;
|
420
|
+
|
421
|
+
/**
|
422
|
+
* Triggers before the file/folder is opened.
|
423
|
+
*
|
424
|
+
* @event
|
425
|
+
*/
|
426
|
+
@Event()
|
427
|
+
public fileOpen: EmitType<FileOpenEventArgs>;
|
428
|
+
|
429
|
+
/**
|
430
|
+
* Triggers before sending the download request to the server.
|
431
|
+
*
|
432
|
+
* @event
|
433
|
+
*/
|
434
|
+
@Event()
|
435
|
+
public beforeDownload: EmitType<BeforeDownloadEventArgs>;
|
436
|
+
|
437
|
+
/**
|
438
|
+
* Triggers before sending the getImage request to the server.
|
439
|
+
*
|
440
|
+
* @event
|
441
|
+
*/
|
442
|
+
@Event()
|
443
|
+
public beforeImageLoad: EmitType<BeforeImageLoadEventArgs>;
|
444
|
+
|
445
|
+
/**
|
446
|
+
* Triggers before the dialog is closed.
|
447
|
+
*
|
448
|
+
* @event
|
449
|
+
*/
|
450
|
+
@Event()
|
451
|
+
public beforePopupClose: EmitType<BeforePopupOpenCloseEventArgs>;
|
452
|
+
|
453
|
+
/**
|
454
|
+
* Triggers before the dialog is opened.
|
455
|
+
*
|
456
|
+
* @event
|
457
|
+
*/
|
458
|
+
@Event()
|
459
|
+
public beforePopupOpen: EmitType<BeforePopupOpenCloseEventArgs>;
|
460
|
+
|
461
|
+
/**
|
462
|
+
* Triggers before sending the AJAX request to the server.
|
463
|
+
*
|
464
|
+
* @event
|
465
|
+
*/
|
466
|
+
@Event()
|
467
|
+
public beforeSend: EmitType<BeforeSendEventArgs>;
|
468
|
+
|
469
|
+
/**
|
470
|
+
* Triggers when the file manager component is created.
|
471
|
+
*
|
472
|
+
* @event
|
473
|
+
*/
|
474
|
+
/* eslint-disable */
|
475
|
+
@Event()
|
476
|
+
public created: EmitType<Object>;
|
477
|
+
/* eslint-enable */
|
478
|
+
|
479
|
+
/**
|
480
|
+
* Triggers when the file manager component is destroyed.
|
481
|
+
*
|
482
|
+
* @event
|
483
|
+
*/
|
484
|
+
/* eslint-disable */
|
485
|
+
@Event()
|
486
|
+
public destroyed: EmitType<Object>;
|
487
|
+
/* eslint-enable */
|
488
|
+
|
489
|
+
/**
|
490
|
+
* Triggers when the file/folder dragging is started.
|
491
|
+
*
|
492
|
+
* @event
|
493
|
+
*/
|
494
|
+
@Event()
|
495
|
+
public fileDragStart: EmitType<FileDragEventArgs>;
|
496
|
+
|
497
|
+
/**
|
498
|
+
* Triggers while dragging the file/folder.
|
499
|
+
*
|
500
|
+
* @event
|
501
|
+
*/
|
502
|
+
@Event()
|
503
|
+
public fileDragging: EmitType<FileDragEventArgs>;
|
504
|
+
|
505
|
+
/**
|
506
|
+
* Triggers when the file/folder is about to be dropped at the target.
|
507
|
+
*
|
508
|
+
* @event
|
509
|
+
*/
|
510
|
+
@Event()
|
511
|
+
public fileDragStop: EmitType<FileDragEventArgs>;
|
512
|
+
|
513
|
+
/**
|
514
|
+
* Triggers when the file/folder is dropped.
|
515
|
+
*
|
516
|
+
* @event
|
517
|
+
*/
|
518
|
+
@Event()
|
519
|
+
public fileDropped: EmitType<FileDragEventArgs>;
|
520
|
+
|
521
|
+
/**
|
522
|
+
* Triggers before the file/folder is selected.
|
523
|
+
*
|
524
|
+
* @event
|
525
|
+
*/
|
526
|
+
@Event()
|
527
|
+
public fileSelection: EmitType<FileSelectionEventArgs>;
|
528
|
+
|
529
|
+
/**
|
530
|
+
* Triggers when the file/folder is selected/unselected.
|
531
|
+
*
|
532
|
+
* @event
|
533
|
+
*/
|
534
|
+
@Event()
|
535
|
+
public fileSelect: EmitType<FileSelectEventArgs>;
|
536
|
+
|
537
|
+
/**
|
538
|
+
* Triggers when the context menu item is clicked.
|
539
|
+
*
|
540
|
+
* @event
|
541
|
+
*/
|
542
|
+
@Event()
|
543
|
+
public menuClick: EmitType<MenuClickEventArgs>;
|
544
|
+
|
545
|
+
/**
|
546
|
+
* Triggers before the context menu is opened.
|
547
|
+
*
|
548
|
+
* @event
|
549
|
+
*/
|
550
|
+
@Event()
|
551
|
+
public menuOpen: EmitType<MenuOpenEventArgs>;
|
552
|
+
|
553
|
+
/**
|
554
|
+
* Triggers when the AJAX request is failed.
|
555
|
+
*
|
556
|
+
* @event
|
557
|
+
*/
|
558
|
+
@Event()
|
559
|
+
public failure: EmitType<FailureEventArgs>;
|
560
|
+
|
561
|
+
/**
|
562
|
+
* Triggers when the dialog is closed.
|
563
|
+
*
|
564
|
+
* @event
|
565
|
+
*/
|
566
|
+
@Event()
|
567
|
+
public popupClose: EmitType<PopupOpenCloseEventArgs>;
|
568
|
+
|
569
|
+
/**
|
570
|
+
* Triggers when the dialog is opened.
|
571
|
+
*
|
572
|
+
* @event
|
573
|
+
*/
|
574
|
+
@Event()
|
575
|
+
public popupOpen: EmitType<PopupOpenCloseEventArgs>;
|
576
|
+
|
577
|
+
/**
|
578
|
+
* Triggers when the AJAX request is success.
|
579
|
+
* @event
|
580
|
+
*/
|
581
|
+
@Event()
|
582
|
+
public success: EmitType<SuccessEventArgs>;
|
583
|
+
|
584
|
+
/**
|
585
|
+
* Triggers when the toolbar item is clicked.
|
586
|
+
*
|
587
|
+
* @event
|
588
|
+
*/
|
589
|
+
@Event()
|
590
|
+
public toolbarClick: EmitType<ToolbarClickEventArgs>;
|
591
|
+
|
592
|
+
/**
|
593
|
+
* Triggers before creating the toolbar.
|
594
|
+
*
|
595
|
+
* @event
|
596
|
+
*/
|
597
|
+
@Event()
|
598
|
+
public toolbarCreate: EmitType<ToolbarCreateEventArgs>;
|
599
|
+
|
600
|
+
/**
|
601
|
+
* Triggers before rendering each file item in upload dialog box.
|
602
|
+
*
|
603
|
+
* @event
|
604
|
+
*/
|
605
|
+
@Event()
|
606
|
+
public uploadListCreate: EmitType<UploadListCreateArgs>;
|
607
|
+
|
608
|
+
constructor(options?: FileManagerModel, element?: string | HTMLElement) {
|
609
|
+
super(options, <HTMLElement | string>element);
|
610
|
+
FileManager.Inject(BreadCrumbBar, LargeIconsView, ContextMenu);
|
611
|
+
}
|
612
|
+
|
613
|
+
/**
|
614
|
+
* Get component name.
|
615
|
+
*
|
616
|
+
* @returns {string} - returns module name.
|
617
|
+
* @private
|
618
|
+
*/
|
619
|
+
public getModuleName(): string {
|
620
|
+
return 'filemanager';
|
621
|
+
}
|
622
|
+
|
623
|
+
/**
|
624
|
+
* Initialize the event handler
|
625
|
+
*
|
626
|
+
* @returns {void}
|
627
|
+
*/
|
628
|
+
protected preRender(): void {
|
629
|
+
if (isNOU(this.element.id) || this.element.id === '') {
|
630
|
+
this.element.setAttribute('id', getUniqueID('filemanager'));
|
631
|
+
}
|
632
|
+
this.ensurePath();
|
633
|
+
this.feParent = [];
|
634
|
+
this.feFiles = [];
|
635
|
+
setAttr(this.element, { 'width': formatUnit(this.width), 'height': formatUnit(this.height) });
|
636
|
+
this.isDevice = Browser.isDevice as boolean;
|
637
|
+
this.isMobile = this.checkMobile();
|
638
|
+
if (this.isMobile) {
|
639
|
+
this.setProperties({ navigationPaneSettings: { visible: false } }, true);
|
640
|
+
}
|
641
|
+
const ele: Element = closest(this.element, '.e-bigger');
|
642
|
+
this.isBigger = ele ? true : false;
|
643
|
+
this.activeModule = (this.view === 'LargeIcons') ? 'largeiconsview' : 'detailsview';
|
644
|
+
createSpinner({ target: this.element }, createElement);
|
645
|
+
this.addWrapper();
|
646
|
+
this.keyConfigs = {
|
647
|
+
altN: 'alt+n',
|
648
|
+
f5: 'f5',
|
649
|
+
ctrlShift1: 'ctrl+shift+1',
|
650
|
+
ctrlShift2: 'ctrl+shift+2',
|
651
|
+
ctrlU: 'ctrl+u'
|
652
|
+
};
|
653
|
+
this.localeObj = new L10n(this.getModuleName(), defaultLocale, this.locale);
|
654
|
+
}
|
655
|
+
|
656
|
+
/**
|
657
|
+
* Gets the properties to be maintained upon browser refresh.
|
658
|
+
*
|
659
|
+
* @returns {string} - returns the persisted data.
|
660
|
+
* @hidden
|
661
|
+
*/
|
662
|
+
public getPersistData(): string {
|
663
|
+
const keyEntity: string[] = ['view', 'path', 'selectedItems'];
|
664
|
+
return this.addOnPersist(keyEntity);
|
665
|
+
}
|
666
|
+
|
667
|
+
/**
|
668
|
+
* To provide the array of modules needed for component rendering
|
669
|
+
*
|
670
|
+
* @returns {ModuleDeclaration[]} - returns module declaration.
|
671
|
+
* @hidden
|
672
|
+
*/
|
673
|
+
public requiredModules(): ModuleDeclaration[] {
|
674
|
+
const modules: ModuleDeclaration[] = [];
|
675
|
+
modules.push({
|
676
|
+
member: 'breadcrumbbar',
|
677
|
+
args: [this]
|
678
|
+
});
|
679
|
+
modules.push({
|
680
|
+
member: 'largeiconsview',
|
681
|
+
args: [this]
|
682
|
+
});
|
683
|
+
if (this.toolbarSettings.visible) {
|
684
|
+
modules.push({
|
685
|
+
member: 'toolbar',
|
686
|
+
args: [this]
|
687
|
+
});
|
688
|
+
}
|
689
|
+
if (this.navigationPaneSettings.visible) {
|
690
|
+
modules.push({
|
691
|
+
member: 'navigationpane',
|
692
|
+
args: [this]
|
693
|
+
});
|
694
|
+
}
|
695
|
+
if (this.view) {
|
696
|
+
modules.push({
|
697
|
+
member: 'detailsview',
|
698
|
+
args: [this]
|
699
|
+
});
|
700
|
+
}
|
701
|
+
if (this.contextMenuSettings.visible && !this.isDevice) {
|
702
|
+
modules.push({
|
703
|
+
member: 'contextmenu',
|
704
|
+
args: [this]
|
705
|
+
});
|
706
|
+
}
|
707
|
+
return modules;
|
708
|
+
}
|
709
|
+
|
710
|
+
/**
|
711
|
+
* To Initialize the control rendering
|
712
|
+
*
|
713
|
+
* @private
|
714
|
+
* @returns {void}
|
715
|
+
*/
|
716
|
+
protected render(): void {
|
717
|
+
this.initialize();
|
718
|
+
const slItems: string[] = isNOU(this.selectedItems) ? [] :
|
719
|
+
this.allowMultiSelection ? this.selectedItems : this.selectedItems.slice(this.selectedItems.length - 1);
|
720
|
+
this.setProperties({ selectedItems: slItems }, true);
|
721
|
+
this.fileView = this.view;
|
722
|
+
this.setRtl(this.enableRtl);
|
723
|
+
this.addEventListeners();
|
724
|
+
read(this, (this.path !== this.originalPath) ? events.initialEnd : events.finalizeEnd, this.path);
|
725
|
+
this.adjustHeight();
|
726
|
+
if (isNOU(this.navigationpaneModule)) {
|
727
|
+
this.splitterObj.collapse(this.enableRtl ? 1 : 0);
|
728
|
+
const bar: Element = select('.' + CLS.SPLIT_BAR, this.element);
|
729
|
+
bar.classList.add(CLS.DISPLAY_NONE);
|
730
|
+
}
|
731
|
+
this.wireEvents();
|
732
|
+
this.renderComplete();
|
733
|
+
}
|
734
|
+
|
735
|
+
private ensurePath(): void {
|
736
|
+
let currentPath: string = this.path;
|
737
|
+
if (isNOU(currentPath)) {
|
738
|
+
currentPath = '/';
|
739
|
+
}
|
740
|
+
if (currentPath.lastIndexOf('/') !== (currentPath.length - 1)) {
|
741
|
+
currentPath = currentPath + '/';
|
742
|
+
}
|
743
|
+
this.originalPath = currentPath;
|
744
|
+
const paths: string[] = currentPath.split('/');
|
745
|
+
this.setProperties({ path: paths[0] + '/' }, true);
|
746
|
+
this.pathNames = [];
|
747
|
+
this.pathId = ['fe_tree'];
|
748
|
+
this.itemData = [];
|
749
|
+
}
|
750
|
+
|
751
|
+
private initialize(): void {
|
752
|
+
if (this.isMobile) { addClass([this.element], CLS.MOBILE); }
|
753
|
+
if (this.allowMultiSelection) { addClass([this.element], CLS.CHECK_SELECT); }
|
754
|
+
this.addCssClass(null, this.cssClass);
|
755
|
+
this.renderFileUpload();
|
756
|
+
}
|
757
|
+
|
758
|
+
private addWrapper(): void {
|
759
|
+
const headerWrap: HTMLElement = this.createElement('div', { id: this.element.id + CLS.TOOLBAR_ID });
|
760
|
+
this.element.appendChild(headerWrap);
|
761
|
+
const layoutWrap: HTMLElement = this.createElement('div', {
|
762
|
+
id: this.element.id + CLS.LAYOUT_ID, className: CLS.LAYOUT
|
763
|
+
});
|
764
|
+
this.element.appendChild(layoutWrap);
|
765
|
+
const navigationWrap: HTMLElement = this.createElement('div', {
|
766
|
+
id: this.element.id + CLS.NAVIGATION_ID, className: CLS.NAVIGATION
|
767
|
+
});
|
768
|
+
const treeWrap: HTMLElement = this.createElement('div', {
|
769
|
+
id: this.element.id + CLS.TREE_ID
|
770
|
+
});
|
771
|
+
navigationWrap.appendChild(treeWrap);
|
772
|
+
const contentWrap: HTMLElement = this.createElement('div', {
|
773
|
+
id: this.element.id + CLS.CONTENT_ID, className: CLS.LAYOUT_CONTENT
|
774
|
+
});
|
775
|
+
this.breadCrumbBarNavigation = this.createElement('div', {
|
776
|
+
id: this.element.id + CLS.BREADCRUMBBAR_ID,
|
777
|
+
className: CLS.BREADCRUMBS
|
778
|
+
});
|
779
|
+
contentWrap.appendChild(this.breadCrumbBarNavigation);
|
780
|
+
const gridWrap: HTMLElement = this.createElement('div', {
|
781
|
+
id: this.element.id + CLS.GRID_ID
|
782
|
+
});
|
783
|
+
contentWrap.appendChild(gridWrap);
|
784
|
+
const largeiconWrap: HTMLElement = this.createElement('div', {
|
785
|
+
id: this.element.id + CLS.LARGEICON_ID,
|
786
|
+
className: CLS.LARGE_ICONS, attrs: { 'role': 'group' }
|
787
|
+
});
|
788
|
+
contentWrap.appendChild(largeiconWrap);
|
789
|
+
const overlay: HTMLElement = this.createElement('span', { className: CLS.OVERLAY });
|
790
|
+
contentWrap.appendChild(overlay);
|
791
|
+
let paneSettings: PanePropertiesModel[];
|
792
|
+
if (!this.enableRtl) {
|
793
|
+
layoutWrap.appendChild(navigationWrap);
|
794
|
+
layoutWrap.appendChild(contentWrap);
|
795
|
+
paneSettings = [
|
796
|
+
{
|
797
|
+
size: '25%', min: this.navigationPaneSettings.minWidth.toString(),
|
798
|
+
max: this.navigationPaneSettings.maxWidth.toString()
|
799
|
+
},
|
800
|
+
{ size: '75%', min: '270px' }
|
801
|
+
];
|
802
|
+
} else {
|
803
|
+
layoutWrap.appendChild(contentWrap);
|
804
|
+
layoutWrap.appendChild(navigationWrap);
|
805
|
+
paneSettings = [
|
806
|
+
{ size: '75%', min: '270px' },
|
807
|
+
{
|
808
|
+
size: '25%', min: this.navigationPaneSettings.minWidth.toString(),
|
809
|
+
max: this.navigationPaneSettings.maxWidth.toString()
|
810
|
+
}
|
811
|
+
];
|
812
|
+
}
|
813
|
+
this.splitterObj = new Splitter({
|
814
|
+
paneSettings: paneSettings,
|
815
|
+
width: '100%',
|
816
|
+
enableRtl: false,
|
817
|
+
enableHtmlSanitizer: this.enableHtmlSanitizer,
|
818
|
+
resizing: this.splitterResize.bind(this)
|
819
|
+
});
|
820
|
+
this.splitterObj.isStringTemplate = true;
|
821
|
+
this.splitterObj.appendTo(layoutWrap);
|
822
|
+
const dialogWrap: HTMLElement = this.createElement('div', { id: this.element.id + CLS.DIALOG_ID });
|
823
|
+
this.element.appendChild(dialogWrap);
|
824
|
+
const menuWrap: HTMLElement = this.createElement('ul', { id: this.element.id + CLS.CONTEXT_MENU_ID });
|
825
|
+
this.element.appendChild(menuWrap);
|
826
|
+
const dialogImgWrap: HTMLElement = this.createElement('div', { id: this.element.id + CLS.IMG_DIALOG_ID });
|
827
|
+
this.element.appendChild(dialogImgWrap);
|
828
|
+
const extnDialogWrap: HTMLElement = this.createElement('div', { id: this.element.id + CLS.EXTN_DIALOG_ID });
|
829
|
+
this.element.appendChild(extnDialogWrap);
|
830
|
+
const uploadDialogWrap: HTMLElement = this.createElement('div', { id: this.element.id + CLS.UPLOAD_DIALOG_ID });
|
831
|
+
this.element.appendChild(uploadDialogWrap);
|
832
|
+
}
|
833
|
+
|
834
|
+
private adjustHeight(): void {
|
835
|
+
const toolbar: HTMLElement = <HTMLElement>select('#' + this.element.id + CLS.TOOLBAR_ID, this.element);
|
836
|
+
const toolBarHeight: number = toolbar ? toolbar.offsetHeight : 0;
|
837
|
+
if (this.splitterObj) {
|
838
|
+
this.splitterObj.height = (this.element.clientHeight - toolBarHeight).toString();
|
839
|
+
this.splitterObj.dataBind();
|
840
|
+
}
|
841
|
+
}
|
842
|
+
/* istanbul ignore next */
|
843
|
+
private splitterResize(): void {
|
844
|
+
this.notify(events.splitterResize, {});
|
845
|
+
}
|
846
|
+
|
847
|
+
private splitterAdjust(): void {
|
848
|
+
const bar: Element = select('.' + CLS.SPLIT_BAR, this.element);
|
849
|
+
if (this.navigationPaneSettings.visible) {
|
850
|
+
this.splitterObj.expand(this.enableRtl ? 1 : 0);
|
851
|
+
bar.classList.remove(CLS.DISPLAY_NONE);
|
852
|
+
} else {
|
853
|
+
this.splitterObj.collapse(this.enableRtl ? 1 : 0);
|
854
|
+
bar.classList.add(CLS.DISPLAY_NONE);
|
855
|
+
}
|
856
|
+
}
|
857
|
+
|
858
|
+
private addCssClass(oldOne: string, newOne: string): void {
|
859
|
+
if (!isNOU(oldOne) && oldOne !== '') {
|
860
|
+
removeClass([this.element], oldOne.split(' '));
|
861
|
+
}
|
862
|
+
if (!isNOU(newOne) && newOne !== '') {
|
863
|
+
addClass([this.element], newOne.split(' '));
|
864
|
+
}
|
865
|
+
}
|
866
|
+
|
867
|
+
private showSpinner(): void {
|
868
|
+
showSpinner(this.element);
|
869
|
+
}
|
870
|
+
|
871
|
+
private hideSpinner(): void {
|
872
|
+
hideSpinner(this.element);
|
873
|
+
}
|
874
|
+
|
875
|
+
private onContextMenu(e: MouseEvent): void {
|
876
|
+
e.preventDefault();
|
877
|
+
}
|
878
|
+
|
879
|
+
private checkMobile(): boolean {
|
880
|
+
return (/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(Browser.userAgent.toLowerCase())
|
881
|
+
&& /mobile/i.test(Browser.userAgent.toLowerCase()));
|
882
|
+
}
|
883
|
+
|
884
|
+
private renderFileUpload(): void {
|
885
|
+
const id: string = this.element.id + CLS.UPLOAD_ID;
|
886
|
+
const uploadEle: HTMLElement = this.createElement('input', { id: id, attrs: { name: 'uploadFiles', type: 'file' } });
|
887
|
+
this.element.appendChild(uploadEle);
|
888
|
+
this.uploadDialogObj = new Dialog({
|
889
|
+
header: getLocaleText(this, 'Header-Upload'),
|
890
|
+
content: uploadEle,
|
891
|
+
animationSettings: { effect: 'None' },
|
892
|
+
showCloseIcon: true,
|
893
|
+
closeOnEscape: true,
|
894
|
+
visible: false,
|
895
|
+
isModal: true,
|
896
|
+
width: '350px',
|
897
|
+
target: this.popupTarget ? this.popupTarget : '#' + this.element.id,
|
898
|
+
cssClass: getCssClass(this, this.isMobile ? CLS.MOB_POPUP : CLS.ROOT_POPUP),
|
899
|
+
locale: this.locale,
|
900
|
+
allowDragging: true,
|
901
|
+
position: { X: 'center', Y: 'center' },
|
902
|
+
enableRtl: this.enableRtl,
|
903
|
+
enableHtmlSanitizer: this.enableHtmlSanitizer,
|
904
|
+
open: this.onOpen.bind(this),
|
905
|
+
close: this.onClose.bind(this),
|
906
|
+
beforeOpen: this.onBeforeOpen.bind(this),
|
907
|
+
beforeClose: this.onBeforeClose.bind(this)
|
908
|
+
});
|
909
|
+
this.uploadDialogObj.appendTo('#' + this.element.id + CLS.UPLOAD_DIALOG_ID);
|
910
|
+
this.renderUploadBox();
|
911
|
+
}
|
912
|
+
|
913
|
+
private renderUploadBox(): void {
|
914
|
+
const uploadUrl: string = this.ajaxSettings.uploadUrl ? this.ajaxSettings.uploadUrl : this.ajaxSettings.url;
|
915
|
+
this.uploadObj = new Uploader({
|
916
|
+
dropArea: <HTMLElement>select('#' + this.element.id + CLS.CONTENT_ID, this.element),
|
917
|
+
asyncSettings: {
|
918
|
+
saveUrl: uploadUrl,
|
919
|
+
removeUrl: uploadUrl
|
920
|
+
},
|
921
|
+
locale: this.locale,
|
922
|
+
enableRtl: this.enableRtl,
|
923
|
+
uploading: this.onUploading.bind(this),
|
924
|
+
removing: this.onRemoving.bind(this),
|
925
|
+
canceling: this.onCancel.bind(this),
|
926
|
+
clearing: this.onClearing.bind(this),
|
927
|
+
selected: this.onSelected.bind(this),
|
928
|
+
success: this.onUploadSuccess.bind(this),
|
929
|
+
failure: this.onUploadFailure.bind(this),
|
930
|
+
autoUpload: this.uploadSettings.autoUpload,
|
931
|
+
minFileSize: this.uploadSettings.minFileSize,
|
932
|
+
maxFileSize: this.uploadSettings.maxFileSize,
|
933
|
+
allowedExtensions: this.uploadSettings.allowedExtensions,
|
934
|
+
fileListRendering: this.onFileListRender.bind(this)
|
935
|
+
});
|
936
|
+
this.uploadObj.appendTo('#' + this.element.id + CLS.UPLOAD_ID);
|
937
|
+
}
|
938
|
+
|
939
|
+
private onFileListRender(args: UploadListCreateArgs): void {
|
940
|
+
this.trigger('uploadListCreate', args);
|
941
|
+
}
|
942
|
+
|
943
|
+
private updateUploader(): void {
|
944
|
+
this.uploadObj.autoUpload = this.uploadSettings.autoUpload;
|
945
|
+
this.uploadObj.minFileSize = this.uploadSettings.minFileSize;
|
946
|
+
this.uploadObj.maxFileSize = this.uploadSettings.maxFileSize;
|
947
|
+
this.uploadObj.allowedExtensions = this.uploadSettings.allowedExtensions;
|
948
|
+
this.uploadObj.dataBind();
|
949
|
+
}
|
950
|
+
|
951
|
+
private onBeforeOpen(args: BeforeOpenEventArgs): void {
|
952
|
+
const eventArgs: BeforePopupOpenCloseEventArgs = {
|
953
|
+
cancel: args.cancel, popupName: 'Upload', popupModule: this.uploadDialogObj
|
954
|
+
};
|
955
|
+
this.trigger('beforePopupOpen', eventArgs, (eventargs: BeforePopupOpenCloseEventArgs) => {
|
956
|
+
args.cancel = eventargs.cancel;
|
957
|
+
});
|
958
|
+
}
|
959
|
+
|
960
|
+
private onBeforeClose(args: BeforeCloseEventArgs): void {
|
961
|
+
const eventArgs: BeforePopupOpenCloseEventArgs = {
|
962
|
+
cancel: args.cancel, popupName: 'Upload', popupModule: this.uploadDialogObj
|
963
|
+
};
|
964
|
+
this.trigger('beforePopupClose', eventArgs, (eventargs: BeforePopupOpenCloseEventArgs) => {
|
965
|
+
args.cancel = eventargs.cancel;
|
966
|
+
});
|
967
|
+
}
|
968
|
+
|
969
|
+
private onOpen(): void {
|
970
|
+
this.isOpened = true;
|
971
|
+
this.uploadDialogObj.element.focus();
|
972
|
+
const args: PopupOpenCloseEventArgs = {
|
973
|
+
popupModule: this.uploadDialogObj, popupName: 'Upload',
|
974
|
+
element: this.uploadDialogObj.element
|
975
|
+
};
|
976
|
+
this.trigger('popupOpen', args);
|
977
|
+
}
|
978
|
+
|
979
|
+
private onClose(): void {
|
980
|
+
this.isOpened = false;
|
981
|
+
this.uploadObj.clearAll();
|
982
|
+
const args: PopupOpenCloseEventArgs = {
|
983
|
+
popupModule: this.uploadDialogObj, popupName: 'Upload',
|
984
|
+
element: this.uploadDialogObj.element
|
985
|
+
};
|
986
|
+
this.trigger('popupClose', args);
|
987
|
+
}
|
988
|
+
/* istanbul ignore next */
|
989
|
+
private onUploading(args: UploadingEventArgs): void {
|
990
|
+
let action: string = 'save';
|
991
|
+
if ((this.retryArgs.length !== 0)) {
|
992
|
+
for (let i: number = 0; i < this.retryArgs.length; i++) {
|
993
|
+
if (args.fileData.name === this.retryArgs[i].file.name) {
|
994
|
+
action = this.retryArgs[i].action;
|
995
|
+
this.retryArgs.splice(i, 1);
|
996
|
+
i = this.retryArgs.length;
|
997
|
+
}
|
998
|
+
}
|
999
|
+
}
|
1000
|
+
const data: string = JSON.stringify(getValue(this.pathId[this.pathId.length - 1], this.feParent));
|
1001
|
+
args.customFormData = [{ 'path': this.path }, { 'action': action }, { 'data': data }];
|
1002
|
+
const uploadUrl: string = this.ajaxSettings.uploadUrl ? this.ajaxSettings.uploadUrl : this.ajaxSettings.url;
|
1003
|
+
// eslint-disable-next-line
|
1004
|
+
const ajaxSettings: Object = {
|
1005
|
+
url: uploadUrl,
|
1006
|
+
type: 'POST',
|
1007
|
+
mode: true,
|
1008
|
+
dataType: null,
|
1009
|
+
contentType: null,
|
1010
|
+
data: JSON.stringify(args.customFormData),
|
1011
|
+
onSuccess: null,
|
1012
|
+
onFailure: null,
|
1013
|
+
beforeSend: null
|
1014
|
+
};
|
1015
|
+
this.uploadEventArgs = { action: 'Upload', ajaxSettings: ajaxSettings, cancel: false };
|
1016
|
+
this.trigger('beforeSend', this.uploadEventArgs, (uploadEventArgs: BeforeSendEventArgs) => {
|
1017
|
+
args.customFormData = JSON.parse(getValue('data', uploadEventArgs.ajaxSettings));
|
1018
|
+
args.cancel = uploadEventArgs.cancel;
|
1019
|
+
// eslint-disable-next-line
|
1020
|
+
const eventArgs: Object = {
|
1021
|
+
cancel: false,
|
1022
|
+
httpRequest: args.currentRequest
|
1023
|
+
};
|
1024
|
+
if (typeof getValue('beforeSend', uploadEventArgs.ajaxSettings) === 'function') {
|
1025
|
+
getValue('beforeSend', uploadEventArgs.ajaxSettings)(eventArgs);
|
1026
|
+
if (getValue('cancel', eventArgs)) {
|
1027
|
+
args.cancel = getValue('cancel', eventArgs);
|
1028
|
+
}
|
1029
|
+
}
|
1030
|
+
});
|
1031
|
+
}
|
1032
|
+
|
1033
|
+
private onRemoving(): void {
|
1034
|
+
this.onFileUploadSuccess({ count: 1 });
|
1035
|
+
if (this.uploadObj.getFilesData().length === 1) {
|
1036
|
+
this.uploadDialogObj.hide();
|
1037
|
+
}
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
/* istanbul ignore next */
|
1041
|
+
private onCancel(args: CancelEventArgs): void {
|
1042
|
+
const data: string = JSON.stringify(getValue(this.pathId[this.pathId.length - 1], this.feParent));
|
1043
|
+
args.customFormData = [{ 'path': this.path }, { 'action': 'remove' }, { 'data': data }];
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
/* istanbul ignore next */
|
1047
|
+
private onClearing(): void {
|
1048
|
+
if (this.isOpened) {
|
1049
|
+
this.uploadDialogObj.hide();
|
1050
|
+
}
|
1051
|
+
}
|
1052
|
+
/* istanbul ignore next */
|
1053
|
+
private onSelected(args: SelectedEventArgs): void {
|
1054
|
+
if (args.filesData.length === 0) { return; }
|
1055
|
+
this.uploadingCount = args.filesData.length;
|
1056
|
+
this.uploadedCount = 0;
|
1057
|
+
// eslint-disable-next-line
|
1058
|
+
const details: Object = getPathObject(this);
|
1059
|
+
if (!hasUploadAccess(details)) {
|
1060
|
+
args.cancel = true;
|
1061
|
+
createDeniedDialog(this, details, events.permissionUpload);
|
1062
|
+
return;
|
1063
|
+
}
|
1064
|
+
this.uploadDialogObj.show();
|
1065
|
+
}
|
1066
|
+
|
1067
|
+
// eslint-disable-next-line
|
1068
|
+
private onFileUploadSuccess(args: { [key: string]: Object; }): void {
|
1069
|
+
this.uploadedCount = this.uploadedCount + (<number>args.count) ;
|
1070
|
+
if (this.uploadSettings.autoClose && (this.uploadingCount === this.uploadedCount)) {
|
1071
|
+
this.uploadDialogObj.hide();
|
1072
|
+
}
|
1073
|
+
}
|
1074
|
+
|
1075
|
+
/* istanbul ignore next */
|
1076
|
+
// eslint-disable-next-line
|
1077
|
+
private onUploadSuccess(files: Object): void {
|
1078
|
+
const args: SuccessEventArgs = { action: 'Upload', result: files };
|
1079
|
+
this.trigger('success', args);
|
1080
|
+
this.itemData = [getValue(this.pathId[this.pathId.length - 1], this.feParent)];
|
1081
|
+
read(this, events.pathChanged, this.path);
|
1082
|
+
this.onFileUploadSuccess({ count: 1 });
|
1083
|
+
if (typeof getValue('onSuccess', this.uploadEventArgs.ajaxSettings) === 'function') {
|
1084
|
+
getValue('onSuccess', this.uploadEventArgs.ajaxSettings)();
|
1085
|
+
}
|
1086
|
+
}
|
1087
|
+
/* istanbul ignore next */
|
1088
|
+
// eslint-disable-next-line
|
1089
|
+
private onUploadFailure(files: Object): void {
|
1090
|
+
// eslint-disable-next-line
|
1091
|
+
const response: object = getValue('response', files);
|
1092
|
+
const statusText: string = getValue('statusText', response);
|
1093
|
+
if (statusText !== '') { setValue('statusText', statusText, files); }
|
1094
|
+
const args: FailureEventArgs = { action: 'Upload', error: files };
|
1095
|
+
this.trigger('failure', args);
|
1096
|
+
if (getValue('statusCode', response) === 400) {
|
1097
|
+
this.retryFiles.push(getValue('file', files));
|
1098
|
+
if (!this.isRetryOpened) { createExtDialog(this, 'UploadRetry'); }
|
1099
|
+
}
|
1100
|
+
if (typeof getValue('onFailure', this.uploadEventArgs.ajaxSettings) === 'function') {
|
1101
|
+
getValue('onFailure', this.uploadEventArgs.ajaxSettings)();
|
1102
|
+
}
|
1103
|
+
}
|
1104
|
+
|
1105
|
+
private onInitialEnd(): void {
|
1106
|
+
setNextPath(this, this.path);
|
1107
|
+
}
|
1108
|
+
|
1109
|
+
private addEventListeners(): void {
|
1110
|
+
this.on(events.beforeRequest, this.showSpinner, this);
|
1111
|
+
this.on(events.afterRequest, this.hideSpinner, this);
|
1112
|
+
this.on(events.initialEnd, this.onInitialEnd, this);
|
1113
|
+
this.on(events.detailsInit, this.onDetailsInit, this);
|
1114
|
+
this.on(events.skipUpload, this.onFileUploadSuccess, this);
|
1115
|
+
EventHandler.add(this.element, 'contextmenu', this.onContextMenu, this);
|
1116
|
+
}
|
1117
|
+
private removeEventListeners(): void {
|
1118
|
+
if (this.isDestroyed) { return; }
|
1119
|
+
this.off(events.beforeRequest, this.showSpinner);
|
1120
|
+
this.off(events.afterRequest, this.hideSpinner);
|
1121
|
+
this.off(events.initialEnd, this.onInitialEnd);
|
1122
|
+
this.off(events.detailsInit, this.onDetailsInit);
|
1123
|
+
this.off(events.skipUpload, this.onFileUploadSuccess);
|
1124
|
+
EventHandler.remove(this.element, 'contextmenu', this.onContextMenu);
|
1125
|
+
}
|
1126
|
+
|
1127
|
+
private onDetailsInit(): void {
|
1128
|
+
if (isNOU(this.activeModule)) {
|
1129
|
+
this.itemData = [getValue(this.pathId[this.pathId.length - 1], this.feParent)];
|
1130
|
+
}
|
1131
|
+
}
|
1132
|
+
|
1133
|
+
private resizeHandler(): void {
|
1134
|
+
this.adjustHeight();
|
1135
|
+
this.notify(events.resizeEnd, {});
|
1136
|
+
}
|
1137
|
+
|
1138
|
+
private keyActionHandler(e: KeyboardEventArgs): void {
|
1139
|
+
let uploadEle: HTMLElement;
|
1140
|
+
switch (e.action) {
|
1141
|
+
case 'altN':
|
1142
|
+
e.preventDefault();
|
1143
|
+
this.itemData = [getPathObject(this)];
|
1144
|
+
if (!hasContentAccess(this.itemData[0])) {
|
1145
|
+
createDeniedDialog(this, this.itemData[0], events.permissionEditContents);
|
1146
|
+
} else {
|
1147
|
+
createDialog(this, 'NewFolder');
|
1148
|
+
}
|
1149
|
+
break;
|
1150
|
+
case 'f5':
|
1151
|
+
e.preventDefault();
|
1152
|
+
refresh(this);
|
1153
|
+
break;
|
1154
|
+
/* istanbul ignore next */
|
1155
|
+
case 'ctrlShift1':
|
1156
|
+
e.preventDefault();
|
1157
|
+
this.fileView = 'Details';
|
1158
|
+
this.setProperties({ view: 'Details' }, true);
|
1159
|
+
showSpinner(this.element);
|
1160
|
+
updateLayout(this, 'Details');
|
1161
|
+
break;
|
1162
|
+
/* istanbul ignore next */
|
1163
|
+
case 'ctrlShift2':
|
1164
|
+
e.preventDefault();
|
1165
|
+
this.fileView = 'LargeIcons';
|
1166
|
+
this.setProperties({ view: 'LargeIcons' }, true);
|
1167
|
+
showSpinner(this.element);
|
1168
|
+
updateLayout(this, 'LargeIcons');
|
1169
|
+
break;
|
1170
|
+
case 'ctrlU':
|
1171
|
+
e.preventDefault();
|
1172
|
+
uploadEle = <HTMLElement>select('#' + this.element.id + CLS.UPLOAD_ID, this.element);
|
1173
|
+
uploadEle.click();
|
1174
|
+
break;
|
1175
|
+
|
1176
|
+
}
|
1177
|
+
}
|
1178
|
+
|
1179
|
+
private wireEvents(): void {
|
1180
|
+
EventHandler.add(<HTMLElement & Window><unknown>window, 'resize', this.resizeHandler, this);
|
1181
|
+
this.keyboardModule = new KeyboardEvents(
|
1182
|
+
this.element,
|
1183
|
+
{
|
1184
|
+
keyAction: this.keyActionHandler.bind(this),
|
1185
|
+
keyConfigs: this.keyConfigs,
|
1186
|
+
eventName: 'keydown'
|
1187
|
+
}
|
1188
|
+
);
|
1189
|
+
}
|
1190
|
+
|
1191
|
+
private unWireEvents(): void {
|
1192
|
+
EventHandler.remove(<HTMLElement & Window><unknown>window, 'resize', this.resizeHandler);
|
1193
|
+
this.keyboardModule.destroy();
|
1194
|
+
}
|
1195
|
+
|
1196
|
+
private setPath(): void {
|
1197
|
+
this.setProperties({ selectedItems: [] }, true);
|
1198
|
+
this.ensurePath();
|
1199
|
+
this.notify(events.clearPathInit, { selectedNode: this.pathId[0] });
|
1200
|
+
read(this, (this.path !== this.originalPath) ? events.initialEnd : events.finalizeEnd, this.path);
|
1201
|
+
}
|
1202
|
+
|
1203
|
+
/**
|
1204
|
+
* Called internally if any of the property value changed.
|
1205
|
+
*
|
1206
|
+
* @param {FileManager} newProp
|
1207
|
+
* @param {FileManager} oldProp
|
1208
|
+
* @returns void
|
1209
|
+
* @private
|
1210
|
+
*/
|
1211
|
+
/* istanbul ignore next */
|
1212
|
+
// eslint:disable-next-line
|
1213
|
+
public onPropertyChanged(newProp: FileManagerModel, oldProp: FileManagerModel): void {
|
1214
|
+
let height: string | number;
|
1215
|
+
for (const prop of Object.keys(newProp)) {
|
1216
|
+
switch (prop) {
|
1217
|
+
case 'ajaxSettings':
|
1218
|
+
this.ajaxSettingSetModel(newProp);
|
1219
|
+
break;
|
1220
|
+
case 'allowDragAndDrop':
|
1221
|
+
this.allowDragAndDrop = newProp.allowDragAndDrop;
|
1222
|
+
this.notify(events.modelChanged, { module: 'common', newProp: newProp, oldProp: oldProp });
|
1223
|
+
break;
|
1224
|
+
case 'allowMultiSelection':
|
1225
|
+
if (this.allowMultiSelection) {
|
1226
|
+
addClass([this.element], CLS.CHECK_SELECT);
|
1227
|
+
} else {
|
1228
|
+
if (this.selectedItems.length > 1) {
|
1229
|
+
this.setProperties({ selectedItems: this.selectedItems.slice(this.selectedItems.length - 1) }, true);
|
1230
|
+
}
|
1231
|
+
removeClass([this.element], CLS.CHECK_SELECT);
|
1232
|
+
}
|
1233
|
+
this.notify(events.modelChanged, { module: 'common', newProp: newProp, oldProp: oldProp });
|
1234
|
+
break;
|
1235
|
+
case 'cssClass':
|
1236
|
+
this.addCssClass(oldProp.cssClass, newProp.cssClass);
|
1237
|
+
this.notify(events.modelChanged, { module: 'common', newProp: newProp, oldProp: oldProp });
|
1238
|
+
break;
|
1239
|
+
case 'detailsViewSettings':
|
1240
|
+
this.notify(events.modelChanged, { module: 'detailsview', newProp: newProp, oldProp: oldProp });
|
1241
|
+
break;
|
1242
|
+
case 'enableRtl':
|
1243
|
+
this.enableRtl = newProp.enableRtl;
|
1244
|
+
this.refresh();
|
1245
|
+
break;
|
1246
|
+
case 'rootAliasName':
|
1247
|
+
this.rootAliasName = newProp.rootAliasName;
|
1248
|
+
this.refresh();
|
1249
|
+
break;
|
1250
|
+
case 'height':
|
1251
|
+
height = !isNOU(newProp.height) ? formatUnit(newProp.height) : newProp.height;
|
1252
|
+
setAttr(this.element, { 'height': height });
|
1253
|
+
this.adjustHeight();
|
1254
|
+
this.notify(events.modelChanged, { module: 'common', newProp: newProp, oldProp: oldProp });
|
1255
|
+
break;
|
1256
|
+
case 'locale':
|
1257
|
+
if (!isNOU(newProp.enableRtl)) {
|
1258
|
+
this.setProperties({ enableRtl: newProp.enableRtl }, true);
|
1259
|
+
}
|
1260
|
+
this.localeSetModelOption(newProp);
|
1261
|
+
break;
|
1262
|
+
case 'navigationPaneSettings':
|
1263
|
+
this.splitterAdjust();
|
1264
|
+
this.notify(events.modelChanged, { module: 'navigationpane', newProp: newProp, oldProp: oldProp });
|
1265
|
+
break;
|
1266
|
+
case 'path':
|
1267
|
+
this.setPath();
|
1268
|
+
break;
|
1269
|
+
case 'searchSettings':
|
1270
|
+
if (!isNullOrUndefined(newProp.searchSettings.allowSearchOnTyping)) {
|
1271
|
+
this.setProperties({ searchSettings: { allowSearchOnTyping: newProp.searchSettings.allowSearchOnTyping } }, true);
|
1272
|
+
}
|
1273
|
+
if (isNullOrUndefined(newProp.searchSettings.ignoreCase)) {
|
1274
|
+
this.setProperties({ searchSettings: { ignoreCase: newProp.searchSettings.ignoreCase } }, true);
|
1275
|
+
}
|
1276
|
+
if (isNullOrUndefined(newProp.searchSettings.filterType)) {
|
1277
|
+
this.setProperties({ searchSettings: { filterType: newProp.searchSettings.filterType } }, true);
|
1278
|
+
}
|
1279
|
+
this.notify(events.modelChanged, { module: 'breadcrumbbar', newProp: newProp, oldProp: oldProp });
|
1280
|
+
break;
|
1281
|
+
case 'selectedItems':
|
1282
|
+
if (this.view === 'Details') {
|
1283
|
+
this.notify(events.modelChanged, { module: 'detailsview', newProp: newProp, oldProp: oldProp });
|
1284
|
+
} else if (this.view === 'LargeIcons') {
|
1285
|
+
this.notify(events.modelChanged, { module: 'largeiconsview', newProp: newProp, oldProp: oldProp });
|
1286
|
+
}
|
1287
|
+
break;
|
1288
|
+
case 'showFileExtension':
|
1289
|
+
this.notify(events.modelChanged, { module: 'common', newProp: newProp, oldProp: oldProp });
|
1290
|
+
break;
|
1291
|
+
case 'showHiddenItems':
|
1292
|
+
this.notify(events.modelChanged, { module: 'common', newProp: newProp, oldProp: oldProp });
|
1293
|
+
break;
|
1294
|
+
case 'showThumbnail':
|
1295
|
+
this.notify(events.modelChanged, { module: 'largeiconsview', newProp: newProp, oldProp: oldProp });
|
1296
|
+
break;
|
1297
|
+
case 'toolbarSettings':
|
1298
|
+
this.adjustHeight();
|
1299
|
+
this.notify(events.modelChanged, { module: 'toolbar', newProp: newProp, oldProp: oldProp });
|
1300
|
+
break;
|
1301
|
+
case 'uploadSettings':
|
1302
|
+
this.updateUploader();
|
1303
|
+
break;
|
1304
|
+
case 'view':
|
1305
|
+
if (newProp.view === 'Details') {
|
1306
|
+
this.notify(events.modelChanged, { module: 'detailsview', newProp: newProp, oldProp: oldProp });
|
1307
|
+
} else if (newProp.view === 'LargeIcons') {
|
1308
|
+
this.notify(events.modelChanged, { module: 'largeiconsview', newProp: newProp, oldProp: oldProp });
|
1309
|
+
}
|
1310
|
+
break;
|
1311
|
+
case 'width':
|
1312
|
+
setAttr(this.element, { 'width': !isNOU(newProp.width) ? formatUnit(newProp.width) : newProp.width });
|
1313
|
+
this.notify(events.modelChanged, { module: 'common', newProp: newProp, oldProp: oldProp });
|
1314
|
+
break;
|
1315
|
+
case 'sortOrder':
|
1316
|
+
refresh(this);
|
1317
|
+
this.notify(events.sortByChange, {});
|
1318
|
+
break;
|
1319
|
+
case 'sortBy':
|
1320
|
+
refresh(this);
|
1321
|
+
this.notify(events.sortByChange, {});
|
1322
|
+
if (this.view === 'Details') {
|
1323
|
+
this.notify(events.sortColumn, {});
|
1324
|
+
}
|
1325
|
+
break;
|
1326
|
+
case 'popupTarget':
|
1327
|
+
if (this.uploadDialogObj) {
|
1328
|
+
this.uploadDialogObj.target = newProp.popupTarget;
|
1329
|
+
}
|
1330
|
+
if (this.dialogObj) {
|
1331
|
+
this.dialogObj.target = newProp.popupTarget;
|
1332
|
+
}
|
1333
|
+
if (this.extDialogObj) {
|
1334
|
+
this.extDialogObj.target = newProp.popupTarget;
|
1335
|
+
}
|
1336
|
+
if (this.viewerObj) {
|
1337
|
+
this.viewerObj.target = newProp.popupTarget;
|
1338
|
+
}
|
1339
|
+
break;
|
1340
|
+
}
|
1341
|
+
}
|
1342
|
+
}
|
1343
|
+
/* istanbul ignore next */
|
1344
|
+
private ajaxSettingSetModel(newProp: FileManagerModel): void {
|
1345
|
+
if (!isNullOrUndefined(newProp.ajaxSettings.url)) {
|
1346
|
+
this.setProperties({ ajaxSettings: { url: newProp.ajaxSettings.url } }, true);
|
1347
|
+
}
|
1348
|
+
if (!isNullOrUndefined(newProp.ajaxSettings.uploadUrl)) {
|
1349
|
+
this.setProperties({ ajaxSettings: { uploadUrl: newProp.ajaxSettings.uploadUrl } }, true);
|
1350
|
+
}
|
1351
|
+
if (!isNullOrUndefined(newProp.ajaxSettings.downloadUrl)) {
|
1352
|
+
this.setProperties({ ajaxSettings: { downloadUrl: newProp.ajaxSettings.downloadUrl } }, true);
|
1353
|
+
}
|
1354
|
+
if (!isNullOrUndefined(newProp.ajaxSettings.getImageUrl)) {
|
1355
|
+
this.setProperties({ ajaxSettings: { getImageUrl: newProp.ajaxSettings.getImageUrl } }, true);
|
1356
|
+
}
|
1357
|
+
this.setProperties({ path: '/' }, true);
|
1358
|
+
this.setProperties({ selectedItems: [] }, true);
|
1359
|
+
super.refresh();
|
1360
|
+
}
|
1361
|
+
|
1362
|
+
/* istanbul ignore next */
|
1363
|
+
private localeSetModelOption(newProp: FileManagerModel): void {
|
1364
|
+
this.uploadObj.locale = newProp.locale;
|
1365
|
+
super.refresh();
|
1366
|
+
}
|
1367
|
+
|
1368
|
+
/**
|
1369
|
+
* Triggers when the component is destroyed.
|
1370
|
+
*
|
1371
|
+
* @returns {void}
|
1372
|
+
*/
|
1373
|
+
public destroy(): void {
|
1374
|
+
if (this.isDestroyed) { return; }
|
1375
|
+
if (!this.refreshing) {
|
1376
|
+
this.notify(events.destroy, {});
|
1377
|
+
}
|
1378
|
+
this.uploadObj.destroy();
|
1379
|
+
this.uploadObj = null;
|
1380
|
+
this.uploadDialogObj.destroy();
|
1381
|
+
this.uploadDialogObj = null;
|
1382
|
+
this.splitterObj.destroy();
|
1383
|
+
this.splitterObj = null;
|
1384
|
+
if (this.dialogObj) {
|
1385
|
+
this.dialogObj.destroy();
|
1386
|
+
this.dialogObj = null;
|
1387
|
+
}
|
1388
|
+
if (this.viewerObj) {
|
1389
|
+
this.viewerObj.destroy();
|
1390
|
+
this.viewerObj = null;
|
1391
|
+
}
|
1392
|
+
if (this.extDialogObj) {
|
1393
|
+
this.extDialogObj.destroy();
|
1394
|
+
this.extDialogObj = null;
|
1395
|
+
}
|
1396
|
+
this.element.removeAttribute('style');
|
1397
|
+
this.element.removeAttribute('tabindex');
|
1398
|
+
this.removeEventListeners();
|
1399
|
+
this.unWireEvents();
|
1400
|
+
this.addCssClass(this.cssClass, null);
|
1401
|
+
removeClass([this.element], [CLS.RTL, CLS.MOBILE, CLS.CHECK_SELECT]);
|
1402
|
+
this.element.innerHTML = '';
|
1403
|
+
super.destroy();
|
1404
|
+
}
|
1405
|
+
|
1406
|
+
/**
|
1407
|
+
* Creates a new folder in file manager.
|
1408
|
+
*
|
1409
|
+
* @param {string} name – Specifies the name of new folder in current path.
|
1410
|
+
* If it is not specified, then the default new folder dialog will be opened.
|
1411
|
+
* @returns {void}
|
1412
|
+
*/
|
1413
|
+
public createFolder(name?: string): void {
|
1414
|
+
this.notify(events.methodCall, { action: 'createFolder' });
|
1415
|
+
// eslint-disable-next-line
|
1416
|
+
const details: Object[] = [getPathObject(this)];
|
1417
|
+
this.itemData = details;
|
1418
|
+
if (name) {
|
1419
|
+
if (/[/\\|*?"<>:]/.test(name)) {
|
1420
|
+
const result: ReadArgs = {
|
1421
|
+
files: null,
|
1422
|
+
error: {
|
1423
|
+
code: '402',
|
1424
|
+
message: getLocaleText(this, 'Validation-Invalid').replace('{0}', '"' + name + '"'),
|
1425
|
+
fileExists: null
|
1426
|
+
}
|
1427
|
+
};
|
1428
|
+
createDialog(this, 'Error', result);
|
1429
|
+
} else {
|
1430
|
+
if (!hasContentAccess(details[0])) {
|
1431
|
+
createDeniedDialog(this, details[0], events.permissionEditContents);
|
1432
|
+
} else {
|
1433
|
+
createFolder(this, name);
|
1434
|
+
}
|
1435
|
+
}
|
1436
|
+
} else {
|
1437
|
+
createNewFolder(this);
|
1438
|
+
}
|
1439
|
+
}
|
1440
|
+
|
1441
|
+
/**
|
1442
|
+
* Deletes the folders or files from the given unique identifiers.
|
1443
|
+
*
|
1444
|
+
* @param {string} ids - Specifies the name of folders or files in current path. If you want to delete the nested level folders or
|
1445
|
+
* files, then specify the filter path along with name of the folders or files when performing the search or custom filtering.
|
1446
|
+
* For ID based file provider, specify the unique identifier of folders or files.
|
1447
|
+
* If it is not specified, then delete confirmation dialog will be opened for selected item.
|
1448
|
+
*
|
1449
|
+
* @returns {void}
|
1450
|
+
*/
|
1451
|
+
public deleteFiles(ids?: string[]): void {
|
1452
|
+
this.notify(events.methodCall, { action: 'deleteFiles', ids: ids });
|
1453
|
+
}
|
1454
|
+
|
1455
|
+
/**
|
1456
|
+
* Disables the specified toolbar items of the file manager.
|
1457
|
+
*
|
1458
|
+
* @param {string[]} items - Specifies an array of items to be disabled.
|
1459
|
+
* @returns {void}
|
1460
|
+
*/
|
1461
|
+
public disableToolbarItems(items: string[]): void {
|
1462
|
+
if (!isNOU(items)) {
|
1463
|
+
this.toolbarModule.enableItems(items, false);
|
1464
|
+
}
|
1465
|
+
}
|
1466
|
+
|
1467
|
+
/**
|
1468
|
+
* Downloads the folders or files from the given unique identifiers.
|
1469
|
+
*
|
1470
|
+
* @param {string} ids - Specifies the name of folders or files in current path. If you want to download the nested level folders
|
1471
|
+
* or files, then specify the filter path along with name of the folders or files when performing search or custom filtering.
|
1472
|
+
* For ID based file provider, specify the unique identifier of folders or files.
|
1473
|
+
* If it is not specified, then the selected items will be downloaded.
|
1474
|
+
*
|
1475
|
+
* @returns {void}
|
1476
|
+
*/
|
1477
|
+
public downloadFiles(ids?: string[]): void {
|
1478
|
+
this.notify(events.methodCall, { action: 'downloadFiles', ids: ids });
|
1479
|
+
}
|
1480
|
+
|
1481
|
+
/**
|
1482
|
+
* Enables the specified toolbar items of the file manager.
|
1483
|
+
*
|
1484
|
+
* @param {string[]} items - Specifies an array of items to be enabled.
|
1485
|
+
* @returns {void}
|
1486
|
+
*/
|
1487
|
+
public enableToolbarItems(items: string[]): void {
|
1488
|
+
if (!isNOU(items)) {
|
1489
|
+
this.toolbarModule.enableItems(items, true);
|
1490
|
+
}
|
1491
|
+
}
|
1492
|
+
/**
|
1493
|
+
* Disables the specified context menu items in file manager. This method is used only in the menuOpen event.
|
1494
|
+
*
|
1495
|
+
* @param {string[]} items - Specifies an array of items to be disabled.
|
1496
|
+
* @returns {void}
|
1497
|
+
*/
|
1498
|
+
public disableMenuItems(items: string[]): void {
|
1499
|
+
if (!isNOU(items) && !isNOU(this.contextmenuModule.contextMenu)) {
|
1500
|
+
this.contextmenuModule.disableItem(items);
|
1501
|
+
}
|
1502
|
+
}
|
1503
|
+
|
1504
|
+
/**
|
1505
|
+
* Returns the index position of given current context menu item in file manager.
|
1506
|
+
*
|
1507
|
+
* @param {string} item - Specifies an item to get the index position.
|
1508
|
+
* @returns {number} - returns menu item index.
|
1509
|
+
*/
|
1510
|
+
public getMenuItemIndex(item: string): number {
|
1511
|
+
if (this.contextmenuModule) {
|
1512
|
+
return this.contextmenuModule.getItemIndex(item);
|
1513
|
+
} else {
|
1514
|
+
return -1;
|
1515
|
+
}
|
1516
|
+
}
|
1517
|
+
|
1518
|
+
/**
|
1519
|
+
* Returns the index position of given toolbar item in file manager.
|
1520
|
+
*
|
1521
|
+
* @param {string} item - Specifies an item to get the index position.
|
1522
|
+
* @returns {number} - returns toolbar item index.
|
1523
|
+
*/
|
1524
|
+
public getToolbarItemIndex(item: string): number {
|
1525
|
+
if (this.toolbarModule) {
|
1526
|
+
return this.toolbarModule.getItemIndex(item);
|
1527
|
+
} else {
|
1528
|
+
return -1;
|
1529
|
+
}
|
1530
|
+
}
|
1531
|
+
|
1532
|
+
/**
|
1533
|
+
* Display the custom filtering files in file manager.
|
1534
|
+
*
|
1535
|
+
* @param {Object} filterData - Specifies the custom filter details along with custom file action name,
|
1536
|
+
* which needs to be sent to the server side. If you do not specify the details, then default action name will be `filter`.
|
1537
|
+
*
|
1538
|
+
* @returns {void}
|
1539
|
+
*/
|
1540
|
+
// eslint-disable-next-line
|
1541
|
+
public filterFiles(filterData?: Object): void {
|
1542
|
+
this.filterData = filterData ? filterData : null;
|
1543
|
+
this.setProperties({ selectedItems: [] }, true);
|
1544
|
+
this.notify(events.selectionChanged, {});
|
1545
|
+
this.isFiltered = true;
|
1546
|
+
if (this.breadcrumbbarModule.searchObj.element.value !== '') {
|
1547
|
+
this.breadcrumbbarModule.searchObj.element.value = '';
|
1548
|
+
}
|
1549
|
+
filter(this, events.filterEnd);
|
1550
|
+
}
|
1551
|
+
|
1552
|
+
/**
|
1553
|
+
* Gets the details of the selected files in the file manager.
|
1554
|
+
*
|
1555
|
+
* @returns {Object[]} - returns selected files.
|
1556
|
+
*/
|
1557
|
+
// eslint-disable-next-line
|
1558
|
+
public getSelectedFiles(): Object[] {
|
1559
|
+
this.notify(events.updateSelectionData, {});
|
1560
|
+
return this.itemData;
|
1561
|
+
}
|
1562
|
+
|
1563
|
+
/**
|
1564
|
+
* Opens the corresponding file or folder from the given unique identifier.
|
1565
|
+
*
|
1566
|
+
* @param {string} id - Specifies the name of folder or file in current path. If you want to open the nested level folder or
|
1567
|
+
* file, then specify the filter path along with name of the folder or file when performing search or custom filtering. For ID based
|
1568
|
+
* file provider, specify the unique identifier of folder or file.
|
1569
|
+
*
|
1570
|
+
* @returns {void}
|
1571
|
+
*/
|
1572
|
+
public openFile(id: string): void {
|
1573
|
+
this.notify(events.methodCall, { action: 'openFile', id: id });
|
1574
|
+
}
|
1575
|
+
|
1576
|
+
/**
|
1577
|
+
* Refreshes the folder files of the file manager.
|
1578
|
+
*
|
1579
|
+
* @returns {void}
|
1580
|
+
*/
|
1581
|
+
public refreshFiles(): void {
|
1582
|
+
refresh(this);
|
1583
|
+
}
|
1584
|
+
|
1585
|
+
/**
|
1586
|
+
* Refreshes the layout of the file manager.
|
1587
|
+
*
|
1588
|
+
* @returns {void}
|
1589
|
+
*/
|
1590
|
+
public refreshLayout(): void {
|
1591
|
+
this.adjustHeight();
|
1592
|
+
this.notify(events.layoutRefresh, {});
|
1593
|
+
}
|
1594
|
+
|
1595
|
+
/**
|
1596
|
+
* Selects the entire folders and files in current path.
|
1597
|
+
*
|
1598
|
+
* @returns {void}
|
1599
|
+
*/
|
1600
|
+
public selectAll(): void {
|
1601
|
+
this.notify(events.methodCall, { action: 'selectAll' });
|
1602
|
+
}
|
1603
|
+
|
1604
|
+
/**
|
1605
|
+
* Deselects the currently selected folders and files in current path.
|
1606
|
+
*
|
1607
|
+
* @returns {void}
|
1608
|
+
*/
|
1609
|
+
public clearSelection(): void {
|
1610
|
+
this.notify(events.methodCall, { action: 'clearSelection' });
|
1611
|
+
}
|
1612
|
+
|
1613
|
+
/**
|
1614
|
+
* Renames the file or folder with given new name in file manager.
|
1615
|
+
*
|
1616
|
+
* @param {string} id - Specifies the name of folder or file in current path. If you want to rename the nested level folder or
|
1617
|
+
* file, then specify the filter path along with name of the folder or file when performing search or custom filtering. For ID based
|
1618
|
+
* file provider, specify the unique identifier of folder or file.
|
1619
|
+
* If it is not specified, then rename dialog will be opened for selected item.
|
1620
|
+
*
|
1621
|
+
* @param {string} name – Specifies the new name of the file or folder in current path. If it is not specified, then rename dialog
|
1622
|
+
* will be opened for given identifier.
|
1623
|
+
*
|
1624
|
+
* @returns {void}
|
1625
|
+
*/
|
1626
|
+
public renameFile(id?: string, name?: string): void {
|
1627
|
+
this.notify(events.methodCall, { action: 'renameFile', id: id, newName: name });
|
1628
|
+
}
|
1629
|
+
|
1630
|
+
/**
|
1631
|
+
* Opens the upload dialog in file manager.
|
1632
|
+
*
|
1633
|
+
* @returns {void}
|
1634
|
+
*/
|
1635
|
+
public uploadFiles(): void {
|
1636
|
+
// eslint-disable-next-line
|
1637
|
+
const details: Object[] = [getPathObject(this)];
|
1638
|
+
this.itemData = details;
|
1639
|
+
uploadItem(this);
|
1640
|
+
}
|
1641
|
+
|
1642
|
+
/**
|
1643
|
+
* Specifies the direction of FileManager
|
1644
|
+
*
|
1645
|
+
* @param {boolean} rtl - specifies rtl parameter.
|
1646
|
+
* @returns {void}
|
1647
|
+
*/
|
1648
|
+
private setRtl(rtl: boolean): void {
|
1649
|
+
if (rtl) {
|
1650
|
+
this.addCssClass(null, CLS.RTL);
|
1651
|
+
} else {
|
1652
|
+
this.addCssClass(CLS.RTL, null);
|
1653
|
+
}
|
1654
|
+
if (this.uploadObj) {
|
1655
|
+
this.uploadDialogObj.enableRtl = rtl;
|
1656
|
+
this.uploadObj.enableRtl = rtl;
|
1657
|
+
}
|
1658
|
+
}
|
1659
|
+
}
|