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