Skip to content

Commit

Permalink
Merge pull request #524 from concord-consortium/158595244-fix-cuke-na…
Browse files Browse the repository at this point in the history
…vigation

158595244 Final Navigation
  • Loading branch information
scytacki authored Aug 27, 2018
2 parents 6fd4598 + b95abc7 commit b7c6dba
Show file tree
Hide file tree
Showing 25 changed files with 111 additions and 263 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
global:
- ARTIFACTS_BUCKET=cc-travis-artifacts
- CC_TEST_REPORTER_ID=555af44da071264ef9c30bc5d16bcaceee2b8c2e40cccdbc74fc2b7db9839a92
- PORTAL_PAGES_LIBRARY_URL=https://portal-pages.concord.org/library
before_install:
- "export DISPLAY=:99.0"
- pip install --user awscli
Expand Down
5 changes: 4 additions & 1 deletion app/assets/javascripts/lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@
this.handle = lightbox;

Lightbox.add(this);

// 2018-08-20 NP: To drop a modal shadow over items such as #navigation
// this value must be at least:
// 2(content + shadow) + the other component's z-index.
lightbox.setZIndex(3);
lightbox.setContent(config.content);
if (typeof config.title === "string") {
lightbox.setHeader(config.title);
Expand Down
122 changes: 3 additions & 119 deletions app/assets/stylesheets/web/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ body#tinymce {

#primary {
display: inline-block;
margin: 57px 0 0 125px;
margin: 0px 0px 120px 20px;

min-height: 400px;
overflow: auto;
padding: 0;
Expand Down Expand Up @@ -665,76 +666,6 @@ li.item_selectable {

/* ------- #secondary ------- */

#secondary {
background: #ea6d2f;
color: #313131;
display: inline-block;
font: 100 16px museo-sans, verdana, helvetica, arial, sans-serif;
height: auto;
margin: 20px 0 50px 0;
padding: 0 0 30px;
vertical-align: top;
a {
color: #fff;
display: inline-block;
margin: 0;
padding: 0;
width: 100%; }
a:link { background: transparent; }
a:visited { background: transparent; }
a:hover { color: #313131; }
a:active { color: #313131; }
a.selected {
color: #313131;
font-weight: 500;
}
h2 {
color: #555555;
font: bold 1.3em Arial, Helvetica, sans-serif !important;
margin: 10px 0 10px 20px; }
ul {
list-style: none;
margin: 20px 0 0;
padding: 0; }
li {
color: #ee864e;
list-style: none;
margin: 20px;
padding: 0;
li { font-size: 14px; }
strong {
display: block;
font-weight: normal;
padding: 5px 20px; } }
ul.create {
border-top: none; }
#utility-links {
background: #f5f5f5;
padding: 20px;
a {
color: #ea6d2f;
font-size: 12px;
font-weight: 500;
padding: 0;
text-transform: uppercase;
}
li {
margin: 10px 0;
}
ul.aux-links {
border-top: solid 1px #ccc;
margin: 20px 0 0;
padding-top: 8px;
a {
font-weight: 100;
}
}
}
.secondary-mobile-menu-toggle {
display: none;
}
}

.user-info-box {
background: white;
margin: 10px 10px 20px;
Expand Down Expand Up @@ -2132,54 +2063,7 @@ span.badge {
padding-bottom: 30px;
}
}
#secondary {
padding-bottom: 0;

#utility-links {
padding-bottom: 0;

ul.aux-links {
border: none;
}
}

.padded_content {
display: none;
transition: .2s;
}
.secondary-mobile-menu-toggle {
color: #fff;
cursor: pointer;
display: block;
font-weight: 500;
padding: 20px;
position: relative;

&:after {
content: "\e905";
font-family: "icomoon";
font-size: 12px;
margin: 5px 0 0 10px;
position: absolute;
right: 20px;
transition: .2s;
}
}

&.open {
.padded_content {
display: block;
transition: .2s;
}
.secondary-mobile-menu-toggle {

&:after {
content: "\e906";
}
}
}
}


.classdata {
td {
display: block;
Expand Down
12 changes: 12 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ def switch
redirect_to home_path
end

# GET users/<id>/switch_back
# Doesn't require posting hidden form fields.
def switch_back
original_user_id = session[:original_user_id]
if original_user_id
switch_to = User.find(original_user_id)
sign_out self.current_visitor
sign_in switch_to
end
redirect_to home_path
end

def update
if params[:commit] == "Cancel"

Expand Down
30 changes: 20 additions & 10 deletions app/helpers/navigation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def show_admin_links
end

def show_switch_user_link
# TODO: @original_user isn't available to us probably...
@original_user && @original_user != current_visitor
end

Expand Down Expand Up @@ -112,7 +111,8 @@ def admin_link_params
{
id: '/admin',
label: nav_label('admin'),
url: admin_path
url: admin_path,
sort: 2
}
end

Expand All @@ -131,7 +131,8 @@ def clazz_links_for_student
clazz_links << {
id: "/#{clazz.id}",
label: clazz_label(clazz),
url: url_for(clazz) }
url: url_for(clazz)
}
end
clazz_links
end
Expand All @@ -143,7 +144,8 @@ def clazz_links_for_teacher
{
id: "/classes",
label: nav_label("classes"),
type: NavigationService::SECTION_TYPE
type: NavigationService::SECTION_TYPE,
sort: 4
}
]
clazzes.each do |clazz|
Expand Down Expand Up @@ -184,12 +186,14 @@ def clazz_links_for_teacher
id: "/classes/add",
label: "Add Class",
divider: true,
url: new_portal_clazz_path
url: new_portal_clazz_path,
sort: 10
}
clazz_links << {
id: "/classes/manage",
label: "Manage Classes",
url: manage_portal_clazzes_url
url: manage_portal_clazzes_url,
sort: 11
# link_to 'Manage Classes', manage_portal_clazzes_url, :class=>"pie", :id=>"btn_manage_classes"
}
clazz_links
Expand All @@ -210,7 +214,8 @@ def project_link(project_link_spec)
id: project_link_spec.link_id || "/resources/#{project_link_spec.name}",
label: project_link_spec.name,
url: project_link_spec.href,
popOut: project_link_spec.pop_out
popOut: project_link_spec.pop_out,
sort: project_link_spec.position
}
end

