@syncfusion/ej2-filemanager 28.1.33 → 28.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.
@@ -1712,9 +1712,9 @@ function getDirectoryPath(parent, args) {
1712
1712
  const fPath = getValue(parent.hasId && !isNullOrUndefined(parent.ajaxSettings.url) ? 'filterId' : 'filterPath', args.cwd);
1713
1713
  if (!isNullOrUndefined(fPath)) {
1714
1714
  if (fPath === '') {
1715
- return parent.hasId && !isNullOrUndefined(parent.ajaxSettings.url) ? filePath : '/';
1715
+ return '/';
1716
1716
  }
1717
- return fPath.replace(/\\/g, '/') + filePath;
1717
+ return fPath.replace(/\\/g, '/').replace(/^.*?(?=\/)/, '') + filePath;
1718
1718
  }
1719
1719
  else {
1720
1720
  return isFileSystemData(parent) ? filePath : parent.path + filePath;
@@ -2619,7 +2619,7 @@ function createNewItem(data, target, itemName, isCopy) {
2619
2619
  }
2620
2620
  }
2621
2621
  const currentDate = new Date();
2622
- const folderPath = target.id !== 0 ? target.filterPath + target.name : '\\';
2622
+ const folderPath = String(target.id) !== String(0) && !isNullOrUndefined(target.parentId) ? target.filterPath + target.name + '\\' : '\\';
2623
2623
  Object.assign(newItem, {
2624
2624
  dateCreated: currentDate,
2625
2625
  dateModified: currentDate,
@@ -2753,7 +2753,9 @@ function triggerRenameOperation(parent, data, eventArgs) {
2753
2753
  if (isFileSystemData(parent)) {
2754
2754
  if (!isFileExists(parent.fileSystemData, args.newName)) {
2755
2755
  const fileData = filterById(parent, args.itemData[0].id);
2756
+ const oldName = fileData.name;
2756
2757
  fileData.name = args.newName;
2758
+ updateChildrenFilterPath(parent, fileData.id, oldName, args.newName);
2757
2759
  }
2758
2760
  else {
2759
2761
  const message = 'Cannot rename' + args.itemData[0].name + 'to' + args.newName + ': destination already exists.';
@@ -2762,6 +2764,26 @@ function triggerRenameOperation(parent, data, eventArgs) {
2762
2764
  }
2763
2765
  });
2764
2766
  }
2767
+ /**
2768
+ * Function to update child item filter path.
2769
+ *
2770
+ * @param {IFileManager} parent - specifies the parent element.
2771
+ * @param {string | number} parentId - specifies the parent id.
2772
+ * @param {string} oldName - specifies the previous name.
2773
+ * @param {string} newName - specifies the new name.
2774
+ * @returns {void}
2775
+ * @private
2776
+ */
2777
+ function updateChildrenFilterPath(parent, parentId, oldName, newName) {
2778
+ parent.fileSystemData.forEach((item) => {
2779
+ if (String(item.parentId) === String(parentId)) {
2780
+ const oldPath = item.filterPath;
2781
+ const newPath = oldPath.replace(oldName + '\\', newName + '\\');
2782
+ item.filterPath = newPath;
2783
+ updateChildrenFilterPath(parent, item.id, oldName, newName);
2784
+ }
2785
+ });
2786
+ }
2765
2787
  /**
2766
2788
  * Function to trigger move or copy operation.
2767
2789
  *
@@ -2824,11 +2846,16 @@ function triggerMoveOrCopyOperation(parent, data, eventArgs) {
2824
2846
  if (!isFileExists(getTargetFiles, currItem.name) || getValue('renameFiles', data).length > 0) {
2825
2847
  if (!target.hasChild) {
2826
2848
  target.hasChild = !currItem.isFile;
2849
+ const targetItem = parent.fileSystemData
2850
+ .filter((item) => String(item.id) === String(target.id));
2851
+ if (targetItem.length > 0) {
2852
+ targetItem[0].hasChild = target.hasChild;
2853
+ }
2827
2854
  }
2828
2855
  if (!currItem.isFile) {
2829
2856
  //Check whether the source folder include other sub folders or not.
2830
2857
  const subItems = currItem.parentId !== 0
2831
- ? filterByParent(parent, currItem.parentID) : [];
2858
+ ? filterByParent(parent, currItem.parentId) : [];
2832
2859
  const itemData = filterById(parent, currItem.parentId);
2833
2860
  itemData.hasChild = subItems.length > 1 ? true : false;
2834
2861
  }
@@ -2951,7 +2978,6 @@ function createAjax(parent, data, fn, event, operation, targetPath) {
2951
2978
  ? getValue('path', data) : parent.path;
2952
2979
  const pathArray = filePath.replace(/^\/|\/$/g, '').split('/');
2953
2980
  const idValue = event === 'rename-end-parent' || (event === 'path-changed' && getValue('data', data).length !== 0 && isNullOrUndefined(parent.renamedItem))
2954
- || (event === 'paste-end' && (parent.targetModule === 'largeiconsview' || parent.targetModule === 'detailsview'))
2955
2981
  ? getValue('data', data)[0].id : pathArray[pathArray.length - 1];
2956
2982
  const action = getValue('action', data);
2957
2983
  const isFileOperation = (action === 'move' || action === 'rename' || action === 'copy' || action === 'delete' || action === 'search') && event !== 'rename-end';
@@ -9972,7 +9998,7 @@ class NavigationPane {
9972
9998
  if (!this.renameParent) {
9973
9999
  this.parent.activeModule = 'navigationpane';
9974
10000
  const nodeData = this.getTreeData(getValue('id', args.nodeData));
9975
- if (args.node.getAttribute('data-uid') !== this.parent.pathId[this.parent.pathId.length - 1] && !this.isRightClick && !this.isNodeClickCalled || this.isSameNodeClicked) {
10001
+ if (args.node.getAttribute('data-uid') !== this.parent.pathId[this.parent.pathId.length - 1] && !this.isRightClick && !this.isNodeClickCalled || this.isSameNodeClicked || this.isPathDragged) {
9976
10002
  this.isNodeClickCalled = false;
9977
10003
  if (!this.isSameNodeClicked) {
9978
10004
  this.isSameNodeClicked = true;
@@ -9988,6 +10014,7 @@ class NavigationPane {
9988
10014
  this.restrictSelecting = this.isNodeClickCalled ? this.previousSelected[0] !== args.node.getAttribute('data-uid') : false;
9989
10015
  this.isNodeClickCalled = true;
9990
10016
  this.isSameNodeClicked = false;
10017
+ this.isPathDragged = false;
9991
10018
  this.previousSelected = this.treeObj.selectedNodes;
9992
10019
  this.treeObj.setProperties({ selectedNodes: [args.node.getAttribute('data-uid')] });
9993
10020
  }
@@ -10297,6 +10324,15 @@ class NavigationPane {
10297
10324
  this.removeChildNodes(e.selectedNode);
10298
10325
  }
10299
10326
  onDragEnd(args) {
10327
+ if (isFileSystemData(this.parent)) {
10328
+ this.moveNames = [];
10329
+ const obj = this.parent.dragData;
10330
+ for (let i = 0; i < obj.length; i++) {
10331
+ if (getValue('isFile', obj[i]) === false) {
10332
+ this.moveNames.push(getValue('_fm_id', obj[i]));
10333
+ }
10334
+ }
10335
+ }
10300
10336
  let moveNames = [];
10301
10337
  if (this.parent.isPasteError || this.parent.isSearchDrag) {
10302
10338
  moveNames = this.getMoveNames(args.files, this.parent.isSearchDrag, this.parent.dragPath);
@@ -10402,11 +10438,6 @@ class NavigationPane {
10402
10438
  if (isFileSystemData(this.parent) && (this.parent.path === this.parent.dropPath || this.parent.targetModule === 'navigationpane')) {
10403
10439
  return;
10404
10440
  }
10405
- if (this.parent.hasId) {
10406
- this.parent.isDropEnd = !this.parent.isPasteError;
10407
- readDropPath(this.parent);
10408
- return;
10409
- }
10410
10441
  if ((this.parent.dropPath.indexOf(getDirectoryPath(this.parent, args)) === -1)) {
10411
10442
  this.parent.isDropEnd = false;
10412
10443
  readDropPath(this.parent);