3
0

Adjust how prompts are handled on FE

This commit is contained in:
Jože Fortun 2024-12-18 13:05:51 +01:00
parent 8fc97c60e2
commit 06831c0df6
4 changed files with 16 additions and 26 deletions

View File

@ -145,11 +145,6 @@ export default {
stepID, stepID,
input, input,
}) })
.then(() => {
setTimeout(() => {
this.$store.dispatch('wfPrompts/update')
}, 500)
})
.catch(this.toastErrorHandler(this.$t('notification:automation.scriptFailed'))) .catch(this.toastErrorHandler(this.$t('notification:automation.scriptFailed')))
.finally(() => { .finally(() => {
this.processing = false this.processing = false

View File

@ -1,7 +1,7 @@
// This mixin is used on View component of Records. // This mixin is used on View component of Records.
import { compose, validator, NoID } from '@cortezaproject/corteza-js' import { compose, validator, NoID } from '@cortezaproject/corteza-js'
import { mapGetters, mapActions } from 'vuex' import { mapGetters } from 'vuex'
import { throttle } from 'lodash' import { throttle } from 'lodash'
export default { export default {
@ -66,10 +66,6 @@ export default {
}, },
methods: { methods: {
...mapActions({
updatePrompts: 'wfPrompts/update',
}),
/** /**
* Handle form submit for record create & update * Handle form submit for record create & update
* *
@ -170,7 +166,6 @@ export default {
record = new compose.Record(this.module, r) record = new compose.Record(this.module, r)
}) })
.then(() => this.dispatchUiEvent('afterFormSubmit', record, { $records: records })) .then(() => this.dispatchUiEvent('afterFormSubmit', record, { $records: records }))
.then(() => this.updatePrompts())
.then(() => { .then(() => {
if (record.valueErrors.set) { if (record.valueErrors.set) {
throw new Error(this.toastWarning(this.$t('notification:record.validationWarnings'))) throw new Error(this.toastWarning(this.$t('notification:record.validationWarnings')))
@ -239,7 +234,6 @@ export default {
record = new compose.Record(this.module, r) record = new compose.Record(this.module, r)
}) })
.then(() => this.dispatchUiEvent('afterFormSubmit', record)) .then(() => this.dispatchUiEvent('afterFormSubmit', record))
.then(() => this.updatePrompts())
.then(() => { .then(() => {
if (this.record.valueErrors.set) { if (this.record.valueErrors.set) {
this.toastWarning(this.$t('notification:record.validationWarnings')) this.toastWarning(this.$t('notification:record.validationWarnings'))
@ -272,7 +266,6 @@ export default {
.dispatchUiEvent('beforeDelete') .dispatchUiEvent('beforeDelete')
.then(() => this.$ComposeAPI.recordDelete(this.record)) .then(() => this.$ComposeAPI.recordDelete(this.record))
.then(this.dispatchUiEvent('afterDelete')) .then(this.dispatchUiEvent('afterDelete'))
.then(this.updatePrompts())
.then(() => { .then(() => {
this.record = undefined this.record = undefined
this.initialRecordState = undefined this.initialRecordState = undefined
@ -293,7 +286,6 @@ export default {
.dispatchUiEvent('beforeUndelete') .dispatchUiEvent('beforeUndelete')
.then(() => this.$ComposeAPI.recordUndelete(this.record)) .then(() => this.$ComposeAPI.recordUndelete(this.record))
.then(this.dispatchUiEvent('afterUndelete')) .then(this.dispatchUiEvent('afterUndelete'))
.then(this.updatePrompts())
.then(() => { .then(() => {
this.record = undefined this.record = undefined
this.initialRecordState = undefined this.initialRecordState = undefined
@ -338,7 +330,6 @@ export default {
throw err throw err
}) })
.then(this.updatePrompts())
.then(() => { .then(() => {
this.toastSuccess(this.$t('notification:record.bulkRecordUpdateSuccess')) this.toastSuccess(this.$t('notification:record.bulkRecordUpdateSuccess'))
this.onModalHide() this.onModalHide()

View File

@ -36,12 +36,13 @@ export default {
props: { props: {
hideToasts: { hideToasts: {
type: Boolean, type: Boolean,
default: false,
}, },
}, },
data () { data () {
return { return {
passive: new Set(), passive: [],
hasFocus: null, hasFocus: null,
hasFocusObserver: 0, hasFocusObserver: 0,
@ -96,7 +97,7 @@ export default {
*/ */
toasts () { toasts () {
return this.hideToasts ? [] : [ return this.hideToasts ? [] : [
...this.passive.values(), ...this.passive,
...this.active ...this.active
] ]
}, },
@ -128,8 +129,8 @@ export default {
immediate: true, immediate: true,
handler (wc) { handler (wc) {
wc.forEach(p => { wc.forEach(p => {
if (p.passive) { if (p.passive && !this.passive.some(({ prompt }) => prompt.stateID === p.prompt.stateID)) {
this.passive.add(p) this.passive.push(p)
} }
}) })
}, },
@ -161,10 +162,14 @@ export default {
this.resume(values) this.resume(values)
}, },
onToastHide ({ prompt, passive}) { onToastHide ({ prompt, passive }) {
if (passive) return setTimeout(() => {
if (passive) {
this.cancel(prompt) this.passive = this.passive.filter(({ prompt: p }) => p.stateID !== prompt.stateID)
} else {
this.cancel(prompt)
}
}, 300)
}, },
pVal (prompt, k, def = undefined) { pVal (prompt, k, def = undefined) {

View File

@ -1,8 +1,6 @@
<template> <template>
<div> <div>
<c-prompt-toast <c-prompt-toast :hide-toasts="hideToasts" />
:hide-toasts="hideToasts"
/>
<c-prompt-modal /> <c-prompt-modal />
</div> </div>
</template> </template>
@ -29,6 +27,7 @@ export default {
props: { props: {
hideToasts: { hideToasts: {
type: Boolean, type: Boolean,
default: false,
}, },
}, },
} }