1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-18 07:52:23 +01:00

(bug) filter already assign machines from new category modal

This commit is contained in:
Sylvain 2023-02-17 12:18:48 +01:00
parent 67d06b5da0
commit 56120f886a
3 changed files with 9 additions and 6 deletions

View File

@ -40,11 +40,11 @@ export const MachineCategoriesList: React.FC<MachineCategoriesListProps> = ({ on
// retrieve the full list of machine categories on component mount
useEffect(() => {
MachineCategoryAPI.index()
.then(data => setMachineCategories(data))
.catch(e => onError(e));
MachineAPI.index()
.then(data => setMachines(data))
.catch(e => onError(e));
.then(setMachineCategories)
.catch(onError);
MachineAPI.index({ category: 'none' })
.then(setMachines)
.catch(onError);
}, []);
/**
@ -59,6 +59,7 @@ export const MachineCategoriesList: React.FC<MachineCategoriesListProps> = ({ on
*/
const onSaveTypeSuccess = (message: string): void => {
setModalIsOpen(false);
MachineAPI.index({ category: 'none' }).then(setMachines).catch(onError);
MachineCategoryAPI.index().then(data => {
setMachineCategories(data);
onSuccess(message);

View File

@ -5,7 +5,7 @@ import { AdvancedAccounting } from './advanced-accounting';
export interface MachineIndexFilter extends ApiFilter {
disabled?: boolean,
category?: number
category?: number | 'none'
}
export interface Machine {

View File

@ -34,6 +34,8 @@ class MachineService
def filter_by_category(machines, filters)
return machines if filters[:category].blank?
return machines.where(machine_category_id: nil) if filters[:category] == 'none'
machines.where(machine_category_id: filters[:category])
end
end