Skip to content

Commit

Permalink
option to move folders to other folders
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Mar 20, 2024
1 parent 1b83e6a commit 6747a92
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/apis/StorageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,9 @@ public function actionFolderUpdate($folderId)

$this->flushApiCache();

return $model->update();
$model->update();

return $model;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/resources/dist/main.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/resources/js/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -1450,10 +1450,21 @@ zaa.directive("storageFileManager", function () {
});
};

$scope.isFolderMoveModalHidden = true;

$scope.currentEditFolder = null;

$scope.cancelFolderEdit = function (folder, oldName) {
folder.name = oldName;
};

$scope.moveFolderTo = function(targetFolder, toFolderId) {
$http.post('admin/api-admin-storage/folder-update?folderId=' + targetFolder.id, { parent_id: toFolderId }).then(function (transport) {
AdminToastService.success(i18nParam('js_ngrest_toggler_success', {field: targetFolder.name}));
$scope.foldersDataReload()
});
}

$scope.deleteFolder = function (folder) {
$http.post('admin/api-admin-storage/is-folder-empty?folderId=' + folder.id, { name: folder.name }).then(function (transport) {
var isEmpty = transport.data.empty;
Expand Down
18 changes: 16 additions & 2 deletions src/views/layouts/_angulardirectives.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,29 +199,43 @@
<i class="material-icons" ng-if="currentFolderId == folder.id">folder</i>
<i class="material-icons" ng-if="currentFolderId != folder.id">folder_open</i>
</div>
<div class="folder-label" ng-class="{'is-active' : hasFolderActiveChild(folder.id)}">{{folder.name }}</div>
<div class="folder-label" ng-class="{'is-active' : hasFolderActiveChild(folder.id)}">{{ folder.name }}</div>
</span>
<div class="folder-edit">
<input class="folder-edit-input" ng-model="folder.name" type="text" />
</div>
</div>
<div class="folder-right folder-action-default">
<button class="folder-button folder-button--edit" ng-click="editFolderLabel=!editFolderLabel;"><i class="material-icons">edit</i></button>
<button class="folder-button folder-button--edit" ng-click="editFolderLabel=!editFolderLabel; currentEditFolder=folder"><i class="material-icons">edit</i></button>
<button class="folder-button folder-button--delete" ng-hide="folder.subfolder || folder.filesCount > 0" ng-click="deleteFolder(folder)"><i class="material-icons">delete</i></button>
</div>
<div class="folder-right folder-action-edit">
<button class="folder-button folder-button--save" ng-click="updateFolder(folder); editFolderLabel=!editFolderLabel"><i class="material-icons">check</i></button>
<button class="folder-button" ng-click="isFolderMoveModalHidden=!isFolderMoveModalHidden"><i class="material-icons">subdirectory_arrow_right</i></button>
<button class="folder-button folder-button--abort" ng-click="cancelFolderEdit(folder, oldFolder); editFolderLabel=!editFolderLabel;"><i class="material-icons">cancel</i></button>
</div>
<div class="folder-right folder-action-move-to">
<button class="folder-button folder-button--move-to" ng-click="moveFilesTo(folder.id)"><i class="material-icons">subdirectory_arrow_left</i></button>
</div>
<modal is-modal-hidden="isFolderMoveModalHidden" modal-title="{{ folder.name }}">
<div ng-if="!isFolderMoveModalHidden">
<button type="button" class="btn my-1 btn-icon btn-outline-folder" ng-click="moveFolderTo(currentEditFolder, 0)"><?= Admin::t('layout_filemanager_root_dir'); ?></button>
<div ng-repeat="folderlist in getFolderData(0) track by folderlist.id" ng-include="'folderMoveTemplate'"></div>
</div>
</modal>
</div>
<ul class="folders" ng-if="folder.subfolder === true && folder.toggle_open==1">
<li class="folders-folder-item" ng-class="{'is-movable' : showFoldersToMove}" ng-repeat="folder in getFolderData(folder.id) track by folder.id" ng-include="'reverseFolders'"></li>
</ul>
</script>

<script type="text/ng-template" id="folderMoveTemplate">
<div>
<button type="button" class="btn my-1 btn-icon btn-outline-folder" ng-click="moveFolderTo(currentEditFolder, folderlist.id)" ng-disabled="folderlist.id == currentEditFolder.id || folderlist.id == currentEditFolder.parentId">{{ folderlist.name }}</button>
<div style="margin-left:20px;" ng-repeat="folderlist in getFolderData(folderlist.id) track by folderlist.id" ng-include="'folderMoveTemplate'"></div>
</div>
</script>

<!-- FILEMANAGER -->
<script type="text/ng-template" id="storageFileManager">
<div class="filemanager" ng-paste="pasteUpload($event)">
Expand Down

0 comments on commit 6747a92

Please sign in to comment.