|
| 1 | +<template> |
| 2 | + <card-base |
| 3 | + :title="title" |
| 4 | + :description="description" |
| 5 | + docs="/collections/tags/"> |
| 6 | + |
| 7 | + <p slot="guidance"> |
| 8 | + Use the table below to delete tags. Note that the same word may be used |
| 9 | + to tag multiple items and therefore could appear multiple times in the |
| 10 | + table below, you can use the search button above to filter the |
| 11 | + table. |
| 12 | + </p> |
| 13 | + |
| 14 | + <b-form slot="controls" :class="darkMode ? 'form-dark' : null"> |
| 15 | + <b-form-input |
| 16 | + v-model="searchString" |
| 17 | + class="search-control" |
| 18 | + size="sm" |
| 19 | + placeholder="Type to search"> |
| 20 | + </b-form-input> |
| 21 | + </b-form> |
| 22 | + |
| 23 | + <b-table |
| 24 | + responsive |
| 25 | + striped |
| 26 | + hover |
| 27 | + show-empty |
| 28 | + :dark="darkMode" |
| 29 | + :items="tagAnnotations" |
| 30 | + :fields="tableFields"> |
| 31 | + <template slot="action" slot-scope="row"> |
| 32 | + <b-btn |
| 33 | + variant="warning" |
| 34 | + size="sm" |
| 35 | + @click="deleteTag(row.item)"> |
| 36 | + Delete |
| 37 | + </b-btn> |
| 38 | + </template> |
| 39 | + </b-table> |
| 40 | + |
| 41 | + <infinite-load-annotations |
| 42 | + ref="infiniteload" |
| 43 | + v-if="hasTagAnnotations" |
| 44 | + v-model="tagAnnotations" |
| 45 | + :search-keys="searchKeys" |
| 46 | + :search-string="searchString" |
| 47 | + :container-iri="currentCollection.info.annotations.tags" |
| 48 | + no-results="It looks like nothing has been tagged yet!" |
| 49 | + no-more-results=""> |
| 50 | + </infinite-load-annotations> |
| 51 | + |
| 52 | + </card-base> |
| 53 | +</template> |
| 54 | + |
| 55 | +<script> |
| 56 | +import { fetchCollectionByName } from '@/mixins/fetchCollectionByName' |
| 57 | +import { metaTags } from '@/mixins/metaTags' |
| 58 | +import InfiniteLoadAnnotations from '@/components/infiniteload/Annotations' |
| 59 | +import CardBase from '@/components/cards/Base' |
| 60 | +
|
| 61 | +export default { |
| 62 | + layout: 'admin-collection-dashboard', |
| 63 | +
|
| 64 | + mixins: [ fetchCollectionByName, metaTags ], |
| 65 | +
|
| 66 | + data () { |
| 67 | + return { |
| 68 | + title: 'Item Tags', |
| 69 | + description: 'Manage item tags for the collection microsite.', |
| 70 | + tagAnnotations: [], |
| 71 | + tableFields: { |
| 72 | + 'body.value': { |
| 73 | + label: 'Name' |
| 74 | + }, |
| 75 | + action: { |
| 76 | + label: 'Action', |
| 77 | + class: 'text-center' |
| 78 | + } |
| 79 | + }, |
| 80 | + searchKeys: [ |
| 81 | + 'body.value' |
| 82 | + ], |
| 83 | + searchString: '' |
| 84 | + } |
| 85 | + }, |
| 86 | +
|
| 87 | + components: { |
| 88 | + CardBase, |
| 89 | + InfiniteLoadAnnotations |
| 90 | + }, |
| 91 | +
|
| 92 | + computed: { |
| 93 | + currentCollection () { |
| 94 | + return this.$store.state.currentCollection |
| 95 | + }, |
| 96 | +
|
| 97 | + hasTagAnnotations () { |
| 98 | + return this.currentCollection.info.annotations.hasOwnProperty('tags') |
| 99 | + } |
| 100 | + }, |
| 101 | +
|
| 102 | + methods: { |
| 103 | + /** |
| 104 | + * Delete a tag. |
| 105 | + * @param {Object} |
| 106 | + * The tag. |
| 107 | + */ |
| 108 | + deleteTag (tag) { |
| 109 | + this.$swal({ |
| 110 | + title: `Confirm`, |
| 111 | + html: `This tag will be removed permanently.<br><br> |
| 112 | + Are you sure you want to continue?`, |
| 113 | + type: 'question', |
| 114 | + showCancelButton: true, |
| 115 | + reverseButtons: true, |
| 116 | + showLoaderOnConfirm: true, |
| 117 | + preConfirm: () => { |
| 118 | + return this.$axios.$delete(tag.id) |
| 119 | + } |
| 120 | + }).then(r => { |
| 121 | + this.reset() |
| 122 | + this.$notifications.success({ |
| 123 | + message: 'Tag deleted' |
| 124 | + }) |
| 125 | + }).catch(err => { |
| 126 | + if (typeof err === 'object' && err.hasOwnProperty('dismiss')) { |
| 127 | + this.$notifications.error({ message: err.message }) |
| 128 | + } |
| 129 | + }) |
| 130 | + }, |
| 131 | +
|
| 132 | + /** |
| 133 | + * Reset the loaded items. |
| 134 | + */ |
| 135 | + reset () { |
| 136 | + this.$refs.infiniteload.reset() |
| 137 | + } |
| 138 | + } |
| 139 | +} |
| 140 | +</script> |
0 commit comments