Browse Source

Fix UX for clickable links

pull/136/head
Alexander D. Bondoc 4 years ago
parent
commit
08480eab46
No known key found for this signature in database
GPG Key ID: 2CCA40FDDA18E7F8
  1. 2
      app/components/citation_index_table_component/citation_index_table_component.html.erb
  2. 4
      app/components/doctrine_index_component/doctrine_index_component.html.erb
  3. 4
      app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb
  4. 6
      app/components/doctrines_offcanvas_accordion_component/doctrines_offcanvas_accordion_component.html.erb
  5. 6
      app/components/doctrines_offcanvas_component/doctrines_offcanvas_component.html.erb
  6. 4
      app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb
  7. 3
      app/components/jurisprudences_index_table_component/jurisprudences_index_table_component.html.erb
  8. 4
      app/components/reports_search_results_component/reports_search_results_component.html.erb
  9. 12
      app/components/subjects_accordion_component/subjects_accordion_component.html.erb
  10. 6
      app/components/subjects_offcanvas_accordion_component/subjects_offcanvas_accordion_component.html.erb
  11. 6
      app/components/subjects_offcanvas_component/subjects_offcanvas_component.html.erb
  12. 2
      app/controllers/concerns/document_search.rb
  13. 2
      app/controllers/concerns/jurisprudence_search.rb
  14. 26
      app/javascript/controllers/application_controller.js
  15. 1
      app/javascript/controllers/doctrines_controller.js
  16. 3
      app/javascript/controllers/subjects_controller.js
  17. 9
      app/models/cdao/subject.rb
  18. 6
      app/views/subject_indexes/index.html.erb
  19. 6
      app/views/subject_indexes/show.html.erb

2
app/components/citation_index_table_component/citation_index_table_component.html.erb

@ -1,4 +1,4 @@
<tr href="<%= document_path(search_result.id, is_citator_tab: true) %>" class="clickable-tr" target="_blank"> <tr class="clickable-tr" data-controller="application" data-href="<%= document_path(search_result.id, is_citator_tab: true) %>" data-action="click->application#openLinkToNewTab">
<td> <%= clean_reference_number %> </td> <td> <%= clean_reference_number %> </td>
<td> <%= short_title || title %> </td> <td> <%= short_title || title %> </td>
<td> <%= date_or_year %> </td> <td> <%= date_or_year %> </td>

4
app/components/doctrine_index_component/doctrine_index_component.html.erb

@ -11,7 +11,9 @@
<% grouped_by_juris_search_params = { subject_ids: opts[:subject_ids], content: content_result.content, is_grouped_by_juris_id: true } %> <% grouped_by_juris_search_params = { subject_ids: opts[:subject_ids], content: content_result.content, is_grouped_by_juris_id: true } %>
<% search_doctrines(grouped_by_juris_search_params).group(:jurisprudence_id).groups.each do |grouped_by_juris| %> <% search_doctrines(grouped_by_juris_search_params).group(:jurisprudence_id).groups.each do |grouped_by_juris| %>
<% grouped_by_juris.results.each do |juris_result| %> <% grouped_by_juris.results.each do |juris_result| %>
<h5 class="clickable-link" style="color: darkred;" href="<%= document_path(juris_result.jurisprudence.document.id, is_index_table: false, subject_ids: params[:subject_ids]) %>"> <h5 class="clickable-link" style="color: darkred;" data-controller="application"
data-href="<%= document_path(juris_result.jurisprudence.document.id, is_index_table: false, subject_ids: params[:subject_ids]) %>"
data-action="click->application#openLink">
<% document_title = juris_result.jurisprudence.short_title || juris_result.jurisprudence.title %> <% document_title = juris_result.jurisprudence.short_title || juris_result.jurisprudence.title %>
<% date_or_year = juris_result.jurisprudence.doc_date.present? ? juris_result.jurisprudence.doc_date.strftime("%B, %d, %Y") : doctrine.jurisprudence.year %> <% date_or_year = juris_result.jurisprudence.doc_date.present? ? juris_result.jurisprudence.doc_date.strftime("%B, %d, %Y") : doctrine.jurisprudence.year %>
<%= [document_title, juris_result.jurisprudence.clean_reference_number, date_or_year].join(", ") %> <%= [document_title, juris_result.jurisprudence.clean_reference_number, date_or_year].join(", ") %>

