Skip to content

Commit

Permalink
Adjust how prompts are handled on FE
Browse files Browse the repository at this point in the history
  • Loading branch information
Fajfa committed Dec 18, 2024
1 parent 8fc97c6 commit 06831c0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,6 @@ export default {
stepID,
input,
})
.then(() => {
setTimeout(() => {
this.$store.dispatch('wfPrompts/update')
}, 500)
})
.catch(this.toastErrorHandler(this.$t('notification:automation.scriptFailed')))
.finally(() => {
this.processing = false
Expand Down
11 changes: 1 addition & 10 deletions client/web/compose/src/mixins/record.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This mixin is used on View component of Records.

import { compose, validator, NoID } from '@cortezaproject/corteza-js'
import { mapGetters, mapActions } from 'vuex'
import { mapGetters } from 'vuex'
import { throttle } from 'lodash'

export default {
Expand Down Expand Up @@ -66,10 +66,6 @@ export default {
},

methods: {
...mapActions({
updatePrompts: 'wfPrompts/update',
}),

/**
* Handle form submit for record create & update
*
Expand Down Expand Up @@ -170,7 +166,6 @@ export default {
record = new compose.Record(this.module, r)
})
.then(() => this.dispatchUiEvent('afterFormSubmit', record, { $records: records }))
.then(() => this.updatePrompts())
.then(() => {
if (record.valueErrors.set) {
throw new Error(this.toastWarning(this.$t('notification:record.validationWarnings')))
Expand Down Expand Up @@ -239,7 +234,6 @@ export default {
record = new compose.Record(this.module, r)
})
.then(() => this.dispatchUiEvent('afterFormSubmit', record))
.then(() => this.updatePrompts())
.then(() => {
if (this.record.valueErrors.set) {
this.toastWarning(this.$t('notification:record.validationWarnings'))
Expand Down Expand Up @@ -272,7 +266,6 @@ export default {
.dispatchUiEvent('beforeDelete')
.then(() => this.$ComposeAPI.recordDelete(this.record))
.then(this.dispatchUiEvent('afterDelete'))
.then(this.updatePrompts())
.then(() => {
this.record = undefined
this.initialRecordState = undefined
Expand All @@ -293,7 +286,6 @@ export default {
.dispatchUiEvent('beforeUndelete')
.then(() => this.$ComposeAPI.recordUndelete(this.record))
.then(this.dispatchUiEvent('afterUndelete'))
.then(this.updatePrompts())
.then(() => {
this.record = undefined
this.initialRecordState = undefined
Expand Down Expand Up @@ -338,7 +330,6 @@ export default {

throw err
})
.then(this.updatePrompts())
.then(() => {
this.toastSuccess(this.$t('notification:record.bulkRecordUpdateSuccess'))
this.onModalHide()
Expand Down
21 changes: 13 additions & 8 deletions lib/vue/src/components/prompts/CPromptToast.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ export default {
props: {
hideToasts: {
type: Boolean,
default: false,
},
},
data () {
return {
passive: new Set(),
passive: [],
hasFocus: null,
hasFocusObserver: 0,
Expand Down Expand Up @@ -96,7 +97,7 @@ export default {
*/
toasts () {
return this.hideToasts ? [] : [
...this.passive.values(),
...this.passive,
...this.active
]
},
Expand Down Expand Up @@ -128,8 +129,8 @@ export default {
immediate: true,
handler (wc) {
wc.forEach(p => {
if (p.passive) {
this.passive.add(p)
if (p.passive && !this.passive.some(({ prompt }) => prompt.stateID === p.prompt.stateID)) {
this.passive.push(p)
}
})
},
Expand Down Expand Up @@ -161,10 +162,14 @@ export default {
this.resume(values)
},
onToastHide ({ prompt, passive}) {
if (passive) return
this.cancel(prompt)
onToastHide ({ prompt, passive }) {
setTimeout(() => {
if (passive) {
this.passive = this.passive.filter(({ prompt: p }) => p.stateID !== prompt.stateID)
} else {
this.cancel(prompt)
}
}, 300)
},
pVal (prompt, k, def = undefined) {
Expand Down
5 changes: 2 additions & 3 deletions lib/vue/src/components/prompts/CPrompts.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<template>
<div>
<c-prompt-toast
:hide-toasts="hideToasts"
/>
<c-prompt-toast :hide-toasts="hideToasts" />
<c-prompt-modal />
</div>
</template>
Expand All @@ -29,6 +27,7 @@ export default {
props: {
hideToasts: {
type: Boolean,
default: false,
},
},
}
Expand Down

0 comments on commit 06831c0

Please sign in to comment.