Skip to content

Commit

Permalink
Transformation edit: Improve dirty handling & Fix settings styling
Browse files Browse the repository at this point in the history
Only mark the transformation as dirty if there was an actual change,
not only an editor input.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
  • Loading branch information
florian-h05 committed Sep 16, 2024
1 parent 6678728 commit 3052801
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
</f7-link>
</div>
</f7-toolbar>
<transformation-general-settings :createMode="createMode" :transformation="transformation" />
<f7-block class="block-narrow">
<transformation-general-settings :createMode="createMode" :transformation="transformation" />
<f7-col>
<f7-list v-if="isEditable">
<f7-list-button color="red" @click="deleteTransformation">
Expand All @@ -86,6 +86,9 @@
</style>

<script>
import cloneDeep from 'lodash/cloneDeep'
import fastDeepEqual from 'fast-deep-equal/es6'
import DirtyMixin from '../dirty-mixin'
import TransformationGeneralSettings from '@/pages/settings/transformations/transformation-general-settings'
import { CodeSnippets, EditorModes } from '@/assets/definitions/transformations.js'
Expand All @@ -105,6 +108,7 @@ export default {
ready: false,
loading: false,
transformation: {},
savedTransformation: {},
types: [],
languages: [],
language: '',
Expand All @@ -113,6 +117,16 @@ export default {
blocklyCodePreview: false
}
},
watch: {
transformation: {
handler: function () {
if (!this.loading) { // ignore changes during loading
this.dirty = !fastDeepEqual(this.transformation, this.savedTransformation)
}
},
deep: true
}
},
computed: {
isEditable () {
return this.transformation && this.transformation.editable !== false
Expand Down Expand Up @@ -201,6 +215,7 @@ export default {
this.$oh.api.get('/rest/transformations/' + this.transformationId).then((data) => {
this.$set(this, 'transformation', data)
this.savedTransformation = cloneDeep(this.transformation)
this.editorMode = EditorModes[this.transformation.type.toLowerCase()] || this.transformation.type
this.loading = false
this.ready = true
Expand All @@ -219,6 +234,7 @@ export default {
}
return this.$oh.api.put('/rest/transformations/' + this.transformation.uid, this.transformation).then((data) => {
this.dirty = false
this.savedTransformation = cloneDeep(this.transformation)
if (!noToast) {
this.$f7.toast.create({
text: 'Transformation updated',
Expand Down Expand Up @@ -261,7 +277,6 @@ export default {
},
onEditorInput (value) {
this.transformation.configuration.function = value
this.dirty = true
},
keyDown (ev) {
if ((ev.ctrlKey || ev.metaKey) && !(ev.altKey || ev.shiftKey)) {
Expand Down

0 comments on commit 3052801

Please sign in to comment.