4
app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb

@ -7,7 +7,9 @@
<tbody> <tbody>
<% search_results.each do |search_result| %> <% search_results.each do |search_result| %>
<tr href="<%= document_path(search_result.document.id, is_index_table: true, subject_ids: opts[:subject_ids]) %> " class="clickable-link"> <tr class="clickable-link" data-controller="application"
data-href="<%= document_path(search_result.document.id, is_index_table: true, subject_ids: opts[:subject_ids]) %>"
data-action="click->application#openLink">
<td> <%= document_reference_number(search_result) %> </td> <td> <%= document_reference_number(search_result) %> </td>
<td> <%= document_title(search_result) %> </td> <td> <%= document_title(search_result) %> </td>
<td> <%= date_or_year(search_result) %> </td> <td> <%= date_or_year(search_result) %> </td>

6
app/components/doctrines_offcanvas_accordion_component/doctrines_offcanvas_accordion_component.html.erb

@ -5,10 +5,12 @@
<div class="accordion-button collapsed m-0 p-0 sub-label<%= search_result["heirarchy_level"] + 1 %>" data-bs-toggle="collapse" data-bs-target="#<%= children_accordion_id %>" <div class="accordion-button collapsed m-0 p-0 sub-label<%= search_result["heirarchy_level"] + 1 %>" data-bs-toggle="collapse" data-bs-target="#<%= children_accordion_id %>"
data-controller="subjects" data-subject-parent-id="<%= search_result["id"] %>" data-accordion-target="#<%= accordion_body_id %>" data-controller="subjects" data-subject-parent-id="<%= search_result["id"] %>" data-accordion-target="#<%= accordion_body_id %>"
data-action="click->subjects#loadDoctrinesOffcanvasAccordion"> data-action="click->subjects#loadDoctrinesOffcanvasAccordion">
<%= link_to search_result["name"], index_url, class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link" %> <%= link_to search_result["name"], "#", class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: index_url, action: "click->application#openLink" } %>
</div> </div>
<% else %> <% else %>
<%= link_to search_result["name"], index_url, class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link" %> <%= link_to search_result["name"], "#", class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: index_url, action: "click->application#openLink" } %>
<% end %> <% end %>
</div> </div>

6
app/components/doctrines_offcanvas_component/doctrines_offcanvas_component.html.erb

@ -15,10 +15,12 @@
data-controller="subjects" data-subject-parent-id="<%= root.id %>" data-controller="subjects" data-subject-parent-id="<%= root.id %>"
data-accordion-target="#<%= ['doctrinesOffCanvasAccordionBody', root.id].join %>" data-accordion-target="#<%= ['doctrinesOffCanvasAccordionBody', root.id].join %>"
data-action="click->subjects#loadDoctrinesOffcanvasAccordion"> data-action="click->subjects#loadDoctrinesOffcanvasAccordion">
<%= link_to root.name, search_doctrines_path(subject_ids: [root.id], is_index_table: false), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %> <%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: search_doctrines_path(subject_ids: [root.id], is_index_table: false), action: "click->application#openLink" } %>
</div> </div>
<% else %> <% else %>
<%= link_to root.name, search_doctrines_path(subject_ids: [root.id], is_index_table: false), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %> <%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: search_doctrines_path(subject_ids: [root.id], is_index_table: false), action: "click->application#openLink" } %>
<% end %> <% end %>
</div> </div>

4
app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb

@ -1,4 +1,6 @@
<div class="row-flex m-3 mt-0 doctrine-content-body clickable-link" href="<%= jurisprudence.present? ? document_doctrine_path(jurisprudence.id, id) : doctrine_path(id)%>"> <div class="row-flex m-3 mt-0 doctrine-content-body clickable-link" data-controller="application"
data-href="<%= jurisprudence.present? ? document_doctrine_path(jurisprudence.id, id) : doctrine_path(id)%>"
data-action="click->application#openLink">
<div class="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>"> <div class="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>">
<span> <b> <i> <%= headnote %> </i> </b> </span> <span> <b> <i> <%= headnote %> </i> </b> </span>
<p class="mb-0"> <%= raw content.html_safe %> </p> <p class="mb-0"> <%= raw content.html_safe %> </p>

