Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
start moving nav categories into sidebar
Browse files Browse the repository at this point in the history
@jkleinsc I’m running into an issue where the category I put into the
sidebar isn’t rendering there. Is that expected? What do I need to
modify to make it render in the new location (navigation.hbs)?
  • Loading branch information
Joel Glovier committed May 29, 2015
1 parent d611918 commit 7c35816
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 70 deletions.
47 changes: 1 addition & 46 deletions app/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,7 @@
<h1 class="view-title">What would you like to do?</h1>

<div class="splash-nav">
{{#if userCan_inventory}}
<div class="nav-category">
<header class="category-header">
<h2 class="primary-section">
{{#link-to 'inventory' class="primary-section-link" }}
<span class="mega-octicon octicon-package"></span>
Inventory
{{/link-to}}
</h2>
<div class="panel-options">
<a href="#" class="hidden-link-list-trigger">
<span class="mega-octicon octicon-gear"></span>
</a>
<nav class="hidden-link-list">
<h4>More options</h4>
<a href="#" class="setting-link">Pin to Nav</a>
<a href="#" class="setting-link">Set as default view</a>
</nav>
</div>
</header>
<nav class="category-links">
{{#if userCan_add_inventory_request}}
{{#link-to 'inventory.index' class="sub-section-link"}}
Requests
<span class="octicon octicon-chevron-right"></span>
{{/link-to}}
{{/if}}
{{#if userCan_inventory}}
{{#link-to 'inventory.listing' class="sub-section-link"}}
Items
<span class="octicon octicon-chevron-right"></span>
{{/link-to}}
{{#if userCan_add_inventory_item}}
{{#link-to 'inventory.batch' 'new' class="sub-section-link"}}
Inventory Received
<span class="octicon octicon-plus"></span>
{{/link-to}}
{{/if}}
{{#link-to 'inventory.reports' class="sub-section-link"}}
Reports
<span class="octicon octicon-chevron-right"></span>
{{/link-to}}
{{/if}}
</nav>
</div>
{{/if}}

{{#if userCan_patients}}
<div class="nav-category">
<header class="category-header">
Expand Down
27 changes: 3 additions & 24 deletions app/templates/navigation.hbs
Original file line number Diff line number Diff line change
@@ -1,31 +1,10 @@
<nav class="sidebar-nav" role="navigation">

<header class="sidebar-nav-header sidebar-nav-section">
<a class="sidebar-nav-logo" href="#">
{{partial "components/logo-svg"}}
</a>
<a href="#" class="settings-trigger">
<span class="mega-octicon octicon-gear"></span>
</a>
<nav class="settings-nav">
{{#if session.isAuthenticated}}
<a href="#" class="logout" {{ action 'invalidateSession' }}>Logout</a>
{{else}}
{{#link-to 'login'}}Login{{/link-to}}
{{/if}}
</nav>
</header>

{{#if allowSearch}}
<div class="sidebar-nav-search sidebar-nav-section" role="search">
<div class="form-group">
{{text-search valueBinding="searchText" autofocus="true" placeholder="Search" class="form-control"}}
</div>
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
</div>
{{/if}}
{{partial "sidebar_nav/header"}}

{{partial "sidebar_nav/search"}}

{{partial "sidebar_nav/primary_nav"}}

<p class="sync-status">{{syncStatus}}</p>

Expand Down
15 changes: 15 additions & 0 deletions app/templates/sidebar_nav/header.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<header class="sidebar-nav-header sidebar-nav-section">
<a class="sidebar-nav-logo" href="#">
{{partial "components/logo-svg"}}
</a>
<a href="#" class="settings-trigger">
<span class="mega-octicon octicon-gear"></span>
</a>
<nav class="settings-nav">
{{#if session.isAuthenticated}}
<a href="#" class="logout" {{ action 'invalidateSession' }}>Logout</a>
{{else}}
{{#link-to 'login'}}Login{{/link-to}}
{{/if}}
</nav>
</header>
43 changes: 43 additions & 0 deletions app/templates/sidebar_nav/primary_nav.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<div class="primary-nav">

{{#if userCan_inventory}}
<div class="sidebar-nav-section primary-nav-item">

<div class="category-title">
<h2>
{{#link-to 'inventory' class="primary-section-link" }}
<span class="mega-octicon octicon-package"></span>
Inventory
{{/link-to}}
</h2>
</div>

<div class="category-sub-items">
{{#if userCan_add_inventory_request}}
{{#link-to 'inventory.index' class="sub-section-link"}}
Requests
<span class="octicon octicon-chevron-right"></span>
{{/link-to}}
{{/if}}
{{#if userCan_inventory}}
{{#link-to 'inventory.listing' class="sub-section-link"}}
Items
<span class="octicon octicon-chevron-right"></span>
{{/link-to}}
{{#if userCan_add_inventory_item}}
{{#link-to 'inventory.batch' 'new' class="sub-section-link"}}
Inventory Received
<span class="octicon octicon-plus"></span>
{{/link-to}}
{{/if}}
{{#link-to 'inventory.reports' class="sub-section-link"}}
Reports
<span class="octicon octicon-chevron-right"></span>
{{/link-to}}
{{/if}}
</div>

</div>
{{/if}}

This comment has been minimized.

Copy link
@jglovier

jglovier May 29, 2015

Member

@jkleinsc this code isn't rendering anything in the view. I pulled it out from index.hbs and dropped it in here (with some slightly reformatted markup), but it doesn't render in the view, only the wrapping div.primary-nav gets rendered.

I did a bit more digging around and I'm guessing it has to do with app/controllers/navigation.js and app/controllers/index.js?

This comment has been minimized.

Copy link
@jkleinsc

jkleinsc May 29, 2015

Member

@jglovier Yes! All of the {{#if conditionals are looking for values that are currently defined in app/controllers/index.js. The following code needs to be moved over:

import UserSession from "hospitalrun/mixins/user-session";
export default Ember.Controller.extend(UserSession, {
    indexLinks: [
        'Appointments',
        'Labs',
        'Imaging',
        'Inventory',
        'Medication',
        'Patients',
        'Users'
    ],

    setupPermissions: function() {
        var permissions = this.get('defaultCapabilities');
        for(var capability in permissions) {
            if (this.currentUserCan(capability)) {
                this.set('userCan_'+capability, true);
            }
        }
    }.on('init'),

This comment has been minimized.

Copy link
@jglovier

jglovier May 29, 2015

Member

@jkleinsc 🤘 ⚡ ❤️; I actually tried, but apparently I didn't copy it right. Working now! Thanks!

This comment has been minimized.

Copy link
@jglovier

jglovier May 30, 2015

Member

@jkleinsc so oddly enough, when I login initially the sidebar items don't display. But once I refresh the page they do. How does that make any sense? This is consistent behavior. If you check out the branch and run the server, you should see it.


</div>
8 changes: 8 additions & 0 deletions app/templates/sidebar_nav/search.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{#if allowSearch}}
<div class="sidebar-nav-search sidebar-nav-section" role="search">
<div class="form-group">
{{text-search valueBinding="searchText" autofocus="true" placeholder="Search" class="form-control"}}
</div>
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
</div>
{{/if}}

1 comment on commit 7c35816

@jkleinsc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jglovier Not sure I follow. What are you expecting to see and what are you actually seeing

Please sign in to comment.