Expand All @@ -225,16 +230,21 @@ def project_links
links.unshift({
id: "/resources",
label: nav_label('resources'),
type: NavigationService::SECTION_TYPE
type: NavigationService::SECTION_TYPE,
sort: 5
})
else
[]
end
end

def switch_user_link
# TODO: Make an API to switch users.
{label: "Switch Back", id: "switch", url: "/users/switch", sort: 2 }
{
label: nav_label('switch_back'),
id: "switch",
url: switch_back_user_path(current_visitor),
sort: 2
}
end


Expand Down
2 changes: 1 addition & 1 deletion app/models/admin/project_link.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Admin::ProjectLink < ActiveRecord::Base
self.table_name = "admin_project_links"
belongs_to :project, :class_name => 'Admin::Project'
attr_accessible :href, :name, :project_id, :link_id, :pop_out
attr_accessible :href, :name, :project_id, :link_id, :pop_out, :position
validates :href, :name, :link_id, :presence => true
end
4 changes: 4 additions & 0 deletions app/views/admin/projects/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
%td ID: (eg: '/resources/help'):
%td
= link_form.text_field :link_id
%tr
%td Position: (default: '5'):
%td
= link_form.text_field :position
%tr
%td Open link in new window:
%td
Expand Down
62 changes: 5 additions & 57 deletions app/views/shared/_left_menu.html.haml
Original file line number Diff line number Diff line change
@@ -1,58 +1,6 @@
-# TODO: possible refactoring to make more clazzes specific.
-# Clazz navigation: top_node could be course, teacher, student ...
-# 2018-07-06 NP: When we get all the blockers fixed, navigtion can use services....
-# - unless @wide_content_layout
-# :javascript
-# PortalPages.renderNavigation(Portal.API_V1.getNavigation(), 'clazzes_nav')
- # Renders Navigation React component, configured by `getNavigation()`, into #clazzes_nav
- # See https://github.com/concord-consortium/portal-pages/blob/master/src/library/library.js
#clazzes_nav
#utility-links
%p
Welcome,
%br
%strong
= "#{current_visitor.name}!"
%ul
- if current_settings && ((current_settings.help_type == 'external url') || (current_settings.help_type == 'help custom html'))
%li
%a{:href => '/help', :target => '_blank', :class => 'help-link'}
%i{:class => 'icon-search'}
&nbsp;Help
%li
%a{:href => preferences_user_path(current_visitor)}
%i{:class => 'icon-settings'}
&nbsp;Settings
- if current_user && !current_user.portal_student
%li
%a{:href => favorites_user_path(current_visitor)}
%i{:class => 'icon-favorite'}
&nbsp;Favorites

- if @original_user != current_visitor
- switch_user_form_id = "switch_user_id_#{@original_user.id}"
%a{:href => 'javascript: void(0);', :onclick => "$('#{switch_user_form_id}').submit();"}
%i{:class => 'icon-login'}
&nbsp;Switch Back
= form_for @original_user, :url => switch_user_path(@original_user), :html => { :method => :put,:class=> "hidden" ,:id=> switch_user_form_id} do |form|
= hidden_field_tag 'user[id]', @original_user.id
= hidden_field_tag 'commit', 'Switch'
- if current_visitor.has_role?('admin', 'manager', 'researcher') || current_visitor.portal_teacher
%ul.aux-links
- if current_visitor.has_role?('admin', 'manager','researcher') || current_visitor.is_project_admin? || current_visitor.is_project_researcher?
%li= link_to 'Admin', admin_path
- current_visitor.projects.each do |project|
- project.links.each do |link|
%li= link_to link.name, link.href

- if top_node
.secondary-mobile-menu-toggle{onclick: "toggleSecondaryMenu()"}
Menu
.padded_content
= render :partial => 'portal/clazzes/clazzes_list', :locals => {:top_node => top_node, :selects => selects}
- if top_node.is_a? Portal::Teacher
.create{:id=>dom_id_for(top_node, :nav_list_create_class)}
.create_link
= link_to 'Add a New Class', new_portal_clazz_path, :class=>"pie", :id=>"btn_create_class"
.manage_classes_link
= link_to 'Manage Classes', manage_portal_clazzes_url, :class=>"pie", :id=>"btn_manage_classes"
:javascript
var navOpts = Portal.API_V1.getNavigation()
PortalPages.renderNavigation(Portal.API_V1.getNavigation(), 'clazzes_nav')
5 changes: 2 additions & 3 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ en:
ErrorLoggedInAsStudent: |
You are logged in as a student in another window.
Please log out, and register again.
ErrorNotAllowed: |
You are not allowed to perform this function.
Navigation:
greeting: Hello,
help: Help
Expand All @@ -167,6 +164,8 @@ en:
class_setup: Class Setup
full_status: Full Status
links: Links
switch_back: Switch back

'en-HAS':
activerecord:
models:
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
put :suspend
put :unsuspend
put :switch
get :switch_back
get :favorites
get :preferences
put :preferences
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPositionToAdminProjectLinks < ActiveRecord::Migration
def change
add_column :admin_project_links, :position, :integer, :default => 5
end
end
Loading

0 comments on commit b7c6dba

Please sign in to comment.