Move one level up instead of to root

This commit is contained in:
rijkvanzanten
2020-08-11 14:25:49 -04:00
parent 1356816f39
commit 7f815f4631
2 changed files with 18 additions and 3 deletions

View File

@@ -16,7 +16,7 @@
"rename_folder": "Rename Folder",
"nested_files_folders_will_be_moved": "Nested files and folders will be moved to the File Library.",
"nested_files_folders_will_be_moved": "Nested files and folders will be moved one level up.",
"uploaded_by": "Uploaded By",
"hide_field_on_detail": "Hide Field on Detail",

View File

@@ -73,6 +73,19 @@
</v-card>
</v-dialog>
<v-dialog v-model="moveActive" persistent>
<v-card>
<v-card-title>{{ $t('move_to_folder') }}</v-card-title>
<v-card-text>
<folder-picker v-model="moveValue" :disabled-folders="[folder.id]" />
</v-card-text>
<v-card-actions>
<v-button secondary @click="moveActive = false">{{ $t('cancel') }}</v-button>
<v-button @click="moveSave" :loading="moveSaving">{{ $t('save') }}</v-button>
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog v-model="deleteActive" persistent>
<v-card>
<v-card-title>{{ $t('delete_folder') }}</v-card-title>
@@ -213,15 +226,17 @@ export default defineComponent({
},
});
const newParent = props.folder.parent_folder || null;
const folderKeys = foldersToUpdate.data.data.map((folder: { id: string }) => folder.id);
const fileKeys = filesToUpdate.data.data.map((file: { id: string }) => file.id);
if (folderKeys.length > 0) {
await api.patch(`/folders/${folderKeys.join(',')}`, { parent_folder: null });
await api.patch(`/folders/${folderKeys.join(',')}`, { parent_folder: newParent });
}
if (fileKeys.length > 0) {
await api.patch(`/files/${fileKeys.join(',')}`, { folder: null });
await api.patch(`/files/${fileKeys.join(',')}`, { folder: newParent });
}
await api.delete(`/folders/${props.folder.id}`);