3
app/components/jurisprudences_index_table_component/jurisprudences_index_table_component.html.erb

@ -1,4 +1,5 @@
<tr href="<%= document_path(document.id) %>" class="clickable-link" target="_blank"> <tr class="clickable-link" data-controller="application" data-href="<%= document_path(document.id) %>"
data-action="click->application#openLink">
<td> <%= clean_reference_number %> </td> <td> <%= clean_reference_number %> </td>
<td> <%= short_title || title %> </td> <td> <%= short_title || title %> </td>
<td> <%= date_or_year %> </td> <td> <%= date_or_year %> </td>

4
app/components/reports_search_results_component/reports_search_results_component.html.erb

@ -1,4 +1,6 @@
<div class="row-flex m-3 mt-0 doctrine-content-body clickable-link" href="<%= jurisprudence.present? ? document_doctrine_path(jurisprudence.id, id) : doctrine_path(id)%>"> <div class="row-flex m-3 mt-0 doctrine-content-body clickable-link" data-controller="application"
data-href="<%= jurisprudence.present? ? document_doctrine_path(jurisprudence.id, id) : doctrine_path(id)%>"
data-action="click->application#openLink">
<div class="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>"> <div class="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>">
<p class="mb-0"> <%= raw content.html_safe %> </p> <p class="mb-0"> <%= raw content.html_safe %> </p>

12
app/components/subjects_accordion_component/subjects_accordion_component.html.erb

@ -5,12 +5,16 @@
<div class="accordion-button collapsed m-0 p-0 sub-label<%= search_result["heirarchy_level"] + 1 %>" data-bs-toggle="collapse" data-bs-target="#<%= children_accordion_id %>" <div class="accordion-button collapsed m-0 p-0 sub-label<%= search_result["heirarchy_level"] + 1 %>" data-bs-toggle="collapse" data-bs-target="#<%= children_accordion_id %>"
data-controller="subjects" data-subject-parent-id="<%= search_result["id"] %>" data-accordion-target="#<%= accordion_body_id %>" data-controller="subjects" data-subject-parent-id="<%= search_result["id"] %>" data-accordion-target="#<%= accordion_body_id %>"
data-action="click->subjects#loadSubjectsAccordion"> data-action="click->subjects#loadSubjectsAccordion">
<%= link_to search_result["name"], custom_url, class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link" %> <%= link_to search_result["name"], "#", class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: search_result["id"]), class: "text-decoration-none d-block sub#{search_result["heirarchy_level"]} clickable-link position-absolute end-0 me-5" %> data: { controller: "application", href: custom_url, action: "click->application#openLink" } %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: search_result["id"]),
class: "text-decoration-none d-block sub#{search_result["heirarchy_level"]} clickable-link position-absolute end-0 me-5" %>
</div> </div>
<% else %> <% else %>
<%= link_to search_result["name"], custom_url, class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link" %> <%= link_to search_result["name"], custom_url, class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: search_result["id"]), class: "text-decoration-none d-block sub#{search_result["heirarchy_level"]} clickable-link position-absolute end-0 non-toggle" %> data: { controller: "application", href: custom_url, action: "click->application#openLink" } %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: search_result["id"]),
class: "text-decoration-none d-block sub#{search_result["heirarchy_level"]} clickable-link position-absolute end-0 non-toggle" %>
<% end %> <% end %>
</div> </div>

6
app/components/subjects_offcanvas_accordion_component/subjects_offcanvas_accordion_component.html.erb

