mumuki-laboratory 9.0.2 → 9.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/mumuki_laboratory/application/codemirror.js +10 -2
- data/app/assets/javascripts/mumuki_laboratory/application/discussions.js +49 -8
- data/app/assets/javascripts/mumuki_laboratory/application/faqs.js +14 -4
- data/app/assets/javascripts/mumuki_laboratory/application/gamification.js +3 -3
- data/app/assets/javascripts/mumuki_laboratory/application/kids.js +11 -7
- data/app/assets/javascripts/mumuki_laboratory/application/kindergarten.js +3 -3
- data/app/assets/javascripts/mumuki_laboratory/application/messages.js +3 -3
- data/app/assets/javascripts/mumuki_laboratory/application/mu-modal-carrousel.js +4 -4
- data/app/assets/javascripts/mumuki_laboratory/application/multiple-files.js +18 -5
- data/app/assets/javascripts/mumuki_laboratory/application/multiple-scenarios.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/organization.js +32 -0
- data/app/assets/javascripts/mumuki_laboratory/application/primary.js +4 -4
- data/app/assets/javascripts/mumuki_laboratory/application/profile.js +0 -6
- data/app/assets/javascripts/mumuki_laboratory/application/progress.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/speech-bubble-renderer.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/submission.js +4 -3
- data/app/assets/javascripts/mumuki_laboratory/application/submissions-store.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/toast.js +3 -0
- data/app/assets/javascripts/mumuki_laboratory/application/tooltip.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/upload.js +2 -2
- data/app/assets/javascripts/mumuki_laboratory/application/user.js +49 -5
- data/app/assets/stylesheets/mumuki_laboratory/application.scss +0 -1
- data/app/assets/stylesheets/mumuki_laboratory/application/_errors.scss +1 -1
- data/app/assets/stylesheets/mumuki_laboratory/application/_layout.scss +1 -27
- data/app/assets/stylesheets/mumuki_laboratory/application/_modules.scss +1 -2
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_activity.scss +14 -0
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_avatar.scss +5 -0
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_breadcrumb.scss +2 -2
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_datepicker.scss +0 -4
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_discussion.scss +49 -59
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_editor.scss +16 -18
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_exercise_assignment.scss +2 -11
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_exercise_results.scss +1 -7
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_faqs.scss +30 -8
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_flash.scss +7 -46
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kids.scss +19 -4
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kids_results.scss +18 -23
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kindergarten.scss +1 -9
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_overlap.scss +1 -1
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_progress_bar.scss +5 -5
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_terms.scss +3 -2
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_timer.scss +1 -3
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_user_menu.scss +38 -3
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_user_profile.scss +1 -2
- data/app/controllers/application_controller.rb +4 -2
- data/app/controllers/discussions_messages_controller.rb +9 -3
- data/app/controllers/users_controller.rb +13 -0
- data/app/helpers/application_helper.rb +5 -5
- data/app/helpers/assignment_result_helper.rb +3 -2
- data/app/helpers/assistance_box_helper.rb +1 -1
- data/app/helpers/concerns/with_student_path_navigation.rb +8 -3
- data/app/helpers/concerns/with_student_path_navigation/continue_navigation.rb +1 -1
- data/app/helpers/concerns/with_student_path_navigation/finish_navigation.rb +1 -1
- data/app/helpers/concerns/with_student_path_navigation/next_parent_navigation.rb +7 -0
- data/app/helpers/concerns/with_student_path_navigation/revisit_navigation.rb +1 -1
- data/app/helpers/discussions_helper.rb +64 -23
- data/app/helpers/editor_tabs_helper.rb +10 -6
- data/app/helpers/email_helper.rb +2 -2
- data/app/helpers/exercise_input_helper.rb +2 -3
- data/app/helpers/links_helper.rb +12 -9
- data/app/helpers/menu_bar_helper.rb +1 -1
- data/app/helpers/messages_helper.rb +1 -1
- data/app/helpers/multiple_file_editor_helper.rb +2 -1
- data/app/helpers/overlapped_buttons_helper.rb +22 -12
- data/app/helpers/profile_helper.rb +3 -3
- data/app/helpers/toast_helper.rb +27 -0
- data/app/helpers/user_activity_helper.rb +48 -0
- data/app/helpers/user_menu_helper.rb +24 -6
- data/app/views/book/show.html.erb +2 -2
- data/app/views/certificates/verify.html.erb +1 -1
- data/app/views/chapters/show.html.erb +2 -2
- data/app/views/discussions/_description_message.html.erb +1 -1
- data/app/views/discussions/_message.html.erb +32 -7
- data/app/views/discussions/_new_message.html.erb +13 -2
- data/app/views/discussions/index.html.erb +8 -10
- data/app/views/discussions/new.html.erb +2 -2
- data/app/views/discussions/show.html.erb +20 -12
- data/app/views/exam_registrations/show.html.erb +10 -11
- data/app/views/exercise_solutions/_assistant_rules_box.html.erb +1 -1
- data/app/views/exercise_solutions/_contextualization_results_body.html.erb +1 -1
- data/app/views/exercise_solutions/_contextualization_results_container.html.erb +1 -1
- data/app/views/exercise_solutions/_kids_results_button.html.erb +2 -2
- data/app/views/exercise_solutions/_results.html.erb +1 -1
- data/app/views/exercises/_exercise_assignment.html.erb +2 -2
- data/app/views/exercises/_exercise_skipped.html.erb +1 -1
- data/app/views/exercises/_read_only.html.erb +108 -105
- data/app/views/exercises/show.html.erb +7 -7
- data/app/views/faqs/index.html.erb +5 -1
- data/app/views/guides/_guide.html.erb +1 -1
- data/app/views/guides/_guide_container.html.erb +4 -4
- data/app/views/invitations/_invitation_form.html.erb +5 -4
- data/app/views/layouts/_authoring.html.erb +1 -1
- data/app/views/layouts/_discussions.html.erb +7 -7
- data/app/views/layouts/_kids.html.erb +5 -5
- data/app/views/layouts/_kindergarten.html.erb +10 -6
- data/app/views/layouts/_main.html.erb +10 -10
- data/app/views/layouts/_organizations_listing.html.erb +2 -2
- data/app/views/layouts/_progress_bar.html.erb +2 -0
- data/app/views/layouts/_submission_result_error.html.erb +1 -1
- data/app/views/layouts/_test_results.html.erb +1 -1
- data/app/views/layouts/_timer.html.erb +1 -1
- data/app/views/layouts/_user_menu.html.erb +13 -20
- data/app/views/layouts/application.html.erb +39 -42
- data/app/views/layouts/exercise_inputs/editors/_code.html.erb +4 -4
- data/app/views/layouts/exercise_inputs/editors/_free_form.html.erb +1 -1
- data/app/views/layouts/exercise_inputs/editors/_multiple_choice.html.erb +7 -9
- data/app/views/layouts/exercise_inputs/editors/_multiple_files.html.erb +10 -10
- data/app/views/layouts/exercise_inputs/editors/_single_choice.html.erb +6 -8
- data/app/views/layouts/exercise_inputs/editors/_text.html.erb +2 -3
- data/app/views/layouts/exercise_inputs/editors/_upload.html.erb +5 -5
- data/app/views/layouts/exercise_inputs/forms/_form.html.erb +1 -1
- data/app/views/layouts/exercise_inputs/forms/_interactive_form.html.erb +2 -2
- data/app/views/layouts/exercise_inputs/forms/_kids_form.html.erb +1 -1
- data/app/views/layouts/exercise_inputs/forms/_playground_form.html.erb +2 -2
- data/app/views/layouts/exercise_inputs/forms/_problem_form.html.erb +13 -9
- data/app/views/layouts/exercise_inputs/layouts/_input_primary.html.erb +2 -2
- data/app/views/layouts/exercise_inputs/layouts/_input_right.html.erb +2 -2
- data/app/views/layouts/exercise_inputs/read_only_editors/_code.html.erb +1 -1
- data/app/views/layouts/exercise_inputs/read_only_editors/_free_form.html.erb +1 -1
- data/app/views/layouts/exercise_inputs/read_only_editors/_multiple_choice.html.erb +4 -4
- data/app/views/layouts/exercise_inputs/read_only_editors/_multiple_files.html.erb +2 -2
- data/app/views/layouts/exercise_inputs/read_only_editors/_single_choice.html.erb +4 -4
- data/app/views/layouts/exercise_inputs/read_only_editors/_text.erb +1 -1
- data/app/views/layouts/modals/_avatar_picker.html.erb +2 -5
- data/app/views/layouts/modals/_guide_corollary.html.erb +4 -8
- data/app/views/layouts/modals/_kids_context.html.erb +7 -5
- data/app/views/layouts/modals/_kids_results.html.erb +2 -2
- data/app/views/layouts/modals/_kids_results_aborted.html.erb +2 -2
- data/app/views/layouts/modals/_kindergarten_context.html.erb +3 -3
- data/app/views/layouts/modals/_kindergarten_results.html.erb +3 -3
- data/app/views/layouts/modals/_kindergarten_results_aborted.html.erb +2 -2
- data/app/views/layouts/modals/_level_up.html.erb +2 -5
- data/app/views/layouts/modals/_new_message.html.erb +5 -5
- data/app/views/notifications/_dropdown.html.erb +3 -3
- data/app/views/users/_activity_indicator.html.erb +17 -0
- data/app/views/users/_edit_user_form.html.erb +6 -6
- data/app/views/users/_profile_fields.html.erb +6 -6
- data/app/views/users/_user_form.html.erb +2 -2
- data/app/views/users/activity.html.erb +37 -0
- data/app/views/users/certificates.html.erb +26 -24
- data/app/views/users/discussions.html.erb +23 -21
- data/app/views/users/messages.html.erb +22 -20
- data/app/views/users/show.html.erb +5 -3
- data/app/views/users/terms.html.erb +4 -2
- data/config/initializers/inflections.rb +3 -0
- data/config/routes.rb +3 -0
- data/lib/mumuki/laboratory.rb +1 -1
- data/lib/mumuki/laboratory/extensions.rb +1 -0
- data/lib/mumuki/laboratory/extensions/date_and_time.rb +11 -0
- data/lib/mumuki/laboratory/locales/en.yml +28 -2
- data/lib/mumuki/laboratory/locales/es-CL.yml +33 -4
- data/lib/mumuki/laboratory/locales/es.yml +33 -4
- data/lib/mumuki/laboratory/locales/pt.yml +34 -3
- data/lib/mumuki/laboratory/version.rb +1 -1
- data/spec/capybara_helper.rb +1 -0
- data/spec/controllers/discussions_messages_controller_spec.rb +84 -3
- data/spec/dummy/db/schema.rb +23 -3
- data/spec/features/discussion_flow_spec.rb +22 -2
- data/spec/features/exercise_flow_spec.rb +1 -1
- data/spec/features/guide_reset_spec.rb +1 -1
- data/spec/features/terms_flow_spec.rb +1 -2
- data/spec/features/user_activity_flow_spec.rb +65 -0
- data/spec/helpers/breadcrumbs_helper_spec.rb +2 -2
- data/spec/helpers/user_activity_helper_spec.rb +32 -0
- data/spec/helpers/with_navigation_spec.rb +36 -13
- data/spec/javascripts/editors-spec.js +3 -3
- data/spec/javascripts/kids-button-spec.js +2 -2
- data/spec/javascripts/upload-spec.js +8 -8
- metadata +133 -123
- data/app/assets/stylesheets/mumuki_laboratory/application/hovers.scss +0 -12
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_checkboxes.scss +0 -34
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_guide_corollary.scss +0 -9
@@ -1,12 +1,44 @@
|
|
1
1
|
.mu-user-menu {
|
2
2
|
display: flex;
|
3
|
+
margin-top: 25px;
|
4
|
+
}
|
5
|
+
|
6
|
+
.mu-user-menu-content {
|
7
|
+
flex-grow: 1;
|
3
8
|
}
|
4
9
|
|
5
10
|
.mu-user-menu-header {
|
6
11
|
font-size: 15px;
|
7
12
|
color: $mu-color-disabled;
|
8
13
|
text-transform: uppercase;
|
9
|
-
|
14
|
+
cursor: pointer;
|
15
|
+
|
16
|
+
@include media-breakpoint-up(md) {
|
17
|
+
cursor: auto;
|
18
|
+
|
19
|
+
i {
|
20
|
+
display: none;
|
21
|
+
}
|
22
|
+
|
23
|
+
span {
|
24
|
+
padding-left: 0;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
.mu-user-menu-items {
|
30
|
+
margin-top: 30px;
|
31
|
+
|
32
|
+
@include media-breakpoint-down(md) {
|
33
|
+
margin-left: 15px;
|
34
|
+
margin-right: 15px;
|
35
|
+
}
|
36
|
+
|
37
|
+
&.mu-hidden-sm-screen {
|
38
|
+
@include media-breakpoint-down(md) {
|
39
|
+
display: none;
|
40
|
+
}
|
41
|
+
}
|
10
42
|
}
|
11
43
|
|
12
44
|
.mu-user-menu-item {
|
@@ -14,7 +46,7 @@
|
|
14
46
|
margin-bottom: 5px;
|
15
47
|
|
16
48
|
a {
|
17
|
-
color: $
|
49
|
+
color: $primary;
|
18
50
|
&.active {
|
19
51
|
font-weight: bold;
|
20
52
|
}
|
@@ -30,6 +62,9 @@
|
|
30
62
|
border-top: 2px solid $mu-color-separator;
|
31
63
|
|
32
64
|
margin: 25px 0;
|
33
|
-
|
65
|
+
|
66
|
+
@include media-breakpoint-up(md) {
|
67
|
+
margin-right: 15px;
|
68
|
+
}
|
34
69
|
}
|
35
70
|
}
|
@@ -6,12 +6,10 @@
|
|
6
6
|
}
|
7
7
|
|
8
8
|
.mu-profile-actions {
|
9
|
-
vertical-align: middle;
|
10
9
|
margin-left: auto;
|
11
10
|
|
12
11
|
.btn {
|
13
12
|
width: 150px;
|
14
|
-
height: 55px;
|
15
13
|
margin-left: 15px;
|
16
14
|
transition: background-color 0.3s, border-color 0.3s;
|
17
15
|
|
@@ -82,3 +80,4 @@
|
|
82
80
|
}
|
83
81
|
}
|
84
82
|
}
|
83
|
+
|
@@ -43,6 +43,8 @@ class ApplicationController < ActionController::Base
|
|
43
43
|
:extension_javascript_url,
|
44
44
|
:current_immersive_path
|
45
45
|
|
46
|
+
add_flash_types :info
|
47
|
+
|
46
48
|
def immersive_context_wrong?
|
47
49
|
current_immersive_context != Organization.current
|
48
50
|
end
|
@@ -124,7 +126,7 @@ class ApplicationController < ActionController::Base
|
|
124
126
|
def validate_user_profile!
|
125
127
|
unless current_user.profile_completed?
|
126
128
|
save_location_before! :profile_completion
|
127
|
-
flash
|
129
|
+
flash[:info] = I18n.t :please_fill_profile_data
|
128
130
|
redirect_to edit_user_path
|
129
131
|
end
|
130
132
|
end
|
@@ -132,7 +134,7 @@ class ApplicationController < ActionController::Base
|
|
132
134
|
def validate_accepted_role_terms!
|
133
135
|
if current_user&.has_role_terms_to_accept?
|
134
136
|
save_location_before! :terms_acceptance
|
135
|
-
flash
|
137
|
+
flash[:info] = I18n.t :accept_terms_to_continue
|
136
138
|
redirect_to terms_user_path
|
137
139
|
end
|
138
140
|
end
|
@@ -3,7 +3,7 @@ class DiscussionsMessagesController < AjaxController
|
|
3
3
|
|
4
4
|
before_action :set_discussion!, only: [:create, :destroy]
|
5
5
|
before_action :authorize_user!, only: [:destroy]
|
6
|
-
before_action :authorize_moderator!, only: [:question, :approve]
|
6
|
+
before_action :authorize_moderator!, only: [:question, :approve, :preview]
|
7
7
|
|
8
8
|
def create
|
9
9
|
@discussion.submit_message! message_params, current_user
|
@@ -11,12 +11,18 @@ class DiscussionsMessagesController < AjaxController
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def destroy
|
14
|
-
|
14
|
+
authorize_moderator! unless params[:motive] == :self_deleted.to_s
|
15
|
+
|
16
|
+
current_message.soft_delete! params[:motive], current_user
|
15
17
|
redirect_back(fallback_location: root_path)
|
16
18
|
end
|
17
19
|
|
20
|
+
def preview
|
21
|
+
render json: { preview: Message.new(content: params[:content]).content_html }
|
22
|
+
end
|
23
|
+
|
18
24
|
def approve
|
19
|
-
current_message.toggle_approved!
|
25
|
+
current_message.toggle_approved! current_user
|
20
26
|
head :ok
|
21
27
|
end
|
22
28
|
|
@@ -30,6 +30,10 @@ class UsersController < ApplicationController
|
|
30
30
|
@watched_discussions = current_user.watched_discussions_in_organization
|
31
31
|
end
|
32
32
|
|
33
|
+
def activity
|
34
|
+
@activity = UserStats.stats_for(current_user).activity date_range_params
|
35
|
+
end
|
36
|
+
|
33
37
|
def certificates
|
34
38
|
@certificates ||= current_user.certificates_in_organization
|
35
39
|
end
|
@@ -54,4 +58,13 @@ class UsersController < ApplicationController
|
|
54
58
|
@user = current_user
|
55
59
|
end
|
56
60
|
|
61
|
+
def date_range_params
|
62
|
+
@date_from = params[:date_from].try { |it| Date.parse it }
|
63
|
+
to = params[:date_to].try { |it| Date.parse it }
|
64
|
+
if @date_from && to
|
65
|
+
@date_from.beginning_of_day..(to - 1.day).end_of_day
|
66
|
+
else
|
67
|
+
nil
|
68
|
+
end
|
69
|
+
end
|
57
70
|
end
|
@@ -12,12 +12,12 @@ module ApplicationHelper
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def avatar_image(avatar_url, **options)
|
15
|
-
options.merge!(class: "
|
15
|
+
options.merge!(class: "rounded-circle #{options[:class]}")
|
16
16
|
image_tag(image_url(avatar_url), options)
|
17
17
|
end
|
18
18
|
|
19
19
|
def paginate(object, options = {})
|
20
|
-
|
20
|
+
super(object, {theme: 'bootstrap-5', pagination_class: 'flex-wrap justify-content-center'}.merge(options))
|
21
21
|
end
|
22
22
|
|
23
23
|
def last_box_class(trailing_boxes)
|
@@ -38,10 +38,10 @@ module ApplicationHelper
|
|
38
38
|
t :chapter_finished_html, chapter: link_to_path_element(chapter) if chapter
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
41
|
+
def btn_toggle(hidden_text, active_text, active, **options)
|
42
42
|
%Q{
|
43
|
-
<
|
44
|
-
<
|
43
|
+
<button class="btn btn-complementary #{'d-none' if active} #{options[:class]}" onclick="#{options[:onclick]}">#{hidden_text}</button>
|
44
|
+
<button class="btn btn-secondary #{'d-none' unless active} #{options[:class]}" onclick="#{options[:onclick]}">#{active_text}</button>
|
45
45
|
}.html_safe
|
46
46
|
end
|
47
47
|
|
@@ -15,7 +15,8 @@ module AssignmentResultHelper
|
|
15
15
|
|
16
16
|
def render_community_link
|
17
17
|
if community_link?
|
18
|
-
link_to fa_icon('facebook-f', type: :brand, text: I18n.t(:ask_community), class: 'fa-fw'),
|
18
|
+
link_to fa_icon('facebook-f', type: :brand, text: I18n.t(:ask_community), class: 'fa-fw'),
|
19
|
+
community_link, target: '_blank', class: 'dropdown-item'
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
@@ -25,7 +26,7 @@ module AssignmentResultHelper
|
|
25
26
|
fa_icon(:bug, text: t(:notify_problem_with_exercise), class: 'fa-fw'),
|
26
27
|
subject: t(:problem_with_exercise, title: @exercise.name),
|
27
28
|
body: assignment_help_email_body(assignment),
|
28
|
-
class: '
|
29
|
+
class: 'dropdown-item'
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module WithStudentPathNavigation
|
2
2
|
def next_button(navigable)
|
3
3
|
return unless navigable
|
4
|
-
|
5
|
-
#TODO Refactor this
|
4
|
+
navigation_flows.lazy.map { |it| it.new(self).button(navigable) }.find(&:present?)
|
6
5
|
end
|
7
6
|
|
8
7
|
def next_lesson_button(guide)
|
@@ -14,6 +13,12 @@ module WithStudentPathNavigation
|
|
14
13
|
end
|
15
14
|
|
16
15
|
def close_modal_button
|
17
|
-
%Q{<button class="btn btn-
|
16
|
+
%Q{<button class="btn btn-complementary w-100 mu-close-modal">#{t :keep_learning}</button>}.html_safe
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def navigation_flows
|
22
|
+
[ContinueNavigation, RevisitNavigation, NextParentNavigation, FinishNavigation]
|
18
23
|
end
|
19
24
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module DiscussionsHelper
|
2
2
|
def read_discussions_link(item)
|
3
|
-
discussions_link others_discussions_icon(t(:solve_your_doubts)), item_discussions_path(item, default_discussions_params)
|
3
|
+
discussions_link others_discussions_icon(t(:solve_your_doubts)), item_discussions_path(item, default_discussions_params), class: 'dropdown-item'
|
4
4
|
end
|
5
5
|
|
6
6
|
def kids_read_discussions_link(item)
|
@@ -8,11 +8,11 @@ module DiscussionsHelper
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def solve_discussions_link
|
11
|
-
discussions_link others_discussions_icon(t(:solve_doubts)), discussions_path(solve_discussion_params_for(current_user))
|
11
|
+
discussions_link others_discussions_icon(t(:solve_doubts)), discussions_path(solve_discussion_params_for(current_user)), class: 'dropdown-item'
|
12
12
|
end
|
13
13
|
|
14
14
|
def user_discussions_link
|
15
|
-
discussions_link
|
15
|
+
discussions_link(user_discussions_icon(t(:my_doubts)), discussions_user_path, class: 'dropdown-item') if current_user.watched_discussions.present?
|
16
16
|
end
|
17
17
|
|
18
18
|
def others_discussions_icon(text)
|
@@ -60,18 +60,6 @@ module DiscussionsHelper
|
|
60
60
|
}.html_safe
|
61
61
|
end
|
62
62
|
|
63
|
-
def discussions_link_with_teaser(item)
|
64
|
-
%Q{
|
65
|
-
<div>
|
66
|
-
<h3>#{t(:discussions)}</h3>
|
67
|
-
<p>
|
68
|
-
#{t(:solve_your_doubts_teaser)}
|
69
|
-
#{read_discussions_link(item)}
|
70
|
-
</p>
|
71
|
-
</div>
|
72
|
-
}.html_safe
|
73
|
-
end
|
74
|
-
|
75
63
|
def discussion_messages_icon(discussion)
|
76
64
|
%Q{
|
77
65
|
<span class="discussion-icon fa-stack fa-xs">
|
@@ -148,7 +136,7 @@ module DiscussionsHelper
|
|
148
136
|
if filters.present?
|
149
137
|
%Q{
|
150
138
|
<div class="dropdown discussions-toolbar-filter">
|
151
|
-
<a id="dropdown-#{label}" data-toggle="dropdown" role="menu">
|
139
|
+
<a id="dropdown-#{label}" data-bs-toggle="dropdown" role="menu">
|
152
140
|
#{t label} #{fa_icon :'caret-down', class: 'fa-xs'}
|
153
141
|
</a>
|
154
142
|
<ul class="dropdown-menu" aria-labelledby="dropdown-#{label}">
|
@@ -161,17 +149,17 @@ module DiscussionsHelper
|
|
161
149
|
end
|
162
150
|
|
163
151
|
def discussion_filter_list(label, filters, &block)
|
164
|
-
filters.map { |it| discussion_filter_item(label, it, &block) }.join("\n")
|
152
|
+
filters.map { |it| discussion_filter_item(label, it, 'dropdown-item', &block) }.join("\n")
|
165
153
|
end
|
166
154
|
|
167
|
-
def discussion_filter_item(label, filter, &block)
|
168
|
-
content_tag(:li, discussion_filter_link(label, filter, &block), class: ('selected' if discussion_filter_selected?(label, filter)))
|
155
|
+
def discussion_filter_item(label, filter, link_class=nil, &block)
|
156
|
+
content_tag(:li, discussion_filter_link(label, filter, link_class, &block), class: ('selected' if discussion_filter_selected?(label, filter)))
|
169
157
|
end
|
170
158
|
|
171
159
|
def discussion_filter_unselect_item(label, can_select_all)
|
172
160
|
if can_select_all
|
173
161
|
content_tag(:li,
|
174
|
-
link_to(t(:all), discussion_filter_params_without_page.except(label)),
|
162
|
+
link_to(t(:all), discussion_filter_params_without_page.except(label), class: 'dropdown-item'),
|
175
163
|
class: ('selected' unless discussion_filter_params.include?(label)))
|
176
164
|
end
|
177
165
|
end
|
@@ -180,12 +168,12 @@ module DiscussionsHelper
|
|
180
168
|
filter.to_s == discussion_filter_params[label]
|
181
169
|
end
|
182
170
|
|
183
|
-
def discussion_filter_link(label, filter, &block)
|
184
|
-
link_to capture(filter, &block), discussion_filter_params_without_page.merge(Hash[label, filter])
|
171
|
+
def discussion_filter_link(label, filter, clazz, &block)
|
172
|
+
link_to capture(filter, &block), discussion_filter_params_without_page.merge(Hash[label, filter]), class: clazz
|
185
173
|
end
|
186
174
|
|
187
175
|
def discussion_info(discussion)
|
188
|
-
"#{t(:time_since, time: time_ago_in_words(discussion.created_at))} · #{t(:message_count, count: discussion.
|
176
|
+
"#{t(:time_since, time: time_ago_in_words(discussion.created_at))} · #{t(:message_count, count: discussion.visible_messages.size)}"
|
189
177
|
end
|
190
178
|
|
191
179
|
def discussion_filter_params_without_page
|
@@ -195,4 +183,57 @@ module DiscussionsHelper
|
|
195
183
|
def should_show_approved_for?(user, message)
|
196
184
|
!user&.moderator_here? && message.approved? && !message.from_moderator?
|
197
185
|
end
|
186
|
+
|
187
|
+
def discussion_user_name(user)
|
188
|
+
user.abbreviated_name
|
189
|
+
end
|
190
|
+
|
191
|
+
def subscription_icon
|
192
|
+
fa_icon :bell, text: t(:subscribe)
|
193
|
+
end
|
194
|
+
|
195
|
+
def unsubscription_icon
|
196
|
+
fa_icon :bell, type: :regular, text: t(:unsubscribe)
|
197
|
+
end
|
198
|
+
|
199
|
+
def upvote_icon
|
200
|
+
fa_icon 'thumbs-up', text: t(:upvote)
|
201
|
+
end
|
202
|
+
|
203
|
+
def undo_upvote_icon
|
204
|
+
fa_icon 'thumbs-up', type: :regular, text: t(:undo_upvote)
|
205
|
+
end
|
206
|
+
|
207
|
+
def discussion_delete_message_link(discussion, message)
|
208
|
+
link_to fa_icon('trash-alt', type: :regular, class: 'fa-lg'), discussion_message_path(discussion, message, motive: :self_deleted),
|
209
|
+
method: :delete, data: { confirm: t(:are_you_sure, action: t(:destroy_message)) }, class: 'discussion-delete-message'
|
210
|
+
end
|
211
|
+
|
212
|
+
def discussion_delete_message_dropdown(discussion, message)
|
213
|
+
%Q{
|
214
|
+
<span class="dropdown">
|
215
|
+
#{content_tag :span, fa_icon('trash-alt', type: :regular, class: 'fa-lg'), role: 'menu', 'data-bs-toggle': 'dropdown',
|
216
|
+
class: 'discussion-delete-message', id: 'deleteDiscussionDropdown'}
|
217
|
+
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="deleteDiscussionDropdown">
|
218
|
+
#{discussion_delete_message_option discussion, message, :inappropriate_content, 'times-circle'}
|
219
|
+
#{discussion_delete_message_option discussion, message, :shares_solution, :code}
|
220
|
+
#{discussion_delete_message_option discussion, message, :discloses_personal_information, 'user-tag'}
|
221
|
+
</ul>
|
222
|
+
</span>
|
223
|
+
}.html_safe
|
224
|
+
end
|
225
|
+
|
226
|
+
def discussion_delete_message_option(discussion, message, motive, icon)
|
227
|
+
%Q{
|
228
|
+
<li>
|
229
|
+
#{link_to fa_icon(icon, text: t("deletion_motive.#{motive}.present"), class: 'fa-fw fixed-icon'),
|
230
|
+
discussion_message_path(discussion, message, motive: motive), method: :delete, class: 'dropdown-item',
|
231
|
+
role: 'menuitem', data: { confirm: t(:are_you_sure, action: t(:destroy_message)) } }
|
232
|
+
</li>
|
233
|
+
}.html_safe
|
234
|
+
end
|
235
|
+
|
236
|
+
def message_deleted_text(message)
|
237
|
+
t(:message_deleted, motive: t("deletion_motive.#{message.deletion_motive}.past").downcase, forum_terms: link_to_forum_terms).html_safe
|
238
|
+
end
|
198
239
|
end
|