19
19
< span class ="caret "> </ span >
20
20
</ button >
21
21
< ul uib-dropdown-menu class ="dropdown-menu " role ="menu ">
22
- < li ng-repeat ="exec in execNames " role ="menuitem " ng-click ="changeExec(exec) " data-cy ="exec-{{ exec }} ">
22
+ < li ng-repeat ="exec in execNames " role ="menuitem " ng-click ="changeExec(exec, true ) " data-cy ="exec-{{ exec }} ">
23
23
< a href =""> {{ exec }}</ a >
24
24
</ li >
25
25
</ ul >
@@ -144,20 +144,22 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg"> {{ statu
144
144
} ;
145
145
146
146
// Change to a newly selected SQL statement
147
- $scope . changeExec = function ( newExec ) {
147
+ $scope . changeExec = function ( newExec , updateMsg ) {
148
148
// Retrieve the newly chosen SQL statement from the server
149
149
$http . get ( "/x/execget/[[ .DB.Info.Owner ]]/[[ .DB.Info.Database ]]?sqlname=" + newExec ) . then (
150
150
function success ( response ) {
151
- // Clear any existing status message
152
- $scope . statusMessage = "" ;
151
+ if ( updateMsg ) {
152
+ // Clear any existing status message
153
+ $scope . statusMessage = "" ;
154
+ }
153
155
154
156
// Apply the retrieved information
155
157
document . getElementById ( "savename" ) . value = newExec ;
156
158
$scope . selectedName = newExec ;
157
159
158
160
// We include '.textContent' here now because Cypress (v12.3.0) *refuses* to return the correct
159
- // data if '.value' is used. Instead, Cypress returns old data which of course fails every test
160
- // using it. Everything else (Chromium, FF, etc) is totally fine, returning the correct data.
161
+ // data if just '.value' is used. Instead, Cypress returns old data which of course fails every
162
+ // test using it. Everything else (Chromium, FF, etc) is totally fine, returning the correct data.
161
163
// Cypress itself even *visually displays* the correct data that it should be returning. But no,
162
164
// the actual .should() call done by Cypress returns *old* (incorrect) data, causing failures.
163
165
// WTF? :(
@@ -167,17 +169,19 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg"> {{ statu
167
169
updateSQL ( ) ;
168
170
169
171
} , function failure ( response ) {
170
- // Retrieving statement text failed, so display the returned error message
171
- $scope . statusMessageColour = "red" ;
172
- $scope . statusMessage = nowString ( ) + "Retrieving saved SQL failed: " + response . data ;
172
+ if ( updateMsg ) {
173
+ // Retrieving statement text failed, so display the returned error message
174
+ $scope . statusMessageColour = "red" ;
175
+ $scope . statusMessage = nowString ( ) + "Retrieving saved SQL failed: " + response . data ;
176
+ }
173
177
}
174
178
)
175
179
}
176
180
177
181
// If there are saved SQL statements but none of them is named "default", then change the Saved SQL drop down
178
182
// selector to use the first one
179
183
if ( ( $scope . execNames . length > 0 ) && ( ! $scope . execNames . includes ( "default" ) ) ) {
180
- $scope . changeExec ( $scope . execNames [ 0 ] ) ;
184
+ $scope . changeExec ( $scope . execNames [ 0 ] , true ) ;
181
185
}
182
186
183
187
// Deletes a saved SQL statement
@@ -207,12 +211,7 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg"> {{ statu
207
211
let newSelected = $scope . execNames [ 0 ] ;
208
212
$scope . selectedName = newSelected ;
209
213
document . getElementById ( "savename" ) . value = newSelected ;
210
- $scope . changeExec ( newSelected ) ;
211
-
212
- // We need to set the status message here too, otherwise the ~async changeExec() above
213
- // can overwrite it
214
- $scope . statusMessageColour = "green" ;
215
- $scope . statusMessage = nowString ( ) + "SQL statement '" + name + "' deleted" ;
214
+ $scope . changeExec ( newSelected , false ) ;
216
215
}
217
216
}
218
217
0 commit comments