mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-19 08:52:25 +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
|
// retrieve the full list of machine categories on component mount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
MachineCategoryAPI.index()
|
MachineCategoryAPI.index()
|
||||||
.then(data => setMachineCategories(data))
|
.then(setMachineCategories)
|
||||||
.catch(e => onError(e));
|
.catch(onError);
|
||||||
MachineAPI.index()
|
MachineAPI.index({ category: 'none' })
|
||||||
.then(data => setMachines(data))
|
.then(setMachines)
|
||||||
.catch(e => onError(e));
|
.catch(onError);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,6 +59,7 @@ export const MachineCategoriesList: React.FC<MachineCategoriesListProps> = ({ on
|
|||||||
*/
|
*/
|
||||||
const onSaveTypeSuccess = (message: string): void => {
|
const onSaveTypeSuccess = (message: string): void => {
|
||||||
setModalIsOpen(false);
|
setModalIsOpen(false);
|
||||||
|
MachineAPI.index({ category: 'none' }).then(setMachines).catch(onError);
|
||||||
MachineCategoryAPI.index().then(data => {
|
MachineCategoryAPI.index().then(data => {
|
||||||
setMachineCategories(data);
|
setMachineCategories(data);
|
||||||
onSuccess(message);
|
onSuccess(message);
|
||||||
|
@ -5,7 +5,7 @@ import { AdvancedAccounting } from './advanced-accounting';
|
|||||||
|
|
||||||
export interface MachineIndexFilter extends ApiFilter {
|
export interface MachineIndexFilter extends ApiFilter {
|
||||||
disabled?: boolean,
|
disabled?: boolean,
|
||||||
category?: number
|
category?: number | 'none'
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Machine {
|
export interface Machine {
|
||||||
|
@ -34,6 +34,8 @@ class MachineService
|
|||||||
def filter_by_category(machines, filters)
|
def filter_by_category(machines, filters)
|
||||||
return machines if filters[:category].blank?
|
return machines if filters[:category].blank?
|
||||||
|
|
||||||
|
return machines.where(machine_category_id: nil) if filters[:category] == 'none'
|
||||||
|
|
||||||
machines.where(machine_category_id: filters[:category])
|
machines.where(machine_category_id: filters[:category])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user