Skip to content

Commit

Permalink
Merge 2e2a93c into 5ecfe5d
Browse files Browse the repository at this point in the history
  • Loading branch information
jgreben committed Jul 11, 2018
2 parents 5ecfe5d + 2e2a93c commit d533017
Show file tree
Hide file tree
Showing 61 changed files with 521 additions and 64 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ Metrics/ClassLength:

Metrics/CyclomaticComplexity:
Max: 10
Exclude:
- 'app/models/ability.rb'

Metrics/PerceivedComplexity:
Max: 10
Exclude:
- 'app/models/ability.rb'

Metrics/MethodLength:
Max: 20
Expand Down
5 changes: 5 additions & 0 deletions app/assets/javascripts/accession_number_updates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
$(document).ready(function() {
$('table').DataTable();
} );
5 changes: 5 additions & 0 deletions app/assets/javascripts/accession_numbers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
$(document).ready(function() {
$('table').DataTable();
} );
3 changes: 1 addition & 2 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require forms
//= require_tree .
//= require html5_webshim
6 changes: 4 additions & 2 deletions app/assets/javascripts/authorized_users.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
jQuery(document).ready(function($) {
$(document).ready(function() {
$('table').DataTable();

$(".clickable-row").click(function() {
window.location = $(this).data("href");
});
});
} );
5 changes: 5 additions & 0 deletions app/assets/javascripts/batch_record_updates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
$(document).ready(function() {
$('table').DataTable();
} );
26 changes: 26 additions & 0 deletions app/assets/javascripts/digital_bookplates_batches.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
jQuery(document).ready(function($) {
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"non-empty-string-asc": function (str1, str2) {
if(str1 === "")
return 1;
if(str2 === "")
return -1;
return ((str1 < str2) ? -1 : ((str1 > str2) ? 1 : 0));
},
"non-empty-string-desc": function (str1, str2) {
if(str1 === "")
return 1;
if(str2 === "")
return -1;
return ((str1 < str2) ? 1 : ((str1 > str2) ? -1 : 0));
}
} );

$('table').DataTable({
columnDefs: [
{type: 'non-empty-string', targets: 0} // define 'name' column as non-empty-string type
]
});
});
36 changes: 36 additions & 0 deletions app/assets/javascripts/edi_error_reports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
jQuery(document).ready(function($) {
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"date-uk-pre": function ( a ) {
var ukDatea = a.split('/');
var yearWithoutTime = ukDatea[2].split(' ')[0];
return (yearWithoutTime + ukDatea[1] + ukDatea[0]) * 1;
},
"date-uk-asc": function ( a, b ) {
console.log("asc");
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"date-uk-desc": function ( a, b ) {
console.log("desc");
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
} );

$('table').DataTable({
"order": [[ 0, "desc" ]],
columnDefs: [
{ type: 'date-uk', targets: 0 } // define 'run' column as date
]
});

$('input#edi_errors_day').on('change', function() {
var url = window.location.href;
if (url.indexOf('?') > -1) {
url = url.substr(0, url.indexOf('?'));
}
url += '?day=' + this.value;
window.location.href = url;
})
});

