Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be smart about case links #797

Merged
merged 2 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ class PagesController < ApplicationController
# end

# this is how we deal with the ACE editor wanting this specific file.
# There is another mode-json.js file that it wants from /assets/mode-json.js,
# and that we are able to just add to /app/assets/javascripts.

def theme_textmate
path = 'node_modules/ace-builds/src-min-noconflict/theme-textmate.js'
file_contents = File.read(path)
render js: file_contents, content_type: Mime::Type.lookup('application/javascript')
end


# In production this route kicks in, and in dev we load /assets/mode-json.js from
# the /app/assets/javascripts/mode-json.js location..
def mode_json
path = 'node_modules/ace-builds/src-min-noconflict/mode-json.js'
file_contents = File.read(path)
Expand Down
3 changes: 3 additions & 0 deletions app/models/book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class Book < ApplicationRecord
has_many :judgements, -> { order('query_doc_pair_id') },
through: :query_doc_pairs,
dependent: :destroy

has_many :cases, dependent: :nullify

scope :for_user, ->(user) {
joins('
LEFT OUTER JOIN `teams` ON `teams`.`id` = `books`.`team_id`
Expand Down
2 changes: 1 addition & 1 deletion app/views/books/_case.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= link_to kase.case_name, case_core_path(kase.id) %>
<%= link_to kase.case_name, case_core_path(kase.id, kase.last_try_number) %>
12 changes: 10 additions & 2 deletions app/views/judgements/_moar_judgements_needed.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
</div>
<% elsif book.query_doc_pairs.empty? %>
<div class="alert alert-warning" role="alert">
You don't have any query/doc pairs. Please
<%= link_to 'return to the Case', root_path, class: 'alert-link' %> and click on <b><i class="bi bi-book-half"></i> Judgements</b> to populate this book with query/doc pairs for rating.
You don't have any query/doc pairs.
<% if book.cases.empty? %>
You can populate this Book with query/doc pairs for judging by <%= link_to 'picking a Case', cases_path, class: 'alert-link' %> and using the <b><i class="bi bi-book-half"></i> Judgements</b> tool to populate this book with query/doc pairs from your search engine.
<% else %>
Return to the linked Case
<% book.cases.each do |kase| %>
<%= link_to kase.case_name, case_core_path(kase, kase.last_try_number), class: 'alert-link' %>
<% end %>
and using the <b><i class="bi bi-book-half"></i> Judgements</b> to populate this Book with query/doc pairs for judging.
<% end %>

</div>
<% else %>
Expand Down