Skip to content

Commit

Permalink
Bind api endpoint directly to call
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianallgeier committed Nov 15, 2024
1 parent 22fd88f commit ebafb7f
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions panel/src/components/Views/ModelView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,6 @@ export default {
return [];
}
},
watch: {
// watch for view changes and
// trigger saving for changes that where
// not sent to the server yet
api() {
if (this.isSaved === false) {
this.save();
}
}
},
mounted() {
// create a delayed version of save
// that we can use in the input event
Expand All @@ -109,15 +99,21 @@ export default {
this.$events.off("view.save", this.onSave);
},
methods: {
async save() {
async save(api, values) {
if (this.isLocked === true) {
return false;
}
await this.$panel.content.save(this.api, this.content);
await this.$panel.content.save(api, values);
// update the last modification timestamp
this.$panel.view.props.lock.modified = new Date();
// if the view hasn't changed in the meantime,
// in which case the correct timestamp will come
// from the server
if (api === this.api) {
this.$panel.view.props.lock.modified = new Date();
}
this.isSaved = true;
},
onBeforeUnload(e) {
Expand All @@ -141,7 +137,7 @@ export default {
}
this.update(values);
this.autosave();
this.autosave(this.api, values);
},
onSave(e) {
e?.preventDefault?.();
Expand Down

0 comments on commit ebafb7f

Please sign in to comment.