From a124b63f56618f79e032c4e1b3cc545cd01d81ef Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 23 Mar 2023 15:28:18 -0700 Subject: [PATCH] fix basil guidance bug & polish UI for release --- app/controllers/basil_controller.rb | 6 +- app/models/concerns/is_content_page.rb | 2 + app/views/basil/content.html.erb | 125 ++++++++++-------- .../display/sidebar/_references.html.erb | 6 +- app/views/content/show.html.erb | 2 +- 5 files changed, 84 insertions(+), 57 deletions(-) diff --git a/app/controllers/basil_controller.rb b/app/controllers/basil_controller.rb index 6b9a61d6..4c046fc0 100644 --- a/app/controllers/basil_controller.rb +++ b/app/controllers/basil_controller.rb @@ -42,7 +42,11 @@ class BasilController < ApplicationController raise "No content found for #{params[:content_type]} with ID #{params[:id]} for user #{current_user.id}" if @content.nil? # Fetch any existing Basil configurations/guidance for this character - @guidance = BasilFieldGuidance.find_or_initialize_by(entity: @content, user: current_user).try(:guidance) + @guidance = BasilFieldGuidance.find_or_initialize_by( + entity_type: @content.page_type, + entity_id: @content.id, + user: current_user + ).try(:guidance) @guidance ||= {} # Fetch all the related fields for this content type and their values diff --git a/app/models/concerns/is_content_page.rb b/app/models/concerns/is_content_page.rb index 718797a4..36b74a73 100644 --- a/app/models/concerns/is_content_page.rb +++ b/app/models/concerns/is_content_page.rb @@ -18,6 +18,8 @@ module IsContentPage has_many :timeline_events, through: :timeline_event_entities has_many :timelines, -> { distinct }, through: :timeline_events + has_many :basil_commissions, as: :entity, dependent: :destroy + has_many :word_count_updates, as: :entity, dependent: :destroy def latest_word_count_cache word_count_updates.order('for_date DESC').limit(1).first.try(:word_count) || 0 diff --git a/app/views/basil/content.html.erb b/app/views/basil/content.html.erb index 8194e7e5..c02cdbf0 100644 --- a/app/views/basil/content.html.erb +++ b/app/views/basil/content.html.erb @@ -15,17 +15,22 @@ function commission_basil(style) { <%= f.hidden_field :entity_id, value: @content.id %>
+ <%= link_to basil_path, class: 'grey-text text-darken-2' do %> + Basil + <% end %> + chevron_right <%= link_to basil_content_index_path(content_type: @content.page_type), class: 'grey-text text-darken-2' do %> - chevron_left - Back to my <%= @content.page_type.downcase.pluralize %> list + <%= @content.page_type.pluralize %> <% end %>
<%= image_tag @content.random_image_including_private(format: :medium), style: 'width: 100%' %>

- <%= link_to @content.name, @content.view_path %> + <%= link_to @content.name, @content.view_path, class: @content.text_color %>

- <%= link_to 'Edit this page', @content.edit_path, class: 'grey-text text-darken-2' %> + <%= link_to @content.edit_path, class: 'grey-text text-darken-2' do %> + Edit this <%= @content.page_type.downcase %> + <% end %>