Skip to content

Commit 10f5064

Browse files
Remove goal component type
1 parent a4f167b commit 10f5064

27 files changed

+54
-393
lines changed

app/frontend/src/home/LandingPage.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,6 @@ export function LandingPage()
128128
DataCurator is for anyone trying to understand a complex system and intervene in it, who has a lot of information to understand and interpret.
129129
</p>
130130

131-
<p>
132-
Use it for simple note-taking and organizing, or model and plan an entire intervention. Choose key indicators to simplify the map or use the goal-priority view to keep your goals on track.
133-
</p>
134-
135131
<h3>
136132
How do I get started?
137133
</h3>

app/frontend/src/state/derived/State.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export interface ComposedKnowledgeView extends Omit<KnowledgeView, "wc_id_map" |
5959

6060
wc_id_connections_map: {[wc_id: string]: Set<string>}
6161
active_judgement_or_objective_ids_by_target_id: { [target_wcomponent_id: string]: string[] }
62-
active_judgement_or_objective_ids_by_goal_or_action_id: { [target_wcomponent_id: string]: string[] }
6362

6463

6564
composed_datetime_line_config: ComposedDatetimeLineConfig
@@ -76,7 +75,7 @@ export interface ComposedKnowledgeView extends Omit<KnowledgeView, "wc_id_map" |
7675
}
7776

7877

79-
type ExtendedWComponentType = WComponentType | "judgement_or_objective" | "goal_or_action" | "has_objectives" | "any_link" | "any_node" | "any_state_VAPs" | "has_single_datetime"
78+
type ExtendedWComponentType = WComponentType | "judgement_or_objective" | "has_objectives" | "any_link" | "any_node" | "any_state_VAPs" | "has_single_datetime"
8079
export type WComponentIdsByType = { [t in ExtendedWComponentType]: Set<string> }
8180

8281

@@ -94,7 +93,6 @@ export interface DerivedState
9493
nested_knowledge_view_ids: NestedKnowledgeViewIds
9594

9695
judgement_or_objective_ids_by_target_id: { [target_wcomponent_id: string]: string[] }
97-
judgement_or_objective_ids_by_goal_or_action_id: { [goal_wcomponent_id: string]: string[] }
9896

9997
current_composed_knowledge_view: ComposedKnowledgeView | undefined
10098
}

app/frontend/src/state/derived/get_wcomponent_ids_by_type.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ export function get_empty_wcomponent_ids_by_type (): WComponentIdsByType
2525
judgement: new Set(),
2626
objective: new Set(),
2727
counterfactualv2: new Set(),
28-
goal: new Set(),
2928

3029
judgement_or_objective: new Set(),
31-
goal_or_action: new Set(),
3230
has_objectives: new Set(),
3331
any_link: new Set(),
3432
any_node: new Set(),
@@ -63,9 +61,6 @@ export function get_wcomponent_ids_by_type (wcomponents_by_id: WComponentsById,
6361
})
6462

6563
wc_ids_by_type.judgement_or_objective = set_union(wc_ids_by_type.judgement, wc_ids_by_type.objective)
66-
wc_ids_by_type.goal_or_action = set_union(wc_ids_by_type.goal, wc_ids_by_type.action)
67-
// Need to keep in sync with wcomponent_has_objectives
68-
wc_ids_by_type.has_objectives = set_union(wc_ids_by_type.action, wc_ids_by_type.goal)
6964
wc_ids_by_type.any_link = set_union(wc_ids_by_type.causal_link, wc_ids_by_type.relation_link)
7065
wc_ids_by_type.any_node = set_difference(new Set(ids), wc_ids_by_type.any_link)
7166
// Need to keep in sync with wcomponent_is_allowed_to_have_state_VAP_sets

