Skip to content

Commit db785d3

Browse files
authored
Allow array properties to be selected in the formula context. (baserow#4488)
* Allow array properties to be selected in the formula context when expert mode is selected * Moving toArrayDescription, the type expects it to be in runtimeFormulaTypes
1 parent 1313a54 commit db785d3

File tree

6 files changed

+37
-6
lines changed

6 files changed

+37
-6
lines changed

backend/src/baserow/contrib/integrations/core/service_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ def formulas_to_resolve(self, service: CoreRouterService) -> list[FormulaToResol
988988
FormulaToResolve(
989989
f"edge_{edge.uid}",
990990
edge.condition,
991-
lambda x: ensure_boolean(x, True),
991+
lambda x: ensure_boolean(x, False),
992992
f'edge "{edge.label}" condition',
993993
)
994994
for edge in service.edges.all()

backend/tests/baserow/contrib/integrations/core/test_core_router_service_type.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,22 @@ def test_update_core_router_service(data_fixture):
4747

4848

4949
@pytest.mark.django_db
50-
def test_core_router_service_type_dispatch_data_with_a_truthful_edge(data_fixture):
50+
@pytest.mark.parametrize(
51+
"truthful_condition",
52+
[1, [1], True, "yes"],
53+
)
54+
def test_core_router_service_type_dispatch_data_with_a_truthful_edge(
55+
data_fixture, truthful_condition
56+
):
5157
service = data_fixture.create_core_router_service()
5258
data_fixture.create_core_router_service_edge(
5359
service=service, label="Edge 1", condition="'false'", skip_output_node=True
5460
)
5561
edge2 = data_fixture.create_core_router_service_edge(
56-
service=service, label="Edge 2", condition="'true'", skip_output_node=True
62+
service=service,
63+
label="Edge 2",
64+
condition=f"'{truthful_condition}'",
65+
skip_output_node=True,
5766
)
5867

5968
service_type = service.get_type()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "feature",
3+
"message": "Allow array properties to be selected in the formula context when expert mode is selected.",
4+
"issue_origin": "github",
5+
"issue_number": 4485,
6+
"domain": "core",
7+
"bullet_points": [],
8+
"created_at": "2025-12-19"
9+
}

web-frontend/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,6 @@
606606
"absDescription": "Returns the absolute value for the argument number provided.",
607607
"ceilDescription": "Returns the smallest integer that is greater than or equal the argument number provided.",
608608
"floorDescription": "Returns the largest integer that is less than or equal the argument number provided.",
609-
"toArrayDescription": "Converts a comma-delimited string into an array.",
610609
"encodeUriDescription": "Returns a encoded URI string from the argument provided.",
611610
"encodeUriComponentDescription": "Returns a encoded URI string component from the argument provided.",
612611
"getFileVisibleNameDescription": "Returns the visible file name from a single file returned from the index function.",
@@ -688,6 +687,7 @@
688687
"sumDescription": "Sums the numbers inside the argument.",
689688
"avgDescription": "Averages the numbers inside the argument.",
690689
"atDescription": "Returns the item in the first argument at the index specified by the second argument.",
690+
"toArrayDescription": "Converts a comma-delimited string into an array.",
691691
"formulaTypeFormula": "Function | Functions",
692692
"formulaTypeOperator": "Operator | Operators",
693693
"formulaTypeData": "Data",

web-frontend/modules/core/components/nodeExplorer/NodeExplorer.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,24 @@
5555
import NodeExplorerTab from '@baserow/modules/core/components/nodeExplorer/NodeExplorerTab'
5656
5757
import _ from 'lodash'
58+
import { BASEROW_FORMULA_MODES } from '@baserow/modules/core/formula/constants'
5859
5960
export default {
6061
name: 'NodeExplorer',
6162
components: {
6263
NodeExplorerTab,
6364
},
65+
provide() {
66+
return {
67+
getFormulaMode: () => this.mode,
68+
}
69+
},
6470
props: {
6571
mode: {
6672
type: String,
6773
required: false,
6874
default: 'advanced',
69-
validator: (value) => ['advanced', 'simple', 'raw'].includes(value),
75+
validator: (value) => BASEROW_FORMULA_MODES.includes(value),
7076
},
7177
nodeSelected: {
7278
type: String,

web-frontend/modules/core/components/nodeExplorer/NodeExplorerContent.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<i class="iconoir-check-circle" />
2222
</span>
2323
<span
24-
v-else-if="allowNodeSelection && node.type === 'array'"
24+
v-else-if="allowArraySelection(node)"
2525
class="data-explorer-node__select-node"
2626
@click.stop="handleClick(node, true)"
2727
>
@@ -86,6 +86,7 @@ export default {
8686
components: {
8787
NodeHelpTooltip,
8888
},
89+
inject: ['getFormulaMode'],
8990
props: {
9091
node: {
9192
type: Object,
@@ -185,6 +186,12 @@ export default {
185186
},
186187
},
187188
methods: {
189+
allowArraySelection(node) {
190+
return (
191+
node.type === 'array' &&
192+
(this.allowNodeSelection || this.getFormulaMode() === 'advanced')
193+
)
194+
},
188195
handleClick(node, isNode) {
189196
if (this.depth < 1) {
190197
// We don't want to click on first level

0 commit comments

Comments
 (0)