Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KG - Fix Service Request Navigation #1828

Merged
merged 4 commits into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ def redirect_to_login
end

def after_sign_in_path_for(resource)
stored_location_for(resource) || root_path
stored_location_for(resource) || root_path(srid: @service_request.id)
end

def after_sign_out_path_for(resource)
root_path(srid: @service_request.id)
end

def set_highlighted_link # default value, override inside controllers
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/service_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def show
end

def navigate
redirect_to eval("#{@forward}_service_request_path(srid: #{@service_request.id})")
redirect_to @forward
end

# service request wizard pages
Expand Down Expand Up @@ -314,8 +314,8 @@ def setup_navigation
if c = YAML.load_file(Rails.root.join('config', 'navigation.yml'))[current_page]
@step_text = c['step_text']
@css_class = c['css_class']
@back = c['back']
@forward = c['forward']
@back = eval("#{c['back']}_service_request_path(srid: #{@service_request.id})") if c['back']
@forward = eval("#{c['forward']}_service_request_path(srid: #{@service_request.id})") if c['forward']
end
end

Expand Down
6 changes: 4 additions & 2 deletions app/views/layouts/_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- url_params = defined?(service_request) ? { srid: service_request.try(:id) } : {}

%nav.navbar.navbar-default
.container-fluid
.navbar-header
Expand All @@ -27,6 +29,6 @@
- if current_user.present?
%span
= I18n.t('proper.navbar.logged_in', email: current_user.email)
= link_to t(:proper)[:navbar][:logout], destroy_identity_session_path, method: :delete, class: 'btn btn-warning'
= link_to t(:proper)[:navbar][:logout], destroy_identity_session_path(url_params), method: :delete, class: 'btn btn-warning'
- else
= link_to t(:proper)[:navbar][:login], new_identity_session_path(srid: service_request.try(:id)), class: 'btn btn-primary', id: 'login-link'
= link_to t(:proper)[:navbar][:login], new_identity_session_path(url_params), class: 'btn btn-primary', id: 'login-link'
1 change: 1 addition & 0 deletions app/views/service_requests/add_service.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ if !url.searchParams.get('srid')
url.searchParams.append('srid', "<%= @service_request.id %>")
window.history.pushState({}, null, url.href)
$('input[name=srid]').val("<%= @service_request.id %>")
$('#login-link').attr('href', "<%= new_identity_session_path(srid: @service_request.id) %>")
<% end %>