app/frontend/src/state/derived/knowledge_views/knowledge_views_derived_reducer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ export function calculate_composed_knowledge_view (args: CalculateComposedKnowle
173173
const current_composed_knowledge_view = args.current_composed_knowledge_view || {
174174
composed_visible_wc_id_map: {},
175175
active_judgement_or_objective_ids_by_target_id: {},
176-
active_judgement_or_objective_ids_by_goal_or_action_id: {},
177176
filters: {
178177
wc_ids_excluded_by_any_filter: new Set(),
179178
wc_ids_excluded_by_filters: new Set(),

app/frontend/src/state/derived/reducer.ts

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { is_defined } from "../../shared/utils/is_defined"
22
import { SortDirection, sort_list } from "../../shared/utils/sort"
33
import { update_substate } from "../../utils/update_state"
4-
import type { WComponentHasObjectives, WComponentJudgement } from "../../wcomponent/interfaces/judgement"
5-
import { wcomponent_is_goal, wcomponent_is_judgement_or_objective } from "../../wcomponent/interfaces/SpecialisedObjects"
4+
import type { WComponentJudgement } from "../../wcomponent/interfaces/judgement"
5+
import { wcomponent_is_judgement_or_objective } from "../../wcomponent/interfaces/SpecialisedObjects"
66
import { default_wcomponent_validity_value, get_wcomponent_validity_value } from "../../wcomponent_derived/get_wcomponent_validity_value"
77
import { get_wcomponents_from_state } from "../specialised_objects/accessors"
88
import type { RootState } from "../State"
@@ -26,13 +26,6 @@ export function derived_state_reducer (prev_state: RootState, state: RootState)
2626

2727
const judgement_or_objective_ids_by_target_id = update_judgement_or_objective_ids_by_target_id(judgement_or_objectives)
2828
state = update_substate(state, "derived", "judgement_or_objective_ids_by_target_id", judgement_or_objective_ids_by_target_id)
29-
30-
const goals = get_wcomponents_from_state(state, state.derived.wcomponent_ids_by_type.goal)
31-
.filter(is_defined)
32-
.filter(wcomponent_is_goal)
33-
34-
const judgement_or_objective_ids_by_goal_or_action_id = update_judgement_or_objective_ids_by_goal_or_action_id(goals)
35-
state = update_substate(state, "derived", "judgement_or_objective_ids_by_goal_or_action_id", judgement_or_objective_ids_by_goal_or_action_id)
3629
}
3730

3831

@@ -79,23 +72,6 @@ function update_judgement_or_objective_ids_by_target_id (judgement_or_objectives
7972
}
8073

8174

82-
83-
function update_judgement_or_objective_ids_by_goal_or_action_id (goals_and_actions: WComponentHasObjectives[])
84-
{
85-
const judgement_or_objective_ids_by_goal_or_action_id: { [goal_or_action_id: string]: string[] } = {}
86-
87-
goals_and_actions
88-
// .sort () // some kind of sort so that front end display is stable and predictable
89-
.forEach(({ id: goal_or_action_id, objective_ids }) =>
90-
{
91-
judgement_or_objective_ids_by_goal_or_action_id[goal_or_action_id] = objective_ids || []
92-
})
93-
94-
return judgement_or_objective_ids_by_goal_or_action_id
95-
}
96-
97-
98-
9975
function conditionally_update_active_judgement_or_objective_ids (prev_state: RootState, state: RootState): RootState
10076
{
10177
let { current_composed_knowledge_view } = state.derived
@@ -111,12 +87,10 @@ function conditionally_update_active_judgement_or_objective_ids (prev_state: Roo
11187

11288
// todo: we should update when the order of elements in current_composed_knowledge_view
11389
// changes so that ... <todo insert reason. Perhaps it's so that the list of judgements / objectives
114-
// are in the correct order when they are rendered on/for their targets and for their goals or actions?>
90+
// are in the correct order when they are rendered on/for their targets and for their actions?>
11591
if (current_composed_knowledge_view && (kv_id_changed || judgement_or_objective_ids_by_target_id_changed || created_at_ms_changed || sim_ms_changed))
11692
{
11793
const active_judgement_or_objective_ids_by_target_id: { [id: string]: string[] } = {}
118-
const active_judgement_or_objective_ids_by_goal_or_action_id: { [id: string]: string[] } = {}
119-
12094

12195
const { wc_ids_by_type, composed_visible_wc_id_map } = current_composed_knowledge_view
12296
const judgement_or_objectives = get_judgement_or_objectives(state, wc_ids_by_type.judgement_or_objective)
@@ -153,15 +127,12 @@ function conditionally_update_active_judgement_or_objective_ids (prev_state: Roo
153127

154128
const {
155129
judgement_or_objective_ids_by_target_id,
156-
judgement_or_objective_ids_by_goal_or_action_id,
157130
} = state.derived
158131

159132
Object.keys(composed_visible_wc_id_map)
160133
.forEach(id =>
161134
{
162135
const target_ids = judgement_or_objective_ids_by_target_id[id]
163-
const ids_from_goal_or_action = judgement_or_objective_ids_by_goal_or_action_id[id]
164-
165136
if (target_ids)
166137
{
167138
const active_judgement_or_objective_ids = target_ids.filter(judgement_or_objective_id_is_active)
@@ -172,24 +143,12 @@ function conditionally_update_active_judgement_or_objective_ids (prev_state: Roo
172143
active_judgement_or_objective_ids_by_target_id[id] = sorted
173144
}
174145
}
175-
176-
if (ids_from_goal_or_action)
177-
{
178-
const active_judgement_or_objective_ids = ids_from_goal_or_action.filter(judgement_or_objective_id_is_active)
179-
if (active_judgement_or_objective_ids.length)
180-
{
181-
const sorted = sort_list(active_judgement_or_objective_ids, get_wcomponent_ids_sort_key, SortDirection.descending)
182-
183-
active_judgement_or_objective_ids_by_goal_or_action_id[id] = sorted
184-
}
185-
}
186146
})
187147

188148

189149
current_composed_knowledge_view = {
190150
...current_composed_knowledge_view,
191151
active_judgement_or_objective_ids_by_target_id,
192-
active_judgement_or_objective_ids_by_goal_or_action_id,
193152
}
194153
state = update_substate(state, "derived", "current_composed_knowledge_view", current_composed_knowledge_view)
195154
}

app/frontend/src/state/derived/starting_state.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export function get_derived_starting_state (): DerivedState
1313
nested_knowledge_view_ids: { top_ids: [], map: {} },
1414

1515
judgement_or_objective_ids_by_target_id: {},
16-
judgement_or_objective_ids_by_goal_or_action_id: {},
1716

1817
current_composed_knowledge_view: undefined,
1918
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { KnowledgeViewsById } from "../../shared/interfaces/knowledge_view"
2+
import { WComponentsById, wcomponent_is_action } from "../../wcomponent/interfaces/SpecialisedObjects"
3+
4+
5+
6+
export function get_default_parent_action_ids (knowledge_view_id: string | undefined, knowledge_views_by_id: KnowledgeViewsById, wcomponents_by_id: WComponentsById)
7+
{
8+
let kv = knowledge_view_id ? knowledge_views_by_id[knowledge_view_id] : undefined
9+
10+
while (kv)
11+
{
12+
const wc = wcomponents_by_id[kv.id]
13+
if (wcomponent_is_action(wc)) return [wc.id]
14+
kv = kv.parent_knowledge_view_id ? knowledge_views_by_id[kv.parent_knowledge_view_id] : undefined
15+
}
16+
17+
return []
18+
}

app/frontend/src/state/specialised_objects/get_default_parent_goal_or_action_ids.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

app/frontend/src/state/specialised_objects/wcomponents/create_wcomponent_type.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
get_current_composed_knowledge_view_from_state,
2424
get_wcomponent_from_state,
2525
} from "../accessors"
26-
import { get_default_parent_goal_or_action_ids } from "../get_default_parent_goal_or_action_ids"
26+
import { get_default_parent_action_ids } from "../get_default_parent_action_ids"
2727
import type { AddToKnowledgeViewArgs } from "./actions"
2828

2929

@@ -108,7 +108,7 @@ function set_parent_goal_or_action_ids (wcomponent: WComponent, state: RootState
108108
const { wcomponents_by_id, knowledge_views_by_id } = state.specialised_objects
109109

110110
const knowledge_view_id = composed_knowledge_view?.id
111-
const parent_goal_or_action_ids = get_default_parent_goal_or_action_ids(knowledge_view_id, knowledge_views_by_id, wcomponents_by_id)
111+
const parent_goal_or_action_ids = get_default_parent_action_ids(knowledge_view_id, knowledge_views_by_id, wcomponents_by_id)
112112

113113
return {
114114
...wcomponent,

app/frontend/src/wcomponent/CRUD_helpers/prepare_new_wcomponent_object.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { get_new_id } from "datacurator-core/utils/ids"
33

44
import type { HasBaseId } from "../../shared/interfaces/base"
55
import type { WComponentNodeAction } from "../interfaces/action"
6-
import type { WComponentNodeGoal } from "../interfaces/goal"
76
import type { WComponentJudgement } from "../interfaces/judgement"
87
import { WComponent, WComponentConnection, WComponentNode, wcomponent_is_causal_link } from "../interfaces/SpecialisedObjects"
98
import type { WComponentNodeStateV2 } from "../interfaces/state"
@@ -78,16 +77,6 @@ export function prepare_new_contextless_wcomponent_object (partial_wcomponent: P
7877
}
7978
wcomponent = statev2
8079
}
81-
else if (partial_wcomponent.type === "goal")
82-
{
83-
const goal: WComponentNodeGoal = {
84-
...base,
85-
objective_ids: [],
86-
...partial_wcomponent,
87-
type: partial_wcomponent.type, // only added to remove type warning
88-
}
89-
wcomponent = goal
90-
}
9180
else if (partial_wcomponent.type === "action")
9281
{
9382
const action: WComponentNodeAction = {

0 commit comments

Comments
 (0)