Skip to content

Commit

Permalink
fix: update display mode when editing context
Browse files Browse the repository at this point in the history
Signed-off-by: Cleopatra Enjeck M. <patrathewhiz@gmail.com>
  • Loading branch information
enjeck committed Dec 13, 2024
1 parent 0e62738 commit 93126f1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/modules/modals/EditContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export default {
isUser: true,
key: 'user-' + getCurrentUser().uid,
})
const displayMode = this.showInNavigation ? 'NAV_ENTRY_MODE_ALL' : 'NAV_ENTRY_MODE_HIDDEN'
const displayMode = this.showInNavigationDefault ? 'NAV_ENTRY_MODE_ALL' : 'NAV_ENTRY_MODE_HIDDEN'
const res = await this.$store.dispatch('updateContext', { id: this.contextId, data, previousReceivers: Object.values(context.sharing), receivers: this.receivers, displayMode: NAV_ENTRY_MODE[displayMode] })
if (res) {
showSuccess(t('tables', 'Updated application "{contextTitle}".', { contextTitle: this.title }))
Expand Down Expand Up @@ -269,7 +269,7 @@ export default {

},
updateDisplayMode() {
this.showInNavigation = !this.showInNavigation
this.showInNavigationDefault = !this.showInNavigationDefault
},
actionTransfer() {
emit('tables:context:edit', null)
Expand Down
5 changes: 1 addition & 4 deletions src/modules/navigation/partials/NavigationContextItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ export default {
},
updateDisplayMode() {
const value = !this.showInNavigation
let displayMode = value ? NAV_ENTRY_MODE.NAV_ENTRY_MODE_RECIPIENTS : NAV_ENTRY_MODE.NAV_ENTRY_MODE_HIDDEN
if (this.ownsContext(this.context)) {
displayMode = value ? NAV_ENTRY_MODE.NAV_ENTRY_MODE_ALL : NAV_ENTRY_MODE.NAV_ENTRY_MODE_HIDDEN
}
const displayMode = value ? NAV_ENTRY_MODE.NAV_ENTRY_MODE_ALL : NAV_ENTRY_MODE.NAV_ENTRY_MODE_HIDDEN
const share = Object.values(this.context.sharing || {}).find(share => share.receiver === getCurrentUser().uid)
if (share) {
this.$store.dispatch('updateDisplayMode', { shareId: share.share_id, displayMode, target: 'self' })
Expand Down
9 changes: 8 additions & 1 deletion src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,11 @@ export default new Vuex.Store({
// Avoid duplicate shares by checking if share exists first
const existingShare = previousReceivers.find((p) => p.receiver === share.receiver && p.receiver_type === share.receiverType)
if (!existingShare) {
await axios.post(generateUrl('/apps/tables/share'), share)
const createdShare = await axios.post(generateUrl('/apps/tables/share'), share)
if (createdShare?.data && createdShare?.data?.id) {
const shareId = createdShare.data.id
await dispatch('updateDisplayMode', { shareId, displayMode, target: 'default' })
}
}
}
} catch (e) {
Expand All @@ -374,6 +378,9 @@ export default new Vuex.Store({
})
if (!currentShare) {
await axios.delete(generateUrl('/apps/tables/share/' + previousReceiver.share_id))
} else {
const shareId = previousReceiver.share_id
await dispatch('updateDisplayMode', { shareId, displayMode, target: 'default' })
}
}
} catch (e) {
Expand Down

0 comments on commit 93126f1

Please sign in to comment.