Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lang/en/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,18 @@
'updater_require_version_command' => 'To require this specific version, run the following command',
'updater_update_to_latest_command' => 'To update to the latest version, run the following command',
'uploader_append_timestamp' => 'Append timestamp',
'asset_conflict_title' => 'File conflict',
'asset_conflict_message' => ':existing_descriptor item named ":filename" already exists in this location. Do you want to replace it with the :moving_age one you\'re moving?',
'asset_upload_conflict_message' => 'An item named ":filename" already exists in this location. What would you like to do?',
'asset_conflict_a_newer' => 'A newer',
'asset_conflict_an_older' => 'An older',
'asset_conflict_newer' => 'newer',
'asset_conflict_older' => 'older',
'asset_conflict_cancel' => 'Cancel',
'asset_conflict_keep_both' => 'Keep Both',
'asset_conflict_overwrite' => 'Overwrite',
'asset_conflict_apply_to_all' => 'Do this for all remaining conflicts',
'asset_conflict_pending' => 'Waiting for conflict decision',
'uploader_choose_new_filename' => 'Choose new filename',
'uploader_discard_use_existing' => 'Discard and use existing file',
'uploader_overwrite_existing' => 'Overwrite existing file',
Expand Down
41 changes: 37 additions & 4 deletions resources/js/components/assets/Browser/AssetBrowserMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export default {
folderActionUrl: String,
folders: Array,
path: String,
selectedAssets: {
type: Array,
default: () => [],
},
restrictFolderNavigation: Boolean,
creatingFolder: Boolean,
creatingFolderError: Boolean,
Expand Down Expand Up @@ -82,25 +86,53 @@ export default {
return folder.actions.some((action) => action.handle === 'move_asset_folder');
},

getDraggingAssetSelections() {
const selectedAssetIds = Array.isArray(this.selectedAssets) ? this.selectedAssets : [];

if (selectedAssetIds.includes(this.draggingAsset)) {
return selectedAssetIds;
}

return this.draggingAsset ? [this.draggingAsset] : [];
},

handleFolderDrop(destinationFolder) {
if (this.draggingAsset) {
let asset = this.assets.find((asset) => asset.id === this.draggingAsset);
let action = asset.actions.find((action) => action.handle === 'move_asset');
const selections = this.getDraggingAssetSelections();

if (!action) {
if (!action || selections.length === 0) {
return;
}

const payload = {
action: action.handle,
context: action.context,
selections: [this.draggingAsset],
selections,
values: { folder: destinationFolder.path },
};

this.$axios
.post(this.actionUrl, payload)
.then(response => this.$emit('action-completed', true, response))
.then(({ data }) => {
if (data.success === false && data.conflict?.type === 'asset_move') {
this.$emit('asset-move-conflict', {
action,
asset,
destinationFolder,
selections,
message: data.message,
conflict: data.conflict,
completedMoves: data.completed_moves,
});

return;
}

this.$emit('action-completed', data.success !== false, data);
})
.catch((error) => this.$emit('action-completed', false, error.response?.data || {}))
.finally(() => this.draggingAsset = null);
}

Expand All @@ -121,7 +153,8 @@ export default {

this.$axios
.post(this.folderActionUrl, payload)
.then(response => this.$emit('action-completed', true, response))
.then(({ data }) => this.$emit('action-completed', data.success !== false, data))
.catch((error) => this.$emit('action-completed', false, error.response?.data || {}))
.finally(() => this.draggingFolder = null);
}
},
Expand Down
Loading
Loading