mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
B: Fix cstUpdate
This commit is contained in:
parent
86f90149ee
commit
cc6e592149
|
@ -12,23 +12,12 @@ export const useCstUpdate = () => {
|
|||
const mutation = useMutation({
|
||||
mutationKey: [rsformsApi.baseKey, 'update-cst'],
|
||||
mutationFn: rsformsApi.cstUpdate,
|
||||
onSuccess: (newCst, variables) => {
|
||||
client.setQueryData(rsformsApi.getRSFormQueryOptions({ itemID: variables.itemID }).queryKey, prev =>
|
||||
!prev
|
||||
? undefined
|
||||
: {
|
||||
...prev,
|
||||
items: prev.items.map(item => (item.id === newCst.id ? { ...item, ...newCst } : item))
|
||||
}
|
||||
);
|
||||
onSuccess: (_, variables) => {
|
||||
updateTimestamp(variables.itemID);
|
||||
|
||||
return Promise.allSettled([
|
||||
client.invalidateQueries({ queryKey: [ossApi.baseKey] }),
|
||||
client.invalidateQueries({
|
||||
queryKey: [rsformsApi.baseKey],
|
||||
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== variables.itemID
|
||||
})
|
||||
client.invalidateQueries({ queryKey: [rsformsApi.baseKey] })
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -115,8 +115,8 @@ function EditorConstituenta() {
|
|||
onKeyDown={handleInput}
|
||||
>
|
||||
<FormConstituenta
|
||||
disabled={disabled}
|
||||
id={globals.constituenta_editor}
|
||||
disabled={disabled}
|
||||
toggleReset={toggleReset}
|
||||
onEditTerm={handleEditTermForms}
|
||||
/>
|
||||
|
|
|
@ -17,10 +17,11 @@ interface ConstituentsSearchProps {
|
|||
dense?: boolean;
|
||||
activeID?: ConstituentaID;
|
||||
activeExpression: string;
|
||||
setFiltered: React.Dispatch<React.SetStateAction<IConstituenta[]>>;
|
||||
|
||||
onChange: React.Dispatch<React.SetStateAction<IConstituenta[]>>;
|
||||
}
|
||||
|
||||
function ConstituentsSearch({ schema, activeID, activeExpression, dense, setFiltered }: ConstituentsSearchProps) {
|
||||
function ConstituentsSearch({ schema, activeID, activeExpression, dense, onChange }: ConstituentsSearchProps) {
|
||||
const query = useCstSearchStore(state => state.query);
|
||||
const filterMatch = useCstSearchStore(state => state.match);
|
||||
const filterSource = useCstSearchStore(state => state.source);
|
||||
|
@ -32,7 +33,7 @@ function ConstituentsSearch({ schema, activeID, activeExpression, dense, setFilt
|
|||
|
||||
useEffect(() => {
|
||||
if (schema.items.length === 0) {
|
||||
setFiltered([]);
|
||||
onChange([]);
|
||||
return;
|
||||
}
|
||||
let result: IConstituenta[] = [];
|
||||
|
@ -47,18 +48,8 @@ function ConstituentsSearch({ schema, activeID, activeExpression, dense, setFilt
|
|||
if (!includeInherited) {
|
||||
result = result.filter(cst => !cst.is_inherited);
|
||||
}
|
||||
setFiltered(result);
|
||||
}, [
|
||||
query,
|
||||
setFiltered,
|
||||
filterSource,
|
||||
activeExpression,
|
||||
schema.items,
|
||||
schema,
|
||||
filterMatch,
|
||||
activeID,
|
||||
includeInherited
|
||||
]);
|
||||
onChange(result);
|
||||
}, [query, onChange, filterSource, activeExpression, schema.items, schema, filterMatch, activeID, includeInherited]);
|
||||
|
||||
return (
|
||||
<div className='flex border-b clr-input rounded-t-md'>
|
||||
|
@ -69,8 +60,8 @@ function ConstituentsSearch({ schema, activeID, activeExpression, dense, setFilt
|
|||
query={query}
|
||||
onChangeQuery={setQuery}
|
||||
/>
|
||||
<SelectMatchMode value={filterMatch} onChange={newValue => setMatch(newValue)} dense={dense} />
|
||||
<SelectGraphFilter value={filterSource} onChange={newValue => setSource(newValue)} dense={dense} />
|
||||
<SelectMatchMode value={filterMatch} onChange={setMatch} dense={dense} />
|
||||
<SelectGraphFilter value={filterSource} onChange={setSource} dense={dense} />
|
||||
{schema.stats.count_inherited > 0 ? (
|
||||
<MiniButton
|
||||
noHover
|
||||
|
|
|
@ -53,7 +53,7 @@ function ViewConstituents({ expression, isBottom, isMounted }: ViewConstituentsP
|
|||
schema={schema}
|
||||
activeID={activeCst?.id}
|
||||
activeExpression={expression}
|
||||
setFiltered={setFilteredData}
|
||||
onChange={setFilteredData}
|
||||
/>
|
||||
<TableSideConstituents
|
||||
maxHeight={listHeight}
|
||||
|
|
Loading…
Reference in New Issue
Block a user