@syncfusion/ej2-filemanager 27.1.51 → 27.1.53

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.
@@ -1281,9 +1281,8 @@ function getSortedData(parent, items) {
1281
1281
  */
1282
1282
  function getObject(parent, key, value) {
1283
1283
  const currFiles = getValue(parent.pathId[parent.pathId.length - 1], parent.feFiles);
1284
- const query = new Query().where(key, 'equal', value);
1285
- const lists = new DataManager(currFiles).executeLocal(query);
1286
- return lists[0];
1284
+ const result = currFiles.filter((data) => data[key].toString() === value);
1285
+ return result.length > 0 ? result[0] : null;
1287
1286
  }
1288
1287
  /**
1289
1288
  * Creates empty element
@@ -1968,16 +1967,15 @@ function removeItemClass(parent, value) {
1968
1967
  * @param {Element} scrollParent - specifies the scrolling target.
1969
1968
  * @param {IFileManager} parent - specifies the parent.
1970
1969
  * @param {string} nodeClass - specifies the node class.
1971
- * @param {number} screenY - specifies the vertical (Y) coordinate of the mouse cursor position relative to the entire screen.
1972
1970
  * @param {number} clientY - specifies the vertical (Y) coordinate of the mouse cursor position relative to the target element.
1973
1971
  * @returns {void}
1974
1972
  * @private
1975
1973
  */
1976
- function scrollHandler(scrollParent, parent, nodeClass, screenY, clientY) {
1974
+ function scrollHandler(scrollParent, parent, nodeClass, clientY) {
1977
1975
  let position;
1978
1976
  const elementData = scrollParent.getBoundingClientRect();
1979
1977
  const node = select('.' + nodeClass, scrollParent);
1980
- if ((screenY >= (elementData.top + scrollParent.clientHeight - 30)) && !isNullOrUndefined(node)) {
1978
+ if ((clientY >= (elementData.top + scrollParent.clientHeight - 30)) && !isNullOrUndefined(node)) {
1981
1979
  position = (parent.targetModule === 'navigationpane' || parent.targetModule === 'detailsview') ? node.offsetHeight / 2.5 : node.offsetHeight / 4.5;
1982
1980
  scrollParent.scrollBy(0, position);
1983
1981
  }
@@ -2014,7 +2012,7 @@ function draggingHandler(parent, args) {
2014
2012
  /* istanbul ignore next */
2015
2013
  parent.treeExpandTimer = window.setTimeout(() => { parent.notify(dragging, args); }, 800);
2016
2014
  scrollParent = parent.navigationpaneModule.treeObj.element.parentElement;
2017
- scrollHandler(scrollParent, parent, 'e-level-2', args.event.screenY, args.event.y);
2015
+ scrollHandler(scrollParent, parent, 'e-level-2', args.event.y);
2018
2016
  }
2019
2017
  else if (parent.targetModule === 'detailsview') {
2020
2018
  node = closest(args.target, 'tr');
@@ -2026,7 +2024,7 @@ function draggingHandler(parent, args) {
2026
2024
  }
2027
2025
  canDrop = true;
2028
2026
  scrollParent = parent.detailsviewModule.gridObj.element.querySelector('.e-content');
2029
- scrollHandler(scrollParent, parent, 'e-row', args.event.screenY, args.event.y);
2027
+ scrollHandler(scrollParent, parent, 'e-row', args.event.y);
2030
2028
  }
2031
2029
  else if (parent.targetModule === 'largeiconsview') {
2032
2030
  node = closest(args.target, 'li');
@@ -2035,7 +2033,7 @@ function draggingHandler(parent, args) {
2035
2033
  }
2036
2034
  canDrop = true;
2037
2035
  scrollParent = parent.largeiconsviewModule.element.firstElementChild;
2038
- scrollHandler(scrollParent, parent, 'e-large-icon', args.event.screenY, args.event.y);
2036
+ scrollHandler(scrollParent, parent, 'e-large-icon', args.event.y);
2039
2037
  /* istanbul ignore next */
2040
2038
  }
2041
2039
  else if (parent.targetModule === 'breadcrumbbar') {
@@ -3194,13 +3192,18 @@ function readSuccess(parent, result, event) {
3194
3192
  * @private
3195
3193
  */
3196
3194
  function filterSuccess(parent, result, event, action) {
3197
- if (!isNullOrUndefined(result.files)) {
3198
- parent.notify(event, result);
3199
- const args = { action: action, result: result };
3200
- parent.trigger('success', args);
3195
+ try {
3196
+ if (!isNullOrUndefined(result.files)) {
3197
+ parent.notify(event, result);
3198
+ const args = { action: action, result: result };
3199
+ parent.trigger('success', args);
3200
+ }
3201
+ else {
3202
+ onFailure(parent, result, action);
3203
+ }
3201
3204
  }
3202
- else {
3203
- onFailure(parent, result, action);
3205
+ catch (error) {
3206
+ handleCatchError(parent, error, action);
3204
3207
  }
3205
3208
  }
3206
3209
  /* istanbul ignore next */
@@ -3214,51 +3217,59 @@ function filterSuccess(parent, result, event, action) {
3214
3217
  * @private
3215
3218
  */
3216
3219
  function createSuccess(parent, result, itemName) {
3217
- if (!isNullOrUndefined(result.files)) {
3218
- if (parent.dialogObj && parent.dialogObj.visible) {
3219
- parent.dialogObj.hide();
3220
- }
3221
- parent.createdItem = isFileSystemData(parent) ? result.files[result.files.length - 1] : result.files[0];
3222
- parent.breadcrumbbarModule.searchObj.value = '';
3223
- const createEventArgs = {
3224
- folderName: itemName,
3225
- path: parent.path,
3226
- parentFolder: parent.itemData
3227
- };
3228
- parent.trigger('folderCreate', createEventArgs);
3229
- const args = { action: 'create', result: result };
3230
- parent.trigger('success', args);
3231
- parent.itemData = [getPathObject(parent)];
3232
- read(parent, createEnd, parent.path);
3233
- }
3234
- else {
3235
- if (result.error.code === '400') {
3220
+ try {
3221
+ if (!isNullOrUndefined(result.files)) {
3236
3222
  if (parent.dialogObj && parent.dialogObj.visible) {
3237
- const ele = select('#newname', parent.dialogObj.element);
3238
- const error = getLocaleText(parent, 'Validation-NewFolder-Exists').replace('{0}', '"' + ele.value + '"');
3239
- ele.parentElement.nextElementSibling.innerHTML = error;
3240
- }
3241
- else {
3242
- const result = {
3243
- files: null,
3244
- error: {
3245
- code: '400',
3246
- message: getLocaleText(parent, 'Validation-NewFolder-Exists').replace('{0}', '"' + itemName + '"'),
3247
- fileExists: null
3248
- }
3249
- };
3250
- createDialog(parent, 'Error', result);
3223
+ parent.dialogObj.hide();
3251
3224
  }
3252
- const args = { action: 'create', error: result.error };
3253
- parent.trigger('failure', args);
3225
+ parent.createdItem = isFileSystemData(parent) ? result.files[result.files.length - 1] : result.files[0];
3226
+ parent.breadcrumbbarModule.searchObj.value = '';
3227
+ const createEventArgs = {
3228
+ folderName: itemName,
3229
+ path: parent.path,
3230
+ parentFolder: parent.itemData
3231
+ };
3232
+ parent.trigger('folderCreate', createEventArgs);
3233
+ const args = { action: 'create', result: result };
3234
+ parent.trigger('success', args);
3235
+ parent.itemData = [getPathObject(parent)];
3236
+ read(parent, createEnd, parent.path);
3254
3237
  }
3255
3238
  else {
3256
- if (parent.dialogObj && parent.dialogObj.visible) {
3257
- parent.dialogObj.hide();
3239
+ if (result.error.code === '400') {
3240
+ if (parent.dialogObj && parent.dialogObj.visible) {
3241
+ const ele = select('#newname', parent.dialogObj.element);
3242
+ const error = getLocaleText(parent, 'Validation-NewFolder-Exists').replace('{0}', '"' + ele.value + '"');
3243
+ ele.parentElement.nextElementSibling.innerHTML = error;
3244
+ }
3245
+ else {
3246
+ const result = {
3247
+ files: null,
3248
+ error: {
3249
+ code: '400',
3250
+ message: getLocaleText(parent, 'Validation-NewFolder-Exists').replace('{0}', '"' + itemName + '"'),
3251
+ fileExists: null
3252
+ }
3253
+ };
3254
+ createDialog(parent, 'Error', result);
3255
+ }
3256
+ const args = { action: 'create', error: result.error };
3257
+ parent.trigger('failure', args);
3258
+ }
3259
+ else {
3260
+ if (parent.dialogObj && parent.dialogObj.visible) {
3261
+ parent.dialogObj.hide();
3262
+ }
3263
+ onFailure(parent, result, 'create');
3258
3264
  }
3259
- onFailure(parent, result, 'create');
3260
3265
  }
3261
3266
  }
3267
+ catch (error) {
3268
+ if (parent.dialogObj && parent.dialogObj.visible) {
3269
+ parent.dialogObj.hide();
3270
+ }
3271
+ handleCatchError(parent, error, 'create');
3272
+ }
3262
3273
  }
3263
3274
  /* istanbul ignore next */
3264
3275
  /**
@@ -4850,7 +4861,9 @@ class LargeIconsView {
4850
4861
  const textEle = args.item.querySelector('.' + LIST_TEXT);
4851
4862
  const txt = getValue('name', args.curData);
4852
4863
  const type = getValue('type', args.curData);
4853
- textEle.innerHTML = txt.substr(0, txt.length - type.length);
4864
+ if (txt.indexOf(type) !== -1) {
4865
+ textEle.innerHTML = txt.substr(0, txt.length - type.length);
4866
+ }
4854
4867
  }
4855
4868
  this.renderCheckbox(args);
4856
4869
  const eventArgs = {
@@ -5217,6 +5230,7 @@ class LargeIconsView {
5217
5230
  read(this.parent, pathChanged, this.parent.path);
5218
5231
  break;
5219
5232
  case 'allowMultiSelection':
5233
+ case 'showItemCheckBoxes':
5220
5234
  if (this.parent.view !== 'LargeIcons') {
5221
5235
  break;
5222
5236
  }
@@ -5271,7 +5285,6 @@ class LargeIconsView {
5271
5285
  if (toBind) {
5272
5286
  this.clickObj = new Touch(this.element, {
5273
5287
  tap: (eve) => {
5274
- eve.originalEvent.preventDefault();
5275
5288
  if (this.parent.isDevice) {
5276
5289
  this.tapCount = eve.tapCount;
5277
5290
  this.tapEvent = eve;
@@ -8109,6 +8122,7 @@ let FileManager = FileManager_1 = class FileManager extends Component {
8109
8122
  /* istanbul ignore next */
8110
8123
  onPropertyChanged(newProp, oldProp) {
8111
8124
  let height;
8125
+ let requiresRefresh = false;
8112
8126
  for (const prop of Object.keys(newProp)) {
8113
8127
  switch (prop) {
8114
8128
  case 'ajaxSettings':
@@ -8118,6 +8132,14 @@ let FileManager = FileManager_1 = class FileManager extends Component {
8118
8132
  this.allowDragAndDrop = newProp.allowDragAndDrop;
8119
8133
  this.notify(modelChanged, { module: 'common', newProp: newProp, oldProp: oldProp });
8120
8134
  break;
8135
+ case 'showItemCheckBoxes':
8136
+ this.showItemCheckBoxes = newProp.showItemCheckBoxes;
8137
+ this.notify(modelChanged, { module: 'common', newProp: newProp, oldProp: oldProp });
8138
+ break;
8139
+ case 'enableVirtualization':
8140
+ this.enableVirtualization = newProp.enableVirtualization;
8141
+ requiresRefresh = true;
8142
+ break;
8121
8143
  case 'allowMultiSelection':
8122
8144
  if (this.allowMultiSelection) {
8123
8145
  addClass([this.element], CHECK_SELECT);
@@ -8145,11 +8167,11 @@ let FileManager = FileManager_1 = class FileManager extends Component {
8145
8167
  break;
8146
8168
  case 'enableRtl':
8147
8169
  this.enableRtl = newProp.enableRtl;
8148
- this.refresh();
8170
+ requiresRefresh = true;
8149
8171
  break;
8150
8172
  case 'rootAliasName':
8151
8173
  this.rootAliasName = newProp.rootAliasName;
8152
- this.refresh();
8174
+ requiresRefresh = true;
8153
8175
  break;
8154
8176
  case 'height':
8155
8177
  height = !isNullOrUndefined(newProp.height) ? formatUnit(newProp.height) : newProp.height;
@@ -8224,11 +8246,21 @@ let FileManager = FileManager_1 = class FileManager extends Component {
8224
8246
  this.notify(sortByChange, {});
8225
8247
  break;
8226
8248
  case 'sortBy':
8227
- refresh(this);
8228
- this.notify(sortByChange, {});
8229
8249
  if (this.view === 'Details') {
8250
+ const columns = this.detailsViewSettings.columns;
8251
+ const isValidSortField = !isNullOrUndefined(columns) &&
8252
+ columns.findIndex((col) => col.field === this.sortBy) !== -1;
8253
+ if (!isValidSortField) {
8254
+ return;
8255
+ }
8256
+ refresh(this);
8257
+ this.notify(sortByChange, {});
8230
8258
  this.notify(sortColumn, {});
8231
8259
  }
8260
+ else {
8261
+ refresh(this);
8262
+ this.notify(sortByChange, {});
8263
+ }
8232
8264
  break;
8233
8265
  case 'popupTarget':
8234
8266
  if (this.uploadDialogObj) {
@@ -8246,10 +8278,13 @@ let FileManager = FileManager_1 = class FileManager extends Component {
8246
8278
  break;
8247
8279
  case 'fileSystemData':
8248
8280
  this.fileSystemData = newProp.fileSystemData;
8249
- this.refresh();
8281
+ requiresRefresh = true;
8250
8282
  break;
8251
8283
  }
8252
8284
  }
8285
+ if (requiresRefresh) {
8286
+ this.refresh();
8287
+ }
8253
8288
  }
8254
8289
  /* istanbul ignore next */
8255
8290
  ajaxSettingSetModel(newProp) {
@@ -10536,6 +10571,7 @@ class DetailsView {
10536
10571
  this.isRendered = true;
10537
10572
  this.isLoaded = false;
10538
10573
  this.isNameWidth = false;
10574
+ this.isMultiSelect = false;
10539
10575
  this.pasteOperation = false;
10540
10576
  this.uploadOperation = false;
10541
10577
  Grid.Inject(Resize, ContextMenu$2, Sort, VirtualScroll);
@@ -10590,7 +10626,9 @@ class DetailsView {
10590
10626
  this.checkNameWidth();
10591
10627
  const columns = this.getColumns();
10592
10628
  let sortSettings;
10593
- if (this.parent.isMobile) {
10629
+ const isValidSortField = !isNullOrUndefined(columns) &&
10630
+ columns.findIndex((col) => col.field === this.parent.sortBy) !== -1;
10631
+ if (this.parent.isMobile || !isValidSortField) {
10594
10632
  sortSettings = [];
10595
10633
  }
10596
10634
  else {
@@ -10797,7 +10835,9 @@ class DetailsView {
10797
10835
  if (textEle) {
10798
10836
  const name = getValue('name', args.data);
10799
10837
  const type = getValue('type', args.data);
10800
- textEle.innerHTML = name.substr(0, name.length - type.length);
10838
+ if (name.indexOf(type) !== -1) {
10839
+ textEle.innerHTML = name.substr(0, name.length - type.length);
10840
+ }
10801
10841
  }
10802
10842
  }
10803
10843
  if (getValue('size', args.data) !== undefined && args.row.querySelector('.e-fe-size')) {
@@ -11058,6 +11098,7 @@ class DetailsView {
11058
11098
  case 'showHiddenItems':
11059
11099
  read(this.parent, pathChanged, this.parent.path);
11060
11100
  break;
11101
+ case 'showItemCheckBoxes':
11061
11102
  case 'allowMultiSelection':
11062
11103
  if (!isNullOrUndefined(this.gridObj)) {
11063
11104
  this.currentSelectedItem = this.parent.selectedItems;
@@ -11619,6 +11660,17 @@ class DetailsView {
11619
11660
  };
11620
11661
  this.parent.trigger('fileSelection', eventArgs);
11621
11662
  args.cancel = eventArgs.cancel;
11663
+ if (!this.isMultiSelect) {
11664
+ this.isMultiSelect = true;
11665
+ if ((args.isShiftPressed || args.isCtrlPressed) && !this.parent.allowMultiSelection && (args.target && args.target.parentElement && !args.target.parentElement.classList.contains('e-checkbox-wrapper'))) {
11666
+ args.cancel = true;
11667
+ const rowIndex = (args && args.rowIndexes)
11668
+ ? args.rowIndexes[args.rowIndexes.length - 1]
11669
+ : args.rowIndex;
11670
+ this.gridObj.selectRow(rowIndex);
11671
+ }
11672
+ this.isMultiSelect = false;
11673
+ }
11622
11674
  }
11623
11675
  /* istanbul ignore next */
11624
11676
  onSelected(args) {