From a97f435342bfd02fa16f74be9e2f0f9654b33494 Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 27 Feb 2020 19:47:15 -0600 Subject: [PATCH] =?UTF-8?q?aliases/implications:=20add=20=C2=BB=20links=20?= =?UTF-8?q?to=20name=20fields.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add » links to the antecedent and consequent name fields. These links let you find all tags aliased or implied to or from a given tag. For implications, this is a deep search (includes indirectly implied tags). --- app/models/tag_implication.rb | 18 ++++++++++++++++++ app/views/tag_aliases/_listing.html.erb | 2 ++ app/views/tag_implications/_listing.html.erb | 6 ++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/models/tag_implication.rb b/app/models/tag_implication.rb index d65cc5fcf..9317dc5dd 100644 --- a/app/models/tag_implication.rb +++ b/app/models/tag_implication.rb @@ -48,6 +48,24 @@ class TagImplication < TagRelationship end end + concerning :SearchMethods do + class_methods do + def search(params) + q = super + + if params[:implied_from].present? + q = q.where(id: ancestors_of(params[:implied_from]).select(:id)) + end + + if params[:implied_to].present? + q = q.where(id: descendants_of(params[:implied_to]).select(:id)) + end + + q + end + end + end + module ValidationMethods def absence_of_circular_relation return if is_rejected? diff --git a/app/views/tag_aliases/_listing.html.erb b/app/views/tag_aliases/_listing.html.erb index 09867f87e..eb43d8a4a 100644 --- a/app/views/tag_aliases/_listing.html.erb +++ b/app/views/tag_aliases/_listing.html.erb @@ -1,10 +1,12 @@ <%= table_for tag_aliases, width: "100%" do |t| %> <% t.column "From", width: "25%" do |tag_alias| %> <%= link_to tag_alias.antecedent_name, posts_path(tags: tag_alias.antecedent_name), class: tag_class(tag_alias.antecedent_tag) %> + <%= link_to "»", tag_aliases_path(search: { antecedent_name_ilike: tag_alias.antecedent_name }) %> <%= tag_alias.antecedent_tag&.post_count.to_i %> <% end %> <% t.column "To", width: "25%" do |tag_alias| %> <%= link_to tag_alias.consequent_name, posts_path(tags: tag_alias.consequent_name), class: tag_class(tag_alias.consequent_tag) %> + <%= link_to "»", tag_aliases_path(search: { consequent_name_ilike: tag_alias.consequent_name }) %> <%= tag_alias.consequent_tag&.post_count.to_i %> <% end %> <% t.column "Reference", width: "10%" do |tag_alias| %> diff --git a/app/views/tag_implications/_listing.html.erb b/app/views/tag_implications/_listing.html.erb index 09a969cc0..457818e8a 100644 --- a/app/views/tag_implications/_listing.html.erb +++ b/app/views/tag_implications/_listing.html.erb @@ -1,15 +1,17 @@ <%= table_for tag_implications, width: "100%" do |t| %> <% t.column "From", width: "25%" do |tag_implication| %> <%= link_to tag_implication.antecedent_name, posts_path(tags: tag_implication.antecedent_name), class: tag_class(tag_implication.antecedent_tag) %> + <%= link_to "»", tag_implications_path(search: { implied_from: tag_implication.antecedent_name }) %> <%= tag_implication.antecedent_tag&.post_count.to_i %> <% end %> <% t.column "To", width: "25%" do |tag_implication| %> <%= link_to tag_implication.consequent_name, posts_path(tags: tag_implication.consequent_name), class: tag_class(tag_implication.consequent_tag) %> + <%= link_to "»", tag_implications_path(search: { implied_to: tag_implication.consequent_name }) %> <%= tag_implication.consequent_tag&.post_count.to_i %> <% end %> - <% t.column "Reference", width: "10%" do |tag_implication| %> + <% t.column "Topic", width: "10%" do |tag_implication| %> <% if tag_implication.forum_topic_id %> - <%= link_to tag_implication.forum_topic_id, forum_topic_path(tag_implication.forum_topic_id) %> + <%= link_to "topic ##{tag_implication.forum_topic_id}", forum_topic_path(tag_implication.forum_topic_id) %> <% end %> <% end %> <% t.column "Approver", width: "15%" do |tag_implication| %>