Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix initialization of subcategory dialog fields on first load after page refresh #1953

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions desk/src/pages/knowledge-base/KnowledgeBaseSubcategory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
<div class="space-y-4">
<FormControl
v-model="newSubCategoryName"
:placeholder="subCategory.doc.category_name"
placeholder="Name"
label="Name"
type="text"
/>
<FormControl
v-model="newSubCategoryDescription"
:placeholder="subCategory.doc.description"
placeholder="Description"
label="Description"
type="textarea"
/>
Expand All @@ -80,7 +80,7 @@
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import {
createDocumentResource,
Expand All @@ -91,6 +91,7 @@ import {
FormControl,
} from "frappe-ui";
import { AGENT_PORTAL_KNOWLEDGE_BASE_ARTICLE } from "@/router";
import { createToast } from "@/utils";
import { createListManager } from "@/composables/listManager";
import { useError } from "@/composables/error";
import { ListView } from "@/components";
Expand Down Expand Up @@ -118,10 +119,25 @@ const subCategory = createDocumentResource({
name: props.subCategoryId,
auto: true,
setValue: {
onSuccess() {
createToast({
title: "Subcategory updated",
icon: "check",
iconClasses: "text-green-500",
});
showEdit.value = false;
},
onError: useError({ title: "Error creating sub category" }),
},
});

watch(showEdit, (newValue) => {
if (newValue) {
newSubCategoryName.value = subCategory.doc?.category_name || "";
newSubCategoryDescription.value = subCategory.doc?.description || "";
}
});

const saveSubCategory = debounce(
() =>
subCategory.setValue.submit({
Expand Down
Loading