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:
parent
67d06b5da0
commit
56120f886a
@ -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);
|
||||
|
@ -5,7 +5,7 @@ import { AdvancedAccounting } from './advanced-accounting';
|
||||
|
||||
export interface MachineIndexFilter extends ApiFilter {
|
||||
disabled?: boolean,
|
||||
category?: number
|
||||
category?: number | 'none'
|
||||
}
|
||||
|
||||
export interface Machine {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user