@syncfusion/ej2-filemanager 31.1.17 → 31.1.21

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.
Files changed (83) hide show
  1. package/dist/ej2-filemanager.min.js +2 -2
  2. package/dist/ej2-filemanager.umd.min.js +2 -2
  3. package/dist/ej2-filemanager.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-filemanager.es2015.js +7 -1
  5. package/dist/es6/ej2-filemanager.es2015.js.map +1 -1
  6. package/dist/es6/ej2-filemanager.es5.js +7 -1
  7. package/dist/es6/ej2-filemanager.es5.js.map +1 -1
  8. package/dist/global/ej2-filemanager.min.js +2 -2
  9. package/dist/global/ej2-filemanager.min.js.map +1 -1
  10. package/dist/global/index.d.ts +1 -1
  11. package/package.json +17 -53
  12. package/src/file-manager/layout/details-view.js +7 -1
  13. package/dist/ts/file-manager/actions/breadcrumb-bar.d.ts +0 -60
  14. package/dist/ts/file-manager/actions/breadcrumb-bar.ts +0 -423
  15. package/dist/ts/file-manager/actions/index.d.ts +0 -6
  16. package/dist/ts/file-manager/actions/index.ts +0 -6
  17. package/dist/ts/file-manager/actions/toolbar.d.ts +0 -54
  18. package/dist/ts/file-manager/actions/toolbar.ts +0 -609
  19. package/dist/ts/file-manager/actions/virtualization.d.ts +0 -93
  20. package/dist/ts/file-manager/actions/virtualization.ts +0 -324
  21. package/dist/ts/file-manager/base/classes.d.ts +0 -224
  22. package/dist/ts/file-manager/base/classes.ts +0 -225
  23. package/dist/ts/file-manager/base/constant.d.ts +0 -136
  24. package/dist/ts/file-manager/base/constant.ts +0 -137
  25. package/dist/ts/file-manager/base/file-manager-model.d.ts +0 -520
  26. package/dist/ts/file-manager/base/file-manager.d.ts +0 -867
  27. package/dist/ts/file-manager/base/file-manager.ts +0 -2061
  28. package/dist/ts/file-manager/base/index.d.ts +0 -8
  29. package/dist/ts/file-manager/base/index.ts +0 -8
  30. package/dist/ts/file-manager/base/interface.d.ts +0 -952
  31. package/dist/ts/file-manager/base/interface.ts +0 -931
  32. package/dist/ts/file-manager/common/index.d.ts +0 -5
  33. package/dist/ts/file-manager/common/index.ts +0 -5
  34. package/dist/ts/file-manager/common/operations.d.ts +0 -122
  35. package/dist/ts/file-manager/common/operations.ts +0 -1369
  36. package/dist/ts/file-manager/common/utility.d.ts +0 -644
  37. package/dist/ts/file-manager/common/utility.ts +0 -1732
  38. package/dist/ts/file-manager/index.d.ts +0 -9
  39. package/dist/ts/file-manager/index.ts +0 -9
  40. package/dist/ts/file-manager/layout/details-view.d.ts +0 -152
  41. package/dist/ts/file-manager/layout/details-view.ts +0 -1993
  42. package/dist/ts/file-manager/layout/index.d.ts +0 -6
  43. package/dist/ts/file-manager/layout/index.ts +0 -6
  44. package/dist/ts/file-manager/layout/large-icons-view.d.ts +0 -157
  45. package/dist/ts/file-manager/layout/large-icons-view.ts +0 -1684
  46. package/dist/ts/file-manager/layout/navigation-pane.d.ts +0 -104
  47. package/dist/ts/file-manager/layout/navigation-pane.ts +0 -921
  48. package/dist/ts/file-manager/models/ajax-settings-model.d.ts +0 -36
  49. package/dist/ts/file-manager/models/ajax-settings.d.ts +0 -30
  50. package/dist/ts/file-manager/models/ajax-settings.ts +0 -39
  51. package/dist/ts/file-manager/models/column-model.d.ts +0 -155
  52. package/dist/ts/file-manager/models/column.d.ts +0 -179
  53. package/dist/ts/file-manager/models/column.ts +0 -216
  54. package/dist/ts/file-manager/models/contextMenu-settings-model.d.ts +0 -36
  55. package/dist/ts/file-manager/models/contextMenu-settings.d.ts +0 -33
  56. package/dist/ts/file-manager/models/contextMenu-settings.ts +0 -44
  57. package/dist/ts/file-manager/models/default-locale.d.ts +0 -4
  58. package/dist/ts/file-manager/models/default-locale.ts +0 -101
  59. package/dist/ts/file-manager/models/details-view-settings-model.d.ts +0 -30
  60. package/dist/ts/file-manager/models/details-view-settings.d.ts +0 -31
  61. package/dist/ts/file-manager/models/details-view-settings.ts +0 -54
  62. package/dist/ts/file-manager/models/index.d.ts +0 -19
  63. package/dist/ts/file-manager/models/index.ts +0 -19
  64. package/dist/ts/file-manager/models/navigation-pane-settings-model.d.ts +0 -40
  65. package/dist/ts/file-manager/models/navigation-pane-settings.d.ts +0 -34
  66. package/dist/ts/file-manager/models/navigation-pane-settings.ts +0 -42
  67. package/dist/ts/file-manager/models/search-settings-model.d.ts +0 -42
  68. package/dist/ts/file-manager/models/search-settings.d.ts +0 -44
  69. package/dist/ts/file-manager/models/search-settings.ts +0 -53
  70. package/dist/ts/file-manager/models/toolbar-settings-model.d.ts +0 -197
  71. package/dist/ts/file-manager/models/toolbar-settings.d.ts +0 -174
  72. package/dist/ts/file-manager/models/toolbar-settings.ts +0 -198
  73. package/dist/ts/file-manager/models/upload-settings-model.d.ts +0 -70
  74. package/dist/ts/file-manager/models/upload-settings.d.ts +0 -61
  75. package/dist/ts/file-manager/models/upload-settings.ts +0 -75
  76. package/dist/ts/file-manager/pop-up/context-menu.d.ts +0 -64
  77. package/dist/ts/file-manager/pop-up/context-menu.ts +0 -693
  78. package/dist/ts/file-manager/pop-up/dialog.d.ts +0 -31
  79. package/dist/ts/file-manager/pop-up/dialog.ts +0 -1009
  80. package/dist/ts/file-manager/pop-up/index.d.ts +0 -5
  81. package/dist/ts/file-manager/pop-up/index.ts +0 -5
  82. package/dist/ts/index.d.ts +0 -4
  83. package/dist/ts/index.ts +0 -4
