-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #303 from mumuki/issue-#301-next-button-on-pending…
…-exercises Adding repeat pending button
- Loading branch information
Showing
22 changed files
with
264 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
module WithNavigation | ||
def next_button(navigable) | ||
sibling_button(navigable.next_for(current_user), :next_exercise, 'chevron-right', 'btn btn-success', true) | ||
ContinueNavigation.new(self).button(navigable) || RevisitNavigation.new(self).button(navigable) | ||
end | ||
|
||
def next_nav_button(navigable) | ||
sibling_button(navigable.next, :next_exercise, 'chevron-circle-right', 'text-info', true) | ||
ForwardNavigation.new(self).button(navigable) | ||
end | ||
|
||
def previous_nav_button(navigable) | ||
sibling_button(navigable.previous, :previous_exercise, 'chevron-circle-left', 'text-info') | ||
end | ||
|
||
def sibling_button(sibling, key, icon, clazz, right=false) | ||
link_to fa_icon(icon, text: t(key), right: right), sibling, class: clazz if sibling | ||
BackwardNavigation.new(self).button(navigable) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module WithNavigation | ||
module AnonymousNavigation | ||
def clazz | ||
'text-info' | ||
end | ||
end | ||
end |
17 changes: 17 additions & 0 deletions
17
app/helpers/concerns/with_navigation/backward_navigation.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module WithNavigation | ||
class BackwardNavigation < Navigation | ||
include AnonymousNavigation | ||
|
||
def icon | ||
'chevron-circle-left' | ||
end | ||
|
||
def key | ||
:navigation_previous | ||
end | ||
|
||
def sibling_for(navigable) | ||
navigable.previous | ||
end | ||
end | ||
end |
23 changes: 23 additions & 0 deletions
23
app/helpers/concerns/with_navigation/continue_navigation.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module WithNavigation | ||
class ContinueNavigation < Navigation | ||
def right | ||
true | ||
end | ||
|
||
def icon | ||
'chevron-right' | ||
end | ||
|
||
def key | ||
:navigation_continue | ||
end | ||
|
||
def clazz | ||
'btn btn-success' | ||
end | ||
|
||
def sibling_for(navigable) | ||
navigable.next_for(current_user) | ||
end | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
app/helpers/concerns/with_navigation/forward_navigation.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module WithNavigation | ||
class ForwardNavigation < Navigation | ||
include AnonymousNavigation | ||
|
||
def right | ||
true | ||
end | ||
|
||
def icon | ||
'chevron-circle-right' | ||
end | ||
|
||
def key | ||
:navigation_next | ||
end | ||
|
||
def sibling_for(navigable) | ||
navigable.next | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module WithNavigation | ||
class Navigation | ||
def initialize(template) | ||
@template = template | ||
end | ||
|
||
def button(navigable) | ||
sibling = sibling_for(navigable) | ||
link_to link_icon(sibling), sibling, class: clazz if sibling && sibling != navigable | ||
end | ||
|
||
def link_icon(sibling) | ||
fa_icon(icon, text: I18n.t(key, sibling: sibling.name), right: right) | ||
end | ||
|
||
def right | ||
false | ||
end | ||
|
||
def method_missing(name, *args, &block) | ||
@template.send(name, *args, &block) | ||
end | ||
end | ||
end |
23 changes: 23 additions & 0 deletions
23
app/helpers/concerns/with_navigation/revisit_navigation.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module WithNavigation | ||
class RevisitNavigation < Navigation | ||
def right | ||
true | ||
end | ||
|
||
def icon | ||
'chevron-right' | ||
end | ||
|
||
def key | ||
:navigation_revisit | ||
end | ||
|
||
def clazz | ||
'btn btn-warning' | ||
end | ||
|
||
def sibling_for(navigable) | ||
navigable.first_for(current_user) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.