-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from mlibrary/history-settings
History Settings
- Loading branch information
Showing
19 changed files
with
349 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.banner { | ||
background: var(--color-teal-200); | ||
padding: var(--space-x-small) 0; | ||
* { | ||
color: var(--color-neutral-400); | ||
} | ||
m-icon { | ||
position: relative; | ||
margin-right: var(--space-xx-small); | ||
top: var(--space-xxx-small); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
form[method="post"] { | ||
m-icon { | ||
position: relative; | ||
margin-right: var(--space-xx-small); | ||
top: var(--space-xxx-small); | ||
} | ||
|
||
#text-notifications:not(:checked) ~ .sms-number-container { | ||
display: none; | ||
} | ||
|
||
#sms-number:invalid + #sms-number-description { | ||
color: var(--color-pink-500); | ||
} | ||
|
||
.retain-history-option { | ||
input[type="radio"] { | ||
&:checked + label m-icon[name="radio-button-unchecked"] { | ||
display: none; | ||
} | ||
&:not(:checked) + label m-icon[name="radio-button-checked"] { | ||
display: none; | ||
} | ||
&:focus + label m-icon { | ||
outline: 0; | ||
box-shadow: 0 0 0 2px var(--color-maize-400),0 0 0 3px var(--color-neutral-400); | ||
border-radius: 2px; | ||
} | ||
} | ||
m-icon { | ||
color: var(--color-teal-500); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
@import "defaults", "base", "utilities", "focus", "site-navigation", | ||
"horizontal-navigation", "site-footer", "overview-cards", "loans", | ||
"empty-state-container", "buttons", "pagination", "messages", | ||
"text-notifications", "tags", "renew", "dropdown", | ||
"maybe-design-system/controls"; | ||
"text-notifications", "tags", "banner", "renew", "dropdown", | ||
"patron", "maybe-design-system/controls"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
class SessionPatron | ||
extend Forwardable | ||
def_delegators :@alma_patron, :uniqname, :full_name, :can_book? | ||
|
||
def initialize(uniqname) | ||
@alma_patron = Patron.for(uniqname: uniqname) | ||
@patron = Patron.for(uniqname: uniqname) | ||
end | ||
def to_h | ||
{ | ||
uniqname: @alma_patron.uniqname, | ||
full_name: @alma_patron.full_name, | ||
can_book: @alma_patron.can_book? | ||
uniqname: @patron.uniqname, | ||
full_name: @patron.full_name, | ||
can_book: @patron.can_book?, | ||
confirmed_history_setting: @patron.confirmed_history_setting? | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,10 +95,10 @@ | |
# :nocov: | ||
|
||
get '/' do | ||
session[:uniqname] = '[email protected]' if !session[:uniqname] | ||
session[:full_name] = 'Julian Tutor' if session[:uniqname] == '[email protected]' | ||
session[:can_book] = true if session[:uniqname] == '[email protected]' | ||
|
||
if !session[:uniqname] | ||
patron = SessionPatron.new('[email protected]') | ||
patron.to_h.each{|k,v| session[k] = v} | ||
end | ||
test_users = [ | ||
{ | ||
label: 'Graduate student (few)', | ||
|
@@ -241,10 +241,20 @@ | |
redirect 'https://apps.lib.umich.edu/my-account/favorites' | ||
end | ||
|
||
get '/settings' do | ||
#session[:uniqname] = 'tutor' #need to get this from cosign? | ||
patron = Patron.for(uniqname: session[:uniqname]) | ||
erb :patron, :locals => {patron: patron} | ||
namespace '/settings' do | ||
get '' do | ||
patron = Patron.for(uniqname: session[:uniqname]) | ||
erb :patron, :locals => {patron: patron} | ||
end | ||
post '/history' do | ||
response = Patron.set_retain_history(uniqname: session[:uniqname], retain_history: params[:retain_history]) | ||
if response.code == 200 | ||
flash[:success] = "<strong>Success:</strong> History Setting Successfully Changed" | ||
else | ||
flash[:error] = "<strong>Error:</strong> #{response.message}" | ||
end | ||
redirect "/settings" | ||
end | ||
end | ||
#TODO set up renew loan to handle renew in place with top part message??? | ||
post '/renew-loan' do | ||
|
@@ -262,12 +272,12 @@ | |
|
||
post '/sms' do | ||
patron = Patron.for(uniqname: session[:uniqname]) | ||
response = patron.update_sms(params["phone-number"]) | ||
response = patron.update_sms(params["text-notifications"] == "on" ? params["sms-number"] : "") | ||
if response.code == 200 | ||
if params["phone-number"] == '' | ||
flash[:success] = "<strong>Success:</strong> SMS Successfully Removed" | ||
else | ||
if params["text-notifications"] == "on" | ||
flash[:success] = "<strong>Success:</strong> SMS Successfully Updated" | ||
else | ||
flash[:success] = "<strong>Success:</strong> SMS Successfully Removed" | ||
end | ||
else | ||
flash[:error] = "<strong>Error:</strong> #{response.message}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"uniqname": "tutor", | ||
"retain_history": true, | ||
"confirmed": true, | ||
"updated_at": "2021-05-20T11:47:48.199-04:00" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.