Skip to content

Commit

Permalink
feat(#378): Adding logic to enable both submitter and admin to edit n…
Browse files Browse the repository at this point in the history
…ewly curated xml
  • Loading branch information
tholulomo committed Oct 7, 2023
1 parent bd4d868 commit 3176bc2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
17 changes: 16 additions & 1 deletion app/src/pages/explorer/xml/Xml.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@

<template v-if="!!Object.keys(xmlFinder).length && !!xmlFinder.xmlData.length">
<md-card v-for="(xml, index) in xmlFinder.xmlData" :key="index" class="btn--animated gallery-item">
<router-link :to="{ name: 'XmlVisualizer', params: { id: xml.id }}">
<div class="u_gridicon">
<div v-if="isAuth && (xml.user === userId || isAdmin)" @click.prevent="editCuration(xml.id, xml.isNewCuration)">
<md-tooltip md-direction="top">Edit Curation</md-tooltip>
<md-icon>edit</md-icon>
</div>
</div>
<router-link :to="{ name: 'XmlVisualizer', params: { id: xml.id }, query: { isNewCuration: xml.isNewCuration}}">
<md-card-media-cover md-solid>
<md-card-media md-ratio="4:3">
<md-icon class="explorer_page-nav-card_icon u_margin-top-small">code_off</md-icon>
Expand Down Expand Up @@ -99,6 +105,7 @@ import pagination from '@/components/explorer/Pagination'
import { XML_FINDER } from '../../../modules/gql/xml-gql'
import explorerQueryParams from '@/mixins/explorerQueryParams'
import SearchGallery from '@/components/XmlSearchUtil'
import { mapGetters } from 'vuex'
export default {
name: 'XmlGallery',
data () {
Expand All @@ -125,6 +132,11 @@ export default {
pagination
},
computed: {
...mapGetters({
isAuth: 'auth/isAuthenticated',
isAdmin: 'auth/isAdmin',
userId: 'auth/userId'
}),
isEmpty () {
if (this.xmlFinder.length === 0 || !Object.keys(this.xmlFinder).length || this.xmlFinder.totalItems === 0) return true
return false
Expand Down Expand Up @@ -164,6 +176,9 @@ export default {
this.filterParams = {}
await this.resetSearch(type)
},
editCuration (id, isNew) {
this.$router.push({ name: 'EditXmlCuration', query: { isNew: isNew, id: id } })
},
selectFilters (e) {
const value = e.target.value
const arrValue = value.split('::')
Expand Down
19 changes: 13 additions & 6 deletions app/src/pages/explorer/xml/XmlLoader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
<md-icon>comment</md-icon>
</md-button>

<md-button @click.prevent="editCuration(xmlViewer.id, xmlViewer.isNewCuration)"
v-if="isAuth && (xmlViewer.user === userId || isAdmin)" class="md-fab md-dense md-primary btn--primary ">
<md-tooltip md-direction="top">Edit Curation</md-tooltip>
<md-icon>edit</md-icon>
</md-button>

<md-button @click="approveCuration" v-if="isAuth && isAdmin" class="md-fab md-dense md-primary btn--primary ">
<md-tooltip md-direction="top">Approve</md-tooltip>
<md-icon>check</md-icon>
Expand Down Expand Up @@ -75,13 +81,11 @@ export default {
computed: {
...mapGetters({
isAuth: 'auth/isAuthenticated',
isAdmin: 'auth/isAdmin'
isAdmin: 'auth/isAdmin',
userId: 'auth/userId'
}),
isSmallTabView () {
return screen.width < 760
},
isNewCuration () {
return this.$route?.query?.isNewCuration === 'true'
}
},
methods: {
Expand All @@ -93,6 +97,9 @@ export default {
},
navBack () {
this.$router.back()
},
editCuration (id, isNew) {
if (!!id && typeof isNew === 'boolean') return this.$router.push({ name: 'EditXmlCuration', query: { isNew: isNew, id: id } })
}
},
mounted () {
Expand All @@ -107,11 +114,11 @@ export default {
return {
input: {
id: this.$route.params.id,
isNewCuration: this.isNewCuration
isNewCuration: this.$route?.query?.isNewCuration ? JSON.parse(this.$route?.query?.isNewCuration) : false
}
}
},
fetchPolicy: 'cache-and-network',
fetchPolicy: 'network-only',
error (error) {
if (error.networkError) {
const err = error.networkError
Expand Down

0 comments on commit 3176bc2

Please sign in to comment.