Sending parent id from vuejs to laravel to enable renaming child folders

parent f2a33802
......@@ -73,10 +73,13 @@
v-if="singleModal">
{{ trans('media.insert') }}
</a>
<a class="btn btn-default btn-flat" :href="getEditMediaUrl(scope)"
<a class="btn btn-default btn-flat" @click.prevent="loadEditForm(scope)"
v-if="! singleModal && ! scope.row.is_folder"><i class="fa fa-pencil"></i></a>
<rename-folder :current-folder="scope.row" v-if="! singleModal && scope.row.is_folder">
</rename-folder>
<a @click.prevent="showEditFolder(scope.row)" class="btn btn-default btn-flat"
v-if="! singleModal && scope.row.is_folder">
<i class="fa fa-pencil"></i>
</a>
</template>
</el-table-column>
</el-table>
......@@ -95,6 +98,7 @@
</div>
</div>
</div>
<rename-folder></rename-folder>
</div>
</template>
......@@ -195,6 +199,12 @@
getEditMediaUrl(scope) {
return route('admin.media.media.edit', {media: scope.row.id});
},
loadEditForm(scope) {
this.$events.emit('editMediaWasClicked', scope.row);
},
showEditFolder(scope) {
this.$events.emit('editFolderWasClicked', scope);
},
changeRoot(folderId, index) {
this.tableIsLoading = true;
this.queryServer({folder_id: folderId});
......
<template>
<div>
<a @click.prevent="dialogFormVisible = true" class="btn btn-default btn-flat">
<i class="fa fa-pencil"></i>
</a>
<el-dialog title="Rename Folder" :visible.sync="dialogFormVisible" size="tiny">
<el-form :model="folder" v-loading.body="loading" @submit.native.prevent="onSubmit()">
<el-form-item label="Folder name" :class="{'el-form-item is-error': form.errors.has('name') }">
......@@ -24,15 +20,16 @@
import Form from 'form-backend-validation'
export default {
props: {
currentFolder: {type: Object}
},
// props: {
// currentFolder: {type: Object}
// },
data() {
return {
dialogFormVisible: false,
folder: {
name: '',
id: '',
parent_id: '',
},
form: new Form(),
loading: false,
......@@ -67,8 +64,12 @@
},
},
mounted() {
this.folder.name = this.currentFolder.filename;
this.folder.id = this.currentFolder.id;
this.$events.listen('editFolderWasClicked', eventData => {
this.folder.name = eventData.filename;
this.folder.id = eventData.id;
this.folder.parent_id = eventData.folder_id;
this.dialogFormVisible = true;
});
}
}
</script>
......@@ -47,6 +47,7 @@ class EloquentFolderRepository extends EloquentBaseRepository implements FolderR
$formattedData = [
'filename' => array_get($data, 'name'),
'path' => $this->getPath($data),
'parent_id' => array_get($data, 'parent_id'),
];
event($event = new FolderIsUpdating($formattedData));
......
......@@ -31,6 +31,7 @@ class MediaTransformer extends Resource
'media_type' => $this->media_type,
'fa_icon' => FileHelper::getFaIcon($this->media_type),
'created_at' => $this->created_at,
'folder_id' => $this->folder_id,
'small_thumb' => $this->imagy->getThumbnail($this->path, 'smallThumb'),
'medium_thumb' => $this->imagy->getThumbnail($this->path, 'mediumThumb'),
];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment