@syncfusion/ej2-filemanager 19.4.38 → 19.4.48

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.
@@ -1,4 +1,4 @@
1
- import { Ajax, Browser, ChildProperty, Complex, Component, Draggable, Event, EventHandler, Internationalization, KeyboardEvents, L10n, NotifyPropertyChanges, Property, Touch, addClass, closest, createElement, detach, extend, formatUnit, getValue, isNullOrUndefined, isVisible, matches, remove, removeClass, select, selectAll, setStyleAttribute, setValue } from '@syncfusion/ej2-base';
1
+ import { Ajax, Browser, ChildProperty, Complex, Component, Draggable, Event, EventHandler, Internationalization, KeyboardEvents, L10n, NotifyPropertyChanges, Property, Touch, addClass, closest, createElement, detach, extend, formatUnit, getUniqueID, getValue, isNullOrUndefined, isVisible, matches, remove, removeClass, select, selectAll, setStyleAttribute, setValue } from '@syncfusion/ej2-base';
2
2
  import { Splitter } from '@syncfusion/ej2-layouts';
3
3
  import { Dialog, createSpinner, hideSpinner, showSpinner } from '@syncfusion/ej2-popups';
4
4
  import { DataManager, Query } from '@syncfusion/ej2-data';
@@ -875,7 +875,13 @@ function searchWordHandler(parent, value, isLayoutChange) {
875
875
  }
