From 2a77bb10b6ca08b1e4c8f8b0cd03c2fbfa798bdc Mon Sep 17 00:00:00 2001 From: Jeremy Booker Date: Sun, 7 Sep 2025 17:47:12 -0400 Subject: [PATCH] Minor updates to majors and programs table. --- class/Command/MajorsProgramsRest.php | 8 +++++++- javascript/editMajor/MajorsTable.jsx | 5 +++++ javascript/editMajor/editMajor.jsx | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/class/Command/MajorsProgramsRest.php b/class/Command/MajorsProgramsRest.php index 9c285fcf..2cef9d36 100644 --- a/class/Command/MajorsProgramsRest.php +++ b/class/Command/MajorsProgramsRest.php @@ -110,6 +110,12 @@ public function patch() } // Check that the CIP code exists + if (!isset($inputJSON['cip_code'])) { + header('HTTP/1.1 400 Bad Request'); + echo json_encode(array('errorMessage' => 'The CIP code field is required.')); + exit; + } + $cipCode = CipCodeProvider::getCipCodeByCode($inputJSON['cip_code']); if ($cipCode === null && !empty($inputJSON['cip_code'])) { header('HTTP/1.1 400 Bad Request'); @@ -122,7 +128,7 @@ public function patch() $inputJSON['description'], $inputJSON['level'], $inputJSON['cip_code'], - null, + '', $inputJSON['hidden'] ); diff --git a/javascript/editMajor/MajorsTable.jsx b/javascript/editMajor/MajorsTable.jsx index 47d62ed9..46fbe534 100644 --- a/javascript/editMajor/MajorsTable.jsx +++ b/javascript/editMajor/MajorsTable.jsx @@ -50,6 +50,9 @@ export default function MajorsTable({ majorsList, studentLevels, isLoading, rowE }; // TODO: Provide a cell editor for the CipCode column with a CipComboBox + // TODO: Provide a cell editor for the Status column with an Active/Inactive dropdown + + // Column definitions const colDefs = [ { field: 'description', width: 300, editable: true, headerName: 'Major Name' }, { @@ -71,6 +74,8 @@ export default function MajorsTable({ majorsList, studentLevels, isLoading, rowE domLayout: 'autoHeight', editType: 'fullRow', onRowValueChanged: event => { + // TODO: Check if anything actually changed before sending the request + // The change event doesn't contain any old data, so this will have to be refactored to use cell editing rowEditCallback(event.data); // Call the rowEditCallback with the new data } }; diff --git a/javascript/editMajor/editMajor.jsx b/javascript/editMajor/editMajor.jsx index 618f2bea..a2c61582 100644 --- a/javascript/editMajor/editMajor.jsx +++ b/javascript/editMajor/editMajor.jsx @@ -1,4 +1,4 @@ -import React, { useCallback, useRef, useState } from 'react'; +import React, { useCallback, useRef } from 'react'; import { createRoot } from 'react-dom/client'; import { QueryClient, QueryClientProvider, useQuery, useMutation } from '@tanstack/react-query'; import { getMajors, postMajor, patchMajor, getStudentLevels } from '../api/api';