@syncfusion/ej2-filemanager 21.1.35 → 21.1.39

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.
@@ -1313,7 +1313,7 @@ function sortbyClickHandler(parent, args) {
1313
1313
  tick = false;
1314
1314
  }
1315
1315
  if (!tick) {
1316
- parent.sortBy = getSortField(args.item.id);
1316
+ parent.sortBy = getSortField(args.item.id, parent);
1317
1317
  }
1318
1318
  else {
1319
1319
  parent.sortOrder = getSortField(args.item.id);
@@ -1340,12 +1340,24 @@ function sortbyClickHandler(parent, args) {
1340
1340
  * @returns {string} - returns the sorted fields
1341
1341
  * @private
1342
1342
  */
1343
- function getSortField(id) {
1343
+ function getSortField(id, parent) {
1344
1344
  const text = id.substring(id.lastIndexOf('_') + 1);
1345
1345
  let field = text;
1346
+ let column;
1347
+ if (parent) {
1348
+ column = parent.detailsViewSettings.columns;
1349
+ }
1346
1350
  switch (text) {
1347
1351
  case 'date':
1348
- field = '_fm_modified';
1352
+ for (let i = 0, len = column.length; i < len; i++) {
1353
+ if (column[i].field === 'dateModified' || column[i].field === 'dateCreated') {
1354
+ field = column[i].field;
1355
+ break;
1356
+ }
1357
+ else {
1358
+ field = '_fm_modified';
1359
+ }
1360
+ }
1349
1361
  break;
1350
1362
  case 'ascending':
1351
1363
  field = 'Ascending';
@@ -2545,10 +2557,15 @@ function renameSuccess(parent, result, path) {
2545
2557
  const args = { action: 'rename', result: result };
2546
2558
  parent.trigger('success', args);
2547
2559
  parent.renamedItem = result.files[0];
2560
+ if (getValue('filterPath', parent.renamedItem) === getValue('filterPath', parent.itemData[0]) && parent.pathNames.length > 1) {
2561
+ parent.pathNames[parent.pathNames.length - 1] = parent.renameText;
2562
+ }
2548
2563
  if (parent.activeModule === 'navigationpane') {
2549
2564
  parent.pathId.pop();
2550
2565
  parent.itemData = [getValue(parent.pathId[parent.pathId.length - 1], parent.feParent)];
2551
- read(parent, renameEndParent, getParentPath(parent.path));
2566
+ read(parent, renameEndParent, getValue('filterPath', parent.renamedItem).replace(/\\/g, '/'));
2567
+ parent.itemData[0] = parent.renamedItem;
2568
+ read(parent, pathChanged, parent.path === '/' ? parent.path : getValue('filterPath', parent.renamedItem).replace(/\\/g, '/') + parent.renamedItem.name + '/');
2552
2569
  }
2553
2570
  else {
2554
2571
  parent.itemData = [getPathObject(parent)];
@@ -3563,7 +3580,8 @@ function onReSubmit(parent) {
3563
3580
  parent.dialogObj.hide();
3564
3581
  return;
3565
3582
  }
3566
- const newPath = (parent.activeModule === 'navigationpane') ? getParentPath(parent.path) : parent.path;
3583
+ const newPath = (parent.activeModule === 'navigationpane') ? getValue('filterPath', parent.itemData[0]).replace(/\\/g, '/') : parent.path;
3584
+ parent.renamedId = getValue('id', parent.itemData[0]);
3567
3585
  parent.renamedId = getValue('id', parent.itemData[0]);
3568
3586
  if (parent.isFile) {
3569
3587
  const oldExtension = (oIndex === -1) ? '' : parent.currentItemText.substr(oIndex);
@@ -5953,10 +5971,11 @@ class ContextMenu$2 {
5953
5971
  this.menuType = 'folder';
5954
5972
  this.contextMenu.items = this.getItemData(this.parent.contextMenuSettings.folder.map((item) => item.trim()));
5955
5973
  this.contextMenu.dataBind();
5956
- if (isTree) {
5974
+ const selectedTreeNode = select('[data-uid="' + this.parent.navigationpaneModule.treeObj.selectedNodes[0] + '"]', this.parent.navigationpaneModule.treeObj.element);
5975
+ if (this.parent.pathNames[this.parent.pathNames.length - 1] === selectedTreeNode.querySelector('.e-list-text').innerHTML && this.parent.activeModule === 'navigationpane') {
5957
5976
  this.disabledItems.push('Open');
5958
5977
  }
5959
- else if (this.parent.selectedItems.length !== 1) {
5978
+ else if (this.parent.selectedItems.length !== 1 && this.parent.activeModule !== 'navigationpane') {
5960
5979
  this.disabledItems.push('Rename', 'Paste');
5961
5980
  }
5962
5981
  }
@@ -6099,10 +6118,13 @@ class ContextMenu$2 {
6099
6118
  refresh(this.parent);
6100
6119
  break;
6101
6120
  case 'open':
6102
- if (this.parent.visitedItem) {
6121
+ if (this.parent.visitedItem && this.parent.activeModule !== 'navigationpane') {
6103
6122
  this.parent.notify(openInit, { target: this.parent.visitedItem });
6104
6123
  }
6105
6124
  else if (this.parent.activeModule === 'navigationpane') {
6125
+ if (this.parent.visitedItem) {
6126
+ this.parent.notify(openInit, { target: this.parent.visitedItem });
6127
+ }
6106
6128
  this.parent.navigationpaneModule.openFileOnContextMenuClick(closest(this.targetNodeElement, 'li'));
6107
6129
  }
6108
6130
  break;
@@ -7888,7 +7910,12 @@ class Toolbar$1 {
7888
7910
  items[itemCount].iconCss = this.parent.sortBy === 'size' ? TB_OPTION_DOT : '';
7889
7911
  }
7890
7912
  else if (items[itemCount].id === this.getPupupId('date')) {
7891
- items[itemCount].iconCss = this.parent.sortBy === '_fm_modified' ? TB_OPTION_DOT : '';
7913
+ if (this.parent.sortBy === 'dateModified' || this.parent.sortBy === 'dateCreated') {
7914
+ items[itemCount].iconCss = this.parent.sortBy === this.parent.sortBy ? TB_OPTION_DOT : '';
7915
+ }
7916
+ else {
7917
+ items[itemCount].iconCss = this.parent.sortBy === '_fm_modified' ? TB_OPTION_DOT : '';
7918
+ }
7892
7919
  }
7893
7920
  else if (items[itemCount].id === this.getPupupId('ascending')) {
7894
7921
  items[itemCount].iconCss = this.parent.sortOrder === 'Ascending' ? TB_OPTION_TICK : '';
@@ -8420,6 +8447,8 @@ class NavigationPane {
8420
8447
  this.isPathDragged = false;
8421
8448
  this.isRenameParent = false;
8422
8449
  this.isRightClick = false;
8450
+ this.isSameNodeClicked = false;
8451
+ this.isNodeExpandCalled = false;
8423
8452
  this.renameParent = null;
8424
8453
  // Specifies the previously selected nodes in the treeview control.
8425
8454
  this.previousSelected = null;
@@ -8574,7 +8603,7 @@ class NavigationPane {
8574
8603
  }
8575
8604
  // Node Selecting event handler
8576
8605
  onNodeSelecting(args) {
8577
- if (!args.isInteracted && !this.isRightClick && !this.isPathDragged && !this.isRenameParent || this.restrictSelecting) {
8606
+ if (!args.isInteracted && !this.isRightClick && !this.isSameNodeClicked && !this.isPathDragged && !this.isRenameParent || this.restrictSelecting) {
8578
8607
  this.restrictSelecting = false;
8579
8608
  this.isNodeClickCalled = false;
8580
8609
  return;
@@ -8583,19 +8612,30 @@ class NavigationPane {
8583
8612
  this.parent.activeModule = 'navigationpane';
8584
8613
  // eslint-disable-next-line
8585
8614
  const nodeData = this.getTreeData(getValue('id', args.nodeData));
8586
- const eventArgs = { cancel: false, fileDetails: nodeData[0], module: 'NavigationPane' };
8587
- this.parent.trigger('fileOpen', eventArgs);
8588
- const selecEventArgs = { action: args.action, fileDetails: nodeData[0], isInteracted: args.isInteracted };
8589
- this.parent.trigger('fileSelect', selecEventArgs);
8590
- args.cancel = eventArgs.cancel;
8591
- if (args.cancel) {
8592
- this.restrictSelecting = this.isNodeClickCalled ? this.previousSelected[0] !== args.node.getAttribute('data-uid') : false;
8593
- this.previousSelected = this.treeObj.selectedNodes;
8594
- this.treeObj.selectedNodes = [args.node.getAttribute("data-uid")];
8595
- if (!isNullOrUndefined(this.parent) && !isNullOrUndefined(this.parent.contextmenuModule)) {
8596
- this.parent.contextmenuModule.contextMenu.enableItems(['Open'], true);
8615
+ if (args.node.getAttribute('data-uid') !== this.parent.pathId[this.parent.pathId.length - 1] && !this.isRightClick && !this.isNodeClickCalled || this.isSameNodeClicked) {
8616
+ this.isNodeClickCalled = false;
8617
+ if (!this.isSameNodeClicked) {
8618
+ this.isSameNodeClicked = true;
8619
+ const selecEventArgs = { action: args.action, fileDetails: nodeData[0], isInteracted: args.isInteracted };
8620
+ this.parent.trigger('fileSelect', selecEventArgs);
8621
+ }
8622
+ if (!this.isRightClick && args.node.getAttribute('data-uid') !== this.parent.pathId[this.parent.pathId.length - 1]) {
8623
+ const eventArgs = { cancel: false, fileDetails: nodeData[0], module: 'NavigationPane' };
8624
+ this.parent.trigger('fileOpen', eventArgs);
8625
+ args.cancel = eventArgs.cancel;
8626
+ }
8627
+ if (args.cancel) {
8628
+ this.restrictSelecting = this.isNodeClickCalled ? this.previousSelected[0] !== args.node.getAttribute('data-uid') : false;
8629
+ this.isNodeClickCalled = true;
8630
+ this.isSameNodeClicked = false;
8631
+ this.previousSelected = this.treeObj.selectedNodes;
8632
+ this.treeObj.selectedNodes = [args.node.getAttribute("data-uid")];
8597
8633
  }
8598
8634
  }
8635
+ else if (this.previousSelected[0] !== args.node.getAttribute('data-uid')) {
8636
+ const selecEventArgs = { action: args.action, fileDetails: nodeData[0], isInteracted: args.isInteracted };
8637
+ this.parent.trigger('fileSelect', selecEventArgs);
8638
+ }
8599
8639
  }
8600
8640
  }
8601
8641
  // Opens the folder while clicking open context menu item in the treeview.
@@ -8606,19 +8646,25 @@ class NavigationPane {
8606
8646
  this.parent.itemData = data;
8607
8647
  this.activeNode = node;
8608
8648
  this.parent.activeModule = 'navigationpane';
8609
- updatePath(node, this.parent.itemData[0], this.parent);
8610
- read(this.parent, this.isPathDragged ? pasteEnd : pathChanged, this.parent.path);
8611
- this.parent.visitedItem = node;
8612
- this.isPathDragged = this.isRenameParent = this.isRightClick = false;
8613
- this.treeObj.selectedNodes = [node.getAttribute('data-uid')];
8649
+ const eventArgs = { cancel: false, fileDetails: data[0], module: 'NavigationPane' };
8650
+ this.parent.trigger('fileOpen', eventArgs);
8651
+ this.isNodeClickCalled = true;
8652
+ if (!eventArgs.cancel) {
8653
+ updatePath(node, this.parent.itemData[0], this.parent);
8654
+ read(this.parent, this.isPathDragged ? pasteEnd : pathChanged, this.parent.path);
8655
+ this.parent.visitedItem = node;
8656
+ this.isPathDragged = this.isRenameParent = this.isRightClick = false;
8657
+ this.treeObj.selectedNodes = [node.getAttribute('data-uid')];
8658
+ }
8614
8659
  }
8615
8660
  onNodeSelected(args) {
8616
8661
  if (this.parent.breadcrumbbarModule && this.parent.breadcrumbbarModule.searchObj && !this.renameParent) {
8617
8662
  this.parent.breadcrumbbarModule.searchObj.element.value = '';
8618
8663
  this.parent.isFiltered = false;
8664
+ this.isNodeClickCalled = false;
8619
8665
  }
8620
8666
  this.parent.searchedItems = [];
8621
- if (!args.isInteracted && !this.isRightClick && !this.isPathDragged && !this.isRenameParent) {
8667
+ if (!args.isInteracted && !this.isRightClick && !this.isSameNodeClicked && !this.isPathDragged && !this.isRenameParent) {
8622
8668
  this.parent.pathId = getPathId(args.node);
8623
8669
  return;
8624
8670
  }
@@ -8629,7 +8675,8 @@ class NavigationPane {
8629
8675
  this.parent.selectedItems = [];
8630
8676
  this.parent.itemData = nodeData;
8631
8677
  const previousPath = this.parent.path;
8632
- if (!this.isRightClick) {
8678
+ const sNode = select('[data-uid="' + this.treeObj.selectedNodes[0] + '"]', this.treeObj.element);
8679
+ if (!this.isRightClick && this.isSameNodeClicked && sNode.querySelector('.e-list-text').innerHTML !== this.parent.pathNames[this.parent.pathNames.length - 1]) {
8633
8680
  updatePath(args.node, this.parent.itemData[0], this.parent);
8634
8681
  }
8635
8682
  else {
@@ -8641,12 +8688,13 @@ class NavigationPane {
8641
8688
  if (args.node.querySelector('.' + ICONS) && args.node.querySelector('.' + LIST_ITEM) === null) {
8642
8689
  this.expandNodeTarget = 'add';
8643
8690
  }
8644
- if (!this.isRightClick) {
8691
+ if (!this.isRightClick && this.isSameNodeClicked) {
8645
8692
  read(this.parent, this.isPathDragged ? pasteEnd : pathChanged, this.parent.path);
8693
+ this.isNodeClickCalled = true;
8646
8694
  }
8647
8695
  this.parent.visitedItem = args.node;
8648
8696
  }
8649
- this.isPathDragged = this.isRenameParent = this.isRightClick = false;
8697
+ this.isPathDragged = this.isRenameParent = this.isRightClick = this.isSameNodeClicked = false;
8650
8698
  }
8651
8699
  /* istanbul ignore next */
8652
8700
  // eslint-disable-next-line
@@ -8669,12 +8717,14 @@ class NavigationPane {
8669
8717
  this.parent.expandedId = this.expandNodeTarget;
8670
8718
  this.parent.itemData = this.getTreeData(getValue('id', args.nodeData));
8671
8719
  read(this.parent, nodeExpand, path);
8720
+ this.isNodeExpandCalled = true;
8672
8721
  }
8673
8722
  }
8674
8723
  /* istanbul ignore next */
8675
8724
  onNodeExpanded(args) {
8676
8725
  this.addChild(args.files, this.expandNodeTarget, false);
8677
8726
  this.parent.expandedId = null;
8727
+ this.isNodeExpandCalled = false;
8678
8728
  }
8679
8729
  onNodeClicked(args) {
8680
8730
  this.parent.activeModule = 'navigationpane';
@@ -8690,6 +8740,14 @@ class NavigationPane {
8690
8740
  const layout = (this.parent.view === 'LargeIcons') ? 'largeiconsview' : 'detailsview';
8691
8741
  this.parent.notify(modelChanged, { module: layout, newProp: { selectedItems: [] } });
8692
8742
  }
8743
+ else if (args.node.getAttribute('data-uid') === this.treeObj.selectedNodes[0] && !this.isNodeClickCalled && !this.isNodeExpandCalled) {
8744
+ if (args.event.which === 3) {
8745
+ this.isRightClick = true;
8746
+ }
8747
+ this.isSameNodeClicked = true;
8748
+ this.isNodeClickCalled = true;
8749
+ this.treeObj.selectedNodes = [args.node.getAttribute('data-uid')];
8750
+ }
8693
8751
  }
8694
8752
  /* istanbul ignore next */
8695
8753
  onNodeEditing(args) {