@click="saveRule">
{{ ruleStatus.title }}
</button>
- <button v-if="rule.id < -1" @click="cancelRule">
+ <button v-if="rule.id < -1 || dirty" @click="cancelRule">
{{ t('workflowengine', 'Cancel') }}
</button>
- <button v-else @click="deleteRule">
+ <button v-else-if="!dirty" @click="deleteRule">
{{ t('workflowengine', 'Delete') }}
</button>
</div>
checks: [],
error: null,
dirty: this.rule.id < 0,
- checking: false
+ checking: false,
+ originalRule: null
}
},
computed: {
return typeof lastCheck === 'undefined' || lastCheck.class !== null
}
},
+ mounted() {
+ this.originalRule = JSON.parse(JSON.stringify(this.rule))
+ },
methods: {
async updateOperation(operation) {
this.$set(this.rule, 'operation', operation)
await this.$store.dispatch('pushUpdateRule', this.rule)
this.dirty = false
this.error = null
+ this.originalRule = JSON.parse(JSON.stringify(this.rule))
} catch (e) {
console.error('Failed to save operation')
this.error = e.response.data.ocs.meta.message
}
},
cancelRule() {
- this.$store.dispatch('removeRule', this.rule)
+ if (this.rule.id < 0) {
+ this.$store.dispatch('removeRule', this.rule)
+ } else {
+ this.$store.dispatch('updateRule', this.originalRule)
+ this.originalRule = JSON.parse(JSON.stringify(this.rule))
+ this.dirty = false
+ }
},
async removeCheck(check) {
const index = this.rule.checks.findIndex(item => item === check)