Skip to content

Commit e325b2b

Browse files
authored
Rename simple->basic and advanced->expert in the UI. Only show a confirmation dialog on an advanced->simple change if there's a value to lose. (baserow#4337)
1 parent 6907800 commit e325b2b

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

web-frontend/locales/en.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -686,13 +686,6 @@
686686
"categoryDate": "Date",
687687
"categoryCondition": "Condition"
688688
},
689-
"formulaInputContext": {
690-
"useRegularInput": "Use regular input",
691-
"useRegularInputModalTitle": "Switch to regular input?",
692-
"useAdvancedInputModalTitle": "Switch to advanced input?",
693-
"useAdvancedInput": "Use advanced input",
694-
"modalMessage": "Switching to a different input mode will clear the current formula. Are you sure you want to continue?"
695-
},
696689
"nodeExplorer": {
697690
"noResults": "No results found",
698691
"resetSearch": "Reset search"

web-frontend/modules/core/components/formula/FormulaInputContext.vue

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
@click="toggleMode"
2323
>{{
2424
isAdvancedMode
25-
? $t('formulaInputContext.useRegularInput')
25+
? $t('formulaInputContext.useSimpleInput')
2626
: $t('formulaInputContext.useAdvancedInput')
2727
}}</ButtonText
2828
>
@@ -32,7 +32,7 @@
3232
<h2 class="box__title">
3333
{{
3434
isAdvancedMode
35-
? $t('formulaInputContext.useRegularInputModalTitle')
35+
? $t('formulaInputContext.useSimpleInputModalTitle')
3636
: $t('formulaInputContext.useAdvancedInputModalTitle')
3737
}}
3838
</h2>
@@ -46,7 +46,7 @@
4646
<Button type="danger" size="large" @click="confirmModeChange">
4747
{{
4848
isAdvancedMode
49-
? $t('formulaInputContext.useRegularInput')
49+
? $t('formulaInputContext.useSimpleInput')
5050
: $t('formulaInputContext.useAdvancedInput')
5151
}}
5252
</Button>
@@ -90,6 +90,16 @@ export default {
9090
return ['advanced', 'simple'].includes(value)
9191
},
9292
},
93+
/**
94+
* Whether the formula input has a formula value set or not.
95+
* Used to determine if we need to show a confirmation prompt
96+
* or not when the mode changes from advanced to simple.
97+
*/
98+
hasValue: {
99+
type: Boolean,
100+
required: false,
101+
default: false,
102+
},
93103
allowNodeSelection: {
94104
type: Boolean,
95105
required: false,
@@ -170,7 +180,14 @@ export default {
170180
},
171181
toggleMode() {
172182
if (this.mode === 'advanced') {
173-
this.showAdvancedModeModal()
183+
if (this.hasValue) {
184+
// If we have a value then we want the user to confirm
185+
// they're happy for the formula to be reset.
186+
this.showAdvancedModeModal()
187+
} else {
188+
// If we have no value then we can safely switch modes.
189+
this.$emit('mode-changed', 'simple')
190+
}
174191
} else {
175192
this.$emit('mode-changed', 'advanced')
176193
}

web-frontend/modules/core/components/formula/FormulaInputField.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
:node-selected="nodeSelected"
2020
:loading="loading"
2121
:mode="mode"
22+
:has-value="value.length > 0"
2223
:allow-node-selection="allowNodeSelection"
2324
:nodes-hierarchy="nodesHierarchy"
2425
@node-selected="handleNodeSelected"

web-frontend/modules/core/locales/en.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -846,10 +846,11 @@
846846
"operators": "Operators",
847847
"search": "Search",
848848
"useRegularInputModalTitle": "Use regular input for this field?",
849-
"useRegularInput": "Use regular input",
850-
"useAdvancedInput": "Use advanced input",
851-
"useAdvancedInputModalTitle": "Use advanced input for this field?",
852-
"modalMessage": "Your field’s content will be cleared and it will not be possible to recover it."
849+
"useSimpleInput": "Switch to basic mode",
850+
"useSimpleInputModalTitle": "Switch to basic mode?",
851+
"useAdvancedInput": "Switch to expert mode",
852+
"useAdvancedInputModalTitle": "Switch to expert mode?",
853+
"modalMessage": "Switching to a different mode will clear the current formula. Are you sure you want to continue?"
853854
},
854855
"dataExplorer": {
855856
"noMatchingNodesText": "No matching results were found.",

0 commit comments

Comments
 (0)