feat: knowledge graph table view met sort, group en bulk edit
Voegt een Graph/Table toggle toe aan de admin Knowledge Graph. De tabel ondersteunt sorteren per kolom, groeperen op type/relevance/theme/difficulty, filteren op label, multi-select en bulk-wijzigen van type, learning_relevance en relevance_locked. Closes #10 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -104,6 +104,23 @@ export function useGraphData() {
|
||||
return true;
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Apply the same patch to many topics in one call. `ids` is the set of
|
||||
* topic IDs to update; `patch` is the partial-topic to merge into each one
|
||||
* (e.g. `{ type: 'process' }` or `{ learning_relevance: 'core', relevance_locked: true }`).
|
||||
*
|
||||
* Persists each topic via db.upsertTopic in parallel and mirrors into state.
|
||||
* Returns the number of topics actually written (selected ∩ existing).
|
||||
*/
|
||||
const bulkUpdateTopics = useCallback(async (ids, patch) => {
|
||||
const idSet = new Set(ids);
|
||||
const targets = topicsRef.current.filter(t => idSet.has(t.id));
|
||||
const updated = targets.map(t => ({ ...t, ...patch }));
|
||||
await Promise.all(updated.map(t => db.upsertTopic(t)));
|
||||
setTopics(prev => prev.map(t => (idSet.has(t.id) ? { ...t, ...patch } : t)));
|
||||
return updated.length;
|
||||
}, []);
|
||||
|
||||
/** Remove a specific (source, target, type) relation triple. */
|
||||
const removeRelation = useCallback(async (source, target, type) => {
|
||||
await db.removeRelation(source, target, type);
|
||||
@@ -165,6 +182,7 @@ export function useGraphData() {
|
||||
snapshotMeta,
|
||||
reload,
|
||||
updateTopic,
|
||||
bulkUpdateTopics,
|
||||
deleteTopic,
|
||||
addRelation,
|
||||
removeRelation,
|
||||
|
||||
Reference in New Issue
Block a user