Repository navigation
add Student Event Report create form with dynamic fields - #81
Conversation
| <Resource name="grade" {...grade} options={{ menuGroup: 'data' }} icon={GradingIcon} /> | ||
| <Resource name="known_absence" {...knownAbsence} options={{ menuGroup: 'data' }} icon={PlaylistRemoveIcon} /> | ||
|
|
||
| {(isStudentView(permissions) || isAdmin(permissions)) && <Resource name="student_event_report" {...studentEventReport} options={{ menuGroup: 'data' }} icon={EventNoteIcon} />} |
There was a problem hiding this comment.
this is not a resource, but a regular page, like in-lesson-report, for example
…d-in student in the report form.
buzz-code
left a comment
There was a problem hiding this comment.
great great work! several small comments
| student_event_report: { | ||
| name: 'דיווח אירוע לתלמידה', | ||
| fields: { | ||
| ...generalResourceFieldsTranslation, | ||
| studentReferenceId: 'תלמידה', | ||
| klassReferenceId: 'כיתה', | ||
| absenceTypeId: 'סוג אירוע', | ||
| reportDate: 'תאריך', | ||
| absnceCount: 'כמות', | ||
| senderName: 'שם שולח', | ||
| reason: 'סיבה', | ||
| year: 'שנה', | ||
| isApproved: 'מאושר' |
There was a problem hiding this comment.
I dont think this is needed now
| return( | ||
| <> </> | ||
| ); | ||
| } |
There was a problem hiding this comment.
dont you need to have StudentEventReport here?
There was a problem hiding this comment.
לא כי אני לא רוצה שיהיה ניתוב בדף הבית של תלמידה לדף דיווח.
| const isStandardView = (permissions) => !isOnlyInLessonReport(permissions) && !isTeacherView(permissions); | ||
| const shouldShowLessonReports = (permissions) => isInLessonReport(permissions) || isTeacherView(permissions); | ||
| const isStandardView = (permissions) => !isOnlyInLessonReport(permissions) && !isTeacherView(permissions) && !isStudentView(permissions); | ||
| const shouldShowLessonReports = (permissions) => (isInLessonReport(permissions) || isTeacherView(permissions)) && !isStudentView(permissions); |
There was a problem hiding this comment.
I dont think this is needed, student view user will not have teacher view or in lesson report permissions
There was a problem hiding this comment.
אני רואה שזה כן הכרחי אחרת התפריט מוצג
There was a problem hiding this comment.
את צריכה להסביר את זה
משתמש שאין לו הרשאה של isInLessonReport ואין לו הרשאה של isTeacherView ויש לו רק isStudentView ורואה את הניתובים האלו?
זה לא נשמע הגיוני
| ({ permissions }) => (isStandardView(permissions) && (!isStudentView(permissions))) && <MenuItemLink key="roadmap" to="/roadmap" primaryText="פיתוחים עתידיים" leftIcon={<MapIcon />} />, | ||
| ({ permissions }) => (isStandardView(permissions) && (!isStudentView(permissions))) && <MenuItemLink key="michlol-file-helper" to="/michlol-file-helper" primaryText="עדכון קבצי מכלול" leftIcon={<ContentPasteSearchIcon />} />, | ||
| ({ permissions }) => (isStandardView(permissions) && (!isStudentView(permissions))) && <MenuItemLink key="settings" to="/settings" primaryText="הגדרות משתמש" leftIcon={<SettingsIcon />} />, |
There was a problem hiding this comment.
duplicate, since isStandardView already checks student view permission
| export const useIsisAbsenceType = () => useHasPermission(appPermissions.absenceType); | ||
|
|
||
| export const isStudentView = (permissions) => hasPermissionLogic(permissions, appPermissions.studentView); | ||
| export const useIsisStudentView = () => useHasPermission(appPermissions.studentView); |
| ...cleanValues, | ||
| userId: userId, | ||
| year: parseInt(cleanValues.year), | ||
| reportDate: cleanValues.reportDate ? new Date(cleanValues.reportDate).toISOString() : new Date().toISOString(), |
There was a problem hiding this comment.
will new Date(cleanValues.reportDate).toISOString() work even when report date is empty?
There was a problem hiding this comment.
אין אפשרות לא לבחור תאריך אוטומטי זה על התאריך של היום ונין אם רוצים לשנות אבל אי אפשר למחוק לגמרי
There was a problem hiding this comment.
אם אי אפשר למחוק, אז לא צריך לבדוק אם זה קיים בכלל
לדעתי את יכולה פשוט לכתוב
reportDate: cleanValues.reportDate
| const { data: absenceType } = await dataProvider.getOne('absence_type', { | ||
| id: values.absenceTypeId | ||
| }); |
There was a problem hiding this comment.
you fetch this twice - once here and once in dynamic fields, can you make it one check only?
|
|
||
| const quota = absenceType?.quota; | ||
|
|
||
| if (quota !== undefined && quota !== null) { |
| const formattedData = { | ||
| ...formatPayload(values, student.userId), | ||
| studentReferenceId: student.id | ||
| }; |
There was a problem hiding this comment.
I think you can put studentReferenceId in formatPayload method too, to make the code simpler
| <NumberInput source="absnceCount" defaultValue={1} min={0} step={0.5} /> | ||
| <TextInput source="senderName" /> | ||
| <TextInput source="reason" multiline fullWidth /> | ||
| <CommonAutocompleteInput source="year" choices={yearChoices} defaultValue={defaultYearFilter.year} /> |
There was a problem hiding this comment.
i think year should be disabled too
| ...cleanValues, | ||
| userId: userId, | ||
| year: parseInt(cleanValues.year), | ||
| reportDate: cleanValues.reportDate ? new Date(cleanValues.reportDate).toISOString() : new Date().toISOString(), |
There was a problem hiding this comment.
אם אי אפשר למחוק, אז לא צריך לבדוק אם זה קיים בכלל
לדעתי את יכולה פשוט לכתוב
reportDate: cleanValues.reportDate
| const isStandardView = (permissions) => !isOnlyInLessonReport(permissions) && !isTeacherView(permissions); | ||
| const shouldShowLessonReports = (permissions) => isInLessonReport(permissions) || isTeacherView(permissions); | ||
| const isStandardView = (permissions) => !isOnlyInLessonReport(permissions) && !isTeacherView(permissions) && !isStudentView(permissions); | ||
| const shouldShowLessonReports = (permissions) => (isInLessonReport(permissions) || isTeacherView(permissions)) && !isStudentView(permissions); |
There was a problem hiding this comment.
את צריכה להסביר את זה
משתמש שאין לו הרשאה של isInLessonReport ואין לו הרשאה של isTeacherView ויש לו רק isStudentView ורואה את הניתובים האלו?
זה לא נשמע הגיוני
| <CommonReferenceInput source="klassReferenceId" reference="klass" validate={required()} dynamicFilter={filterByUserIdAndYear} /> | ||
| <CommonReferenceInput source="absenceTypeId" reference="absence_type" dynamicFilter={filterByUserIdAndYear} validate={required()} /> | ||
| <CommonReferenceInput source="absenceTypeId" reference="absence_type" dynamicFilter={filterByUserIdAndYear} validate={required()} | ||
| onChange={(e) => { const value = e?.target ? e.target.value : e; setSelectedAbsenceTypeId(value); }} /> |
There was a problem hiding this comment.
setSelectedAbsenceTypeId(e?.target?.value ?? e)
No description provided.