Browse Source

Merge pull request #65 from lexintegritastech/improve-main-ui

Initial viewing updates
pull/66/head
Alexander D. Bondoc 4 years ago committed by GitHub
parent
commit
44f2b67518
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/components/document_advanced_search_component/document_advanced_search_component.html.erb
  2. 4
      app/components/subject_index_form_component.rb
  3. 6
      app/components/subject_index_form_component/subject_index_form_component.html.erb
  4. 8
      app/controllers/concerns/doctrine_search.rb
  5. 2
      app/controllers/reports_controller.rb
  6. 2
      app/models/cdao/subject.rb
  7. 10
      app/views/reports/index.html.erb
  8. 5
      app/views/subject_indexes/show.html.erb

4
app/components/document_advanced_search_component/document_advanced_search_component.html.erb

@ -15,7 +15,7 @@
<div class="mb-3"> <div class="mb-3">
<label for="exampleFormControlInput1" class="form-label text-white">Year</label> <label for="exampleFormControlInput1" class="form-label text-white">Year</label>
<%= select_tag :year, options_for_select(years, params[:year]), class: "form-select" %> <%= select_tag :year, options_for_select(years, params[:year]), class: "form-select", include_blank: true %>
</div> </div>
<div class="mb-3"> <div class="mb-3">
@ -27,4 +27,4 @@
<button type="button" class="btn btn-success me-2 mb-3">Refresh</button> <button type="button" class="btn btn-success me-2 mb-3">Refresh</button>
<button type="submit" class="btn btn-danger mb-3">Search</button> <button type="submit" class="btn btn-danger mb-3">Search</button>
</div> </div>
<% end %> <% end %>

4
app/components/subject_index_form_component.rb

@ -7,6 +7,10 @@ class SubjectIndexFormComponent < BaseComponent
@parent_id = @opts[:parent_id] @parent_id = @opts[:parent_id]
end end
def parent
Cdao::Subject.find(parent_id)
end
def current_library def current_library
Cdao::Library.first Cdao::Library.first
end end

6
app/components/subject_index_form_component/subject_index_form_component.html.erb

@ -7,11 +7,13 @@
</div> </div>
</div> </div>
<% if parent_id.present? %> <% if parent_id.present? || subject_index.persisted? %>
<div cass="row"> <div cass="row">
<div class="col-sm-12"> <div class="col-sm-12">
<strong> <%= label_tag :subjects %> </strong> <strong> <%= label_tag :subjects %> </strong>
<select class="form-control subjects-selectize ps-0 pe-0" name="parent_id" id="parent_id" value="<%= parent_id %>"> </select> <select class="form-control subjects-selectize ps-0 pe-0" name="parent_id" id="parent_id" value="<%= parent_id %>">
<option value="<%= parent_id %>" selected="selected"> <%= parent.name %> </option>
</select>
</div> </div>
</div> </div>
<% end %> <% end %>

8
app/controllers/concerns/doctrine_search.rb

@ -13,6 +13,14 @@ module DoctrineSearch
with(:created_at).between(Date.parse(search_params[:created_at])..Time.zone.today.to_date) with(:created_at).between(Date.parse(search_params[:created_at])..Time.zone.today.to_date)
end end
if search_params[:created_at_start].present? && search_params[:created_at_end].blank?
with(:created_at).between(Date.parse(search_params[:created_at_start])..Time.zone.today.to_date)
end
if search_params[:created_at_start].present? && search_params[:created_at_end].present?
with(:created_at).between(Date.parse(search_params[:created_at_start])..Date.parse(search_params[:created_at_end]))
end
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?
paginate page: search_params[:page] || 1, per_page: search_params[:per_page] || 20 paginate page: search_params[:page] || 1, per_page: search_params[:per_page] || 20

2
app/controllers/reports_controller.rb

@ -12,6 +12,6 @@ class ReportsController < ApplicationController
private private
def search_params def search_params
params.permit(:created_at, :q, :page, :per_page, exclude_ids: [], subject_ids: [], user_ids: []) params.permit(:created_at, :created_at_start, :created_at_end, :q, :page, :per_page, exclude_ids: [], subject_ids: [], user_ids: [])
end end
end end

2
app/models/cdao/subject.rb

@ -41,7 +41,7 @@ class Cdao::Subject < Cdao::Base
end end
def lineage_name def lineage_name
path.map(&:name).join("; ") path.map(&:name).join(" > ")
end end
def name_with_product_names def name_with_product_names

10
app/views/reports/index.html.erb

@ -11,9 +11,15 @@
<select class="form-control subject-ids-selectize p-0" name="subject_ids[]" id="subject_ids_" multiple="true"> </select> <select class="form-control subject-ids-selectize p-0" name="subject_ids[]" id="subject_ids_" multiple="true"> </select>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="exampleFormControlInput1" class="form-label text-white"> Date Created At </label> <label for="exampleFormControlInput1" class="form-label text-white"> Date Created (Start) </label>
<%= text_field_tag :created_at, params[:created_at], class: "form-control default-flatpickr" %> <%= text_field_tag :created_at_start, params[:created_at_start], class: "form-control default-flatpickr" %>
</div> </div>
<div class="mb-3">
<label for="exampleFormControlInput1" class="form-label text-white"> Date Created (End) </label>
<%= text_field_tag :created_at_end, params[:created_at_end], class: "form-control default-flatpickr" %>
</div>
<hr class="simple"> <hr class="simple">
<div class="mb-3"> <div class="mb-3">
<label for="exampleFormControlInput1" class="form-label text-white"> Users </label> <label for="exampleFormControlInput1" class="form-label text-white"> Users </label>

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

@ -25,7 +25,10 @@
<div class="col-sm-2 d-flex justify-content-end "> <div class="col-sm-2 d-flex justify-content-end ">
<a class="btn btn-secondary me-3 btn-sm" href="<%= edit_subject_index_path(@subject_index) %>"> Edit </a> <a class="btn btn-secondary me-3 btn-sm" href="<%= edit_subject_index_path(@subject_index) %>"> Edit </a>
<a class="btn btn-danger btn-sm" href="<%= subject_index_path(@subject_index) %>" data-confirm="Are you sure to delete this record?" data-method="DELETE"> Delete </a>
<% if !@subject_index.has_children? %>
<a class="btn btn-danger btn-sm" href="<%= subject_index_path(@subject_index) %>" data-confirm="Are you sure to delete this record?" data-method="DELETE"> Delete </a>
<% end %>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save