-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #3644: Handles empty hint in hint editor by showing a message and deleting it #3648
Conversation
Did you test this carefully? I poked around and ran into cases where it does not fully work -- e.g. if you clear hint 1 and then click on hint 2. |
var currentActiveIndex = $scope.activeHintIndex; | ||
if (currentActiveIndex && ( | ||
!stateHintsService.displayed[currentActiveIndex].hintText)) { | ||
alertsService.addInfoMessage('Deleting empty hint!'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd drop the exclamation mark here, and follow the style of the other info messages -- deleting a hint is not that exciting :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha, sure! (and yes, that particular case doesn't work. I'll fix it.)
Codecov Report
@@ Coverage Diff @@
## develop #3648 +/- ##
===========================================
- Coverage 44.85% 44.83% -0.02%
===========================================
Files 257 257
Lines 19881 19888 +7
Branches 3133 3135 +2
===========================================
Hits 8917 8917
- Misses 10964 10971 +7
Continue to review full report at Codecov.
|
@@ -51,6 +51,13 @@ oppia.controller('StateHints', [ | |||
}; | |||
|
|||
$scope.changeActiveHintIndex = function(newIndex) { | |||
var currentActiveIndex = $scope.activeHintIndex; | |||
if (Number.isInteger(currentActiveIndex) && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semantically, should this actually be something like currentActiveIndex !== null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
@@ -51,6 +51,13 @@ oppia.controller('StateHints', [ | |||
}; | |||
|
|||
$scope.changeActiveHintIndex = function(newIndex) { | |||
var currentActiveIndex = $scope.activeHintIndex; | |||
if (Number.isInteger(currentActiveIndex) && ( | |||
!stateHintsService.displayed[currentActiveIndex].hintText)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can indent this by 2 more to distinguish it from the next line (which is the one that actually starts an inner scope).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
alertsService.addInfoMessage('Deleting empty hint.'); | ||
stateHintsService.displayed.splice(currentActiveIndex, 1); | ||
stateHintsService.saveDisplayedValue(); | ||
} | ||
// If the current hint is being clicked on again, close it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, small nit: indent this by 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'll fix the "Hints" showing up in logged out view in this PR along with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sounds good. Let me drop the lgtm for the time being while you do that, then :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing the deletion of empty hints: lgtm
Fixed "Hints" text appearing when there are no hints in logged out view as well. PTAL. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM from code perspective.
Linking #3644.