Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion class/Command/MajorsProgramsRest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -122,7 +128,7 @@ public function patch()
$inputJSON['description'],
$inputJSON['level'],
$inputJSON['cip_code'],
null,
'',
$inputJSON['hidden']
);

Expand Down
5 changes: 5 additions & 0 deletions javascript/editMajor/MajorsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
{
Expand All @@ -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
}
};
Expand Down
2 changes: 1 addition & 1 deletion javascript/editMajor/editMajor.jsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down