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

Section page displays subsection details links #938

Merged
merged 2 commits into from
May 10, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/app/js/controllers/sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ angular.module('sgApp')
}
}

$scope.isMainSection = function(section) {
return section.reference.indexOf('.') === -1;
};

$scope.isEmptyMainSection = function(section) {
return section.reference.indexOf('.') === -1 && !section.renderMarkup && (!section.modifiers || section.modifiers.length === 0);
};
Expand Down
1 change: 1 addition & 0 deletions lib/app/views/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ <h1 ng-if="status.hasError">Error: {{status.error.name}}</h1>
</a>
</li>
</ul>
</li>
</ul>
</nav>

Expand Down
29 changes: 28 additions & 1 deletion lib/app/views/sections.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
<article
sg-section
ng-repeat="section in sections.data | filter: filterSections | filter: search">
</article>
</article>
<div ng-repeat="section in sections.data | filter: filterMainSections()" ng-if="isMainSection(section) && isActive(section)">
<a class="sg"
ng-class="{ 'active': (currentSection === section.reference), 'sub-active': (currentSection.indexOf(section.reference + '.') === 0) }"
ng-click="clearSearch()"
ui-sref="app.index.section({section: section.reference})">
</a>
<ul>
<li ng-repeat="subsection in sections.data | filter: filterSubsections(section)">
<a class="sg"
ng-class="currentSection === subsection.reference ? 'active' : ''"
ng-click="clearSearch()"
ui-sref="app.index.section({section: subsection.reference})">
<span class="sg-ref">{{ subsection.reference }}</span> <span ng-bind-html="subsection.header | unsafe"></span>
<ul class="sg-nav-subsubsection">
<li ng-repeat="subsubsection in sections.data | filter: filterSubsections(subsection)">
<a class="sg"
ng-class="currentSection === subsubsection.reference ? 'active' : ''"
ng-click="clearSearch()"
ui-sref="app.index.section({section: subsubsection.reference})">
<span class="sg-ref">{{ subsubsection.reference }}</span> <span ng-bind-html="subsubsection.header | unsafe"></span>
</a>
</li>
</ul>
</a>
</li>
</ul>
</div>
10 changes: 10 additions & 0 deletions test/angular/unit/controllers/sections.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ describe('SectionsCtrl', function() {
});

describe('empty main section detection', function() {
it('should return true if main section', function() {
var section = {
header: 'Section header text',
reference: '1',
renderMarkup: '',
markup: ''
};
expect(scope.isMainSection(section)).to.eql(true);
});

it('should return true for empty main sections', function() {
var section = {
header: 'Section header text',
Expand Down