@@ -1,1732 +0,0 @@
1
- import { IFileManager, ReadArgs, SortOrder, SearchArgs, FileDragEventArgs, BeforeImageLoadEventArgs } from '../base/interface';
2
- import * as CLS from '../base/classes';
3
- import * as events from '../base/constant';
4
- import { read, paste, Search, filter, Download, Delete, isFileSystemData } from '../common/operations';
5
- import { getValue, setValue, isNullOrUndefined as isNOU, matches, select, createElement, Draggable, isNullOrUndefined } from '@syncfusion/ej2-base';
6
- import { closest, DragEventArgs, detach } from '@syncfusion/ej2-base';
7
- import { DataManager, Query } from '@syncfusion/ej2-data';
8
- import { MenuEventArgs } from '@syncfusion/ej2-navigations';
9
- import { createDialog } from '../pop-up/dialog';
10
- import { ColumnModel } from '../models';
11
-
12
- /**
13
- * Utility function to compare two strings in a way similar to Windows Explorer.
14
- * Files and folders are sorted separately, with folders coming before files.
15
- *
16
- * @param {string} reference - The first string to compare. This could be a file or folder name.
17
- * @param {string} comparer - The second string to compare. This could be a file or folder name.
18
- * @returns {number} - A negative number if `reference` should come before `comparer`, a positive number if `comparer` should come before `reference`, and 0 if they are considered equal.
19
- */
20
- export function sortComparer(reference: string, comparer: string): number {
21
- // Check if reference and comparer are files or folders
22
- const referenceIsFile: boolean = /\.\S+/.test(reference);
23
- const comparerIsFile: boolean = /\.\S+/.test(comparer);
24
- // If one is a file and the other is a folder, the folder should come first
25
- if (referenceIsFile && !comparerIsFile) {return 1; }
26
- if (!referenceIsFile && comparerIsFile) {return -1; }
27
- const referenceParts: Array<[number, string]> = [];
28
- const comparerParts: Array<[number, string]> = [];
29
- (reference + '').replace(/(\d+)|(\D+)/g, function(_: string, $1: number, $2: string): string { referenceParts.push([$1 || Infinity, $2 || '']); return ''; });
30
- (comparer + '').replace(/(\d+)|(\D+)/g, function(_: string, $1: number, $2: string): string { comparerParts.push([$1 || Infinity, $2 || '']); return ''; });
31
- // Compare each part of reference and comparer
32
- while (referenceParts.length && comparerParts.length) {
33
- const referencePart: [number, string] = referenceParts.shift();
34
- const comparerPart: [number, string] = comparerParts.shift();
35
- if (referencePart && comparerPart) {
36
- const comparisonResult: number =
37
- referencePart[0] - comparerPart[0] ||
38
- referencePart[1].localeCompare(comparerPart[1]);
39
- if (comparisonResult) {return comparisonResult; }
40
- }
41
- }
42
- return referenceParts.length - comparerParts.length;
43
- }
44
- /**
45
- * Utility file for common actions
46
- *
47
- * @param {HTMLLIElement} node - specifies the node.
48
- * @param {Object} data - specifies the data.
49
- * @param {IFileManager} instance - specifies the control instance.
50
- * @returns {void}
51
- * @private
52
- */
53
- export function updatePath(node: HTMLLIElement, data: Object, instance: IFileManager): void {
54
- const text: string = getValue('name', data);
55
- const id: string = node.getAttribute('data-id');
56
- const newText: string = isNOU(id) ? text : id;
57
- instance.setProperties({ path: getPath(node, newText, instance.hasId) }, true);
58
- instance.pathId = getPathId(node);
59
- instance.pathNames = getPathNames(node, text);
60
- }
61
- /**
62
- * Functions for get path in FileManager
63
- *
64
- * @param {Element | Node} element - specifies the element.
65
- * @param {string} text - specifies the text.
66
- * @param {boolean} hasId - specifies the id.
67
- * @returns {string} returns the path.
68
- * @private
69
- */
70
- export function getPath(element: Element | Node, text: string, hasId: boolean): string {
71
- const matched: string[] = getParents(<Element>element, text, false, hasId);
72
- let path: string = '/';
73
- const len: number = matched.length - (2);
74
- for (let i: number = len; i >= 0; i--) {
75
- path += matched[i as number] + '/';
76
- }
77
- return path;
78
- }
79
- /**
80
- * Functions for get path id in FileManager
81
- *
82
- * @param {Element} node - specifies the node element.
83
- * @returns {string[]} returns the path ids.
84
- * @private
85
- */
86
- export function getPathId(node: Element): string[] {
87
- const matched: string[] = getParents(node, node.getAttribute('data-uid'), true);
88
- const ids: string[] = [];
89
- for (let i: number = matched.length - 1; i >= 0; i--) {
90
- ids.push(matched[i as number]);
91
- }
92
- return ids;
93
- }
94
-
95
- /**
96
- * Functions for get path names in FileManager
97
- *
98
- * @param {Element} element - specifies the node element.
99
- * @param {string} text - specifies the text.
100
- * @returns {string[]} returns the path names.
101
- * @private
102
- */
103
- export function getPathNames(element: Element, text: string): string[] {
104
- const matched: string[] = getParents(element, text, false);
105
- const names: string[] = [];
106
- for (let i: number = matched.length - 1; i >= 0; i--) {
107
- names.push(matched[i as number]);
108
- }
109
- return names;
110
- }
111
-
112
- /**
113
- * Functions for get path id in FileManager
114
- *
115
- * @param {Element} element - specifies the node element.
116
- * @param {string} text - specifies the text.
117
- * @param {boolean} isId - specifies the id.
118
- * @param {boolean} hasId - checks the id exists.
119
- * @returns {string[]} returns parent element.
120
- * @private
121
- */
122
- export function getParents(element: Element, text: string, isId: boolean, hasId?: boolean): string[] {
123
- const matched: string[] = [text];
124
- let el: Element = <Element>element.parentNode;
125
- while (!isNOU(el)) {
126
- if (matches(el, '.' + CLS.LIST_ITEM)) {
127
- const parentText: string = isId ? el.getAttribute('data-uid') : (hasId ? el.getAttribute('data-id') :
128
- select('.' + CLS.LIST_TEXT, el).textContent);
129
- matched.push(parentText);
130
- }
131
- el = <Element>el.parentNode;
132
- if (el.classList.contains(CLS.TREE_VIEW)) {
133
- break;
134
- }
135
- }
136
- return matched;
137
- }
138
- /**
139
- * Functions for generate path
140
- *
141
- * @param {IFileManager} parent - specifies the parent element.
142
- * @returns {void}
143
- * @private
144
- */
145
- export function generatePath(parent: IFileManager): void {
146
- const key: string = parent.hasId ? 'id' : 'name';
147
- let newPath: string = '/';
148
- let i: number = 1;
149
- for (i; i < parent.pathId.length; i++) {
150
- const data: Object = getValue(parent.pathId[parseInt(i.toString(), 10)], parent.feParent);
151
- newPath += getValue(key, data) + '/';
152
- }
153
- parent.setProperties({ path: newPath }, true);
154
- }
155
-
156
- /**
157
- * Functions for remove active element
158
- *
159
- * @param {IFileManager} parent - specifies the parent element.
160
- * @returns {void}
161
- * @private
162
- */
163
- export function removeActive(parent: IFileManager): void {
164
- if (parent.isCut) {
165
- removeBlur(parent);
166
- parent.selectedNodes = [];
167
- parent.actionRecords = [];
168
- parent.enablePaste = false;
169
- parent.notify(events.hidePaste, {});
170
- }
171
- }
172
-
173
- /**
174
- * Selects active element in File Manager
175
- *
176
- * @param {string} action - specifies the action.
177
- * @param {IFileManager} parent - specifies the parent element.
178
- * @returns {boolean} - returns active element.
179
- * @private
180
- */
181
- export function activeElement(action: string, parent: IFileManager): boolean {
182
- parent.isSearchCut = false;
183
- parent.actionRecords = [];
184
- parent.activeElements = [];
185
- parent.notify(events.cutCopyInit, {});
186
- if (parent.activeElements.length === 0) { return false; }
187
- removeBlur(parent);
188
- const blurEle: Element[] = parent.activeElements;
189
- if (parent.activeModule !== 'navigationpane') {
190
- parent.targetPath = parent.path;
191
- } else {
192
- parent.targetPath = getParentPath(parent.path);
193
- }
194
- let i: number = 0;
195
- if (blurEle) {
196
- getModule(parent, blurEle[0]);
197
- if (action === 'cut') {
198
- while (i < blurEle.length) {
199
- addBlur(blurEle[i as number]);
200
- i++;
201
- }
202
- }
203
- }
204
- i = 0;
205
- parent.selectedNodes = [];
206
- parent.enablePaste = true;
207
- parent.notify(events.showPaste, {});
208
- while (i < parent.activeRecords.length) {
209
- parent.actionRecords.push(parent.activeRecords[i as number]);
210
- parent.selectedNodes.push(getValue('name', parent.activeRecords[i as number]));
211
- i++;
212
- }
213
- if ((parent.breadcrumbbarModule.searchObj.element.value !== '' || parent.isFiltered) &&
214
- parent.activeModule !== 'navigationpane') {
215
- parent.selectedNodes = [];
216
- parent.isSearchCut = true;
217
- let i: number = 0;
218
- while (i < parent.selectedItems.length) {
219
- parent.selectedNodes.push(parent.selectedItems[i as number]);
220
- i++;
221
- }
222
- }
223
- return true;
224
- }
225
- /**
226
- * Adds blur to the elements
227
- *
228
- * @param {Element} nodes - specifies the nodes.
229
- * @returns {void}
230
- * @private
231
- */
232
- export function addBlur(nodes: Element): void {
233
- nodes.classList.add(CLS.BLUR);
234
- }
235
-
236
- /**
237
- * Removes blur from elements
238
- *
239
- * @param {IFileManager} parent - specifies the parent element.
240
- * @param {string} hover - specifies the hover string.
241
- * @returns {void}
242
- * @private
243
- */
244
- export function removeBlur(parent?: IFileManager, hover?: string): void {
245
- const blurEle: NodeListOf<Element> = (!hover) ? parent.element.querySelectorAll('.' + CLS.BLUR) :
246
- parent.element.querySelectorAll('.' + CLS.HOVER);
247
- let i: number = 0;
248
- while (i < blurEle.length) {
249
- blurEle[i as number].classList.remove((!hover) ? CLS.BLUR : CLS.HOVER);
250
- i++;
251
- }
252
- }
253
-
254
- /**
255
- * Gets module name
256
- *
257
- * @param {IFileManager} parent - specifies the parent element.
258
- * @param {Element} element - specifies the element.
259
- * @returns {void}
260
- * @private
261
- */
262
- export function getModule(parent: IFileManager, element: Element): void {
263
- if (element) {
264
- if (element.classList.contains(CLS.ROW)) {
265
- parent.activeModule = 'detailsview';
266
- } else if (closest(element, '.' + CLS.LARGE_ICON)) {
267
- parent.activeModule = 'largeiconsview';
268
- } else {
269
- parent.activeModule = 'navigationpane';
270
- }
271
- }
272
- }
273
-
274
- /**
275
- * Get all child items
276
- *
277
- * @param {IFileManager} parent - specifies the parent element.
278
- * @param {string | number} parentId - specifies the parent ID.
279
- * @returns {Object[]} An array of child items
280
- * @private
281
- */
282
- export function getAllChildItems(parent: IFileManager, parentId: number | string ): { [key: string]: Object }[] {
283
- const children: { [key: string]: Object }[] = parent.fileSystemData.filter(
284
- (item: { [key: string]: Object }) =>
285
- String(item.parentId) === String(parentId)
286
- );
287
- let allChildren: { [key: string]: Object }[] = [...children];
288
- children.forEach((child: { [key: string]: Object }) => {
289
- const childId: number | string = child.id as string | number;
290
- allChildren = allChildren.concat(getAllChildItems(parent, childId));
291
- });
292
- return allChildren;
293
- }
294
-
295
- /**
296
- * Gets module name
297
- *
298
- * @param {IFileManager} parent - specifies the parent element.
299
- * @param {string} value - specifies the value.
300
- * @param {boolean} isLayoutChange - specifies the layout change.
301
- * @returns {void}
302
- * @private
303
- */
304
- export function searchWordHandler(parent: IFileManager, value: string, isLayoutChange: boolean): void {
305
- let searchWord: string;
306
- if (value.length === 0 && !parent.isFiltered) {
307
- parent.notify(events.pathColumn, { args: parent });
308
- }
309
-
310
- if (isFileSystemData(parent)) {
311
- if (value === '') {
312
- parent.itemData = parent.fileSystemData;
313
- read(parent, isLayoutChange ? events.layoutChange : events.search, parent.path);
314
- }
315
- else {
316
- parent.searchSettings.filterType = isNOU(parent.searchSettings.filterType) ? 'contains' : parent.searchSettings.filterType;
317
- const currData: { [key: string]: Object } = getValue(parent.pathId[parent.pathId.length - 1], parent.feParent);
318
- const parentId: number | string = getValue('id', currData);
319
- const filteredData: { [key: string]: Object }[] = getAllChildItems(parent, parentId);
320
- const data: Object[] = new DataManager(filteredData).
321
- executeLocal(new Query().where('name', parent.searchSettings.filterType, value, parent.searchSettings.ignoreCase));
322
- const searchValue: string = parent.searchSettings.ignoreCase ? value.toLowerCase() : value;
323
- parent.itemData = data;
324
- parent.responseData.error = null;
325
- Search(parent, isLayoutChange ? events.layoutChange : events.search, parent.path, searchValue,
326
- parent.showHiddenItems, !parent.searchSettings.ignoreCase);
327
- }
328
- return;
329
- }
330
- if (parent.searchSettings.filterType === 'startsWith') {
331
- searchWord = value + '*';
332
- } else if (parent.searchSettings.filterType === 'endsWith') {
333
- searchWord = '*' + value;
334
- } else {
335
- searchWord = '*' + value + '*';
336
- }
337
- parent.searchWord = searchWord;
338
- parent.itemData = [getPathObject(parent)];
339
- if (value.length > 0) {
340
- const caseSensitive: boolean = parent.searchSettings.ignoreCase;
341
- const hiddenItems: boolean = parent.showHiddenItems;
342
- Search(parent, isLayoutChange ? events.layoutChange : events.search, parent.path, searchWord, hiddenItems, !caseSensitive);
343
- } else {
344
- if (!parent.isFiltered) {
345
- if (parent.isSortByClicked) {
346
- parent.notify(events.layoutChange, { files: (parent.oldView === 'Details') ? parent.detailsviewModule.gridObj.dataSource : parent.largeiconsviewModule.allItems });
347
- parent.isSortByClicked = false;
348
- } else {
349
- read(parent, isLayoutChange ? events.layoutChange : events.search, parent.path);
350
- }
351
- } else {
352
- filter(parent, events.layoutChange);
353
- }
354
- }
355
- }
356
-
357
- /**
358
- * Gets updated layout
359
- *
360
- * @param {IFileManager} parent - specifies the parent element.
361
- * @param {string} view - specifies the view.
362
- * @returns {void}
363
- * @private
364
- */
365
- export function updateLayout(parent: IFileManager, view: string): void {
366
- parent.oldView = parent.view;
367
- parent.setProperties({ view: view }, true);
368
- if (parent.breadcrumbbarModule.searchObj.element.value !== '' || parent.isFiltered) {
369
- parent.layoutSelectedItems = parent.selectedItems;
370
- }
371
- let searchWord: string = '';
372
- if (parent.breadcrumbbarModule.searchObj.element.value) {
373
- searchWord = parent.breadcrumbbarModule.searchObj.element.value;
374
- }
375
- parent.isLayoutChange = true;
376
- searchWordHandler(parent, searchWord, true);
377
- }
378
-
379
- /* istanbul ignore next */
380
- /**
381
- * Gets updated layout
382
- *
383
- * @param {IFileManager} parent - specifies the parent element.
384
- * @param {Element} element - specifies the element.
385
- * @returns {void}
386
- * @private
387
- */
388
- export function getTargetModule(parent: IFileManager, element: Element): void {
389
- let tartgetModule: string = '';
390
- if (element) {
391
- if (closest(element, '.' + CLS.ROOT + '.' + CLS.CONTROL + ' .' + CLS.GRID_CONTENT)) {
392
- tartgetModule = 'detailsview';
393
- } else if (closest(element, '.' + CLS.LARGE_ICONS)) {
394
- tartgetModule = 'largeiconsview';
395
- } else if (element.classList.contains('e-fullrow') ||
396
- element.classList.contains('e-icon-expandable')) {
397
- tartgetModule = 'navigationpane';
398
- } else if (closest(element, '.e-address-list-item')) {
399
- tartgetModule = 'breadcrumbbar';
400
- } else {
401
- tartgetModule = '';
402
- }
403
- }
404
- parent.targetModule = tartgetModule;
405
- }
406
- /* istanbul ignore next */
407
- /**
408
- * refresh the layout
409
- *
410
- * @param {IFileManager} parent - specifies the parent element.
411
- * @returns {void}
412
- * @private
413
- */
414
- export function refresh(parent: IFileManager): void {
415
- parent.itemData = [getPathObject(parent)];
416
- if (!hasReadAccess(parent.itemData[0])) {
417
- createDeniedDialog(parent, parent.itemData[0], events.permissionRead);
418
- } else {
419
- read(parent, events.refreshEnd, parent.path);
420
- }
421
- }
422
-
423
- /**
424
- * open action in the layout
425
- *
426
- * @param {IFileManager} parent - specifies the parent element.
427
- * @returns {void}
428
- * @private
429
- */
430
- export function openAction(parent: IFileManager): void {
431
- read(parent, events.openEnd, parent.path);
432
- }
433
-
434
- /**
435
- * open action in the layout
436
- *
437
- * @param {IFileManager} parent - specifies the parent element.
438
- * @returns {Object} - returns the path data.
439
- * @private
440
- */
441
- export function getPathObject(parent: IFileManager): Object {
442
- return getValue(parent.pathId[parent.pathId.length - 1], parent.feParent);
443
- }
444
-
445
- /**
446
- * Copy files
447
- *
448
- * @param {IFileManager} parent - specifies the parent element.
449
- * @returns {void}
450
- * @private
451
- */
452
- export function copyFiles(parent: IFileManager): void {
453
- if (!activeElement('copy', parent)) {
454
- return;
455
- } else {
456
- parent.fileAction = 'copy';
457
- }
458
- }
459
-
460
- /**
461
- * Cut files
462
- *
463
- * @param {IFileManager} parent - specifies the parent element.
464
- * @returns {void}
465
- * @private
466
- */
467
- export function cutFiles(parent: IFileManager): void {
468
- if (!activeElement('cut', parent)) {
469
- return;
470
- } else {
471
- parent.isCut = true;
472
- parent.fileAction = 'move';
473
- }
474
- }
475
-
476
- /**
477
- * To add class for fileType
478
- *
479
- * @param {Object} file - specifies the file.
480
- * @returns {string} - returns the file type.
481
- * @private
482
- */
483
- export function fileType(file: Object): string {
484
- const isFile: string = getValue('isFile', file);
485
- if (!isFile) {
486
- return CLS.FOLDER;
487
- }
488
- const imageFormat: string[] = ['bmp', 'dib', 'jpg', 'jpeg', 'jpe', 'jfif', 'gif', 'tif', 'tiff', 'png', 'ico'];
489
- const audioFormat: string[] = ['mp3', 'wav', 'aac', 'ogg', 'wma', 'aif', 'fla', 'm4a'];
490
- const videoFormat: string[] = ['webm', 'mkv', 'flv', 'vob', 'ogv', 'ogg', 'avi', 'wmv', 'mp4', '3gp'];
491
- const knownFormat: string[] = ['css', 'exe', 'html', 'js', 'msi', 'pdf', 'pptx', 'ppt', 'rar', 'zip', 'txt', 'docx', 'doc',
492
- 'xlsx', 'xls', 'xml', 'rtf', 'php'];
493
- let filetype: string = getValue('type', file);
494
- filetype = filetype.toLowerCase();
495
- if (filetype.indexOf('.') !== -1) {
496
- filetype = filetype.split('.').join('');
497
- }
498
- let iconType: string;
499
- if (imageFormat.indexOf(filetype) !== -1) {
500
- iconType = CLS.ICON_IMAGE;
501
- } else if (audioFormat.indexOf(filetype) !== -1) {
502
- iconType = CLS.ICON_MUSIC;
503
- } else if (videoFormat.indexOf(filetype) !== -1) {
504
- iconType = CLS.ICON_VIDEO;
505
- } else if (knownFormat.indexOf(filetype) !== -1) {
506
- iconType = 'e-fe-' + filetype;
507
- } else {
508
- iconType = 'e-fe-unknown e-fe-' + filetype;
509
- }
510
- return iconType;
511
- }
512
- /* istanbul ignore next */
513
- /**
514
- * To get the image URL
515
- *
516
- * @param {IFileManager} parent - specifies the parent element.
517
- * @param {Object} item - specifies the item.
518
- * @returns {BeforeImageLoadEventArgs} - returns the eventargs.
519
- * @private
520
- */
521
- export function getImageUrl(parent: IFileManager, item: Object): BeforeImageLoadEventArgs {
522
- let imgUrl: string = isFileSystemData(parent) ? getValue('imageUrl', item) : '';
523
- if (isFileSystemData(parent)) {
524
- const eventArgs: BeforeImageLoadEventArgs = {
525
- fileDetails: [item],
526
- imageUrl: imgUrl,
527
- useImageAsUrl: true
528
- };
529
- parent.trigger('beforeImageLoad', eventArgs);
530
- return eventArgs;
531
- }
532
- const baseUrl: string = parent.ajaxSettings.getImageUrl ? parent.ajaxSettings.getImageUrl : parent.ajaxSettings.url;
533
- const pathUrl: string = (baseUrl.indexOf('?') !== -1) ? '&path=' : '?path=';
534
- const fileName: string = encodeURIComponent(getValue('name', item));
535
- const fPath: string = getValue('filterPath', item);
536
- if (parent.hasId) {
537
- const imgId: string = getValue('id', item);
538
- imgUrl = baseUrl + pathUrl + parent.path + '&id=' + imgId;
539
- } else if (!isNOU(fPath)) {
540
- imgUrl = baseUrl + pathUrl + encodeURIComponent(fPath.replace(/\\/g, '/')) + fileName;
541
- } else {
542
- imgUrl = baseUrl + pathUrl + parent.path + fileName;
543
- }
544
- imgUrl = imgUrl + '&time=' + (new Date().getTime()).toString();
545
- const data: Object = { 'action': 'getImage', 'path': parent.path + fileName, 'id': getValue('id', item) };
546
- const ajaxSettings: Object = {
547
- url: baseUrl,
548
- type: 'POST',
549
- contentType: 'application/json',
550
- responseType: 'blob',
551
- data: JSON.stringify(data),
552
- onSuccess: null,
553
- onFailure: null,
554
- beforeSend: null
555
- };
556
- const eventArgs: BeforeImageLoadEventArgs = {
557
- fileDetails: [item],
558
- imageUrl: imgUrl,
559
- useImageAsUrl: true,
560
- ajaxSettings: ajaxSettings
561
- };
562
- parent.trigger('beforeImageLoad', eventArgs);
563
- return eventArgs;
564
- }
565
- /* istanbul ignore next */
566
- /**
567
- * Gets the full path
568
- *
569
- * @param {IFileManager} parent - specifies the parent element.
570
- * @param {Object} data - specifies the data.
571
- * @param {string} path - specifies the path.
572
- * @returns {string} - returns the image url.
573
- * @private
574
- */
575
- export function getFullPath(parent: IFileManager, data: Object, path: string): string {
576
- const filePath: string = getValue(parent.hasId ? 'id' : 'name', data) + '/';
577
- const fPath: string = getValue(parent.hasId ? 'filterId' : 'filterPath', data);
578
- if (!isNOU(fPath)) {
579
- return fPath.replace(/\\/g, '/').replace(/^.*?(?=\/)/, '') + filePath;
580
- } else {
581
- return path + filePath;
582
- }
583
- }
584
- /**
585
- * Gets the name
586
- *
587
- * @param {IFileManager} parent - specifies the parent element.
588
- * @param {Object} data - specifies the data.
589
- * @returns {string} - returns the name.
590
- * @private
591
- */
592
- export function getName(parent: IFileManager, data: Object): string {
593
- let name: string = getValue('name', data);
594
- let fPath: string = getValue('filterPath', data);
595
- if ((parent.breadcrumbbarModule.searchObj.element.value !== '' || parent.isFiltered) && !isNOU(fPath)) {
596
- fPath = fPath.replace(/\\/g, '/');
597
- name = fPath.replace(parent.path, '') + name;
598
- }
599
- return name;
600
- }
601
-
602
- /**
603
- * Gets the name
604
- *
605
- * @param {IFileManager} parent - specifies the parent element.
606
- * @param {Object[]} items - specifies the item elements.
607
- * @returns {Object[]} - returns the sorted data.
608
- * @private
609
- */
610
- export function getSortedData(parent: IFileManager, items: Object[]): Object[] {
611
- if (items.length === 0) { return items; }
612
- let query: Query ;
613
- if (parent.sortOrder !== 'None' && !isNullOrUndefined(parent.sortOrder)) {
614
- query = new Query().sortBy(parent.sortBy, parent.sortOrder.toLowerCase(), true).group('isFile');
615
- } else {
616
- query = new Query().group('isFile');
617
- }
618
- const lists: Object[] = new DataManager(items).executeLocal(query);
619
- return getValue('records', lists);
620
- }
621
- /**
622
- * Gets the data object
623
- *
624
- * @param {IFileManager} parent - specifies the parent element.
625
- * @param {string} key - specifies the key.
626
- * @param {string} value - specifies the value.
627
- * @returns {Object} - returns the sorted data.
628
- * @private
629
- */
630
- export function getObject(parent: IFileManager, key: string, value: string): Object {
631
- const currFiles: Object[] = getValue(parent.pathId[parent.pathId.length - 1], parent.feFiles);
632
- const result: object[] = currFiles.filter((data: { [key: string]: string | number }) => data[key as string].toString() === value);
633
- return result[0];
634
- }
635
-
636
- /**
637
- * Creates empty element
638
- *
639
- * @param {IFileManager} parent - specifies the parent element.
640
- * @param {HTMLElement} element - specifies the element.
641
- * @param {ReadArgs | SearchArgs} args - specifies the args.
642
- * @returns {void}
643
- * @private
644
- */
645
- export function createEmptyElement(parent: IFileManager, element: HTMLElement, args: ReadArgs | SearchArgs): void {
646
- let top: number;
647
- const layoutElement: Element = select('#' + parent.element.id + CLS.LAYOUT_ID, parent.element);
648
- const addressBarHeight: number = (<HTMLElement>select('#' + parent.element.id + CLS.BREADCRUMBBAR_ID, layoutElement)).offsetHeight;
649
- top = (<HTMLElement>layoutElement).offsetHeight - addressBarHeight;
650
- if (parent.view === 'Details') {
651
- top = top - (<HTMLElement>select('.' + CLS.GRID_HEADER, layoutElement)).offsetHeight;
652
- }
653
- if (isNOU(element.querySelector('.' + CLS.EMPTY))) {
654
- const emptyDiv: Element = createElement('div', { className: CLS.EMPTY });
655
- const emptyFolder: Element = createElement('div', { className: CLS.LARGE_EMPTY_FOLDER });
656
- const emptyEle: Element = createElement('div', { className: CLS.EMPTY_CONTENT });
657
- const dragFile: Element = createElement('div', { className: CLS.EMPTY_INNER_CONTENT });
658
- if (parent.view === 'Details') {
659
- element.querySelector('.' + CLS.GRID_VIEW).appendChild(emptyDiv);
660
- } else {
661
- element.appendChild(emptyDiv);
662
- }
663
- emptyDiv.appendChild(emptyFolder);
664
- emptyDiv.appendChild(emptyEle);
665
- emptyDiv.appendChild(dragFile);
666
- }
667
- if (element.querySelector('.' + CLS.EMPTY)) {
668
- if (!isNOU(args.error)) {
669
- element.querySelector('.' + CLS.EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Access-Denied');
670
- element.querySelector('.' + CLS.EMPTY_INNER_CONTENT).innerHTML = getLocaleText(parent, 'Access-Details');
671
- } else if (parent.isFiltered) {
672
- element.querySelector('.' + CLS.EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Filter-Empty');
673
- element.querySelector('.' + CLS.EMPTY_INNER_CONTENT).innerHTML = getLocaleText(parent, 'Filter-Key');
674
- } else if (parent.breadcrumbbarModule.searchObj.element.value !== '') {
675
- element.querySelector('.' + CLS.EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Search-Empty');
676
- element.querySelector('.' + CLS.EMPTY_INNER_CONTENT).innerHTML = getLocaleText(parent, 'Search-Key');
677
- } else {
678
- element.querySelector('.' + CLS.EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Folder-Empty');
679
- element.querySelector('.' + CLS.EMPTY_INNER_CONTENT).innerHTML = parent.uploadObj.dropArea == null ? getLocaleText(parent, '') : getLocaleText(parent, 'File-Upload');
680
- }
681
- }
682
- const eDiv: HTMLElement = <HTMLElement>select('.' + CLS.EMPTY, element);
683
- top = (top - eDiv.offsetHeight) / 2;
684
- eDiv.style.marginTop = top + 'px';
685
- }
686
-
687
- /**
688
- * Gets the directories
689
- *
690
- * @param {Object[]} files - specifies the file object.
691
- * @returns {Object[]} - returns the sorted data.
692
- * @private
693
- */
694
- export function getDirectories(files: Object[]): Object[] {
695
- return new DataManager(files).executeLocal(new Query().where(events.isFile, 'equal', false, false));
696
- }
697
-
698
- /**
699
- * set the Node ID
700
- *
701
- * @param {ReadArgs} result - specifies the result.
702
- * @param {string} rootId - specifies the rootId.
703
- * @returns {void}
704
- * @private
705
- */
706
- export function setNodeId(result: ReadArgs, rootId: string): void {
707
- const dirs: Object[] = getDirectories(result.files);
708
- for (let i: number = 0, len: number = dirs.length; i < len; i++) {
709
- setValue('_fm_id', rootId + '_' + i, dirs[i as number]);
710
- }
711
- }
712
-
713
- /**
714
- * set the date object
715
- *
716
- * @param {Object[]} args - specifies the file object.
717
- * @returns {void}
718
- * @private
719
- */
720
- export function setDateObject(args: Object[]): void {
721
- for (let i: number = 0; i < args.length; i++) {
722
- const createdDate: Date = new Date(getValue('dateCreated', args[i as number]));
723
- const modifiedDate: Date = new Date(getValue('dateModified', args[i as number]));
724
- setValue('_fm_created', createdDate, args[i as number]);
725
- setValue('_fm_modified', modifiedDate, args[i as number]);
726
- }
727
- }
728
-
729
- /**
730
- * get the locale text
731
- *
732
- * @param {IFileManager} parent - specifies the parent element.
733
- * @param {string} text - specifies the text.
734
- * @returns {string} - returns the locale text.
735
- * @private
736
- */
737
- export function getLocaleText(parent: IFileManager, text: string): string {
738
- const locale: string = parent.localeObj.getConstant(text);
739
- return (locale === '') ? text : locale;
740
- }
741
-
742
- /**
743
- * get the CSS class
744
- *
745
- * @param {IFileManager} parent - specifies the parent element.
746
- * @param {string} css - specifies the css.
747
- * @returns {string} - returns the css classes.
748
- * @private
749
- */
750
- export function getCssClass(parent: IFileManager, css: string): string {
751
- let cssClass: string = parent.cssClass;
752
- cssClass = (isNOU(cssClass) || cssClass === '') ? css : (cssClass + ' ' + css);
753
- return cssClass;
754
- }
755
-
756
- /**
757
- * sort on click
758
- *
759
- * @param {IFileManager} parent - specifies the parent element.
760
- * @param {MenuEventArgs} args - specifies the menu event arguements.
761
- * @returns {void}
762
- * @private
763
- */
764
- export function sortbyClickHandler(parent: IFileManager, args: MenuEventArgs): void {
765
- let tick: boolean;
766
- parent.isSortByClicked = true;
767
- if (args.item.id.indexOf('ascending') !== -1 || args.item.id.indexOf('descending') !== -1 || args.item.id.indexOf('none') !== -1) {
768
- tick = true;
769
- } else {
770
- tick = false;
771
- }
772
- if (!tick) {
773
- parent.sortBy = getSortField(args.item.id, parent);
774
- } else {
775
- parent.sortOrder = <SortOrder>getSortField(args.item.id);
776
- }
777
- parent.itemData = [getPathObject(parent)];
778
- if (parent.view === 'Details') {
779
- if (parent.isMobile) {
780
- updateLayout(parent, 'Details');
781
- } else {
782
- parent.notify(events.sortColumn, { module: 'detailsview' });
783
- parent.isSortByClicked = false;
784
- }
785
- }
786
- if (parent.view === 'LargeIcons') {
787
- updateLayout(parent, 'LargeIcons');
788
- }
789
-
790
- parent.notify(events.sortByChange, {});
791
- }
792
-
793
- /**
794
- * Gets the sorted fields
795
- *
796
- * @param {string} id - specifies the id.
797
- * @param {IFileManager} [parent] - optional parameter representing the parent IFileManager.
798
- * @returns {string} - returns the sorted fields
799
- * @private
800
- */
801
- export function getSortField(id: string, parent?: IFileManager): string {
802
- const text: string = id.substring(id.lastIndexOf('_') + 1);
803
- let field: string = text;
804
- let column: ColumnModel[];
805
- if (parent) {
806
- column = parent.detailsViewSettings.columns;
807
- }
808
- switch (text) {
809
- case 'date':
810
- for (let i: number = 0, len: number = column.length; i < len; i++) {
811
- if (column[i as number].field === 'dateModified' || column[i as number].field === 'dateCreated') {
812
- field = column[i as number].field;
813
- break;
814
- }
815
- else {
816
- field = '_fm_modified';
817
- }
818
- }
819
- break;
820
- case 'ascending':
821
- field = 'Ascending';
822
- break;
823
- case 'descending':
824
- field = 'Descending';
825
- break;
826
- case 'none':
827
- field = 'None';
828
- break;
829
- }
830
- return field;
831
- }
832
-
833
- /**
834
- * Sets the next path
835
- *
836
- * @param {IFileManager} parent - specifies the parent element.
837
- * @param {string} path - specifies the path.
838
- * @returns {void}
839
- * @private
840
- */
841
- export function setNextPath(parent: IFileManager, path: string): void {
842
- const currfolders: string[] = path.split('/');
843
- const folders: string[] = parent.originalPath.split('/');
844
- const root: Object = getValue(parent.pathId[0], parent.feParent);
845
- const key: string = isNOU(getValue('id', root)) ? 'name' : 'id';
846
- for (let i: number = currfolders.length - 1, len: number = folders.length - 1; i < len; i++) {
847
- const eventName: string = (folders[i + 1] === '') ? events.finalizeEnd : events.initialEnd;
848
- const newPath: string = (folders[i as number] === '') ? '/' : (parent.path + folders[i as number] + '/');
849
- const data: Object = getObject(parent, key, folders[parseInt(i.toString(), 10)]);
850
- const id: string = getValue('_fm_id', data);
851
- parent.setProperties({ path: newPath }, true);
852
- if (!isNullOrUndefined(id)) {
853
- parent.pathId.push(id);
854
- }
855
- parent.itemData = [data];
856
- parent.pathNames.push(getValue('name', data));
857
- read(parent, eventName, parent.path);
858
- break;
859
- }
860
- }
861
-
862
- /**
863
- * Opens the searched folder
864
- *
865
- * @param {IFileManager} parent - specifies the parent element.
866
- * @param {Object} data - specifies the data
867
- * @returns {void}
868
- * @private
869
- */
870
- export function openSearchFolder(parent: IFileManager, data: Object): void {
871
- parent.originalPath = getFullPath(parent, data, parent.path);
872
- const root: Object = getValue(parent.pathId[0], parent.feParent);
873
- const navData: object = parent.feParent[getValue('_fm_id', parent.itemData[0])];
874
- const isRoot: boolean = isNullOrUndefined(navData) || getValue('_fm_id', navData) === 'fe_tree';
875
- const key: string = isNOU(getValue('id', root)) ? 'name' : 'id';
876
- const searchData: object = getObject(parent, key, isFileSystemData(parent) ? getValue('id', data) : getValue('name', data));
877
- if (isNullOrUndefined(searchData))
878
- {
879
- if (!isRoot)
880
- {
881
- parent.notify(events.clearPathInit, { selectedNode: parent.pathId[parent.pathId.length - 1] });
882
- }
883
- else
884
- {
885
- setNextPath(parent, parent.path);
886
- return;
887
- }
888
- }
889
- else
890
- {
891
- const id: string = getValue('_fm_id', searchData);
892
- parent.setProperties({ path: parent.originalPath }, true);
893
- parent.pathId.push(id);
894
- parent.itemData = [searchData];
895
- parent.pathNames.push(getValue('name', searchData));
896
- }
897
- read(parent, (parent.path !== parent.originalPath) ? events.initialEnd : events.finalizeEnd, parent.path);
898
- }
899
-
900
- /**
901
- * Paste handling function
902
- *
903
- * @param {IFileManager} parent - specifies the parent element.
904
- * @returns {void}
905
- * @private
906
- */
907
- export function pasteHandler(parent: IFileManager): void {
908
- parent.isDragDrop = false;
909
- if (parent.selectedNodes.length !== 0 && parent.enablePaste) {
910
- const path: string = (parent.folderPath === '') ? parent.path : parent.folderPath;
911
- if (parent.activeModule === 'navigationpane' && !parent.selectedNodes[0].includes('/')) {
912
- parent.targetPath = getTargetPath(parent, parent.actionRecords[0]);
913
- }
914
- const subFolder: boolean = validateSubFolder(parent, <{ [key: string]: Object; }[]>parent.actionRecords, path, parent.path);
915
- if (!subFolder) {
916
- if ((parent.fileAction === 'move' && parent.targetPath !== path) || parent.fileAction === 'copy') {
917
- parent.notify(events.pasteInit, {});
918
- paste(
919
- parent, parent.targetPath, parent.selectedNodes, path, parent.fileAction, [], parent.actionRecords);
920
- } else {
921
- parent.enablePaste = false;
922
- parent.notify(events.hidePaste, {});
923
- removeBlur(parent);
924
- const result: ReadArgs = {
925
- files: null,
926
- error: {
927
- code: '402',
928
- message: getLocaleText(parent, 'Same-Folder-Error'),
929
- fileExists: null
930
- }
931
- };
932
- createDialog(parent, 'Error', result);
933
- }
934
- }
935
- }
936
- }
937
-
938
- /**
939
- * Validates the sub folders
940
- *
941
- * @param {IFileManager} parent - specifies the parent element.
942
- * @param {'{ [key: string]: Object; }[]'} data - specifies the data.
943
- * @param {string} dropPath - specifies the drop path.
944
- * @param {string} dragPath - specifies the drag path.
945
- * @returns {boolean} - returns the validated sub folder.
946
- * @private
947
- */
948
- export function validateSubFolder(parent: IFileManager, data: { [key: string]: Object; }[], dropPath: string, dragPath: string): boolean {
949
- let subFolder: boolean = false;
950
- for (let i: number = 0; i < data.length; i++) {
951
- if (!getValue('isFile', data[i as number])) {
952
- const tempTarget: string = getFullPath(parent, data[i as number], dragPath);
953
- if (dropPath.indexOf(tempTarget) === 0) {
954
- const result: ReadArgs = {
955
- files: null,
956
- error: {
957
- code: '402',
958
- message: getLocaleText(parent, 'Sub-Folder-Error'),
959
- fileExists: null
960
- }
961
- };
962
- createDialog(parent, 'Error', result);
963
- subFolder = true;
964
- break;
965
- }
966
- } else {
967
- const name: Object = parent.dragData[i as number] ? parent.dragData[i as number].name : null;
968
- const srcData: string = isFileSystemData(parent) ? name as string : parent.dragNodes[i as number];
969
- let len: number = 0;
970
- if (srcData) {
971
- len = srcData.lastIndexOf('/');
972
- }
973
- let path: string = '';
974
- if (len > 0) {
975
- path = dragPath + srcData.substring(0, len + 1);
976
- }
977
- if (path === dropPath) {
978
- const result: ReadArgs = {
979
- files: null,
980
- error: {
981
- code: '402',
982
- message: getLocaleText(parent, 'Same-Folder-Error'),
983
- fileExists: null
984
- }
985
- };
986
- createDialog(parent, 'Error', result);
987
- subFolder = true;
988
- break;
989
- }
990
- }
991
- }
992
- return subFolder;
993
- }
994
-
995
- /**
996
- * Validates the drop handler
997
- *
998
- * @param {IFileManager} parent - specifies the parent element.
999
- * @returns {void}
1000
- * @private
1001
- */
1002
- export function dropHandler(parent: IFileManager): void {
1003
- parent.isDragDrop = true;
1004
- if (parent.dragData.length !== 0) {
1005
- parent.dragPath = parent.dragPath.replace(/\\/g, '/');
1006
- parent.dropPath = parent.dropPath.replace(/\\/g, '/');
1007
- const subFolder: boolean = validateSubFolder(parent, parent.dragData, parent.dropPath, parent.dragPath);
1008
- if (!subFolder && (parent.dragPath !== parent.dropPath)) {
1009
- parent.itemData = [parent.dropData];
1010
- paste(
1011
- parent, parent.dragPath, parent.dragNodes, parent.dropPath, 'move', [], parent.dragData);
1012
- parent.notify(events.pasteInit, {});
1013
- }
1014
- }
1015
- }
1016
-
1017
- /**
1018
- * Gets the parent path
1019
- *
1020
- * @param {string} oldPath - specifies the old path.
1021
- * @returns {string} - returns the parent path.
1022
- * @private
1023
- */
1024
- export function getParentPath(oldPath: string): string {
1025
- const path: string[] = oldPath.split('/');
1026
- let newPath: string = path[0] + '/';
1027
- for (let i: number = 1; i < path.length - 2; i++) {
1028
- newPath += path[i as number] + '/';
1029
- }
1030
- return newPath;
1031
- }
1032
-
1033
- /**
1034
- * Gets the directory path
1035
- *
1036
- * @param {IFileManager} parent - specifies the parent.
1037
- * @param {ReadArgs} args - returns the read arguements.
1038
- * @returns {string} - returns the directory path
1039
- * @private
1040
- */
1041
- export function getDirectoryPath(parent: IFileManager, args: ReadArgs): string {
1042
- const filePath: string = getValue(parent.hasId ? 'id' : 'name', args.cwd) + '/';
1043
- let fPath: string = getValue(parent.hasId && !isNullOrUndefined(parent.ajaxSettings.url) ? 'filterId' : 'filterPath', args.cwd);
1044
- if (!isNOU(fPath) && isFileSystemData(parent) && fPath !== '' && fPath !== '\\') {
1045
- fPath = '\\' + args.cwd.parentId + '\\';
1046
- }
1047
- if (!isNOU(fPath)) {
1048
- if (fPath === '') {
1049
- return '/';
1050
- }
1051
- return fPath.replace(/\\/g, '/').replace(/^.*?(?=\/)/, '') + filePath;
1052
- } else {
1053
- return isFileSystemData(parent) ? filePath : parent.path + filePath;
1054
- }
1055
- }
1056
-
1057
- /**
1058
- * Gets the do paste path
1059
- *
1060
- * @param {IFileManager} parent - specifies the parent.
1061
- * @param {string} operation - specifies the operations.
1062
- * @param {ReadArgs} result - returns the result.
1063
- * @returns {void}
1064
- * @private
1065
- */
1066
- export function doPasteUpdate(parent: IFileManager, operation: string, result: ReadArgs): void {
1067
- if (operation === 'move') {
1068
- if (!parent.isDragDrop) {
1069
- parent.enablePaste = false;
1070
- parent.notify(events.hidePaste, {});
1071
- parent.notify(events.cutEnd, result);
1072
- } else {
1073
- parent.notify(events.dragEnd, result);
1074
- }
1075
- }
1076
- if (parent.duplicateItems.length === 0) {
1077
- parent.pasteNodes = [];
1078
- }
1079
- const flag: boolean = false;
1080
- for (let count: number = 0; (count < result.files.length) && !flag; count++) {
1081
- parent.pasteNodes.push(<string>result.files[count as number][parent.hasId ? 'id' : 'name']);
1082
- if (parent.isDragDrop) {
1083
- parent.droppedObjects.push(result.files[count as number]);
1084
- }
1085
- }
1086
- parent.duplicateItems = [];
1087
- parent.duplicateRecords = [];
1088
- if (parent.isDragDrop && !parent.isPasteError) {
1089
- parent.isDropEnd = true;
1090
- } else {
1091
- parent.isDropEnd = false;
1092
- }
1093
- parent.trigger('success', { action: operation, result: result });
1094
- if (!parent.isDragDrop || (parent.path === parent.dragPath) || (parent.path === parent.dropPath)
1095
- || parent.isSearchDrag) {
1096
- parent.isPathDrag = false;
1097
- read(parent, events.pasteEnd, parent.path);
1098
- } else {
1099
- readDropPath(parent);
1100
- }
1101
- }
1102
-
1103
- /**
1104
- * Reads the drop path
1105
- *
1106
- * @param {IFileManager} parent - specifies the parent.
1107
- * @returns {void}
1108
- * @private
1109
- */
1110
- export function readDropPath(parent: IFileManager): void {
1111
- let pathId: string = getValue('_fm_id', parent.dropData);
1112
- parent.expandedId = pathId;
1113
- parent.itemData = [parent.dropData];
1114
- if (parent.isPathDrag) {
1115
- parent.notify(events.pathDrag, parent.itemData);
1116
- } else {
1117
- if (parent.navigationpaneModule) {
1118
- let node: Element = select('[data-uid="' + pathId + '"]', parent.navigationpaneModule.treeObj.element);
1119
- if (!node) {
1120
- const liElement: Element = document.querySelector('[data-id = "' + getValue('id', parent.dropData) + '"]');
1121
- pathId = liElement.getAttribute('data-uid');
1122
- node = select('[data-uid="' + pathId + '"]', parent.navigationpaneModule.treeObj.element);
1123
- }
1124
- updatePath(<HTMLLIElement>node, parent.dropData, parent);
1125
- }
1126
- read(parent, events.dropPath, parent.dropPath);
1127
- }
1128
- }
1129
-
1130
- /**
1131
- * Gets the duplicated path
1132
- *
1133
- * @param {IFileManager} parent - specifies the parent.
1134
- * @param {string} name - specifies the name.
1135
- * @returns {object} - returns the duplicated path.
1136
- * @private
1137
- */
1138
- export function getDuplicateData(parent: IFileManager, name: string): object {
1139
- let data: object = null;
1140
- const records: object[] = parent.isDragDrop ? parent.dragData : parent.actionRecords;
1141
- for (let i: number = 0; i < records.length; i++) {
1142
- if (getValue('name', records[i as number]) === name) {
1143
- data = records[i as number];
1144
- break;
1145
- }
1146
- }
1147
- return data;
1148
- }
1149
-
1150
- /**
1151
- * Gets the create the virtual drag element
1152
- *
1153
- * @param {IFileManager} parent - specifies the parent.
1154
- * @returns {void}
1155
- * @private
1156
- */
1157
- export function createVirtualDragElement(parent: IFileManager): void {
1158
- parent.isSearchDrag = false;
1159
- if (parent.breadcrumbbarModule.searchObj.element.value !== '') { parent.isSearchDrag = true; }
1160
- if (parent.activeModule !== 'navigationpane') {
1161
- parent.dragNodes = [];
1162
- let i: number = 0;
1163
- while (i < parent.selectedItems.length) {
1164
- parent.dragNodes.push(parent.selectedItems[i as number]);
1165
- i++;
1166
- }
1167
- if (parent.selectedItems.length === 0 && parent.dragData && parent.dragData.length === 1) {
1168
- parent.dragNodes.push(getItemName(parent, parent.dragData[0]));
1169
- }
1170
- }
1171
- const cloneIcon: HTMLElement = parent.createElement('div', {
1172
- className: 'e-fe-icon ' + fileType(parent.dragData[0])
1173
- });
1174
- const cloneName: HTMLElement = parent.createElement('div', {
1175
- className: 'e-fe-name',
1176
- innerHTML: <string>parent.dragData[0].name
1177
- });
1178
- const virtualEle: HTMLElement = parent.createElement('div', {
1179
- className: 'e-fe-content'
1180
- });
1181
- virtualEle.appendChild(cloneIcon);
1182
- virtualEle.appendChild(cloneName);
1183
- const ele: HTMLElement = parent.createElement('div', {
1184
- className: CLS.CLONE
1185
- });
1186
- ele.appendChild(virtualEle);
1187
- if (parent.dragNodes.length > 1) {
1188
- const badge: HTMLElement = parent.createElement('span', {
1189
- className: 'e-fe-count',
1190
- innerHTML: (parent.dragNodes.length).toString(10)
1191
- });
1192
- ele.appendChild(badge);
1193
- }
1194
- parent.virtualDragElement = ele;
1195
- parent.element.appendChild(parent.virtualDragElement);
1196
- }
1197
-
1198
- /**
1199
- * Drops the stop handler
1200
- *
1201
- * @param {IFileManager} parent - specifies the parent.
1202
- * @param {DragEventArgs} args - specifies the drag event arguements.
1203
- * @returns {void}
1204
- * @private
1205
- */
1206
- export function dragStopHandler(parent: IFileManager, args: DragEventArgs): void {
1207
- const dragArgs: FileDragEventArgs = args;
1208
- dragArgs.cancel = false;
1209
- if (parent.treeExpandTimer != null) {
1210
- window.clearTimeout(parent.treeExpandTimer);
1211
- parent.treeExpandTimer = null;
1212
- }
1213
- removeDropTarget(parent);
1214
- parent.element.classList.remove('e-fe-drop', 'e-no-drop');
1215
- removeBlur(parent);
1216
- parent.uploadObj.dropArea = <HTMLElement>select('#' + parent.element.id + CLS.CONTENT_ID, parent.element);
1217
- const virtualEle: Element = select('.' + CLS.CLONE, parent.element);
1218
- if (virtualEle) { detach(virtualEle); }
1219
- getTargetModule(parent, args.target);
1220
- parent.notify(events.dropInit, args);
1221
- removeBlur(parent, 'hover');
1222
- dragArgs.fileDetails = parent.dragData;
1223
- parent.trigger('fileDragStop', dragArgs, (dragArgs: FileDragEventArgs) => {
1224
- if (!dragArgs.cancel && !isNOU(parent.targetModule) && parent.targetModule !== '' && parent.dragCount > 2) {
1225
- dropHandler(parent);
1226
- }
1227
- parent.dragCount = 0;
1228
- });
1229
- }
1230
-
1231
- /**
1232
- * Drag the start handler
1233
- *
1234
- * @param {IFileManager} parent - specifies the parent.
1235
- * @param {'DragEventArgs'} args - specifies the drag event arguements.
1236
- * @param {Draggable} dragObj - specifies the drag event arguements.
1237
- * @returns {void}
1238
- * @private
1239
- */
1240
- export function dragStartHandler(parent: IFileManager, args: DragEventArgs, dragObj: Draggable): void {
1241
- const dragArgs: FileDragEventArgs = args;
1242
- dragArgs.cancel = false;
1243
- dragArgs.fileDetails = parent.dragData;
1244
- parent.dragCount = 0;
1245
- parent.droppedObjects = [];
1246
- if (!parent.allowDragAndDrop || ((parent.activeModule === 'navigationpane') &&
1247
- (closest(args.element, 'li').getAttribute('data-uid') === parent.pathId[0]))) {
1248
- dragArgs.cancel = true;
1249
- }
1250
- if ((parent.activeModule === 'navigationpane') &&
1251
- (parent.pathId.indexOf(closest(args.element, 'li').getAttribute('data-uid')) !== -1)) {
1252
- parent.isPathDrag = true;
1253
- } else {
1254
- parent.isPathDrag = false;
1255
- }
1256
- removeBlur(parent);
1257
- if (dragArgs.cancel) {
1258
- dragObj.intDestroy(args.event);
1259
- dragCancel(parent);
1260
- } else if (!dragArgs.cancel) {
1261
- let i: number = 0;
1262
- while (i < parent.activeElements.length) {
1263
- addBlur(parent.activeElements[i as number]);
1264
- i++;
1265
- }
1266
- parent.trigger('fileDragStart', dragArgs, (dragArgs: FileDragEventArgs) => {
1267
- if (dragArgs.cancel) {
1268
- dragObj.intDestroy(args.event);
1269
- dragCancel(parent);
1270
- } else {
1271
- parent.uploadObj.dropArea = null;
1272
- }
1273
- });
1274
- }
1275
- }
1276
-
1277
- /**
1278
- * Drag the cancel handler
1279
- *
1280
- * @param {IFileManager} parent - specifies the parent.
1281
- * @returns {void}
1282
- * @private
1283
- */
1284
- export function dragCancel(parent: IFileManager): void {
1285
- removeBlur(parent);
1286
- const virtualEle: Element = select('.' + CLS.CLONE, parent.element);
1287
- if (virtualEle) { detach(virtualEle); }
1288
- }
1289
-
1290
- /**
1291
- * Remove drop target handler
1292
- *
1293
- * @param {IFileManager} parent - specifies the parent.
1294
- * @returns {void}
1295
- * @private
1296
- */
1297
- export function removeDropTarget(parent: IFileManager): void {
1298
- removeItemClass(parent, CLS.DROP_FOLDER);
1299
- removeItemClass(parent, CLS.DROP_FILE);
1300
- }
1301
-
1302
- /**
1303
- * Remove item class handler
1304
- *
1305
- * @param {IFileManager} parent - specifies the parent.
1306
- * @param {string} value - specifies the value.
1307
- * @returns {void}
1308
- * @private
1309
- */
1310
- export function removeItemClass(parent: IFileManager, value: string): void {
1311
- const ele: NodeListOf<Element> = parent.element.querySelectorAll('.' + value);
1312
- for (let i: number = 0; i < ele.length; i++) {
1313
- ele[i as number].classList.remove(value);
1314
- }
1315
- }
1316
-
1317
- /**
1318
- * Remove item class handler
1319
- *
1320
- * @param {Element} scrollParent - specifies the scrolling target.
1321
- * @param {IFileManager} parent - specifies the parent.
1322
- * @param {string} nodeClass - specifies the node class.
1323
- * @param {number} clientY - specifies the vertical (Y) coordinate of the mouse cursor position relative to the target element.
1324
- * @returns {void}
1325
- * @private
1326
- */
1327
- export function scrollHandler(scrollParent: Element, parent: IFileManager, nodeClass: string, clientY: number): void {
1328
- let position: number;
1329
- const elementData: DOMRect | ClientRect = scrollParent.getBoundingClientRect();
1330
- const node: HTMLElement = select('.' + nodeClass, scrollParent);
1331
- if ((clientY >= (elementData.top + scrollParent.clientHeight - 30)) && !isNullOrUndefined(node)) {
1332
- position = (parent.targetModule === 'navigationpane' || parent.targetModule === 'detailsview') ? node.offsetHeight / 2.5 : node.offsetHeight / 4.5;
1333
- scrollParent.scrollBy(0, position);
1334
- }
1335
- if (!isNullOrUndefined(node) && (clientY <= (elementData.top + 30))) {
1336
- position = (parent.targetModule === 'navigationpane' || parent.targetModule === 'detailsview') ? node.offsetHeight / 2.5 : node.offsetHeight / 4.5;
1337
- scrollParent.scrollBy(0, -position);
1338
- }
1339
- }
1340
-
1341
- /**
1342
- * Dragging handler
1343
- *
1344
- * @param {IFileManager} parent - specifies the parent.
1345
- * @param {DragEventArgs} args - specifies the arguements.
1346
- * @returns {void}
1347
- * @private
1348
- */
1349
- export function draggingHandler(parent: IFileManager, args: DragEventArgs): void {
1350
- const dragArgs: FileDragEventArgs = args;
1351
- dragArgs.fileDetails = parent.dragData;
1352
- let canDrop: boolean = false;
1353
- getTargetModule(parent, args.target);
1354
- removeDropTarget(parent);
1355
- if (parent.treeExpandTimer != null) {
1356
- window.clearTimeout(parent.treeExpandTimer);
1357
- parent.treeExpandTimer = null;
1358
- }
1359
- removeBlur(parent, 'hover');
1360
- let node: Element = null;
1361
- let scrollParent: Element;
1362
- if (parent.targetModule === 'navigationpane') {
1363
- node = closest(args.target, 'li');
1364
- node.classList.add(CLS.HOVER, CLS.DROP_FOLDER);
1365
- canDrop = true;
1366
- /* istanbul ignore next */
1367
- parent.treeExpandTimer = window.setTimeout(() => { parent.notify(events.dragging, args); }, 800);
1368
- scrollParent = parent.navigationpaneModule.treeObj.element.parentElement;
1369
- scrollHandler(scrollParent, parent, 'e-level-2', args.event.y);
1370
- } else if (parent.targetModule === 'detailsview') {
1371
- node = closest(args.target, 'tr');
1372
- if (node && node.querySelector('.' + CLS.FOLDER) && !node.classList.contains(CLS.BLUR)) {
1373
- node.classList.add(CLS.DROP_FOLDER);
1374
- } else if (node && !node.querySelector('.' + CLS.FOLDER) && !node.classList.contains(CLS.BLUR)) {
1375
- node.classList.add(CLS.DROP_FILE);
1376
- }
1377
- canDrop = true;
1378
- scrollParent = parent.detailsviewModule.gridObj.element.querySelector('.e-content');
1379
- scrollHandler(scrollParent, parent, 'e-row', args.event.y);
1380
- } else if (parent.targetModule === 'largeiconsview') {
1381
- node = closest(args.target, 'li');
1382
- if (node && node.querySelector('.' + CLS.FOLDER) && !node.classList.contains(CLS.BLUR)) {
1383
- node.classList.add(CLS.HOVER, CLS.DROP_FOLDER);
1384
- }
1385
- canDrop = true;
1386
- scrollParent = parent.largeiconsviewModule.element.firstElementChild;
1387
- scrollHandler(scrollParent, parent, 'e-large-icon', args.event.y);
1388
- /* istanbul ignore next */
1389
- } else if (parent.targetModule === 'breadcrumbbar') {
1390
- canDrop = true;
1391
- }
1392
- parent.element.classList.remove('e-fe-drop', 'e-no-drop');
1393
- parent.element.classList.add(canDrop ? 'e-fe-drop' : 'e-no-drop');
1394
- parent.dragCount = parent.dragCount + 1;
1395
- parent.trigger('fileDragging', dragArgs);
1396
- }
1397
-
1398
- /**
1399
- * Object to string handler
1400
- *
1401
- * @param {Object} data - specifies the data.
1402
- * @returns {string} returns string converted from Object.
1403
- * @private
1404
- */
1405
- // Ignored the message key value in permission object
1406
- export function objectToString(data: Object): string {
1407
- let str: string = '';
1408
- const keys: string[] = Object.keys(data);
1409
- for (let i: number = 0; i < keys.length; i++) {
1410
- if (keys[i as number] !== 'message') {
1411
- str += (i === 0 ? '' : ', ') + keys[i as number] + ': ' + getValue(keys[i as number], data);
1412
- }
1413
- }
1414
- return str;
1415
- }
1416
-
1417
- /**
1418
- * Get item name handler
1419
- *
1420
- * @param {IFileManager} parent - specifies the parent.
1421
- * @param {Object} data - specifies the data.
1422
- * @returns {string} returns the item name.
1423
- * @private
1424
- */
1425
- export function getItemName(parent: IFileManager, data: Object): string {
1426
- if (parent.hasId) {
1427
- return getValue('id', data);
1428
- }
1429
- return getName(parent, data);
1430
- }
1431
-
1432
- /**
1433
- * Get item name handler
1434
- *
1435
- * @param {IFileManager} parent - specifies the parent.
1436
- * @param {Object} data - specifies the data.
1437
- * @returns {void}
1438
- * @private
1439
- */
1440
- export function updateRenamingData(parent: IFileManager, data: Object): void {
1441
- parent.itemData = [data];
1442
- parent.currentItemText = getValue('name', data);
1443
- parent.isFile = getValue('isFile', data);
1444
- parent.filterPath = getValue('filterPath', data);
1445
- }
1446
-
1447
- /**
1448
- * Get item name handler
1449
- *
1450
- * @param {IFileManager} parent - specifies the parent.
1451
- * @returns {void}
1452
- * @private
1453
- */
1454
- export function doRename(parent: IFileManager): void {
1455
- if (!hasEditAccess(parent.itemData[0])) {
1456
- createDeniedDialog(parent, parent.itemData[0], events.permissionEdit);
1457
- } else {
1458
- createDialog(parent, 'Rename');
1459
- }
1460
- }
1461
-
1462
- /* istanbul ignore next */
1463
- /**
1464
- * Download handler
1465
- *
1466
- * @param {IFileManager} parent - specifies the parent.
1467
- * @returns {void}
1468
- * @private
1469
- */
1470
- export function doDownload(parent: IFileManager): void {
1471
- const items: Object[] = parent.itemData;
1472
- for (let i: number = 0; i < items.length; i++) {
1473
- if (!hasDownloadAccess(items[i as number])) {
1474
- createDeniedDialog(parent, items[i as number], events.permissionDownload);
1475
- return;
1476
- }
1477
- }
1478
- if (parent.selectedItems.length > 0) {
1479
- Download(parent, parent.path, parent.selectedItems);
1480
- }
1481
- }
1482
-
1483
- /**
1484
- * Delete Files handler
1485
- *
1486
- * @param {IFileManager} parent - specifies the parent.
1487
- * @param {Object[]} data - specifies the data.
1488
- * @param {string[]} newIds - specifies the new Ids.
1489
- * @returns {void}
1490
- * @private
1491
- */
1492
- export function doDeleteFiles(parent: IFileManager, data: Object[], newIds: string[]): void {
1493
- for (let i: number = 0; i < data.length; i++) {
1494
- if (!hasEditAccess(data[i as number])) {
1495
- createDeniedDialog(parent, data[i as number], events.permissionEdit);
1496
- return;
1497
- }
1498
- }
1499
- parent.itemData = data;
1500
- Delete(parent, newIds, parent.path, 'delete');
1501
- }
1502
- /* istanbul ignore next */
1503
- /**
1504
- * Download files handler
1505
- *
1506
- * @param {IFileManager} parent - specifies the parent.
1507
- * @param {Object[]} data - specifies the data.
1508
- * @param {string[]} newIds - specifies the new Ids.
1509
- * @returns {void}
1510
- * @private
1511
- */
1512
- export function doDownloadFiles(parent: IFileManager, data: Object[], newIds: string[]): void {
1513
- for (let i: number = 0; i < data.length; i++) {
1514
- if (!hasDownloadAccess(data[i as number])) {
1515
- createDeniedDialog(parent, data[i as number], events.permissionDownload);
1516
- return;
1517
- }
1518
- }
1519
- parent.itemData = data;
1520
- if (newIds.length > 0) {
1521
- Download(parent, parent.path, newIds);
1522
- }
1523
- }
1524
-
1525
- /**
1526
- * Download files handler
1527
- *
1528
- * @param {IFileManager} parent - specifies the parent.
1529
- * @param {Object} data - specifies the data.
1530
- * @param {string} action - specifies the actions.
1531
- * @returns {void}
1532
- * @private
1533
- */
1534
- export function createDeniedDialog(parent: IFileManager, data: Object, action: string): void {
1535
- let message: string = getValue('message', getValue('permission', data));
1536
- if (message === '') {
1537
- message = getLocaleText(parent, 'Access-Message').replace('{0}', getValue('name', data)).replace('{1}', action);
1538
- }
1539
- const response: ReadArgs = {
1540
- error: {
1541
- code: '401',
1542
- fileExists: null,
1543
- message: message
1544
- }
1545
- };
1546
- createDialog(parent, 'Error', response);
1547
- }
1548
-
1549
- /**
1550
- * Get Access Classes
1551
- *
1552
- * @param {Object} data - specifies the data.
1553
- * @returns {string} - returns accesses classes.
1554
- * @private
1555
- */
1556
- export function getAccessClass(data: Object): string {
1557
- return !hasReadAccess(data) ? 'e-fe-locked e-fe-hidden' : 'e-fe-locked';
1558
- }
1559
-
1560
- /**
1561
- * Check read access handler
1562
- *
1563
- * @param {Object} data - specifies the data.
1564
- * @returns {boolean} - returns read access.
1565
- * @private
1566
- */
1567
- export function hasReadAccess(data: Object): boolean {
1568
- const permission: Object = getValue('permission', data);
1569
- return (permission && !getValue('read', permission)) ? false : true;
1570
- }
1571
-
1572
- /**
1573
- * Check edit access handler
1574
- *
1575
- * @param {Object} data - specifies the data.
1576
- * @returns {boolean} - returns edit access.
1577
- * @private
1578
- */
1579
- export function hasEditAccess(data: Object): boolean {
1580
- const permission: Object = getValue('permission', data);
1581
- return permission ? ((getValue('read', permission) && getValue('write', permission))) : true;
1582
- }
1583
-
1584
- /**
1585
- * Check content access handler
1586
- *
1587
- * @param {Object} data - specifies the data.
1588
- * @returns {boolean} - returns content access.
1589
- * @private
1590
- */
1591
- export function hasContentAccess(data: Object): boolean {
1592
- const permission: Object = getValue('permission', data);
1593
- return permission ? ((getValue('read', permission) && getValue('writeContents', permission))) : true;
1594
- }
1595
-
1596
- /**
1597
- * Check upload access handler
1598
- *
1599
- * @param {Object} data - specifies the data.
1600
- * @returns {boolean} - returns upload access.
1601
- * @private
1602
- */
1603
- export function hasUploadAccess(data: Object): boolean {
1604
- const permission: Object = getValue('permission', data);
1605
- return permission ? ((getValue('read', permission) && getValue('upload', permission))) : true;
1606
- }
1607
-
1608
- /**
1609
- * Check download access handler
1610
- *
1611
- * @param {Object} data - specifies the data.
1612
- * @returns {boolean} - returns download access.
1613
- * @private
1614
- */
1615
- export function hasDownloadAccess(data: Object): boolean {
1616
- const permission: Object = getValue('permission', data);
1617
- return permission ? ((getValue('read', permission) && getValue('download', permission))) : true;
1618
- }
1619
-
1620
- /**
1621
- * Create new folder handler
1622
- *
1623
- * @param {IFileManager} parent - specifies the parent.
1624
- * @returns {void}
1625
- * @private
1626
- */
1627
- export function createNewFolder(parent: IFileManager): void {
1628
- const details: Object = parent.itemData[0];
1629
- if (!hasContentAccess(details)) {
1630
- createDeniedDialog(parent, details, events.permissionEditContents);
1631
- } else {
1632
- createDialog(parent, 'NewFolder');
1633
- }
1634
- }
1635
-
1636
- /**
1637
- * Upload item handler
1638
- *
1639
- * @param {IFileManager} parent - specifies the parent.
1640
- * @returns {void}
1641
- * @private
1642
- */
1643
- export function uploadItem(parent: IFileManager): void {
1644
- const details: Object = parent.itemData[0];
1645
- if (!hasUploadAccess(details)) {
1646
- createDeniedDialog(parent, details, events.permissionUpload);
1647
- } else {
1648
- const eleId: string = '#' + parent.element.id + CLS.UPLOAD_ID;
1649
- const uploadEle: HTMLElement = document.querySelector(eleId);
1650
- uploadEle.click();
1651
- }
1652
- }
1653
-
1654
- /**
1655
- * Close dialog popup handler
1656
- *
1657
- * @param {IFileManager} parent - specifies the parent.
1658
- * @returns {void}
1659
- * @private
1660
- */
1661
- export function closePopup(parent: IFileManager): void {
1662
- if (!isNullOrUndefined(parent.dialogObj)) {
1663
- parent.dialogObj.hide();
1664
- }
1665
- }
1666
-
1667
- /**
1668
- * Get target path from item data.
1669
- *
1670
- * @param {IFileManager} parent - specifies the parent.
1671
- * @param {Object} itemData - specifies the item elements.
1672
- * @returns {string} returns the path.
1673
- * @private
1674
- */
1675
- export function getTargetPath(parent: IFileManager, itemData: Object): string {
1676
- if (parent.hasId && !isNOU(getValue('filterId', itemData))) {
1677
- return getValue('filterId', itemData).replace(/\\/g, '/').replace(/^[^/]+\//, '/');
1678
- }
1679
- else {
1680
- return getValue('filterPath', itemData).replace(/\\/g, '/');
1681
- }
1682
- }
1683
- /**
1684
- * Access control handler
1685
- *
1686
- * @param {IFileManager} parent - specifies the parent.
1687
- * @param {Object[]} itemData - specifies the item elements.
1688
- * @param {string} action - specifies the action.
1689
- * @param {boolean} isPathPermision - specifies the path permission.
1690
- * @returns {string} returns the path.
1691
- * @private
1692
- */
1693
- export function getAccessDetails(parent: IFileManager, itemData: Object[], action: string, isPathPermision: boolean): string {
1694
- let accessMessage: string = '';
1695
- for (let i: number = 0; i < itemData.length; i++){
1696
- let permission: object = getValue('permission', itemData[i as number]);
1697
- if (permission == null) {
1698
- permission = undefined;
1699
- }
1700
- if (isPathPermision) {
1701
- if (permission && (!getValue('read', permission) || !getValue('writeContents', permission))) {
1702
- accessMessage = getValue('message', getValue('permission', itemData[i as number]));
1703
- if (accessMessage === '') {
1704
- accessMessage = getLocaleText(parent, 'Access-Message').replace('{0}', getValue('name', itemData[i as number])).replace('{1}', 'writeContents');
1705
- }
1706
- }
1707
- }
1708
- else {
1709
- const copyOrMovePermission: boolean = action === 'copy' ? getValue('copy', permission) : getValue('write', permission);
1710
- if (permission && (!getValue('read', permission) || !copyOrMovePermission)) {
1711
- accessMessage = getValue('message', getValue('permission', itemData[i as number]));
1712
- if (accessMessage === '') {
1713
- accessMessage = getLocaleText(parent, 'Access-Message').replace('{0}', getValue('name', itemData[i as number])).replace('{1}', action);
1714
- }
1715
- }
1716
- }
1717
- if (accessMessage !== '') {
1718
- parent.responseData = {
1719
- cwd: null,
1720
- details: null,
1721
- error: {
1722
- code: '401',
1723
- message: accessMessage,
1724
- fileExists: null
1725
- },
1726
- files: null
1727
- };
1728
- break;
1729
- }
1730
- }
1731
- return accessMessage;
1732
- }