Skip to content

Commit 1890e49

Browse files
committed
app: Split Alma item set env dropdowns
This makes the production and sandbox dropdown elements completely separate. This should resolve the issue where the sandbox element sometimes overrides the production element, causing the wrong item set to be written to. Closes: AP-560
1 parent ba0dbd0 commit 1890e49

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

app/controllers/alma_item_set_controller.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'date'
22

33
class AlmaItemSetController < ApplicationController
4+
VALID_ENVS = %w(production sandbox)
45

56
# TODO: - Need to make sure only certain staff access this page
67
before_action :authorize!
@@ -14,7 +15,11 @@ def index
1415
# rubocop:disable Metrics/AbcSize
1516
def update
1617
env = params[:alma_env]
17-
alma_set_id = params[:alma_set_id]
18+
unless env.in? VALID_ENVS
19+
redirect_to alma_item_set_url, warning: 'Invalid environment specified', status: :see_other and return
20+
end
21+
22+
alma_set_id = params["alma_set_id_#{env}".to_sym]
1823
num = params[:note_num]
1924

2025
note = new_note(params[:note_value], params[:initials])

app/views/alma_item_set/index.html.erb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,21 @@
1717
<%= f.label("#{rb_alma_env}_sandbox".to_sym, "Sandbox") %>
1818
</div>
1919
<%# Set Name %>
20-
<div class="form-label form-group required mt-4">
21-
<%= label_tag(:alma_set_id, 'Alma Set Name:', class: 'control-label') %>
20+
<div id="prod-drop-down">
21+
<div class="form-label form-group required mt-4">
22+
<%= label_tag(:alma_set_id_production, 'Production Alma Set Name:', class: 'control-label') %>
23+
</div>
24+
<div class="form-input required">
25+
<%= f.select(:alma_set_id_production, @production_sets, {}, {:class => 'form-control'}) %>
26+
</div>
2227
</div>
23-
<div class="form-input required">
24-
<%# f.text_field(:alma_set_name, class: 'narrow form-control add-required', aria: { required: true }, required: true, autofocus: true) %>
25-
<%= f.select(:alma_set_id, @production_sets, {}, {:class => 'form-control', :id => 'prod-drop-down'}) %>
26-
<%= f.select(:alma_set_id, @sandbox_sets, {}, {:class => 'form-control', :id => 'sand-drop-down'}) %>
28+
<div id="sand-drop-down">
29+
<div class="form-label form-group required mt-4">
30+
<%= label_tag(:alma_set_id_sandbox, 'Sandbox Alma Set Name:', class: 'control-label') %>
31+
</div>
32+
<div class="form-input required">
33+
<%= f.select(:alma_set_id_sandbox, @sandbox_sets, {}, {:class => 'form-control'}) %>
34+
</div>
2735
</div>
2836
<%# Note Number %>
2937
<div class="form-label form-group mt-4">

0 commit comments

Comments
 (0)