diff --git a/src/actions/mixins/page_helpers.cr b/src/actions/mixins/page_helpers.cr index 510841f..9060562 100644 --- a/src/actions/mixins/page_helpers.cr +++ b/src/actions/mixins/page_helpers.cr @@ -1,4 +1,21 @@ module PageHelpers + def show_university_batch_levels(university_name, university_code, university_batch_level) + batch_names = UniversityQuery.new + .name.like("#{university_name}%") + .reject { |e| e.code == university_code && e.batch_level == university_batch_level } + .map { |e| [e.name, e.batch_level.display_name] } + + str = String.build do |io| + io << "名称相似的其他学校:\n" + + io << "\n" unless batch_names.blank? + + batch_names.each do |e| + io << "#{e[0]}, #{e[1]}\n" + end + end + end + def show_score_info(university, year, score_value) if score_value.blank? "" diff --git a/src/components/universities/name_link.cr b/src/components/universities/name_link.cr index 89e07d2..71f2126 100644 --- a/src/components/universities/name_link.cr +++ b/src/components/universities/name_link.cr @@ -1,4 +1,6 @@ class Universities::NameLink < BaseComponent + include PageHelpers + needs university : University needs current_user : User @@ -7,17 +9,21 @@ class Universities::NameLink < BaseComponent name = university.name if university.is_985 - name = "#{name}/985" + full_name = "#{name}/985" elsif university.is_211 - name = "#{name}/211" + full_name = "#{name}/211" elsif university.is_good - name = "#{name}/双一流" + full_name = "#{name}/双一流" + else + full_name = name end a( - name, + full_name, href: "#", - class: "dropdown-trigger", + class: "dropdown-trigger tooltipped", + "data-position": "top", + "data-tooltip": show_university_batch_levels(name, university.code, university.batch_level), data_target: "dropdown3", id: id, marked_2023: university.marked_2023(current_user),