Skip to content

Commit

Permalink
Form for shelf selection report
Browse files Browse the repository at this point in the history
  • Loading branch information
tallenaz committed Jul 7, 2016
1 parent af813d9 commit 1c21744
Show file tree
Hide file tree
Showing 28 changed files with 637 additions and 10 deletions.
19 changes: 19 additions & 0 deletions app/assets/javascripts/shelf_selection_reports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$(document).on('ready page:load', function() {
$('#shelf_selection_report_lib').change(function() {
$("#shelf_selection_report_loc_array option").remove();
lib = $('#shelf_selection_report_lib').find(':selected').text();
$.ajax({
url: '/shelf_selection_reports/home_locations',
cache: false,
data: { lib: lib },
success: function(html){
$('#shelf_selection_report_loc_array').append(html);
}
})
})
$('input[type="radio"]').click(function (){
$('#lc-show-hide').css('display', ($(this).val() == 'lc') ? 'block' : 'none');
$('#classic-show-hide').css('display', ($(this).val() == 'classic') ? 'block' : 'none');
$('#other-show-hide').css('display', ($(this).val() == 'other') ? 'block' : 'none');
})
});
23 changes: 23 additions & 0 deletions app/controllers/shelf_selection_reports_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
###
# Controller to handle the shelf selection report
###
class ShelfSelectionReportsController < ApplicationController
def new
@shelf_selection_report = ShelfSelectionReport.new
end

# def create
# @shelf_selection_report = ShelfSelectionReport.new(params[:shelf_selection_report])
# if @shelf_selection_report.valid?
# flash[:notice] = 'Shelf Selection Report params submitted!'
# redirect_to root_url
# else
# render action: 'new'
# end
# end

def home_locations
@home_locations = UniLibsLocs.home_locations_from(params[:lib])
render layout: false
end
end
8 changes: 8 additions & 0 deletions app/models/circulation_statistics_report_format.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# app/models/circulation_statistics_report_format.rb
class CirculationStatisticsReportFormat < ActiveRecord::Base
self.table_name = 'circ_stats_rpt_fmts'

def self.formats
select(:format).distinct.order(:format).pluck(:format)
end
end
8 changes: 8 additions & 0 deletions app/models/shelf_sel_item_cat1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# app/models/shelf_sel_item_cat1.rb
class ShelfSelItemCat1 < ActiveRecord::Base
self.table_name = 'shelf_sel_item_cat1s'

def self.item_category1s
select(:item_category1).distinct.order(:item_category1).pluck(:item_category1)
end
end
12 changes: 12 additions & 0 deletions app/models/shelf_sel_search.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# app/model/shelf_sel_search.rb
class ShelfSelSearch < ActiveRecord::Base
self.table_name = 'shelf_sel_searches'
# TODO: make saved_cursors return more than just my own
def self.saved_cursors(sunet_id)
own_saved_cursor(sunet_id)
end

def self.own_saved_cursor(sunet_id)
where(user_name: sunet_id).order(:search_name).pluck(:search_name, :user_name).map { |a| a.join(', ') }
end
end
8 changes: 8 additions & 0 deletions app/models/shelf_selection_item_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# app/models/shelf_selection_item_type.rb
class ShelfSelectionItemType < ActiveRecord::Base
self.table_name = 'shelf_sel_item_types'

def self.item_types
select(:item_type).distinct.order(:item_type).pluck(:item_type)
end
end
15 changes: 15 additions & 0 deletions app/models/shelf_selection_report.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# app/model/shelf_selection_report.rb
class ShelfSelectionReport
include ActiveModel::Model
attr_accessor :email, :lib, :loc_array, :cloc_diff, :fmt_array,
:itype_array, :icat1_array, :lang, :min_yr, :max_yr,
:min_circ, :max_circ, :shadowed, :digisent, :url,
:mhlds, :has_dups, :multvol, :multcop, :no_boundw,
:range_type, :lc_call_lo, :lc_call_hi, :classic_call_lo,
:classic_call_hi, :other_call_hi, :call_alpha, :subj_name,
:save_opt

def self.generic_options
[["Doesn't matter", 0], ['INCLUDE only', 1], ['EXCLUDE', 2]]
end
end
6 changes: 5 additions & 1 deletion app/models/uni_libs_locs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ class UniLibsLocs < ActiveRecord::Base
self.table_name = 'uni_libs_locs'

def self.libraries
UniLibsLocs.select(:library).distinct.where.not(library: nil).order(:library).pluck(:library)
select(:library).distinct.where.not(library: nil).order(:library).pluck(:library)
end

def self.home_locations_from(library)
select(:home_loc).distinct.where(library: library).order(:home_loc).pluck(:home_loc)
end
end
2 changes: 1 addition & 1 deletion app/views/management_reports/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ul>
<li><%= link_to "Circulation Statistics Report", 'circulation_statistics_report' %></li>
<li><%= link_to "Shelf Selection Report", 'shelf_selection_report' %></li>
<li><%= link_to "Shelf Selection Report", new_shelf_selection_report_path %></li>
<li><%= link_to "Expenditures Report", 'expenditures_report' %></li>
<li><%= link_to "Expenditures with Circ Stats Report", 'expenditures_with_circ_stats_report' %></li>
<li><%= link_to "Encumbrances Report", new_encumbrance_report_path %></li>
Expand Down
3 changes: 3 additions & 0 deletions app/views/shelf_selection_reports/home_locations.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% @home_locations.each do |home_location| %>
<option><%= home_location %></option>
<% end %>

0 comments on commit 1c21744

Please sign in to comment.