Skip to content

Commit

Permalink
GDB-9366: Drop-down list in Resource view should not be accessible fr…
Browse files Browse the repository at this point in the history
…om Context tab

## What
When opening the "Resource" view and clicking on the "inference-select" dropdown, there is an empty option. If a new option is selected, the empty option disappear.

## Why
This can happen if the select does not match any option with the value of "nb-model". [More explanation](https://stackoverflow
.com/questions/12654631/why-does-angularjs-include-an-empty-option-in-select/12654812#12654812).
The problem in our code is that the value of the select is an id of a context type, but during initialization, an instance of the context type is used instead of the id. This causes the select not to match the initial value with a passed option.

## How
Fixed the initial value to be the ID of the context type instead of the instance. Renamed the variable "currentContextType" to "currentContextTypeId" for more clarity regarding the expected value.
  • Loading branch information
boyan-tonchev committed Jan 24, 2024
1 parent f2f72a7 commit 51a09bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/js/angular/explore/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function ExploreCtrl(

$scope.ContextTypes = ContextTypes;
$scope.contextTypes = ContextType.getAllType();
$scope.currentContextType = ContextTypes.EXPLICIT;
$scope.currentContextTypeId = ContextTypes.EXPLICIT.id;
$scope.roles = [RoleType.SUBJECT, RoleType.PREDICATE, RoleType.OBJECT, RoleType.CONTEXT, RoleType.ALL];

$scope.resourceInfo = undefined;
Expand Down
4 changes: 2 additions & 2 deletions src/pages/explore.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ <h1 fit-text fit-text-min="30">
<label for="inference-select" class="mb-0">
<select id="inference-select"
class="form-control form-control-sm"
ng-model="currentContextType"
ng-change="changeInference(currentContextType)"
ng-model="currentContextTypeId"
ng-change="changeInference(currentContextTypeId)"
ng-disabled="loading || resourceInfo.role === 'context' || getActiveRepository() === 'SYSTEM'">
<option ng-repeat="contextType in contextTypes"
value="{{contextType.id}}"
Expand Down

0 comments on commit 51a09bf

Please sign in to comment.