@syncfusion/ej2-filemanager 27.1.52 → 27.1.55

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.
@@ -1430,9 +1430,8 @@ function getSortedData(parent, items) {
1430
1430
  */
1431
1431
  function getObject(parent, key, value) {
1432
1432
  var currFiles = getValue(parent.pathId[parent.pathId.length - 1], parent.feFiles);
1433
- var query = new Query().where(key, 'equal', value);
1434
- var lists = new DataManager(currFiles).executeLocal(query);
1435
- return lists[0];
1433
+ var result = currFiles.filter(function (data) { return data[key].toString() === value; });
1434
+ return result.length > 0 ? result[0] : null;
1436
1435
  }
1437
1436
  /**
1438
1437
  * Creates empty element
@@ -1676,7 +1675,8 @@ function setNextPath(parent, path) {
1676
1675
  function openSearchFolder(parent, data) {
1677
1676
  parent.originalPath = getFullPath(parent, data, parent.path);
1678
1677
  var root = getValue(parent.pathId[0], parent.feParent);
1679
- var isRoot = getValue('_fm_id', parent.itemData[0]) === 'fe_tree';
1678
+ var navData = parent.feParent[getValue('_fm_id', parent.itemData[0])];
1679
+ var isRoot = isNullOrUndefined(navData) || getValue('_fm_id', navData) === 'fe_tree';
1680
1680
  var key = isNullOrUndefined(getValue('id', root)) ? 'name' : 'id';
1681
1681
  var searchData = getObject(parent, key, isFileSystemData(parent) ? getValue('id', data) : getValue('name', data));
1682
1682
  if (isNullOrUndefined(searchData)) {
@@ -2117,16 +2117,15 @@ function removeItemClass(parent, value) {
2117
2117
  * @param {Element} scrollParent - specifies the scrolling target.
2118
2118
  * @param {IFileManager} parent - specifies the parent.
2119
2119
  * @param {string} nodeClass - specifies the node class.
2120
- * @param {number} screenY - specifies the vertical (Y) coordinate of the mouse cursor position relative to the entire screen.
2121
2120
  * @param {number} clientY - specifies the vertical (Y) coordinate of the mouse cursor position relative to the target element.
2122
2121
  * @returns {void}
2123
2122
  * @private
2124
2123
  */
2125
- function scrollHandler(scrollParent, parent, nodeClass, screenY, clientY) {
2124
+ function scrollHandler(scrollParent, parent, nodeClass, clientY) {
2126
2125
  var position;
2127
2126
  var elementData = scrollParent.getBoundingClientRect();
2128
2127
  var node = select('.' + nodeClass, scrollParent);
2129
- if ((screenY >= (elementData.top + scrollParent.clientHeight - 30)) && !isNullOrUndefined(node)) {
2128
+ if ((clientY >= (elementData.top + scrollParent.clientHeight - 30)) && !isNullOrUndefined(node)) {
2130
2129
  position = (parent.targetModule === 'navigationpane' || parent.targetModule === 'detailsview') ? node.offsetHeight / 2.5 : node.offsetHeight / 4.5;
2131
2130
  scrollParent.scrollBy(0, position);
2132
2131
  }
@@ -2163,7 +2162,7 @@ function draggingHandler(parent, args) {
2163
2162
  /* istanbul ignore next */
2164
2163
  parent.treeExpandTimer = window.setTimeout(function () { parent.notify(dragging, args); }, 800);
2165
2164
  scrollParent = parent.navigationpaneModule.treeObj.element.parentElement;
2166
- scrollHandler(scrollParent, parent, 'e-level-2', args.event.screenY, args.event.y);
2165
+ scrollHandler(scrollParent, parent, 'e-level-2', args.event.y);
2167
2166
  }
2168
2167
  else if (parent.targetModule === 'detailsview') {
2169
2168
  node = closest(args.target, 'tr');
@@ -2175,7 +2174,7 @@ function draggingHandler(parent, args) {
2175
2174
  }
2176
2175
  canDrop = true;
2177
2176
  scrollParent = parent.detailsviewModule.gridObj.element.querySelector('.e-content');
2178
- scrollHandler(scrollParent, parent, 'e-row', args.event.screenY, args.event.y);
2177
+ scrollHandler(scrollParent, parent, 'e-row', args.event.y);
2179
2178
  }
2180
2179
  else if (parent.targetModule === 'largeiconsview') {
2181
2180
  node = closest(args.target, 'li');
@@ -2184,7 +2183,7 @@ function draggingHandler(parent, args) {
2184
2183
  }
2185
2184
  canDrop = true;
2186
2185
  scrollParent = parent.largeiconsviewModule.element.firstElementChild;
2187
- scrollHandler(scrollParent, parent, 'e-large-icon', args.event.screenY, args.event.y);
2186
+ scrollHandler(scrollParent, parent, 'e-large-icon', args.event.y);
2188
2187
  /* istanbul ignore next */
2189
2188
  }
2190
2189
  else if (parent.targetModule === 'breadcrumbbar') {
@@ -3222,7 +3221,7 @@ function performReadOperation(parent, result, fn, data, event, operation, target
3222
3221
  var item = result.files[i];
3223
3222
  setValue('_fm_iconClass', fileType(item), item);
3224
3223
  }
3225
- if (getValue('action', data) === 'read' || isFileSystemData(parent) && getValue('action', data) === 'search') {
3224
+ if (getValue('action', data) === 'read') {
3226
3225
  setNodeId(result, id);
3227
3226
  setValue(id, result.files, parent.feFiles);
3228
3227
  }
@@ -3343,13 +3342,18 @@ function readSuccess(parent, result, event) {
3343
3342
  * @private
3344
3343
  */
3345
3344
  function filterSuccess(parent, result, event, action) {
3346
- if (!isNullOrUndefined(result.files)) {
3347
- parent.notify(event, result);
3348
- var args = { action: action, result: result };
3349
- parent.trigger('success', args);
3345
+ try {
3346
+ if (!isNullOrUndefined(result.files)) {
3347
+ parent.notify(event, result);
3348
+ var args = { action: action, result: result };
3349
+ parent.trigger('success', args);
3350
+ }
3351
+ else {
3352
+ onFailure(parent, result, action);
3353
+ }
3350
3354
  }
3351
- else {
3352
- onFailure(parent, result, action);
3355
+ catch (error) {
3356
+ handleCatchError(parent, error, action);
3353
3357
  }
3354
3358
  }
3355
3359
  /* istanbul ignore next */
@@ -3363,51 +3367,59 @@ function filterSuccess(parent, result, event, action) {
3363
3367
  * @private
3364
3368
  */
3365
3369
  function createSuccess(parent, result, itemName) {
3366
- if (!isNullOrUndefined(result.files)) {
3367
- if (parent.dialogObj && parent.dialogObj.visible) {
3368
- parent.dialogObj.hide();
3369
- }
3370
- parent.createdItem = isFileSystemData(parent) ? result.files[result.files.length - 1] : result.files[0];
3371
- parent.breadcrumbbarModule.searchObj.value = '';
3372
- var createEventArgs = {
3373
- folderName: itemName,
3374
- path: parent.path,
3375
- parentFolder: parent.itemData
3376
- };
3377
- parent.trigger('folderCreate', createEventArgs);
3378
- var args = { action: 'create', result: result };
3379
- parent.trigger('success', args);
3380
- parent.itemData = [getPathObject(parent)];
3381
- read(parent, createEnd, parent.path);
3382
- }
3383
- else {
3384
- if (result.error.code === '400') {
3370
+ try {
3371
+ if (!isNullOrUndefined(result.files)) {
3385
3372
  if (parent.dialogObj && parent.dialogObj.visible) {
3386
- var ele = select('#newname', parent.dialogObj.element);
3387
- var error = getLocaleText(parent, 'Validation-NewFolder-Exists').replace('{0}', '"' + ele.value + '"');
3388
- ele.parentElement.nextElementSibling.innerHTML = error;
3389
- }
3390
- else {
3391
- var result_2 = {
3392
- files: null,
3393
- error: {
3394
- code: '400',
3395
- message: getLocaleText(parent, 'Validation-NewFolder-Exists').replace('{0}', '"' + itemName + '"'),
3396
- fileExists: null
3397
- }
3398
- };
3399
- createDialog(parent, 'Error', result_2);
3373
+ parent.dialogObj.hide();
3400
3374
  }
3401
- var args = { action: 'create', error: result.error };
3402
- parent.trigger('failure', args);
3375
+ parent.createdItem = isFileSystemData(parent) ? result.files[result.files.length - 1] : result.files[0];
3376
+ parent.breadcrumbbarModule.searchObj.value = '';
3377
+ var createEventArgs = {
3378
+ folderName: itemName,
3379
+ path: parent.path,
3380
+ parentFolder: parent.itemData
3381
+ };
3382
+ parent.trigger('folderCreate', createEventArgs);
3383
+ var args = { action: 'create', result: result };
3384
+ parent.trigger('success', args);
3385
+ parent.itemData = [getPathObject(parent)];
3386
+ read(parent, createEnd, parent.path);
3403
3387
  }
3404
3388
  else {
3405
- if (parent.dialogObj && parent.dialogObj.visible) {
3406
- parent.dialogObj.hide();
3389
+ if (result.error.code === '400') {
3390
+ if (parent.dialogObj && parent.dialogObj.visible) {
3391
+ var ele = select('#newname', parent.dialogObj.element);
3392
+ var error = getLocaleText(parent, 'Validation-NewFolder-Exists').replace('{0}', '"' + ele.value + '"');
3393
+ ele.parentElement.nextElementSibling.innerHTML = error;
3394
+ }
3395
+ else {
3396
+ var result_2 = {
3397
+ files: null,
3398
+ error: {
3399
+ code: '400',
3400
+ message: getLocaleText(parent, 'Validation-NewFolder-Exists').replace('{0}', '"' + itemName + '"'),
3401
+ fileExists: null
3402
+ }
3403
+ };
3404
+ createDialog(parent, 'Error', result_2);
3405
+ }
3406
+ var args = { action: 'create', error: result.error };
3407
+ parent.trigger('failure', args);
3408
+ }
3409
+ else {
3410
+ if (parent.dialogObj && parent.dialogObj.visible) {
3411
+ parent.dialogObj.hide();
3412
+ }
3413
+ onFailure(parent, result, 'create');
3407
3414
  }
3408
- onFailure(parent, result, 'create');
3409
3415
  }
3410
3416
  }
3417
+ catch (error) {
3418
+ if (parent.dialogObj && parent.dialogObj.visible) {
3419
+ parent.dialogObj.hide();
3420
+ }
3421
+ handleCatchError(parent, error, 'create');
3422
+ }
3411
3423
  }
3412
3424
  /* istanbul ignore next */
3413
3425
  /**
@@ -3429,7 +3441,7 @@ function renameSuccess(parent, result) {
3429
3441
  parent.renamedItem = Array.isArray(result.files) ? result.files[0] : result.files;
3430
3442
  var renameEventArgs = {
3431
3443
  newName: parent.renamedItem.name,
3432
- itemData: parent.renamedItem,
3444
+ itemData: [parent.renamedItem],
3433
3445
  path: parent.path
3434
3446
  };
3435
3447
  parent.trigger('rename', renameEventArgs);
@@ -5003,7 +5015,9 @@ var LargeIconsView = /** @__PURE__ @class */ (function () {
5003
5015
  var textEle = args.item.querySelector('.' + LIST_TEXT);
5004
5016
  var txt = getValue('name', args.curData);
5005
5017
  var type = getValue('type', args.curData);
5006
- textEle.innerHTML = txt.substr(0, txt.length - type.length);
5018
+ if (txt.indexOf(type) !== -1) {
5019
+ textEle.innerHTML = txt.substr(0, txt.length - type.length);
5020
+ }
5007
5021
  }
5008
5022
  this.renderCheckbox(args);
5009
5023
  var eventArgs = {
@@ -5371,6 +5385,7 @@ var LargeIconsView = /** @__PURE__ @class */ (function () {
5371
5385
  read(this.parent, pathChanged, this.parent.path);
5372
5386
  break;
5373
5387
  case 'allowMultiSelection':
5388
+ case 'showItemCheckBoxes':
5374
5389
  if (this.parent.view !== 'LargeIcons') {
5375
5390
  break;
5376
5391
  }
@@ -8289,7 +8304,9 @@ var FileManager = /** @__PURE__ @class */ (function (_super) {
8289
8304
  */
8290
8305
  /* istanbul ignore next */
8291
8306
  FileManager.prototype.onPropertyChanged = function (newProp, oldProp) {
8307
+ var _this = this;
8292
8308
  var height;
8309
+ var requiresRefresh = false;
8293
8310
  for (var _i = 0, _a = Object.keys(newProp); _i < _a.length; _i++) {
8294
8311
  var prop = _a[_i];
8295
8312
  switch (prop) {
@@ -8300,6 +8317,14 @@ var FileManager = /** @__PURE__ @class */ (function (_super) {
8300
8317
  this.allowDragAndDrop = newProp.allowDragAndDrop;
8301
8318
  this.notify(modelChanged, { module: 'common', newProp: newProp, oldProp: oldProp });
8302
8319
  break;
8320
+ case 'showItemCheckBoxes':
8321
+ this.showItemCheckBoxes = newProp.showItemCheckBoxes;
8322
+ this.notify(modelChanged, { module: 'common', newProp: newProp, oldProp: oldProp });
8323
+ break;
8324
+ case 'enableVirtualization':
8325
+ this.enableVirtualization = newProp.enableVirtualization;
8326
+ requiresRefresh = true;
8327
+ break;
8303
8328
  case 'allowMultiSelection':
8304
8329
  if (this.allowMultiSelection) {
8305
8330
  addClass([this.element], CHECK_SELECT);
@@ -8327,11 +8352,11 @@ var FileManager = /** @__PURE__ @class */ (function (_super) {
8327
8352
  break;
8328
8353
  case 'enableRtl':
8329
8354
  this.enableRtl = newProp.enableRtl;
8330
- this.refresh();
8355
+ requiresRefresh = true;
8331
8356
  break;
8332
8357
  case 'rootAliasName':
8333
8358
  this.rootAliasName = newProp.rootAliasName;
8334
- this.refresh();
8359
+ requiresRefresh = true;
8335
8360
  break;
8336
8361
  case 'height':
8337
8362
  height = !isNullOrUndefined(newProp.height) ? formatUnit(newProp.height) : newProp.height;
@@ -8406,11 +8431,21 @@ var FileManager = /** @__PURE__ @class */ (function (_super) {
8406
8431
  this.notify(sortByChange, {});
8407
8432
  break;
8408
8433
  case 'sortBy':
8409
- refresh(this);
8410
- this.notify(sortByChange, {});
8411
8434
  if (this.view === 'Details') {
8435
+ var columns = this.detailsViewSettings.columns;
8436
+ var isValidSortField = !isNullOrUndefined(columns) &&
8437
+ columns.findIndex(function (col) { return col.field === _this.sortBy; }) !== -1;
8438
+ if (!isValidSortField) {
8439
+ return;
8440
+ }
8441
+ refresh(this);
8442
+ this.notify(sortByChange, {});
8412
8443
  this.notify(sortColumn, {});
8413
8444
  }
8445
+ else {
8446
+ refresh(this);
8447
+ this.notify(sortByChange, {});
8448
+ }
8414
8449
  break;
8415
8450
  case 'popupTarget':
8416
8451
  if (this.uploadDialogObj) {
@@ -8428,10 +8463,13 @@ var FileManager = /** @__PURE__ @class */ (function (_super) {
8428
8463
  break;
8429
8464
  case 'fileSystemData':
8430
8465
  this.fileSystemData = newProp.fileSystemData;
8431
- this.refresh();
8466
+ requiresRefresh = true;
8432
8467
  break;
8433
8468
  }
8434
8469
  }
8470
+ if (requiresRefresh) {
8471
+ this.refresh();
8472
+ }
8435
8473
  };
8436
8474
  /* istanbul ignore next */
8437
8475
  FileManager.prototype.ajaxSettingSetModel = function (newProp) {
@@ -10783,6 +10821,7 @@ var DetailsView = /** @__PURE__ @class */ (function () {
10783
10821
  }
10784
10822
  /* istanbul ignore next */
10785
10823
  DetailsView.prototype.render = function (args) {
10824
+ var _this = this;
10786
10825
  showSpinner(this.parent.element);
10787
10826
  if (this.parent.view === 'Details') {
10788
10827
  removeClass([this.parent.element], MULTI_SELECT);
@@ -10790,7 +10829,9 @@ var DetailsView = /** @__PURE__ @class */ (function () {
10790
10829
  this.checkNameWidth();
10791
10830
  var columns = this.getColumns();
10792
10831
  var sortSettings = void 0;
10793
- if (this.parent.isMobile) {
10832
+ var isValidSortField = !isNullOrUndefined(columns) &&
10833
+ columns.findIndex(function (col) { return col.field === _this.parent.sortBy; }) !== -1;
10834
+ if (this.parent.isMobile || !isValidSortField) {
10794
10835
  sortSettings = [];
10795
10836
  }
10796
10837
  else {
@@ -11001,7 +11042,9 @@ var DetailsView = /** @__PURE__ @class */ (function () {
11001
11042
  if (textEle) {
11002
11043
  var name_1 = getValue('name', args.data);
11003
11044
  var type = getValue('type', args.data);
11004
- textEle.innerHTML = name_1.substr(0, name_1.length - type.length);
11045
+ if (name_1.indexOf(type) !== -1) {
11046
+ textEle.innerHTML = name_1.substr(0, name_1.length - type.length);
11047
+ }
11005
11048
  }
11006
11049
  }
11007
11050
  if (getValue('size', args.data) !== undefined && args.row.querySelector('.e-fe-size')) {
@@ -11264,6 +11307,7 @@ var DetailsView = /** @__PURE__ @class */ (function () {
11264
11307
  case 'showHiddenItems':
11265
11308
  read(this.parent, pathChanged, this.parent.path);
11266
11309
  break;
11310
+ case 'showItemCheckBoxes':
11267
11311
  case 'allowMultiSelection':
11268
11312
  if (!isNullOrUndefined(this.gridObj)) {
11269
11313
  this.currentSelectedItem = this.parent.selectedItems;