@ -5,10 +5,12 @@
<div class="accordion-button collapsed m-0 p-0 sub-label<%= search_result["heirarchy_level"] + 1 %>" data-bs-toggle="collapse" data-bs-target="#<%= children_accordion_id %>" <div class="accordion-button collapsed m-0 p-0 sub-label<%= search_result["heirarchy_level"] + 1 %>" data-bs-toggle="collapse" data-bs-target="#<%= children_accordion_id %>"
data-controller="subjects" data-subject-parent-id="<%= search_result["id"] %>" data-accordion-target="#<%= accordion_body_id %>" data-controller="subjects" data-subject-parent-id="<%= search_result["id"] %>" data-accordion-target="#<%= accordion_body_id %>"
data-action="click->subjects#loadSubjectsOffcanvasAccordion"> data-action="click->subjects#loadSubjectsOffcanvasAccordion">
<%= link_to search_result["name"], index_url, class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link" %> <%= link_to search_result["name"], "#", class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: index_url, action: "click->application#openLink" } %>
</div> </div>
<% else %> <% else %>
<%= link_to search_result["name"], index_url, class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link" %> <%= link_to search_result["name"], "#", class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: index_url, action: "click->application#openLink" } %>
<% end %> <% end %>
</div> </div>

6
app/components/subjects_offcanvas_component/subjects_offcanvas_component.html.erb

@ -15,10 +15,12 @@
data-controller="subjects" data-subject-parent-id="<%= root.id %>" data-controller="subjects" data-subject-parent-id="<%= root.id %>"
data-accordion-target="#<%= ['subjectsOffCanvasAccordionBody', root.id].join %>" data-accordion-target="#<%= ['subjectsOffCanvasAccordionBody', root.id].join %>"
data-action="click->subjects#loadSubjectsOffcanvasAccordion"> data-action="click->subjects#loadSubjectsOffcanvasAccordion">
<%= link_to root.name, search_documents_path(subject_ids: root.id, is_index_table: true), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %> <%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: search_documents_path(subject_ids: root.id, is_index_table: true), action: "click->application#openLink" } %>
</div> </div>
<% else %> <% else %>
<%= link_to root.name, search_documents_path(subject_ids: root.id, is_index_table: true), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %> <%= link_to root.name, search_documents_path(subject_ids: root.id, is_index_table: true), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: search_documents_path(subject_ids: root.id, is_index_table: true), action: "click->application#openLink" } %>
<% end %> <% end %>
</div> </div>

2
app/controllers/concerns/document_search.rb

@ -16,8 +16,6 @@ module DocumentSearch
with(:citation_finders_names).any_of(sanitize_citer_finder_param(search_params[:citation_finder])) if search_params[:citation_finder].present? with(:citation_finders_names).any_of(sanitize_citer_finder_param(search_params[:citation_finder])) if search_params[:citation_finder].present?
with(:is_only_in_premium_libraries, false)
if search_params[:sort_by].blank? if search_params[:sort_by].blank?
order_by :search_year, :desc order_by :search_year, :desc
order_by :search_doc_date, :desc order_by :search_doc_date, :desc

2
app/controllers/concerns/jurisprudence_search.rb

@ -24,8 +24,6 @@ module JurisprudenceSearch
without(:id).any_of(search_params[:exclude_ids]) if search_params[:exclude_ids].present? without(:id).any_of(search_params[:exclude_ids]) if search_params[:exclude_ids].present?
with(:is_only_in_premium_libraries, false)
if search_params[:sort_by].blank? if search_params[:sort_by].blank?
order_by :search_year, :desc order_by :search_year, :desc
order_by :search_doc_date, :desc order_by :search_doc_date, :desc

26
app/javascript/controllers/application_controller.js

