diff --git a/.gitignore b/.gitignore
index 246e939..8d1b66f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,8 +17,13 @@ public/assets/
yarn.lock
*.log
.bundle
+<<<<<<< HEAD
*.env
!.env
*.sql
*.sql.gz
log/*
+=======
+*.sql.gz
+*.sql
+>>>>>>> origin/20241126-maintenance-release
diff --git a/Gemfile b/Gemfile
index 449f33b..7e36ebd 100644
--- a/Gemfile
+++ b/Gemfile
@@ -2,6 +2,7 @@
source 'http://rubygems.org'
ruby '3.1.4'
+ruby '3.1.4'
## RAILS and related ##
gem 'rails', '~> 7.0.0'
diff --git a/README.md b/README.md
index 0fa540f..079875a 100644
--- a/README.md
+++ b/README.md
@@ -12,10 +12,12 @@ There are 3 containers created: **web**, **db** and **mailcatcher**
# Access the front end web app in DEVELOPMENT
+By default, the application will listen on port 3006 and runs with RAILS_ENV=development.
By default, the application will listen on port 3006 and runs with RAILS_ENV=development.
To access the application in Chrome browser, you will need to add the ModHeader extension to your Chrome browser.
+Once the extension has been activated, you can add the following header to the site http://localhost:3006/. This will enable you to login as **manager** user.
Once the extension has been activated, you can add the following header to the site http://localhost:3006/. This will enable you to login as **manager** user.
Header: PYORK_USER
diff --git a/app/assets/javascripts/bib_finders.js b/app/assets/javascripts/bib_finders.js
index 8f4c40b..f9c0053 100644
--- a/app/assets/javascripts/bib_finders.js
+++ b/app/assets/javascripts/bib_finders.js
@@ -35,7 +35,7 @@ function searchRecords() {
$("#item_publisher").val(my_record.publisher);
$("#item_isbn").val(my_record.isbn);
-
+ $("#item_other_isbn_issn").val(my_record.other_isbn_issn);
$("#item_callnumber").val(my_record.callnumber);
$("#item_edition").val(my_record.edition);
$("#item_publication_date").val(my_record.publish_date);
diff --git a/app/assets/javascripts/request_history.js b/app/assets/javascripts/request_history.js
index 737d589..13784e1 100644
--- a/app/assets/javascripts/request_history.js
+++ b/app/assets/javascripts/request_history.js
@@ -1,15 +1,12 @@
$(document).ready(function() {
- $(".request_history table .comment").click(function() {
- //alert($(this).parent().next().prop("class"));
- $(this).parent().next().toggleClass('hide');
- });
-
-
- $("#note-textarea").bind('keyup', function(){
- checkCount();
+ $(document).on("click", ".request_history table .comment", function() {
+ $(this).parent().next().toggleClass('hide');
});
+ $(document).on('keyup', '[id^="note-textarea_"]', function () {
+ updateCharacterCount($(this));
+ });
$('#history_popup').on('shown.bs.modal', function (e) {
@@ -18,16 +15,28 @@ $(document).ready(function() {
$( "#request_history_log" ).load( data_url);
} );
+ $(document).on('shown.bs.modal', '[id^="item_history_popup_"]', function () {
+ var $modal = $(this);
+ var itemId = $modal.attr('id').split('_').pop();
+ var dataUrl = $modal.find("#request_history_log_" + itemId).data("url");
+
+ if (dataUrl) {
+ $modal.find("#request_history_log_" + itemId).load(dataUrl);
+ }
+ });
+
});
-/* Checks the count of the note text area and changes color to red if limit hit */
-function checkCount(){
- var textAreaValue = $("#note-textarea").val();
- $('.remaining').html(textAreaValue.length);
+function updateCharacterCount($textArea) {
+ var textAreaValue = $textArea.val();
+ var itemId = $textArea.attr('id').split('_').pop();
+ var remainingCounter = $textArea.closest('.modal').find('.remaining');
+
+ remainingCounter.text(textAreaValue.length);
+
if (textAreaValue.length > 255) {
- $('.remaining').addClass("red");
- }
- else {
- $('.remaining').removeClass("red");
+ remainingCounter.addClass("red");
+ } else {
+ remainingCounter.removeClass("red");
}
}
diff --git a/app/assets/stylesheets/controllers/items.css.scss b/app/assets/stylesheets/controllers/items.css.scss
index c93cd8c..4943ada 100644
--- a/app/assets/stylesheets/controllers/items.css.scss
+++ b/app/assets/stylesheets/controllers/items.css.scss
@@ -35,8 +35,8 @@ form {
a.change-item-status {
&.item_ready {
- color: #006600;
- border: 1px solid #006600;
+ color: #32cd32;
+ border: 1px solid #32cd32;
}
&.item_not_ready {
@@ -45,7 +45,7 @@ form {
&.item_ready:hover,
&.item_ready:focus {
- color: green;
+ color: #32cd32;
}
@@ -54,7 +54,7 @@ form {
span.item-status {
&.item_ready {
color: white;
- background: green;
+ background: #32cd32;
}
}
diff --git a/app/controllers/acquisition_requests_controller.rb b/app/controllers/acquisition_requests_controller.rb
index bf537d0..9413c72 100644
--- a/app/controllers/acquisition_requests_controller.rb
+++ b/app/controllers/acquisition_requests_controller.rb
@@ -106,6 +106,7 @@ def change_status
def send_to_acquisitions
@acquisition_request.audit_comment = "Sent email to #{params[:which].humanize}. CC: #{current_user.email}"
+ @acquisition_request.acquisition_notes = params[:acquisition_notes]
@acquisition_request.save(validate: false)
@acquisition_request.email_to(params[:which], current_user)
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index 145aa77..614d707 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -28,7 +28,7 @@ def index
end
## location, nil is all locations
- location_id = params[:location] || nil
+ location_id = params[:location] || 'all'
if location_id.nil?
## home location
diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb
index 64cacc4..0d32194 100644
--- a/app/controllers/items_controller.rb
+++ b/app/controllers/items_controller.rb
@@ -47,7 +47,7 @@ def create
respond_to do |format|
if @item.save
- @request.update(status: Request::OPEN)
+ @request.reload
RequestMailer.new_item_notification(@request, @item).deliver_later
format.html { redirect_to [@request, @item], notice: 'Item was successfully created.' }
@@ -78,6 +78,7 @@ def update
def destroy
@item.audit_comment = "Item #{@item.title} removed from request"
@item.destroy
+ @request.reload
respond_to do |format|
format.html { redirect_to @request }
format.js
@@ -123,7 +124,7 @@ def set_item
# Never trust parameters from the scary internet, only allow the white list through.
def item_params
- item_attributes = %i[id title author description callnumber isbn publication_date edition publisher loan_period provided_by_requestor
+ item_attributes = %i[id title author description callnumber isbn other_isbn_issn publication_date edition publisher loan_period provided_by_requestor
metadata_source metadata_source_id _destroy request_id item_type copyright_options other_copyright_options url format map_index_num
page_number physical_copy_required journal_title issue volume ils_barcode]
diff --git a/app/controllers/request_history_controller.rb b/app/controllers/request_history_controller.rb
index b3625f9..c387074 100644
--- a/app/controllers/request_history_controller.rb
+++ b/app/controllers/request_history_controller.rb
@@ -5,20 +5,38 @@ class RequestHistoryController < ApplicationController
authorize_resource User
# skip_authorization_check
- def index
- @audits = @request.audits | @request.associated_audits # | @request.course.audits
- @audits.sort! { |a, b| a.created_at <=> b.created_at }
+ def index
+ associated_audits = @request.associated_audits.where.not(associated_type: 'item')
- @audits_grouped = @audits.reverse.group_by { |a| a.created_at.at_beginning_of_day }
+ request_audits = @request.audits.where(auditable_type: 'Request', associated_id: nil, associated_type: nil)
+
+ @audits = (associated_audits + request_audits).sort_by(&:created_at)
+
+ @audits_grouped = @audits.reverse.group_by { |audit| audit.created_at.at_beginning_of_day }
+
+ @users = User.all
+ @locations = Location.active
+
+ render partial: 'history_log', layout: false if request.xhr?
+ end
+ def item_history
+ item_id = params[:item_id]
+ @audits = @request.audits.where(associated_type: 'item', associated_id: item_id.to_i).order(created_at: :desc)
+
+ @audits_grouped = @audits.reverse.group_by { |a| a.created_at.at_beginning_of_day }
+
@users = User.all
@locations = Location.active
render partial: 'history_log', layout: false if request.xhr?
end
+
+
def create
# @aud = Audited::Adapters::ActiveRecord::Audit.new
+ @item_id = params[:item_id]
@aud = Audited::Audit.new
@aud.action = 'note'
@aud.user = current_user
@@ -26,20 +44,25 @@ def create
@aud.audited_changes = 'Note Added'
@aud.comment = params[:audit_comment]
+ if @item_id.present?
+ @aud.associated_id = @item_id
+ @aud.associated_type = "item"
+ end
+
+
respond_to do |format|
+ redirect_path = @item_id.present? ? item_history_request_path(@request, item_id: @item_id) : history_request_path(@request)
if @aud.comment.blank?
- format.html { redirect_to history_request_path(@request), alert: 'Note is blank. Nothing updated' }
+ format.html { redirect_to redirect_path, alert: 'Note is blank. Nothing updated' }
format.js
elsif @aud.comment.length > 255
- format.html { redirect_to history_request_path(@request), alert: 'Note is more than 255 characters!' }
+ format.html { redirect_to redirect_path, alert: 'Note is more than 255 characters!' }
format.js
elsif @aud.save
- format.html { redirect_to history_request_path(@request), notice: 'Note saved' }
+ format.html { redirect_to redirect_path, notice: 'Note saved' }
format.js
else
- format.html do
- redirect_to history_request_path(@request), alert: 'Note not saved. Please contact application administrator'
- end
+ format.html { redirect_to redirect_path, alert: 'Note not saved. Please contact application administrator' }
end
end
end
diff --git a/app/controllers/request_wizard_controller.rb b/app/controllers/request_wizard_controller.rb
index 555e42b..2a5274a 100644
--- a/app/controllers/request_wizard_controller.rb
+++ b/app/controllers/request_wizard_controller.rb
@@ -6,7 +6,7 @@ class RequestWizardController < ApplicationController
def step_one
if current_user.valid?
- @request = Request.new
+ @request = Request.new(status: Request::INCOMPLETE)
@request.course = Course.new
@request.requester = current_user
else
@@ -35,7 +35,7 @@ def save
end
else
@old_request = get_request_duplicated
- if @old_request.course.created_by_id == current_user.id
+ if !@old_request.nil? && @old_request.course.created_by_id == current_user.id
redirect_to new_request_step_two_path(@old_request), notice: 'Proceeding to Step 2.'
elsif !@request.save
render action: 'step_one'
@@ -48,7 +48,7 @@ def step_two
end
def finish
- if @request.items.size.positive?
+ if @request.items.where.not(status: 'deleted').exists?
@request.audit_comment = 'Request Step Two Completed'
@request.status = Request::OPEN
@request.requested_date = Date.today.to_date
@@ -62,7 +62,7 @@ def finish
else
redirect_to new_request_step_two_path(@request),
- alert: 'You must add at least one item for this request to be submitted!'
+ alert: 'You must add at least one active item for this request to be submitted!'
end
end
diff --git a/app/helpers/items_helper.rb b/app/helpers/items_helper.rb
index 012f1bf..2abeeed 100644
--- a/app/helpers/items_helper.rb
+++ b/app/helpers/items_helper.rb
@@ -24,7 +24,7 @@ def format(field, simple_format = false)
def show_field?(item, field, &block)
field_map = {
- Item::TYPE_BOOK => %w[title author callnumber isbn publisher publication_date edition
+ Item::TYPE_BOOK => %w[title author callnumber isbn other_isbn_issn publisher publication_date edition
provided_by loan_period physical_copy_required],
Item::TYPE_EBOOK => %w[title author callnumber isbn publisher publication_date edition
provided_by url],
diff --git a/app/models/acquisition_request.rb b/app/models/acquisition_request.rb
index 916980c..63f7a98 100644
--- a/app/models/acquisition_request.rb
+++ b/app/models/acquisition_request.rb
@@ -30,7 +30,7 @@ class AcquisitionRequest < ApplicationRecord
## VALIDATIONS
validates_presence_of :item, :requested_by, :location ## default basic validation
- validates_presence_of :acquired_by, :acquired_at, :acquisition_source_type, :acquisition_source_name, if: lambda {
+ validates_presence_of :acquired_by, :acquired_at, if: lambda {
status == STATUS_ACQUIRED
}
validates_presence_of :cancelled_by, :cancelled_at, :cancellation_reason, if: lambda {
diff --git a/app/models/bib_result.rb b/app/models/bib_result.rb
index d82697e..90b62cf 100644
--- a/app/models/bib_result.rb
+++ b/app/models/bib_result.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class BibResult
- attr_accessor :title, :author, :isbn_issn, :callnumber, :publication_date, :publisher, :edition,
+ attr_accessor :title, :author, :isbn_issn, :other_isbn_issn, :callnumber, :publication_date, :publisher, :edition,
:item_type, :format, :map_index_num, :journal_title, :volume, :page_number,
:issue, :ils_barcode, :ils_id, :description, :main_location, :url, :rtype,
:catalogue_record, :source, :language, :subject
@@ -65,10 +65,13 @@ def from_primo(record)
rescue StandardError
'n/a'
end
- self.isbn_issn = get_value record[:pnx]['addata']['isbn']
+ self.isbn_issn = get_value(record[:pnx]['addata']['isbn']&.first || '').tr('^A-Za-z0-9', '')
+ self.other_isbn_issn = (record[:pnx]['addata']['isbn']&.drop(1) || []).map { |isbn| get_value(isbn).tr('^A-Za-z0-9', '') }.join(',')
## journals
- self.isbn_issn = get_value record[:pnx]['addata']['issn'] if isbn_issn.blank?
+ self.isbn_issn = get_value(record[:pnx]['addata']['issn']&.first || '').tr('^A-Za-z0-9', '') if isbn_issn.blank?
+ self.other_isbn_issn = (record[:pnx]['addata']['issn']&.drop(1) || []).map { |issn| get_value(issn).tr('^A-Za-z0-9', '') }.join(',') if isbn_issn.blank?
+
self.journal_title = get_value record[:pnx]['addata']['jtitle']
self.volume = get_value record[:pnx]['addata']['volume']
self.issue = get_value record[:pnx]['addata']['issue']
@@ -111,6 +114,7 @@ def to_json(*_args)
{ title: title,
author: author,
isbn_issn: isbn_issn,
+ other_isbn_issn: other_isbn_issn,
callnumber: callnumber,
publication_date: publication_date,
publisher: publisher,
diff --git a/app/models/request.rb b/app/models/request.rb
index 2202f79..6ff62e6 100644
--- a/app/models/request.rb
+++ b/app/models/request.rb
@@ -38,6 +38,7 @@ class Request < ApplicationRecord
## VALIDATIONS
+ validates :course, presence: { message: 'Cannot be empty' }
# :requester_id, :course_id, :item_id ,:assigned_to_id, :department_id,
validates_presence_of :reserve_start_date, :reserve_location_id, :course, :reserve_end_date,
message: 'Cannot be empty'
diff --git a/app/models/setting.rb b/app/models/setting.rb
index a0f890c..61350dd 100644
--- a/app/models/setting.rb
+++ b/app/models/setting.rb
@@ -17,7 +17,7 @@ class Setting < RailsSettings::Base
## Request Related Defaults
field :request_expiry_notice_interval, default: (ENV['request_expiry_notice_interval'] || 2.weeks)
- field :request_archive_all_after, default: (ENV['request_archive_all_after'] || 60.days)
+ field :request_archive_all_after, default: (ENV['request_archive_all_after'] || 60)
field :request_archive_all_user_id, default: (ENV['request_archive_all_user_id'] || 0)
field :request_archive_all_allow, default: (ENV['request_archive_all_allow'] || false)
field :request_remove_incomplete_allow, default: (ENV['request_remove_incomplete_allow'] || false)
diff --git a/app/views/acquisition_requests/_new_form.html.erb b/app/views/acquisition_requests/_new_form.html.erb
index 91c5313..a4c4b99 100644
--- a/app/views/acquisition_requests/_new_form.html.erb
+++ b/app/views/acquisition_requests/_new_form.html.erb
@@ -24,7 +24,7 @@
<% end %>
diff --git a/app/views/acquisition_requests/_send_email_choice.html.erb b/app/views/acquisition_requests/_send_email_choice.html.erb
index cc87deb..b9ded08 100644
--- a/app/views/acquisition_requests/_send_email_choice.html.erb
+++ b/app/views/acquisition_requests/_send_email_choice.html.erb
@@ -1,9 +1,8 @@
<% if can? :send_to_acquisitions, @acquisition_request %>
-
Send Acquisition Email To:
<%= form_tag send_to_acquisitions_acquisition_request_path(@acquisition_request), method: :post do |f| %>
- Bookstore
+ <%# Bookstore %>
Acquisitions Department
<% if @acquisition_request.location.acquisitions_email.blank? %>
-- No Acquistion Email Set For This Location --
@@ -12,6 +11,14 @@
<% end %>
+
+
+
+ Notes
+
+ This note will be sent along with the acquisition email.
+
+
<%= submit_tag 'Send Request Details', data: { confirm: "Are you sure? "}, class: "btn btn-sm btn-primary", style: "margin-top: 10px;" %>
<% end %>
diff --git a/app/views/acquisition_requests/show.html.erb b/app/views/acquisition_requests/show.html.erb
index aae40da..7c207b8 100644
--- a/app/views/acquisition_requests/show.html.erb
+++ b/app/views/acquisition_requests/show.html.erb
@@ -49,9 +49,10 @@
<%= @acquisition_request.location == nil ? "Unassigned Location" : @acquisition_request.location.name %>
- <%= render partial: "send_email_choice" %>
+
+ <%= render partial: "send_email_choice" %>
<% if @acquisition_request.status == AcquisitionRequest::STATUS_ACQUIRED %>
Acquired By
<%= format @acquisition_request.acquired_by.name %>
@@ -68,20 +69,9 @@
Cancellation Reason
<%= format @acquisition_request.cancellation_reason %>
<% elsif can? :change_status, @acquisition_request %>
-
+ <%= simple_form_for @acquisition_request, url: change_status_acquisition_request_path(@acquisition_request) do |f| %>
+
+ <%= f.input :acquisition_source_type, label: "Source", collection: Setting.acquisition_sources %>
+ <%= f.input :acquisition_source_name, label: "Source Name", as: :string %>
+ <%= f.input :acquisition_notes, label: "Notes", hint: "This note will be sent along with the acquisition email." %>
+ <%= f.button :submit, "Item Acquired", class: "btn btn-success btn-sm", data: { confirm: "Are you sure?" } %>
+ or
+
+ Cancel Request
+
+ <% end %>
+
diff --git a/app/views/courses/_form_fields.html.erb b/app/views/courses/_form_fields.html.erb
index 09cf9b1..beca1f7 100644
--- a/app/views/courses/_form_fields.html.erb
+++ b/app/views/courses/_form_fields.html.erb
@@ -20,7 +20,7 @@
<%= f.input :subject, collection: Courses::Subject.all_subjects, input_html: { class: "input-sm" } %>
- <%= f.input :course_id, label: "Course Number", input_html: { class: "input-sm" } %>
+ <%= f.input :course_id, label: "Course Number", input_html: { class: "input-sm", maxlength: 4, oninput: "this.value = this.value.replace(/[^0-9]/g, '').slice(0, 4);" } %>
<%= f.input :term, collection: Course::TERMS, input_html: { class: "input-sm", id: "request_course_attributes_term" } %>
diff --git a/app/views/items/_add_item.html.erb b/app/views/items/_add_item.html.erb
index c8970a8..865fe62 100644
--- a/app/views/items/_add_item.html.erb
+++ b/app/views/items/_add_item.html.erb
@@ -1,21 +1,6 @@
-
-
Add an item:
- <% Item::TYPES.reject { |t| @request.reserve_location.disallowed_item_types.include?(t) }.each do |type| %>
- <%= link_to type.humanize, new_request_item_path(@request, type: type), remote: true, class: "btn btn-link item-option" %>
- <% end %>
-
-
-
-
- <%= link_to request_copy_items_path(@request), remote: true, class: "btn btn-link blend" do%>
- Copy Items
- <% end %>
- <%= link_to request_items_path(@request, status: Item::STATUS_DELETED), class: "btn btn-link blend" do %>
- <%= @request.items.deleted.size %>
- <% end %>
-
-
-
-
-
+
+ Add an item:
+ <% Item::TYPES.reject { |t| @request.reserve_location.disallowed_item_types.include?(t) }.each do |type| %>
+ <%= link_to type.humanize, new_request_item_path(@request, type: type), remote: true, class: "btn btn-link item-option" %>
+ <% end %>
diff --git a/app/views/items/_item.html.erb b/app/views/items/_item.html.erb
index 2e4b20e..6d019ea 100644
--- a/app/views/items/_item.html.erb
+++ b/app/views/items/_item.html.erb
@@ -17,6 +17,9 @@
<% show_field? item, "isbn" do%>
ISBN <%= format item.isbn %>
<% end %>
+ <% show_field? item, "other_isbn_issn" do%>
+
Other ISBN <%= format item.other_isbn_issn %>
+ <% end %>
<% show_field? item, "callnumber" do%>
Call Number <%= format item.callnumber %>
<% end %>
diff --git a/app/views/items/_item_actions.html.erb b/app/views/items/_item_actions.html.erb
index 3210fe1..d2a69e9 100644
--- a/app/views/items/_item_actions.html.erb
+++ b/app/views/items/_item_actions.html.erb
@@ -32,7 +32,7 @@
<% if can?(:update, item) && is_request_active(@request) && item.status != Item::STATUS_DELETED %>
<% if item.acquisition_requests.acquired.size > 0 %>
-
Item Aqcuired
+
Item Acquired
<% end %>
@@ -63,7 +63,7 @@
<% if can?(:change_status, item) && is_request_active(@request) %>
<% status_class = (item.status == Item::STATUS_READY ? "item_ready" : "item_not_ready") %>
<%= link_to change_status_request_item_path(@request, item), class: "btn btn-lg change-item-status #{status_class}", remote: true, data: { status: item.status}, method: :get do %>
-
+
Done
<% end %>
<%= item.status.humanize.capitalize rescue nil %>
@@ -76,8 +76,8 @@
<% end %>
<% if can?(:change_status, item) && item.status != Item::STATUS_DELETED%>
-
-
- Add a Note
-
+
+ <%= render partial: 'requests/item_history_log_modal_', locals: { item: item } %>
+
+ <%= link_to 'Add a Note / History Log', '#', data: { toggle: 'modal', target: "#item_history_popup_#{item.id}" }, class: 'btn btn-xs btn-default' %>
<% end %>
diff --git a/app/views/items/create.js.erb b/app/views/items/create.js.erb
index c7fcc40..5a3e947 100644
--- a/app/views/items/create.js.erb
+++ b/app/views/items/create.js.erb
@@ -12,6 +12,8 @@
$("#item_<%= @item.id %>").effect("highlight",2000);
$("#item_<%= @item.id %> span.item-type").after("
");
+ $("#save_buttons_frame").html("<%= j render 'request_wizard/save_buttons', request: @request %>");
+
<% else %>
searchRecords();
bootstrap_modal_replace_content("item_form", "<%= j render "form_modal", formats: [:html] %>")
diff --git a/app/views/items/destroy.js.erb b/app/views/items/destroy.js.erb
index 850ac78..cc48b43 100644
--- a/app/views/items/destroy.js.erb
+++ b/app/views/items/destroy.js.erb
@@ -2,3 +2,4 @@ $("#item_<%=@item.id %> .item_actions").remove();
$( "#item_<%= @item.id %>" ).fadeOut( 3000, function() {
$("#item_<%= @item.id %>").remove();
});
+$("#save_buttons_frame").html("<%= j render 'request_wizard/save_buttons', request: @request %>");
diff --git a/app/views/items/form_fields/_book_form_fields.html.erb b/app/views/items/form_fields/_book_form_fields.html.erb
index fd81e95..9551104 100644
--- a/app/views/items/form_fields/_book_form_fields.html.erb
+++ b/app/views/items/form_fields/_book_form_fields.html.erb
@@ -11,6 +11,9 @@
<%= f.input :publisher, required: true %>
<%= f.input :isbn, label: "ISBN", required: true %>
+
+
<%= f.input :other_isbn_issn, label: "Other ISBN", as: :text %>
+
<%= f.input :loan_period, collection: LoanPeriod.all.collect { |p| p.duration }, required: true %>
diff --git a/app/views/request_history/_form.html.erb b/app/views/request_history/_form.html.erb
index d4f0a53..486b705 100644
--- a/app/views/request_history/_form.html.erb
+++ b/app/views/request_history/_form.html.erb
@@ -1,9 +1,10 @@
-<%= form_tag(save_note_request_path(format: "js"), method: "post", class: "form", role: "form", remote: true ) do %>
+<%= form_tag(save_note_request_path(@request, format: "js"), method: "post", remote: true) do %>
+ <%= hidden_field_tag 'item_id', local_assigns[:item_id] %>
<%= Date.today.strftime('%b %e, %Y')%>
- <%= text_area_tag("audit_comment", nil, class:"form-control", id:"note-textarea", title: "Add a note") %>
+ <%= text_area_tag("audit_comment", nil, class:"form-control", id: "note-textarea_#{local_assigns[:item_id]}", title: "Add a note") %>
Character count is / 255 maximum allowed
diff --git a/app/views/request_history/create.js.erb b/app/views/request_history/create.js.erb
index 6db04b3..45b9cd6 100644
--- a/app/views/request_history/create.js.erb
+++ b/app/views/request_history/create.js.erb
@@ -1,14 +1,22 @@
+<% if @aud.present? %>
+ <% is_associated = @aud.associated_id.present? %>
+ <% prefix = is_associated ? "#item_history_popup_#{@aud.associated_id}" : "" %>
+ <% log_error_selector = "#{prefix} #history_log_error" %>
+ <% form_reset_selector = is_associated ? "#history_popup_#{@aud.associated_id} form" : "#history_popup form" %>
+ <% textarea_selector = is_associated ? "#note-textarea_#{@aud.associated_id}" : nil %>
+ <% log_url_selector = is_associated ? "#request_history_log_#{@aud.associated_id}" : "#request_history_log" %>
-<% if @aud.comment.blank? %>
- $("#history_log_error").text("Note is blank. Please fill it in.").removeClass("hide");
-
-<% elsif @aud.comment.length > 255 %>
- $("#history_log_error").text("Note is more than 255 characters!").removeClass("hide");
-<% else %>
- $("#history_log_error").addClass("hide");
- $('#history_popup form').trigger("reset");
-
- var url = $("#request_history_log").data("url");
- $( "#request_history_log" ).load( url);
-
+ <% if @aud.comment.blank? %>
+ $( "<%= log_error_selector %>" ).text("Note is blank. Please fill it in.").removeClass("hide");
+ <% elsif @aud.comment.length > 255 %>
+ $( "<%= log_error_selector %>" ).text("Note is more than 255 characters!").removeClass("hide");
+ <% else %>
+ $( "<%= log_error_selector %>" ).addClass("hide");
+ $( "<%= form_reset_selector %>" ).trigger("reset");
+ <% if textarea_selector %>
+ $( "<%= textarea_selector %>" ).val("");
+ <% end %>
+ var url = $( "<%= log_url_selector %>" ).data("url");
+ $( "<%= log_url_selector %>" ).load(url);
+ <% end %>
<% end %>
diff --git a/app/views/request_wizard/_save_buttons.html.erb b/app/views/request_wizard/_save_buttons.html.erb
index e9bb4ce..7ddd794 100644
--- a/app/views/request_wizard/_save_buttons.html.erb
+++ b/app/views/request_wizard/_save_buttons.html.erb
@@ -2,13 +2,13 @@
-
- <%= link_to edit_request_path(@request), class: "btn btn-link" do %>
- Update Request
- <% end %>
-
- <%= link_to new_request_finish_path(@request), method: :post, class: "btn btn-success" do%>
- I am done, submit this request
+ <% if @request.items.where.not(status: 'deleted').exists? %>
+ <%= link_to edit_request_path(@request), class: "btn btn-link" do %>
+ Update Request
+ <% end %>
+ <%= link_to new_request_finish_path(@request), method: :post, class: "btn btn-success" do%>
+ I am done, submit this request
+ <% end %>
<% end %>
diff --git a/app/views/request_wizard/step_two.html.erb b/app/views/request_wizard/step_two.html.erb
index 4bfdd2f..62a4c9d 100644
--- a/app/views/request_wizard/step_two.html.erb
+++ b/app/views/request_wizard/step_two.html.erb
@@ -4,11 +4,15 @@
Please add the items you would like to put on reserve. You can add as many as you need.
+ You must add one item to create this request. You can still save this request for later without any items.
Start by clicking on the type of item you would like to add, then fill in the details and click the add button.
-<%= render partial: "request_wizard/save_buttons"%>
+
+ <%= render partial: "request_wizard/save_buttons"%>
+
+
<%= render partial: "items/add_item" %>
@@ -27,7 +31,3 @@
You must add at least one item in order for your request to be open
<% end %>
-
-
-
-<%= render partial: "request_wizard/save_buttons"%>
diff --git a/app/views/requests/_change_owner.html.erb b/app/views/requests/_change_owner.html.erb
index 479a65e..d4609a7 100644
--- a/app/views/requests/_change_owner.html.erb
+++ b/app/views/requests/_change_owner.html.erb
@@ -9,8 +9,7 @@
<%= simple_form_for @request, url: change_owner_request_path do |f| %>
Look up a new request owner by name
- <%= text_field :requester, :name, data: { autocomplete_source: users_path }, aria: { label: "Change owner"}, class: "input-lg form-control" %>
- <%= hidden_field :nil, nil, name: "requester_id", id: "requester_id" %>
+ <%= f.collection_select :requester_id, User.all, :id, :name, { prompt: "Choose a new owner" }, { class: "input-lg form-control" } %>
This change will be recorded in the audit trail
@@ -72,12 +86,12 @@
<%= f.input :reserve_location_id, collection: Location.active, required: true, hint: "Where do you want students to pick up your items?" %>
- <%= f.input :reserve_start_date, as: :string, readonly: ! current_user.admin?, required: false, hint: "Prefilled after term selection.",
- input_html: { id: "request_reserve_start_date", class: current_user.admin? ? "datepicker" : "" } %>
+ <%= f.input :reserve_start_date, as: :string, readonly: true, required: false, hint: "Prefilled after term selection.",
+ input_html: { id: "request_reserve_start_date", class: "" } %>
- <%= f.input :reserve_end_date, as: :string, readonly: ! current_user.admin?, required: false,
- input_html: { id: "request_reserve_end_date", class: current_user.admin? ? "datepicker" : "" } %>
+ <%= f.input :reserve_end_date, as: :string, readonly: true, required: false,
+ input_html: { id: "request_reserve_end_date", class: "" } %>
diff --git a/app/views/requests/_history_log_modal.html.erb b/app/views/requests/_history_log_modal.html.erb
index df8e572..05055e2 100644
--- a/app/views/requests/_history_log_modal.html.erb
+++ b/app/views/requests/_history_log_modal.html.erb
@@ -1,4 +1,4 @@
-<% if can?(:add_note, @request) %>
+
+<% end %>
diff --git a/app/views/requests/show.html.erb b/app/views/requests/show.html.erb
index b0e61c8..df8d288 100644
--- a/app/views/requests/show.html.erb
+++ b/app/views/requests/show.html.erb
@@ -130,14 +130,15 @@
<% if can?(:manage, @request) %>
Assigned to
<%= @request.assigned_to ? @request.assigned_to.name : "Nobody" %>
-
-
History Log
-
- Add a Note / History Log
-
+
<% else %>
Status
<%= @request.status ? @request.status.upcase : "Unknown" %>
+
+
Request History Log
+
+ View Log
+
<% end %>
@@ -191,19 +192,27 @@
-
-
-
Requested Items
-
+
+
Requested Items
+
<% if is_request_active(@request) %>
<%= render partial: "items/add_item" %>
<% end %>
-
+
+
+ <%= link_to request_copy_items_path(@request), remote: true, class: "btn btn-link blend" do %>
+ Copy Items
+ <% end %>
+ <%= link_to request_items_path(@request, status: Item::STATUS_DELETED), class: "btn btn-link blend" do %>
+ <%= @request.items.deleted.size %>
+ <% end %>
+
- <%if @request.items.active.size > 0 %>
+
+ <% if @request.items.active.size > 0 %>
<% @request.items.active.recent_first.each do |item| %>
<%= render item %>
<% end %>
@@ -217,25 +226,26 @@
<% end %>
-
<% if @request.status == Request::REMOVED %>
-
Removed Items
- <% @request.items.deleted.each do |item| %>
- <%= link_to request_item_path(@request, item), class: "btn btn-link blend", remote: true do %>
- <%= item.title %>
+ Removed Items
+ <% @request.items.deleted.each do |item| %>
+ <%= link_to request_item_path(@request, item), class: "btn btn-link blend", remote: true do %>
+ <%= item.title %>
<% end %>
- <% end %>
+ <% end %>
<% end %>
-
- <%= render partial: "request_wizard/save_buttons"%>
+
+
+ <%= render partial: "request_wizard/save_buttons"%>
+
<% if @request.status != Request::INCOMPLETE %>
<%= render partial: "change_status" %>
diff --git a/app/views/search/primo/create.js.erb b/app/views/search/primo/create.js.erb
index 3d89565..8b190f4 100644
--- a/app/views/search/primo/create.js.erb
+++ b/app/views/search/primo/create.js.erb
@@ -20,11 +20,10 @@ function use_this_record() {
$("#item_author").val(my_record.author);
$("#item_publisher").val(my_record.publisher);
$("#item_isbn").val(my_record.isbn_issn);
+ $("#item_other_isbn_issn").val(my_record.other_isbn_issn);
$("#item_callnumber").val(my_record.callnumber);
$("#item_edition").val(my_record.edition);
$("#item_publication_date").val(my_record.publication_date);
- $("#item_metadata_source").val(my_record.source);
- $("#item_metadata_source_id").val(my_record.ils_id);
$("#item_url").val(my_record.url); // URL will not be populated.
clear_primo_search();
diff --git a/config/routes.rb b/config/routes.rb
index ab91bb8..07411c5 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -78,6 +78,7 @@
post 'save_note' => 'request_history#create'
post :rollover
get :rollover_confirm
+ get 'item_history/:item_id', to: 'request_history#item_history', as: 'item_history'
end
resource :copy_items, only: %i[show new create], module: 'requests'
diff --git a/db/migrate/20240820132657_add_other_isbn_issn_to_items.rb b/db/migrate/20240820132657_add_other_isbn_issn_to_items.rb
new file mode 100644
index 0000000..5d642be
--- /dev/null
+++ b/db/migrate/20240820132657_add_other_isbn_issn_to_items.rb
@@ -0,0 +1,5 @@
+class AddOtherIsbnIssnToItems < ActiveRecord::Migration[7.0]
+ def change
+ add_column :items, :other_isbn_issn, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index b75fc4d..cdc4f03 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -111,6 +111,7 @@
t.string "issue"
t.string "ils_barcode"
t.boolean "physical_copy_required", default: false
+ t.string "other_isbn_issn"
end
create_table "loan_periods", id: :integer, charset: "utf8mb3", force: :cascade do |t|
diff --git a/test/controllers/items_controller_test.rb b/test/controllers/items_controller_test.rb
index 24a88de..66413fc 100644
--- a/test/controllers/items_controller_test.rb
+++ b/test/controllers/items_controller_test.rb
@@ -83,11 +83,18 @@ class ItemsControllerTest < ActionDispatch::IntegrationTest
## ADDITIONAL ACTIONS TESTS ##
- should 'change request status to open if new item is added' do
+ # should 'change request status to open if new item is added' do
+ # request = create(:request, status: Request::INPROGRESS)
+ # post request_items_path(@_request), params: { item: attributes_for(:item).except(:request) }
+ # r = get_instance_var(:request)
+ # assert_equal Request::OPEN, r.status, 'Status should be set to open'
+ # end
+
+ should 'request status should remain in progress when new item is added' do
request = create(:request, status: Request::INPROGRESS)
post request_items_path(@_request), params: { item: attributes_for(:item).except(:request) }
r = get_instance_var(:request)
- assert_equal Request::OPEN, r.status, 'Status should be set to open'
+ assert_equal Request::INPROGRESS, r.status, 'Status should in progress'
end
should 'change status' do