easy-file-system 2.1.98 → 2.1.101

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/src/explorer.js CHANGED
@@ -4,7 +4,7 @@ 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 { pathUtilities, arrayUtilities } from "necessary";
7
+ import { pathUtilities } from "necessary";
8
8
 
9
9
  import EntriesList from "./list/entries";
10
10
  import DragEntryItem from "./item/entry/drag";
@@ -20,8 +20,7 @@ import { explorerPadding } from "./styles";
20
20
  import { FILE_NAME_DRAG_ENTRY_TYPE, DIRECTORY_NAME_DRAG_ENTRY_TYPE } from "./entryTypes";
21
21
  import { sourceEntryPathFromEntryItem, targetEntryPathFromEntryItem } from "./utilities/pathMap";
22
22
 
23
- const { last } = arrayUtilities,
24
- { concatenatePaths, pathWithoutBottommostNameFromPath } = pathUtilities;
23
+ const { concatenatePaths, pathWithoutBottommostNameFromPath } = pathUtilities;
25
24
 
26
25
  class Explorer extends Element {
27
26
  dragOverHandler = (dragElement, element) => {
@@ -176,14 +175,6 @@ class Explorer extends Element {
176
175
  return directoryPaths;
177
176
  }
178
177
 
179
- openFileNameDragEntryItem(fileNameDragEntryItem) {
180
- const fileNameDragEntryItemPath = fileNameDragEntryItem.getPath(),
181
- filePath = fileNameDragEntryItemPath, ///
182
- explorer = fileNameDragEntryItem.getExplorer();
183
-
184
- this.callOpenHandlers(filePath, explorer);
185
- }
186
-
187
178
  collapse() {
188
179
  const directoryNameDragEntryItems = this.retrieveDirectoryNameDragEntryItems();
189
180
 
@@ -262,32 +253,45 @@ class Explorer extends Element {
262
253
  return selectedPath;
263
254
  }
264
255
 
265
- selectDragEntryItem(dragEntryItem, callHandlers = true) {
266
- const path = dragEntryItem.getPath();
256
+ openFileNameDragEntryItem(fileNameDragEntryItem) {
257
+ const disabled = this.isDisabled();
258
+
259
+ if (disabled) {
260
+ return;
261
+ }
267
262
 
268
- this.deselectAllPaths();
263
+ const fileNameDragEntryItemPath = fileNameDragEntryItem.getPath(),
264
+ filePath = fileNameDragEntryItemPath, ///
265
+ explorer = fileNameDragEntryItem.getExplorer();
269
266
 
270
- this.selectPath(path);
267
+ this.callOpenHandlers(filePath, explorer);
268
+ }
271
269
 
272
- if (callHandlers) {
273
- const selected = true,
274
- readOnly = dragEntryItem.isReadOnly(),
275
- explorer = dragEntryItem.getExplorer();
270
+ selectOrDeselectDragEntryItem(dragEntryItem) {
271
+ const disabled = this.isDisabled();
276
272
 
277
- this.callSelectHandlers(path, selected, readOnly, explorer);
273
+ if (disabled) {
274
+ return;
278
275
  }
279
- }
280
276
 
281
- deselectDragEntryItem(dragEntryItem, callHandlers = true) {
282
- const path = null;
277
+ let selected = dragEntryItem.isSelected();
278
+
279
+ const path = dragEntryItem.getPath();
283
280
 
284
- if (callHandlers) {
285
- const selected = false,
286
- readOnly = dragEntryItem.isReadOnly(),
287
- explorer = dragEntryItem.getExplorer();
281
+ if (selected) {
282
+ dragEntryItem.deselect();
283
+ } else {
284
+ this.deselectAllPaths();
288
285
 
289
- this.callSelectHandlers(path, selected, readOnly, explorer);
286
+ this.selectPath(path);
290
287
  }
288
+
289
+ selected = !selected; ///
290
+
291
+ const readOnly = dragEntryItem.isReadOnly(),
292
+ explorer = dragEntryItem.getExplorer();
293
+
294
+ this.callSelectHandlers(path, selected, readOnly, explorer);
291
295
  }
292
296
 
293
297
  editDragEntryItem(dragEntryItem, done) {
@@ -321,16 +325,8 @@ class Explorer extends Element {
321
325
  explorer = dragEntryItemExplorer; ///
322
326
 
323
327
  this.moveDragEntryItems(pathMaps, explorer, () => {
324
- const lastPathMap = last(pathMaps),
325
- { targetEntryPath } = lastPathMap,
326
- path = targetEntryPath;
327
-
328
328
  this.removeMarker();
329
329
 
330
- if (path !== null) {
331
- this.selectPath(path);
332
- }
333
-
334
330
  done();
335
331
  });
336
332
  }
@@ -391,6 +387,22 @@ class Explorer extends Element {
391
387
  });
392
388
  }
393
389
 
390
+ enable() {
391
+ const disabled = false;
392
+
393
+ this.setDisabled(disabled);
394
+
395
+ this.enableDrag();
396
+ }
397
+
398
+ disable() {
399
+ const disabled = true;
400
+
401
+ this.setDisabled(disabled);
402
+
403
+ this.disableDrag();
404
+ }
405
+
394
406
  enableDrag() {
395
407
  const dragEntryItems = this.retrieveDragEntryItems();
396
408
 
@@ -407,6 +419,26 @@ class Explorer extends Element {
407
419
  });
408
420
  }
409
421
 
422
+ isDisabled() {
423
+ const { disabled } = this.getState();
424
+
425
+ return disabled;
426
+ }
427
+
428
+ setDisabled(disabled) {
429
+ this.updateState({
430
+ disabled
431
+ });
432
+ }
433
+
434
+ setInitialState() {
435
+ const disabled = false;
436
+
437
+ this.setState({
438
+ disabled
439
+ });
440
+ }
441
+
410
442
  didMount() {
411
443
  const { onMove, onOpen, onSelect } = this.properties,
412
444
  moveHandler = onMove, ///
@@ -477,6 +509,8 @@ class Explorer extends Element {
477
509
 
478
510
  initialise() {
479
511
  this.assignContext();
512
+
513
+ this.setInitialState();
480
514
  }
481
515
 
482
516
  static EntriesList = EntriesList;
@@ -183,7 +183,7 @@ class DragEntryItem extends EntryItem {
183
183
 
184
184
  this.editNameSpan();
185
185
 
186
- explorer.disableDrag();
186
+ explorer.disable();
187
187
  }
188
188
 
189
189
  edit() {
@@ -198,7 +198,7 @@ class DragEntryItem extends EntryItem {
198
198
 
199
199
  this.editNameSpan();
200
200
 
201
- explorer.disableDrag();
201
+ explorer.disable();
202
202
  }
203
203
 
204
204
  reset() {
@@ -209,7 +209,7 @@ class DragEntryItem extends EntryItem {
209
209
 
210
210
  this.setCreated(created);
211
211
 
212
- explorer.enableDrag();
212
+ explorer.enable();
213
213
  }
214
214
 
215
215
  cancel() {
package/src/rubbishBin.js CHANGED
@@ -268,6 +268,16 @@ class RubbishBin extends Element {
268
268
  });
269
269
  }
270
270
 
271
+ setInitialState() {
272
+ const markerEntryItemPath = null,
273
+ markerEntryItemExplorer = null;
274
+
275
+ this.setState({
276
+ markerEntryItemPath,
277
+ markerEntryItemExplorer
278
+ });
279
+ }
280
+
271
281
  childElements() {
272
282
  const { OpenRubbishBinSVG, ClosedRubbishBinSVG } = this.constructor;
273
283
 
@@ -280,15 +290,9 @@ class RubbishBin extends Element {
280
290
  }
281
291
 
282
292
  initialise() {
283
- const markerEntryItemPath = null,
284
- markerEntryItemExplorer = null;
285
-
286
293
  this.assignContext();
287
294
 
288
- this.setState({
289
- markerEntryItemPath,
290
- markerEntryItemExplorer
291
- });
295
+ this.setInitialState();
292
296
  }
293
297
 
294
298
  static OpenRubbishBinSVG = OpenRubbishBinSVG;