UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

699 lines (698 loc) • 38.7 kB
/** * DevExtreme (esm/__internal/ui/file_manager/ui.file_manager.editing.js) * Version: 25.2.7 * Build date: Tue May 05 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import messageLocalization from "../../../common/core/localization/message"; import $ from "../../../core/renderer"; import { Deferred } from "../../../core/utils/deferred"; import { extend } from "../../../core/utils/extend"; import { each } from "../../../core/utils/iterator"; import { format } from "../../../core/utils/string"; import { isDefined } from "../../../core/utils/type"; import Widget from "../../core/widget/widget"; import FileManagerDialogManager from "../../ui/file_manager/ui.file_manager.dialog_manager"; import FileManagerFileUploader from "../../ui/file_manager/ui.file_manager.file_uploader"; import { ErrorCode, FileManagerMessages } from "../../ui/file_manager/ui.file_manager.messages"; class FileManagerActionContext { constructor(actionMetadata, itemInfos, directoryInfo) { this._actionMetadata = actionMetadata; this._itemInfos = itemInfos; this._onlyFiles = !this._actionMetadata.affectsAllItems && this._itemInfos.every(info => !info.fileItem.isDirectory); this._items = this._itemInfos.map(itemInfo => itemInfo.fileItem); this._multipleItems = this._items.length > 1; this._location = directoryInfo.getDisplayName(); this._singleRequest = true; this._completedItems = []; this._commonProgress = 0; this._errorState = { failedCount: 0 }; this._itemNewName = "" } completeOperationItem(itemIndex) { if (this._singleRequest) { this._completedItems = [...this._items] } else { const item = this._items[itemIndex]; this._completedItems.push(item) } if (!this._actionMetadata.allowItemProgress) { this._commonProgress = this._completedItems.length / this._items.length * 100 } } processSingleRequestError(errorText) { this._errorState.failedCount = 1; this._errorState.commonErrorText = this._multipleItems ? this._actionMetadata.commonErrorMessage : this._actionMetadata.singleItemErrorMessage; const itemIndex = this._multipleItems ? -1 : 1; const itemInfo = this.getItemForSingleRequestError(); this._setCurrentDetailError(itemIndex, itemInfo, errorText) } processMultipleRequestError(itemIndex, errorText) { this._errorState.failedCount += 1; this._errorState.commonErrorText = this._errorState.failedCount > 1 ? format(this._actionMetadata.multipleItemsErrorMessage, this._errorState.failedCount) : this._actionMetadata.singleItemErrorMessage; const itemInfo = this.getItemForMultipleRequestError(itemIndex); this._setCurrentDetailError(itemIndex, itemInfo, errorText) } hasModifiedItems() { return this._hasCompletedItems() || this._singleRequest && !this.success && this._multipleItems } getItemForSingleRequestError() { return this._multipleItems ? null : this._itemInfos[0] } getItemForMultipleRequestError(itemIndex) { return this._itemInfos[itemIndex] } getItemName(errorCode, itemIndex) { const itemInfo = this.singleRequest ? this.getItemForSingleRequestError() : this.getItemForMultipleRequestError(itemIndex); let result = null === itemInfo || void 0 === itemInfo ? void 0 : itemInfo.fileItem.name; if (this.itemNewName && this._isItemExistsErrorCode(errorCode)) { result = this.itemNewName } return result } _isItemExistsErrorCode(errorCode) { return errorCode === ErrorCode.DirectoryExists || errorCode === ErrorCode.FileExists } _setCurrentDetailError(itemIndex, itemInfo, errorText) { this._errorState.currentDetailError = { itemIndex: itemIndex, itemInfo: itemInfo, errorText: errorText } } _hasCompletedItems() { return this._completedItems.length > 0 } get actionMetadata() { return this._actionMetadata } get itemInfos() { return this._itemInfos } get itemNewName() { return this._itemNewName } set itemNewName(value) { this._itemNewName = value } get errorState() { return this._errorState } get singleRequest() { return this._singleRequest } set singleRequest(value) { this._singleRequest = value } get multipleItems() { return this._multipleItems } get onlyFiles() { return this._onlyFiles } get processingMessage() { return this._multipleItems ? format(this._actionMetadata.multipleItemsProcessingMessage, this._items.length, this._location) : format(this._actionMetadata.singleItemProcessingMessage, this._location) } get successMessage() { if (this._hasCompletedItems()) { return this._multipleItems ? format(this._actionMetadata.multipleItemsSuccessMessage, this._completedItems.length, this._location) : format(this._actionMetadata.singleItemSuccessMessage, this._location) } return this._multipleItems ? format(this._actionMetadata.multipleItemsErrorMessage, this._items.length) : this._actionMetadata.singleItemErrorMessage } get completionMessage() { return this.success ? this.successMessage : this.errorState.commonErrorText } get statusText() { return this.success && !this._hasCompletedItems() ? this._actionMetadata.canceledMessage : void 0 } get commonProgress() { return this._commonProgress } get success() { return !this._errorState.failedCount } } class FileManagerEditingControl extends Widget { _initMarkup() { var _this$_controller, _this$_controller2, _this$_controller3, _this$_controller4, _this$_controller5, _this$_controller6, _this$_controller7, _this$_controller8, _this$_controller9; super._initMarkup(); this._initActions(); const { controller: controller } = this.option(); this._controller = controller; null === (_this$_controller = this._controller) || void 0 === _this$_controller || _this$_controller.on("EditActionStarting", this._onEditActionStarting.bind(this)); null === (_this$_controller2 = this._controller) || void 0 === _this$_controller2 || _this$_controller2.on("EditActionResultAcquired", this._onEditActionResultAcquired.bind(this)); null === (_this$_controller3 = this._controller) || void 0 === _this$_controller3 || _this$_controller3.on("EditActionItemError", this._onEditActionItemError.bind(this)); null === (_this$_controller4 = this._controller) || void 0 === _this$_controller4 || _this$_controller4.on("EditActionError", this._onEditActionError.bind(this)); null === (_this$_controller5 = this._controller) || void 0 === _this$_controller5 || _this$_controller5.on("CompleteEditActionItem", this._onCompleteEditActionItem.bind(this)); null === (_this$_controller6 = this._controller) || void 0 === _this$_controller6 || _this$_controller6.on("CompleteEditAction", this._onCompleteEditAction.bind(this)); const { model: model } = this.option(); this._model = model; this._uploadOperationInfoMap = {}; const { rtlEnabled: rtlEnabled } = this.option(); this._dialogManager = new FileManagerDialogManager(this.$element(), { chooseDirectoryDialog: { provider: null === (_this$_controller7 = this._controller) || void 0 === _this$_controller7 ? void 0 : _this$_controller7._fileProvider, getDirectories: null === (_this$_controller8 = this._controller) || void 0 === _this$_controller8 ? void 0 : _this$_controller8.getDirectories.bind(this._controller), getCurrentDirectory: null === (_this$_controller9 = this._controller) || void 0 === _this$_controller9 ? void 0 : _this$_controller9.getCurrentDirectory.bind(this._controller) }, rtlEnabled: rtlEnabled, onDialogClosed: this._onDialogClosed.bind(this) }); this._fileUploader = this._createFileUploader(); const { notificationControl: notificationControl } = this.option(); if (notificationControl) { this._initNotificationControl(notificationControl) } this._createMetadataMap() } _initNotificationControl(notificationControl) { this._notificationControl = notificationControl; this._notificationControl.option({ onOperationCanceled: _ref => { let { info: info } = _ref; return this._onCancelUploadSession(info) }, onOperationItemCanceled: _ref2 => { let { item: item, itemIndex: itemIndex } = _ref2; return this._onCancelFileUpload(item, itemIndex) } }) } _getFileUploaderComponent() { return FileManagerFileUploader } _createFileUploader() { const $fileUploader = $("<div>").appendTo(this.$element()); const { uploadDropZonePlaceholderContainer: uploadDropZonePlaceholderContainer } = this.option(); return this._createComponent($fileUploader, this._getFileUploaderComponent(), { getController: this._getFileUploaderController.bind(this), dropZonePlaceholderContainer: uploadDropZonePlaceholderContainer, onUploadSessionStarted: e => this._onUploadSessionStarted(e), onUploadProgress: e => this._onUploadProgress(e), onUploadFinished: e => this._onUploadFinished(e) }) } setUploaderDropZone($element) { var _this$_fileUploader; null === (_this$_fileUploader = this._fileUploader) || void 0 === _this$_fileUploader || _this$_fileUploader.option("dropZone", $element) } setUploaderSplitterElement(element) { var _this$_fileUploader2; null === (_this$_fileUploader2 = this._fileUploader) || void 0 === _this$_fileUploader2 || _this$_fileUploader2.option("splitterElement", element) } _getFileUploaderController() { var _this$_controller0; const uploadDirectory = this.uploadDirectoryInfo.fileItem; return { chunkSize: null === (_this$_controller0 = this._controller) || void 0 === _this$_controller0 ? void 0 : _this$_controller0.getFileUploadChunkSize(), uploadFileChunk: (fileData, chunksInfo) => { var _this$_controller1; return null === (_this$_controller1 = this._controller) || void 0 === _this$_controller1 ? void 0 : _this$_controller1.uploadFileChunk(fileData, chunksInfo, uploadDirectory) }, abortFileUpload: (fileData, chunksInfo) => { var _this$_controller10; return null === (_this$_controller10 = this._controller) || void 0 === _this$_controller10 ? void 0 : _this$_controller10.abortFileUpload(fileData, chunksInfo, uploadDirectory) } } } _createMetadataMap() { this._metadataMap = { create: { action: arg => this._tryCreate(arg), affectsAllItems: true, singleItemProcessingMessage: messageLocalization.format("dxFileManager-editingCreateSingleItemProcessingMessage"), singleItemSuccessMessage: messageLocalization.format("dxFileManager-editingCreateSingleItemSuccessMessage"), singleItemErrorMessage: messageLocalization.format("dxFileManager-editingCreateSingleItemErrorMessage"), commonErrorMessage: messageLocalization.format("dxFileManager-editingCreateCommonErrorMessage") }, rename: { action: arg => this._tryRename(arg), singleItemProcessingMessage: messageLocalization.format("dxFileManager-editingRenameSingleItemProcessingMessage"), singleItemSuccessMessage: messageLocalization.format("dxFileManager-editingRenameSingleItemSuccessMessage"), singleItemErrorMessage: messageLocalization.format("dxFileManager-editingRenameSingleItemErrorMessage"), commonErrorMessage: messageLocalization.format("dxFileManager-editingRenameCommonErrorMessage") }, delete: { action: arg => this._tryDelete(arg), singleItemProcessingMessage: messageLocalization.format("dxFileManager-editingDeleteSingleItemProcessingMessage"), multipleItemsProcessingMessage: messageLocalization.format("dxFileManager-editingDeleteMultipleItemsProcessingMessage"), singleItemSuccessMessage: messageLocalization.format("dxFileManager-editingDeleteSingleItemSuccessMessage"), multipleItemsSuccessMessage: messageLocalization.format("dxFileManager-editingDeleteMultipleItemsSuccessMessage"), singleItemErrorMessage: messageLocalization.format("dxFileManager-editingDeleteSingleItemErrorMessage"), multipleItemsErrorMessage: messageLocalization.format("dxFileManager-editingDeleteMultipleItemsErrorMessage"), commonErrorMessage: messageLocalization.format("dxFileManager-editingDeleteCommonErrorMessage") }, move: { action: arg => this._tryMove(arg), singleItemProcessingMessage: messageLocalization.format("dxFileManager-editingMoveSingleItemProcessingMessage"), multipleItemsProcessingMessage: messageLocalization.format("dxFileManager-editingMoveMultipleItemsProcessingMessage"), singleItemSuccessMessage: messageLocalization.format("dxFileManager-editingMoveSingleItemSuccessMessage"), multipleItemsSuccessMessage: messageLocalization.format("dxFileManager-editingMoveMultipleItemsSuccessMessage"), singleItemErrorMessage: messageLocalization.format("dxFileManager-editingMoveSingleItemErrorMessage"), multipleItemsErrorMessage: messageLocalization.format("dxFileManager-editingMoveMultipleItemsErrorMessage"), commonErrorMessage: messageLocalization.format("dxFileManager-editingMoveCommonErrorMessage") }, copy: { action: arg => this._tryCopy(arg), singleItemProcessingMessage: messageLocalization.format("dxFileManager-editingCopySingleItemProcessingMessage"), multipleItemsProcessingMessage: messageLocalization.format("dxFileManager-editingCopyMultipleItemsProcessingMessage"), singleItemSuccessMessage: messageLocalization.format("dxFileManager-editingCopySingleItemSuccessMessage"), multipleItemsSuccessMessage: messageLocalization.format("dxFileManager-editingCopyMultipleItemsSuccessMessage"), singleItemErrorMessage: messageLocalization.format("dxFileManager-editingCopySingleItemErrorMessage"), multipleItemsErrorMessage: messageLocalization.format("dxFileManager-editingCopyMultipleItemsErrorMessage"), commonErrorMessage: messageLocalization.format("dxFileManager-editingCopyCommonErrorMessage") }, upload: { action: arg => this._tryUpload(arg), allowCancel: true, allowItemProgress: true, singleItemProcessingMessage: messageLocalization.format("dxFileManager-editingUploadSingleItemProcessingMessage"), multipleItemsProcessingMessage: messageLocalization.format("dxFileManager-editingUploadMultipleItemsProcessingMessage"), singleItemSuccessMessage: messageLocalization.format("dxFileManager-editingUploadSingleItemSuccessMessage"), multipleItemsSuccessMessage: messageLocalization.format("dxFileManager-editingUploadMultipleItemsSuccessMessage"), singleItemErrorMessage: messageLocalization.format("dxFileManager-editingUploadSingleItemErrorMessage"), multipleItemsErrorMessage: messageLocalization.format("dxFileManager-editingUploadMultipleItemsErrorMessage"), canceledMessage: messageLocalization.format("dxFileManager-editingUploadCanceledMessage") }, download: { action: arg => this._download(arg), singleItemProcessingMessage: "", multipleItemsProcessingMessage: "", singleItemErrorMessage: messageLocalization.format("dxFileManager-editingDownloadSingleItemErrorMessage"), multipleItemsErrorMessage: messageLocalization.format("dxFileManager-editingDownloadMultipleItemsErrorMessage") }, getItemContent: { action: arg => this._getItemContent(arg) }, getItems: { singleItemProcessingMessage: "", singleItemErrorMessage: messageLocalization.format("dxFileManager-errorDirectoryOpenFailed"), commonErrorMessage: messageLocalization.format("dxFileManager-errorDirectoryOpenFailed") } } } getCommandActions() { const result = {}; each(this._metadataMap, name => { if (Object.prototype.hasOwnProperty.call(this._metadataMap, name)) { result[name] = arg => this._executeAction(name, arg) } }); return result } _executeAction(actionName, arg) { var _this$_metadataMap, _actionMetadata$actio; const actionMetadata = null === (_this$_metadataMap = this._metadataMap) || void 0 === _this$_metadataMap ? void 0 : _this$_metadataMap[actionName]; return actionMetadata ? null === actionMetadata || void 0 === actionMetadata || null === (_actionMetadata$actio = actionMetadata.action) || void 0 === _actionMetadata$actio ? void 0 : _actionMetadata$actio.call(actionMetadata, arg) : null } _onCancelUploadSession(info) { var _this$_fileUploader3; null === (_this$_fileUploader3 = this._fileUploader) || void 0 === _this$_fileUploader3 || _this$_fileUploader3.cancelUpload(info.uploadSessionId) } _onCancelFileUpload(item, itemIndex) { var _this$_fileUploader4; null === (_this$_fileUploader4 = this._fileUploader) || void 0 === _this$_fileUploader4 || _this$_fileUploader4.cancelFileUpload(item.info.uploadSessionId, itemIndex) } _onUploadProgress(_ref3) { var _this$_notificationCo; let { sessionId: sessionId, fileIndex: fileIndex, commonValue: commonValue, fileValue: fileValue } = _ref3; const { operationInfo: operationInfo } = this._uploadOperationInfoMap[sessionId]; null === (_this$_notificationCo = this._notificationControl) || void 0 === _this$_notificationCo || _this$_notificationCo.updateOperationItemProgress(operationInfo, fileIndex, 100 * fileValue, 100 * commonValue) } _onUploadFinished(_ref4) { var _this$_notificationCo2; let { sessionId: sessionId, commonValue: commonValue } = _ref4; const { operationInfo: operationInfo } = this._uploadOperationInfoMap[sessionId]; null === (_this$_notificationCo2 = this._notificationControl) || void 0 === _this$_notificationCo2 || _this$_notificationCo2.finishOperation(operationInfo, 100 * commonValue); this._scheduleUploadSessionDisposal(sessionId, "uploader") } _onUploadSessionStarted(_ref5) { var _this$_controller11; let { sessionInfo: sessionInfo } = _ref5; null === (_this$_controller11 = this._controller) || void 0 === _this$_controller11 || _this$_controller11.processUploadSession(sessionInfo, this.uploadDirectoryInfo) } _onEditActionStarting(actionInfo) { var _this$_metadataMap2, _this$_notificationCo3; const actionMetadata = (null === (_this$_metadataMap2 = this._metadataMap) || void 0 === _this$_metadataMap2 ? void 0 : _this$_metadataMap2[actionInfo.name]) ?? {}; const context = new FileManagerActionContext(actionMetadata, actionInfo.itemInfos, actionInfo.directory); const operationInfo = null === (_this$_notificationCo3 = this._notificationControl) || void 0 === _this$_notificationCo3 ? void 0 : _this$_notificationCo3.addOperation(context.processingMessage, null === actionMetadata || void 0 === actionMetadata ? void 0 : actionMetadata.allowCancel, !(null !== actionMetadata && void 0 !== actionMetadata && actionMetadata.allowItemProgress)); extend(actionInfo.customData, { context: context, operationInfo: operationInfo }); switch (actionInfo.name) { case "upload": { const { sessionId: sessionId } = actionInfo.customData.sessionInfo; operationInfo.uploadSessionId = sessionId; this._uploadOperationInfoMap[sessionId] = { operationInfo: operationInfo }; break } case "rename": actionInfo.customData.context.itemNewName = actionInfo.customData.itemNewName } } _onEditActionResultAcquired(actionInfo) { var _this$_notificationCo4; const { context: context, operationInfo: operationInfo } = actionInfo.customData; context.singleRequest = actionInfo.singleRequest; const details = context.itemInfos.map(itemInfo => this._getItemProgressDisplayInfo(itemInfo)); null === (_this$_notificationCo4 = this._notificationControl) || void 0 === _this$_notificationCo4 || _this$_notificationCo4.addOperationDetails(operationInfo, details, context.actionMetadata.allowCancel) } _onEditActionError(actionInfo, errorInfo) { const { context: context, operationInfo: operationInfo } = actionInfo.customData; context.singleRequest = actionInfo.singleRequest; this._handleActionError(operationInfo, context, errorInfo); this._completeAction(operationInfo, context) } _onEditActionItemError(actionInfo, errorInfo) { const { context: context, operationInfo: operationInfo } = actionInfo.customData; this._handleActionError(operationInfo, context, errorInfo) } _onCompleteEditActionItem(actionInfo, info) { var _info$result; const { context: context, operationInfo: operationInfo } = actionInfo.customData; if (!(null !== (_info$result = info.result) && void 0 !== _info$result && _info$result.canceled)) { var _this$_notificationCo5; context.completeOperationItem(info.index); null === (_this$_notificationCo5 = this._notificationControl) || void 0 === _this$_notificationCo5 || _this$_notificationCo5.completeOperationItem(operationInfo, info.index, context.commonProgress) } } _onCompleteEditAction(actionInfo) { const { context: context, operationInfo: operationInfo } = actionInfo.customData; this._completeAction(operationInfo, context); if ("upload" === actionInfo.name) { this._scheduleUploadSessionDisposal(actionInfo.customData.sessionInfo.sessionId, "controller") } } _scheduleUploadSessionDisposal(sessionId, requester) { if (isDefined(this._uploadOperationInfoMap[sessionId].requester) && this._uploadOperationInfoMap[sessionId].requester !== requester) { delete this._uploadOperationInfoMap[sessionId] } else { this._uploadOperationInfoMap[sessionId].requester = requester } } _tryCreate(parentDirectories) { var _this$_showDialog, _this$_dialogManager; const parentDirectoryInfo = (null === parentDirectories || void 0 === parentDirectories ? void 0 : parentDirectories[0]) || this._getCurrentDirectory(); const newDirName = messageLocalization.format("dxFileManager-newDirectoryName"); return null === (_this$_showDialog = this._showDialog(null === (_this$_dialogManager = this._dialogManager) || void 0 === _this$_dialogManager ? void 0 : _this$_dialogManager.getCreateItemDialog(), newDirName)) || void 0 === _this$_showDialog ? void 0 : _this$_showDialog.then(_ref6 => { var _this$_controller12; let { name: name } = _ref6; return null === (_this$_controller12 = this._controller) || void 0 === _this$_controller12 ? void 0 : _this$_controller12.createDirectory(parentDirectoryInfo, name) }) } _tryRename(itemInfos) { var _this$_model, _this$_model$getMulti, _this$_showDialog2, _this$_dialogManager2; const itemInfo = (null === itemInfos || void 0 === itemInfos ? void 0 : itemInfos[0]) || (null === (_this$_model = this._model) || void 0 === _this$_model || null === (_this$_model$getMulti = _this$_model.getMultipleSelectedItems) || void 0 === _this$_model$getMulti ? void 0 : _this$_model$getMulti.call(_this$_model)[0]); if (!itemInfo) { return (new Deferred).reject().promise() } return null === (_this$_showDialog2 = this._showDialog(null === (_this$_dialogManager2 = this._dialogManager) || void 0 === _this$_dialogManager2 ? void 0 : _this$_dialogManager2.getRenameItemDialog(), itemInfo.fileItem.name)) || void 0 === _this$_showDialog2 ? void 0 : _this$_showDialog2.then(_ref7 => { var _this$_controller13; let { name: name } = _ref7; return null === (_this$_controller13 = this._controller) || void 0 === _this$_controller13 ? void 0 : _this$_controller13.renameItem(itemInfo, name) }) } _tryDelete(itemInfos) { var _this$_model2, _this$_model2$getMult, _this$_showDialog3, _this$_dialogManager3; itemInfos = itemInfos || (null === (_this$_model2 = this._model) || void 0 === _this$_model2 || null === (_this$_model2$getMult = _this$_model2.getMultipleSelectedItems) || void 0 === _this$_model2$getMult ? void 0 : _this$_model2$getMult.call(_this$_model2)); if (0 === itemInfos.length) { return (new Deferred).reject().promise() } const itemName = itemInfos[0].fileItem.name; const itemCount = itemInfos.length; return null === (_this$_showDialog3 = this._showDialog(null === (_this$_dialogManager3 = this._dialogManager) || void 0 === _this$_dialogManager3 ? void 0 : _this$_dialogManager3.getDeleteItemDialog(), { itemName: itemName, itemCount: itemCount })) || void 0 === _this$_showDialog3 ? void 0 : _this$_showDialog3.then(() => { var _this$_controller14; return null === (_this$_controller14 = this._controller) || void 0 === _this$_controller14 ? void 0 : _this$_controller14.deleteItems(itemInfos) }) } _tryMove(itemInfos) { var _this$_model3, _this$_model3$getMult, _this$_showDialog4, _this$_dialogManager4; itemInfos = itemInfos || (null === (_this$_model3 = this._model) || void 0 === _this$_model3 || null === (_this$_model3$getMult = _this$_model3.getMultipleSelectedItems) || void 0 === _this$_model3$getMult ? void 0 : _this$_model3$getMult.call(_this$_model3)); if (0 === itemInfos.length) { return (new Deferred).reject().promise() } return null === (_this$_showDialog4 = this._showDialog(null === (_this$_dialogManager4 = this._dialogManager) || void 0 === _this$_dialogManager4 ? void 0 : _this$_dialogManager4.getMoveDialog(itemInfos))) || void 0 === _this$_showDialog4 ? void 0 : _this$_showDialog4.then(_ref8 => { var _this$_controller15; let { folder: folder } = _ref8; return null === (_this$_controller15 = this._controller) || void 0 === _this$_controller15 ? void 0 : _this$_controller15.moveItems(itemInfos, folder) }) } _tryCopy(itemInfos) { var _this$_model4, _this$_model4$getMult, _this$_showDialog5, _this$_dialogManager5; itemInfos = itemInfos || (null === (_this$_model4 = this._model) || void 0 === _this$_model4 || null === (_this$_model4$getMult = _this$_model4.getMultipleSelectedItems) || void 0 === _this$_model4$getMult ? void 0 : _this$_model4$getMult.call(_this$_model4)); if (0 === itemInfos.length) { return (new Deferred).reject().promise() } return null === (_this$_showDialog5 = this._showDialog(null === (_this$_dialogManager5 = this._dialogManager) || void 0 === _this$_dialogManager5 ? void 0 : _this$_dialogManager5.getCopyDialog(itemInfos))) || void 0 === _this$_showDialog5 ? void 0 : _this$_showDialog5.then(_ref9 => { var _this$_controller16; let { folder: folder } = _ref9; return null === (_this$_controller16 = this._controller) || void 0 === _this$_controller16 ? void 0 : _this$_controller16.copyItems(itemInfos, folder) }) } _tryUpload(destinationFolder) { var _this$_fileUploader5; this._uploadDirectoryInfo = null === destinationFolder || void 0 === destinationFolder ? void 0 : destinationFolder[0]; null === (_this$_fileUploader5 = this._fileUploader) || void 0 === _this$_fileUploader5 || _this$_fileUploader5.tryUpload() } _download(itemInfos) { var _this$_model5, _this$_model5$getMult, _this$_controller17; itemInfos = itemInfos || (null === (_this$_model5 = this._model) || void 0 === _this$_model5 || null === (_this$_model5$getMult = _this$_model5.getMultipleSelectedItems) || void 0 === _this$_model5$getMult ? void 0 : _this$_model5$getMult.call(_this$_model5)); if (0 === itemInfos.length) { return (new Deferred).reject().promise() } return null === (_this$_controller17 = this._controller) || void 0 === _this$_controller17 ? void 0 : _this$_controller17.downloadItems(itemInfos) } _getItemContent(itemInfos) { var _this$_model6, _this$_model6$getMult, _this$_controller18; itemInfos = itemInfos || (null === (_this$_model6 = this._model) || void 0 === _this$_model6 || null === (_this$_model6$getMult = _this$_model6.getMultipleSelectedItems) || void 0 === _this$_model6$getMult ? void 0 : _this$_model6$getMult.call(_this$_model6)); return null === (_this$_controller18 = this._controller) || void 0 === _this$_controller18 ? void 0 : _this$_controller18.getItemContent(itemInfos) } _completeAction(operationInfo, context) { var _this$_notificationCo6; null === (_this$_notificationCo6 = this._notificationControl) || void 0 === _this$_notificationCo6 || _this$_notificationCo6.completeOperation(operationInfo, context.completionMessage, !context.success, context.statusText); if (context.hasModifiedItems()) { this._raiseOnSuccess(context.onlyFiles) } } _handleActionError(operationInfo, context, errorInfo) { operationInfo.hasError = true; if (context.singleRequest) { this._handleSingleRequestActionError(operationInfo, context, errorInfo) } else { this._handleMultipleRequestActionError(operationInfo, context, errorInfo) } } _handleSingleRequestActionError(operationInfo, context, errorInfo) { var _this$_notificationCo7; const itemInfo = context.getItemForSingleRequestError(); const itemName = context.getItemName(errorInfo.errorCode); const errorText = this._getErrorText(errorInfo, itemInfo, itemName); context.processSingleRequestError(errorText); const operationErrorInfo = this._getOperationErrorInfo(context); null === (_this$_notificationCo7 = this._notificationControl) || void 0 === _this$_notificationCo7 || _this$_notificationCo7.completeSingleOperationWithError(operationInfo, operationErrorInfo); if (context.multipleItems) { this._raiseOnSuccess(context.onlyFiles) } } _handleMultipleRequestActionError(operationInfo, context, errorInfo) { var _this$_notificationCo8; const itemInfo = context.getItemForMultipleRequestError(errorInfo.index); const itemName = context.getItemName(errorInfo.errorCode, errorInfo.index); const errorText = this._getErrorText(errorInfo, itemInfo, itemName); context.processMultipleRequestError(errorInfo.index, errorText); const operationErrorInfo = this._getOperationErrorInfo(context); null === (_this$_notificationCo8 = this._notificationControl) || void 0 === _this$_notificationCo8 || _this$_notificationCo8.addOperationDetailsError(operationInfo, operationErrorInfo) } _getOperationErrorInfo(context) { const detailError = context.errorState.currentDetailError; return { commonErrorText: context.errorState.commonErrorText, item: detailError.itemInfo ? this._getItemProgressDisplayInfo(detailError.itemInfo) : null, itemIndex: detailError.itemIndex, detailErrorText: detailError.errorText } } _getErrorText(errorInfo, itemInfo, itemName) { const errorText = errorInfo.errorText || FileManagerMessages.get(errorInfo.errorCode, itemName); const errorArgs = { fileSystemItem: null === itemInfo || void 0 === itemInfo ? void 0 : itemInfo.fileItem, errorCode: errorInfo.errorCode, errorText: errorText }; this._raiseOnError(errorArgs); return errorArgs.errorText } _getItemProgressDisplayInfo(itemInfo) { return { commonText: itemInfo.fileItem.name, imageUrl: this._getItemThumbnail(itemInfo) } } _showDialog(dialog, dialogArgument) { var _this$_dialogDeferred; this._dialogDeferred = new Deferred; dialog.show(dialogArgument); return null === (_this$_dialogDeferred = this._dialogDeferred) || void 0 === _this$_dialogDeferred ? void 0 : _this$_dialogDeferred.promise() } _onDialogClosed(e) { const result = e.dialogResult; if (result) { var _this$_dialogDeferred2; null === (_this$_dialogDeferred2 = this._dialogDeferred) || void 0 === _this$_dialogDeferred2 || _this$_dialogDeferred2.resolve(result) } else { var _this$_dialogDeferred3; null === (_this$_dialogDeferred3 = this._dialogDeferred) || void 0 === _this$_dialogDeferred3 || _this$_dialogDeferred3.reject() } } updateDialogRtl(value) { var _this$_dialogManager6; null === (_this$_dialogManager6 = this._dialogManager) || void 0 === _this$_dialogManager6 || _this$_dialogManager6.updateDialogRtl(value) } _getItemThumbnail(item) { const { getItemThumbnail: getItemThumbnail } = this.option(); if (!getItemThumbnail) { return null } const info = getItemThumbnail(item); return info ? info.thumbnail : null } _initActions() { this._actions = { onSuccess: this._createActionByOption("onSuccess"), onError: this._createActionByOption("onError") } } _getDefaultOptions() { return Object.assign({}, super._getDefaultOptions(), { model: { getMultipleSelectedItems: void 0 }, notificationControl: void 0, getItemThumbnail: void 0, onSuccess: void 0, onError: void 0 }) } _optionChanged(args) { var _this$_fileUploader6; const { name: name } = args; switch (name) { case "model": this.repaint(); break; case "notificationControl": this._initNotificationControl(args.value); break; case "getItemThumbnail": break; case "uploadDropZonePlaceholderContainer": null === (_this$_fileUploader6 = this._fileUploader) || void 0 === _this$_fileUploader6 || _this$_fileUploader6.option("dropZonePlaceholderContainer", args.value); break; case "onSuccess": case "onError": this._actions[name] = this._createActionByOption(name); break; default: super._optionChanged(args) } } _raiseOnSuccess(updatedOnlyFiles) { var _this$_actions$onSucc, _this$_actions; null === (_this$_actions$onSucc = (_this$_actions = this._actions).onSuccess) || void 0 === _this$_actions$onSucc || _this$_actions$onSucc.call(_this$_actions, { updatedOnlyFiles: updatedOnlyFiles }) } _raiseOnError(args) { var _this$_actions$onErro, _this$_actions2; null === (_this$_actions$onErro = (_this$_actions2 = this._actions).onError) || void 0 === _this$_actions$onErro || _this$_actions$onErro.call(_this$_actions2, args) } _getCurrentDirectory() { var _this$_controller19; return null === (_this$_controller19 = this._controller) || void 0 === _this$_controller19 ? void 0 : _this$_controller19.getCurrentDirectory() } get uploadDirectoryInfo() { return this._uploadDirectoryInfo || this._getCurrentDirectory() } } export default FileManagerEditingControl;