easy-file-system 1.5.17 → 1.5.19
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/example.js +267 -306
- package/lib/button/name.js +3 -5
- package/lib/example/view.js +4 -4
- package/lib/explorer.js +13 -4
- package/lib/item/entry/drag/directoryName.js +14 -16
- package/lib/item/entry/drag/fileName.js +13 -32
- package/lib/item/entry/drag.js +18 -49
- package/lib/item/entry.js +3 -3
- package/lib/mixins/explorer.js +92 -0
- package/lib/mixins/rubbishBin.js +36 -0
- package/lib/rubbishBin.js +4 -29
- package/lib/styles.js +5 -5
- package/lib/utilities/pathMap.js +14 -14
- package/package.json +1 -1
- package/src/button/name.js +2 -6
- package/src/example/view.js +4 -3
- package/src/explorer.js +17 -7
- package/src/item/entry/drag/directoryName.js +17 -19
- package/src/item/entry/drag/fileName.js +11 -10
- package/src/item/entry/drag.js +27 -67
- package/src/item/entry.js +4 -3
- package/src/mixins/{event.js → explorer.js} +7 -17
- package/src/mixins/rubbishBin.js +42 -0
- package/src/rubbishBin.js +5 -35
- package/src/styles.js +1 -1
- package/src/utilities/pathMap.js +13 -11
- package/lib/mixins/event.js +0 -99
package/lib/utilities/pathMap.js
CHANGED
|
@@ -9,11 +9,11 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
|
|
13
|
-
return
|
|
12
|
+
sourceEntryPathFromEntryItem: function() {
|
|
13
|
+
return sourceEntryPathFromEntryItem;
|
|
14
14
|
},
|
|
15
|
-
|
|
16
|
-
return
|
|
15
|
+
targetEntryPathFromEntryItem: function() {
|
|
16
|
+
return targetEntryPathFromEntryItem;
|
|
17
17
|
},
|
|
18
18
|
adjustSourceEntryPath: function() {
|
|
19
19
|
return adjustSourceEntryPath;
|
|
@@ -24,13 +24,13 @@ _export(exports, {
|
|
|
24
24
|
});
|
|
25
25
|
var _necessary = require("necessary");
|
|
26
26
|
var _constants = require("../constants");
|
|
27
|
-
var pathWithoutBottommostNameFromPath = _necessary.pathUtilities.pathWithoutBottommostNameFromPath;
|
|
28
|
-
function
|
|
29
|
-
var
|
|
27
|
+
var concatenatePaths = _necessary.pathUtilities.concatenatePaths, pathWithoutBottommostNameFromPath = _necessary.pathUtilities.pathWithoutBottommostNameFromPath;
|
|
28
|
+
function sourceEntryPathFromEntryItem(entryItem) {
|
|
29
|
+
var entryItemPath = entryItem.getPath(), entryItemPathWithoutBottommostName = pathWithoutBottommostNameFromPath(entryItemPath), sourceEntryPath = nonNullPathFromName(entryItemPathWithoutBottommostName); ///
|
|
30
30
|
return sourceEntryPath;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
var
|
|
32
|
+
function targetEntryPathFromEntryItem(entryItem) {
|
|
33
|
+
var entryItemPath = entryItem.getPath(), entryItemPathWithoutBottommostName = pathWithoutBottommostNameFromPath(entryItemPath), targetEntryPath = nonNullPathFromName(entryItemPathWithoutBottommostName); ///
|
|
34
34
|
return targetEntryPath;
|
|
35
35
|
}
|
|
36
36
|
function adjustSourceEntryPath(sourceEntryPath, name) {
|
|
@@ -39,19 +39,19 @@ function adjustSourceEntryPath(sourceEntryPath, name) {
|
|
|
39
39
|
} else if (sourceEntryPath === _constants.EMPTY_STRING) {
|
|
40
40
|
sourceEntryPath = name; ///
|
|
41
41
|
} else {
|
|
42
|
-
sourceEntryPath =
|
|
42
|
+
sourceEntryPath = concatenatePaths(sourceEntryPath, name);
|
|
43
43
|
}
|
|
44
44
|
return sourceEntryPath;
|
|
45
45
|
}
|
|
46
|
-
function adjustTargetEntryPath(targetEntryPath,
|
|
46
|
+
function adjustTargetEntryPath(targetEntryPath, nameInputName) {
|
|
47
47
|
if (false) {
|
|
48
48
|
///
|
|
49
49
|
} else if (targetEntryPath === null) {
|
|
50
50
|
targetEntryPath = null;
|
|
51
51
|
} else if (targetEntryPath === _constants.EMPTY_STRING) {
|
|
52
|
-
targetEntryPath =
|
|
52
|
+
targetEntryPath = nameInputName; ///
|
|
53
53
|
} else {
|
|
54
|
-
targetEntryPath =
|
|
54
|
+
targetEntryPath = concatenatePaths(targetEntryPath, nameInputName);
|
|
55
55
|
}
|
|
56
56
|
return targetEntryPath;
|
|
57
57
|
}
|
|
@@ -60,4 +60,4 @@ function nonNullPathFromName(name) {
|
|
|
60
60
|
return path;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
63
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvcGF0aE1hcC5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJcInVzZSBzdHJpY3RcIjtcblxuaW1wb3J0IHsgcGF0aFV0aWxpdGllcyB9IGZyb20gXCJuZWNlc3NhcnlcIjtcblxuaW1wb3J0IHsgRU1QVFlfU1RSSU5HIH0gZnJvbSBcIi4uL2NvbnN0YW50c1wiO1xuXG5jb25zdCB7IGNvbmNhdGVuYXRlUGF0aHMsIHBhdGhXaXRob3V0Qm90dG9tbW9zdE5hbWVGcm9tUGF0aCB9ID0gcGF0aFV0aWxpdGllcztcblxuZXhwb3J0IGZ1bmN0aW9uIHNvdXJjZUVudHJ5UGF0aEZyb21FbnRyeUl0ZW0oZW50cnlJdGVtKSB7XG4gIGNvbnN0IGVudHJ5SXRlbVBhdGggPSBlbnRyeUl0ZW0uZ2V0UGF0aCgpLFxuICAgICAgICBlbnRyeUl0ZW1QYXRoV2l0aG91dEJvdHRvbW1vc3ROYW1lID0gcGF0aFdpdGhvdXRCb3R0b21tb3N0TmFtZUZyb21QYXRoKGVudHJ5SXRlbVBhdGgpLFxuICAgICAgICBzb3VyY2VFbnRyeVBhdGggPSBub25OdWxsUGF0aEZyb21OYW1lKGVudHJ5SXRlbVBhdGhXaXRob3V0Qm90dG9tbW9zdE5hbWUpOyAvLy9cblxuICByZXR1cm4gc291cmNlRW50cnlQYXRoO1xufVx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FBRztJQUN2QyxPQUFPO1FBQ0xILGtCQUFrQlQsaUJBQWlCUyxpQkFBaUJHO0lBQ3RELENBQUM7SUFFRCxPQUFPSDtBQUNUO0FBRUEsU0FBU0Qsb0JBQW9CRSxJQUFJLEVBQUU7SUFDakMsSUFBTUcsT0FBTyxBQUFDSCxTQUFTLElBQUksR0FDWEEsT0FDRUMsdUJBQVk7SUFFOUIsT0FBT0U7QUFDVCJ9
|
package/package.json
CHANGED
package/src/button/name.js
CHANGED
|
@@ -41,15 +41,11 @@ class NameButton extends Button {
|
|
|
41
41
|
|
|
42
42
|
parentContext() {
|
|
43
43
|
const showNameButton = this.show.bind(this), ///
|
|
44
|
-
hideNameButton = this.hide.bind(this)
|
|
45
|
-
getNameButtonName = this.getName.bind(this), ///
|
|
46
|
-
setNameButtonName = this.setName.bind(this); ///
|
|
44
|
+
hideNameButton = this.hide.bind(this); ///
|
|
47
45
|
|
|
48
46
|
return ({
|
|
49
47
|
showNameButton,
|
|
50
|
-
hideNameButton
|
|
51
|
-
getNameButtonName,
|
|
52
|
-
setNameButtonName
|
|
48
|
+
hideNameButton
|
|
53
49
|
});
|
|
54
50
|
}
|
|
55
51
|
|
package/src/example/view.js
CHANGED
|
@@ -16,6 +16,7 @@ export default class View extends Element {
|
|
|
16
16
|
secondExplorer = this.getSecondExplorer();
|
|
17
17
|
|
|
18
18
|
firstExplorer.editSelectedPath();
|
|
19
|
+
|
|
19
20
|
secondExplorer.editSelectedPath();
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -35,10 +36,10 @@ export default class View extends Element {
|
|
|
35
36
|
done();
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
pathChangeHandler = (
|
|
39
|
-
|
|
39
|
+
pathChangeHandler = (pathMaps, done) => {
|
|
40
|
+
console.log("remove", JSON.stringify(pathMaps, null, " "))
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
done();
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
getExplorers() {
|
package/src/explorer.js
CHANGED
|
@@ -5,9 +5,9 @@ import withStyle from "easy-with-style"; ///
|
|
|
5
5
|
import { Element } from "easy";
|
|
6
6
|
import { dropMixins } from "easy-drag-and-drop";
|
|
7
7
|
|
|
8
|
-
import eventMixins from "./mixins/event";
|
|
9
8
|
import EntriesList from "./list/entries";
|
|
10
9
|
import DragEntryItem from "./item/entry/drag";
|
|
10
|
+
import explorerMixins from "./mixins/explorer";
|
|
11
11
|
import FileNameDragEntryItem from "./item/entry/drag/fileName";
|
|
12
12
|
import FileNameMarkerEntryItem from "./item/entry/marker/fileName";
|
|
13
13
|
import DirectoryNameDragEntryItem from "./item/entry/drag/directoryName";
|
|
@@ -15,7 +15,7 @@ import DirectoryNameMarkerEntryItem from "./item/entry/marker/directoryName";
|
|
|
15
15
|
|
|
16
16
|
import { explorerPadding } from "./styles";
|
|
17
17
|
import { FILE_NAME_DRAG_ENTRY_TYPE, DIRECTORY_NAME_DRAG_ENTRY_TYPE } from "./entryTypes";
|
|
18
|
-
import {
|
|
18
|
+
import { sourceEntryPathFromEntryItem, targetEntryPathFromEntryItem } from "./utilities/pathMap";
|
|
19
19
|
|
|
20
20
|
class Explorer extends Element {
|
|
21
21
|
constructor(selector, mounted) {
|
|
@@ -213,13 +213,23 @@ class Explorer extends Element {
|
|
|
213
213
|
this.callSelectHandlers(path, selected);
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
renameDragEntryItem(dragEntryItem, done) {
|
|
217
|
+
const dragEntryItemExplorer = dragEntryItem.getExplorer(),
|
|
218
|
+
sourceEntryPath = sourceEntryPathFromEntryItem(dragEntryItem),
|
|
219
|
+
targetEntryPath = targetEntryPathFromEntryItem(dragEntryItem),
|
|
220
|
+
pathMaps = dragEntryItem.getPathMaps(sourceEntryPath, targetEntryPath),
|
|
221
|
+
explorer = dragEntryItemExplorer; ///
|
|
222
|
+
|
|
223
|
+
this.moveDragEntryItems(pathMaps, explorer, () => {
|
|
224
|
+
done();
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
216
228
|
dropDragEntryItem(dragEntryItem, done) {
|
|
217
229
|
const markerEntryItem = this.retrieveMarkerEntryItem(),
|
|
218
|
-
dragEntryItemPath = dragEntryItem.getPath(),
|
|
219
|
-
markerEntryItemPath = markerEntryItem.getPath(),
|
|
220
230
|
dragEntryItemExplorer = dragEntryItem.getExplorer(),
|
|
221
|
-
sourceEntryPath =
|
|
222
|
-
targetEntryPath =
|
|
231
|
+
sourceEntryPath = sourceEntryPathFromEntryItem(dragEntryItem),
|
|
232
|
+
targetEntryPath = targetEntryPathFromEntryItem(markerEntryItem),
|
|
223
233
|
pathMaps = dragEntryItem.getPathMaps(sourceEntryPath, targetEntryPath),
|
|
224
234
|
explorer = dragEntryItemExplorer; ///
|
|
225
235
|
|
|
@@ -415,7 +425,7 @@ class Explorer extends Element {
|
|
|
415
425
|
}
|
|
416
426
|
|
|
417
427
|
Object.assign(Explorer.prototype, dropMixins);
|
|
418
|
-
Object.assign(Explorer.prototype,
|
|
428
|
+
Object.assign(Explorer.prototype, explorerMixins);
|
|
419
429
|
|
|
420
430
|
export default withStyle(Explorer)`
|
|
421
431
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { dropMixins } from "easy-drag-and-drop";
|
|
4
|
+
import { pathUtilities } from "necessary";
|
|
4
5
|
|
|
5
6
|
import ToggleButton from "../../../button/toggle";
|
|
6
7
|
import DragEntryItem from "../../../item/entry/drag";
|
|
@@ -10,6 +11,8 @@ import DirectoryNameEntryItemDiv from "../../../div/item/entry/directoryName";
|
|
|
10
11
|
import { adjustSourceEntryPath, adjustTargetEntryPath } from "../../../utilities/pathMap";
|
|
11
12
|
import { FILE_NAME_DRAG_ENTRY_TYPE, FILE_NAME_MARKER_ENTRY_TYPE, DIRECTORY_NAME_DRAG_ENTRY_TYPE, DIRECTORY_NAME_MARKER_ENTRY_TYPE } from "../../../entryTypes";
|
|
12
13
|
|
|
14
|
+
const { concatenatePaths } = pathUtilities;
|
|
15
|
+
|
|
13
16
|
export default class DirectoryNameDragEntryItem extends DragEntryItem {
|
|
14
17
|
dropHandler = (dragElement, aborted, element, done) => {
|
|
15
18
|
const dragElementDragEntryItem = (dragElement instanceof DragEntryItem);
|
|
@@ -66,7 +69,7 @@ export default class DirectoryNameDragEntryItem extends DragEntryItem {
|
|
|
66
69
|
previousMarkerEntryItemPath = markerEntryItemPath, ///
|
|
67
70
|
previousMarkerEntryItemExplorer = markerEntryItemExplorer; ///
|
|
68
71
|
|
|
69
|
-
markerEntryItemPath =
|
|
72
|
+
markerEntryItemPath = concatenatePaths(path, dragEntryItemName);
|
|
70
73
|
|
|
71
74
|
markerEntryItemExplorer = explorer; ///
|
|
72
75
|
|
|
@@ -104,19 +107,6 @@ export default class DirectoryNameDragEntryItem extends DragEntryItem {
|
|
|
104
107
|
return before;
|
|
105
108
|
}
|
|
106
109
|
|
|
107
|
-
getPathMap(sourceEntryPath, targetEntryPath) {
|
|
108
|
-
const pathMap = super.getPathMap(sourceEntryPath, targetEntryPath),
|
|
109
|
-
collapsed = this.isCollapsed(),
|
|
110
|
-
entryDirectory = true;
|
|
111
|
-
|
|
112
|
-
Object.assign(pathMap, {
|
|
113
|
-
collapsed,
|
|
114
|
-
entryDirectory
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
return pathMap;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
110
|
isCollapsed() {
|
|
121
111
|
const entriesListCollapsed = this.isEntriesListCollapsed(),
|
|
122
112
|
collapsed = entriesListCollapsed; ///
|
|
@@ -124,14 +114,22 @@ export default class DirectoryNameDragEntryItem extends DragEntryItem {
|
|
|
124
114
|
return collapsed;
|
|
125
115
|
}
|
|
126
116
|
|
|
117
|
+
isEntryDirectory() {
|
|
118
|
+
const entryDirectory = true;
|
|
119
|
+
|
|
120
|
+
return entryDirectory;
|
|
121
|
+
}
|
|
122
|
+
|
|
127
123
|
retrievePathMaps(sourceEntryPath, targetEntryPath, pathMaps) {
|
|
128
124
|
const name = this.getName(),
|
|
129
|
-
pathMap = this.getPathMap(sourceEntryPath, targetEntryPath)
|
|
125
|
+
pathMap = this.getPathMap(sourceEntryPath, targetEntryPath),
|
|
126
|
+
nameInputName = this.getNameInputName();
|
|
130
127
|
|
|
131
128
|
pathMaps.push(pathMap);
|
|
132
129
|
|
|
133
130
|
sourceEntryPath = adjustSourceEntryPath(sourceEntryPath, name);
|
|
134
|
-
|
|
131
|
+
|
|
132
|
+
targetEntryPath = adjustTargetEntryPath(targetEntryPath, nameInputName);
|
|
135
133
|
|
|
136
134
|
this.forEachDragEntryItem((dragEntryItem) => {
|
|
137
135
|
dragEntryItem.retrievePathMaps(sourceEntryPath, targetEntryPath, pathMaps);
|
|
@@ -209,11 +207,11 @@ export default class DirectoryNameDragEntryItem extends DragEntryItem {
|
|
|
209
207
|
]);
|
|
210
208
|
}
|
|
211
209
|
|
|
212
|
-
|
|
210
|
+
static type = DIRECTORY_NAME_DRAG_ENTRY_TYPE;
|
|
213
211
|
|
|
214
|
-
|
|
212
|
+
static ToggleButton = ToggleButton;
|
|
215
213
|
|
|
216
|
-
static
|
|
214
|
+
static DirectoryNameSVG = DirectoryNameSVG;
|
|
217
215
|
|
|
218
216
|
static defaultProperties = {
|
|
219
217
|
className: "directory-name"
|
|
@@ -40,16 +40,17 @@ export default class FileNameDragEntryItem extends DragEntryItem {
|
|
|
40
40
|
return fileName;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
entryDirectory = false;
|
|
43
|
+
isCollapsed() {
|
|
44
|
+
const collapsed = null; ///
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
46
|
+
return collapsed;
|
|
47
|
+
}
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
isEntryDirectory() {
|
|
50
|
+
const entryDirectory = false;
|
|
51
|
+
|
|
52
|
+
return entryDirectory;
|
|
53
|
+
}
|
|
53
54
|
|
|
54
55
|
retrievePathMaps(sourceEntryPath, targetEntryPath, pathMaps) {
|
|
55
56
|
const pathMap = this.getPathMap(sourceEntryPath, targetEntryPath);
|
|
@@ -76,10 +77,10 @@ export default class FileNameDragEntryItem extends DragEntryItem {
|
|
|
76
77
|
);
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
static FileNameSVG = FileNameSVG;
|
|
80
|
-
|
|
81
80
|
static type = FILE_NAME_DRAG_ENTRY_TYPE;
|
|
82
81
|
|
|
82
|
+
static FileNameSVG = FileNameSVG;
|
|
83
|
+
|
|
83
84
|
static defaultProperties = {
|
|
84
85
|
className: "file-name"
|
|
85
86
|
};
|
package/src/item/entry/drag.js
CHANGED
|
@@ -32,14 +32,11 @@ class DragEntryItem extends EntryItem {
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
success ?
|
|
41
|
-
this.update() :
|
|
42
|
-
this.cancel();
|
|
35
|
+
const explorer = this.getExplorer(),
|
|
36
|
+
dragEntryItem = this; ///
|
|
37
|
+
|
|
38
|
+
explorer.renameDragEntryItem(dragEntryItem, () => {
|
|
39
|
+
this.cancel();
|
|
43
40
|
});
|
|
44
41
|
}
|
|
45
42
|
|
|
@@ -80,56 +77,37 @@ class DragEntryItem extends EntryItem {
|
|
|
80
77
|
markerEntryItemExplorer.dropDragEntryItem(dragEntryItem, done);
|
|
81
78
|
}
|
|
82
79
|
|
|
83
|
-
|
|
84
|
-
const nameButtonName = this.getNameButtonName(),
|
|
85
|
-
name = nameButtonName; ///
|
|
86
|
-
|
|
87
|
-
return name;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
getOldName() {
|
|
91
|
-
const nameButtonName = this.getNameButtonName(),
|
|
92
|
-
oldName = nameButtonName; ///
|
|
93
|
-
|
|
94
|
-
return oldName;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
getNewName() {
|
|
80
|
+
getInputName() {
|
|
98
81
|
const nameInputName = this.getNameInputName(),
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return oldName;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
getOldPath() {
|
|
105
|
-
const path = this.getPath(),
|
|
106
|
-
oldName = this.getOldName(),
|
|
107
|
-
pathWithoutBottommostName = pathWithoutBottommostNameFromPath(path),
|
|
108
|
-
oldPath = (pathWithoutBottommostName === null) ?
|
|
109
|
-
oldName :
|
|
110
|
-
concatenatePaths(pathWithoutBottommostName, oldName);
|
|
82
|
+
inputName = nameInputName; ///
|
|
111
83
|
|
|
112
|
-
return
|
|
84
|
+
return inputName;
|
|
113
85
|
}
|
|
114
86
|
|
|
115
|
-
|
|
87
|
+
getInputPath() {
|
|
116
88
|
const path = this.getPath(),
|
|
117
|
-
|
|
89
|
+
inputName = this.getInputName(),
|
|
118
90
|
pathWithoutBottommostName = pathWithoutBottommostNameFromPath(path),
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
91
|
+
inputPath = (pathWithoutBottommostName === null) ?
|
|
92
|
+
inputName :
|
|
93
|
+
concatenatePaths(pathWithoutBottommostName, inputName);
|
|
122
94
|
|
|
123
|
-
return
|
|
95
|
+
return inputPath;
|
|
124
96
|
}
|
|
125
97
|
|
|
126
98
|
getPathMap(sourceEntryPath, targetEntryPath) {
|
|
127
|
-
const name = this.getName()
|
|
99
|
+
const name = this.getName(),
|
|
100
|
+
collapsed = this.isCollapsed(),
|
|
101
|
+
nameInputName = this.getNameInputName(),
|
|
102
|
+
entryDirectory = this.isEntryDirectory();
|
|
128
103
|
|
|
129
104
|
sourceEntryPath = adjustSourceEntryPath(sourceEntryPath, name); ///
|
|
130
|
-
|
|
105
|
+
|
|
106
|
+
targetEntryPath = adjustTargetEntryPath(targetEntryPath, nameInputName); ///
|
|
131
107
|
|
|
132
108
|
const pathMap = {
|
|
109
|
+
collapsed,
|
|
110
|
+
entryDirectory,
|
|
133
111
|
sourceEntryPath,
|
|
134
112
|
targetEntryPath
|
|
135
113
|
};
|
|
@@ -148,9 +126,9 @@ class DragEntryItem extends EntryItem {
|
|
|
148
126
|
}
|
|
149
127
|
|
|
150
128
|
hasNameChanged() {
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
nameChanged = (
|
|
129
|
+
const name = this.getName(),
|
|
130
|
+
inputName = this.getInputName(),
|
|
131
|
+
nameChanged = (inputName !== name);
|
|
154
132
|
|
|
155
133
|
return nameChanged;
|
|
156
134
|
}
|
|
@@ -181,8 +159,8 @@ class DragEntryItem extends EntryItem {
|
|
|
181
159
|
}
|
|
182
160
|
|
|
183
161
|
cancel() {
|
|
184
|
-
const
|
|
185
|
-
nameInputName =
|
|
162
|
+
const name = this.getName(),
|
|
163
|
+
nameInputName = name; ///
|
|
186
164
|
|
|
187
165
|
this.setNameInputName(nameInputName);
|
|
188
166
|
|
|
@@ -190,24 +168,6 @@ class DragEntryItem extends EntryItem {
|
|
|
190
168
|
this.hideNameInput();
|
|
191
169
|
}
|
|
192
170
|
|
|
193
|
-
update() {
|
|
194
|
-
const nameInputName = this.getNameInputName(),
|
|
195
|
-
nameButtonName = nameInputName; ///
|
|
196
|
-
|
|
197
|
-
this.setNameButtonName(nameButtonName);
|
|
198
|
-
|
|
199
|
-
this.showNameButton();
|
|
200
|
-
this.hideNameInput();
|
|
201
|
-
|
|
202
|
-
const parentElement = this.getParentElement(),
|
|
203
|
-
entriesList = parentElement, ///
|
|
204
|
-
entryItem = this; ///
|
|
205
|
-
|
|
206
|
-
entriesList.removeEntryItem(entryItem);
|
|
207
|
-
|
|
208
|
-
entriesList.addEntryItem(entryItem);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
171
|
didMount() {
|
|
212
172
|
this.hideNameInput();
|
|
213
173
|
|
package/src/item/entry.js
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import withStyle from "easy-with-style"; ///
|
|
4
4
|
|
|
5
|
-
import { arrayUtilities } from "necessary";
|
|
5
|
+
import { pathUtilities, arrayUtilities } from "necessary";
|
|
6
6
|
|
|
7
7
|
import { Element } from "easy";
|
|
8
8
|
|
|
9
|
-
const { first } = arrayUtilities
|
|
9
|
+
const { first } = arrayUtilities,
|
|
10
|
+
{ concatenatePaths } = pathUtilities;
|
|
10
11
|
|
|
11
12
|
class EntryItem extends Element {
|
|
12
13
|
getParentDirectoryNameDragEntryItem() {
|
|
@@ -36,7 +37,7 @@ class EntryItem extends Element {
|
|
|
36
37
|
} else {
|
|
37
38
|
const parentDirectoryNameDragEntryItemPath = parentDirectoryNameDragEntryItem.getPath();
|
|
38
39
|
|
|
39
|
-
path =
|
|
40
|
+
path = concatenatePaths(parentDirectoryNameDragEntryItemPath, name);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
return path;
|
|
@@ -92,33 +92,23 @@ function callMoveHandlersAsync(pathMaps, done) {
|
|
|
92
92
|
|
|
93
93
|
forEach(eventListeners, (eventListener, next) => {
|
|
94
94
|
const { handler, element } = eventListener,
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
moveHandler = handler, ///
|
|
96
|
+
done = next; ///
|
|
97
97
|
|
|
98
98
|
moveHandler.call(element, pathMaps, done);
|
|
99
99
|
}, done);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
function callPathChangeHandlersAsync(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const done = () => {
|
|
106
|
-
const success = !notSuccess;
|
|
107
|
-
|
|
108
|
-
callback(success);
|
|
109
|
-
},
|
|
110
|
-
eventType = PATH_CHANGE_EVENT_TYPE,
|
|
102
|
+
function callPathChangeHandlersAsync(pathMap, done) {
|
|
103
|
+
const eventType = PATH_CHANGE_EVENT_TYPE,
|
|
111
104
|
eventListeners = this.findEventListeners(eventType);
|
|
112
105
|
|
|
113
106
|
forEach(eventListeners, (eventListener, next) => {
|
|
114
107
|
const { handler, element } = eventListener,
|
|
115
|
-
pathChangeHandler = handler
|
|
116
|
-
|
|
117
|
-
pathChangeHandler.call(element, oldPath, newPath, (success) => {
|
|
118
|
-
notSuccess = !success;
|
|
108
|
+
pathChangeHandler = handler, ///
|
|
109
|
+
done = next; ///
|
|
119
110
|
|
|
120
|
-
|
|
121
|
-
});
|
|
111
|
+
pathChangeHandler.call(element, pathMap, done);
|
|
122
112
|
}, done);
|
|
123
113
|
}
|
|
124
114
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { asynchronousUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
import { REMOVE_EVENT_TYPE } from "../eventTypes";
|
|
6
|
+
|
|
7
|
+
const { forEach } = asynchronousUtilities;
|
|
8
|
+
|
|
9
|
+
function onRemove(removeHandler, element) {
|
|
10
|
+
const eventType = REMOVE_EVENT_TYPE,
|
|
11
|
+
handler = removeHandler; ///
|
|
12
|
+
|
|
13
|
+
this.addEventListener(eventType, handler, element);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function offRemove(removeHandler, element) {
|
|
17
|
+
const eventType = REMOVE_EVENT_TYPE,
|
|
18
|
+
handler = removeHandler; ///
|
|
19
|
+
|
|
20
|
+
this.removeEventListener(eventType, handler, element);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function callRemoveHandlersAsync(pathMaps, done) {
|
|
24
|
+
const eventType = REMOVE_EVENT_TYPE,
|
|
25
|
+
eventListeners = this.findEventListeners(eventType);
|
|
26
|
+
|
|
27
|
+
forEach(eventListeners, (eventListener, next) => {
|
|
28
|
+
const { handler, element } = eventListener,
|
|
29
|
+
removeHandler = handler, ///
|
|
30
|
+
done = next; ///
|
|
31
|
+
|
|
32
|
+
removeHandler.call(element, pathMaps, done);
|
|
33
|
+
}, done);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const rubbishBinMixins = {
|
|
37
|
+
onRemove,
|
|
38
|
+
offRemove,
|
|
39
|
+
callRemoveHandlersAsync
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default rubbishBinMixins;
|
package/src/rubbishBin.js
CHANGED
|
@@ -4,21 +4,18 @@ import withStyle from "easy-with-style"; ///
|
|
|
4
4
|
|
|
5
5
|
import { Element } from "easy";
|
|
6
6
|
import { dropMixins } from "easy-drag-and-drop";
|
|
7
|
-
import { asynchronousUtilities } from "necessary";
|
|
8
7
|
|
|
9
8
|
import DragEntryItem from "./item/entry/drag";
|
|
9
|
+
import rubbishBinMixins from "./mixins/rubbishBin";
|
|
10
10
|
import OpenRubbishBinSVG from "./svg/rubbishBin/open";
|
|
11
11
|
import ClosedRubbishBinSVG from "./svg/rubbishBin/closed";
|
|
12
12
|
import FileNameMarkerEntryItem from "./item/entry/marker/fileName";
|
|
13
13
|
import DirectoryNameMarkerEntryItem from "./item/entry/marker/directoryName";
|
|
14
14
|
|
|
15
|
-
import { REMOVE_EVENT_TYPE } from "./eventTypes";
|
|
16
15
|
import { nonNullPathFromName } from "./utilities/pathMap";
|
|
17
|
-
import {
|
|
16
|
+
import { sourceEntryPathFromEntryItem } from "./utilities/pathMap";
|
|
18
17
|
import { DIRECTORY_NAME_DRAG_ENTRY_TYPE, FILE_NAME_DRAG_ENTRY_TYPE } from "./entryTypes";
|
|
19
18
|
|
|
20
|
-
const { forEach } = asynchronousUtilities;
|
|
21
|
-
|
|
22
19
|
class RubbishBin extends Element {
|
|
23
20
|
dropHandler = (dragElement, aborted, element, done) => {
|
|
24
21
|
const dragElementDragEntryItem = (dragElement instanceof DragEntryItem);
|
|
@@ -161,24 +158,9 @@ class RubbishBin extends Element {
|
|
|
161
158
|
});
|
|
162
159
|
}
|
|
163
160
|
|
|
164
|
-
onRemove(removeHandler, element) {
|
|
165
|
-
const eventType = REMOVE_EVENT_TYPE,
|
|
166
|
-
handler = removeHandler; ///
|
|
167
|
-
|
|
168
|
-
this.addEventListener(eventType, handler, element);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
offRemove(removeHandler, element) {
|
|
172
|
-
const eventType = REMOVE_EVENT_TYPE,
|
|
173
|
-
handler = removeHandler; ///
|
|
174
|
-
|
|
175
|
-
this.removeEventListener(eventType, handler, element);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
161
|
dropDragEntryItem(dragEntryItem, done) {
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
sourceEntryPath = sourceEntryPathFromDragEntryItemPath(dragEntryItemPath),
|
|
162
|
+
const dragEntryItemExplorer = dragEntryItem.getExplorer(),
|
|
163
|
+
sourceEntryPath = sourceEntryPathFromEntryItem(dragEntryItem),
|
|
182
164
|
targetEntryPath = null,
|
|
183
165
|
pathMaps = dragEntryItem.getPathMaps(sourceEntryPath, targetEntryPath),
|
|
184
166
|
explorer = dragEntryItemExplorer; ///
|
|
@@ -230,19 +212,6 @@ class RubbishBin extends Element {
|
|
|
230
212
|
explorer.removeDirectoryPath(directoryPath);
|
|
231
213
|
}
|
|
232
214
|
|
|
233
|
-
callRemoveHandlersAsync(pathMaps, done) {
|
|
234
|
-
const eventType = REMOVE_EVENT_TYPE,
|
|
235
|
-
eventListeners = this.findEventListeners(eventType);
|
|
236
|
-
|
|
237
|
-
forEach(eventListeners, (eventListener, next) => {
|
|
238
|
-
const { handler, element } = eventListener,
|
|
239
|
-
removeHandler = handler, ///
|
|
240
|
-
done = next; ///
|
|
241
|
-
|
|
242
|
-
removeHandler.call(element, pathMaps, done);
|
|
243
|
-
}, done);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
215
|
open() {
|
|
247
216
|
this.showOpenRubbishBinSVG();
|
|
248
217
|
this.hideClosedRubbishBinSVG();
|
|
@@ -347,6 +316,7 @@ class RubbishBin extends Element {
|
|
|
347
316
|
}
|
|
348
317
|
|
|
349
318
|
Object.assign(RubbishBin.prototype, dropMixins);
|
|
319
|
+
Object.assign(RubbishBin.prototype, rubbishBinMixins);
|
|
350
320
|
|
|
351
321
|
export default withStyle(RubbishBin)`
|
|
352
322
|
|
package/src/styles.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
export const markerSVGHeight = "2rem";
|
|
4
3
|
export const explorerPadding = "2rem";
|
|
4
|
+
export const markerSVGHeight = "2rem";
|
|
5
5
|
export const toggleSVGHeight = "2rem";
|
|
6
6
|
export const fileNameSVGHeight = "2rem";
|
|
7
7
|
export const rubbishBinSVGHeight = "4rem";
|