-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ff7d0a
commit 2f5eac9
Showing
12 changed files
with
252 additions
and
178 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,24 @@ | ||
module CoursesHelper | ||
# create text for notification about new course in notification dropdown menu | ||
def course_notification_header(course) | ||
text = 'Neues Modul' + course.title | ||
def course_notification_item_header(course) | ||
'Neues Modul ' + course.title | ||
end | ||
|
||
def course_notification_details(course) | ||
# create text for notification card | ||
def course_notification_item_details(course) | ||
'Über Deine Profileinstellungen kannst Du es abonnieren.' | ||
end | ||
|
||
# create text for notification about new course in notification card | ||
def course_notification_card_text(course) | ||
'Neues Modul angelegt:' + tag(:br) + course.title | ||
end | ||
|
||
# create link for notification about new lecture in notification card | ||
def course_notification_card_link | ||
'Du kannst es über Deine ' + | ||
link_to('Profileinstellungen', edit_profile_path, | ||
class: 'darkblue') + | ||
' abonnieren.' | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,78 @@ | ||
# Notifications Helper | ||
module NotificationsHelper | ||
# create text for notification in notification dropdown menu | ||
def notification_menu_item_header(notification) | ||
notifiable = notification.notifiable | ||
return medium_notification_header(notifiable) if notification.medium? | ||
return course_notification_header(notifiable) if notification.course? | ||
return lecture_notification_header(notifiable) if notification.lecture? | ||
announcement_notification_header(notifiable) | ||
return medium_notification_item_header(notifiable) if notification.medium? | ||
return course_notification_item_header(notifiable) if notification.course? | ||
return lecture_notification_item_header(notifiable) if notification.lecture? | ||
announcement_notification_item_header(notifiable) | ||
end | ||
|
||
# create text for notification details in notification dropdown menu | ||
def notification_menu_item_details(notification) | ||
notifiable = notification.notifiable | ||
return medium_notification_details(notifiable) if notification.medium? | ||
return course_notification_details(notifiable) if notification.course? | ||
return lecture_notification_details(notifiable) if notification.lecture? | ||
return medium_notification_item_details(notifiable) if notification.medium? | ||
return course_notification_item_details(notifiable) if notification.course? | ||
if notification.lecture? | ||
return lecture_notification_item_details(notifiable) | ||
end | ||
'' | ||
end | ||
|
||
# determine the color of a notification card | ||
def notification_color(notification) | ||
return 'bg-post-it-green' if notification.sesam? | ||
return 'bg-post-it-pink' if notification.nuesse? | ||
return 'bg-post-it-light-green' if notification.quiz? | ||
return 'bg-post-it-blue' if notification.generic_announcement? | ||
return 'bg-post-it-red' if notification.announcement? | ||
return 'bg-post-it-orange' if notification.course? || notification.lecture? | ||
'bg-post-it-yellow' | ||
end | ||
|
||
# provide text or link for header of notification card | ||
def notification_header(notification) | ||
notifiable = notification.notifiable | ||
text = if notification.medium? | ||
link_to(notifiable.teachable.media_scope.title_for_viewers, | ||
polymorphic_path(notifiable.teachable.media_scope), | ||
class: 'text-dark') | ||
medium_notification_card_header(notifiable) | ||
elsif notification.course? || notification.lecture? | ||
'Kursangebot' | ||
elsif notifiable.lecture.present? | ||
link_to(notifiable.lecture.title_for_viewers, | ||
notifiable.lecture.path(current_user), | ||
class: 'text-dark') | ||
elsif notification.lecture_announcement? | ||
announcement_notification_card_header(notifiable) | ||
else | ||
link_to 'MaMpf-News', news_path, class: 'text-dark' | ||
end | ||
text.html_safe | ||
end | ||
|
||
def notification_color(notification) | ||
notifiable = notification.notifiable | ||
if notifiable.class.to_s == 'Medium' && notifiable.sort == 'Sesam' | ||
return 'bg-post-it-green' | ||
elsif notifiable.class.to_s == 'Medium' && notifiable.sort == 'Nuesse' | ||
return 'bg-post-it-pink' | ||
elsif notifiable.class.to_s == 'Medium' && notifiable.sort == 'KeksQuiz' | ||
return 'bg-post-it-light-green' | ||
elsif notifiable.class.to_s == 'Announcement' && notifiable.lecture.nil? | ||
return 'bg-post-it-blue' | ||
elsif notifiable.class.to_s == 'Announcement' | ||
return 'bg-post-it-red' | ||
elsif notifiable.class.to_s.in?(['Lecture', 'Course', 'Announcement']) | ||
return 'bg-post-it-orange' | ||
end | ||
'bg-post-it-yellow' | ||
end | ||
|
||
# provide text for body of notification card | ||
def notification_text(notification) | ||
notifiable = notification.notifiable | ||
return unless notifiable.class.to_s | ||
.in?(Notification.allowed_notifiable_types) | ||
text = if notifiable.class.to_s == 'Medium' | ||
text = if notification.medium? | ||
'Neues Medium angelegt:' | ||
elsif notifiable.class.to_s == 'Course' | ||
'Neues Modul angelegt:' + tag(:br) + notifiable.course.title | ||
elsif notifiable.class.to_s == 'Lecture' | ||
'Neue Vorlesung angelegt:' + tag(:br) + notifiable.course.title + | ||
' (' + notifiable.term.to_label + ', ' + | ||
notifiable.teacher.name + ')' | ||
elsif notification.course? | ||
course_notification_card_text(notifiable) | ||
elsif notification.lecture? | ||
lecture_notification_card_text(notifiable) | ||
else | ||
'Neue Mitteilung:' | ||
end | ||
text.html_safe | ||
end | ||
|
||
# provide link for body of notification card | ||
def notification_link(notification) | ||
notifiable = notification.notifiable | ||
if notifiable.class.to_s == 'Medium' | ||
return link_to(notifiable.local_title_for_viewers, notifiable, | ||
style: 'color: #2251dd;') | ||
elsif notifiable.class.to_s.in?(['Lecture', 'Course']) | ||
return ('Du kannst sie über Deine ' + | ||
link_to('Profileinstellungen', edit_profile_path, | ||
style: 'color: #2251dd;') + | ||
' abonnieren.').html_safe | ||
else | ||
notifiable.details | ||
end | ||
end | ||
|
||
def delete_notification_href(announcement, user) | ||
notification = user.matching_notification(announcement) | ||
return '' unless notification.present? | ||
'href=' + notification_path(notification) | ||
text = if notification.medium? | ||
medium_notification_card_link(notifiable) | ||
elsif notification.course? | ||
course_notification_card_link | ||
elsif notification.lecture? | ||
lecture_notification_card_link | ||
else | ||
notifiable.details | ||
end | ||
text.html_safe | ||
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
Oops, something went wrong.