Просмотр исходного кода

feat: add student search term handling and initial name prop to AddEditStudentDialog

alvesantos 2 недель назад
Родитель
Сommit
e947a044bb

+ 6 - 0
src/pages/students/components/AddEditContractDialog.vue

@@ -632,6 +632,7 @@ const packages = ref([]);
 const restoringDefaultDates = ref(false);
 const selectedStudent = ref(props.student);
 const students = ref([]);
+const studentSearchTerm = ref("");
 const syncingFromDate = ref(false);
 const syncingFromDay = ref(false);
 const unitDetails = ref(store.selectedUnit ?? {});
@@ -980,6 +981,8 @@ const calculateEndTime = (startTime, durationMinutes = 120) => {
 };
 
 const filterStudents = (value, update) => {
+  studentSearchTerm.value = value.trim();
+
   update(() => {
     const search = value.trim().toLocaleLowerCase("pt-BR");
 
@@ -1064,6 +1067,9 @@ const handleSave = async () => {
 const openCreateStudent = () => {
   $q.dialog({
     component: AddEditStudentDialog,
+    componentProps: {
+      initialName: studentSearchTerm.value || null,
+    },
   }).onOk(async (createdStudent) => {
     const unitStudents = await getStudentsForSelect();
 

+ 8 - 1
src/pages/students/components/AddEditStudentDialog.vue

@@ -510,6 +510,13 @@ import CustomTabComponent from "src/components/shared/CustomTabComponent.vue";
 
 defineEmits([...useDialogPluginComponent.emits]);
 
+const props = defineProps({
+  initialName: {
+    type: String,
+    default: null,
+  },
+});
+
 const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } =
   useDialogPluginComponent();
 
@@ -551,7 +558,7 @@ const form = ref({
   email: null,
   gender: "no_preference",
   how_found: null,
-  name: null,
+  name: props.initialName || null,
   neighborhood: null,
   notes: null,
   payer: null,