mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-25 14:14:42 +00:00
api resource refactoring
This commit is contained in:
@@ -311,7 +311,7 @@ export default {
|
||||
|
||||
// Change item name
|
||||
events.$on('change:name', item => {
|
||||
if (this.item.data.id === item.data.id) this.itemName = item.data.attributes.name
|
||||
if (this.item.data.id === item.id) this.itemName = item.name
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="inline-wrapper icon-append copy-input" :class="size">
|
||||
<input ref="sel" :value="item.data.relationships.shared.link" id="link-input" type="text" class="input-text" readonly>
|
||||
<input ref="sel" :value="item.data.relationships.shared.data.attributes.link" id="link-input" type="text" class="input-text" readonly>
|
||||
<div class="multi-icon">
|
||||
<div @click="copyUrl" class="icon-item group hover-bg-theme-100">
|
||||
<link-icon v-if="! isCopiedLink" size="14" class="group-hover-text-theme hover-text-theme"/>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
:subtitle="this.clipboard.length + ' ' + $tc('file_detail.items', this.clipboard.length)"
|
||||
v-if="clipboard.length > 1 && !isSelectedItem" />
|
||||
|
||||
<TreeMenu :disabled-by-id="pickedItem" :depth="1" :nodes="items" v-for="items in navigation" :key="items.data.id" />
|
||||
<TreeMenu :disabled-by-id="pickedItem" :depth="1" :nodes="items" v-for="items in navigation" :key="items.id" />
|
||||
</div>
|
||||
</PopupContent>
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
if (!this.selectedFolder) return
|
||||
|
||||
// Prevent to move items to the same parent
|
||||
if (isArray(this.selectedFolder) && this.clipboard.find(item => item.parent_id === this.selectedFolder.data.id)) return
|
||||
if (isArray(this.selectedFolder) && this.clipboard.find(item => item.parent_id === this.selectedFolder.id)) return
|
||||
|
||||
// Move item
|
||||
if (!this.isSelectedItem) {
|
||||
@@ -110,7 +110,7 @@
|
||||
mounted() {
|
||||
events.$on('pick-folder', folder => {
|
||||
|
||||
if (folder.data.id === this.pickedItem.data.id) {
|
||||
if (folder.id === this.pickedItem.data.id) {
|
||||
this.selectedFolder = undefined
|
||||
|
||||
} else if (!folder.id && folder.location === 'base') {
|
||||
|
||||
@@ -207,7 +207,9 @@ export default {
|
||||
// End loading
|
||||
this.isGeneratedShared = true
|
||||
|
||||
this.$store.commit('UPDATE_SHARED_ITEM', response.data.data.attributes)
|
||||
this.$store.commit('UPDATE_SHARED_ITEM', response.data)
|
||||
|
||||
this.pickedItem.data.relationships.shared = response.data
|
||||
})
|
||||
.catch(() => {
|
||||
events.$emit('alert:open', {
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ActionButton v-if="(pickedItem.data.relationships.shared.protected && canChangePassword) && shareOptions.isProtected" @click.native="changePassword" class="change-password">
|
||||
<ActionButton v-if="(pickedItem.data.relationships.shared.data.attributes.protected && canChangePassword) && shareOptions.isProtected" @click.native="changePassword" class="change-password">
|
||||
{{ $t('popup_share_edit.change_pass') }}
|
||||
</ActionButton>
|
||||
|
||||
@@ -315,11 +315,11 @@
|
||||
|
||||
// Store shared options
|
||||
this.shareOptions = {
|
||||
id: args.item.data.relationships.shared.id,
|
||||
token: args.item.data.relationships.shared.token,
|
||||
expiration: args.item.data.relationships.shared.expire_in,
|
||||
isProtected: args.item.data.relationships.shared.protected,
|
||||
permission: args.item.data.relationships.shared.permission,
|
||||
id: args.item.data.relationships.shared.data.id,
|
||||
token: args.item.data.relationships.shared.data.attributes.token,
|
||||
expiration: args.item.data.relationships.shared.data.attributes.expire_in,
|
||||
isProtected: args.item.data.relationships.shared.data.attributes.protected,
|
||||
permission: args.item.data.relationships.shared.data.attributes.permission,
|
||||
password: undefined,
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@
|
||||
this.sendToRecipientsMenu = true
|
||||
this.isEmailSended = false
|
||||
|
||||
this.canChangePassword = args.item.data.relationships.shared.is_protected
|
||||
this.canChangePassword = args.item.data.relationships.shared.data.attributes.protected
|
||||
})
|
||||
|
||||
events.$on('popup:close', () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<!--Folder Icon-->
|
||||
<div class="folder-item-wrapper" :class="{'is-inactive': disabledById && disabledById.id === nodes.id || !disableId} ">
|
||||
<div class="folder-item-wrapper" :class="{'is-inactive': disabledById && disabledById.data.id === nodes.id || !disableId} ">
|
||||
|
||||
<div class="folder-item text-theme dark-text-theme" :class="{'is-selected': isSelected}" @click="getFolder" :style="indent">
|
||||
<chevron-right-icon @click.stop="showTree" size="17" class="icon-arrow" :class="{'is-opened': isVisible, 'is-visible': nodes.folders.length !== 0}"/>
|
||||
@@ -39,7 +39,7 @@
|
||||
let canBeShow = true
|
||||
if(this.clipboard.includes(this.disabledById)){
|
||||
this.clipboard.map(item => {
|
||||
if(item.id === this.nodes.id) {
|
||||
if(item.data.id === this.nodes.id) {
|
||||
canBeShow = false
|
||||
}
|
||||
})
|
||||
@@ -66,7 +66,7 @@
|
||||
mounted() {
|
||||
|
||||
// Show first location
|
||||
if (this.depth == 1)
|
||||
if (this.depth === 1)
|
||||
this.isVisible = true
|
||||
|
||||
// Select clicked folder
|
||||
|
||||
+3
-8
@@ -160,13 +160,6 @@ const mutations = {
|
||||
})
|
||||
},
|
||||
CHANGE_ITEM_NAME(state, updatedFile) {
|
||||
|
||||
// Rename filename in clipboard
|
||||
if (state.clipboard && state.clipboard.data.id === updatedFile.data.id) {
|
||||
state.clipboard = updatedFile
|
||||
}
|
||||
|
||||
// Rename item name in data view
|
||||
state.entries.find(item => {
|
||||
if (item.data.id === updatedFile.data.id) {
|
||||
item.data.attributes.name = updatedFile.data.attributes.name
|
||||
@@ -177,7 +170,9 @@ const mutations = {
|
||||
},
|
||||
UPDATE_SHARED_ITEM(state, data) {
|
||||
state.entries.find(item => {
|
||||
if (item.data.id === data.item_id) item.shared = data
|
||||
if (item.data.id === data.data.attributes.item_id) {
|
||||
item.data.relationships.shared = data
|
||||
}
|
||||
})
|
||||
},
|
||||
ADD_NEW_FOLDER(state, folder) {
|
||||
|
||||
+7
-7
@@ -60,7 +60,7 @@ const actions = {
|
||||
|
||||
axios
|
||||
.post(route, {
|
||||
to_id: to_item.data.id ? to_item.data.id : null,
|
||||
to_id: to_item.id ? to_item.id : null,
|
||||
items: itemsToMove
|
||||
})
|
||||
.then(() => {
|
||||
@@ -70,7 +70,8 @@ const actions = {
|
||||
|
||||
if (item.type === 'folder')
|
||||
dispatch('getAppData')
|
||||
if (getters.currentFolder.location === 'public')
|
||||
|
||||
if (Vue.prototype.$isThisRoute(router.currentRoute, ['Public']))
|
||||
dispatch('getFolderTree')
|
||||
})
|
||||
})
|
||||
@@ -100,7 +101,7 @@ const actions = {
|
||||
|
||||
// Set focus on new folder name
|
||||
setTimeout(() => {
|
||||
events.$emit('newFolder:focus', response.data.id)
|
||||
events.$emit('newFolder:focus', response.data.data.id)
|
||||
}, 10)
|
||||
|
||||
if (Vue.prototype.$isThisRoute(router.currentRoute, ['Public']))
|
||||
@@ -322,13 +323,12 @@ const actions = {
|
||||
items: itemsToDelete
|
||||
})
|
||||
.then(() => {
|
||||
|
||||
itemsToDelete.forEach(data => {
|
||||
|
||||
// If is folder, update app data
|
||||
if (data.data.type === 'folder') {
|
||||
if (data.type === 'folder') {
|
||||
|
||||
if (data.data.id === getters.currentFolder.data.id) {
|
||||
if (data.id === getters.currentFolder.data.id) {
|
||||
|
||||
if (getters.currentFolder.location === 'public') {
|
||||
dispatch('browseShared')
|
||||
@@ -345,7 +345,7 @@ const actions = {
|
||||
dispatch('getAppData')
|
||||
|
||||
})
|
||||
.catch(() => Vue.prototype.$isSomethingWrong())
|
||||
//.catch(() => Vue.prototype.$isSomethingWrong())
|
||||
},
|
||||
emptyTrash: ({commit, getters}) => {
|
||||
|
||||
|
||||
+5
-5
@@ -77,8 +77,8 @@ const actions = {
|
||||
items = getters.clipboard
|
||||
}
|
||||
|
||||
items.forEach(data => {
|
||||
tokens.push(data.shared.token)
|
||||
items.forEach(item => {
|
||||
tokens.push(item.data.relationships.shared.data.attributes.token)
|
||||
})
|
||||
|
||||
axios
|
||||
@@ -91,12 +91,12 @@ const actions = {
|
||||
items.forEach(item => {
|
||||
|
||||
// Remove item from file browser
|
||||
if ( getters.currentFolder && getters.currentFolder.location === 'shared' ) {
|
||||
commit('REMOVE_ITEM', item.id)
|
||||
if ( getters.currentFolder && Vue.prototype.$isThisRoute(router.currentRoute, ['MySharedItems']) ) {
|
||||
commit('REMOVE_ITEM', item.data.id)
|
||||
}
|
||||
|
||||
// Flush shared data
|
||||
commit('FLUSH_SHARED', item.id)
|
||||
commit('FLUSH_SHARED', item.data.id)
|
||||
commit('CLIPBOARD_CLEAR')
|
||||
})
|
||||
resolve(true)
|
||||
|
||||
+7
-8
@@ -56,14 +56,13 @@ const actions = {
|
||||
if (!folder)
|
||||
items = context.getters.clipboard
|
||||
|
||||
items.forEach((data) => {
|
||||
if (data.type === 'folder') {
|
||||
items.forEach((item) => {
|
||||
|
||||
if (context.getters.user.data.relationships.favourites.data.attributes.folders.find(folder => folder.id === data.id)) return
|
||||
if (item.data.type === 'folder') {
|
||||
|
||||
addFavourites.push({
|
||||
id: data.id
|
||||
})
|
||||
if (context.getters.user.data.relationships.favourites.data.attributes.folders.find(folder => folder.id === item.data.id)) return
|
||||
|
||||
addFavourites.push({id: item.data.id})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -98,7 +97,7 @@ const actions = {
|
||||
commit('REMOVE_ITEM_FROM_FAVOURITES', folder)
|
||||
|
||||
axios
|
||||
.post(getters.api + '/folders/favourites/' + folder.id, {
|
||||
.post(getters.api + '/folders/favourites/' + folder.data.id, {
|
||||
_method: 'delete'
|
||||
})
|
||||
.catch(() => {
|
||||
@@ -136,7 +135,7 @@ const mutations = {
|
||||
state.user.data.relationships.settings.data.attributes.avatar = avatar
|
||||
},
|
||||
REMOVE_ITEM_FROM_FAVOURITES(state, item) {
|
||||
state.user.data.relationships.favourites.data.attributes.folders = state.user.data.relationships.favourites.data.attributes.folders.filter(folder => folder.id !== item.id)
|
||||
state.user.data.relationships.favourites.data.attributes.folders = state.user.data.relationships.favourites.data.attributes.folders.filter(folder => folder.id !== item.data.id)
|
||||
},
|
||||
UPDATE_NAME_IN_FAVOURITES(state, data) {
|
||||
state.user.data.relationships.favourites.data.attributes.folders.find(folder => {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<Option @click.native="$deleteFileOrFolder(item)" :title="$t('context_menu.delete')" icon="trash" />
|
||||
</OptionGroup>
|
||||
<OptionGroup v-if="item">
|
||||
<Option @click.native="$shareFileOrFolder(item)" :title="item.shared ? $t('context_menu.share_edit') : $t('context_menu.share')" icon="share" />
|
||||
<Option @click.native="$shareFileOrFolder(item)" :title="item.data.relationships.shared ? $t('context_menu.share_edit') : $t('context_menu.share')" icon="share" />
|
||||
<Option @click.native="$updateTeamFolder(item)" v-if="isFolder" :title="$t('Convert as Team Folder')" icon="users" />
|
||||
</OptionGroup>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<Option @click.native="$deleteFileOrFolder(item)" :title="$t('context_menu.delete')" icon="trash" />
|
||||
</OptionGroup>
|
||||
<OptionGroup>
|
||||
<Option @click.native="$shareFileOrFolder(item)" :title="item.shared ? $t('context_menu.share_edit') : $t('context_menu.share')" icon="share" />
|
||||
<Option @click.native="$shareFileOrFolder(item)" :title="item.data.relationships.shared ? $t('context_menu.share_edit') : $t('context_menu.share')" icon="share" />
|
||||
<Option @click.native="$updateTeamFolder(item)" v-if="isFolder" :title="$t('Convert as Team Folder')" icon="user-plus" />
|
||||
</OptionGroup>
|
||||
<OptionGroup>
|
||||
@@ -156,10 +156,10 @@
|
||||
return this.user && this.user.data.attributes.storage.used <= 100
|
||||
},
|
||||
isFolder() {
|
||||
return this.item && this.item.type === 'folder'
|
||||
return this.item && this.item.data.type === 'folder'
|
||||
},
|
||||
isInFavourites() {
|
||||
return this.favourites.find((el) => el.data.id === this.item.data.id)
|
||||
return this.favourites.find((el) => el.id === this.item.data.id)
|
||||
},
|
||||
hasFile() {
|
||||
return this.clipboard.find(item => item.data.type !== 'folder')
|
||||
@@ -185,10 +185,7 @@
|
||||
methods: {
|
||||
addToFavourites() {
|
||||
// Check if folder is in favourites and then add/remove from favourites
|
||||
if (
|
||||
this.favourites &&
|
||||
!this.favourites.find(el => el.data.id === this.item.data.id)
|
||||
) {
|
||||
if (this.favourites && !this.favourites.find(el => el.id === this.item.data.id)) {
|
||||
// Add to favourite folder that is not selected
|
||||
if (!this.clipboard.includes(this.item)) {
|
||||
this.$store.dispatch('addToFavourites', this.item)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<Option @click.native="$deleteFileOrFolder(item)" :title="$t('context_menu.delete')" icon="trash" />
|
||||
</OptionGroup>
|
||||
<OptionGroup>
|
||||
<Option @click.native="$shareFileOrFolder(item)" :title="item.shared ? $t('context_menu.share_edit') : $t('context_menu.share')" icon="share" />
|
||||
<Option @click.native="$shareFileOrFolder(item)" :title="item.data.relationships.shared ? $t('context_menu.share_edit') : $t('context_menu.share')" icon="share" />
|
||||
</OptionGroup>
|
||||
<OptionGroup>
|
||||
<Option @click.native="$openInDetailPanel(item)" :title="$t('context_menu.detail')" icon="detail" />
|
||||
@@ -137,10 +137,7 @@
|
||||
methods: {
|
||||
addToFavourites() {
|
||||
// Check if folder is in favourites and then add/remove from favourites
|
||||
if (
|
||||
this.favourites &&
|
||||
!this.favourites.find(el => el.id === this.item.id)
|
||||
) {
|
||||
if (this.favourites && !this.favourites.find(el => el.id === this.item.data.id)) {
|
||||
// Add to favourite folder that is not selected
|
||||
if (!this.clipboard.includes(this.item)) {
|
||||
this.$store.dispatch('addToFavourites', this.item)
|
||||
@@ -153,7 +150,7 @@
|
||||
} else {
|
||||
this.$store.dispatch('removeFromFavourites', this.item)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.$store.dispatch('getMySharedItems')
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<Option @click.native="$deleteFileOrFolder(item)" :title="$t('context_menu.delete')" icon="trash" />
|
||||
</OptionGroup>
|
||||
<OptionGroup>
|
||||
<Option @click.native="$shareFileOrFolder(item)" :title="item.shared ? $t('context_menu.share_edit') : $t('context_menu.share')" icon="share" />
|
||||
<Option @click.native="$shareFileOrFolder(item)" :title="item.data.relationships.shared ? $t('context_menu.share_edit') : $t('context_menu.share')" icon="share" />
|
||||
</OptionGroup>
|
||||
<OptionGroup>
|
||||
<Option @click.native="$openInDetailPanel(item)" :title="$t('context_menu.detail')" icon="detail" />
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<Option @click.native="$deleteFileOrFolder(item)" :title="$t('context_menu.delete')" icon="trash" />
|
||||
</OptionGroup>
|
||||
<OptionGroup v-if="item">
|
||||
<Option @click.native="$shareFileOrFolder(item)" :title="item.shared ? $t('context_menu.share_edit') : $t('context_menu.share')" icon="share" />
|
||||
<Option @click.native="$shareFileOrFolder(item)" :title="item.data.relationships.shared ? $t('context_menu.share_edit') : $t('context_menu.share')" icon="share" />
|
||||
<Option @click.native="$updateTeamFolder(item)" v-if="isFolder" :title="$t('Convert as Team Folder')" icon="users" />
|
||||
</OptionGroup>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<Option @click.native="$deleteFileOrFolder(item)" :title="$t('context_menu.delete')" icon="trash" />
|
||||
</OptionGroup>
|
||||
<OptionGroup>
|
||||
<Option @click.native="$shareFileOrFolder(item)" :title="item.shared ? $t('context_menu.share_edit') : $t('context_menu.share')" icon="share" />
|
||||
<Option @click.native="$shareFileOrFolder(item)" :title="item.data.relationships.shared ? $t('context_menu.share_edit') : $t('context_menu.share')" icon="share" />
|
||||
<Option @click.native="$updateTeamFolder(item)" v-if="isFolder" :title="$t('Edit Team Members')" icon="users" />
|
||||
</OptionGroup>
|
||||
<OptionGroup>
|
||||
@@ -185,10 +185,7 @@
|
||||
methods: {
|
||||
addToFavourites() {
|
||||
// Check if folder is in favourites and then add/remove from favourites
|
||||
if (
|
||||
this.favourites &&
|
||||
!this.favourites.find(el => el.id === this.item.id)
|
||||
) {
|
||||
if (this.favourites && !this.favourites.find(el => el.id === this.item.data.id)) {
|
||||
// Add to favourite folder that is not selected
|
||||
if (!this.clipboard.includes(this.item)) {
|
||||
this.$store.dispatch('addToFavourites', this.item)
|
||||
@@ -202,6 +199,7 @@
|
||||
this.$store.dispatch('removeFromFavourites', this.item)
|
||||
}
|
||||
},
|
||||
},
|
||||
createFolder() {
|
||||
events.$emit('popup:open', {name: 'create-folder'})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user