Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Let TaskContent emit update-content and thus centralize the place to patch task

Tianzhou Chen02adf65526dd
diff --git a/frontend/src/views/TaskContent.vue b/frontend/src/views/TaskContent.vue
index 22499d8799..235c1bcdbc 100644
--- a/frontend/src/views/TaskContent.vue
+++ b/frontend/src/views/TaskContent.vue
@@ -74,7 +74,6 @@
<script lang="ts">
import { nextTick, onMounted, onUnmounted, PropType, ref, reactive } from "vue";
-import { useStore } from "vuex";
import { Task } from "../types";
import { sizeToFit } from "../utils";
@@ -84,6 +83,7 @@ interface LocalState {
export default {
name: "TaskContent",
+ emits: ["update-content"],
props: {
task: {
required: true,
@@ -91,8 +91,7 @@ export default {
},
},
components: {},
- setup(props, ctx) {
- const store = useStore();
+ setup(props, { emit }) {
const editContent = ref(props.task.attributes.content);
const editContentTextArea = ref();
@@ -130,23 +129,13 @@ export default {
};
const saveEdit = () => {
- store
- .dispatch("task/patchTask", {
- taskId: props.task.id,
- taskPatch: {
- content: editContent.value,
- },
- })
- .then((updatedTask: Task) => {
- state.edit = false;
- editContent.value = updatedTask.attributes.content;
- nextTick(() => {
- sizeToFit(editContentTextArea.value);
- });
- })
- .catch((error) => {
- console.log(error);
+ emit("update-content", editContent.value, (updatedTask: Task) => {
+ state.edit = false;
+ editContent.value = updatedTask.attributes.content;
+ nextTick(() => {
+ sizeToFit(editContentTextArea.value);
});
+ });
};
const cancelEdit = () => {
diff --git a/frontend/src/views/TaskDetail.vue b/frontend/src/views/TaskDetail.vue
index 5393e7f6e1..87880b8fbf 100644
--- a/frontend/src/views/TaskDetail.vue
+++ b/frontend/src/views/TaskDetail.vue
@@ -71,7 +71,7 @@
@update-custom-field="updateCustomField"
/>
<div class="lg:hidden my-4 border-t border-block-border" />
- <TaskContent :task="state.task" />
+ <TaskContent :task="state.task" @update-content="updateContent" />
</div>
<section
v-if="!state.new"
@@ -318,6 +318,18 @@ export default {
document.getElementById("task-detail-top")!.scrollIntoView();
});
+ const updateContent = (
+ newContent: string,
+ postUpdated: (updatedTask: Task) => void
+ ) => {
+ patchTask(
+ {
+ content: newContent,
+ },
+ postUpdated
+ );
+ };
+
const updateTaskStatus = (newStatus: TaskStatus) => {
// if (newStatus === "DONE") {
// if (template.fieldList) {
@@ -361,7 +373,10 @@ export default {
});
};
- const patchTask = (taskPatch: TaskPatch) => {
+ const patchTask = (
+ taskPatch: TaskPatch,
+ postUpdated?: (updatedTask: Task) => void
+ ) => {
store
.dispatch("task/patchTask", {
taskId: (state.task as Task).id,
@@ -373,7 +388,11 @@ export default {
},
},
})
- .then((updatedTask) => {})
+ .then((updatedTask) => {
+ if (postUpdated) {
+ postUpdated(updatedTask);
+ }
+ })
.catch((error) => {
console.log(error);
});
@@ -457,6 +476,7 @@ export default {
return {
state,
modalState,
+ updateContent,
updateTaskStatus,
updateCustomField,
doCreate,