@ -21,22 +21,6 @@ import Selectize from "selectize";
*/ */
export default class extends Controller { export default class extends Controller {
connect () { connect () {
$(".clickable-link").on("click", function (e) {
e.preventDefault();
let $href = $(this).attr("href");
if ($href !== undefined) {
window.location.href = $href;
}
});
$(".clickable-tr").on("click", function () {
let $href = $(this).attr("href");
if ($href !== undefined) {
window.open($href);
}
})
$(".reset-document-advanced-search").on("click", function (ev) { $(".reset-document-advanced-search").on("click", function (ev) {
ev.preventDefault() ev.preventDefault()
@ -54,6 +38,16 @@ export default class extends Controller {
StimulusReflex.register(this) StimulusReflex.register(this)
} }
openLink ($event) {
$event.preventDefault()
window.location.href = this.element.dataset['href']
}
openLinkToNewTab ($event) {
$event.preventDefault()
window.open(this.element.dataset['href'])
}
/* Application-wide lifecycle methods /* Application-wide lifecycle methods
* *
* Use these methods to handle lifecycle concerns for the entire application. * Use these methods to handle lifecycle concerns for the entire application.

1
app/javascript/controllers/doctrines_controller.js

@ -196,7 +196,6 @@ export default class extends ApplicationController {
content: $modal.find("input[name='document_title']").val(), phil_rep: $modal.find("#phil_rep").val(), content: $modal.find("input[name='document_title']").val(), phil_rep: $modal.find("#phil_rep").val(),
editor_notes: $modal.find("input[name='editor_notes']").val(), annomark_ids: $modal.find("select[name='annomark_ids[]']").val() } editor_notes: $modal.find("input[name='editor_notes']").val(), annomark_ids: $modal.find("select[name='annomark_ids[]']").val() }
console.log(annotaitons_attributes_index.length)
if (annotaitons_attributes_index.length > 0) { if (annotaitons_attributes_index.length > 0) {
annotations_attributes.splice(annotaitons_attributes_index, 1, params) annotations_attributes.splice(annotaitons_attributes_index, 1, params)
$( ".toast-body" ).html( "<span><b>Case List is successfully updated.</b></span>" ); $( ".toast-body" ).html( "<span><b>Case List is successfully updated.</b></span>" );

3
app/javascript/controllers/subjects_controller.js

@ -9,7 +9,6 @@ export default class extends ApplicationController {
opts = { parent_accordion_id: $this.element.dataset["accordionId"], accordionTarget: $this.element.dataset["accordionTarget"], opts = { parent_accordion_id: $this.element.dataset["accordionId"], accordionTarget: $this.element.dataset["accordionTarget"],
accordionFor: $this.element.dataset["accordionFor"] } accordionFor: $this.element.dataset["accordionFor"] }
console.log(opts)
if (parent_id !== null && parent_id !== undefined && parent_id !== "") { if (parent_id !== null && parent_id !== undefined && parent_id !== "") {
params.parent_id = parent_id params.parent_id = parent_id
} else { } else {
@ -29,7 +28,6 @@ export default class extends ApplicationController {
var $this = this, params = { per_page: 10000 }, parent_id = $this.element.dataset["subjectParentId"], var $this = this, params = { per_page: 10000 }, parent_id = $this.element.dataset["subjectParentId"],
opts = { accordionTarget: $this.element.dataset["accordionTarget"] } opts = { accordionTarget: $this.element.dataset["accordionTarget"] }
console.log(opts)
if (parent_id !== null && parent_id !== undefined && parent_id !== "") { if (parent_id !== null && parent_id !== undefined && parent_id !== "") {
params.parent_id = parent_id params.parent_id = parent_id
} else { } else {
@ -49,7 +47,6 @@ export default class extends ApplicationController {
var $this = this, params = { per_page: 10000 }, parent_id = $this.element.dataset["subjectParentId"], var $this = this, params = { per_page: 10000 }, parent_id = $this.element.dataset["subjectParentId"],
opts = { accordionTarget: $this.element.dataset["accordionTarget"] } opts = { accordionTarget: $this.element.dataset["accordionTarget"] }
console.log(opts)
if (parent_id !== null && parent_id !== undefined && parent_id !== "") { if (parent_id !== null && parent_id !== undefined && parent_id !== "") {
params.parent_id = parent_id params.parent_id = parent_id
} else { } else {

9
app/models/cdao/subject.rb

@ -67,14 +67,19 @@ class Cdao::Subject < Cdao::Base
sub6_name = names[6] sub6_name = names[6]
root = Cdao::Subject.find_or_create_by(name: root_name, ancestry: nil) if root_name.present? root = Cdao::Subject.find_or_create_by(name: root_name, ancestry: nil) if root_name.present?
root.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if root.persisted?
sub1 = root.children.find_or_create_by(name: sub1_name) if root.present? && sub1_name.present? sub1 = root.children.find_or_create_by(name: sub1_name) if root.present? && sub1_name.present?
sub1.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub1.present? && sub1.persisted?
sub2 = sub1.children.find_or_create_by(name: sub2_name) if sub1.present? && sub2_name.present? sub2 = sub1.children.find_or_create_by(name: sub2_name) if sub1.present? && sub2_name.present?
sub2.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub2.present? && sub2.persisted?
sub3 = sub2.children.find_or_create_by(name: sub3_name) if sub2.present? && sub3_name.present? sub3 = sub2.children.find_or_create_by(name: sub3_name) if sub2.present? && sub3_name.present?
sub3.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub3.present? && sub3.persisted?
sub4 = sub3.children.find_or_create_by(name: sub4_name) if sub3.present? && sub4_name.present? sub4 = sub3.children.find_or_create_by(name: sub4_name) if sub3.present? && sub4_name.present?
sub4.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub4.present? && sub4.persisted?
sub5 = sub4.children.find_or_create_by(name: sub5_name) if sub4.present? && sub5_name.present? sub5 = sub4.children.find_or_create_by(name: sub5_name) if sub4.present? && sub5_name.present?
sub5.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub5.present? && sub5.persisted?
sub6 = sub5.children.find_or_create_by(name: sub6_name) if sub5.present? && sub6_name.present? sub6 = sub5.children.find_or_create_by(name: sub6_name) if sub5.present? && sub6_name.present?
sub6.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub6.present? && sub6.persisted?
root.descendants.each { |a| a.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] } if root.present?
end end
end end

6
app/views/subject_indexes/index.html.erb

@ -11,11 +11,13 @@
data-controller="subjects" data-subject-parent-id="<%= root.id %>" data-controller="subjects" data-subject-parent-id="<%= root.id %>"
data-accordion-target="#<%= ['subjectsAccordionBody', root.id].join %>" data-accordion-target="#<%= ['subjectsAccordionBody', root.id].join %>"
data-action="click->subjects#loadSubjectsAccordion"> data-action="click->subjects#loadSubjectsAccordion">
<%= link_to root.name, subject_index_path(root.id), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %> <%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: subject_index_path(root.id), action: "click->application#openLink" } %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: root.id), class: "text-decoration-none d-block sub1 clickable-link position-absolute end-0 me-5" %> <%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: root.id), class: "text-decoration-none d-block sub1 clickable-link position-absolute end-0 me-5" %>
</div> </div>
<% else %> <% else %>
<%= link_to root.name, subject_index_path(root.id), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %> <%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: subject_index_path(root.id), action: "click->application#openLink" } %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: root.id), class: "text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin non-toggle" %> <%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: root.id), class: "text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin non-toggle" %>
<% end %> <% end %>
</div> </div>

6
app/views/subject_indexes/show.html.erb

@ -51,11 +51,13 @@
data-controller="subjects" data-subject-parent-id="<%= root.id %>" data-controller="subjects" data-subject-parent-id="<%= root.id %>"
data-accordion-target="#<%= ['subjectsAccordionBody', root.id].join %>" data-accordion-target="#<%= ['subjectsAccordionBody', root.id].join %>"
data-action="click->subjects#loadSubjectsAccordion"> data-action="click->subjects#loadSubjectsAccordion">
<%= link_to root.name, subject_index_path(root.id), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %> <%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: subject_index_path(root.id), action: "click->application#openLink" } %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: root.id), class: "text-decoration-none d-block sub1 clickable-link position-absolute end-0 me-5" %> <%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: root.id), class: "text-decoration-none d-block sub1 clickable-link position-absolute end-0 me-5" %>
</div> </div>
<% else %> <% else %>
<%= link_to root.name, subject_index_path(root.id), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %> <%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: subject_index_path(root.id), action: "click->application#openLink" } %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: root.id), class: "text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin non-toggle" %> <%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: root.id), class: "text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin non-toggle" %>
<% end %> <% end %>
</div> </div>

Loading…
Cancel
Save