3 changes: 3 additions & 0 deletions app/assets/javascripts/edi_invoices.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
jQuery(document).ready(function($) {
$('table').DataTable();
});
5 changes: 5 additions & 0 deletions app/assets/javascripts/encumbrance_reports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
jQuery(document).ready(function($) {
$('table').DataTable();
});
5 changes: 5 additions & 0 deletions app/assets/javascripts/endowed_funds_reports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
jQuery(document).ready(function($) {
$('table').DataTable();
});
5 changes: 5 additions & 0 deletions app/assets/javascripts/expenditure_reports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
jQuery(document).ready(function($) {
$('table').DataTable();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
jQuery(document).ready(function($) {
$('table').DataTable();
});
22 changes: 0 additions & 22 deletions app/assets/javascripts/forms.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
$(document).on('ready page:load', function () {
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"non-empty-string-asc": function (str1, str2) {
if(str1 === "")
return 1;
if(str2 === "")
return -1;
return ((str1 < str2) ? -1 : ((str1 > str2) ? 1 : 0));
},

"non-empty-string-desc": function (str1, str2) {
if(str1 === "")
return 1;
if(str2 === "")
return -1;
return ((str1 < str2) ? 1 : ((str1 > str2) ? -1 : 0));
}
} );
$('table').DataTable({
columnDefs: [
{type: 'non-empty-string', targets: 0} // define 'name' column as non-empty-string type
]
});
$("[data-toggle='tooltip']").tooltip();
});
2 changes: 1 addition & 1 deletion app/assets/javascripts/html5_webshim.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$(document).on('ready page:load', function() {
if (window.webshim && $('[data-behavior="rerun-date-picker"]').length > 0) {
if (window.webshim && $('[data-behavior="date-picker"]').length > 0) {
var webShimOptions = {
lazyCustomMessages: true,
replaceUI: true,
Expand Down
5 changes: 5 additions & 0 deletions app/assets/javascripts/sal3_batch_requests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
$(document).ready(function() {
$('table').DataTable();
} );
12 changes: 12 additions & 0 deletions app/controllers/edi_error_reports_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Controller to handle Edi Error Report requests
class EdiErrorReportsController < ApplicationController
load_and_authorize_resource
has_scope :day

def index
@edi_error_report = apply_scopes(EdiErrorReport).all
rescue StandardError => e
flash[:error] = e.message
redirect_to edi_error_reports_path
end
end
2 changes: 2 additions & 0 deletions app/controllers/edi_invoices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ class EdiInvoicesController < ApplicationController
load_and_authorize_resource
has_scope :vendfilter

def menu; end

def index
@edi_invoice = apply_scopes(EdiInvoice).all
end
Expand Down
4 changes: 3 additions & 1 deletion app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def initialize(current_user)
assign_user_permission if current_user
assign_batch_permission if /A|Y/ =~ current_user.unicorn_updates
alias_action :queue, :completed, to: :read
alias_action :menu, to: :read
end

def assign_basic_permission
Expand All @@ -28,8 +29,9 @@ def assign_staff_permission(current_user)
can %i[create read], Sal3BatchRequestsBatch if /A|Y/ =~ current_user.sal3_batch_req
can %i[read update download], Sal3BatchRequestsBatch if /A|Y/ =~ current_user.sal3_breq_edit
can :create, UserloadRerun if /A|Y/ =~ current_user.userload_rerun
can %i[read manage], EdiInvoice if /A|Y/ =~ current_user.edi_inv_manage
can :read, EdiInvoice if /Y/ =~ current_user.edi_inv_view
can :manage, EdiInvoice if /A|Y/ =~ current_user.edi_inv_manage
can :manage, EdiErrorReport if /A|Y/ =~ current_user.edi_inv_manage
end

def assign_admin_permission(current_user)
Expand Down
22 changes: 22 additions & 0 deletions app/models/edi_error_report.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Model for the Edi Error Report table
class EdiErrorReport < ActiveRecord::Base
# so we can use the database table column name 'type' which is normally a reserved keyword
# which rails uses to define the subclass of a model that should be loaded.
self.inheritance_column = 'inheritance_type'

scope :day, ->(day) { where(date_query, day.to_date) }

self.table_name = 'edi_error_report'

# The date queries for 'development' sqlite3 and 'production' Oracle SQL are different
# In order to test the application locally we need to check the database configuration
# against the environment to construct the correct query.
# (N.B. There may be a less hacky way to do this using the oracle_enhanced adapter or ruby-oci8...)
def self.date_query
if Rails.configuration.database_configuration[Rails.env]['database'] =~ /sqlite3/
'DATE(run) = ?'
else
'trunc(run) = ?'
end
end
end
3 changes: 3 additions & 0 deletions app/views/accession_number_updates/by_location.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<% content_for :javascript_includes do %>
<%= javascript_include_tag "accession_number_updates.js" %>
<% end %>
<h2>Accession numbers by location</h2>
<%= render partial: 'accession_num_message' %>
<h3><%= @location.pluck(:location)[0] %></h3>
Expand Down
3 changes: 3 additions & 0 deletions app/views/accession_number_updates/by_resource_type.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<% content_for :javascript_includes do %>
<%= javascript_include_tag "accession_number_updates.js" %>
<% end %>
<h2>Accession numbers by resource type</h2>
<%= render partial: 'accession_num_message' %>
<h3><%= @resource_type.pluck(:resource_type)[0] %></h3>
Expand Down
3 changes: 3 additions & 0 deletions app/views/accession_numbers/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<% content_for :javascript_includes do %>
<%= javascript_include_tag "accession_numbers.js" %>
<% end %>
<p id="notice"><%= notice %></p>

<h1>Accession Numbers</h1>
Expand Down
3 changes: 3 additions & 0 deletions app/views/authorized_users/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<% content_for :javascript_includes do %>
<%= javascript_include_tag "authorized_users.js" %>
<% end %>
<h1>Authorized Users</h1>

<%= link_to "Add a user", authorized_users_new_path, :class => "btn btn-primary",
Expand Down
3 changes: 3 additions & 0 deletions app/views/batch_record_updates/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<% content_for :javascript_includes do %>
<%= javascript_include_tag "batch_record_updates.js" %>
<% end %>
<div class="home-page-section">
<h1>Batch Record Updates</h1>
<% if current_user %>
Expand Down
4 changes: 4 additions & 0 deletions app/views/circulation_statistics_reports/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<% content_for :javascript_includes do %>
<%= javascript_include_tag "circulation_statistics_reports.js" %>
<% end %>
<h2>Circulation Statistics Report Request</h2>
<%= form_for @circulation_statistics_report, multipart: true, class: 'form-group' do |f| %>
<% if @circulation_statistics_report.errors.any? %>
Expand Down Expand Up @@ -199,3 +202,4 @@
<div class="pad"><%= link_to 'Main menu', root_path, class: 'btn btn-md btn-primary btn-full' %></div>
<HR>
<%= render 'shared/call_number_range_examples' %>
</div>
3 changes: 3 additions & 0 deletions app/views/digital_bookplates_batches/add_batch.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<% content_for :javascript_includes do %>
<%= javascript_include_tag "digital_bookplates_batches.js" %>
<% end %>
<h1>Digital Bookplates Batches</h1>
<h2>Add digital bookplate metadata to Symphony records</h2>

Expand Down
3 changes: 3 additions & 0 deletions app/views/digital_bookplates_batches/completed.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<% content_for :javascript_includes do %>
<%= javascript_include_tag "digital_bookplates_batches.js" %>
<% end %>
<h1>Digital Bookplates Batches Completed</h1>

<%= render 'batches' %>
Expand Down
3 changes: 3 additions & 0 deletions app/views/digital_bookplates_batches/delete_batch.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<% content_for :javascript_includes do %>
<%= javascript_include_tag "digital_bookplates_batches.js" %>
<% end %>
<h1>Digital Bookplates Batches</h1>
<h2>Delete digital bookplate metadata from Symphony records</h2>

Expand Down
3 changes: 3 additions & 0 deletions app/views/digital_bookplates_batches/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<% content_for :javascript_includes do %>
<%= javascript_include_tag "digital_bookplates_batches.js" %>
<% end %>
<div class="home-page-section">
<h1>Digital Bookplates</h1>
<% if can? :read, DigitalBookplatesBatch %>
Expand Down
3 changes: 3 additions & 0 deletions app/views/digital_bookplates_batches/queue.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<% content_for :javascript_includes do %>
<%= javascript_include_tag "digital_bookplates_batches.js" %>
<% end %>
<h1>Digital Bookplates Batches in Queue</h1>

<%= render 'batches' %>
Expand Down
42 changes: 42 additions & 0 deletions app/views/edi_error_reports/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<% content_for :javascript_includes do %>
<%= javascript_include_tag "edi_error_reports.js" %>
<% end %>
<div class="home-page-section">
<h1>EDIFACT invoice errors</h1>
<div>
<%= link_to 'Show errors for all days', { controller: 'edi_error_reports', action: 'index' }, class: 'btn btn-default', style: 'margin-bottom: 10px' %>
<%= link_to 'Show errors for today', { controller: 'edi_error_reports', action: 'index', day: "#{Time.zone.today}" }, class: 'btn btn-default', style: 'margin-bottom: 10px' %>
</div>
<div class="field">
Show errors for selected date:
<%= date_field('edi_errors', 'day', value: params[:day] || "#{Time.zone.today}",
'data-behavior': 'date-picker',
max: Time.zone.today) %>
</div>
<table class="table-striped" id="table-date">
<thead>
<tr>
<th>Run</th>
<th>Type</th>
<th>Error</th>
<th>Error level</th>
</tr>
</thead>
<tbody>
<% @edi_error_report.each do |eer| %>
<tr class='<%= cycle("odd", "even") %>'>
<td><%= eer.run.present? ? eer.run.strftime('%x %H:%M') : '' %></td>
<td><%= eer.type %></td>
<td><%= eer.error %></td>
<td><%= eer.err_lvl %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="btn-group">
<%= main_menu_button %>
</div>
<div class="btn-group">
<%= edi_menu_button %>
</div>
</div>
5 changes: 4 additions & 1 deletion app/views/edi_invoices/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<% content_for :javascript_includes do %>
<%= javascript_include_tag "edi_invoices.js" %>
<% end %>
<div class="home-page-section">
<h1>EDIFACT invoice management</h1>
<h1>EDIFACT invoices</h1>
<div style='margin-left: 20px'>
Filter by vendor:
<%= select_tag 'vendor', options_for_select(EdiInvoice.vendor_filter, selected: params[:vendfilter]),
Expand Down

0 comments on commit d533017

Please sign in to comment.