- fileinfodetail renamed to clipboard

This commit is contained in:
Peter Papp
2021-04-19 09:22:50 +02:00
parent b71072ddda
commit b0c81a692c
24 changed files with 382 additions and 353 deletions
+31 -33
View File
@@ -5,12 +5,14 @@ import router from '@/router'
import i18n from '@/i18n/index'
const defaultState = {
fileInfoDetail: [],
currentFolder: undefined,
navigation: undefined,
isSearching: false,
browseHistory: [],
isLoading: true,
browseHistory: [],
clipboard: [],
data: [],
}
@@ -30,7 +32,7 @@ const actions = {
// Set folder location
payload.folder.location = payload.folder.deleted_at || payload.folder.location === 'trash' ? 'trash' : 'base'
if (! payload.back && !payload.sorting)
if (!payload.back && !payload.sorting)
commit('STORE_PREVIOUS_FOLDER', getters.currentFolder)
let url = payload.folder.location === 'trash'
@@ -77,7 +79,7 @@ const actions = {
})
axios
.get(getters.api + '/browse/latest' )
.get(getters.api + '/browse/latest')
.then(response => {
commit('LOADING_STATE', {loading: false, data: response.data})
events.$emit('scrollTop')
@@ -175,7 +177,6 @@ const actions = {
.catch(() => Vue.prototype.$isSomethingWrong())
},
getFolderTree: ({commit, getters}) => {
return new Promise((resolve, reject) => {
// Get route
@@ -204,14 +205,14 @@ const actions = {
}
const mutations = {
UPDATE_FOLDER_TREE(state, tree) {
state.navigation = tree
},
LOADING_STATE(state, payload) {
state.fileInfoDetail= []
state.clipboard = []
state.data = payload.data
state.isLoading = payload.loading
},
UPDATE_FOLDER_TREE(state, tree) {
state.navigation = tree
},
FLUSH_FOLDER_HISTORY(state) {
state.browseHistory = []
},
@@ -227,9 +228,10 @@ const mutations = {
state.browseHistory.pop()
},
CHANGE_ITEM_NAME(state, updatedFile) {
// Rename filename in file info detail
if (state.fileInfoDetail && state.fileInfoDetail.id === updatedFile.id) {
state.fileInfoDetail = updatedFile
// Rename filename in clipboard
if (state.clipboard && state.clipboard.id === updatedFile.id) {
state.clipboard = updatedFile
}
// Rename item name in data view
@@ -241,26 +243,6 @@ const mutations = {
}
})
},
REMOVE_ITEM_FILEINFO_DETAIL(state,item) {
state.fileInfoDetail = state.fileInfoDetail.filter(element => element.id !== item.id)
},
CLEAR_FILEINFO_DETAIL(state) {
state.fileInfoDetail = []
},
LOAD_FILEINFO_DETAIL(state, item) {
state.fileInfoDetail = []
state.fileInfoDetail.push(item)
},
GET_FILEINFO_DETAIL(state, item) {
let selectedItem = state.data.find(el => el.id === item.id)
if(state.fileInfoDetail.includes(selectedItem)) return
state.fileInfoDetail.push(selectedItem ? selectedItem : state.currentFolder)
},
SELECT_ALL_FILES(state){
state.fileInfoDetail = state.data
},
CHANGE_SEARCHING_STATE(state, searchState) {
state.isSearching = searchState
},
@@ -286,10 +268,26 @@ const mutations = {
STORE_CURRENT_FOLDER(state, folder) {
state.currentFolder = folder
},
REMOVE_ITEM_FROM_CLIPBOARD(state, item) {
state.clipboard = state.clipboard.filter(element => element.id !== item.id)
},
ADD_ALL_ITEMS_TO_CLIPBOARD(state) {
state.clipboard = state.data
},
ADD_ITEM_TO_CLIPBOARD(state, item) {
let selectedItem = state.data.find(el => el.id === item.id)
if (state.clipboard.includes(selectedItem)) return
state.clipboard.push(selectedItem ? selectedItem : state.currentFolder)
},
CLIPBOARD_CLEAR(state) {
state.clipboard = []
},
}
const getters = {
fileInfoDetail: state => state.fileInfoDetail,
clipboard: state => state.clipboard,
currentFolder: state => state.currentFolder,
browseHistory: state => state.browseHistory,
isSearching: state => state.isSearching,
+11 -11
View File
@@ -41,7 +41,7 @@ const actions = {
let files = []
// get ids of selected files
getters.fileInfoDetail.forEach(file => files.push(file.id))
getters.clipboard.forEach(file => files.push(file.id))
// Get route
let route = getters.sharedDetail
@@ -71,9 +71,9 @@ const actions = {
let itemsToMove = []
let items = [noSelectedItem]
// If coming no selected item dont get items to move from fileInfoDetail
// If coming no selected item dont get items to move from clipboard
if (!noSelectedItem)
items = getters.fileInfoDetail
items = getters.clipboard
items.forEach(data => itemsToMove.push({
'id': data.id,
@@ -82,7 +82,7 @@ const actions = {
// Remove file preview
if (!noSelectedItem)
commit('CLEAR_FILEINFO_DETAIL')
commit('CLIPBOARD_CLEAR')
// Get route
let route = getters.sharedDetail
@@ -267,9 +267,9 @@ const actions = {
let items = [item]
let restoreToHome = false
// If coming no selected item dont get items to restore from fileInfoDetail
// If coming no selected item dont get items to restore from clipboard
if (!item)
items = getters.fileInfoDetail
items = getters.clipboard
// Check if file can be restored to home directory
if (getters.currentFolder.location === 'trash')
@@ -281,7 +281,7 @@ const actions = {
}))
// Remove file preview
commit('CLEAR_FILEINFO_DETAIL')
commit('CLIPBOARD_CLEAR')
axios
.post(getters.api + '/trash/restore', {
@@ -299,9 +299,9 @@ const actions = {
let itemsToDelete = []
let items = [noSelectedItem]
// If coming no selected item dont get items to move from fileInfoDetail
// If coming no selected item dont get items to move from clipboard
if (!noSelectedItem)
items = getters.fileInfoDetail
items = getters.clipboard
items.forEach(data => {
itemsToDelete.push({
@@ -333,7 +333,7 @@ const actions = {
// Remove file preview
if (!noSelectedItem) {
commit('CLEAR_FILEINFO_DETAIL')
commit('CLIPBOARD_CLEAR')
}
// Get route
@@ -385,7 +385,7 @@ const actions = {
commit('LOADING_STATE', {loading: false, data: []})
events.$emit('scrollTop')
commit('CLEAR_FILEINFO_DETAIL')
commit('CLIPBOARD_CLEAR')
})
.catch(() => Vue.prototype.$isSomethingWrong())
}
+2 -2
View File
@@ -95,7 +95,7 @@ const actions = {
let items = [singleItem]
if(!singleItem) {
items = getters.fileInfoDetail
items = getters.clipboard
}
items.forEach(data => {
@@ -119,7 +119,7 @@ const actions = {
// Flush shared data
commit('FLUSH_SHARED', item.id)
commit('CLEAR_FILEINFO_DETAIL')
commit('CLIPBOARD_CLEAR')
})
resolve(true)
+4 -4
View File
@@ -52,9 +52,9 @@ const actions = {
let addFavourites = []
let items = [folder]
// If dont coming single folder get folders to add to favourites from fileInfoDetail
// If dont coming single folder get folders to add to favourites from clipboard
if (!folder)
items = context.getters.fileInfoDetail
items = context.getters.clipboard
items.forEach((data) => {
if (data.type === 'folder') {
@@ -67,9 +67,9 @@ const actions = {
}
})
// If dont coming single folder clear the selected folders in fileInfoDetail
// If dont coming single folder clear the selected folders in clipboard
if (!folder) {
context.commit('CLEAR_FILEINFO_DETAIL')
context.commit('CLIPBOARD_CLEAR')
}
let pushToFavorites = []