Skip to content

Commit

Permalink
added unarchive action button and archive/unarchive logic
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
  • Loading branch information
elzody committed Feb 26, 2024
1 parent 713e19d commit 93e5776
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions src/modules/navigation/partials/NavigationTableItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,27 @@
<Connection :size="20" />
</template>
</NcActionButton>
<NcActionButton v-if="canManageElement(table)"

<!-- ARCHIVE -->
<NcActionButton v-if="canManageElement(table) && !table.archived"
:close-after-click="true"
@click="archiveTable">
@click="toggleArchiveTable(true)">
{{ t('tables', 'Archive table') }}
<template #icon>
<ArchiveArrowDown :size="20" />
</template>
</NcActionButton>

<!-- UNARCHIVE -->
<NcActionButton v-if="canManageElement(table) && table.archived"
:close-after-click="true"
@click="toggleArchiveTable(false)">
{{ t('tables', 'Unarchive table') }}
<template #icon>
<ArchiveArrowUpOutline :size="20" />
</template>
</NcActionButton>

<NcActionButton v-if="canManageElement(table)"
icon="icon-delete"
:close-after-click="true"
Expand All @@ -94,6 +107,7 @@ import { mapGetters, mapState } from 'vuex'
import { emit } from '@nextcloud/event-bus'
import Table from 'vue-material-design-icons/Table.vue'
import ArchiveArrowDown from 'vue-material-design-icons/ArchiveArrowDown.vue'
import ArchiveArrowUpOutline from 'vue-material-design-icons/ArchiveArrowUpOutline.vue'
import permissionsMixin from '../../../shared/components/ncTable/mixins/permissionsMixin.js'
import { getCurrentUser } from '@nextcloud/auth'
import Connection from 'vue-material-design-icons/Connection.vue'
Expand All @@ -109,6 +123,7 @@ export default {
// eslint-disable-next-line vue/no-reserved-component-names
Table,
ArchiveArrowDown,
ArchiveArrowUpOutline,
Import,
NavigationViewItem,
NcActionButton,
Expand Down Expand Up @@ -204,9 +219,17 @@ export default {
})
}
},
archiveTable() {
async toggleArchiveTable(archived) {
const res = await this.$store.dispatch('updateTable', {
id: this.table.id,
data: { archived },
})
// eslint-disable-next-line no-console
if (!res) { console.log('failed to archive/unarchive table') }
// eslint-disable-next-line no-console
console.log(this.table)
console.log('archived/unarchived table')
},
},
Expand Down

0 comments on commit 93e5776

Please sign in to comment.