mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-23 13:24:42 +00:00
editing with shared items in public
This commit is contained in:
Vendored
+3
-3
@@ -1,6 +1,6 @@
|
||||
const defaultState = {
|
||||
fileInfoPanelVisible: localStorage.getItem('file_info_visibility') == 'true' || false,
|
||||
FilePreviewType: localStorage.getItem('FilePreviewType') || 'list',
|
||||
FilePreviewType: localStorage.getItem('preview_type') || 'list',
|
||||
appSize: undefined,
|
||||
config: undefined,
|
||||
}
|
||||
@@ -20,8 +20,8 @@ const actions = {
|
||||
|
||||
} else {
|
||||
|
||||
if ( this.$isThisLocation('public') ) {
|
||||
dispatch('browseShared', [this.currentFolder(), false, true])
|
||||
if ( getters.currentFolder.location === 'public' ) {
|
||||
dispatch('browseShared', [getters.currentFolder, false, true])
|
||||
} else {
|
||||
dispatch('getFolder', [getters.currentFolder, false, true])
|
||||
}
|
||||
|
||||
+48
-9
@@ -1,7 +1,7 @@
|
||||
import axios from 'axios'
|
||||
import {events} from '@/bus'
|
||||
import router from '@/router'
|
||||
import { includes } from 'lodash'
|
||||
import {includes} from 'lodash'
|
||||
import i18n from '@/i18n/index'
|
||||
|
||||
const defaultState = {
|
||||
@@ -11,6 +11,7 @@ const defaultState = {
|
||||
homeDirectory: undefined,
|
||||
uploadingFileProgress: 0,
|
||||
filesViewWidth: undefined,
|
||||
navigation: undefined,
|
||||
isSearching: false,
|
||||
browseHistory: [],
|
||||
isLoading: true,
|
||||
@@ -22,7 +23,7 @@ const actions = {
|
||||
events.$emit('show:content')
|
||||
|
||||
// Go to files view
|
||||
if ( ! includes(['Files', 'SharedContent'], router.currentRoute.name) ) {
|
||||
if (!includes(['Files', 'SharedContent'], router.currentRoute.name)) {
|
||||
router.push({name: 'Files'})
|
||||
}
|
||||
|
||||
@@ -42,7 +43,7 @@ const actions = {
|
||||
location: folder.deleted_at || folder.location === 'trash' ? 'trash' : 'base'
|
||||
}
|
||||
|
||||
let url = currentFolder.location === 'trash' ?'/folders/' + currentFolder.unique_id + '?trash=true' : '/folders/' + currentFolder.unique_id
|
||||
let url = currentFolder.location === 'trash' ? '/folders/' + currentFolder.unique_id + '?trash=true' : '/folders/' + currentFolder.unique_id
|
||||
|
||||
axios
|
||||
.get(context.getters.api + url)
|
||||
@@ -76,9 +77,9 @@ const actions = {
|
||||
router.push({name: 'Files'})
|
||||
}
|
||||
|
||||
if (! back) context.commit('FLUSH_BROWSER_HISTORY')
|
||||
context.commit('FLUSH_DATA')
|
||||
context.commit('LOADING_STATE', true)
|
||||
if (!back) context.commit('FLUSH_BROWSER_HISTORY')
|
||||
context.commit('FLUSH_DATA')
|
||||
context.commit('LOADING_STATE', true)
|
||||
|
||||
// Create shared object for history
|
||||
let trash = {
|
||||
@@ -113,9 +114,9 @@ const actions = {
|
||||
router.push({name: 'Files'})
|
||||
}
|
||||
|
||||
if (! back) context.commit('FLUSH_BROWSER_HISTORY')
|
||||
context.commit('FLUSH_DATA')
|
||||
context.commit('LOADING_STATE', true)
|
||||
if (!back) context.commit('FLUSH_BROWSER_HISTORY')
|
||||
context.commit('FLUSH_DATA')
|
||||
context.commit('LOADING_STATE', true)
|
||||
|
||||
// Create trash object for history
|
||||
let trash = {
|
||||
@@ -177,9 +178,46 @@ const actions = {
|
||||
})
|
||||
})
|
||||
},
|
||||
getFolderTree: ({commit, getters}) => {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
// Get route
|
||||
let route = undefined
|
||||
|
||||
if (getters.sharedDetail && getters.sharedDetail.protected)
|
||||
route = '/api/navigation/private'
|
||||
else if (getters.sharedDetail && ! getters.sharedDetail.protected)
|
||||
route = '/api/navigation/public/' + router.currentRoute.params.token
|
||||
else
|
||||
route = '/api/navigation'
|
||||
|
||||
axios
|
||||
.get(route)
|
||||
.then(response => {
|
||||
resolve(response)
|
||||
|
||||
commit('UPDATE_FOLDER_TREE', response.data)
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error)
|
||||
|
||||
// Show error message
|
||||
events.$emit('alert:open', {
|
||||
title: i18n.t('popup_error.title'),
|
||||
message: i18n.t('popup_error.message'),
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
UPDATE_FOLDER_TREE(state, tree) {
|
||||
state.navigation = tree
|
||||
},
|
||||
LOADING_STATE(state, val) {
|
||||
state.isLoading = val
|
||||
},
|
||||
@@ -274,6 +312,7 @@ const getters = {
|
||||
currentFolder: state => state.currentFolder,
|
||||
browseHistory: state => state.browseHistory,
|
||||
isSearching: state => state.isSearching,
|
||||
navigation: state => state.navigation,
|
||||
isLoading: state => state.isLoading,
|
||||
data: state => state.data,
|
||||
}
|
||||
|
||||
+37
-9
@@ -1,11 +1,19 @@
|
||||
import axios from 'axios'
|
||||
import {events} from '@/bus'
|
||||
import i18n from '@/i18n/index'
|
||||
import router from '@/router'
|
||||
import {events} from '@/bus'
|
||||
import axios from 'axios'
|
||||
|
||||
|
||||
const actions = {
|
||||
moveItem: ({commit, getters}, [item_from, to_item]) => {
|
||||
|
||||
// Get route
|
||||
let route = getters.sharedDetail && ! getters.sharedDetail.protected
|
||||
? '/api/move/' + item_from.unique_id + '/public/' + router.currentRoute.params.token
|
||||
: '/api/move/' + item_from.unique_id
|
||||
|
||||
axios
|
||||
.patch(getters.api + '/move-item/' + item_from.unique_id, {
|
||||
.patch(route, {
|
||||
from_type: item_from.type,
|
||||
to_unique_id: to_item.unique_id
|
||||
})
|
||||
@@ -16,11 +24,15 @@ const actions = {
|
||||
.catch(() => isSomethingWrong())
|
||||
},
|
||||
createFolder: ({commit, getters}, folderName) => {
|
||||
const parent_id = getters.currentFolder ? getters.currentFolder.unique_id : 0
|
||||
|
||||
// Get route
|
||||
let route = getters.sharedDetail && ! getters.sharedDetail.protected
|
||||
? '/api/create-folder/public/' + router.currentRoute.params.token
|
||||
: '/api/create-folder'
|
||||
|
||||
axios
|
||||
.post(getters.api + '/create-folder', {
|
||||
parent_id: parent_id,
|
||||
.post(route, {
|
||||
parent_id: getters.currentFolder.unique_id,
|
||||
name: folderName
|
||||
})
|
||||
.then(response => {
|
||||
@@ -34,8 +46,13 @@ const actions = {
|
||||
if (getters.permission === 'master' && data.type === 'folder')
|
||||
commit('UPDATE_NAME_IN_FAVOURITES', data)
|
||||
|
||||
// Get route
|
||||
let route = getters.sharedDetail && ! getters.sharedDetail.protected
|
||||
? '/api/rename-item/' + data.unique_id + '/public/' + router.currentRoute.params.token
|
||||
: '/api/rename-item/' + data.unique_id
|
||||
|
||||
axios
|
||||
.patch(getters.api + '/rename-item/' + data.unique_id, {
|
||||
.patch(route, {
|
||||
name: data.name,
|
||||
type: data.type,
|
||||
})
|
||||
@@ -46,8 +63,14 @@ const actions = {
|
||||
},
|
||||
uploadFiles: ({commit, getters}, files) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
// Get route
|
||||
let route = getters.sharedDetail && ! getters.sharedDetail.protected
|
||||
? '/api/upload/public/' + router.currentRoute.params.token
|
||||
: '/api/upload'
|
||||
|
||||
axios
|
||||
.post(getters.api + '/upload-file', files, {
|
||||
.post(route, files, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
},
|
||||
@@ -114,8 +137,13 @@ const actions = {
|
||||
// Remove file preview
|
||||
commit('CLEAR_FILEINFO_DETAIL')
|
||||
|
||||
// Get route
|
||||
let route = getters.sharedDetail && ! getters.sharedDetail.protected
|
||||
? '/api/remove-item/' + data.unique_id + '/public/' + router.currentRoute.params.token
|
||||
: '/api/remove-item/' + data.unique_id
|
||||
|
||||
axios
|
||||
.delete(getters.api + '/remove-item/' + data.unique_id, {
|
||||
.delete(route, {
|
||||
data: {
|
||||
type: data.type,
|
||||
force_delete: data.deleted_at ? true : false
|
||||
|
||||
-25
@@ -68,37 +68,12 @@ const actions = {
|
||||
})
|
||||
})
|
||||
},
|
||||
getFolderTree: (context) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
.get(context.getters.api + '/folder-tree')
|
||||
.then(response => {
|
||||
resolve(response)
|
||||
|
||||
context.commit('UPDATE_FOLDER_TREE', response.data)
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error)
|
||||
|
||||
// Show error message
|
||||
events.$emit('alert:open', {
|
||||
title: i18n.t('popup_error.title'),
|
||||
message: i18n.t('popup_error.message'),
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
RETRIEVE_APP_DATA(state, app) {
|
||||
state.app = app
|
||||
},
|
||||
UPDATE_FOLDER_TREE(state, tree) {
|
||||
state.app.folders = tree
|
||||
},
|
||||
SET_PERMISSION(state, role) {
|
||||
state.permission = role
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user