876
876
  else {
877
877
  if (!parent.isFiltered) {
878
- read(parent, isLayoutChange ? layoutChange : search, parent.path);
878
+ if (parent.isSortByClicked) {
879
+ parent.notify(layoutChange, { files: parent.largeiconsviewModule.items });
880
+ parent.isSortByClicked = false;
881
+ }
882
+ else {
883
+ read(parent, isLayoutChange ? layoutChange : search, parent.path);
884
+ }
879
885
  }
880
886
  else {
881
887
  filter(parent, layoutChange);
@@ -1056,7 +1062,7 @@ function fileType(file) {
1056
1062
  function getImageUrl(parent, item) {
1057
1063
  const baseUrl = parent.ajaxSettings.getImageUrl ? parent.ajaxSettings.getImageUrl : parent.ajaxSettings.url;
1058
1064
  let imgUrl;
1059
- const fileName = getValue('name', item);
1065
+ const fileName = encodeURIComponent(getValue('name', item));
1060
1066
  const fPath = getValue('filterPath', item);
1061
1067
  if (parent.hasId) {
1062
1068
  const imgId = getValue('id', item);
@@ -1286,6 +1292,7 @@ function getCssClass(parent, css) {
1286
1292
  */
1287
1293
  function sortbyClickHandler(parent, args) {
1288
1294
  let tick;
1295
+ parent.isSortByClicked = true;
1289
1296
  if (args.item.id.indexOf('ascending') !== -1 || args.item.id.indexOf('descending') !== -1 || args.item.id.indexOf('none') !== -1) {
1290
1297
  tick = true;
1291
1298
  }
@@ -5701,14 +5708,11 @@ class ContextMenu$2 {
5701
5708
  let data;
5702
5709
  let treeFolder = false;
5703
5710
  let target = args.event.target;
5704
- this.menuTarget = target;
5711
+ this.menuTarget = this.targetNodeElement = target;
5705
5712
  this.currentElement = args.element;
5706
5713
  if (target.classList.contains('e-spinner-pane')) {
5707
5714
  target = this.parent.navigationpaneModule.activeNode.getElementsByClassName(FULLROW)[0];
5708
- this.menuTarget = target;
5709
- }
5710
- if (target.classList.contains(FULLROW)) {
5711
- this.parent.selectedItems.length = 0;
5715
+ this.menuTarget = this.targetNodeElement = target;
5712
5716
  }
5713
5717
  this.targetElement = this.parent.view === 'Details' ? closest(target, 'tr.e-row') : target;
5714
5718
  const view = this.getTargetView(target);
@@ -5819,7 +5823,7 @@ class ContextMenu$2 {
5819
5823
  this.enableItems(this.disabledItems, false, true);
5820
5824
  args.cancel = menuOpenArgs.cancel;
5821
5825
  if (menuOpenArgs.cancel) {
5822
- this.menuTarget = this.currentElement = null;
5826
+ this.menuTarget = this.targetNodeElement = this.currentElement = null;
5823
5827
  }
5824
5828
  });
5825
5829
  }
@@ -5938,7 +5942,12 @@ class ContextMenu$2 {
5938
5942
  }
5939
5943
  else {
5940
5944
  this.parent.notify(selectedData, {});
5941
- details = this.parent.itemData;
5945
+ if (this.parent.activeModule === 'navigationpane' && itemText === 'open') {
5946
+ details = [this.menuItemData];
5947
+ }
5948
+ else {
5949
+ details = this.parent.itemData;
5950
+ }
5942
5951
  }
5943
5952
  const eventArgs = {
5944
5953
  cancel: false,
@@ -6015,6 +6024,9 @@ class ContextMenu$2 {
6015
6024
  if (this.parent.visitedItem) {
6016
6025
  this.parent.notify(openInit, { target: this.parent.visitedItem });
6017
6026
  }
6027
+ else if (this.parent.activeModule === 'navigationpane') {
6028
+ this.parent.navigationpaneModule.openFileOnContextMenuClick(closest(this.targetNodeElement, 'li'));
6029
+ }
6018
6030
  break;
6019
6031
  case 'details':
6020
6032
  this.parent.notify(detailsInit, {});
@@ -6372,6 +6384,8 @@ let FileManager = FileManager_1 = class FileManager extends Component {
6372
6384
  this.folderPath = '';
6373
6385
  this.isSameAction = false;
6374
6386
  this.isFiltered = false;
6387
+ // Specifies whether the sort by option is clicked or not.
6388
+ this.isSortByClicked = false;
6375
6389
  this.enablePaste = false;
6376
6390
  this.persistData = false;
6377
6391
  this.retryArgs = [];
@@ -6413,6 +6427,9 @@ let FileManager = FileManager_1 = class FileManager extends Component {
6413
6427
  * @returns {void}
6414
6428
  */
6415
6429
  preRender() {
6430
+ if (isNullOrUndefined(this.element.id) || this.element.id === '') {
6431
+ this.element.setAttribute('id', getUniqueID('filemanager'));
6432
+ }
6416
6433
  this.ensurePath();
6417
6434
  this.feParent = [];
6418
6435
  this.feFiles = [];
@@ -8048,6 +8065,12 @@ class NavigationPane {
8048
8065
  this.isRenameParent = false;
8049
8066
  this.isRightClick = false;
8050
8067
  this.renameParent = null;
8068
+ // Specifies the previously selected nodes in the treeview control.
8069
+ this.previousSelected = null;
8070
+ // Specifies whether the nodeClicked event of the treeview control is triggered or not.
8071
+ this.isNodeClickCalled = false;
8072
+ // Specifies whether to restrict node selection in the treeview control.
8073
+ this.restrictSelecting = false;
8051
8074
  this.parent = parent;
8052
8075
  this.addEventListener();
8053
8076
  this.keyConfigs = {
@@ -8087,6 +8110,7 @@ class NavigationPane {
8087
8110
  hasChildren: 'hasChild', iconCss: '_fm_icon', htmlAttributes: '_fm_htmlAttr', tooltip: 'name'
8088
8111
  },
8089
8112
  enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
8113
+ nodeSelecting: this.onNodeSelecting.bind(this),
8090
8114
  nodeSelected: this.onNodeSelected.bind(this),
8091
8115
  nodeExpanding: this.onNodeExpand.bind(this),
8092
8116
  nodeClicked: this.onNodeClicked.bind(this),
@@ -8191,6 +8215,44 @@ class NavigationPane {
8191
8215
  this.treeObj.addNodes(directories, target, null, prevent);
8192
8216
  }
8193
8217
  }
8218
+ // Node Selecting event handler
8219
+ onNodeSelecting(args) {
8220
+ if (!args.isInteracted && !this.isRightClick && !this.isPathDragged && !this.isRenameParent || this.restrictSelecting) {
8221
+ this.restrictSelecting = false;
8222
+ this.isNodeClickCalled = false;
8223
+ return;
8224
+ }
8225
+ if (!this.renameParent) {
8226
+ this.parent.activeModule = 'navigationpane';
8227
+ // eslint-disable-next-line
8228
+ const nodeData = this.getTreeData(getValue('id', args.nodeData));
8229
+ const eventArgs = { cancel: false, fileDetails: nodeData[0], module: 'NavigationPane' };
8230
+ this.parent.trigger('fileOpen', eventArgs);
8231
+ args.cancel = eventArgs.cancel;
8232
+ if (args.cancel) {
8233
+ this.restrictSelecting = this.isNodeClickCalled ? this.previousSelected[0] != args.node.getAttribute('data-uid') : false;
8234
+ this.treeObj.selectedNodes = this.isNodeClickCalled ? this.previousSelected : this.treeObj.selectedNodes;
8235
+ this.previousSelected = this.treeObj.selectedNodes;
8236
+ if (!isNullOrUndefined(this.parent) && !isNullOrUndefined(this.parent.contextmenuModule)) {
8237
+ this.parent.contextmenuModule.contextMenu.enableItems(['Open'], true);
8238
+ }
8239
+ }
8240
+ }
8241
+ }
8242
+ // Opens the folder while clicking open context menu item in the treeview.
8243
+ openFileOnContextMenuClick(node) {
8244
+ const data = this.treeObj.getTreeData(node);
8245
+ // eslint-disable-next-line
8246
+ this.parent.selectedItems = [];
8247
+ this.parent.itemData = data;
8248
+ this.activeNode = node;
8249
+ this.parent.activeModule = 'navigationpane';
8250
+ updatePath(node, this.parent.itemData[0], this.parent);
8251
+ read(this.parent, this.isPathDragged ? pasteEnd : pathChanged, this.parent.path);
8252
+ this.parent.visitedItem = node;
8253
+ this.isPathDragged = this.isRenameParent = this.isRightClick = false;
8254
+ this.treeObj.selectedNodes = [node.getAttribute('data-uid')];
8255
+ }
8194
8256
  onNodeSelected(args) {
8195
8257
  if (this.parent.breadcrumbbarModule && this.parent.breadcrumbbarModule.searchObj && !this.renameParent) {
8196
8258
  this.parent.breadcrumbbarModule.searchObj.element.value = '';
@@ -8204,11 +8266,6 @@ class NavigationPane {
8204
8266
  this.parent.activeModule = 'navigationpane';
8205
8267
  // eslint-disable-next-line
8206
8268
  const nodeData = this.getTreeData(getValue('id', args.nodeData));
8207
- if (!this.renameParent) {
8208
- const eventArgs = { cancel: false, fileDetails: nodeData[0], module: 'NavigationPane' };
8209
- delete eventArgs.cancel;
8210
- this.parent.trigger('fileOpen', eventArgs);
8211
- }
8212
8269
  this.parent.selectedItems = [];
8213
8270
  this.parent.itemData = nodeData;
8214
8271
  updatePath(args.node, this.parent.itemData[0], this.parent);
@@ -8250,9 +8307,11 @@ class NavigationPane {
8250
8307
  }
8251
8308
  onNodeClicked(args) {
8252
8309
  this.parent.activeModule = 'navigationpane';
8310
+ this.previousSelected = this.treeObj.selectedNodes;
8253
8311
  this.activeNode = args.node;
8254
8312
  if ((args.event.which === 3) && (args.node.getAttribute('data-uid') !== this.treeObj.selectedNodes[0])) {
8255
8313
  this.isRightClick = true;
8314
+ this.isNodeClickCalled = true;
8256
8315
  this.treeObj.selectedNodes = [args.node.getAttribute('data-uid')];
8257
8316
  }
8258
8317
  else if (args.node.getAttribute('data-uid') === this.treeObj.selectedNodes[0] && this.parent.selectedItems.length !== 0) {